List of usage examples for com.google.gwt.user.client.ui Widget getParent
public Widget getParent()
From source file:com.cgxlib.xq.client.plugins.widgets.WidgetsUtils.java
License:Apache License
/** * This method detach a widget of its parent without doing a physical * detach (DOM manipulation).//from w w w . jav a 2 s . c o m */ public static void doLogicalDetachFromHtmlPanel(Widget w) { Widget parent = w.getParent(); if (parent instanceof HTMLPanel) { complexPanelGetChildren((HTMLPanel) parent).remove(w); widgetSetParent(w, null); } else { throw new IllegalStateException("You can only use this method to detach a child from an HTMLPanel"); } }
From source file:com.dianaui.universal.core.client.ui.base.ValueBoxErrorSupport.java
License:Apache License
/** * Find the sibling {@link HelpBlock}./*from www. j a va 2 s. c o m*/ * * @param widget the {@link Widget} to search. * @return the found {@link HelpBlock} of null if not found. */ private HelpBlock findHelpBlock(Widget widget) { if (widget instanceof HelpBlock) return (HelpBlock) widget; // Try and find the HelpBlock in the children of the given widget. if (widget instanceof HasWidgets) { for (Widget w : (HasWidgets) widget) { if (w instanceof HelpBlock) return (HelpBlock) w; } } if (!(widget instanceof HasValidationState)) { // Try and find the HelpBlock in the parent of widget. return findHelpBlock(widget.getParent()); } return null; }
From source file:com.dianaui.universal.core.client.ui.base.ValueBoxErrorSupport.java
License:Apache License
/** * Initialize the instance. We find the parent {@link HasValidationState} and sibling {@link HelpBlock} * only 1 time on initialization.//from w w w . ja v a2 s. com */ public void init() { if (initialized) return; initialized = true; Widget parent = inputWidget.getParent(); while (parent != null && !parent.getClass().getName().equals("com.google.gwt.user.client.ui.Widget")) { if (parent instanceof HasValidationState) { validationStateParent = (HasValidationState) parent; validationStateHelpBlock = findHelpBlock(inputWidget); } parent = parent.getParent(); } }
From source file:com.eas.widgets.boxes.DateTimeBox.java
@Override protected void onAttach() { super.onAttach(); redecorate();// ww w.j a v a 2 s . co m Widget lParent = getParent(); while (lParent != null && !(lParent instanceof AutoCloseBox)) { lParent = lParent.getParent(); } if (lParent instanceof AutoCloseBox) autoCloseParent = (AutoCloseBox) lParent; if (autoCloseParent != null) { autoCloseParent.addAutoHidePartner(popup.getElement()); } }
From source file:com.eas.widgets.containers.AnchorsPanel.java
public void ajustDisplay(Widget child) { if (child.getParent() == this) { Element el = getWidgetContainerElement(child); boolean visible = !child.getElement().hasAttribute("aria-hidden"); if (visible) { el.getStyle().clearDisplay(); if (child instanceof RequiresResize) { ((RequiresResize) child).onResize(); }// ww w . jav a 2s . co m } else { el.getStyle().setDisplay(Style.Display.NONE); } } }
From source file:com.example.querybuilder.client.Utilities.java
License:Open Source License
public static Window getWindow(Widget widget) { while (widget != null) { if (widget instanceof Window) { return (Window) widget; }// w w w . j ava 2 s.com widget = widget.getParent(); } return null; }
From source file:com.extjs.gxt.ui.client.aria.ContentPanelNavigationHandler.java
License:sencha.com license
public List<Widget> getOrderedWidgets(Widget widget) { ContentPanel panel = null;/*from w ww .j a v a 2s. co m*/ if (widget instanceof HorizontalPanel) { panel = (ContentPanel) widget.getParent().getParent(); } else if (widget.getParent() instanceof ContentPanel) { panel = (ContentPanel) widget.getParent(); } else { panel = (ContentPanel) widget; } List<Widget> widgets = new ArrayList<Widget>(); Header header = panel.getHeader(); for (int i = 0, len = header.getTools().size(); i < len; i++) { widgets.add(header.getTool(i)); } if (panel.getTopComponent() != null) { widgets.add(panel.getTopComponent()); } for (int i = 0, len = panel.getItemCount(); i < len; i++) { widgets.add(panel.getItem(i)); } if (panel.getBottomComponent() != null) { widgets.add(panel.getBottomComponent()); } if (panel.getButtonBar() != null && panel.getButtonBar().getItemCount() > 0) { widgets.add(panel.getButtonBar()); } if (panel instanceof CollapsePanel) { widgets.add(((CollapsePanel) panel).getCollapseButton()); } return widgets; }
From source file:com.extjs.gxt.ui.client.aria.DefaultHandler.java
License:sencha.com license
@SuppressWarnings("rawtypes") @Override/* w ww .j a v a 2 s .c om*/ public void onTab(Component component, PreviewEvent pe) { if (!isManaged()) return; if (component.getFocusSupport().isIgnore()) { return; } if (pe.isShiftKey()) { if (focusPreviousWidget(component)) { pe.stopEvent(); } else { Widget w = component.getParent(); while (w != null) { if (w instanceof RootPanel) { // do nothing leave app return; } else if (w instanceof Component) { Component c = (Component) w; if (c.getFocusSupport().isIgnore()) { w = w.getParent(); } else { w = null; pe.stopEvent(); } } } } } else { if (focusNextWidget(component)) { pe.stopEvent(); } else { if (!(component.getParent() instanceof RootPanel)) { Widget p = component.getParent(); if (p instanceof Container) { Container c = (Container) p; if (c.getItemCount() == 1) { if (c.getParent() instanceof RootPanel) { pe.stopEvent(); onStepOutApp(); return; } } } pe.stopEvent(); } else { pe.stopEvent(); onStepOutApp(); } } } }
From source file:com.extjs.gxt.ui.client.aria.FocusHandler.java
License:sencha.com license
@SuppressWarnings({ "unchecked", "rawtypes" }) public static boolean focusNextWidget(Widget c) { if (c instanceof Component) { Component comp = (Component) c; if (forwardIfOverride(comp)) { return true; }//from w w w . j ava 2s . c o m } Widget p = c.getParent(); List<Widget> widgets = null; NavigationHandler handler = null; if (p instanceof Component) { handler = findNavigationHandler((Component) p); } if (handler != null) { widgets = handler.getOrderedWidgets(p); } else if (p instanceof Container) { Container con = (Container) p; widgets = con.getItems(); } else if (p instanceof HasWidgets) { HasWidgets hs = (HasWidgets) p; widgets = new ArrayList<Widget>(); Iterator<Widget> it = hs.iterator(); while (it.hasNext()) { widgets.add(it.next()); } } if (widgets == null || widgets.size() == 1) { return false; } int idx = widgets.indexOf(c); if (idx != -1) { idx = idx == widgets.size() - 1 ? 0 : ++idx; return focusWidget(widgets.get(idx)); } return false; }
From source file:com.extjs.gxt.ui.client.aria.FocusHandler.java
License:sencha.com license
@SuppressWarnings({ "rawtypes", "unchecked" }) protected static Widget findNextWidget(Widget c) { if (c instanceof Component) { Component comp = (Component) c; if (findForwardOverride(comp) != null) { return findForwardOverride(comp); }/* w ww.jav a2s . c o m*/ } Widget p = c.getParent(); List<Widget> widgets = null; NavigationHandler handler = null; if (p instanceof Component) { handler = findNavigationHandler((Component) p); } if (handler != null) { widgets = handler.getOrderedWidgets(p); } else if (p instanceof Container) { Container con = (Container) p; widgets = con.getItems(); } else if (p instanceof HasWidgets) { HasWidgets hs = (HasWidgets) p; widgets = new ArrayList<Widget>(); Iterator<Widget> it = hs.iterator(); while (it.hasNext()) { widgets.add(it.next()); } } if (widgets == null) { return null; } int idx = widgets.indexOf(c); if (idx != -1) { Widget w = null; if (idx == widgets.size() - 1 && widgets.size() > 1) { w = widgets.get(0); } else if (idx != widgets.size() - 1) { w = widgets.get(idx + 1); } if (isIgnore(w)) { return findNextWidget(w); } return w; } return null; }