List of usage examples for com.google.gwt.event.logical.shared BeforeSelectionHandler BeforeSelectionHandler
BeforeSelectionHandler
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);//w w 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); }
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 ww w . j av a 2s. 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:com.google.gwt.gen2.demo.fasttree.client.FastTreeDemo.java
License:Apache License
private Widget cancelEventTree() { final FastTree cancelEventTree = new FastTree(); FastTreeItem firstBranch = cancelEventTree.addItem("Select Me!"); firstBranch.addItem("No! Select Me!"); firstBranch.addItem("No! Select Me!"); firstBranch.addItem("No! Select Me!"); FastTreeItem secondBranch = cancelEventTree.addItem("Don't Select me!"); secondBranch.addItem("Not me!"); secondBranch.addItem("Not me!"); secondBranch.addItem("Not me!"); cancelEventTree.addBeforeSelectionHandler(new BeforeSelectionHandler<FastTreeItem>() { public void onBeforeSelection(BeforeSelectionEvent<FastTreeItem> event) { if (!Window.confirm("Continue?")) { event.cancel();/*from ww w. jav a 2 s . c o m*/ } } }); return cancelEventTree; }
From source file:com.google.livingstories.client.contentmanager.ContentManager.java
License:Apache License
public void onModuleLoad() { // Inject the contents of the living story page CSS file Resources.INSTANCE.css().ensureInjected(); AjaxLoader.init();//from w ww.j a v a 2 s. c o m tabs = new TabPanel(); tabs.setWidth("100%"); tabs.add(contentItemManager, "Manage Content"); tabs.add(livingStoryManager, "Manage Living Stories"); tabs.add(themeManager, "Manage Themes"); tabs.add(importManager, "Import/Export Data"); tabs.selectTab(0); selectedIndex = 0; tabs.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { // TODO: this work is extra if the user didn't actually change // anything on the source tab. ManagerPane previousTab = (ManagerPane) tabs.getWidget(selectedIndex); boolean livingStoriesEdited = (previousTab == livingStoryManager); boolean contentItemsEdited = (previousTab == contentItemManager); for (int i = 0; i < tabs.getWidgetCount(); i++) { ManagerPane pane = (ManagerPane) tabs.getWidget(i); if (pane != previousTab) { if (livingStoriesEdited) { pane.onLivingStoriesChanged(); } if (contentItemsEdited) { pane.onContentItemsChanged(); } pane.onShow(); } } selectedIndex = event.getItem(); } }); RootPanel.get().add(tabs); }
From source file:com.google.livingstories.client.ui.RichTextEditor.java
License:Apache License
private void createEditor() { richTextVerticalPanel = new VerticalPanel(); populateRichTextVerticalPanel();//from w w w .j a va2 s . c o m textArea = new TextArea(); textArea.setWidth(EDITOR_WIDTH + "px"); textArea.setVisibleLines(20); tabPanel.add(richTextVerticalPanel, "Rich Text"); tabPanel.add(textArea, "HTML"); tabPanel.selectTab(0); // When the tabs are switched, populate the edits in the content from the current tab to the // other one. tabPanel.getTabBar().addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (event.getItem() == 0) { // This is a workaround for some bugs in RichTextArea. It is necessary to create a new // RichTextArea when selecting this tab because once the RichTextArea loses focus to the // other TextArea, it does not get focus back. The cursor is lost and all the toggle // buttons are depressed. See post on GWT-users titled "Weird behavior in RichTextArea" // for details. populateRichTextVerticalPanel(); richTextArea.setHTML(textArea.getText()); } else { textArea.setText(richTextArea.getHTML()); } } }); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.chart.DashboardExample.java
License:sencha.com license
@Override public Widget asWidget() { if (panel == null) { for (int i = 0; i < companies.length; i++) { store.add(new Data(companies[i], Math.random() * 100, Math.random() * 100, Math.random() * 100, Math.random() * 100, Math.random() * 100, 0, 0, 0, 0)); }/*w w w.j av a 2 s.c o m*/ final Chart<Data> barChart = new Chart<Data>(); barChart.setStore(store); barChart.setShadowChart(true); barChart.setAnimated(true); CategoryAxis<Data, String> catAxis = new CategoryAxis<Data, String>(); catAxis.setPosition(Position.BOTTOM); catAxis.setField(dataAccess.name()); TextSprite rotation = new TextSprite(); rotation.setRotation(270); catAxis.setLabelConfig(rotation); catAxis.setLabelProvider(new LabelProvider<String>() { @Override public String getLabel(String item) { if (item.length() > 8) { return item.substring(0, 8) + "..."; } else { return item; } } }); barChart.addAxis(catAxis); final BarSeries<Data> bar = new BarSeries<Data>(); bar.setYAxisPosition(Position.LEFT); bar.addYField(dataAccess.data1()); SeriesLabelConfig<Data> barLabelConfig = new SeriesLabelConfig<Data>(); rotation = rotation.copy(); rotation.setTextAnchor(TextAnchor.END); rotation.setTextBaseline(TextBaseline.MIDDLE); barLabelConfig.setSpriteConfig(rotation); bar.setLabelConfig(barLabelConfig); bar.addColor(new RGB(148, 174, 10)); bar.setColumn(true); bar.setHighlighter(new SeriesHighlighter() { @Override public void highlight(Sprite sprite) { if (sprite instanceof RectangleSprite) { RectangleSprite bar = (RectangleSprite) sprite; bar.setStroke(new RGB(85, 85, 204)); bar.setStrokeWidth(3); bar.setFill(new RGB("#a2b5ca")); bar.redraw(); } } @Override public void unHighlight(Sprite sprite) { if (sprite instanceof RectangleSprite) { RectangleSprite bar = (RectangleSprite) sprite; bar.setStroke(Color.NONE); bar.setStrokeWidth(0); bar.setFill(new RGB(148, 174, 10)); bar.redraw(); } } }); bar.addSeriesSelectionHandler(new SeriesSelectionHandler<Data>() { @Override public void onSeriesSelection(SeriesSelectionEvent<Data> event) { grid.getSelectionModel().select(event.getIndex(), false); } }); barChart.addSeries(bar); ContentPanel eastPanel = new ContentPanel(); eastPanel.setHeadingText("Company Details"); eastPanel.addStyleName("white-bg"); vbox = new VBoxLayoutContainer(); name.setReadOnly(true); FieldLabel nameLabel = new FieldLabel(name, "Name"); price.setIncrement(1d); price.setMinValue(0d); price.setMaxValue(100d); price.setAllowBlank(false); price.getPropertyEditor().setFormat(NumberFormat.getFormat("0.00")); price.addValueChangeHandler(new ValueChangeHandler<Double>() { @Override public void onValueChange(ValueChangeEvent<Double> event) { if (currentData != null) { Double value = event.getValue(); if (value != null) { int storeIndex = store.indexOf(currentData); currentData.setData1(value); store.update(currentData); bar.drawSeries(); bar.highlight(storeIndex); updateRadarStore(storeIndex); radarChart.redrawChart(); } } } }); FieldLabel priceLabel = new FieldLabel(price, "Price $"); revenue.setIncrement(1d); revenue.setMinValue(0d); revenue.setMaxValue(100d); revenue.setAllowBlank(false); revenue.getPropertyEditor().setFormat(NumberFormat.getFormat("0.00")); revenue.addValueChangeHandler(new ValueChangeHandler<Double>() { @Override public void onValueChange(ValueChangeEvent<Double> event) { if (currentData != null) { Double value = event.getValue(); if (value != null) { int storeIndex = store.indexOf(currentData); currentData.setData2(value); store.update(currentData); updateRadarStore(storeIndex); radarChart.redrawChart(); } } } }); FieldLabel revenueLabel = new FieldLabel(revenue, "Revenue %"); growth.setIncrement(1d); growth.setMinValue(0d); growth.setMaxValue(100d); growth.setAllowBlank(false); growth.getPropertyEditor().setFormat(NumberFormat.getFormat("0.00")); growth.addValueChangeHandler(new ValueChangeHandler<Double>() { @Override public void onValueChange(ValueChangeEvent<Double> event) { if (currentData != null) { Double value = event.getValue(); if (value != null) { int storeIndex = store.indexOf(currentData); currentData.setData3(value); store.update(currentData); updateRadarStore(storeIndex); radarChart.redrawChart(); } } } }); FieldLabel growthLabel = new FieldLabel(growth, "Growth %"); product.setIncrement(1d); product.setMinValue(0d); product.setMaxValue(100d); product.setAllowBlank(false); product.getPropertyEditor().setFormat(NumberFormat.getFormat("0.00")); product.addValueChangeHandler(new ValueChangeHandler<Double>() { @Override public void onValueChange(ValueChangeEvent<Double> event) { if (currentData != null) { Double value = event.getValue(); if (value != null) { int storeIndex = store.indexOf(currentData); currentData.setData4(value); store.update(currentData); updateRadarStore(storeIndex); radarChart.redrawChart(); } } } }); FieldLabel productLabel = new FieldLabel(product, "Product %"); market.setIncrement(1d); market.setMinValue(0d); market.setMaxValue(100d); market.setAllowBlank(false); market.getPropertyEditor().setFormat(NumberFormat.getFormat("0.00")); market.addValueChangeHandler(new ValueChangeHandler<Double>() { @Override public void onValueChange(ValueChangeEvent<Double> event) { if (currentData != null) { Double value = event.getValue(); if (value != null) { int storeIndex = store.indexOf(currentData); currentData.setData5(event.getValue()); store.update(currentData); updateRadarStore(storeIndex); radarChart.redrawChart(); } } } }); FieldLabel marketLabel = new FieldLabel(market, "Market %"); radarChart = createRadar(); vbox.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); vbox.add(nameLabel); vbox.add(priceLabel); vbox.add(revenueLabel); vbox.add(growthLabel); vbox.add(productLabel); vbox.add(marketLabel); vbox.add(radarChart); eastPanel.add(vbox, new VerticalLayoutData(1, 1, new Margins(20, 0, 0, 0))); ContentPanel centerPanel = new ContentPanel(); centerPanel.setHeadingText("Company Data"); List<ColumnConfig<Data, ?>> columns = new ArrayList<ColumnConfig<Data, ?>>(); columns.add(new ColumnConfig<Data, String>(dataAccess.name(), 120, "Name")); ColumnConfig<Data, Double> priceColumnConfig = new ColumnConfig<Data, Double>(dataAccess.data1(), 75, "Price $"); priceColumnConfig.setCell(new NumberCell<Double>(NumberFormat.getFormat("0.00"))); columns.add(priceColumnConfig); ColumnConfig<Data, Double> revenueColumnConfig = new ColumnConfig<Data, Double>(dataAccess.data2(), 75, "Revenue %"); revenueColumnConfig.setCell(new NumberCell<Double>(NumberFormat.getFormat("0.00"))); columns.add(revenueColumnConfig); ColumnConfig<Data, Double> growthColumnConfig = new ColumnConfig<Data, Double>(dataAccess.data3(), 75, "Growth %"); growthColumnConfig.setCell(new NumberCell<Double>(NumberFormat.getFormat("0.00"))); columns.add(growthColumnConfig); ColumnConfig<Data, Double> productColumnConfig = new ColumnConfig<Data, Double>(dataAccess.data4(), 75, "Product %"); productColumnConfig.setCell(new NumberCell<Double>(NumberFormat.getFormat("0.00"))); columns.add(productColumnConfig); ColumnConfig<Data, Double> marketColumnConfig = new ColumnConfig<Data, Double>(dataAccess.data5(), 75, "Market %"); marketColumnConfig.setCell(new NumberCell<Double>(NumberFormat.getFormat("0.00"))); columns.add(marketColumnConfig); grid = new Grid<Data>(store, new ColumnModel<Data>(columns)); grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); grid.getSelectionModel().addBeforeSelectionHandler(new BeforeSelectionHandler<Data>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Data> event) { price.finishEditing(); revenue.finishEditing(); growth.finishEditing(); product.finishEditing(); market.finishEditing(); } }); grid.getSelectionModel().addSelectionChangedHandler(new SelectionChangedHandler<Data>() { @Override public void onSelectionChanged(SelectionChangedEvent<Data> event) { if (event.getSelection().size() > 0) { int index = store.indexOf(event.getSelection().get(0)); if (currentData != null) { bar.unHighlight(store.indexOf(currentData)); currentData = null; } if (index >= 0) { bar.highlight(index); currentData = event.getSelection().get(0); // update radar chart updateRadarStore(index); radarChart.redrawChart(); } } } }); grid.addSortChangeHandler(new SortChangeHandler() { @Override public void onSortChange(SortChangeEvent event) { barChart.redrawChart(); } }); centerPanel.add(grid); StringFilter<Data> nameFilter = new StringFilter<Data>(dataAccess.name()); FormattedNumericFilter data1Filter = new FormattedNumericFilter(dataAccess.data1(), new DoublePropertyEditor(), "0.00"); FormattedNumericFilter data2Filter = new FormattedNumericFilter(dataAccess.data2(), new DoublePropertyEditor(), "0.00"); FormattedNumericFilter data3Filter = new FormattedNumericFilter(dataAccess.data3(), new DoublePropertyEditor(), "0.00"); FormattedNumericFilter data4Filter = new FormattedNumericFilter(dataAccess.data4(), new DoublePropertyEditor(), "0.00"); FormattedNumericFilter data5Filter = new FormattedNumericFilter(dataAccess.data5(), new DoublePropertyEditor(), "0.00"); GridFilters<Data> filters = new GridFilters<Data>(); filters.initPlugin(grid); filters.setLocal(true); filters.addFilter(nameFilter); filters.addFilter(data1Filter); filters.addFilter(data2Filter); filters.addFilter(data3Filter); filters.addFilter(data4Filter); filters.addFilter(data5Filter); store.addStoreFilterHandler(new StoreFilterHandler<Data>() { @Override public void onFilter(StoreFilterEvent<Data> event) { barChart.redrawChart(); currentData = store.get(0); updateRadarStore(0); radarChart.redrawChart(); } }); BorderLayoutContainer container = new BorderLayoutContainer(); BorderLayoutData centerLayoutData = new BorderLayoutData(); centerLayoutData.setMargins(new Margins(5, 5, 0, 0)); container.setCenterWidget(centerPanel, centerLayoutData); SimpleContainer barChartContainer = new SimpleContainer(); barChartContainer.add(barChart); barChartContainer.setBorders(true); container.setNorthWidget(barChartContainer, new BorderLayoutData(200)); BorderLayoutData eastLayoutData = new BorderLayoutData(330); eastLayoutData.setMargins(new Margins(5, 0, 0, 0)); container.setEastWidget(eastPanel, eastLayoutData); panel = new FramedPanel(); panel.setLayoutData(new BoxLayoutData(new Margins(10))); panel.setHeadingText("Company Data"); panel.setPixelSize(870, 720); panel.add(container); } return panel; }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.forms.AdvancedComboBoxExample.java
License:sencha.com license
public Widget asWidget() { if (vp == null) { vp = new VerticalPanel(); vp.setSpacing(10);// w ww. j a v a2s . co m String url = "http://www.sencha.com/forum/topics-remote.php"; ScriptTagProxy<ForumLoadConfig> proxy = new ScriptTagProxy<ForumLoadConfig>(url); proxy.setWriter( new UrlEncodingWriter<ForumLoadConfig>(TestAutoBeanFactory.instance, ForumLoadConfig.class)); JsoReader<ForumListLoadResult, ForumCollection> reader = new JsoReader<ForumListLoadResult, ForumCollection>( TestAutoBeanFactory.instance, ForumCollection.class) { @Override protected ForumListLoadResult createReturnData(Object loadConfig, ForumCollection records) { PagingLoadConfig cfg = (PagingLoadConfig) loadConfig; ForumListLoadResult res = TestAutoBeanFactory.instance.dataLoadResult().as(); res.setData(records.getTopics()); res.setOffset(cfg.getOffset()); res.setTotalLength(Integer.parseInt(records.getTotalCount())); return res; } }; PagingLoader<ForumLoadConfig, ForumListLoadResult> loader = new PagingLoader<ForumLoadConfig, ForumListLoadResult>( proxy, reader); loader.useLoadConfig(TestAutoBeanFactory.instance.loadConfig().as()); loader.addBeforeLoadHandler(new BeforeLoadHandler<ForumLoadConfig>() { @Override public void onBeforeLoad(BeforeLoadEvent<ForumLoadConfig> event) { String query = combo.getText(); if (query != null && !query.equals("")) { event.getLoadConfig().setQuery(query); } } }); ForumProperties props = GWT.create(ForumProperties.class); ListStore<Forum> store = new ListStore<Forum>(props.topicId()); loader.addLoadHandler( new LoadResultListStoreBinding<ForumLoadConfig, Forum, ForumListLoadResult>(store)); final Bundle b = GWT.create(Bundle.class); b.css().ensureInjected(); final ExampleTemplate template = GWT.create(ExampleTemplate.class); ListView<Forum, Forum> view = new ListView<Forum, Forum>(store, new IdentityValueProvider<Forum>()); view.setCell(new AbstractCell<Forum>() { @Override public void render(com.google.gwt.cell.client.Cell.Context context, Forum value, SafeHtmlBuilder sb) { sb.append(template.render(value, b.css())); } }); ComboBoxCell<Forum> cell = new ComboBoxCell<Forum>(store, props.title(), view); combo = new ComboBox<Forum>(cell); combo.setLoader(loader); combo.setWidth(580); combo.setHideTrigger(true); combo.setPageSize(10); combo.addBeforeSelectionHandler(new BeforeSelectionHandler<Forum>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Forum> event) { event.cancel(); Forum f = combo.getListView().getSelectionModel().getSelectedItem(); Window.open( "http://sencha.com/forum/showthread.php?t=" + f.getTopicId() + "&p=" + f.getPostId(), null, null); } }); combo.getElement().getStyle().setMargin(10, Unit.PX); ContentPanel cp = new ContentPanel(); cp.setWidth(600); cp.setHeadingText("Search the Sencha Forums"); cp.add(combo); cp.setResize(false); vp.add(cp); } return vp; }
From source file:com.ponysdk.ui.terminal.ui.PTStackLayoutPanel.java
License:Apache License
@Override public void addHandler(final PTInstruction addHandler, final UIService uiService) { final String handlerType = addHandler.getString(HANDLER.KEY); if (handlerType.equals(HANDLER.KEY_.SELECTION_HANDLER)) { final StackLayoutPanel stackLayoutPanel = uiObject; stackLayoutPanel.addSelectionHandler(new SelectionHandler<Integer>() { @Override/*www. j a va 2s. co m*/ public void onSelection(final SelectionEvent<Integer> event) { final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.SELECTION_HANDLER); eventInstruction.put(PROPERTY.VALUE, event.getSelectedItem()); uiService.triggerEvent(eventInstruction); } }); return; } if (handlerType.equals(HANDLER.KEY_.BEFORE_SELECTION_HANDLER)) { uiObject.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) { final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.BEFORE_SELECTION_HANDLER); eventInstruction.put(PROPERTY.VALUE, event.getItem()); uiService.triggerEvent(eventInstruction); } }); return; } super.addHandler(addHandler, uiService); }
From source file:com.ponysdk.ui.terminal.ui.PTTabLayoutPanel.java
License:Apache License
@Override public void addHandler(final PTInstruction addHandler, final UIService uiService) { final String handler = addHandler.getString(HANDLER.KEY); if (HANDLER.KEY_.SELECTION_HANDLER.equals(handler)) { uiObject.addSelectionHandler(new SelectionHandler<Integer>() { @Override/*from ww w . j a v a 2 s. c om*/ public void onSelection(final SelectionEvent<Integer> event) { final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.SELECTION_HANDLER); eventInstruction.put(PROPERTY.INDEX, uiObject.getSelectedIndex()); uiService.triggerEvent(eventInstruction); } }); } else if (HANDLER.KEY_.BEFORE_SELECTION_HANDLER.equals(handler)) { uiObject.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) { final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.BEFORE_SELECTION_HANDLER); eventInstruction.put(PROPERTY.INDEX, event.getItem()); uiService.triggerEvent(eventInstruction); } }); } else { super.addHandler(addHandler, uiService); } }
From source file:com.ponysdk.ui.terminal.ui.PTTabPanel.java
License:Apache License
@Override public void addHandler(final PTInstruction addHandler, final UIService uiService) { final String handler = addHandler.getString(HANDLER.KEY); if (HANDLER.KEY_.SELECTION_HANDLER.equals(handler)) { uiObject.addSelectionHandler(new SelectionHandler<Integer>() { @Override/* w w w . j av a 2s.c om*/ public void onSelection(final SelectionEvent<Integer> event) { final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.SELECTION_HANDLER); eventInstruction.put(PROPERTY.INDEX, event.getSelectedItem()); uiService.triggerEvent(eventInstruction); } }); } else if (HANDLER.KEY_.BEFORE_SELECTION_HANDLER.equals(handler)) { uiObject.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) { final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.BEFORE_SELECTION_HANDLER); eventInstruction.put(PROPERTY.INDEX, event.getItem()); uiService.triggerEvent(eventInstruction); } }); } else { super.addHandler(addHandler, uiService); } }