List of usage examples for com.google.gwt.user.client.ui Widget getParent
public Widget getParent()
From source file:org.semanticsoft.vaaclipse.widgets.client.ui.stackwidget.VStackWidget.java
License:Open Source License
private void changeLocationOfPartToolbar(Widget selectedWidget, Element _toolbarElement) { if (toolbarRelocated || activeTabIndex < 0 || this.getParent() == null) return;//from w w w .j ava 2 s . c o m toolbarElement = _toolbarElement; overflowRewritedElements = new HashMap<Element, String>(); List<Node> pathToParent = findPathToParent(toolbarElement, selectedWidget.getParent().getElement()); if (pathToParent == null || pathToParent.isEmpty()) { //VConsole.log(this.hashCode() + ".Path to parent is null or empty"); } for (Node node : pathToParent) { if (node instanceof Element) { Element element = (Element) node; String overflow = DOM.getElementProperty((Element) element, "overflow"); if (!"".equals(overflow) && !"visible".equals(overflow) && !"".equals("inherit")) { DOM.setStyleAttribute(element, "overflow", "visible"); overflowRewritedElements.put(element, overflow); } } } toolbarRelocated = true; updateGeometry(); }
From source file:org.senchalabs.gwt.gwtdriver.client.SeleniumExporter.java
License:Apache License
@Override public void onModuleLoad() { export(GWT.getModuleName());//from w w w. j av a 2s . c om registerFunction("isWidget", new Function() { @Override public Object apply(JsArray<?> args) { Element elt = args.get(0).cast(); EventListener listener = DOM.getEventListener(elt); return "" + (listener instanceof Widget); } }); registerFunction("instanceofwidget", new Function() { @Override public Object apply(JsArray<?> args) { Element elt = args.get(0).cast(); String type = ((JsArrayString) args.cast()).get(1); Object instance = DOM.getEventListener(elt); if (instance == null) { return "null"; } return "" + isOfType(type, instance); } }); registerFunction("getContainingWidgetClass", new Function() { @Override public Object apply(JsArray<?> args) { Element elt = args.get(0).cast(); EventListener listener = DOM.getEventListener(elt); while (listener instanceof Widget == false) { if (elt == null) { return null; } elt = elt.getParentElement().cast(); listener = DOM.getEventListener(elt); } return listener.getClass().getName(); } }); registerFunction("getContainingWidgetElt", new Function() { @Override public Object apply(JsArray<?> args) { Element elt = args.get(0).cast(); EventListener listener = DOM.getEventListener(elt); while (listener instanceof Widget == false) { if (elt == null) { return null; } elt = elt.getParentElement().cast(); if (elt == elt.getOwnerDocument().cast()) { return null; } listener = DOM.getEventListener(elt); } return elt; } }); registerFunction("getContainingWidgetEltOfType", new Function() { @Override public Object apply(JsArray<?> args) { Element elt = args.get(0).cast(); String type = ((JsArrayString) args.cast()).get(1); EventListener listener = DOM.getEventListener(elt); while (listener instanceof Widget == false) { if (elt == null) { return null; } elt = elt.getParentElement().cast(); if (elt == elt.getOwnerDocument().cast()) { return null; } listener = DOM.getEventListener(elt); } //found a real widget Widget w = (Widget) listener; while (w != null && !isOfType(type, w)) { w = w.getParent(); } return w == null ? null : w.getElement(); } }); // registerFunction("getClass", new Function() { // @Override // public Object apply(JsArray<?> args) { // Object obj = get(args, 1); // return obj.getClass().getName(); // } // }); // registerFunction("instanceOf", new Function() { // @Override // public Object apply(JsArray<?> args) { // String type = (args.<JsArrayString>cast().get(0)); // Object instance = (get(args, 1)); // // Class<?> currentType = instance.getClass(); // while (currentType != null && !currentType.getName().equals(Object.class.getName())) { // if (type.equals(currentType.getName())) { // return "" + true; // } // currentType = currentType.getSuperclass(); // } // return "" + false; // } // }); }
From source file:org.switchyard.console.client.ui.application.ApplicationView.java
License:Apache License
@Override public Widget createWidget() { _applicationsList = new ApplicationsList(); _applicationsList.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override/*from w ww . ja va2 s . c om*/ public void onSelectionChange(SelectionChangeEvent event) { // prevent infinite recursion if (_applicationsList.getSelection() != _selectedApplication) { _presenter.onApplicationSelected(_applicationsList.getSelection()); } } }); VerticalPanel applicationDetailsPanel = new VerticalPanel(); applicationDetailsPanel.setStyleName("fill-layout-width"); //$NON-NLS-1$ _applicationDetailsForm = new Form<Application>(Application.class); // XXX: '_' included in names to workaround bug in form builder _applicationDetailsForm.setFields( new LocalNameFormItem("name_1", Singleton.MESSAGES.label_applicationName()), //$NON-NLS-1$ new NamespaceFormItem("name_2", Singleton.MESSAGES.label_applicationNamespace())); //$NON-NLS-1$ Widget formWidget = _applicationDetailsForm.asWidget(); formWidget.getElement().setAttribute("style", "margin:15px"); //$NON-NLS-1$ //$NON-NLS-2$ _servicesEditor = new ApplicationServicesEditor(_presenter); _referencesEditor = new ApplicationReferencesList(_presenter); // read only for now _propertiesEditor = new PropertyEditor(); _artifactReferencesList = new ArtifactReferencesList(); _transformationsEditor = new ApplicationTransformationsEditor(_presenter); _validatorsList = new ValidatorsList(); _artifactReferencesList.addSelectionChangeHandler(new Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { _presenter.onArtifactSelected(_artifactReferencesList.getSelection()); } }); // this creates the controls, but we can't use the layout, so we // reparent the panel containing the controls OneToOneLayout applicationDetailsLayout = new OneToOneLayout().setPlain(true) .setHeadline(Singleton.MESSAGES.label_applicationDetails()) .setDescription(Singleton.MESSAGES.description_applicationDetails()).setMaster(null, formWidget) .addDetail(Singleton.MESSAGES.label_services(), _servicesEditor.asWidget()) .addDetail(Singleton.MESSAGES.label_references(), _referencesEditor.asWidget()) .addDetail(Singleton.MESSAGES.label_properties(), _propertiesEditor.asWidget()) .addDetail(Singleton.MESSAGES.label_artifacts(), _artifactReferencesList.asWidget()) .addDetail(Singleton.MESSAGES.label_transformers(), _transformationsEditor.asWidget()) .addDetail(Singleton.MESSAGES.label_validators(), _validatorsList.asWidget()); applicationDetailsLayout.build(); formWidget.getParent().setStyleName("fill-layout-width"); //$NON-NLS-1$ /* disable updating "key" field. */ _propertiesEditor.getPropertyTable().getColumn(0).setFieldUpdater(null); SimpleLayout layout = new SimpleLayout().setPlain(true) .setTitle(Singleton.MESSAGES.label_switchYardApplications()) .setHeadline(Singleton.MESSAGES.label_applications()) .setDescription(Singleton.MESSAGES.description_applications()) .addContent(Singleton.MESSAGES.label_applications(), _applicationsList.asWidget()) .addContent(Singleton.MESSAGES.label_applicationDetails(), formWidget.getParent()); return layout.build(); }
From source file:org.talend.mdm.webapp.browserecords.client.widget.treedetail.TreeDetailGridFieldCreator.java
License:Open Source License
private static TreeDetail getCurrentTreeDetail(Widget child) { if (child == null) { return null; }/*from w w w . j a v a2 s . co m*/ Widget current = child; while (current != null) { if (current instanceof TreeDetail) { return (TreeDetail) current; } current = current.getParent(); } return null; }
From source file:org.talend.mdm.webapp.browserecords.client.widget.treedetail.TreeEx.java
License:Open Source License
void orphan(Widget widget) { // Validation should already be done. assert (widget.getParent() == this); // Orphan./* www .ja va 2 s. co m*/ try { setParent(widget, null); } finally { // Logical detach. childWidgets.remove(widget); } }
From source file:org.thechiselgroup.biomixer.client.core.visualization.DefaultViewAccessor.java
License:Apache License
@Override public View findView(Widget w) { while (w != null) { if (w instanceof ViewProvider) { return ((ViewProvider) w).get(); }//w w w.ja va2s . c om w = w.getParent(); } return null; }
From source file:org.thechiselgroup.biomixer.client.dnd.DragProxyUtils.java
License:Apache License
private static void fireEventOnWidgetAndParents(Widget w, GwtEvent<?> event) { while (w != null) { w.fireEvent(event);/*w w w . j av a 2 s . com*/ w = w.getParent(); } }
From source file:org.thechiselgroup.biomixer.client.dnd.resources.DefaultResourceSetAvatarDragController.java
License:Apache License
private WindowPanel getWindow(Widget originalWidget) { assert originalWidget != null; Widget widget = originalWidget; while (widget != null) { if (widget instanceof WindowPanel) { return (WindowPanel) widget; }/*from w w w . ja va 2s.c om*/ widget = widget.getParent(); } throw new RuntimeException("no window found for widget " + originalWidget); }
From source file:org.thechiselgroup.biomixer.client.dnd.windows.WindowDragController.java
License:Apache License
private void getWindowPanelFromDraggable() { Widget draggable = getDraggable(); while ((draggable != null) && !(draggable instanceof WindowPanel)) { draggable = draggable.getParent(); }//from w w w . ja va2 s.co m windowPanel = (WindowPanel) draggable; }
From source file:org.uberfire.client.util.Layouts.java
License:Apache License
/** * Returns a multi-line string detailing layout information about the given widget and each of its ancestors in the * widget tree, optionally setting debug IDs on each widget to assist in locating them in browser DOM explorer * tools./*from w w w . jav a2s .c om*/ * @param w the widget to start at. Null is permitted, and results in this method returning an empty string. * @param setDebugIds if true, the element and each of its ancestors will have its ID set to * <code>"containment-parent-<i>depth</i>"</code>, where depth is 0 for the given widget, 1 for * its parent, 2 for its grandparent, and so on. This ID will replace any ID that was previously set on * the element, so it may break some CSS and even javascript functionality. Use with caution. * @return information about w and its ancestors, one widget per line. */ public static String getContainmentHierarchy(Widget w, boolean setDebugIds) { StringBuilder sb = new StringBuilder(); int depth = 0; while (w != null) { if (setDebugIds) { w.getElement().setId("containment-parent-" + depth); } sb.append(" " + depth + " - " + widgetInfo(w)); w = w.getParent(); depth++; } return sb.toString(); }