List of usage examples for com.google.gwt.user.client.ui TabPanel getDeckPanel
public DeckPanel getDeckPanel()
From source file:com.google.gwt.language.sample.hellolanguage.client.HelloLanguage.java
License:Apache License
/** * The onModuleLoad() method is called when the body of the document is * finished loading. The JavaScript APIs are not loaded unless they were * included in the body of the .html file. Use the LanguageUtils.loadXXX() * methods to load them after the app starts, but before any API calls are * made.//from ww w. ja v a 2 s . c om */ public void onModuleLoad() { final TabPanel demoTabPanel = new TabPanel(); demoTabPanel.getDeckPanel().setPixelSize(Window.getClientWidth() - 30, DEMO_PANEL_HEIGHT); RootPanel.get().add(demoTabPanel); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { demoTabPanel.getDeckPanel().setPixelSize(Window.getClientWidth() - 30, DEMO_PANEL_HEIGHT); } }); final VerticalPanel transDemoPanel = new VerticalPanel(); transDemoPanel.add(loadingLabel()); final VerticalPanel langDetectDemoPanel = new VerticalPanel(); langDetectDemoPanel.add(loadingLabel()); final VerticalPanel translitDemoPanel = new VerticalPanel(); translitDemoPanel.add(loadingLabel()); demoTabPanel.add(transDemoPanel, "Translation demo"); demoTabPanel.add(langDetectDemoPanel, "Language detection demo"); demoTabPanel.add(translitDemoPanel, "Transliteration demo"); demoTabPanel.selectTab(0); LanguageUtils.loadTranslation(new Runnable() { public void run() { transDemoPanel.clear(); transDemoPanel.add(new TranslationDemo()); langDetectDemoPanel.clear(); langDetectDemoPanel.add(new LanguageDetectionDemo()); } }); LanguageUtils.loadTransliteration(new Runnable() { public void run() { translitDemoPanel.clear(); TransliterationDemo translitDemo = new TransliterationDemo(); translitDemoPanel.add(translitDemo); } }); }
From source file:net.officefloor.demo.stocks.client.StockGraphWidget.java
License:Open Source License
/** * Initiate.//from w ww. j a va 2 s .c o m * * @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:org.xwiki.gwt.user.client.TabPanelSelector.java
License:Open Source License
@Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (!event.isCanceled()) { TabPanel tabPanel = (TabPanel) event.getSource(); int selectedTabIndex = tabPanel.getTabBar().getSelectedTab(); // Check if there is a selected tab and the tab to be selected is not the same. if (selectedTabIndex >= 0 && selectedTabIndex != event.getItem()) { Widget selectedTab = tabPanel.getDeckPanel().getWidget(selectedTabIndex); if (selectedTab instanceof Selectable && ((Selectable) selectedTab).isSelected()) { // Notify the tab before it is hidden. ((Selectable) selectedTab).setSelected(false); }//from ww w. j ava 2 s. c o m } } }
From source file:org.xwiki.gwt.user.client.TabPanelSelector.java
License:Open Source License
@Override public void onSelection(SelectionEvent<Integer> event) { TabPanel tabPanel = (TabPanel) event.getSource(); // Check if a tab was selected. if (event.getSelectedItem() >= 0) { Widget selectedTab = tabPanel.getDeckPanel().getWidget(event.getSelectedItem()); if (selectedTab instanceof Selectable && !((Selectable) selectedTab).isSelected()) { // Notify the tab after it is shown. ((Selectable) selectedTab).setSelected(true); }//from www . java 2s . c o m } }
From source file:ro.zg.opengroups.gwt.client.views.EntityUserActionsTabView.java
License:Apache License
private void addCommandDefinitionsList(final CommandDefinitionsList cdl, final List<Integer> desiredActionPath, final TabPanel tabPanel) { final Map<Integer, CommandDefinition> commandsMap = new LinkedHashMap<Integer, CommandDefinition>(); final Map<Integer, BaseGwtView> viewsMap = new HashMap<Integer, BaseGwtView>(); if (cdl != null) { int tabIndex = 0; for (CommandDefinition cd : cdl.getCommandDefinitions().values()) { commandsMap.put(tabIndex, cd); if (cd instanceof CommandDefinitionsList) { EntityUserActionsTabView newView = (EntityUserActionsTabView) createViewForType( ViewsTypes.ENTITY_USER_ACTIONS_TAB_VIEW, this); TabPanel currentTabPanel = newView.construct(); currentTabPanel.getTabBar().setStylePrimaryName("og-CommandsTabBar"); currentTabPanel.getDeckPanel().setStylePrimaryName("og-CommandsTabPanelBottom"); tabPanel.add(currentTabPanel, cd.getDisplayName()); viewsMap.put(tabIndex, newView); } else { BaseGwtView newView = (BaseGwtView) createViewForCommand(cd.getActionName(), this); tabPanel.add(newView.construct(), cd.getDisplayName()); viewsMap.put(tabIndex, newView); }//from w ww . j a va 2s . c om tabIndex++; } /* set the selection listener */ handlerReg = tabPanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { Integer si = event.getSelectedItem(); updateCurrentActionPath(si); BaseGwtView view = viewsMap.get(si); if (view instanceof EntityUserActionsTabView) { ((EntityUserActionsTabView) view).update((CommandDefinitionsList) commandsMap.get(si), desiredActionPath, new ArrayList<Integer>(currentActionPath)); } else { CommandDefinition cd = commandsMap.get(si); UserEvent userEvent = new UserEvent(); userEvent.setSourceViewType(getViewType()); userEvent.setElementId(COMMANDS_TAB); userEvent.setEventType(UserEvent.CLICK); userEvent.addEventParam(UserEventParams.COMMAND_ID, cd.getUniqueCommandDesc()); userEvent.addEventParam(OpenGroupsParams.CURRENT_TAB_ACTION_PATH, new ArrayList<Integer>(currentActionPath)); userEvent.setTargetViewId(view.getId()); System.out.println(userEvent.getFullEventType()); dispatchEventToManager(userEvent); } } }); /* if didn't tell otherwise, select the first action */ int nextIndex = 0; /* select the desired action */ if (desiredActionPath != null && desiredActionPath.size() > 0) { nextIndex = desiredActionPath.remove(0); } currentActionPath.add(nextIndex); tabPanel.selectTab(nextIndex); } }