Java Code Examples for com.google.gwt.user.client.ui.Widget#getElement()
The following examples show how to use
com.google.gwt.user.client.ui.Widget#getElement() .
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: GwtRenderingMutationHandler.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Override {@link #createGwtWidget(Renderable)} to create your widget */ @Override public final Element createDomImpl(Renderable element) { Widget w = createGwtWidget(element); Element implNodelet; Element attachNodelet; if (flow == Flow.USE_WIDGET) { Preconditions.checkState(w != null, "Cannot have null widget with USE_WIDGET"); implNodelet = w.getElement(); attachNodelet = null; } else { implNodelet = flow.createContainer(); attachNodelet = implNodelet; } DomHelper.setContentEditable(implNodelet, false, false); DomHelper.makeUnselectable(implNodelet); if (w != null) { associateWidget(element, w, attachNodelet); } return implNodelet; }
Example 2
Source File: GwtRenderingMutationHandler.java From swellrt with Apache License 2.0 | 6 votes |
/** * Override {@link #createGwtWidget(Renderable)} to create your widget */ @Override public final Element createDomImpl(Renderable element) { Widget w = createGwtWidget(element); Element implNodelet; Element attachNodelet; if (flow == Flow.USE_WIDGET) { Preconditions.checkState(w != null, "Cannot have null widget with USE_WIDGET"); implNodelet = w.getElement(); attachNodelet = null; } else { implNodelet = flow.createContainer(); attachNodelet = implNodelet; } DomHelper.setContentEditable(implNodelet, false, false); DomHelper.makeUnselectable(implNodelet); if (w != null) { associateWidget(element, w, attachNodelet); } return implNodelet; }
Example 3
Source File: SuggestionButton.java From swellrt with Apache License 2.0 | 6 votes |
public SuggestionButton(final ContentElement element) { Widget clickButton = ButtonFactory.createIconClickButton(IconButtonStyle.LIGHTBULB, TOOLTIP, new ClickButtonListener() { @Override public void onClick() { HasSuggestions suggestion = element.getProperty(SuggestionRenderer.HAS_SUGGESTIONS_PROP); element.getSuggestionsManager().showSuggestionsFor(suggestion); } }); clickButton.getElement().getStyle().setDisplay(Display.INLINE_BLOCK); // Logically attach it to the root panel to listen to events, but then // manually move the dom to the desired location. RootPanel.get().add(clickButton); this.element = clickButton.getElement(); NodeManager.setTransparency(this.element, Skip.DEEP); DomHelper.makeUnselectable(this.element); this.element.setAttribute("contentEditable", "false"); }
Example 4
Source File: CubaTableDragSourceExtensionConnector.java From cuba with Apache License 2.0 | 6 votes |
protected void initDraggableRows() { TableWidget tableWidget = getTableWidget(); if (tableWidget != null) { List<Widget> list = tableWidget.getRenderedRows(); for (Widget row : list) { Element rowElement = row.getElement(); rowElement.setDraggable(Element.DRAGGABLE_TRUE); String primaryDragSourceStyle = getStylePrimaryName(getDraggableElement()) + STYLE_SUFFIX_DRAGSOURCE; if (!isElementContainsClass(rowElement, primaryDragSourceStyle)) { rowElement.addClassName(primaryDragSourceStyle); } if (!isElementContainsClass(rowElement, getStyleNameDraggable())) { rowElement.addClassName(getStyleNameDraggable()); } } } }
Example 5
Source File: CubaTableDragSourceExtensionConnector.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void removeDraggable(Element element) { if (getDragSourceWidget() instanceof TableWidget) { TableWidget widget = (TableWidget) getDragSourceWidget(); List<Widget> list = widget.getRenderedRows(); for (Widget row : list) { Element rowElement = row.getElement(); rowElement.setDraggable(Element.DRAGGABLE_FALSE); String primaryDragSourceStyle = getStylePrimaryName(getDraggableElement()) + STYLE_SUFFIX_DRAGSOURCE; rowElement.removeClassName(primaryDragSourceStyle); rowElement.removeClassName(getStyleNameDraggable()); } } }
Example 6
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 7
Source File: HtmlAttributesExtensionConnector.java From cuba with Apache License 2.0 | 6 votes |
protected void withElement(String querySelector, Consumer<Element> action) { ServerConnector parent = getParent(); if (parent instanceof AbstractComponentConnector) { Widget widget = ((AbstractComponentConnector) parent).getWidget(); if (widget != null) { Element element = widget.getElement(); if (DEFAULT_SELECTOR.equals(querySelector)) { action.accept(element); } else { NodeList<Element> subElements = findSubElements(element, querySelector); for (int i = 0; i < subElements.getLength(); i++) { action.accept(subElements.getItem(i)); } } } } }
Example 8
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 9
Source File: InputDatePicker.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
public void popup(Widget container, Widget relativeTo) { this.setVisible(true); StyleUtils.addStyle(this, InputDatePicker.STYLE_POPUP); RootPanel.get().add(this); Element positioningElement = this.getElement(); Element relativeElement = relativeTo.getElement(); int targetHeight = relativeElement.getOffsetHeight(); int targetTop = relativeElement.getAbsoluteTop(); int positioningWidth = positioningElement.getOffsetWidth(); int targetRight = relativeElement.getAbsoluteRight(); Style elementStyle = positioningElement.getStyle(); elementStyle.setPosition(Position.ABSOLUTE); elementStyle.setLeft(targetRight - positioningWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight, Unit.PX); StyleUtils.addStyle(this, InputDatePicker.STYLE_FADE); StyleUtils.addStyle(this, InputDatePicker.STYLE_SHOW); this.setFocus(true); if (this.popupBlurHandler == null) { this.popupBlurHandler = this.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { InputDatePicker.this.hide(); } }); } }
Example 10
Source File: GwtRenderingMutationHandlerGwtTest.java From swellrt with Apache License 2.0 | 5 votes |
@SuppressWarnings("static") public void testRegistersContainerNodelet() { complexHandler(Flow.INLINE); AgentAdapter e1 = elem("ab"); Widget a = handler.getGwtWidget(e1); com.google.gwt.user.client.Element b = a.getElement(); Node c = b.getFirstChild(); Element d = e1.getContainerNodelet(); assertSame(c, d); }
Example 11
Source File: SimpleForm.java From unitime with Apache License 2.0 | 5 votes |
public int getRowForWidget(Widget w) { for (Element td = w.getElement(); td != null; td = DOM.getParent(td)) { if (td.getPropertyString("tagName").equalsIgnoreCase("td")) { Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); if (body == getBodyElement()) return DOM.getChildIndex(body, tr); } if (td == getBodyElement()) { return -1; } } return -1; }
Example 12
Source File: FlowForm.java From unitime with Apache License 2.0 | 5 votes |
public int getCellForWidget(Widget w) { for (Element e = w.getElement(); e != null; e = DOM.getParent(e)) { if (e.getPropertyString("tagName").equalsIgnoreCase("span")) { if (DOM.getParent(e) == getElement()) return DOM.getChildIndex(getElement(), e); } if (e == getElement()) { return -1; } } return -1; }
Example 13
Source File: MaterialDropDown.java From gwt-material with Apache License 2.0 | 5 votes |
@Override public void load() { Widget parent = getParent(); if (parent instanceof HasActivates) { String uid = DOM.createUniqueId(); ((HasActivates) parent).setActivates(uid); setId(uid); activatorElement = parent.getElement(); } else if (activatorElement == null) { activatorElement = DOMHelper.getElementByAttribute("data-activates", activator); } $(activatorElement).dropdown(options); }
Example 14
Source File: AbstractHover.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void resetPosition(Element toPositionedElement, Widget relativeTo, Placement placement) { Element relativeElement = relativeTo.getElement(); com.google.gwt.dom.client.Style elementStyle = toPositionedElement.getStyle(); int tooltipWidth = toPositionedElement.getOffsetWidth(); int tooltipHeight = toPositionedElement.getOffsetHeight(); int targetWidth = relativeElement.getOffsetWidth(); int targetHeight = relativeElement.getOffsetHeight(); int targetTop = relativeElement.getOffsetTop(); int targetLeft = relativeElement.getOffsetLeft(); elementStyle.setPosition(Position.ABSOLUTE); switch (placement) { case TOP: elementStyle.setLeft(targetLeft + targetWidth / 2 - tooltipWidth / 2, Unit.PX); elementStyle.setTop(targetTop - tooltipHeight, Unit.PX); break; case BOTTOM: elementStyle.setLeft(targetLeft + targetWidth / 2 - tooltipWidth / 2, Unit.PX); elementStyle.setTop(targetTop + targetHeight, Unit.PX); break; case LEFT: elementStyle.setLeft(targetLeft - tooltipWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight / 2 - tooltipHeight / 2, Unit.PX); break; case RIGHT: elementStyle.setLeft(targetLeft + targetWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight / 2 - tooltipHeight / 2, Unit.PX); break; default: break; } }
Example 15
Source File: CubaVerticalActionsLayoutWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override protected int computeWidgetHeight(Widget w) { Element el = w.getElement(); int computedHeight = (int) new ComputedStyle(el).getHeight(); int measuredHeight = getLayoutManager().getOuterHeight(el); return measuredHeight >= 0 ? measuredHeight : computedHeight; }
Example 16
Source File: MockComponentsUtil.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Clears the text color of a widget to its default by CSS rules * * @param widget widget to remove the text color for */ static void resetWidgetTextColor(Widget widget) { Element el = widget.getElement(); if (el != null) { el.getStyle().clearColor(); } }
Example 17
Source File: MockComponentsUtil.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Clears the background color of a widget to its default by CSS rules. * * @param widget widget to remove the background color for */ static void resetWidgetBackgroundColor(Widget widget) { Element el = widget.getElement(); if (el != null) { el.getStyle().clearBackgroundColor(); } }
Example 18
Source File: StyleUtils.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
public static void initStyle(Widget w) { if (w != null && w.getElement() != null) { String widgetClassName = "p-" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, w.getClass().getSimpleName()); w.getElement().addClassName(widgetClassName); } }
Example 19
Source File: ScrollHelper.java From gwt-material with Apache License 2.0 | 4 votes |
/** * The container of which the scrolling feature will be applied. */ public void setContainer(Widget widget) { this.containerElement = widget.getElement(); }
Example 20
Source File: ClonedWidget.java From appinventor-extensions with Apache License 2.0 | 4 votes |
public ClonedWidget(Widget origWidget) { this(origWidget.getElement()); }