List of usage examples for com.google.gwt.uibinder.rebind UiBinderWriter warn
public void warn(XMLElement context, String message, Object... params)
From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.button.ButtonParser.java
License:Apache License
@Deprecated private void handleBackwardsCompatibleMenu(XMLElement elem, String fieldName, UiBinderWriter writer) throws UnableToCompleteException { Interpreter<Boolean> menuInterpreter = new SimpleInterpreter(elem.getNamespaceUri(), "menu"); Collection<XMLElement> menuChildElements = elem.consumeChildElements(menuInterpreter); if (menuChildElements.isEmpty()) { return;/*from w w w.j a va 2 s . c o m*/ } writer.warn(elem, "Use of <%s:menu> has been deprecated. Nesting a Menu widget is the new preferred approach.", elem.getPrefix()); if (menuChildElements.size() > 1) { writer.die(elem, "Buttons can contain only a single menu."); } String menu = writer.declareField(GxtClassnameConstants.MENU, elem); XMLElement menuNode = menuChildElements.iterator().next(); for (XMLElement child : menuNode.consumeChildElements()) { String childField = writer.parseElementToField(child); writer.addStatement("%s.add(%s);", menu, childField); } writer.addStatement("%s.setMenu(%s);", fieldName, menu); }
From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.util.ElementParserUtil.java
License:Apache License
/** * Consumes and applies attributes to given element * //from w w w .j av a 2s.c o m * @param elem * @param fieldName * @param type * @param writer * @throws UnableToCompleteException */ public static void applyAttributes(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { // first get the special Margin attribute ElementParserUtil.consumeRegionAttributes(elem, fieldName, writer); Map<String, JType> setterMethods = fetchSetterMethods(type); int attributeCount = elem.getAttributeCount(); // count backwards since we're consuming as we go for (int i = attributeCount - 1; i >= 0; i--) { // always get 0 because we're consuming them XMLAttribute attribute = elem.getAttribute(i); String setterMethod = "set" + initialCap(attribute.getName()); if (setterMethods.containsKey(setterMethod)) { JType setterType = setterMethods.get(setterMethod); String value; if ("float".equals(setterType.getQualifiedSourceName())) { value = attribute.consumeRawValue(); float floatValue = 0; try { floatValue = Float.parseFloat(value); } catch (NumberFormatException e) { writer.die(elem, "Cannot parse float value for attribute '%s'. Found %s.", attribute.getName(), value); } // assuming that we didn't die due to a NumberFormatException, we can use the value value = floatValue + "f"; } else if ("java.lang.Number".equals(setterType.getQualifiedSourceName())) { value = elem.consumeRawAttribute(attribute.getName()); } else { value = elem.consumeAttribute(attribute.getName(), setterType); } writer.addStatement("%s.%s(%s);", fieldName, setterMethod, value); } else { try { writer.findFieldType(elem); } catch (UnableToCompleteException e) { writer.warn(elem, "Found attribute without associated setter method: %s. IGNORING", attribute.getName()); } } } }