Example usage for com.google.gwt.user.client.ui TabPanel TabPanel

List of usage examples for com.google.gwt.user.client.ui TabPanel TabPanel

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TabPanel TabPanel.

Prototype

public TabPanel() 

Source Link

Document

Creates an empty tab panel.

Usage

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryList.java

License:Open Source License

/**
 * Creates a new GalleryList/*ww  w. ja v a 2  s . c om*/
 */
public GalleryList() {

    gallery = GalleryClient.getInstance();
    gallery.addListener(this);
    galleryGF = new GalleryGuiFactory();

    selectedApps = new ArrayList<GalleryApp>();

    // Initialize UI
    galleryGUI = new FlowPanel();
    galleryGUI.addStyleName("gallery");
    appTabs = new TabPanel();
    appRecent = new FlowPanel();
    appFeatured = new FlowPanel();
    appPopular = new FlowPanel();
    appSearch = new FlowPanel();
    appTutorial = new FlowPanel();
    appRecentContent = new FlowPanel();
    appFeaturedContent = new FlowPanel();
    appPopularContent = new FlowPanel();
    appSearchContent = new FlowPanel();
    appTutorialContent = new FlowPanel();
    searchText = new TextBox();

    // HTML segment for gallery typeface
    HTML headerExtra = new HTML("<link href='http://fonts.googleapis.com/css?"
            + "family=Roboto:400,300,100' rel='stylesheet' type='text/css'>");
    galleryGUI.add(headerExtra);

    // Add content to panels
    appFeaturedTab = new GalleryAppTab(appFeatured, appFeaturedContent, REQUEST_FEATURED);
    appRecentTab = new GalleryAppTab(appRecent, appRecentContent, REQUEST_RECENT);
    appSearchTab = new GalleryAppTab(appSearch, appSearchContent, REQUEST_SEARCH);
    appPopularTab = new GalleryAppTab(appPopular, appPopularContent, REQUEST_MOSTLIKED);
    appTutorialTab = new GalleryAppTab(appTutorial, appTutorialContent, REQUEST_TUTORIAL);
    // don't think we need because in regular addgallerytab below

    // Add panels to main tabPanel
    appTabs.add(appRecent, "Recent");
    appTabs.add(appTutorial, "Tutorials");
    appTabs.add(appFeatured, "Featured");
    appTabs.add(appPopular, "Popular");
    appTabs.add(appSearch, "Search");
    appTabs.selectTab(0);
    appTabs.addStyleName("gallery-app-tabs");
    galleryGUI.add(appTabs);

    // Initialize top-level GUI
    VerticalPanel panel = new VerticalPanel();
    panel.setWidth("100%");
    panel.add(galleryGUI);

    initWidget(panel);
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java

License:Open Source License

/**
* Helper method called by constructor to initialize ui components
*//*from w  w w. j ava2s  .  c o m*/
private void initComponents() {
    // Initialize UI
    panel = new VerticalPanel();
    panel.setWidth("100%");
    galleryGUI = new FlowPanel();
    appSingle = new FlowPanel();
    appDetails = new FlowPanel();
    appHeader = new FlowPanel();
    appInfo = new FlowPanel();
    appAction = new FlowPanel();
    appAuthor = new FlowPanel();
    appMeta = new FlowPanel();
    appDates = new FlowPanel();
    appPrimaryWrapper = new FlowPanel();
    appSecondaryWrapper = new FlowPanel();
    appDescPanel = new FlowPanel();
    appReportPanel = new FlowPanel();
    appSharePanel = new FlowPanel();
    appActionTabs = new TabPanel();
    sidebarTabs = new TabPanel();
    appComments = new FlowPanel();
    appCommentsList = new FlowPanel();
    appsByAuthor = new FlowPanel();
    appsByTags = new FlowPanel();
    appsRemixes = new FlowPanel();
    returnToGallery = new FlowPanel();
    //    tagSelected = "";

    appCreated = new Label();
    appChanged = new Label();
    descBox = new FlowPanel();
    titleBox = new FlowPanel();
    desc = new TextArea();
    titleText = new TextArea();
    moreInfoText = new TextArea();
    creditText = new TextArea();
    ccLicenseRef = new HTML(MESSAGES.galleryCcLicenseRef());
    ccLicenseRef.addStyleName("app-action-html");
}

From source file:com.google.appinventor.client.explorer.youngandroid.ProfilePage.java

License:Open Source License

/**
 * Creates a new ProfilePage, must take in parameters
 *
 * @param incomingUserId  the string ID of user that we are about to render
 * @param editStatus  the edit status (0 is private, 1 is public)
 *
 *//* w ww.j  a  v  a 2  s  . c o  m*/
public ProfilePage(final String incomingUserId, final int editStatus) {

    appCatalog = new FlowPanel();
    appCatalogContent = new FlowPanel();
    selectedApps = new ArrayList<GalleryApp>();
    appTabs = new TabPanel();

    // Replace the global variable
    if (incomingUserId.equalsIgnoreCase("-1")) {
        // this is user checking out own profile, thus we grab current user info
        // Get current user id
        final User currentUser = Ode.getInstance().getUser();
        userId = currentUser.getUserId();
    } else {
        // this is checking out an already existing user's profile...
        userId = incomingUserId;
    }
    profileStatus = editStatus;

    // If we're editing or updating, add input form for image
    if (editStatus == PRIVATE) {
        // This should only set up image after userId is returned above
    } else { // we are just viewing this page so setup the image
        initReadOnlyImage();
    }

    if (editStatus == PRIVATE) {
        userContentHeader.setText(MESSAGES.labelEditYourProfile());
        usernameLabel.setText(MESSAGES.labelYourDisplayName());
        userLinkLabel.setText(MESSAGES.labelMoreInfoLink());
        userEmailDescriptionLabel.setText(MESSAGES.labelEmailDescription());
        userEmailFrequencyPrefixLabel.setText(MESSAGES.labelEmailFrequencyPrefix());
        userEmailFrequencySuffixLabel.setText(MESSAGES.labelEmailFrequencySuffix());
        editProfile.setVisible(false);

        profileSubmit.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                profileSubmit.setEnabled(false);
                if (!validEmailFrequency(userEmailFrequencyBox.getText())) {
                    Window.alert(MESSAGES.errorEmailFrequency());
                    profileSubmit.setEnabled(true);
                    return;
                }

                // Store the name value of user, modify database
                final OdeAsyncCallback<Void> userNameUpdateCallback = new OdeAsyncCallback<Void>(
                        // failure message
                        MESSAGES.galleryError()) {
                    @Override
                    public void onSuccess(Void arg0) {
                        profileSubmit.setEnabled(true);
                    }
                };
                ode.getUserInfoService().storeUserName(userNameBox.getText(), userNameUpdateCallback);

                // Store the link value of user, modify database
                final OdeAsyncCallback<Void> userLinkUpdateCallback = new OdeAsyncCallback<Void>(
                        // failure message
                        MESSAGES.galleryError()) {
                    @Override
                    public void onSuccess(Void arg0) {
                    }
                };
                if (userLinkBox.getText().isEmpty()) {
                    Ode.getInstance().getUserInfoService().storeUserLink("", userLinkUpdateCallback);
                } else {
                    Ode.getInstance().getUserInfoService().storeUserLink(userLinkBox.getText(),
                            userLinkUpdateCallback);
                }

                // Store the email notification frequency value of user, modofy database
                final OdeAsyncCallback<Void> userEmailFrequencyUpdateCallback = new OdeAsyncCallback<Void>(
                        // failure message
                        MESSAGES.galleryError()) {
                    @Override
                    public void onSuccess(Void arg0) {
                    }
                };
                Ode.getInstance().getUserInfoService().storeUserEmailFrequency(
                        Integer.valueOf(userEmailFrequencyBox.getText()), userEmailFrequencyUpdateCallback);

            }
        });

        profileInfo.add(userContentHeader);
        profileInfo.add(usernameLabel);
        profileInfo.add(userNameBox);
        profileInfo.add(userLinkLabel);
        profileInfo.add(userLinkBox);
        profileInfo.add(userEmailDescriptionLabel);
        profileInfo.add(userEmailFrequencyPrefixLabel);
        profileInfo.add(userEmailFrequencyBox);
        profileInfo.add(userEmailFrequencySuffixLabel);
        profileInfo.add(profileSubmit);

    } else {
        profileSingle.addStyleName("ode-Public");
        // USER PROFILE IN PUBLIC (NON-EDITABLE) STATE
        // Set up the user info stuff
        userLinkLabel.setText("More info:");
        profileInfo.add(userContentHeader);
        profileInfo.add(userLinkLabel);
        profileInfo.add(userLinkDisplay);
        profileInfo.add(editProfile);
    }

    // Add GUI layers in the "main content" container
    profileHeader.addStyleName("app-header"); //TODO: change a more contextual style name
    profilePrimaryWrapper.add(profileHeader); // profileImage
    profileInfo.addStyleName("app-info-container");
    profilePrimaryWrapper.add(profileInfo);
    profilePrimaryWrapper.addStyleName("clearfix");
    mainContent.add(profilePrimaryWrapper);

    // Add styling for user info detail components
    mainContent.addStyleName("gallery-container");
    mainContent.addStyleName("gallery-content-details");
    userContentHeader.addStyleName("app-title");
    usernameLabel.addStyleName("profile-textlabel");
    userNameBox.addStyleName("profile-textbox");
    userNameDisplay.addStyleName("profile-textdisplay");
    userLinkLabel.addStyleName("profile-textlabel");
    userLinkBox.addStyleName("profile-textbox");
    userLinkDisplay.addStyleName("profile-textdisplay");
    userEmailDescriptionLabel.addStyleName("profile-textlabel-emaildescription");
    userEmailFrequencyPrefixLabel.addStyleName("profile-textlabel");
    userEmailFrequencySuffixLabel.addStyleName("profile-textlabel");
    userEmailFrequencyBox.addStyleName("profile-textbox-small");
    editProfile.addStyleName("profile-submit");

    profileSubmit.addStyleName("profile-submit");
    imageUpload.addStyleName("app-image-upload");

    // Add sidebar
    if (editStatus == PUBLIC) {
        sidebarTabs.addStyleName("gallery-container");
        sidebarTabs.addStyleName("gallery-app-showcase");
    }
    // Setup top level containers
    // profileSingle is the actual container that components go in
    profileSingle.addStyleName("gallery-page-single");

    // Add containers to the top-tier GUI, initialize
    profileSingle.add(mainContent);
    if (editStatus == PUBLIC) {
        profileSingle.add(appTabs);
        profileSingle.add(sidebarTabs);
    }

    // profileGUI is just the abstract top-level GUI container
    profileGUI.add(profileSingle);
    profileGUI.addStyleName("ode-UserProfileWrapper");
    profileGUI.addStyleName("gallery");
    initWidget(profileGUI);

    // Retrieve other user info right after GUI is initialized
    final OdeAsyncCallback<User> userInformationCallback = new OdeAsyncCallback<User>(
            // failure message
            MESSAGES.galleryError()) {
        @Override
        public void onSuccess(User user) {
            // Set associate GUI components of public states
            // In this case it'll return the user of [userId]
            userContentHeader.setText(user.getUserName());
            makeValidLink(userLinkDisplay, user.getUserLink());
            userEmailFrequencyBox.setText(String.valueOf(user.getUserEmailFrequency()));
        }
    };
    if (editStatus == PRIVATE) {
        User currentUser = Ode.getInstance().getUser();
        // In this case it'll return the current user
        userId = currentUser.getUserId();
        userNameBox.setText(currentUser.getUserName());
        userLinkBox.setText(currentUser.getUserLink());
        userEmailFrequencyBox.setText(String.valueOf(currentUser.getUserEmailFrequency()));
    } else {
        // Public state
        Ode.getInstance().getUserInfoService().getUserInformationByUserId(userId, userInformationCallback);
        sidebarTabs.setVisible(false);
        appCatalogTab = new GalleryAppTab(appCatalog, appCatalogContent, userId);
        appTabs.add(appCatalog, "My Catalog");
        appTabs.selectTab(0);
        appTabs.addStyleName("gallery-app-tabs");
    }

    //TODO this callback should combine with previous ones. Leave it out for now
    final User user = Ode.getInstance().getUser();
    if (incomingUserId.equals(user.getUserId())) {
        editProfile.setVisible(true);
        editProfile.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent clickEvent) {
                ode.switchToPrivateUserProfileView();
                PrivateUserProfileTabPanel.getPrivateUserProfileTabPanel().selectTab(0);
            }
        });
    } else {
        editProfile.setVisible(false);
    }

}

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 .  c  o 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.// ww  w.j av a 2 s.  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);/*from  ww  w  .  j  a  v  a2  s .c o m*/

    // Add it to the root panel.
    RootPanel.get().add(tp);
}

From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java

License:Apache License

/**
 * This is the entry point method./* w ww.j  a v  a2s . c om*/
 */
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./*  ww w  . j a  v a 2s  .  co 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);
        }
    });
}

From source file:com.google.gwt.sample.simplexml.client.SimpleXML.java

License:Apache License

private void renderXML(String xmlText) {
    final TabPanel tab = new TabPanel();
    final FlowPanel xmlSource = new FlowPanel();
    final FlowPanel xmlParsed = new FlowPanel();
    tab.add(xmlParsed, "Customer Pane");
    tab.add(xmlSource, "XML Source");
    tab.selectTab(0);//w w w . j a  v a  2  s .c om
    RootPanel.get().add(tab);
    xmlPane(xmlText, xmlSource);
    customerPane(xmlText, xmlParsed);
}

From source file:com.google.gwt.sample.stockwatcher.client.BrowserHistoryExample.java

/**
 * This is the entry point method./*from   w ww  .  j a  v a  2  s  .  c o m*/
 */
public void onModuleLoad() {
    tabPanel = new TabPanel();

    tabPanel.add(new HTML("<h1>Page 0 Content: Llamas</h1>"), " Page 0 ");
    tabPanel.add(new HTML("<h1>Page 1 Content: Alpacas</h1>"), " Page 1 ");
    tabPanel.add(new HTML("<h1>Page 2 Content: Camels</h1>"), " Page 2 ");

    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        public void onSelection(SelectionEvent<Integer> event) {
            History.newItem("page" + event.getSelectedItem());
        }
    });

    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        public void onValueChange(ValueChangeEvent<String> event) {
            String historyToken = event.getValue();

            // Parse the history token
            try {
                if (historyToken.substring(0, 4).equals("page")) {
                    String tabIndexToken = historyToken.substring(4, 5);
                    int tabIndex = Integer.parseInt(tabIndexToken);
                    // Select the specified tab panel
                    tabPanel.selectTab(tabIndex);
                } else {
                    tabPanel.selectTab(0);
                }

            } catch (IndexOutOfBoundsException e) {
                tabPanel.selectTab(0);
            }
        }
    });

    tabPanel.selectTab(0);
    RootPanel.get().add(tabPanel);
}