public void addFieldWithLabel(Widget w, String id, String label, String... styles) { // Prepend form ID for uniqueness id = formId + "_" + id; // Create HTML DIV for each field FlowPanel div = new FlowPanel(); div.getElement().setId("div_" + id); if (w instanceof HasName) { ((HasName) w).setName(id); } w.getElement().setId(id); if (label != null) { div.add(createLabel(id, label)); } div.add(w); for (String styleName : styles) { div.addStyleName(styleName); } contentPanel.add(div); }
@Override public <T extends UIObject & HasName> void checkName(T button) { final String name = "name"; final Element label = button.getElement(); final InputElement input = InputElement.as(label.getFirstChildElement()); button.setName(name); assertEquals(name, button.getName()); assertEquals(name, input.getName()); }
/** * @see com.google.gwt.event.logical.shared.SelectionHandler#onSelection(com.google.gwt.event.logical.shared.SelectionEvent) */ @Override public void onSelection(SelectionEvent<TreeItem> event) { if ( (view != null) && (event != null) ) { Object source = event.getSource(); // Only proceed if the source was from the same panel if ( (source != null) && (source instanceof HasName) ) { String sourceName = ((HasName) source).getName(); if ( view.getName().equalsIgnoreCase(sourceName) ) { TextBox breadcrumbs = view.getBreadcrumbs(); TreeItem selectedItem = event.getSelectedItem(); if ( selectedItem != null ) { String selectedItemText = selectedItem.getText(); // Only bother to update the bread crumbs if the // user // has // selected an item that has actually loaded if ( !selectedItemText.equalsIgnoreCase(DatasetWidget.LOADING) ) { // Update bread crumbs by walking the meta data // categories GUI tree already in memory TreeItem parentItem = selectedItem.getParentItem(); if ( parentItem != null ) { // First clear bread crumbs so events fire // even // when there is no change in // breadcrumbsText // characters, but set boolean fireEvents to // false to avoid unnecessary event firing. breadcrumbs.setValue("", false); String breadcrumbsText = getBreadcrumbsText(parentItem); breadcrumbs.setValue(breadcrumbsText, true); } } } } } } }
@Override public void onValueChange (ValueChangeEvent<String> event) { String name = null; if (event.getSource() instanceof HasName) { name = ((HasName) event.getSource()).getName(); } if (name != null) { propertyLookup.get(name).value = event.getValue(); } }
public void add(HasValue<Boolean> aItem) { if (!grouped.contains(aItem)) { if (aItem instanceof HasName) { ((HasName) aItem).setName(groupName); } groupedHandlers.put(aItem, aItem.addValueChangeHandler(this)); grouped.add(aItem); } }
public boolean remove(HasValue<Boolean> aItem) { HandlerRegistration handler = groupedHandlers.get(aItem); if (handler != null) { handler.removeHandler(); } if (aItem instanceof HasName) { ((HasName) aItem).setName(""); } return grouped.remove(aItem); }
public void clear() { for (HandlerRegistration handler : groupedHandlers.values()) { if (handler != null) { handler.removeHandler(); } } groupedHandlers.clear(); for (HasValue<Boolean> item : grouped) { if (item instanceof HasName) { ((HasName) item).setName(""); } } grouped.clear(); }
@Override public void setJsName(String aValue) { name = aValue; if(decorated instanceof HasName){ ((HasName)decorated).setName(aValue); } }
/** * Convenience method that will set the name of all child widgets that can have a name * * @param name Name of group * @see #add(com.google.gwt.user.client.ui.Widget) */ @Override public void setName(final String name) { this.name = name; if (name == null) { return; } for (final Widget w : getChildren()) { if (w instanceof HasName) { ((HasName) w).setName(name); } } }
@Override public void add(final Widget w) { super.add(w); if (name == null) { return; } // Add group's name to child widgets that can have a name if (w instanceof HasName) { ((HasName) w).setName(name); } }
@Override public void onSelection(SelectionEvent<TreeItem> event) { if ( (view != null) && (event != null) ) { Object source = event.getSource(); // Only proceed if the source was from the same panel or from // the comparePanel if ( (source != null) && (source instanceof HasName) ) { String sourceName = ((HasName) source).getName(); String viewName = view.getName(); if ( ((viewName != null) && viewName.equalsIgnoreCase(sourceName)) || CONSTANTS.comparePanelName().equalsIgnoreCase(sourceName) ) { //$NON-NLS-1$ // Get variables from the tree TreeItem selectedItem = event.getSelectedItem(); if ( selectedItem != null ) { Object userObject = selectedItem.getUserObject(); if ( (userObject != null) && (userObject instanceof VariableSerializable) ) { VariableSerializable selectedVariable = (VariableSerializable) userObject; // Find all siblings if any Vector<VariableSerializable> variables = new Vector<VariableSerializable>(); // Vector<TreeItem> children = new // Vector<TreeItem>(); int selectedIndex = 0; TreeItem parent = selectedItem.getParentItem(); if ( parent == null ) { // There are no reachable siblings without a // parent, so just use the selectedVariable // and leave selectedIndex == 0 variables.add(selectedVariable); // children.add(selectedItem); } else { for ( int i = 0; i < parent.getChildCount(); i++ ) { TreeItem child = parent.getChild(i); userObject = child.getUserObject(); if ( (userObject != null) && (userObject instanceof VariableSerializable) ) { variables.add((VariableSerializable) userObject); // children.add(child); } } selectedIndex = variables.indexOf(selectedVariable); } // Add the variables to the view view.setVariables(variables, selectedIndex); } } } } } }
public String getName() { if (uiObject instanceof HasName){ return ((HasName)uiObject).getName(); } return null; }
public void setName(String arg0) { if (uiObject instanceof HasName){ ((HasName)uiObject).setName(arg0); } }
public String getName() { if (textbox instanceof HasName) { return ((HasName)textbox).getName(); } return null; }
public void setName(String arg0) { if (textbox instanceof HasName) { ((HasName)textbox).setName(arg0); } }
public <T extends UIObject & HasName> void checkName(T button) { final String name = "name"; button.setName(name); assertEquals(name, button.getName()); }