List of usage examples for com.google.gwt.event.logical.shared BeforeSelectionHandler BeforeSelectionHandler
BeforeSelectionHandler
From source file:org.openelis.ui.screen.ScreenNavigator.java
License:Open Source License
protected void initialize() { if (table != null) { table.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (enable && selection != event.getItem()) select(event.getItem()); }//from w ww . j av a 2s.c o m }); table.addBeforeCellEditedHandler(new BeforeCellEditedHandler() { public void onBeforeCellEdited(BeforeCellEditedEvent event) { event.cancel(); } }); } if (nextPage != null) { nextPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { noSelection = true; setPage(query.getPage() + 1); } }); } if (prevPage != null) { prevPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { setPage(query.getPage() - 1); } }); } }
From source file:org.openelis.ui.widget.AutoComplete.java
License:Open Source License
/** * Sets the Table definition to be used as the PopupContext for this * Dropdown. Will set the isDropdown flag in the Table so the correct * styling is used./*w w w . java 2 s.c o m*/ * * @param tree */ @UiChild(limit = 1, tagname = "popup") public void setPopupContext(Table tableDef) { this.table = tableDef; table.setCSS(UIResources.INSTANCE.dropTable()); table.addStyleName(UIResources.INSTANCE.dropTable().Single()); // table.setFixScrollbar(false); table.setRowHeight(16); table.setEnabled(true); /* * This handler will will cancel the selection if the item has been * disabled. */ table.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @SuppressWarnings("unchecked") public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (!((Item<Integer>) table.getModel().get(event.getItem())).isEnabled()) event.cancel(); } }); /* * This handler will catch the events when the user clicks on rows in * the table. */ table.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { setDisplay(); } }); /* * We close the popup on CellClick instead of selectionso that the display * can be set on selection of use of keyboard. */ table.addCellClickedHandler(new CellClickedHandler() { public void onCellClicked(CellClickedEvent event) { popup.hide(); } }); }
From source file:org.openelis.ui.widget.Dropdown.java
License:Open Source License
/** * Sets the Table definition to be used as the PopupContext for this * Dropdown./*from ww w .java2s . c o m*/ * */ @UiChild(limit = 1, tagname = "popup") public void setPopupContext(Table tableDef) { this.table = tableDef; table.setCSS(UIResources.INSTANCE.dropTable()); table.addStyleName(UIResources.INSTANCE.dropTable().Single()); // table.setFixScrollbar(false); table.setRowHeight(16); table.setEnabled(true); table.setCtrlKeyDefault(true); /* * This handler will will cancel the selection if the item has been * disabled. */ table.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @SuppressWarnings("rawtypes") public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (!((Item) table.getModel().get(event.getItem())).isEnabled()) event.cancel(); } }); /* * This handler will catch the events when the user clicks on rows in * the table. */ table.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { setDisplay(); } }); table.addUnselectionHandler(new UnselectionHandler<Integer>() { @Override public void onUnselection(UnselectionEvent<Integer> event) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { setDisplay(); } }); } }); table.addCellClickedHandler(new CellClickedHandler() { public void onCellClicked(CellClickedEvent event) { /* * Keep options up if multiple selection occurs */ if (queryMode) return; popup.hide(); } }); }
From source file:org.openelis.ui.widget.MultiDropdown.java
License:Open Source License
/** * Sets the Table definition to be used as the PopupContext for this * Dropdown. //from w w w . j a va2s. co m * */ @UiChild(limit = 1, tagname = "popup") public void setPopupContext(Table tableDef) { this.table = tableDef; table.setCSS(UIResources.INSTANCE.dropTable()); //table.setFixScrollbar(false); table.setRowHeight(16); table.setEnabled(true); table.setAllowMultipleSelection(true); table.setCtrlKeyDefault(true); /* * This handler will will cancel the selection if the item has been * disabled. */ table.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @SuppressWarnings("rawtypes") public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (!((Item) table.getModel().get(event.getItem())).isEnabled()) event.cancel(); } }); /* * This handler will catch the events when the user clicks on rows in * the table. */ table.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { setDisplay(); } }); table.addUnselectionHandler(new UnselectionHandler<Integer>() { @Override public void onUnselection(UnselectionEvent<Integer> event) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { setDisplay(); } }); } }); }
From source file:org.pentaho.mantle.client.solutionbrowser.tabs.MantleTabPanel.java
License:Open Source License
public MantleTabPanel() { setupNativeHooks(this); // add window close listener Window.addWindowClosingHandler(new ClosingHandler() { public void onWindowClosing(ClosingEvent event) { // close only if we have stuff open if (getTabBar().getTabCount() > 0) { event.setMessage(Messages.getString("windowCloseWarning")); //$NON-NLS-1$ }/*from w w w. j a va 2 s. c om*/ } }); addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { previousIndex = getTabBar().getSelectedTab(); } }); addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { int tabIndex = event.getSelectedItem(); SolutionBrowserPerspective.getInstance().fireSolutionBrowserListenerEvent( SolutionBrowserListener.EventType.DESELECT, previousIndex); SolutionBrowserPerspective.getInstance() .fireSolutionBrowserListenerEvent(SolutionBrowserListener.EventType.SELECT, tabIndex); if (previousIndex != tabIndex) { Widget tabPanel = getWidget(tabIndex); Window.setTitle(Messages.getString("productName") + " - " + getCurrentTab().getText()); //$NON-NLS-1$ //$NON-NLS-2$ if (tabPanel instanceof IFrameTabPanel) { NamedFrame frame = ((IFrameTabPanel) tabPanel).getFrame(); frame.setVisible(true); refreshIfPDF(); } } for (int i = 0; i < tabIndex; i++) { hideFrame(i); } for (int i = tabIndex + 1; i < getTabBar().getTabCount(); i++) { hideFrame(i); } } }); setHeight("100%"); //$NON-NLS-1$ setWidth("100%"); //$NON-NLS-1$ }
From source file:org.pentaho.ui.xul.gwt.tags.GwtTabbox.java
License:Open Source License
public void layout() { for (int i = 0; i < tabPanel.getWidgetCount(); i++) { tabPanel.remove(i);/* w w w. j ava 2s. c o m*/ } for (int i = 0; i < tabs.getChildNodes().size(); i++) { XulTabpanel panel = this.panels.getTabpanelByIndex(i); if (panel == null) { // no panel for tab continue; } GwtTabWidget widget = new GwtTabWidget(tabs.getTabByIndex(i).getLabel(), "", tabPanel, ((Widget) panel.getManagedObject())); Widget panelWidget = (Widget) panel.getManagedObject(); panelWidget.setStylePrimaryName("pentaho-tabPanel"); tabPanel.add(panelWidget, widget); } setSelectedIndex(selectedIndex); initialized = true; tabPanel.getTabBar().setStylePrimaryName("pentaho-tabBar"); tabPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (event != null && event.getItem() >= 0) { try { final String onBeforeSelectMethod = ((GwtTab) tabs.getTabByIndex(event.getItem())) .getOnBeforeSelect(); if (StringUtils.isEmpty(onBeforeSelectMethod) == false) { Object returnValue = GwtTabbox.this.getXulDomContainer().invoke(onBeforeSelectMethod, new Object[] { event.getItem() }); if (returnValue != null && returnValue instanceof Boolean) { Boolean value = (Boolean) returnValue; if (!value) { event.cancel(); } } } } catch (XulException e) { e.printStackTrace(); } } } }); tabPanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(final SelectionEvent<Integer> event) { if (event != null && event.getSelectedItem() >= 0) { try { final String onClickMethod = tabs.getTabByIndex(event.getSelectedItem()).getOnclick(); if (onClickMethod != null) { GwtTabbox.this.getXulDomContainer().invoke(onClickMethod, new Object[] {}); } } catch (XulException e) { e.printStackTrace(); } } } }); }
From source file:org.rstudio.studio.client.workbench.ui.WorkbenchTabPanel.java
License:Open Source License
@Override protected void onLoad() { super.onLoad(); releaseOnUnload_.add(tabPanel_.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (clearing_) return; if (getSelectedIndex() >= 0) { int unselectedTab = getSelectedIndex(); if (unselectedTab < tabs_.size()) { WorkbenchTab lastTab = tabs_.get(unselectedTab); lastTab.onBeforeUnselected(); }//from ww w . ja v a2 s.c o m } int selectedTab = event.getItem().intValue(); if (selectedTab < tabs_.size()) { WorkbenchTab tab = tabs_.get(selectedTab); tab.onBeforeSelected(); } } })); releaseOnUnload_.add(tabPanel_.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { if (clearing_) return; WorkbenchTab pane = tabs_.get(event.getSelectedItem().intValue()); pane.onSelected(); } })); int selectedIndex = tabPanel_.getSelectedIndex(); if (selectedIndex >= 0) { WorkbenchTab tab = tabs_.get(selectedIndex); tab.onBeforeSelected(); tab.onSelected(); } }
From source file:org.switchyard.console.client.ui.service.ServiceEditor.java
License:Apache License
/** * @return this editor as a Widget./* www. java2s. co m*/ */ public Widget asWidget() { VerticalPanel panel = new VerticalPanel(); panel.add(new ContentGroupLabel(Singleton.MESSAGES.label_serviceDetails())); panel.add(new ContentDescription(Singleton.MESSAGES.description_serviceDetails())); panel.add(createImplementationDetailsPanel()); TabPanel tabs = new TabPanel(); tabs.setStyleName("default-tabpanel"); //$NON-NLS-1$ tabs.getElement().setAttribute("style", "margin-top:15px;"); //$NON-NLS-1$ //$NON-NLS-2$ tabs.add(createGatewayDetailsPanel(), Singleton.MESSAGES.label_gateways()); tabs.add(createThrottlingDetailsPanel(), Singleton.MESSAGES.label_throttling()); tabs.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { _toolstrip.doCancel(); } }); panel.add(tabs); tabs.selectTab(0); return panel; }
From source file:strat.mining.multipool.stats.client.mvp.view.impl.MainViewImpl.java
License:Open Source License
public MainViewImpl(final MainView.MainViewPresenter presenter) { mainContainer = new BorderLayoutContainer(); tabPanel = new TabPanel(); tabPanel.setCloseContextMenu(true);// w w w . j a va 2 s .com TabItemConfig config = new TabItemConfig(); config.setIcon(ClientResources.INSTANCE.add()); config.setClosable(false); config.setText("Open pool"); final Label fakeLabel = new Label(); tabPanel.add(fakeLabel, config); tabPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Widget>() { public void onBeforeSelection(BeforeSelectionEvent<Widget> event) { activeWidget = tabPanel.getActiveWidget(); if (event.getItem() != fakeLabel && activeWidget != null) { presenter.deactivatePoolPresenter(tabPanel.getConfig(activeWidget).getText()); } } }); tabPanel.addSelectionHandler(new SelectionHandler<Widget>() { public void onSelection(SelectionEvent<Widget> event) { if (event.getSelectedItem() == fakeLabel) { if (activeWidget != null) { tabPanel.setActiveWidget(activeWidget); } else if (tabPanel.getWidgetCount() > 1) { // Open the first tab if the active widget is null (it // is a closed panel) and another pool tab exist tabPanel.setActiveWidget(tabPanel.getWidget(0)); } presenter.openPoolSelectionView(); } else { presenter.activatePoolPresenter(tabPanel.getConfig(event.getSelectedItem()).getText()); } } }); tabPanel.addCloseHandler(new CloseHandler<Widget>() { public void onClose(CloseEvent<Widget> event) { presenter.closePoolPresenter(tabPanel.getConfig(event.getItem()).getText()); } }); mainContainer.setWidget(tabPanel); }
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()); }/*from w w w . j a v a 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(); } } }); return bar; }