Java Code Examples for com.google.gwt.dom.client.Element#getParentElement()
The following examples show how to use
com.google.gwt.dom.client.Element#getParentElement() .
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: SelectionW3CNative.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Ensure that the rendered content view's DOM has focus * * NOTE(patcoleman): Fixes firefox bug that causes invalid selections while * mutating DOM that doesn't have focus - fixed by finding the next parent element directly * editable, and forcing this to have the focus. */ private static void setFocusElement(Node node) { if (UserAgent.isFirefox()) { // adjust to parent if node is a text node Element toFocus = null; if (DomHelper.isTextNode(node)) { toFocus = node.getParentElement(); } else { toFocus = node.<Element>cast(); } // traverse up until we have a concretely editable element: while (toFocus != null && DomHelper.getContentEditability(toFocus) != ElementEditability.EDITABLE) { toFocus = toFocus.getParentElement(); } // then focus it: if (toFocus != null) { DomHelper.focus(toFocus); } } }
Example 2
Source File: SelectionImplIE.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * @param target collapsed text range * @return HtmlPoint matching the collapsed text range */ private Point<Node> pointAtCollapsedRangeInner(JsTextRangeIE target) { // The point is (mostly) either directly in target's parent, // or in a text node child of parent. (Occasionally, the point // sits right after the parent, see below.) Element parent = target.parentElement(); // XXX(zdwang): For some reason IE 7 likes to focus on the input box of the // contacts pop up during the on key press event when you press shift+enter // on a blip. This causes attempt.moveToElementText(el) to thrown an // exception. // TODO(user): check with zdwang if this is still needed... if (parent.getTagName().equals("INPUT")) { return Point.inElement(parent, parent.getFirstChild()); } // This catches an corner case where the target is actually // *outside* its parent node. This happens, e.g., in this case: // <p><thumbnail/>|</p>. Best look out for other such cases! while (parent.getAttribute("contentEditable").equalsIgnoreCase("false")) { parent = parent.getParentElement(); } return binarySearchForRange(target, parent); // return searchForRangeUsingPaste(target, parent); // return linearSearchForRange(target, parent); }
Example 3
Source File: VDDHorizontalLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected Slot getSlot(Element e, NativeEvent event) { Slot slot = null; if (getLayout().getElement() == e) { // Most likely between components, use the closes one in that case slot = findSlotHorizontally(12, event); } else { slot = WidgetUtil.findWidget(e, Slot.class); if (slot == null) { return null; } VAbstractOrderedLayout layout = VDragDropUtil.getSlotLayout(slot); while (layout != getLayout() && getLayout().getElement() .isOrHasChild(e.getParentElement())) { e = e.getParentElement(); slot = WidgetUtil.findWidget(e, Slot.class); if (slot == null) { return null; } layout = VDragDropUtil.getSlotLayout(slot); } } return slot; }
Example 4
Source File: VDDVerticalLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected Slot getSlot(Element e, NativeEvent event) { Slot slot = null; if (getLayout().getElement() == e) { // Most likely between components, use the closest one in that case slot = findSlotVertically(12, event); } else { slot = WidgetUtil.findWidget(e, Slot.class); if (slot == null) { return null; } VAbstractOrderedLayout layout = VDragDropUtil.getSlotLayout(slot); while (layout != getLayout() && getLayout().getElement() .isOrHasChild(e.getParentElement())) { e = e.getParentElement(); slot = WidgetUtil.findWidget(e, Slot.class); if (slot == null) { return null; } layout = VDragDropUtil.getSlotLayout(slot); } } return slot; }
Example 5
Source File: TransparencyUtil.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Helper to remove a list of transparent nodes from the document * @param elements */ public static void clear(List<Element> elements) { for (Element e : elements) { if (e.getParentElement() != null) { if (NodeManager.getTransparency(e) == Skip.DEEP) { e.removeFromParent(); } else { DomHelper.unwrap(e); } } // Break circular references in browsers with poor gc NodeManager.setTransparentBackref(e, null); } elements.clear(); }
Example 6
Source File: DomHelper.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Checks whether the given DOM element is editable, either explicitly or * inherited from its ancestors. * @param e Element to check */ public static boolean isEditable(Element e) { // special early-exit for problematic shadow dom: if (isUnreadable(e)) { return true; } Element docElement = Document.get().getDocumentElement(); do { ElementEditability editability = getElementEditability(e); if (editability == ElementEditability.NEUTRAL) { if (e == docElement) { return false; } e = e.getParentElement(); } else { return editability == ElementEditability.EDITABLE ? true : false; } } while (e != null); // NOTE(danilatos): We didn't hit the body. The only way I know that this can happen // is if the browser gave us a text node from its SHADOW dom, e.g. in a text box, // which doesn't have any text node children. I've observed the parent of this text node // to be reported as a div, and the parent of that div to be null. return true; }
Example 7
Source File: Tools.java From cuba with Apache License 2.0 | 5 votes |
public static Element findCurrentOrParentTd(Element target) { if (target == null) { return null; } // Iterate upwards until we find the TR element Element element = target; while (element != null && !"td".equalsIgnoreCase(element.getTagName())) { element = element.getParentElement(); } return element; }
Example 8
Source File: DomHelper.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * @param element * @param styleName * @return true if the element or an ancestor has the given stylename */ public static boolean hasStyleOrAncestorHasStyle(Element element, String styleName) { while (element != null) { if (element.getClassName().indexOf(styleName) >= 0) { return true; } element = element.getParentElement(); } return false; }
Example 9
Source File: GanttWidget.java From gantt with Apache License 2.0 | 5 votes |
protected SubStepWidget getSubStepWidget(Element subStepElement) { Element stepElement = subStepElement.getParentElement(); StepWidget widget = getStepWidget(stepElement); if (widget != null) { return widget.getSubStepWidgetByElement(subStepElement); } return null; }
Example 10
Source File: SelectionUtil.java From swellrt with Apache License 2.0 | 5 votes |
/** * Takes an html selection and returns it, or null if it's not related to editor content. * * @param htmlSelection Selection range to filter. * @return htmlSelection or null if there's no related content. */ public static FocusedPointRange<Node> filterNonContentSelection( FocusedPointRange<Node> htmlSelection) { if (htmlSelection == null) { return null; // quick exit } // get just the focus point, finding the element it is inside. Point<Node> htmlFocus = htmlSelection.getFocus(); Element el; if (htmlFocus.isInTextNode()) { el = htmlFocus.getContainer().getParentElement(); } else { el = htmlFocus.getContainer().cast(); } // Assume given range is always in the editor, the htmlHelper should guarantee that. while (!NodeManager.hasBackReference(el)) { if (NodeManager.getTransparency(el) == Skip.DEEP || el.getPropertyBoolean(ContentElement.COMPLEX_IMPLEMENTATION_MARKER)) { // Exception: when we explicitly want the selection still to be reported if (!NodeManager.mayContainSelectionEvenWhenDeep(el)) { htmlSelection = null; break; } } el = el.getParentElement(); } return htmlSelection; }
Example 11
Source File: FullStructure.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override public ParticipantsView fromNewWaveWithParticipantsButton(Element e) { Preconditions.checkArgument(e == null || typeOf(e) == Type.NEW_WAVE_WITH_PARTICIPANTS); while (e != null && !hasKnownType(e)) { e = e.getParentElement(); } // Assume that the nearest kinded ancestor of the add button is the // participants view (an exception is thrown if not). return asParticipants(e); }
Example 12
Source File: FullStructure.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private View parentOf(DomView v) { Element c = v.getElement().getParentElement(); while (c != null && !hasKnownType(c)) { c = c.getParentElement(); } return viewOf(c); }
Example 13
Source File: UIHider.java From djvu-html5 with GNU General Public License v2.0 | 5 votes |
private boolean isUIFocused() { Element focusedElement = getFocusedElement(); while (focusedElement != null) { for (UIElement element : uiElements) { if (element.widget.getElement() == focusedElement) return true; } focusedElement = focusedElement.getParentElement(); } return false; }
Example 14
Source File: FullStructure.java From swellrt with Apache License 2.0 | 5 votes |
@Override public ParticipantsView fromNewWaveWithParticipantsButton(Element e) { Preconditions.checkArgument(e == null || typeOf(e) == Type.NEW_WAVE_WITH_PARTICIPANTS); while (e != null && !hasKnownType(e)) { e = e.getParentElement(); } // Assume that the nearest kinded ancestor of the add button is the // participants view (an exception is thrown if not). return asParticipants(e); }
Example 15
Source File: SearchPanelWidget.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@UiHandler("self") void handleClick(ClickEvent e) { Element target = e.getNativeEvent().getEventTarget().cast(); Element top = self.getElement(); while (!top.equals(target)) { if ("digest".equals(target.getAttribute(BuilderHelper.KIND_ATTRIBUTE))) { handleClick(byId.get(target.getAttribute(DigestDomImpl.DIGEST_ID_ATTRIBUTE))); e.stopPropagation(); return; } else if (showMore.equals(target)) { handleShowMoreClicked(); } target = target.getParentElement(); } }
Example 16
Source File: FullStructure.java From swellrt with Apache License 2.0 | 5 votes |
private View parentOf(DomView v) { Element c = v.getElement().getParentElement(); while (c != null && !hasKnownType(c)) { c = c.getParentElement(); } return viewOf(c); }
Example 17
Source File: STextWebRemote.java From swellrt with Apache License 2.0 | 4 votes |
@Override public boolean isAttachedToDOM() { Element nodelet = interactiveDoc.getDocument().getFullContentView().getDocumentElement() .getImplNodelet(); return nodelet != null && nodelet.getParentElement() != null; }
Example 18
Source File: STextWebLocal.java From swellrt with Apache License 2.0 | 4 votes |
@Override public boolean isAttachedToDOM() { Element nodelet = doc.getFullContentView().getDocumentElement().getImplNodelet(); return nodelet != null && nodelet.getParentElement() != null; }
Example 19
Source File: DomUtil.java From jetpad-projectional-open-source with Apache License 2.0 | 4 votes |
public static boolean hasScrollers(Element ctx) { if (ctx.getParentElement() == null) return false; if (hasScroller(ctx)) return true; return hasScrollers(ctx.getParentElement()); }
Example 20
Source File: VDDFormLayout.java From cuba with Apache License 2.0 | 4 votes |
public static Element getRowFromChildElement(Element e, Element root) { while (!elementIsRow(e) && e != root && e.getParentElement() != null) { e = e.getParentElement().cast(); } return e; }