List of usage examples for com.google.gwt.event.logical.shared SelectionEvent getSelectedItem
public T getSelectedItem()
From source file:org.obiba.opal.web.gwt.app.client.magma.view.CategoricalSummaryView.java
License:Open Source License
public CategoricalSummaryView(final String title, CategoricalSummaryDto categorical, Collection<FrequencyDto> categoriesNonMissing, Collection<FrequencyDto> categoriesMissing, double totalNonMissing, double totalMissing, double totalOther) { initWidget(uiBinder.createAndBindUi(this)); chartsPanel.addSelectionHandler(new SelectionHandler<Integer>() { @Override/*from w w w .j a v a 2 s . com*/ public void onSelection(SelectionEvent<Integer> event) { if (event.getSelectedItem() == 1 && chartFactory != null && pctPanel.getWidgetCount() == 0) { pctPanel.add(chartFactory.createPercentageChart(title)); } } }); stats.clear(); stats.drawHeader(); freqPanel.clear(); pctPanel.clear(); if (categorical.getFrequenciesArray() != null) { double total = totalNonMissing + totalMissing + totalOther; stats.drawValuesFrequencies(categoriesNonMissing, translations.nonMissing(), translations.notEmpty(), totalNonMissing + totalOther, totalOther, total); stats.drawValuesFrequencies(categoriesMissing, translations.missingLabel(), translations.naLabel(), totalMissing, total); stats.drawTotal(total); // Populate chart chartFactory = new FrequencyChartFactory(); for (FrequencyDto frequency : JsArrays.toIterable(categorical.getFrequenciesArray())) { if (frequency.hasValue()) { chartFactory.push(frequency.getValue(), frequency.getFreq(), new BigDecimal(frequency.getPct() * 100).setScale(2, RoundingMode.HALF_UP) .doubleValue()); } } freqPanel.add(chartFactory.createValueChart(title)); } }
From source file:org.obiba.opal.web.gwt.app.client.ui.BreadcrumbsTabPanel.java
License:Open Source License
public BreadcrumbsTabPanel() { super(new Breadcrumbs()); // remove all tabs after the one selected addSelectionHandler(new SelectionHandler<Integer>() { @Override/*from w w w. j ava2 s . c o m*/ public void onSelection(SelectionEvent<Integer> event) { final int idx = event.getSelectedItem(); if (isAnimationEnabled()) { // wait for the end of the animation before removing descendants Timer timer = new Timer() { @Override public void run() { if (!isAnimationRunning()) { removeDescendants(idx); cancel(); } } }; timer.scheduleRepeating(10); } else { removeDescendants(idx); } } private void removeDescendants(int idx) { while (getWidgetCount() > idx + 1) { remove(getWidgetCount() - 1); } } }); setAnimationEnabled(true); getMenu().addStyleName("inline-block"); }
From source file:org.onesocialweb.gwt.client.ui.dialog.LoginDialog.java
License:Apache License
private LoginDialog() { // overall widgets VerticalPanel vpanel1 = new VerticalPanel(); HorizontalPanel buttoncontainer = new HorizontalPanel(); // tab contents FieldLabel username = new FieldLabel(uiText.YourUsername()); FieldLabel password = new FieldLabel(uiText.YourPassword()); FlowPanel loginflow = new FlowPanel(); FlowPanel registerflow = new FlowPanel(); FieldLabel usernameRegister = new FieldLabel(uiText.ChooseUsername()); FieldLabel passwordRegister = new FieldLabel(uiText.ChoosePassword()); FieldLabel emailRegister = new FieldLabel(uiText.EnterYourEmail()); FieldLabel codeRegister = new FieldLabel(uiText.EnterCode()); TextBox usernameTextRegister = new TextBox(); PasswordTextBox passwordTextRegister = new PasswordTextBox(); TextBox emailTextRegister = new TextBox(); TextBox codeTextRegister = new TextBox(); ErrorLabel usernameRegisterError = new ErrorLabel(); ErrorLabel passwordRegisterError = new ErrorLabel(); ErrorLabel emailRegisterError = new ErrorLabel(); ErrorLabel codeRegisterError = new ErrorLabel(); registerflow.setStyleName("tabcontentflowlayout"); loginflow.setStyleName("tabcontentflowlayout"); tabpanel.add(loginflow, uiText.Login()); // if registration is enabled if (OswClient.getInstance().getPreference("registration_allowed").equals("true")) { tabpanel.add(registerflow, uiText.Register()); }//from ww w . j av a2 s . c om rememberme.addStyleName("checkbox"); loginflow.add(loginError); loginflow.add(username); loginflow.add(usernameText); loginflow.add(password); loginflow.add(passwordText); loginflow.add(rememberme); registerflow.add(usernameRegister); registerflow.add(usernameTextRegister); registerflow.add(usernameRegisterError); registerflow.add(passwordRegister); registerflow.add(passwordTextRegister); registerflow.add(passwordRegisterError); registerflow.add(emailRegister); registerflow.add(emailTextRegister); registerflow.add(emailRegisterError); // if registration via a registration code only is enabled if (OswClient.getInstance().getPreference("registration_code").equals("true")) { registerflow.add(codeRegister); registerflow.add(codeTextRegister); registerflow.add(codeRegisterError); } buttoncontainer.add(buttonLogin); buttoncontainer.add(buttonRegister); buttoncontainer.setStyleName("dialogButtons"); vpanel1.add(tabpanel); vpanel1.add(buttoncontainer); tabpanel.selectTab(0); setCurrentTab(0); setWidget(vpanel1); setWidth("300px"); tabpanel.setWidth(Integer.toString(this.getOffsetWidth() - 20)); this.setAutoHideEnabled(false); // this.handler = handler; // build and init dialog setText(uiMessages.WelcomeToServer(OswClient.getInstance().getPreference("service_name"))); // center(); tabpanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { setCurrentTab(event.getSelectedItem()); } }); passwordText.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent arg0) { char keyCode = arg0.getCharCode(); if (keyCode == KeyCodes.KEY_ENTER) { processLogin(); } } }); usernameText.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent arg0) { char keyCode = arg0.getCharCode(); if (keyCode == KeyCodes.KEY_ENTER) { processLogin(); } } }); buttonRegister.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // TODO add code for registration boolean success = validator.validate(); if (success) { // No validation errors found. We can submit the data to the // server! } else { // One (or more) validations failed. The actions will have // been // already invoked by the validator.validate() call. center(); } } }); buttonLogin.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { processLogin(); } }); validator.addValidators("Username", new StringLengthValidator(usernameTextRegister, 4, 25) .addActionForFailure(new StyleAction("validationFailed")) .addActionForFailure(new CustomLabelTextAction(usernameRegisterError, false))); validator.addValidators("Password", new StringLengthValidator(passwordTextRegister, 4, 25) .addActionForFailure(new StyleAction("validationFailed")) .addActionForFailure(new CustomLabelTextAction(passwordRegisterError, false))); validator.addValidators("Email", new EmailValidator(emailTextRegister).addActionForFailure(new StyleAction("validationFailed")) .addActionForFailure(new CustomLabelTextAction(emailRegisterError, false))); }
From source file:org.onesocialweb.gwt.client.ui.window.PreferencesWindow.java
License:Apache License
private void composeWindow() { // add components tabpanel.add(account, uiText.Account()); tabpanel.add(profile, uiText.ProfileAndContact()); // tabpanel.add(privacy, "Privacy"); tabpanel.selectTab(0);/*from w w w .ja v a 2 s . co m*/ getContents().add(tabpanel); // load first tab getAccountPreferences(); // styles account.setStyleName("tabcontentflowlayout"); profile.setStyleName("tabcontentflowlayout"); privacy.setStyleName("tabcontentflowlayout"); tabpanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { if (event.getSelectedItem() == 0) { getAccountPreferences(); } if (event.getSelectedItem() == 1) { getProfilePreferences(); } if (event.getSelectedItem() == 2) { getPrivacyPreferences(); } } }); }
From source file:org.opencms.gwt.client.ui.input.location.CmsLocationPopupContent.java
License:Open Source License
/** * On address suggest selection.<p> * * @param event the selection event//from ww w . java 2s. c o m */ @UiHandler("m_addressField") void onAddressSelection(SelectionEvent<SuggestOracle.Suggestion> event) { m_controller.onAddressChange(event.getSelectedItem()); }
From source file:org.opencms.gwt.client.ui.preferences.CmsUserSettingsFormFieldPanel.java
License:Open Source License
/** * Creates a new instance.<p>/*from w w w . j av a 2 s.c o m*/ * * @param userSettings the bean containing the current user settings */ public CmsUserSettingsFormFieldPanel(CmsUserSettingsBean userSettings) { uiBinder.createAndBindUi(this); // don't use the return value, since we use the created widgets as tabs for the tab panel m_tabPanel.add(m_basicTab, Messages.get().key(Messages.GUI_USERSETTINGS_TAB_BASIC_0)); m_tabPanel.add(m_extendedTab, Messages.get().key(Messages.GUI_USERSETTINGS_TAB_EXTENDED_0)); final FlowPanel[] tabs = { m_basicSettingsPanel, m_extendedSettingsPanel }; m_tabPanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { final Widget constTarget = tabs[event.getSelectedItem().intValue()]; Timer timer = new Timer() { @Override public void run() { CmsDomUtil.resizeAncestor(constTarget); } }; timer.schedule(1); } }); initWidget(m_tabPanel); }
From source file:org.opencms.gwt.client.ui.resourceinfo.CmsResourceInfoDialog.java
License:Open Source License
/** * Creates the dialog for the given resource information.<p> * * @param statusBean the resource information to bean * @param includeTargets true if relation targets should be displayed *//*from ww w .java 2 s.c o m*/ public CmsResourceInfoDialog(final CmsResourceStatusBean statusBean, boolean includeTargets) { super(); setModal(true); setGlassEnabled(true); addDialogClose(null); setWidth(610); removePadding(); final CmsTabbedPanel<CmsTabContentWrapper> tabPanel = new CmsTabbedPanel<CmsTabContentWrapper>(); m_tabPanel = tabPanel; tabPanel.setAutoResize(true); tabPanel.setAutoResizeHeightDelta(45); final List<CmsResourceRelationView> relationViews = new ArrayList<CmsResourceRelationView>(); for (Map.Entry<CmsResourceStatusTabId, String> tabEntry : statusBean.getTabs().entrySet()) { switch (tabEntry.getKey()) { case tabRelationsFrom: CmsResourceRelationView targets = new CmsResourceRelationView(statusBean, Mode.targets); setTabMinHeight(targets); targets.setPopup(this); tabPanel.add(new CmsTabContentWrapper(targets), tabEntry.getValue()); relationViews.add(targets); break; case tabRelationsTo: CmsResourceRelationView usage = new CmsResourceRelationView(statusBean, Mode.sources); setTabMinHeight(usage); usage.setPopup(this); tabPanel.add(new CmsTabContentWrapper(usage), tabEntry.getValue()); relationViews.add(usage); break; case tabStatus: CmsResourceInfoView infoView = new CmsResourceInfoView(statusBean); setTabMinHeight(infoView); tabPanel.add(new CmsTabContentWrapper(infoView), tabEntry.getValue()); relationViews.add(null); break; case tabSiblings: if (statusBean.getSiblings().size() > 0) { CmsResourceRelationView siblings = new CmsResourceRelationView(statusBean, Mode.siblings); setTabMinHeight(siblings); tabPanel.add(new CmsTabContentWrapper(siblings), tabEntry.getValue()); relationViews.add(siblings); } break; default: break; } } if (relationViews.get(0) != null) { relationViews.get(0).onResizeDescendant(); } tabPanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { Widget tabContent = tabPanel.getWidget(event.getSelectedItem().intValue()).getWidget(); if (tabContent instanceof I_CmsDescendantResizeHandler) { ((I_CmsDescendantResizeHandler) tabContent).onResizeDescendant(); } delayedResize(); } }); setMainContent(tabPanel); List<CmsResourceStatusTabId> tabKeyList = Lists.newArrayList(statusBean.getTabs().keySet()); int startTab = tabKeyList.indexOf(statusBean.getStartTab()); tabPanel.selectTab(startTab); }
From source file:org.opendatakit.aggregate.client.AggregateUI.java
License:Apache License
void setSubMenuSelectionHandler(final TabPanel menuTab, final Tabs menu, final SubTabs[] subMenus) { // add the mainNav selection handler for this menu... mainNav.addSelectionHandler(new SelectionHandler<Integer>() { @Override//from w ww .j av a 2 s . c om public void onSelection(SelectionEvent<Integer> event) { if (userInfo == null) { GWT.log("getSubMenuSelectionHandler: No userInfo - not setting selection"); return; } int selected = event.getSelectedItem(); String tabHash = menu.getHashString(); Tabs tab = tabPosition.get(selected); if (tab == null) { return; } if (tabHash.equals(tab.getHashString())) { if (!authorizedForTab(tab)) { return; } // and select the appropriate subtab... AggregateTabBase tabObj = tabMap.get(menu); if (tabObj != null) { tabObj.selectTab(tabObj.findSubTabIndexFromHash(hash)); } } } }); menuTab.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { // allow the currently-selected SubTab to refuse the tab selection. // refusal should only occur after user confirmation. if (!getTimer().canLeaveCurrentSubTab()) { event.cancel(); } } }); menuTab.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { if (userInfo == null) { GWT.log("getSubMenuSelectionHandler: No userInfo - not setting subMenu selection"); return; } int selected = event.getSelectedItem(); clearError(); hash.clear(); hash.set(UrlHash.MAIN_MENU, menu.getHashString()); hash.set(UrlHash.SUB_MENU, subMenus[selected].getHashString()); getTimer().setCurrentSubTab(subMenus[selected]); hash.put(); changeHelpPanel(subMenus[selected]); } }); }
From source file:org.openelis.gwt.widget.ScrollableTabBar.java
License:Open Source License
public ScrollableTabBar() { barScroller = new TabBarScroller(tabBar); initWidget(barScroller);//from ww w.ja v a2s . c om final HasSelectionHandlers<Integer> source = this; tabBar.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { SelectionEvent.fire(source, event.getSelectedItem()); barScroller.scrollToSelected(); } }); }
From source file:org.openelis.gwt.widget.ScrollableTabBar.java
License:Open Source License
public void onSelection(SelectionEvent<Integer> event) { selectTab(event.getSelectedItem()); }