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

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

Introduction

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

Prototype

public T getItem() 

Source Link

Document

Gets the item.

Usage

From source file:cc.alcina.framework.gwt.client.stdlayout.MainTabPanel.java

License:Apache License

public MainTabPanel(ArrayList<IsWidget> buttons) {
    super();// w w  w .  jav  a 2  s  . c om
    this.buttons = buttons;
    VerticalPanel vp = (VerticalPanel) getWidget();
    dockPanel = new DockPanel();
    dockPanel.setStyleName("alcina-MainMenu");
    dockPanel.setWidth("100%");
    mainMenuContainer = new FlowPanel();
    mainMenuContainer.setStyleName("alcina-MainMenuContainer");
    mainMenuContainer.add(dockPanel);
    tabBarProt = (TabBar) vp.getWidget(0);
    vp.remove(tabBarProt);
    if (isWrapCenterContainer()) {
        centerContainer = new SpanPanel();
        centerContainer.add(tabBarProt);
        dockPanel.add(centerContainer, DockPanel.CENTER);
    } else {
        dockPanel.add(tabBarProt, DockPanel.CENTER);
    }
    bp = createButtonsPanel();
    refreshButtonPanelVis();
    dockPanel.add(bp, DockPanel.EAST);
    dockPanel.setCellHorizontalAlignment(bp, DockPanel.ALIGN_RIGHT);
    vp.insert(mainMenuContainer, 0);
    customizeDock();
    vp.insert(toolbarHolder, 1);
    vp.getWidget(1).setWidth("100%");
    noTabContentHolder.setVisible(false);
    noTabContentHolder.setStyleName("content alcina-ContentFrame alcina-MainContent");
    vp.add(noTabContentHolder);
    vp.setWidth("100%");
    addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            int tabIndex = event.getItem();
            getDeckPanel().setVisible(tabIndex >= 0);
            if (tabIndex != -1) {
                noTabContentHolder.clear();
            }
            noTabContentHolder.setVisible(tabIndex == -1);
        }
    });
}

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

License:Apache License

public static void addBeforeSelectionHandler(final CustomisableTabPanel panel) {
    panel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            Integer tabIndex = event.getItem();
            Widget widget = panel.getWidget(tabIndex);
            if (widget instanceof LazyPanel) {
                ((LazyPanel) widget).ensureWidget();
            }/* ww  w  . java 2s.  c  o m*/
        }
    });
}

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

License:Apache License

/**
 * Adds a tab listener to ensure that any {@link LazyPanel} instances are
 * loaded when a tab panel selects the lazy panel's tab.
 * /*from w  ww  .  j av a 2 s.  c om*/
 * @param panel
 *            to add listener to
 */
public static void addBeforeSelectionHandler(final TabPanel panel) {
    panel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            Integer tabIndex = event.getItem();
            Widget widget = panel.getWidget(tabIndex);
            if (widget instanceof LazyPanel) {
                ((LazyPanel) widget).ensureWidget();
            }
        }
    });
}

From source file:com.bramosystems.oss.player.showcase.client.ControlPane.java

License:Apache License

public ControlPane() {
    animator = new Animation() {

        @Override/*from w  ww.  j a v a  2  s.co m*/
        protected void onUpdate(double progress) {
            onAnimatorUpdate(progress);
        }
    };

    playlistPane = PlaylistPane.singleton;
    playerLog = new PlayerLogPane();

    tp = new TabPanel();
    tp.add(playlistPane, "Playlist");
    tp.add(playerLog, "Player Log");
    tp.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {

        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            if ((event.getItem() == selectedTab) || !fullState) {
                toggle();
            }
            selectedTab = event.getItem();
        }
    });
    initWidget(tp);
}

From source file:com.edgenius.wiki.gwt.client.page.PageTabPanel.java

License:Open Source License

public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
    Integer index = event.getItem();
    if (index == tabCommentIdx) {
        if (allowVisibleOnComment) {
            //try to switch panel as busy so that when the tab is set to visible, it won't display the old content.
            //ie, showBusy()->showTab()->loadContent
            commentPanel.showBusy(true);
        }/*from  w  w  w.  j av a 2  s . c  o m*/
    } else if (index == tabHistoryIdx) {
        if (allowVisibleOnHistory) {
            historyPanel.showBusy(true);
        }
    } else if (index == tabChildrenIdx) {
        if (allowVisibleOnChildren) {
            childrenPanel.showBusy(true);
        }
    }
}

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
 *//*  w  w w. j a  va2  s.  c o  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.ephesoft.gxt.admin.client.view.fuzzymapping.FuzzyDBMappingGridView.java

License:Open Source License

private void addSelectionChangeHandler() {
    connectionCombo.addBeforeSelectionHandler(new BeforeSelectionHandler<ConnectionsDTO>() {

        @Override/*  w  ww.j  ava  2 s. c  om*/
        public void onBeforeSelection(final BeforeSelectionEvent<ConnectionsDTO> event) {
            final ConnectionsDTO connection = event.getItem();
            if (presenter.getCurrentConnection() == connection) {
                event.cancel();
            } else {
                if (indexFieldMappingGrid.getStore().size() > 0) {
                    event.cancel();
                    ConfirmationDialog dialog = DialogUtil.showConfirmationDialog(
                            LocaleDictionary.getConstantValue(BatchClassConstants.CONFIRMATION),
                            LocaleDictionary.getMessageValue(
                                    BatchClassMessages.SURE_YOU_WANT_TO_RESET_FUZZY_DB_MAPPINGS));
                    dialog.setDialogListener(new DialogAdapter() {

                        @Override
                        public void onOkClick() {
                            presenter.deleteAllMappings();
                            clearComboStores(true, true, false, false, false);
                            setConnection(connection);
                        }

                        @Override
                        public void onCloseClick() {
                            event.cancel();
                        }

                        @Override
                        public void onCancelClick() {
                            event.cancel();
                        }
                    });
                }
            }
        }
    });
    connectionCombo.addSelectionHandler(new SelectionHandler<ConnectionsDTO>() {

        @Override
        public void onSelection(final SelectionEvent<ConnectionsDTO> event) {
            final ConnectionsDTO connection = event.getSelectedItem();
            connectionCombo.setValue(connection, true, true);
        }
    });
    connectionCombo.addValueChangeHandler(new ValueChangeHandler<ConnectionsDTO>() {

        @Override
        public void onValueChange(ValueChangeEvent<ConnectionsDTO> event) {
            // TODO Auto-generated method stub
            final ConnectionsDTO connection = event.getValue();
            presenter.setConnection(connection);
            presenter.setTables(connection);
        }
    });

    tableNameCombo.addBeforeSelectionHandler(new BeforeSelectionHandler<String>() {

        @Override
        public void onBeforeSelection(final BeforeSelectionEvent<String> event) {
            final String value = event.getItem();
            final String previouslySelectedTableName = tableNameCombo.getValue();
            if (!StringUtil.isNullOrEmpty(previouslySelectedTableName)
                    && !previouslySelectedTableName.equals(value)) {
                if (indexFieldMappingGrid.getStore().size() > 0) {
                    event.cancel();
                    ConfirmationDialog dialog = DialogUtil.showConfirmationDialog(
                            LocaleDictionary.getConstantValue(BatchClassConstants.CONFIRMATION),
                            LocaleDictionary.getMessageValue(
                                    BatchClassMessages.SURE_YOU_WANT_TO_RESET_FUZZY_DB_MAPPINGS));
                    dialog.setDialogListener(new DialogAdapter() {

                        @Override
                        public void onOkClick() {
                            presenter.deleteAllMappings();
                            clearComboStores(true, false, false, false, false);
                            setSelectedTable(value);
                        }

                        @Override
                        public void onCloseClick() {
                            event.cancel();
                        }

                        @Override
                        public void onCancelClick() {
                            event.cancel();
                        }
                    });
                }
            }
        }
    });

    tableNameCombo.addSelectionHandler(new SelectionHandler<String>() {

        @Override
        public void onSelection(SelectionEvent<String> event) {
            String value = event.getSelectedItem();
            setSelectedTable(value);
        }
    });
    tableNameCombo.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            final ListStore<String> store = tableNameCombo.getStore();
            if (store != null) {
                final String value = event.getValue();
                final int totalItems = store.size();
                for (int index = 0; index < totalItems; index++) {
                    final String item = store.get(index);
                    if (null != item && item.equalsIgnoreCase(value)) {
                        getColumns(item);
                        tableNameCombo.setValue(item);
                        break;
                    }
                }
            }
        }
    });

    columnNameCombo.addSelectionHandler(new SelectionHandler<String>() {

        @Override
        public void onSelection(SelectionEvent<String> event) {
            columnNameCombo.setValue(event.getSelectedItem(), true, true);
            // columnNameCombo.focus();
            columnNameCombo.finishEditing();
        }
    });

    rowIDCombo.addSelectionHandler(new SelectionHandler<String>() {

        @Override
        public void onSelection(SelectionEvent<String> event) {
            String value = event.getSelectedItem();
            rowIDCombo.setValue(value, true, true);
        }
    });
}

From source file:com.ephesoft.gxt.admin.client.view.mapping.DatabaseExportMappingEditView.java

License:Open Source License

private Grid<IndexFieldDBExportMappingDTO> getIndexFieldGrid() {
    return new Grid<IndexFieldDBExportMappingDTO>(PropertyAccessModel.INDEX_FIELD_MAPPING) {

        @SuppressWarnings("rawtypes")
        @Override//from   ww  w . j a v  a 2  s. co  m
        public void completeEditing(final CompleteEditEvent<IndexFieldDBExportMappingDTO> completeEditEvent) {
            super.completeEditing(completeEditEvent);
            final com.sencha.gxt.widget.core.client.grid.Grid.GridCell editCell = completeEditEvent
                    .getEditCell();
            presenter.setBatchClassDirty();
            if (null != editCell) {
                final int editCol = editCell.getCol();
                final ValueProvider valueProvider = cm.getValueProvider(editCol);
                final IndexFieldDBExportMappingDTO currentSelectedModel = store.get(editCell.getRow());
                if (valueProvider == FieldNameValueProvider.getInstance()) {
                    presenter.setFieldType(currentSelectedModel, fieldNamesCombo.getText());
                }
                String tableName;
                if (null != currentSelectedModel
                        && valueProvider == IndexFieldMappingProperties.INSTANCE.tableName()) {
                    tableName = currentSelectedModel.getTableName();
                    indexFieldMappingGrid.getStore().commitChanges();
                    String newTableName = currentSelectedModel.getTableName();
                    tableName = tableName == null ? CoreCommonConstant.EMPTY_STRING : tableName;
                    if (!tableName.equalsIgnoreCase(newTableName)) {
                        List<IndexFieldOptionalParametersDTO> optionalParamsList = getNotEqualOptionalParams(
                                currentSelectedModel);
                        setOptionalParams(currentSelectedModel, optionalParamsList);
                    }
                } else {
                    Timer timer = new Timer() {

                        @Override
                        public void run() {
                            indexFieldMappingGrid.getStore().commitChanges();
                        }
                    };
                    timer.schedule(100);
                }
                BatchClassManagementEventBus.fireEvent(new OptionalParametersVisibilityEvent(
                        indexFieldMappingGrid.isValid(currentSelectedModel)));
                BatchClassManagementEventBus.fireEvent(new OptionalParametersRenderEvent(currentSelectedModel,
                        store.getAll(), columnNameCombo.getStore().getAll()));
            }
        }

        @Override
        protected void onBeforeCellSelectionChange(BeforeSelectionEvent<IndexFieldDBExportMappingDTO> event,
                IndexFieldDBExportMappingDTO model) {
            super.onBeforeCellSelectionChange(event, model);
            IndexFieldDBExportMappingDTO newModel = event.getItem();
            if (!presenter.isOptionalViewValid() && newModel != model) {
                event.cancel();
            }
        }

        public void setOptionalParams(final IndexFieldDBExportMappingDTO model,
                final List<IndexFieldOptionalParametersDTO> optionalParamsList) {
            model.clearOptionalParams();
            if (!CollectionUtil.isEmpty(optionalParamsList)) {
                for (IndexFieldOptionalParametersDTO optionalParam : optionalParamsList) {
                    model.addOptionalParamter(DatabaseExportMappingEditView.this.clone(optionalParam));
                }
            }
        }

        @Override
        protected void onCellSelectionChange(final IndexFieldDBExportMappingDTO selectedModel) {
            super.onCellSelectionChange(selectedModel);
            onCellSelection(selectedModel);
            indexFieldMap = getCurrentSelectedModel();
            setView();
        }

        private void setView() {
            final Timer timer = new Timer() {

                @Override
                public void run() {
                    final IndexFieldDBExportMappingDTO currentSelectedModel = getCurrentSelectedModel();
                    if (null != currentSelectedModel) {
                        BatchClassManagementEventBus.fireEvent(new OptionalParametersVisibilityEvent(
                                indexFieldMappingGrid.isValid(currentSelectedModel)));
                        BatchClassManagementEventBus.fireEvent(new OptionalParametersRenderEvent(
                                currentSelectedModel, store.getAll(), columnNameCombo.getStore().getAll()));
                    }
                }
            };
            timer.schedule(200);
        }
    };
}

From source file:com.ephesoft.gxt.admin.client.view.mapping.DatabaseExportMappingEditView.java

License:Open Source License

private void addSelectionChangeHandler() {
    connectionCombo.addBeforeSelectionHandler(new BeforeSelectionHandler<ConnectionsDTO>() {

        @Override//from  w  w  w. j  a v a  2s.  c  o  m
        public void onBeforeSelection(final BeforeSelectionEvent<ConnectionsDTO> event) {
            final ConnectionsDTO connection = event.getItem();
            ConnectionsDTO currentConnection = presenter.getCurrentConnection();
            if (currentConnection != null) {
                if (currentConnection == connection) {
                    event.cancel();
                }
            }
        }
    });
    connectionCombo.addSelectionHandler(new SelectionHandler<ConnectionsDTO>() {

        @Override
        public void onSelection(final SelectionEvent<ConnectionsDTO> event) {
            final ConnectionsDTO connection = event.getSelectedItem();
            presenter.setConnection(connection);
            presenter.setTables(connection);
            presenter.setBatchClassDirty();
        }
    });
}

From source file:com.fullmetalgalaxy.client.creation.MAppGameCreation.java

License:Open Source License

public MAppGameCreation() {
    m_btnCreateGame.addClickHandler(this);
    m_btnCancel.addClickHandler(this);

    // m_form.setBean( ModelFmpMain.model().getGame() );

    m_tabPanel.add(m_simpleForm, s_messages.simpleCreation());
    m_tabPanel.setSize("100%", "90%");
    m_tabPanel.selectTab(0);/*from ww  w .  j  av  a  2 s  .  c om*/
    m_tabPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> p_event) {
            if (p_event.getItem() == 5 // tab admin
                    && !AppMain.instance().iAmAdmin()) {
                Window.alert("Vous n'avez pas les droits pour cet onglet");
                p_event.cancel();
            }
        }
    });
    m_tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> p_event) {
            // Let the user know what they just did.
            switch (p_event.getSelectedItem()) {
            case 0:
                break;
            case 1: // map
                m_wgtEditLand.setPixelSize(m_tabPanel.getOffsetWidth(), m_tabPanel.getOffsetHeight() - 20);
                if (m_isLandGenerated == false) {
                    GameGenerator.generLands();
                    m_isLandGenerated = true;
                }
                AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
                break;
            case 2: // tokens
                m_wgtEditTokens.onTabSelected();
                // I never understand this bug but... the second call IS needed :(
                m_wgtEditTokens.onTabSelected();
                m_wgtEditTokens.setPixelSize(m_tabPanel.getOffsetWidth(), m_tabPanel.getOffsetHeight() - 20);
                if (m_isOreGenerated == false) {
                    if (m_isLandGenerated == false) {
                        GameGenerator.generLands();
                        m_isLandGenerated = true;
                    }
                    GameGenerator.populateOres();
                    m_isOreGenerated = true;
                }
                AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
                break;
            case 3: // rserve
                m_wgtEditReserve.onTabSelected();
                break;
            case 4: // initial holds
                m_wgtEditIntialHolds.onTabSelected();
                break;
            case 5: // Admin
                m_wgtEditAdmin.onTabSelected();
                break;
            default:
                break;
            }
        }
    });

    m_tabPanel.add(m_wgtEditLand, s_messages.map());
    m_tabPanel.add(m_wgtEditTokens, s_messages.tokens());
    m_tabPanel.add(m_wgtEditReserve, s_messages.reserve());
    m_tabPanel.add(m_wgtEditIntialHolds, s_messages.initialHolds());
    m_tabPanel.add(m_wgtEditAdmin, "Admin");

    m_panel.setSize("100%", "100%");
    m_panel.add(m_tabPanel);
    m_panel.add(m_btnCreateGame);
    m_panel.add(m_btnCancel);

    initWidget(m_panel);

    AppMain.getEventBus().addHandler(ModelUpdateEvent.TYPE, this);
}