Example usage for com.google.gwt.user.client.ui TabBar addBeforeSelectionHandler

List of usage examples for com.google.gwt.user.client.ui TabBar addBeforeSelectionHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TabBar addBeforeSelectionHandler.

Prototype

public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Integer> handler) 

Source Link

Usage

From source file:com.google.gwt.examples.TabBarExample.java

License:Apache License

public void onModuleLoad() {
    // Create a tab bar with three items.
    TabBar bar = new TabBar();
    bar.addTab("foo");
    bar.addTab("bar");
    bar.addTab("baz");

    // Hook up a tab listener to do something when the user selects a tab.
    bar.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            // Let the user know what they just did.
            Window.alert("You clicked tab " + event.getSelectedItem());
        }/*from  www  . j a va  2  s. c  o m*/
    });

    // Just for fun, let's disallow selection of 'bar'.
    bar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            if (event.getItem().intValue() == 1) {
                event.cancel();
            }
        }
    });

    // Add it to the root panel.
    RootPanel.get().add(bar);
}

From source file:tn.spindox.client.ui.TabBarExample.java

License:Apache License

public TabBar onModuleLoad() {
    // Create a tab bar with three items.
    TabBar bar = new TabBar();
    bar.addTab("Person Management");
    bar.addTab("Technology Area Management");
    bar.addTab("Technology Management");
    bar.addTab("Competence Management");

    // Hook up a tab listener to do something when the user selects a tab.
    bar.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            // Let the user know what they just did.
            Window.alert("You clicked tab " + event.getSelectedItem());
        }/* w  w w  . j  a  v  a  2 s  .  co  m*/
    });

    // Just for fun, let's disallow selection of 'bar'.
    bar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            if (event.getItem().intValue() == 1) {
                event.cancel();
            }
        }
    });

    return bar;

}