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

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

Introduction

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

Prototype

public static <T> BeforeSelectionEvent<T> fire(HasBeforeSelectionHandlers<T> source, T item) 

Source Link

Document

Fires a before selection event on all registered handlers in the handler manager.

Usage

From source file:at.ac.fhcampuswien.atom.client.gui.frames.TabLayoutPanelCopy.java

License:Apache 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
 *///w  w  w . j  a  v  a 2  s . com
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.
    if (selectedIndex != -1) {
        tabs.get(selectedIndex).setSelected(false);
    }

    deckPanel.showWidget(index);
    tabs.get(index).setSelected(true);
    selectedIndex = index;

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

From source file:bufferings.ktr.wjr.client.ui.widget.WjrTabPanel.java

License:Apache License

/**
 * Selects the tab and show its contents.
 * /*  ww w . j  a  v  a2s.  co m*/
 * @param index
 *          The index of the tab to show.
 */
public void selectTab(int index) {
    checkIndex(index);
    if (index == selectedIndex) {
        return;
    }

    BeforeSelectionEvent<Integer> event = BeforeSelectionEvent.fire(this, index);
    if ((event != null) && event.isCanceled()) {
        return;
    }

    if (selectedIndex != -1) {
        Widget child = children.get(selectedIndex);
        Element container = panel.getWidgetContainerElement(child);
        container.getStyle().setDisplay(Display.NONE);
        child.setVisible(false);
        tabs.get(selectedIndex).setSelected(false);
    }

    Widget child = children.get(index);
    Element container = panel.getWidgetContainerElement(child);
    container.getStyle().clearDisplay();
    child.setVisible(true);
    tabs.get(index).setSelected(true);
    selectedIndex = index;

    SelectionEvent.fire(this, index);
}

From source file:cc.alcina.framework.gwt.client.widget.CustomisableTabPanel.java

License:Apache License

/**
 * @deprecated Use {@link BeforeSelectionHandler#onBeforeSelection} instead
 */// ww w  .  java 2 s. co  m
@Deprecated
public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
    BeforeSelectionEvent<Integer> event = BeforeSelectionEvent.fire(this, tabIndex);
    return event == null || !event.isCanceled();
}

From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java

License:Apache License

/**
 * Programmatically selects the specified tab. Use index -1 to specify that
 * no tab should be selected.//from w  w  w  .j a va 2 s  .c om
 * 
 * @param index
 *            the index of the tab to be selected.
 * @return <code>true</code> if successful, <code>false</code> if the change
 *         is denied by the {@link TabListener}.
 */
public boolean selectTab(int index) {
    BeforeSelectionEvent<?> event = BeforeSelectionEvent.fire(this, index);
    if (event != null && event.isCanceled()) {
        return false;
    }
    // Check for -1.
    setSelectionStyle(selectedTab, false);
    if (index == -1) {
        selectedTab = null;
        return true;
    }
    selectedTab = tabs.get(index);
    setSelectionStyle(selectedTab, true);
    SelectionEvent.fire(this, index);
    return true;
}

From source file:com.agnie.gwt.common.client.widget.TabBar.java

License:Open Source License

/**
 * Programmatically selects the specified tab. Use index -1 to specify that no tab should be selected.
 * //from   w  w w . j  a  v  a 2 s. com
 * @param index
 *            the index of the tab to be selected
 * @param fireEvents
 *            true to fire events, false not to
 * @return <code>true</code> if successful, <code>false</code> if the change is denied by the
 *         {@link BeforeSelectionHandler}.
 */
public boolean selectTab(int index, boolean fireEvents) {
    checkTabIndex(index);

    if (fireEvents) {
        BeforeSelectionEvent<?> event = BeforeSelectionEvent.fire(this, index);
        if (event != null && event.isCanceled()) {
            return false;
        }
    }

    // Check for -1.
    setSelectionStyle(selectedTab, false);
    if (index == -1) {
        selectedTab = null;
        return true;
    }

    selectedTab = panel.getWidget(index);
    setSelectionStyle(selectedTab, true);
    if (fireEvents) {
        SelectionEvent.fire(this, index);
    }
    return true;
}

From source file:com.agnie.gwt.common.client.widget.WizardBar.java

License:Open Source License

private boolean checkForBeforeSelectionEvent(int index) {

    BeforeSelectionEvent<?> event = BeforeSelectionEvent.fire(this, index);
    if (event != null && event.isCanceled()) {
        return false;
    }//from w w  w  .  ja  va2  s  . c o  m
    return true;
}

From source file:com.edgenius.wiki.gwt.client.widgets.URLTabBar.java

License:Open Source License

public int addTab(String title, Image icon) {
    FlowPanel tab = new FlowPanel();
    if (icon != null)
        tab.add(icon);//from w  w w .  j a va2 s.com

    ClickLink link = new ClickLink(title);
    Label label = new Label(title);
    tab.add(link);
    tab.add(label);
    link.setStyleName(Css.TEXT);
    label.setStyleName(Css.TEXT);
    //init status: only show link
    label.setVisible(false);
    //tab.setStyleName(Css.DESELECTED);
    tabBar.add(tab);

    //increase uniqueID every new tab
    final int tabIndex = uniqueID++;
    link.setObject(tabIndex);

    link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            BeforeSelectionEvent<Integer> evt = BeforeSelectionEvent.fire(URLTabBar.this, tabIndex);
            if (evt != null && !evt.isCanceled()) {
                select(tabIndex);
                SelectionEvent.fire(URLTabBar.this, tabIndex);

            }
        }
    });

    return tabIndex;
}

From source file:com.edgenius.wiki.gwt.client.widgets.URLTabPanel.java

License:Open Source License

/**
 * !!! This method must call after the widget is put into HMTL body. Please refer to 
 * URLPanel.setURL()//from  www  . ja  v a 2s.  c  om
 * 
 * @param uniqueID
 * @param fireEvent: TODO: 
 */
public void setSelected(int uniqueID, boolean fireEvent) {
    boolean go = true;
    if (fireEvent) {
        BeforeSelectionEvent<Integer> evt = BeforeSelectionEvent.fire(this, uniqueID);
        go = evt != null ? !evt.isCanceled() : false;
    }
    if (go) {
        tabBar.select(uniqueID);
        select(uniqueID);
        if (fireEvent)
            SelectionEvent.fire(this, uniqueID);

    }

}

From source file:com.edgenius.wiki.gwt.client.widgets.URLTabPanel.java

License:Open Source License

/**
 * The reason call uniqueID rather than tabIdx is,  tabIdx maybe change for each tab if there is
 * insert etc method. But uniqueID won't. Actually, here uniqueID == tabIdx
 *//* www . ja  v  a  2s. co  m*/
public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
    //OK,if choose same tab, do nothing 
    Integer uniqueID = event.getItem();
    if (selected == uniqueID) {
        event.cancel();
        return;
    }

    BeforeSelectionEvent.fire(this, uniqueID);

    LazyLoadingPanel lazyPanel = lazy.get(uniqueID);
    if (lazyPanel != null) {
        lazyPanel.load();
    }

}

From source file:com.sencha.gxt.widget.core.client.menu.Item.java

License:sencha.com license

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void onClick(NativeEvent be) {
    be.<XEvent>cast().stopEvent();

    BeforeSelectionEvent<Item> itemEvent = BeforeSelectionEvent.fire(this, this);

    BeforeSelectionEvent<Item> menuEvent = null;

    if (getParent() instanceof HasBeforeSelectionHandlers<?>) {
        menuEvent = BeforeSelectionEvent.fire((HasBeforeSelectionHandlers) getParent(), this);
    }//from  w w  w . jav a  2  s.  co  m

    if (!disabled && (itemEvent == null || !itemEvent.isCanceled())
            && (menuEvent == null || !menuEvent.isCanceled())) {
        if (getParent() instanceof HasSelectionHandlers<?>) {
            SelectionEvent.fire((HasSelectionHandlers) getParent(), this);
        }

        SelectionEvent.fire(this, this);
        handleClick(be);
    }
}