com.google.gwt.user.client.Element Java Examples

The following examples show how to use com.google.gwt.user.client.Element. 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: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example #2
Source File: VDDAccordion.java    From cuba with Apache License 2.0 6 votes vote down vote up
private void insertSpacer(Widget spacer,
        com.google.gwt.dom.client.Element container, int beforeIndex) {
    // Validate index; adjust if the widget is already a child of this
    // panel.
    beforeIndex = adjustIndex(spacer, beforeIndex);

    // Detach new child.
    spacer.removeFromParent();

    // We don't add the spacer to the children otherwise we mess the
    // accordion logic.

    // Physical attach.
    DOM.insertChild(container, spacer.getElement(), beforeIndex);

    // Adopt.
    adopt(spacer);
}
 
Example #3
Source File: VDDAccordion.java    From cuba with Apache License 2.0 6 votes vote down vote up
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: OutputBoolean.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void resetInner() {
	if (this.elementExists()) {
		Element element = this.getElement();
		element.removeAllChildren();
		boolean rendervalue = Boolean.TRUE.equals(this.getValue());
		if (this.outputType != RenderType.TEXT) {
			Icon icon = rendervalue ? this.trueIcon : this.falseIcon;
			if (icon != null) {
				element.appendChild(icon.getElement());
			}
		}
		if (this.outputType != RenderType.ICON) {
			Text textElem = Document.get().createTextNode(rendervalue ? this.trueLabel : this.falseLabel);
			element.appendChild(textElem);
		}
	}
}
 
Example #5
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example #6
Source File: MyWidgetTestWithoutRunner.java    From gwtmockito with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  GwtMockito.initMocks(this);
  widget = new MyWidget() {
    @Override
    protected void initWidget(Widget widget) {
      // initWidget must be disarmed when testing widget to avoid
      // UnsatisfiedLinkErrors
    }

    @Override
    Element doStuffInJavaScript() {
      // JSNI methods  must be explicitly overridden or factored out to avoid
      // UnsatisfiedLinkErrors
      return null;
    }
  };
}
 
Example #7
Source File: Util.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Download files exported as zip
 *
 * @author danilo
 */
@Deprecated
public static void downloadFiles(List<String> path, String params) {
	if (!params.equals("")) {
		params = "&" + params;
	}

	final Element downloadIframe = RootPanel.get("__download").getElement();
	String url = RPCService.DownloadServlet + "?export" + params;

	for (String p : path) {
		url += "&pathList=" + URL.encodeQueryString(p);
	}

	DOM.setElementAttribute(downloadIframe, "src", url);
}
 
Example #8
Source File: MockComponentsUtil.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the preferred size of the specified DOM element in an array of the
 * form {@code [width, height]}.
 *
 * @see #getPreferredSizeOfDetachedWidget(Widget)
 * @param element the DOM element to compute the size for
 * @return the natural width and height of the element
 */
public static int[] getPreferredSizeOfElement(Element element) {
  Element root = RootPanel.get().getElement();
  root.appendChild(element);

  String[] style = clearSizeStyle(element);
  int width = element.getOffsetWidth() + 4;
  int height = element.getOffsetHeight() + 6;
  if (height < 26) {
    height = 26;
  }
  restoreSizeStyle(element, style);

  root.removeChild(element);
  return new int[] { width, height };
}
 
Example #9
Source File: DiagramTab.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private void initTooltips() {

        Element mousePointerElement = getMousePointerLineElement();
        DOM.setStyleAttribute(mousePointerElement, "backgroundColor", "blue");
        DOM.setStyleAttribute(mousePointerElement, "width", "0px");
        DOM.setStyleAttribute(mousePointerElement, "height", "0px");
        DOM.setStyleAttribute(mousePointerElement, "visibility", "hidden");
        DOM.setStyleAttribute(mousePointerElement, "marginTop", "6px");
        this.mainChartViewport.add(this.verticalMousePointerLine);

        this.tooltipPresenter = new TooltipPresenter(this.mainChartEventBus);

        this.tooltipPresenter.configureHoverMatch(true, false, false);
        this.tooltipPresenter.setTooltipZIndex(Constants.Z_INDEX_ON_TOP);

        GenericWidgetViewImpl widget = new GenericWidgetViewImpl(this.verticalMousePointerLine);
        MousePointerPresenter mpp = new MousePointerPresenter(this.mainChartEventBus, widget);
        mpp.configure(true, false);
    }
 
Example #10
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example #11
Source File: WindowUtils.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void setFavicon(GUIInfo info) {
	try {
		Element link = DOM.getElementById("favicon");
		Element parent = DOM.getParent(link);
		DOM.removeChild(parent, link);

		link = DOM.createElement("link");
		link.setId("favicon");
		link.setAttribute("rel", "shortcut icon");
		link.setAttribute("type", "image/png");
		link.setAttribute("href", info.getBranding().getFaviconSrc());

		DOM.appendChild(parent, link);
	} catch (Throwable t) {

	}
}
 
Example #12
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example #13
Source File: ColoredFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	super.onBrowserEvent(event);
	Element td = getEventTargetCell(event);
	if (td == null)
		return;
	Element tr = DOM.getParent(td);

	switch (DOM.eventGetType(event)) {
		case Event.ONMOUSEOVER:
			tr.addClassName(ROW_STYLE_NAME + "-mouseover");
			break;

		case Event.ONMOUSEOUT: {
			tr.removeClassName(ROW_STYLE_NAME + "-mouseover");
			break;
		}
	}
}
 
Example #14
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example #15
Source File: StackedBar.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void setRatio(double total, double actual)
{
    Element inner = panel.getElementById(innerId);
    double percentage = percentage(total, actual);
    if(percentage>0)
    {
        inner.setAttribute("style", "width:" + percentage + "%");
        inner.setAttribute("cssText", "width:" + percentage + "%");
    }
    else
    {
        inner.setAttribute("style", "background:none");
        inner.setAttribute("cssText", "background:none");
    }
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<span style='padding-right:5px;'>").appendEscaped(percentage + "%").appendHtmlConstant("</span>");
    inner.setInnerHTML(html.toSafeHtml().asString());
}
 
Example #16
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example #17
Source File: Util.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Download file by path
 */
@Deprecated
public static void downloadFile(String path, String params) {
	if (!params.equals("") && !params.endsWith("&")) {
		params += "&";
	}

	final Element downloadIframe = RootPanel.get("__download").getElement();
	String url = RPCService.DownloadServlet + "?" + params + "path=" + URL.encodeQueryString(path);
	DOM.setElementAttribute(downloadIframe, "src", url);
}
 
Example #18
Source File: ExtendedTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * collectElementChain
 */
private void collectElementChain(Vector<Element> chain, Element elementRoot, Element element) {
	if ((element == null) || element == elementRoot)
		return;

	collectElementChain(chain, elementRoot, DOM.getParent(element));
	chain.add(element);
}
 
Example #19
Source File: SearchFilterField.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
public void setIcon(AbstractImagePrototype icon) {
    if (rendered) {
        El oldIcon = el().selectNode(style);
        if (oldIcon != null) {
            oldIcon.remove();
        }
        if (icon != null) {
            Element e = icon.createElement().cast();
            El.fly(e).addStyleName(style);
            el().insertChild(e, 0);
        }
    }
    this.icon = icon;
}
 
Example #20
Source File: ExtendedTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detects whether mouse cursor is inside actual item.
 *
 * @return returns true if mouse cursor is inside actual item
 */
private boolean isCursorInsideActualItem(TreeItem clickedItem) {
	if (clickedItem == null) {
		return false;
	}

	Element selectedElement = Draggable.getSelectedElement(clickedItem.getElement());

	if (selectedElement == null) {
		return false;
	}

	return mouseX >= selectedElement.getAbsoluteLeft() && mouseX <= selectedElement.getAbsoluteRight()
			&& mouseY >= selectedElement.getAbsoluteTop() && mouseY <= selectedElement.getAbsoluteBottom();
}
 
Example #21
Source File: AbstractTextOutput.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void ensureElement(Element element) {
	if (this.text != null) {
		this.setText(this.text);
	}
	this.setStyle(this.style);
}
 
Example #22
Source File: Util.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * downloadFilesByUUID
 */
public static void downloadFilesByUUID(List<String> uuidList, String params) {
	if (!params.equals("")) {
		params = "&" + params;
	}

	final Element downloadIframe = RootPanel.get("__download").getElement();
	String url = RPCService.DownloadServlet + "?export" + params;

	for (String uuid : uuidList) {
		url += "&uuidList=" + URL.encodeQueryString(uuid);
	}

	DOM.setElementAttribute(downloadIframe, "src", url);
}
 
Example #23
Source File: VDDVerticalSplitPanel.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the drop details while dragging. This is needed to ensure client
 * side criterias can validate the drop location.
 * 
 * @param event
 *            The drag event
 */
protected void updateDragDetails(VDragEvent event) {
    Element over = event.getElementOver();

    // Resolve where the drop was made
    VerticalDropLocation location = null;
    Widget content = null;
    if (firstContainer.isOrHasChild(over)) {
        location = VerticalDropLocation.TOP;
        content = Util.findWidget(firstContainer, null);
    } else if (splitter.isOrHasChild(over)) {
        location = VerticalDropLocation.MIDDLE;
        content = this;
    } else if (secondContainer.isOrHasChild(over)) {
        location = VerticalDropLocation.BOTTOM;
        content = Util.findWidget(secondContainer, null);
    }

    event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION,
            location);

    if (content != null) {
        event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS,
                content.getClass().getName());
    } else {
        event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS,
                this.getClass().getName());
    }

    // Add mouse event details
    MouseEventDetails details = MouseEventDetailsBuilder
            .buildMouseEventDetails(event.getCurrentGwtEvent(),
                    getElement());
    event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT,
            details.serialize());
}
 
Example #24
Source File: AbstractOutput.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Element ensureElement() {
	if (this.element == null) {
		this.element = (Element) Document.get().createElement(this.tag);
		this.setElement(this.element);
		StyleUtils.initStyle(this);
		StyleUtils.addStyle(this.element, EditorOutput.STYLE_CONTROL_STATIC);
		this.ensureElement(this.element);
	}
	return this.element;
}
 
Example #25
Source File: IframeCoverUtility.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Removes a iframe cover
 * 
 * @param iframe
 *            The iframe element which has been covered
 */
private static void removeIframeCover(Element iframe) {
    Element coverContainer = iframeCoverMap.get(iframe);
    if (coverContainer != null) {
        Element parent = coverContainer.getParentElement().cast();
        parent.replaceChild(iframe, coverContainer);
        iframe.getStyle().clearPosition();
        iframeCoverMap.remove(iframe);
    }
}
 
Example #26
Source File: IframeCoverUtility.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Adds iframe covers for all child iframe elements
 * 
 * @param rootElement
 *            The parent element
 * @return A set of elements with the iframe covers
 */
private static Set<Element> addIframeCovers(Element rootElement) {
    Set<Element> coveredIframes = new HashSet<Element>();
    NodeList<com.google.gwt.dom.client.Element> iframes = rootElement
            .getElementsByTagName("iframe");
    for (int i = 0; i < iframes.getLength(); i++) {
        Element iframe = (Element) iframes.getItem(i);
        addIframeCover(iframe);
        coveredIframes.add(iframe);
    }
    return coveredIframes;
}
 
Example #27
Source File: IframeCoverUtility.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Enable IFrame covers for a element
 * 
 * @param enabled
 *            Enable/Disable Iframe covers
 * @param root
 *            The root element where to put the IFrame covers
 */
public void setIframeCoversEnabled(final boolean enabled,
        final Element root, final LayoutDragMode mode) {
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            if (enabled && mode != LayoutDragMode.NONE) {
                coveredIframes = addIframeCovers(root);
            } else if (coveredIframes != null) {
                removeIframeCovers(coveredIframes);
                coveredIframes = null;
            }
        }
    });
}
 
Example #28
Source File: VDDAccordion.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Emphasisizes a container element
 * 
 * @param element
 */
protected void emphasis(Element element, VDragEvent event) {

    // Find the tab
    StackItem tab = WidgetUtil.findWidget(element, StackItem.class);
    if (tab != null && getElement().isOrHasChild(tab.getElement())
            && currentlyEmphasised != tab) {
        VerticalDropLocation location = getDropLocation(tab, event);

        if (location == VerticalDropLocation.MIDDLE) {
            if (tab.isOpen()) {
                tab.addStyleName(CLASSNAME_OVER);
            } else {
                tab.getWidget(0).addStyleName(CLASSNAME_OVER);
            }
        } else if (!spacer.isAttached()) {
            if (location == VerticalDropLocation.TOP) {
                insertSpacer(spacer, getElement(), getWidgetIndex(tab));
                tab.setHeight(
                        (tab.getOffsetHeight() - spacer.getOffsetHeight())
                                + "px");
            } else if (location == VerticalDropLocation.BOTTOM) {
                insertSpacer(spacer, getElement(), getWidgetIndex(tab) + 1);
                int newHeight = tab.getOffsetHeight()
                        - spacer.getOffsetHeight();
                if (getWidgetIndex(spacer) == getWidgetCount() - 1) {
                    newHeight -= spacer.getOffsetHeight();
                }
                if (newHeight >= 0) {
                    tab.setHeight(newHeight + "px");
                }
            }
        }
        currentlyEmphasised = tab;
    }
}
 
Example #29
Source File: ListPopupPanel2.java    From consulo with Apache License 2.0 5 votes vote down vote up
/** See class docs */
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent nativePreviewEvent) {
  if (nativePreviewEvent.getTypeInt() != Event.ONCLICK) {
    return;
  }

  Element source = (Element) Element.as(nativePreviewEvent.getNativeEvent().getEventTarget());
  if (!DOM.isOrHasChild(getElement(), source)
      && !DOM.isOrHasChild(getComboBox().getElement(), source)) {
    hide();
    getComboBox().getChoiceButton().setDown(false);
  }
}
 
Example #30
Source File: Util.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Download file
 */
public static void downloadFilePdf(String uuid) {
	final Element downloadIframe = RootPanel.get("__download").getElement();
	String url = RPCService.ConverterServlet + "?inline=false&toPdf=true&uuid=" + URL.encodeQueryString(uuid);
	DOM.setElementAttribute(downloadIframe, "src", url);
	Main.get().conversionStatus.getStatus();
}