List of usage examples for com.google.gwt.user.client.ui TabPanel selectTab
public void selectTab(int index)
From source file:com.akjava.gwt.hangout.apilist.client.APILists.java
License:Apache License
@Override protected void init(TestPreference preferences) { //create css/* w w w .j a v a2s .co m*/ StyleInjector.inject(".bold{font-weight:bold;color:#666;}"); ScriptElement script = createScriptElement("http://hangoutsapi.appspot.com/static/hangout.js", null); HTML html = new HTML(); html.getElement().insertFirst(script); RootPanel.get().add(html); TabPanel tab = new TabPanel(); RootPanel.get().add(tab); ParticipantsPanel participantsPanel = new ParticipantsPanel(); tab.add(participantsPanel, "Participants"); HangoutPanel hangoutPanel = new HangoutPanel(); tab.add(hangoutPanel, "Hangout"); NoticePanel noticePanel = new NoticePanel(); tab.add(noticePanel, "Notice"); ActiveSpeakerPanel activeSpeakerPanel = new ActiveSpeakerPanel(); tab.add(activeSpeakerPanel, "Speaker"); LayoutPanel laytouPanel = new LayoutPanel(); tab.add(laytouPanel, "layout"); StatePanel statePanel = new StatePanel(); tab.add(statePanel, "state"); AVPanel avPanel = new AVPanel(); tab.add(avPanel, "AV"); tab.selectTab(0); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.resetcache.ResetCacheExample.java
License:Apache License
public ResetCacheExample(PickupDragController dragController) { super(dragController); addStyleName(CSS_DEMO_CACHE_EXAMPLE); // some colors to go with each tab String[] colors = { "#AAAAFF", "#AAFFAA", "#FFAAAA", "#FFFFAA", "#FFAAFF", "#AAFFFF", }; // use the containing panel as this composite's widget AbsolutePanel containingPanel = new AbsolutePanel(); containingPanel.setPixelSize(600, 300); setWidget(containingPanel);/*from w ww . j a v a2s.c om*/ // create a tab panel and populate with a few tabs TabPanel tabPanel = new TabPanel(); tabPanel.addStyleName(CSS_DEMO_CACHE_EXAMPLE_TAB_PANEL); tabPanel.setPixelSize(300, 200); containingPanel.add(tabPanel, 40, 20); for (int i = 0; i < colors.length; i++) { // create a simple panel for the tab content AbsolutePanel contentPanel = new AbsolutePanel(); contentPanel.setHeight("200px"); contentPanel.getElement().getStyle().setProperty("backgroundColor", colors[i]); // create a tab widget HTML tabWidget = new HTML("Tab #" + (i + 1)); tabWidget.setWordWrap(false); tabWidget.getElement().getStyle().setProperty("backgroundColor", colors[i]); tabPanel.add(contentPanel, tabWidget); // add drop controller to allow automatic tab selection and dropping on tab TabSelectingDropController tabSelectingDropController = new TabSelectingDropController(tabWidget, tabPanel, i); dragController.registerDropController(tabSelectingDropController); // create a sample draggable Widget draggableLabel = new Label("Drag me to another tab"); draggableLabel.getElement().getStyle().setProperty("backgroundColor", colors[i]); draggableLabel.addStyleName(CSS_DEMO_CACHE_EXAMPLE_DRAGGABLE); // make label draggable dragController.makeDraggable(draggableLabel); // determine random location within target panel int left = Random.nextInt(200); int top = Random.nextInt(150); contentPanel.add(draggableLabel, left, top); // create a drop controller for the content panel AbsolutePositionDropController contentPanelDropController = new AbsolutePositionDropController( contentPanel); dragController.registerDropController(contentPanelDropController); } tabPanel.selectTab(0); // create a drop controller for the containing panel containerDropController = new AbsolutePositionDropController(containingPanel); dragController.registerDropController(containerDropController); }
From source file:com.apress.progwt.client.college.gui.CollegeEntry.java
License:Apache License
/** * What is displayed when the user expands us. * /* w w w .j a v a 2 s . com*/ * @return */ private Widget getInfoPanel() { VerticalPanel infoPanel = new VerticalPanel(); TabPanel infoTabs = new TabPanel(); infoTabs.add(getThoughts(), "Thoughts"); infoTabs.add(getRatings(), "Ratings"); infoTabs.selectTab(1); infoPanel.add(infoTabs); infoPanel.add(getButtons()); return infoPanel; }
From source file:com.dimdim.conference.ui.common.client.layout.MultipleListsControlDialog.java
License:Open Source License
protected Widget getContent() { int size = lists.size(); TabPanel tabPanel = new TabPanel(); for (int i = 0; i < size; i++) { DefaultList list = (DefaultList) lists.elementAt(i); ListControlPanel w = list.getListControlPanel(); if (w != null) { this.memberControlPanels.addElement(w); tabPanel.add(w, w.getPanelLabel()); }//from w ww . j a v a2 s.c o m } tabPanel.selectTab(0); return tabPanel; }
From source file:com.google.appinventor.client.GalleryGuiFactory.java
License:Open Source License
/** * Creates a sidebar showcasing apps; the CSS name will be the same as the * passed-in container's name. This sidebar shows up as a tab under parent. * * @param apps: list of returned gallery apps from callback. * * @param parent: the parent TabPanel that this panel will reside in. * * @param container: the panel containing this particular sidebar. * * @param name: the name or title of this particular sidebar. * * @param desc: the short description of this particular sidebar. * * @param refreshable: if true then this sidebar can be reloaded later. * * @param isDefault: if true then this sidebar is the default tab showing. *//*from w ww.jav a 2 s . c o m*/ public void generateSidebar(List<GalleryApp> apps, TabPanel parent, FlowPanel container, String name, String desc, Boolean refreshable, Boolean isDefault) { if (refreshable) { // Flush the panel's content if we knew new stuff is coming in! container.clear(); } parent.add(container, name); if (isDefault) { parent.selectTab(0); //TODO: fix order } Label descLabel = new Label(desc); descLabel.addStyleName("gallery-showcase-desc"); container.add(descLabel); for (final GalleryApp app : apps) { // Create the associated GUI object for app GalleryAppWidget gaw = new GalleryAppWidget(app); // Create necessary GUI wrappers and components FlowPanel appCard = new FlowPanel(); FlowPanel appCardContent = new FlowPanel(); FlowPanel appCardMeta = new FlowPanel(); // Special processing for the app title, mainly for fade-out effect HTML appTitle = new HTML("" + "<div class='gallery-title'>" + gaw.nameLabel.getText() + "<span class='paragraph-end-block'></span></div>"); // Special processing for the app author, mainly for fade-out effect HTML appAuthor = new HTML("" + "<div class='gallery-subtitle'>" + gaw.authorLabel.getText() + "<span class='paragraph-end-block'></span></div>"); gaw.image.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } }); appTitle.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } }); // Add everything to the top-level stuff appCard.add(gaw.image); appCard.add(appCardContent); appCardContent.add(appTitle); appCardContent.add(appAuthor); appCardContent.add(appCardMeta); // Set helper icons // Image numViews = new Image(); // numViews.setUrl(NUM_VIEW_ICON_URL); Image numDownloads = new Image(); numDownloads.setUrl(DOWNLOAD_ICON_URL); Image numLikes = new Image(); numLikes.setUrl(HOLLOW_HEART_ICON_URL); // For generic cards, do not show comment // Image numComments = new Image(); // numComments.setUrl(NUM_COMMENT_ICON_URL); // appCardMeta.add(numViews); // appCardMeta.add(gaw.numViewsLabel); appCardMeta.add(numDownloads); appCardMeta.add(gaw.numDownloadsLabel); appCardMeta.add(numLikes); appCardMeta.add(gaw.numLikesLabel); // For generic cards, do not show comment // appCardMeta.add(numComments); // appCardMeta.add(gaw.numCommentsLabel); // Add associated styling appCard.addStyleName("gallery-card"); appCard.addStyleName("clearfix"); gaw.image.addStyleName("gallery-card-cover"); // gaw.nameLabel.addStyleName("gallery-title"); // gaw.authorLabel.addStyleName("gallery-subtitle"); appCardContent.addStyleName("gallery-card-content"); gaw.numViewsLabel.addStyleName("gallery-meta"); gaw.numDownloadsLabel.addStyleName("gallery-meta"); gaw.numLikesLabel.addStyleName("gallery-meta"); // gaw.numCommentsLabel.addStyleName("gallery-meta"); container.add(appCard); } }
From source file:com.google.appinventor.client.wizards.ComponentImportWizard.java
License:Open Source License
public ComponentImportWizard() { super(MESSAGES.componentImportWizardCaption(), true, false); final CellTable compTable = createCompTable(); final FileUpload fileUpload = createFileUpload(); final Grid urlGrid = createUrlGrid(); final TabPanel tabPanel = new TabPanel(); tabPanel.add(fileUpload, "From my computer"); tabPanel.add(urlGrid, "URL"); tabPanel.selectTab(FROM_MY_COMPUTER_TAB); tabPanel.addStyleName("ode-Tabpanel"); VerticalPanel panel = new VerticalPanel(); panel.add(tabPanel);/*from ww w . j a v a 2 s. co m*/ addPage(panel); getConfirmButton().setText("Import"); setPagePanelHeight(150); setPixelSize(200, 150); setStylePrimaryName("ode-DialogBox"); initFinishCommand(new Command() { @Override public void execute() { final long projectId = ode.getCurrentYoungAndroidProjectId(); final Project project = ode.getProjectManager().getProject(projectId); final YoungAndroidAssetsFolder assetsFolderNode = ((YoungAndroidProjectNode) project.getRootNode()) .getAssetsFolder(); if (tabPanel.getTabBar().getSelectedTab() == URL_TAB) { TextBox urlTextBox = (TextBox) urlGrid.getWidget(1, 0); String url = urlTextBox.getText(); if (url.trim().isEmpty()) { Window.alert(MESSAGES.noUrlError()); return; } ode.getComponentService().importComponentToProject(url, projectId, assetsFolderNode.getFileId(), new ImportComponentCallback()); } else if (tabPanel.getTabBar().getSelectedTab() == FROM_MY_COMPUTER_TAB) { if (!fileUpload.getFilename().endsWith(COMPONENT_ARCHIVE_EXTENSION)) { Window.alert(MESSAGES.notComponentArchiveError()); return; } String url = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_COMPONENT + "/" + trimLeadingPath(fileUpload.getFilename()); Uploader.getInstance().upload(fileUpload, url, new OdeAsyncCallback<UploadResponse>() { @Override public void onSuccess(UploadResponse uploadResponse) { String toImport = uploadResponse.getInfo(); ode.getComponentService().importComponentToProject(toImport, projectId, assetsFolderNode.getFileId(), new ImportComponentCallback()); } }); return; } } private String trimLeadingPath(String filename) { // Strip leading path off filename. // We need to support both Unix ('/') and Windows ('\\') separators. return filename.substring(Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')) + 1); } }); }
From source file:com.google.code.gwt.storage.sample.hellostorage.client.HelloStorage.java
License:Apache License
/** * This is the entry point method.//from w w w .ja v a 2s. c o m */ public void onModuleLoad() { VerticalPanel main = new VerticalPanel(); RootPanel.get().add(main); RootPanel.get().setWidgetPosition(main, 10, 10); eventArea = new TextArea(); eventArea.setStyleName("widePanel"); eventArea.setHeight("60px"); eventArea.setText("[StorageEvent info]"); main.add(eventArea); HorizontalPanel eventPanel = new HorizontalPanel(); eventPanel.setStyleName("widePanel"); main.add(eventPanel); handlersLabel = new Label("#Handlers: 0"); eventPanel.add(new Button("Add a Handler", new ClickHandler() { public void onClick(ClickEvent event) { StorageEventHandler handler = new MyHandler(handlers.size() + 1); handlers.add(handler); Storage.addStorageEventHandler(handler); handlersLabel.setText("#Handlers: " + handlers.size()); } })); eventPanel.add(new Button("Delete a Handler", new ClickHandler() { public void onClick(ClickEvent event) { if (handlers.size() > 0) { StorageEventHandler handler = handlers.remove(handlers.size() - 1); Storage.removeStorageEventHandler(handler); handlersLabel.setText("#Handlers: " + handlers.size()); } } })); eventPanel.add(handlersLabel); eventPanel.setCellHorizontalAlignment(handlersLabel, HasHorizontalAlignment.ALIGN_RIGHT); if (!Storage.isLocalStorageSupported() && !Storage.isSessionStorageSupported()) { Window.alert("Web Storage NOT supported in this browser!"); return; } Storage local = Storage.getLocalStorage(); Storage session = Storage.getSessionStorage(); TabPanel tabs = new TabPanel(); main.add(tabs); tabs.add(createStorageTab(local, Storage.isLocalStorageSupported()), "localStorage"); tabs.add(createStorageTab(session, Storage.isSessionStorageSupported()), "sessionStorage"); tabs.selectTab(0); }
From source file:com.google.gwt.examples.TabPanelExample.java
License:Apache License
public void onModuleLoad() { // Create a tab panel with three tabs, each of which displays a different // piece of text. TabPanel tp = new TabPanel(); tp.add(new HTML("Foo"), "foo"); tp.add(new HTML("Bar"), "bar"); tp.add(new HTML("Baz"), "baz"); // Show the 'bar' tab initially. tp.selectTab(1); // Add it to the root panel. RootPanel.get().add(tp);//from ww w. j a va 2 s .com }
From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java
License:Apache License
/** * This is the entry point method.//from ww w . j a va2 s. co m */ public void onModuleLoad() { Log.info("Log messages enabled"); HorizontalPanel master = new HorizontalPanel(); SimpleLogHandler handler = new SimpleLogHandler(false); Log.addLogHandler(handler); DatePicker.injectDefaultCss(); TabPanel panel = new TabPanel(); master.add(panel); master.add(handler.getWidget()); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return simplePicker(); } }, "simple"); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return eventPicker(); } }, "events"); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return stylingPicker(); } }, "styles"); panel.add(new LazyPanel<Widget>() { @Override public Widget createWidget() { return dateRange(); } }, "date range"); panel.selectTab(0); RootPanel.get().add(master); }
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.// w w w . j ava2 s . c o m */ 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); } }); }