Example usage for com.google.gwt.event.logical.shared SelectionEvent fire

List of usage examples for com.google.gwt.event.logical.shared SelectionEvent fire

Introduction

In this page you can find the example usage for com.google.gwt.event.logical.shared SelectionEvent fire.

Prototype

public static <T> void fire(HasSelectionHandlers<T> source, T selectedItem) 

Source Link

Document

Fires a selection event on all registered handlers in the handler manager.If no such handlers exist, this method will do nothing.

Usage

From source file:org.eclipse.che.ide.ui.smartTree.SelectionModel.java

License:Open Source License

protected void doSingleSelect(Node node, boolean suppressEvent) {
    int index;/*  w  w  w . j  a v  a2s.co m*/
    index = nodeStorage.indexOf(node);
    if (index == -1 || isSelected(node)) {
        return;
    } else {
        if (!suppressEvent) {
            BeforeSelectionEvent<Node> evt = BeforeSelectionEvent.fire(this, node);
            if (evt != null && evt.isCanceled()) {
                return;
            }
        }
    }

    boolean change = false;
    if (selectionStorage.size() > 0 && !isSelected(node)) {
        doDeselect(Collections.singletonList(lastSelectedNode), true);
        change = true;
    }

    if (selectionStorage.size() == 0) {
        change = true;
    }

    selectionStorage.add(node);
    lastSelectedNode = node;
    onSelectChange(node, true);
    setLastFocused(lastSelectedNode);

    if (!suppressEvent) {
        SelectionEvent.fire(this, node);
    }

    if (change && !suppressEvent) {
        fireSelectionChange();
    }
}

From source file:org.eclipse.che.ide.ui.smartTree.SelectionModel.java

License:Open Source License

protected void doMultiSelect(List<Node> nodes, boolean keepExisting, boolean suppressEvent) {
    boolean change = false;
    if (!keepExisting && selectionStorage.size() > 0) {
        change = true;//from   ww  w  .ja v a 2s .  c  o m
        doDeselect(new ArrayList<>(selectionStorage), true);
    }

    for (Node node : nodes) {
        boolean isSelected = isSelected(node);
        if (!suppressEvent && !isSelected) {
            BeforeSelectionEvent<Node> evt = BeforeSelectionEvent.fire(this, node);
            if (evt != null && evt.isCanceled()) {
                continue;
            }
        }

        change = true;
        lastSelectedNode = node;

        selectionStorage.add(node);
        setLastFocused(lastSelectedNode);

        if (!isSelected) {
            onSelectChange(node, true);
            if (!suppressEvent) {
                SelectionEvent.fire(this, node);
            }
        }
    }

    if (change && !suppressEvent) {
        fireSelectionChange();
    }
}

From source file:org.eclipse.che.ide.ui.smartTree.TreeSelectionModel.java

License:Open Source License

protected void doMultiSelect(List<Node> nodes, boolean keepExisting, boolean suppressEvent) {
    boolean change = false;
    if (!keepExisting && selectionStorage.size() > 0) {
        change = true;//w  w  w .ja  v a 2 s.  com
        doDeselect(new ArrayList<>(selectionStorage), false);
    }

    for (Node node : nodes) {
        boolean isSelected = isSelected(node);
        if (!suppressEvent && !isSelected) {
            BeforeSelectionEvent<Node> evt = BeforeSelectionEvent.fire(this, node);
            if (evt != null && evt.isCanceled()) {
                continue;
            }
        }

        change = true;
        lastSelectedNode = node;

        selectionStorage.add(node);
        setLastFocused(lastSelectedNode);

        if (!isSelected) {
            onSelectChange(node, true);
            if (!suppressEvent) {
                SelectionEvent.fire(this, node);
            }
        }
    }

    if (change && !suppressEvent) {
        fireSelectionChange();
    }
}

From source file:org.iplantc.de.tags.client.views.TagItemImpl.java

License:Apache License

@Inject
TagItemImpl(final CustomIplantTagResources resources, @Assisted final Tag tag) {
    this.resources = resources;
    this.resources.style().ensureInjected();
    this.tag = tag;

    initWidget(uiBinder.createAndBindUi(this));

    this.tagDiv.setAttribute("class", resources.style().tag());
    this.value.setStylePrimaryName(resources.style().tagCaption());

    this.value.setText(tag.getValue());

    tagPanel.addDomHandler(new ClickHandler() {

        @Override// w ww. ja  v a2 s  .  c o m
        public void onClick(ClickEvent event) {
            Element e = Element.as(event.getNativeEvent().getEventTarget());
            if (e.getAttribute("name").contains("tagEdit")) {
                fireEvent(new EditTagSelected(tag));
            } else if (e.getAttribute("name").contains("tagDelete")) {
                fireEvent(new RemoveTagSelected(tag));
            } else {
                SelectionEvent.fire(TagItemImpl.this, tag);
            }

        }
    }, ClickEvent.getType());

    activateDnD();
}

From source file:org.jbpm.formbuilder.client.effect.view.ValidationTablePanel.java

License:Apache License

protected void fireSelectedValidation() {
    SelectionEvent.fire(this, this.selectedValidation);
}

From source file:org.komodo.web.client.panels.vdb.editor.diag.tree.TreeCanvas.java

License:Open Source License

@Override
protected void fireSelectionEvent() {
    if (selectionHandler == null)
        return;//  w w w  . ja va2  s  .c  o  m

    final List<KomodoObjectBean> selectedObjects = new ArrayList<KomodoObjectBean>();

    String selectedClass = DOT + css().selected();
    final Selection selection = svgGroup.selectAll(selectedClass);
    if (selection.empty()) {
        SelectionEvent.fire(selectionHandler, selectedObjects.toArray(new KomodoObjectBean[0]));
        return;
    }

    /*
     * The selection contains the rectangles used for displaying the selection
     *  so have to find their accompanying data.
     */
    selection.each(new DatumFunction<Void>() {

        @Override
        public Void apply(Element element, Value jsNode, final int index) {
            Value idValue = jsNode.getProperty(ID);
            String path = idValue.asString();

            KomodoRpcService service = KomodoRpcService.get();
            service.getKomodoNode(path, new IRpcServiceInvocationHandler<KomodoObjectBean>() {

                @Override
                public void onReturn(KomodoObjectBean kObject) {
                    selectedObjects.add(kObject);

                    if (index == selection.size() - 1)
                        SelectionEvent.fire(selectionHandler, selectedObjects.toArray(new KomodoObjectBean[0]));
                }

                @Override
                public void onError(Throwable error) {
                    Window.alert("Failed to process the selected nodes: " + error.getMessage()); //$NON-NLS-1$
                    LOGGER.log(Level.SEVERE, "Node selection failure", error); //$NON-NLS-1$
                }
            });

            return null;
        }
    });
}

From source file:org.obiba.opal.web.gwt.app.client.ui.AbstractTabPanel.java

License:Open Source License

/**
 * Programmatically selects the specified tab.
 *
 * @param index the index of the tab to be selected
 * @param fireEvents true to fire events, false not to
 *///from  w w  w  . j av a  2  s. co m
public void selectTab(int index, boolean fireEvents) {
    checkIndex(index);
    if (index == selectedIndex) {
        return;
    }

    // Fire the before selection event, giving the recipients a chance to
    // cancel the selection.
    if (fireEvents) {
        BeforeSelectionEvent<Integer> event = BeforeSelectionEvent.fire(this, index);
        if (event != null && event.isCanceled()) {
            return;
        }
    }

    // Update the tabs being selected and unselected.
    setSelectedIndex(index);

    // Fire the selection event.
    if (fireEvents) {
        SelectionEvent.fire(this, index);
    }

}

From source file:org.openelis.gwt.widget.DropdownWidget.java

License:Open Source License

public void onClick(ClickEvent event) {
    Cell cell = ((FlexTable) event.getSource()).getCellForEvent(event);
    int row = cell.getRowIndex();
    int col = cell.getCellIndex();
    if (getHandlerCount(BeforeSelectionEvent.getType()) > 0) {
        BeforeSelectionEvent<TableRow> be = BeforeSelectionEvent.fire(this, renderer.rows.get(row));
        if (be.isCanceled())
            return;
    } else if (!isEnabled()) {
        return;/*from  w  ww .  j  a v  a 2s.co  m*/
    }
    if (selectedRow > -1 && ((multiSelect && !ctrlKey) || !multiSelect)) {
        unselect(-1);
    }
    if (multiSelect && ctrlKey && isSelected(modelIndexList[row])) {
        unselect(modelIndexList[row]);
    } else {
        selectedRow = row;
        selectRow(modelIndexList[row]);
    }
    SelectionEvent.fire(this, renderer.rows.get(row));
    if (!multiSelect || (!ctrlKey && multiSelect))
        complete();

}

From source file:org.openelis.gwt.widget.DropdownWidget.java

License:Open Source License

public void onKeyDown(KeyDownEvent event) {
    if (!popup.isShowing())
        return;/*  ww w . j  a  v  a  2  s.co  m*/
    event.stopPropagation();
    if (event.getNativeKeyCode() == KeyCodes.KEY_CTRL)
        ctrlKey = true;
    if (event.getNativeKeyCode() == KeyCodes.KEY_SHIFT)
        shiftKey = true;
    if (KeyCodes.KEY_DOWN == event.getNativeKeyCode()) {
        if (selectedRow >= 0 && selectedRow < numRows() - 1) {
            final int row = findNextActive(selectedRow);
            if (!isRowDrawn(row)) {
                view.setScrollPosition(view.top + (cellHeight * (row - selectedRow)));
            }
            selectRow(row);
        } else if (selectedRow < 0) {
            selectRow(0);
        }
    }
    if (KeyCodes.KEY_UP == event.getNativeKeyCode()) {
        if (selectedRow > 0) {
            final int row = findPrevActive(selectedRow);
            if (!isRowDrawn(row)) {
                view.setScrollPosition(view.top - (cellHeight * (selectedRow - row)));
            }
            selectRow(row);
        }
    }
    if (KeyCodes.KEY_ENTER == event.getNativeKeyCode() || KeyCodes.KEY_TAB == event.getNativeKeyCode()) {
        if (selectedRow > -1) {
            itemSelected = true;
            SelectionEvent.fire(this, renderer.rows.get(tableIndex(selectedRow)));
            complete();
        }
    }
    if (KeyCodes.KEY_ESCAPE == event.getNativeKeyCode()) {
        complete();
    }

}

From source file:org.openelis.gwt.widget.ScrollableTabBar.java

License:Open Source License

public ScrollableTabBar() {
    barScroller = new TabBarScroller(tabBar);
    initWidget(barScroller);/*  www  . j a v a2  s . c o  m*/

    final HasSelectionHandlers<Integer> source = this;
    tabBar.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            SelectionEvent.fire(source, event.getSelectedItem());
            barScroller.scrollToSelected();
        }
    });

}