Java Code Examples for com.google.gwt.user.client.ui.Widget#getParent()
The following examples show how to use
com.google.gwt.user.client.ui.Widget#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GanttWidget.java From gantt with Apache License 2.0 | 6 votes |
public int removeAndReturnIndex(Widget w) { int index = -1; // Validate. if (w.getParent() != this) { return index; } // Orphan. try { orphan(w); } finally { index = getWidgetIndex(w); // Physical detach. Element elem = w.getElement(); content.removeChild(elem); // Logical detach. getChildren().remove(w); } return index; }
Example 2
Source File: DefaultErrorHandler.java From gwt-material with Apache License 2.0 | 6 votes |
/** * Initialize the instance. */ public void init() { if (initialized) { return; } Widget parent = inputWidget.getParent(); while (parent != null && !parent.getClass().getName().equals("com.google.gwt.user.client.ui.Widget")) { helpBlock = findHelpBlock(inputWidget); if (helpBlock != null) { break; } else { parent = parent.getParent(); } } initialized = true; }
Example 3
Source File: VDDAccordion.java From cuba with Apache License 2.0 | 6 votes |
private boolean removeSpacer(Widget spacer) { // Validate. if (spacer.getParent() != this) { return false; } // Orphan. try { orphan(spacer); } finally { // Physical detach. Element elem = spacer.getElement(); DOM.getParent(elem).removeChild(elem); // We don't remove the spacer from the children otherwise we mess // the accordion logic. } return true; }
Example 4
Source File: VPopupButton.java From cuba with Apache License 2.0 | 6 votes |
@Override public void show() { hiding = false; // ** Copied from PopupView ** // Find the shortcut action handler that should handle keyboard // events from the popup. The events do not propagate automatically // because the popup is directly attached to the RootPanel. Widget widget = VPopupButton.this; while (shortcutActionHandler == null && widget != null) { if (widget instanceof ShortcutActionHandler.ShortcutActionHandlerOwner) { shortcutActionHandler = ((ShortcutActionHandler.ShortcutActionHandlerOwner) widget) .getShortcutActionHandler(); } widget = widget.getParent(); } super.show(); }
Example 5
Source File: GwtUIUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @SuppressWarnings("unchecked") public static <T extends Widget> T getParentOf(Widget widget, Class<T> type) { Widget target = widget; do { if (target.getClass() == type) { return (T)target; } target = target.getParent(); } while (target != null); return null; }
Example 6
Source File: ImplPanel.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Narrows an object to a widget, if it is a child of this panel. Otherwise, * throws an exception. * * @param o object to narrow * @return {@code o} as a widget * @throws IllegalArgumentException if {@code o} is not a child of this panel. */ public Widget narrowChild(Object o) { // Note: it is very important that this method can be implemented WITHOUT // casting. This implementation uses casting as an optimization. However, // a non-casting version is provided in comments. Anyone touching this // method must ensure that a non-casting possibility exists. // // for (Widget child : getChildren()) { // if (child == o) { // return child; // } // } // return null; // Widget w = o instanceof Widget ? (Widget) o : null; if (w != null && w.getParent() == this) { return w; } else { throw new IllegalArgumentException("Not a child"); } }
Example 7
Source File: AbstractShape.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
protected int getContainerOffsetTop() { // if (containerOffsetTop < 0 || !sync) { // int scrollTop = 0; // Element parent = DOM.getParent(widget.getElement()); // while (parent != null) { // if (getScrollTop(parent) > 0) { // scrollTop += getScrollTop(parent); // GWT.log("Scroll Top detected : " + scrollTop); // } // if ("relative".equals(DOM.getStyleAttribute(parent, "position"))) { // containerOffsetTop = DOM.getAbsoluteTop(parent) - scrollTop; // } // parent = DOM.getParent(parent); // } // } if (containerOffsetTop < 0 || !sync) { int top = 0; Widget parent = widget.getParent(); while (parent != null && top == 0) { parent = parent.getParent(); if (parent != null) top = parent.getAbsoluteTop(); } containerOffsetTop = top; //containerOffsetTop = AdminPanel.get().getContent().getAbsoluteTop(); } return containerOffsetTop; }
Example 8
Source File: GwtRenderingMutationHandler.java From swellrt with Apache License 2.0 | 5 votes |
private void maybeLogicalDetach(ContentElement element) { Widget w = getGwtWidget(element); LogicalPanel p = getLogicalPanel(element); if (p != null && w != null && w.getParent() != null) { p.doOrphan(w); } }
Example 9
Source File: CubaTreeGridWidget.java From cuba with Apache License 2.0 | 5 votes |
protected boolean isWidgetOrParentFocusable(Widget widget) { boolean widgetFocusable = isWidgetFocusable(widget); if (!widgetFocusable) { Widget parent = widget.getParent(); while (parent != null && !widgetFocusable && !isGridCell(parent)) { widgetFocusable = isWidgetFocusable(parent); parent = parent.getParent(); } } return widgetFocusable; }
Example 10
Source File: GwtRenderingMutationHandler.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private void maybeLogicalDetach(ContentElement element) { Widget w = getGwtWidget(element); LogicalPanel p = getLogicalPanel(element); if (p != null && w != null && w.getParent() != null) { p.doOrphan(w); } }
Example 11
Source File: VDragFilter.java From cuba with Apache License 2.0 | 5 votes |
private boolean isCaptionForAccordion(Widget widget) { if (widget == null) { return false; } if (!(widget instanceof VCaption)) { return false; } Widget parent = widget.getParent(); return parent instanceof StackItem; }
Example 12
Source File: VGrabFilter.java From cuba with Apache License 2.0 | 5 votes |
protected boolean isCaptionForAccordion(Widget widget) { if (widget == null) { return false; } if (!(widget instanceof VCaption)) { return false; } Widget parent = widget.getParent(); return parent instanceof VAccordion.StackItem; }
Example 13
Source File: CubaTreeTableWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override protected Element getElementTdOrTr(Element eventTarget) { Widget widget = WidgetUtil.findWidget(eventTarget, null); Widget targetWidget = widget; if (widget != this) { /* * This is a workaround to make Labels, read only TextFields * and Embedded in a Table clickable (see #2688). It is * really not a fix as it does not work with a custom read * only components (not extending VLabel/VEmbedded). */ while (widget != null && widget.getParent() != this) { widget = widget.getParent(); } if (!(widget instanceof VLabel) && !(widget instanceof VEmbedded) && !(widget instanceof VTextField && ((VTextField) widget).isReadOnly()) && !(targetWidget instanceof VLabel) && !(targetWidget instanceof Panel) && !(targetWidget instanceof VEmbedded) && !(widget instanceof CubaImageWidget) && !(targetWidget instanceof VTextField && ((VTextField) targetWidget).isReadOnly())) { return null; } } return getTdOrTr(eventTarget); }
Example 14
Source File: CubaPopupButtonConnector.java From cuba with Apache License 2.0 | 5 votes |
protected boolean isLastChild(Element target) { Widget widget = WidgetUtil.findWidget(target, null); Widget widgetParent = widget.getParent(); FlowPanel layout = (FlowPanel) widgetParent.getParent(); int widgetIndex = layout.getWidgetIndex(widget); return widgetIndex == layout.getWidgetCount() - 1; }
Example 15
Source File: CubaGridWidget.java From cuba with Apache License 2.0 | 5 votes |
protected boolean isWidgetOrParentFocusable(Widget widget) { boolean widgetFocusable = isWidgetFocusable(widget); if (!widgetFocusable) { Widget parent = widget.getParent(); while (parent != null && !widgetFocusable && !isGridCell(parent)) { widgetFocusable = isWidgetFocusable(parent); parent = parent.getParent(); } } return widgetFocusable; }
Example 16
Source File: JQueryFileUploadOverlay.java From cuba with Apache License 2.0 | 5 votes |
protected static Widget getWidgetTopParent(Widget widget) { Widget parent = widget.getParent(); while (!(parent instanceof VWindow) && !(parent instanceof VUI) && !(parent instanceof VOverlay)) { parent = parent.getParent(); } return parent; }
Example 17
Source File: AbstractShape.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
protected int getContainerOffsetLeft() { // if (containerOffsetLeft < 0 || !sync) { // int scrollLeft = 0; // Element parent = DOM.getParent(widget.getElement()); // while (parent != null) { // if(getScrollLeft(parent) > 0){ // scrollLeft += getScrollLeft(parent); // GWT.log("Scroll left detected : " + scrollLeft); // } // if ("relative".equals(DOM.getStyleAttribute(parent, "position"))) { // containerOffsetLeft = DOM.getAbsoluteLeft(parent) - scrollLeft; // } // parent = DOM.getParent(parent); // } if (containerOffsetLeft < 0 || !sync) { int left = 0; Widget parent = widget.getParent(); while (parent != null && left == 0) { parent = parent.getParent(); if (parent != null) left = parent.getAbsoluteLeft(); } containerOffsetLeft = left; //containerOffsetLeft = AdminPanel.get().getContent().getAbsoluteLeft(); } return containerOffsetLeft; }
Example 18
Source File: VDragFilter.java From cuba with Apache License 2.0 | 4 votes |
private ComponentConnector findConnectorForAccordionCaption(Widget widget) { StackItem parent = (StackItem) widget.getParent(); return Util.findConnectorFor(parent.getChildWidget()); }
Example 19
Source File: VLayoutDragDropMouseHandler.java From cuba with Apache License 2.0 | 4 votes |
/** * Initiates the drag only on the first move event * * @param originalEvent * the original Mouse Down event. Only events on elements are * passed in here (Element.as() is safe without check here) */ protected void initiateDragOnMove(final NativeEvent originalEvent) { EventTarget eventTarget = originalEvent.getEventTarget(); boolean stopEventPropagation = false; Element targetElement = Element.as(eventTarget); Widget target = WidgetUtil.findWidget(targetElement, null); Widget targetParent = target.getParent(); // Stop event propagation and prevent default behaviour if // - target is *not* a VTabsheet.TabCaption or // - drag mode is caption mode and widget is caption boolean isTabCaption = WidgetUtil.findWidget(target.getElement(), TabCaption.class) != null; boolean isCaption = VDragDropUtil.isCaptionOrCaptionless(targetParent); if (dragMode == LayoutDragMode.CLONE && isTabCaption == false) { stopEventPropagation = true; // overwrite stopEventPropagation flag again if // - root implements VHasDragFilter but // - target is not part of its drag filter and // - target is not a GWT Label based widget if (root instanceof VHasDragFilter) { if (((VHasDragFilter) root).getDragFilter() .isDraggable(target) == false && (target instanceof LabelBase) == false) { stopEventPropagation = false; } } if (root instanceof VHasGrabFilter) { VGrabFilter grabFilter = ((VHasGrabFilter) root).getGrabFilter(); if (grabFilter != null && !grabFilter.canBeGrabbed(root, target)) { return; } } } if (dragMode == LayoutDragMode.CAPTION && isCaption) { stopEventPropagation = true; } if (isElementNotDraggable(targetElement)) { stopEventPropagation = false; } if (stopEventPropagation) { originalEvent.stopPropagation(); originalEvent.preventDefault(); // Manually focus as preventDefault() will also cancel focus targetElement.focus(); } mouseDownHandlerReg = Event .addNativePreviewHandler(new NativePreviewHandler() { @Override public void onPreviewNativeEvent(NativePreviewEvent event) { int type = event.getTypeInt(); if (type == Event.ONMOUSEUP || type == Event.ONTOUCHCANCEL || type == Event.ONTOUCHEND) { mouseDownHandlerReg.removeHandler(); mouseDownHandlerReg = null; } else if (type == Event.ONMOUSEMOVE || type == Event.ONTOUCHMOVE) { mouseDownHandlerReg.removeHandler(); mouseDownHandlerReg = null; initiateDrag(originalEvent); } } }); }
Example 20
Source File: VGrabFilter.java From cuba with Apache License 2.0 | 4 votes |
protected ComponentConnector findConnectorForAccordionCaption(Widget widget) { VAccordion.StackItem parent = (VAccordion.StackItem) widget.getParent(); return Util.findConnectorFor(parent.getChildWidget()); }