List of usage examples for com.google.gwt.uibinder.rebind XMLElement getPrefix
public String getPrefix()
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;// w w w .j a v a 2 s . c om } 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.form.SimpleComboBoxParser.java
License:Apache License
@Override public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { String parameterizedType = elem.consumeRawAttribute("type", "java.lang.String"); JClassType valueType = writer.getOracle().findType(parameterizedType); if (valueType == null) { writer.die(elem, "Found type attribute, but unable to resolve the value: %s", parameterizedType); }/*from www .j a v a 2s. c o m*/ for (XMLElement child : elem.consumeChildElements()) { if (!child.getNamespaceUri().equals(elem.getNamespaceUri())) { writer.die(elem, "Children of SimpleComboBox must be in the same namespace. Expected '%s' but found '%s'", elem.getPrefix(), child.getPrefix()); } String data = parseChildElement(child, valueType, writer); writer.addStatement("%s.add(%s);", fieldName, data); } if (elem.getAttribute("simpleValue") != null) { writer.addStatement("%s.setSimpleValue(%s);", fieldName, elem.consumeAttribute("simpleValue", valueType)); } }
From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.grid.GridParser.java
License:Apache License
@Override public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { JClassType listStoreType = writer.getOracle().findType(GxtClassnameConstants.LISTSTORE); String store = elem.consumeAttribute("store", listStoreType); if (store == null) { writer.die(elem, "Attribute 'store' is required"); }//w w w. j a va 2s. c om // have to set the following fields to null temporarily. // Due to the order of operations added, we need to construct // all ColumnConfigs before constructing a ColumnModel. writer.setFieldInitializer(fieldName, "null"); // new ColumnModel(columnConfig) String columnModel = writer.declareField(GxtClassnameConstants.COLUMNMODEL, elem); writer.setFieldInitializer(columnModel, "null"); JClassType arrayListType = writer.getOracle().findType(ArrayList.class.getName()); JClassType columnConfigType = writer.getOracle().findType(GxtClassnameConstants.COLUMNCONFIG); JParameterizedType parameterizedArrayListType = writer.getOracle() .getParameterizedType(arrayListType.isGenericType(), new JClassType[] { columnConfigType }); Map<String, JType> columnConfigSetterTypes = fetchColumnConfigProperties(columnConfigType); // List<ColumnConfig> String columnConfigList = writer.declareField(List.class.getName(), elem); writer.setFieldInitializerAsConstructor(columnConfigList, parameterizedArrayListType); for (XMLElement child : elem.consumeChildElements()) { if (!elem.getPrefix().equals(child.getPrefix())) { writer.die(child, "Child node of %s must use the same prefix. Expecting %s, but found %s", elem, elem.getPrefix(), child.getPrefix()); } if (!"column".equals(child.getLocalName())) { writer.die(child, "Only <%s:column> children are allowed. Found %s.", elem.getPrefix(), child); } String columnConfig = writer.declareField(GxtClassnameConstants.COLUMNCONFIG, elem); applyColumnConfigProperties(writer, columnConfigSetterTypes, child, columnConfig); writer.addStatement("%s.add(%s);", columnConfigList, columnConfig); } // now that we have all ColumnConfigs created and added to list, we can now // construct the ColumnModel and Grid writer.addStatement("%s = new %s(%s);", columnModel, GxtClassnameConstants.COLUMNMODEL, columnConfigList); writer.addStatement("%s = new %s(%s, %s);", fieldName, type.getQualifiedSourceName(), store, columnModel); }
From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.layout.BorderLayoutParser.java
License:Apache License
public void parse(XMLElement layoutElem, XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { createAndSetLayout(layoutElem, elem, fieldName, writer); Set<String> layoutRegionsSeen = new HashSet<String>(); for (XMLElement layoutDataElem : elem.consumeChildElements()) { if (!isValidChildElement(elem, layoutDataElem)) { StringBuilder sb = new StringBuilder("Child must be one of "); for (String name : DOCK_NAMES) { sb.append("<%1$s:").append(name).append(", "); }//from ww w. j a va2s. c o m sb.append("but found %2$s"); writer.die(elem, sb.toString(), elem.getPrefix(), layoutDataElem); } // have we already added this region? String region = layoutDataElem.getLocalName(); if (layoutRegionsSeen.contains(region)) { writer.die(elem, "Only one <%s:%s> is allowed", elem.getPrefix(), region); } layoutRegionsSeen.add(region); // delegate to super class layoutDataElem.setAttribute("type", "BorderLayoutData"); handleLayoutData(layoutDataElem, fieldName, writer); } }
From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.layout.RowLayoutParser.java
License:Apache License
@Override public void parse(XMLElement layoutElem, XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { String layout = createAndSetLayout(layoutElem, elem, fieldName, writer); JClassType orientationType = writer.getOracle().findType(GxtClassnameConstants.STYLEORIENTATION); String layoutOrientation = elem.consumeAttribute("rowLayoutOrientation", orientationType); if (layoutOrientation != null) { writer.warn(elem,//from w w w . j a v a 2s .c o m "rowLayoutOrientation has been deprecated. Please use nested <%s:layout orientation='%s'> instead.", elem.getPrefix(), layoutOrientation); writer.addStatement("%s.setOrientation(%s);", layout, layoutOrientation); } // override with layoutOrientation layoutOrientation = elem.consumeAttribute("layoutOrientation", orientationType); if (layoutOrientation != null) { writer.warn(elem, "layoutOrientation has been deprecated. Please use nested <%s:layout orientation='%s'> instead.", elem.getPrefix(), layoutOrientation); writer.addStatement("%s.setOrientation(%s);", layout, layoutOrientation); } handleChildren(elem, fieldName, writer); }
From source file:com.jhickman.web.gwt.gxtuibinder.elementparsers.LayoutContainerParser.java
License:Apache License
private boolean consumeLayout(XMLElement elem, String layoutContainerFieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException { boolean layoutFound = false; // locate child Element for (XMLElement layoutChild : elem .consumeChildElements(new SimpleInterpreter(elem.getNamespaceUri(), "layout"))) { if (layoutFound) { writer.die(elem,//from ww w . j a v a 2s . c om "LayoutContainer's and subclasses can contain only a single <%s:layout /> child. Found multiple.", elem.getPrefix()); } String layoutType = layoutChild.consumeRequiredRawAttribute("type"); LayoutParser layoutParser = LayoutParserFactory.findLayoutParserBySimpleName(elem, layoutType, writer); layoutParser.parse(layoutChild, elem, layoutContainerFieldName, type, writer); layoutFound = true; } // first, check attribute XMLAttribute layoutAttribute = elem.getAttribute("layout"); if (layoutAttribute != null) { if (layoutFound) { writer.die(elem, "LayoutContainer can contain either a layout attribute or a single nested <%s:layout /> child. Not both.", elem.getPrefix()); } String layoutType = layoutAttribute.consumeRawValue(); LayoutParser layoutParser = LayoutParserFactory.findLayoutParserBySimpleName(elem, layoutType, writer); layoutParser.parse(elem, layoutContainerFieldName, type, writer); layoutFound = true; } return layoutFound; }