Example usage for com.google.gwt.user.client Element getId

List of usage examples for com.google.gwt.user.client Element getId

Introduction

In this page you can find the example usage for com.google.gwt.user.client Element getId.

Prototype

@Override
    public String getId() 

Source Link

Usage

From source file:com.extjs.gxt.ui.client.widget.tree.Tree.java

License:Open Source License

/**
 * Returns the tree whose element or child elements match the passed target.
 * //from ww  w. ja v a 2s . c  o m
 * @param element the target element
 * @return the matching tree item or <code>null</code> if no match
 */
public TreeItem findItem(Element element) {
    Element elem = fly(element).findParentElement(itemSelector, 15);
    if (elem != null) {
        String id = elem.getId();
        if (id != null && !id.equals("")) {
            TreeItem item = getItemById(id);
            return item;
        }
    }
    return null;
}

From source file:com.extjs.gxt.ui.client.widget.treepanel.TreePanel.java

License:sencha.com license

/**
 * Returns the tree node for the given target.
 * //from  w ww .  ja v a  2  s .co m
 * @param target the target element
 * @return the tree node or null if no match
 */
public TreeNode findNode(Element target) {
    Element item = fly(target).findParentElement(itemSelector, 10);
    if (item != null) {
        String id = item.getId();
        TreeNode node = nodes.get(id);
        return node;
    }
    return null;
}

From source file:com.qualogy.qafe.gwt.client.component.MapWidget.java

License:Apache License

public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
    case Event.ONCLICK:
        if (items != null && items.length > 0) {
            Element target = DOM.eventGetTarget(event);
            for (int i = 0; i < items.length; i++) {
                if (items[i].getElement() != null) {
                    //   if (DOM.compare(target, items[i].getElement())) {
                    if (target.getId() != null && target.getId().equals(items[i].getElement().getId())) {
                        Command command = items[i].getCommand();
                        if (command != null) {
                            DeferredCommand.addCommand(command);
                        }//from  w w  w.  j  av  a2s . c om
                    }
                }
            }
            DOM.eventPreventDefault(event);
            return;
        }
    }
    super.onBrowserEvent(event);
}

From source file:com.vaadin.client.ui.AriaHelper.java

License:Apache License

/**
 * Makes sure that the provided element has an id attribute. Adds a new
 * unique id if not.//from   w w w . j  a v  a2s  . c  o  m
 * 
 * @param element
 *            Element to check
 * @return String with the id of the element
 */
public static String ensureUniqueId(Element element) {
    assert element != null : "Valid Element required";

    String id = element.getId();
    if (null == id || id.isEmpty()) {
        id = DOM.createUniqueId();
        element.setId(id);
    }
    return id;
}

From source file:fr.fg.client.openjwt.OpenJWT.java

License:Open Source License

public final static Element getElementById(String id, Element parent) {
    if (parent == null)
        return null;

    if (parent.getId() != null && parent.getId().equals(id))
        return parent;

    int count = parent.getChildNodes().getLength();

    for (int i = 0; i < count; i++) {
        Element element = getElementById(id, DOM.getChild(parent, i));
        if (element != null)
            return element;
    }/*from   www  .  j  a va2  s.  c  o  m*/

    return null;
}

From source file:fr.putnami.pwt.core.widget.client.base.AbstractHTMLPanel.java

License:Open Source License

@Override
public void addAndReplaceElement(Widget widget, com.google.gwt.user.client.Element toReplace) {
    this.addEditor(widget);
    String elementId = toReplace.getId();
    this.children.put(widget, elementId);
    toReplace.removeAttribute("id");
    super.addAndReplaceElement(widget, toReplace);
}

From source file:ilarkesto.gwt.client.AWidget.java

License:Open Source License

protected void onUpdate() {
    Element element = wrapper.getElement();
    String newId = getId();//from   w ww. j a  v  a2 s  .  co  m
    if (element.getId() != newId)
        element.setId(newId);
    Gwt.update(wrapper.getWidget());
}

From source file:org.bonitasoft.web.toolkit.client.ViewController.java

License:Open Source License

public static RawView showView(final RawView view, final Element rootElement,
        final TreeIndexed<String> params) {
    // Set the parent Element to the view that will be displayed
    view.setParentElement(rootElement);/*  ww w  .j av  a2 s . c  o m*/

    if (ViewController.ROOT_DIV_ID.equals(rootElement.getId())) {

        // Reset useless elements
        ViewController.closePopup();
        // getInstance().componentsWaitingForRefresh.clear();
        getInstance().currentPage = view;
        getInstance().setCurrentPageToken(view.getToken());

        // Set the URL
        // if (!BlankPage.TOKEN.equals(view.getToken())) {
        ClientApplicationURL.setPageToken(view.getToken(), false);
        // }
        ClientApplicationURL.setPageAttributes(params);
        ClientApplicationURL.refreshUrl(false);
    }

    final CustomPanel widget = view.toWidget();
    final Element widgetElement = widget.getElement();

    if (view instanceof AngularIFrameView) {
        if (!isAngularFrameDisplayed) {
            $(rootElement).empty();
            rootElement.appendChild(widgetElement);
        }
        ((AngularIFrameView) view).display(params);
        isAngularFrameDisplayed = true;
    } else {
        if (view.getToken() != null && !view.getToken().trim().equals("")) {
            isAngularFrameDisplayed = false;
        }
        if (view instanceof PageOnItem<?>) {
            $(widgetElement).hide();
        } else {
            $(rootElement).empty();
        }
        rootElement.appendChild(widgetElement);
    }

    ViewController.updateUI(rootElement, true);
    widget.onLoad();

    MainEventBus.getInstance().fireEventFromSource(new ChangeViewEvent(view), getInstance());

    return view;
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.CriterionTestHelper.java

License:Open Source License

static VDropHandler createMockedVDropHandler(String dropTargetId) {
    com.google.gwt.user.client.Element element = Mockito.mock(com.google.gwt.user.client.Element.class);
    when(element.getId()).thenReturn(dropTargetId);
    Widget widget = Mockito.mock(Widget.class);
    when(widget.getElement()).thenReturn(element);
    ComponentConnector connector = Mockito.mock(ComponentConnector.class);
    when(connector.getWidget()).thenReturn(widget);
    VDropHandler dropHandler = Mockito.mock(VDropHandler.class);
    when(dropHandler.getConnector()).thenReturn(connector);

    return dropHandler;
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.CriterionTestHelper.java

License:Open Source License

static VDragEvent createMockedVDragEvent(String dragSourceId, Widget widget) {
    com.google.gwt.user.client.Element element = Mockito.mock(com.google.gwt.user.client.Element.class);
    when(element.getId()).thenReturn(dragSourceId);
    when(widget.getElement()).thenReturn(element);
    ComponentConnector dragSource = Mockito.mock(ComponentConnector.class);
    when(dragSource.getWidget()).thenReturn(widget);
    VTransferable transferable = Mockito.mock(VTransferable.class);
    when(transferable.getDragSource()).thenReturn(dragSource);
    VDragEvent dragEvent = Mockito.mock(VDragEvent.class);
    when(dragEvent.getTransferable()).thenReturn(transferable);

    return dragEvent;
}