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

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

Introduction

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

Prototype

public T getSelectedItem() 

Source Link

Document

Gets the selected item.

Usage

From source file:net.cbtltd.client.form.ProductForm.java

public void initialize() {
    AbstractField.CSS.ensureInjected();
    CSS.ensureInjected();/*  www . j a v a  2  s.co m*/

    final ScrollPanel scroll = new ScrollPanel();
    add(scroll);
    final HorizontalPanel panel = new HorizontalPanel();
    panel.addStyleName(AbstractField.CSS.cbtAbstractWidth());
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    scroll.add(panel);
    final HorizontalPanel content = new HorizontalPanel();
    panel.add(content);

    createActions();
    content.add(createContent());
    stackPanel = new StackLayoutPanel(com.google.gwt.dom.client.Style.Unit.EM);
    content.add(stackPanel);
    stackPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            if (event.getSelectedItem() != 0 && productField.noValue()) {
                AbstractField.addMessage(Level.ERROR, CONSTANTS.productError(), productField);
            }
            refreshStackPanel();
        }
    });
    stackPanel.addStyleName(CSS.stackStyle());
    stackPanel.add(createDescription(), CONSTANTS.descriptionLabel(), 1.5);
    stackPanel.add(createText(), CONSTANTS.textLabel(), 1.5);
    stackPanel.add(mapField, CONSTANTS.mapLabel(), 1.5);
    stackPanel.add(imageGallery, CONSTANTS.imageLabel(), 1.5);
    stackPanel.add(createPrice(), CONSTANTS.priceLabel(), 1.5);
    stackPanel.add(createTax(), CONSTANTS.taxLabel(), 1.5);
    stackPanel.add(createYield(), CONSTANTS.yieldLabel(), 1.5);
    stackPanel.add(createFeature(), CONSTANTS.featureLabel(), 1.5);
    stackPanel.add(createAsset(), CONSTANTS.assetLabel(), 1.5);
    stackPanel.add(createAudit(), CONSTANTS.auditLabel(), 1.5);
    stackPanel.add(createAlert(), CONSTANTS.alertLabel(), 1.5);

    productTable = createProduct();
    //      stackPanel.add(createService(), CONSTANTS.serviceLabel(), 1.5);
    createService();
    onRefresh();
    onReset(Product.CREATED);
    triggerResize();
}

From source file:net.cbtltd.client.form.ReservationForm.java

@Override
public void initialize() {
    AbstractField.CSS.ensureInjected();
    CSS.ensureInjected();/*from w w  w  . j a  va 2 s. co  m*/

    final ScrollPanel scroll = new ScrollPanel();
    add(scroll);
    final HorizontalPanel panel = new HorizontalPanel();
    panel.addStyleName(AbstractField.CSS.cbtAbstractWidth());
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    scroll.add(panel);

    final HorizontalPanel content = new HorizontalPanel();
    panel.add(content);

    createActions();

    content.add(createContent());
    stackPanel = new StackLayoutPanel(com.google.gwt.dom.client.Style.Unit.EM);
    content.add(stackPanel);

    stackPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            if (event.getSelectedItem() != 0 && reservationField.noValue()) {
                AbstractField.addMessage(Level.ERROR, CONSTANTS.reservationError(), reservationField);
            }
            refreshStackPanel();
        }
    });

    stackPanel.addStyleName(CSS.stackStyle());
    stackPanel.add(createHospitality(), CONSTANTS.hospitalityLabel(), 1.5);
    stackPanel.add(createFeature(), CONSTANTS.featureLabel(), 1.5);
    stackPanel.add(createMaintenance(), CONSTANTS.maintenanceLabel(), 1.5);
    stackPanel.add(createFinancial(), CONSTANTS.financeLabel(), 1.5);
    createService();
    //      stackPanel.add(createService(), CONSTANTS.serviceLabel(), 1.5);
    onRefresh();
    onReset(Reservation.State.Provisional.name());
}

From source file:net.easysmarthouse.ui.webui.client.view.RootView.java

private void initRootPanel() {
    this.add(rootPanel);

    WelcomeLabel welcomeLabel = new WelcomeLabel(rootMessages.labelTextWelcome());
    RootPanel.get("welcome").add(welcomeLabel);

    Hyperlink logoutLink = new Hyperlink();
    logoutLink.setText(rootMessages.hyperlinkTextLogout());
    logoutLink.addDomHandler(new LogoutHandler(), ClickEvent.getType());
    RootPanel.get("logout").add(logoutLink);

    HorizontalPanel headerPanel = new HorizontalPanel();
    rootPanel.add(headerPanel);//from  w w  w.j a v a2 s. com

    tabsIndexes = new HashMap<Integer, PanelKey>();

    final Panel signalingPanel = PanelManager.addPanel(PanelKey.SIGNALING);
    tabPanel.add(signalingPanel, rootMessages.panelTabsTitleSignaling());
    tabsIndexes.put(0, PanelKey.SIGNALING);

    final Panel monitoringPanel = PanelManager.addPanel(PanelKey.MONITORING);
    tabPanel.add(monitoringPanel, rootMessages.panelTabsTitleClimate());
    tabsIndexes.put(1, PanelKey.MONITORING);

    final Panel switchingPanel = PanelManager.addPanel(PanelKey.SWITCHING);
    tabPanel.add(switchingPanel, rootMessages.panelTabsTitleLight());
    tabsIndexes.put(2, PanelKey.SWITCHING);

    final Panel devicePanel = PanelManager.addPanel(PanelKey.CAMERAS);
    tabPanel.add(devicePanel, rootMessages.panelTabsTitleCameras());
    tabsIndexes.put(3, PanelKey.CAMERAS);

    final Panel triggerPanel = PanelManager.addPanel(PanelKey.TRIGGER);
    tabPanel.add(triggerPanel, rootMessages.panelTabsTitleTriggers());
    tabsIndexes.put(4, PanelKey.TRIGGER);

    fireHistoryChange(History.getToken());

    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            final Integer item = event.getSelectedItem();
            final PanelKey key = tabsIndexes.get(item);

            controller.call(new MvcEvent<PanelKey>(RootControllerAction.TAB_SELECTED, key));
        }
    });

    rootPanel.add(tabPanel);
    rootPanel.setCellHorizontalAlignment(tabPanel, HasHorizontalAlignment.ALIGN_CENTER);
}

From source file:net.officefloor.demo.stocks.client.StockGraphWidget.java

License:Open Source License

/**
 * Initiate.// w w w .ja v  a  2s  . com
 * 
 * @param historyPeriod
 *            Time in milliseconds to display history of prices.
 * @param redrawPeriod
 *            Time in milliseconds to allow before complete redraw of the
 *            graph.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param stocks
 *            {@link Stock} instances to graph.
 */
public StockGraphWidget(final long historyPeriod, final long redrawPeriod, final String width,
        final String height, Stock... stocks) {

    // Create sorted copy of stocks
    final Stock[] orderedStocks = new Stock[stocks.length];
    for (int i = 0; i < orderedStocks.length; i++) {
        orderedStocks[i] = stocks[i];
    }
    Arrays.sort(orderedStocks, new Comparator<Stock>() {
        @Override
        public int compare(Stock a, Stock b) {
            return String.CASE_INSENSITIVE_ORDER.compare(a.getName(), b.getName());
        }
    });

    // Load the chart visualisation
    Runnable loadGraph = new Runnable() {
        @Override
        public void run() {

            // Provide tab panel for graphs
            TabPanel tab = new TabPanel();
            tab.setWidth(width);
            tab.getTabBar().setWidth(width);
            tab.getDeckPanel().setWidth(width);
            StockGraphWidget.this.add(tab);

            // Load each graph onto a tab
            final StockGraph[] graphs = new StockGraph[orderedStocks.length];
            for (int i = 0; i < orderedStocks.length; i++) {
                Stock stock = orderedStocks[i];

                // Create the stock graph
                StockGraph graph = new StockGraph(stock, historyPeriod, redrawPeriod, width, height);
                graphs[i] = graph;

                // Add the stock graph
                tab.add(graph.getChart(), stock.getName());
            }

            // Provide the selection handler
            tab.addSelectionHandler(new SelectionHandler<Integer>() {
                @Override
                public void onSelection(SelectionEvent<Integer> event) {

                    // Unselect all graphs
                    for (StockGraph graph : graphs) {
                        graph.setSelected(false);
                    }

                    // Select the graph for the tab
                    Integer tabIndex = event.getSelectedItem();
                    graphs[tabIndex.intValue()].setSelected(true);
                }
            });

            // Display first tab selected (also sets up graph)
            tab.selectTab(0);
        }
    };
    VisualizationUtils.loadVisualizationApi(loadGraph, AnnotatedTimeLine.PACKAGE);
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwConstantsExample.java

License:Apache License

@Override
public void onSelection(SelectionEvent<Integer> event) {
    super.onSelection(event);

    int tabIndex = event.getSelectedItem().intValue();
    if (!javaLoaded && tabIndex == 2) {
        // Load ErrorMessages.java
        javaLoaded = true;/*  w  w  w  . j  av  a 2s.  c  o  m*/
        String className = ExampleConstants.class.getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_RAW + className + ".java.html", javaWidget, null);
    } else if (!propertiesLoaded && tabIndex == 3) {
        // Load ErrorMessages.properties
        propertiesLoaded = true;
        String className = ExampleConstants.class.getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_RAW + className + ".properties.html",
                propertiesWidget, null);
    }
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwConstantsWithLookupExample.java

License:Apache License

@Override
public void onSelection(SelectionEvent<Integer> event) {
    super.onSelection(event);

    int tabIndex = event.getSelectedItem().intValue();
    if (!javaLoaded && tabIndex == 2) {
        // Load ErrorMessages.java
        javaLoaded = true;//from w  w  w  .  j  av  a2  s .co m
        String className = ColorConstants.class.getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_RAW + className + ".java.html", javaWidget, null);
    } else if (!propertiesLoaded && tabIndex == 3) {
        // Load ErrorMessages.properties
        propertiesLoaded = true;
        String className = ColorConstants.class.getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_RAW + className + ".properties.html",
                propertiesWidget, null);
    }
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.i18n.CwMessagesExample.java

License:Apache License

@Override
public void onSelection(SelectionEvent<Integer> event) {
    super.onSelection(event);

    int tabIndex = event.getSelectedItem().intValue();
    if (!javaLoaded && tabIndex == 2) {
        // Load ErrorMessages.java
        javaLoaded = true;/*from  w w  w .j  a  v a  2s  . c o  m*/
        String className = ErrorMessages.class.getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_RAW + className + ".java.html", javaWidget, null);
    } else if (!propertiesLoaded && tabIndex == 3) {
        // Load ErrorMessages.properties
        propertiesLoaded = true;
        String className = ErrorMessages.class.getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_RAW + className + ".properties.html",
                propertiesWidget, null);
    }
}

From source file:net.s17fabu.vip.gwt.showcase.client.ContentWidget.java

License:Apache License

public void onSelection(SelectionEvent<Integer> event) {
    // Show the associated widget in the deck panel
    int tabIndex = event.getSelectedItem().intValue();
    deckPanel.showWidget(tabIndex);//from w w  w.  j  a  v a  2  s  . c om

    // Load the source code
    String tabHTML = getTabBar().getTabHTML(tabIndex);
    if (!sourceLoaded && tabHTML.equals(constants.contentWidgetSource())) {
        sourceLoaded = true;
        String className = this.getClass().getName();
        className = className.substring(className.lastIndexOf(".") + 1);
        requestSourceContents(ShowcaseConstants.DST_SOURCE_EXAMPLE + className + ".html", sourceWidget, null);
    }

    // Load the style definitions
    if (hasStyle() && tabHTML.equals(constants.contentWidgetStyle())) {
        final String theme = Showcase.CUR_THEME;
        if (styleDefs.containsKey(theme)) {
            styleWidget.setHTML(styleDefs.get(theme));
        } else {
            styleDefs.put(theme, "");
            RequestCallback callback = new RequestCallback() {
                public void onError(Request request, Throwable exception) {
                    styleDefs.put(theme, "Style not available.");
                }

                public void onResponseReceived(Request request, Response response) {
                    styleDefs.put(theme, response.getText());
                }
            };

            String srcPath = ShowcaseConstants.DST_SOURCE_STYLE + theme;
            if (LocaleInfo.getCurrentLocale().isRTL()) {
                srcPath += "_rtl";
            }
            String className = this.getClass().getName();
            className = className.substring(className.lastIndexOf(".") + 1);
            requestSourceContents(srcPath + "/" + className + ".html", styleWidget, callback);
        }
    }
}

From source file:net.urlgrey.mythpodcaster.client.MainWindow.java

License:Open Source License

public MainWindow() {
    super();//from   ww w . j  av a  2s.com

    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.setStyleName("mythpodcaster-MainPanel");
    logoLabel.setText("MythPodcaster");
    logoLabel.setStyleName("mythpodcaster-Header");
    tabPanel.add(recordingsPanel, "Recordings");
    tabPanel.add(jobHistoryPanel, "Job History");
    tabPanel.selectTab(RECORDINGS_TAB_INDEX);
    tabPanel.setSize("100%", "100%");
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {

        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            switch (event.getSelectedItem()) {
            case RECORDINGS_TAB_INDEX:
                recordingsPanel.refreshData();
                break;
            case JOB_HISTORY_TAB_INDEX:
                jobHistoryPanel.refreshData();
                break;
            }
        }
    });

    mainPanel.add(logoLabel);
    mainPanel.add(statusPanel);
    mainPanel.add(tabPanel);
    initWidget(mainPanel);
}

From source file:org.activityinfo.ui.client.component.form.field.SuggestBoxWidget.java

License:Open Source License

public SuggestBoxWidget(List<FormInstance> range, final ValueUpdater<ReferenceValue> valueUpdater) {
    this.range = range;
    this.suggestBox = new SuggestBox(new InstanceSuggestOracle(range));
    this.suggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
        @Override//  w  w  w.jav a2 s.c o  m
        public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
            InstanceSuggestion suggestion = (InstanceSuggestion) event.getSelectedItem();
            if (!Objects.equals(suggestion.getInstanceId(), value)) {
                valueUpdater.update(new ReferenceValue(suggestion.getInstanceId()));
            }
        }
    });
}