Example usage for com.google.gwt.user.client.ui HorizontalPanel setVerticalAlignment

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

Introduction

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

Prototype

public void setVerticalAlignment(VerticalAlignmentConstant align) 

Source Link

Document

Sets the default vertical alignment to be used for widgets added to this panel.

Usage

From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.git.GitCommitLocalChangesDialogWidget.java

License:Open Source License

/**
 * Helper Method to add two widgets to a horizontal panel
 * TODO Refactor To Utility Class//from w  w w  . j  a  v  a2 s  . co  m
 * @param leftWidget
 * @param rightWidget
 * @return
 */
private HorizontalPanel createHorizontalHolder(Widget leftWidget, Widget rightWidget) {
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(10);
    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hpanel.add(leftWidget);
    hpanel.add(rightWidget);
    return hpanel;
}

From source file:com.gmail.cjbooms.thesis.pythonappengine.client.menus.Toolbar.java

License:Open Source License

/**
 * Builds the main toolbar.//from ww w.  ja v  a2  s.co  m
 *
 * @return the main toolbar
 */
private HorizontalPanel buildToolBar() {
    HorizontalPanel toolbarPanel = new HorizontalPanel();
    toolbarPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    toolbarPanel.setStyleName("lab-Toolbar");
    toolbarPanel.add(buildButton(resources.blankFile(), "New Project",
            new CreateNewProjectDialogWidget().openDialogForNewProjectCommand()));
    toolbarPanel.add(buildButton(resources.openIcon(), "Open Project", createBlankCommand()));
    toolbarPanel.add(buildButton(resources.saveIcon(), "Save Project", createBlankCommand()));
    toolbarPanel.add(buildSeparator());
    toolbarPanel.add(buildButton(resources.refreshIcon(), "Refresh", createBlankCommand()));
    toolbarPanel.add(buildSeparator());
    toolbarPanel.add(buildButton(resources.copyIcon(), "Clone Project",
            (new GitCloneDialogWidget().openDialogForGITCloneCommand())));
    toolbarPanel.add(buildSeparator());
    toolbarPanel
            .add(buildButton(resources.uploadIcon(), "Deploy Project", (new DeployDialog().openMenuDialog())));

    return toolbarPanel;
}

From source file:com.google.appinventor.client.TopPanel.java

License:Open Source License

/**
 * Initializes and assembles all UI elements shown in the top panel.
 *//*from  w  ww .ja  v  a  2s.com*/
public TopPanel() {
    /*
     * The layout of the top panel is as follows:
     *
     *  +-- topPanel ------------------------------------+
     *  |+-- logo --++-----tools-----++--links/account--+|
     *  ||          ||               ||                 ||
     *  |+----------++---------------++-----------------+|
     *  +------------------------------------------------+
     */
    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    // Create the Tools
    TopToolbar tools = new TopToolbar();
    ode.setTopToolbar(tools);

    // Create the Links
    HorizontalPanel links = new HorizontalPanel();
    links.setStyleName("ode-TopPanelLinks");
    links.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    if (Ode.getInstance().isReadOnly()) {
        Label readOnly = new Label(MESSAGES.readOnlyMode());
        readOnly.setStyleName("ode-TopPanelWarningLabel");
        links.add(readOnly);
    }

    // My Projects Link
    TextButton myProjects = new TextButton(MESSAGES.myProjectsTabName());
    myProjects.setStyleName("ode-TopPanelButton");

    myProjects.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ode.switchToProjectsView();
        }
    });

    myProjects.setStyleName("ode-TopPanelButton");
    links.add(myProjects);

    // Code on gallerydev branch
    // Gallery Link
    gallery = new TextButton(MESSAGES.tabNameGallery());
    gallery.setStyleName("ode-TopPanelButton");
    gallery.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            ode.switchToGalleryView();
        }
    });
    links.add(gallery);

    Config config = ode.getSystemConfig();
    String guideUrl = config.getGuideUrl();
    if (!Strings.isNullOrEmpty(guideUrl)) {
        TextButton guideLink = new TextButton(MESSAGES.guideTabName());
        guideLink.addClickHandler(new WindowOpenClickHandler(guideUrl));
        guideLink.setStyleName("ode-TopPanelButton");
        links.add(guideLink);
    }

    // Feedback Link
    String feedbackUrl = config.getFeedbackUrl();
    if (!Strings.isNullOrEmpty(feedbackUrl)) {
        TextButton feedbackLink = new TextButton(MESSAGES.feedbackTabName());
        feedbackLink.addClickHandler(new WindowOpenClickHandler(feedbackUrl));
        feedbackLink.setStyleName("ode-TopPanelButton");
        links.add(feedbackLink);
    }

    /*
    // Code on master branch
      // Gallery Link
      if (Ode.getInstance().getUser().getIsAdmin()) {
        TextButton gallery = new TextButton(MESSAGES.galleryTabName());
        gallery.addClickHandler(new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            Window.open("http://gallery.appinventor.mit.edu", "_blank", "scrollbars=1");
          }
        });
            
        gallery.setStyleName("ode-TopPanelButton");
        links.add(gallery);
      }
      */

    moderation = new TextButton(MESSAGES.tabNameModeration());
    moderation.setStyleName("ode-TopPanelButton");
    moderation.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            ode.switchToModerationPageView();
        }
    });
    moderation.setVisible(false);
    links.add(moderation);

    // Create the Account Information
    rightPanel = new VerticalPanel();
    rightPanel.setHeight("100%");
    rightPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);

    HorizontalPanel account = new HorizontalPanel();
    account.setStyleName("ode-TopPanelAccount");

    // Account Drop Down Button
    List<DropDownItem> userItems = Lists.newArrayList();

    // Sign Out
    userItems.add(new DropDownItem(WIDGET_NAME_SIGN_OUT, MESSAGES.signOutLink(), new SignOutAction()));

    accountButton = new DropDownButton(WIDGET_NAME_USER, " ", userItems, true);
    accountButton.setItemEnabled(WIDGET_NAME_MESSAGES, false);
    accountButton.setStyleName("ode-TopPanelButton");

    // Language
    List<DropDownItem> languageItems = Lists.newArrayList();
    String[] localeNames = LocaleInfo.getAvailableLocaleNames();
    String nativeName;
    for (String localeName : localeNames) {
        if (!localeName.equals("default")) {
            SelectLanguage lang = new SelectLanguage();
            lang.setLocale(localeName);
            nativeName = getDisplayName(localeName);
            languageItems.add(new DropDownItem(WIDGET_NAME_LANGUAGE, nativeName, lang));
        }
    }
    String currentLang = LocaleInfo.getCurrentLocale().getLocaleName();
    String nativeDisplayName = getDisplayName(currentLang);
    languageDropDown = new DropDownButton(WIDGET_NAME_LANGUAGE, nativeDisplayName, languageItems, true);
    languageDropDown.setStyleName("ode-TopPanelButton");

    account.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    account.add(links);
    account.add(languageDropDown);
    account.add(accountButton);

    rightPanel.add(account);

    // Add the Logo, Tools, Links to the TopPanel
    addLogo(topPanel);
    topPanel.add(tools);
    topPanel.add(rightPanel);
    topPanel.setCellVerticalAlignment(rightPanel, HorizontalPanel.ALIGN_MIDDLE);
    rightPanel.setCellHorizontalAlignment(account, HorizontalPanel.ALIGN_RIGHT);
    topPanel.setCellHorizontalAlignment(rightPanel, HorizontalPanel.ALIGN_RIGHT);

    initWidget(topPanel);

    setStyleName("ode-TopPanel");
    setWidth("100%");
}

From source file:com.google.appinventor.client.TopToolbar.java

License:Open Source License

public TopToolbar() {
    /*//from   w w  w  .j av a 2s.c o  m
     * Layout is as follows:
     * +--------------------------------------------------+
     * | Project  | Connect  | Build | Help | Admin  |
     * +--------------------------------------------------+
     */
    HorizontalPanel toolbar = new HorizontalPanel();
    toolbar.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    List<DropDownItem> fileItems = Lists.newArrayList();
    List<DropDownItem> componentItems = Lists.newArrayList();
    List<DropDownItem> connectItems = Lists.newArrayList();
    List<DropDownItem> buildItems = Lists.newArrayList();
    List<DropDownItem> helpItems = Lists.newArrayList();

    // Should the UI be in read only mode?
    isReadOnly = Ode.getInstance().isReadOnly();

    // File -> {New Project; Save; Save As; Checkpoint; |; Delete this Project; My Projects;}
    fileItems.add(
            new DropDownItem(WIDGET_NAME_MY_PROJECTS, MESSAGES.projectMenuItem(), new SwitchToProjectAction()));
    fileItems.add(null);
    if (!isReadOnly) {
        fileItems.add(new DropDownItem(WIDGET_NAME_NEW, MESSAGES.newProjectMenuItem(), new NewAction()));
        fileItems.add(new DropDownItem(WIDGET_NAME_IMPORTPROJECT, MESSAGES.importProjectMenuItem(),
                new ImportProjectAction()));
        fileItems.add(new DropDownItem(WIDGET_NAME_IMPORTTEMPLATE, MESSAGES.importTemplateButton(),
                new ImportTemplateAction()));
        fileItems.add(new DropDownItem(WIDGET_NAME_DELETE, MESSAGES.deleteProjectButton(), new DeleteAction()));
        fileItems.add(null);
        fileItems.add(new DropDownItem(WIDGET_NAME_SAVE, MESSAGES.saveMenuItem(), new SaveAction()));
        fileItems.add(new DropDownItem(WIDGET_NAME_SAVE_AS, MESSAGES.saveAsMenuItem(), new SaveAsAction()));
        fileItems.add(new DropDownItem(WIDGET_NAME_CHECKPOINT, MESSAGES.checkpointMenuItem(),
                new CheckpointAction()));
        fileItems.add(null);
    }
    fileItems.add(new DropDownItem(WIDGET_NAME_EXPORTPROJECT, MESSAGES.exportProjectMenuItem(),
            new ExportProjectAction()));
    fileItems.add(new DropDownItem(WIDGET_NAME_EXPORTALLPROJECTS, MESSAGES.exportAllProjectsMenuItem(),
            new ExportAllProjectsAction()));
    fileItems.add(null);
    if (!isReadOnly) {
        fileItems.add(new DropDownItem(WIDGET_NAME_UPLOAD_KEYSTORE, MESSAGES.uploadKeystoreMenuItem(),
                new UploadKeystoreAction()));
    }
    fileItems.add(new DropDownItem(WIDGET_NAME_DOWNLOAD_KEYSTORE, MESSAGES.downloadKeystoreMenuItem(),
            new DownloadKeystoreAction()));
    if (!isReadOnly) {
        fileItems.add(new DropDownItem(WIDGET_NAME_DELETE_KEYSTORE, MESSAGES.deleteKeystoreMenuItem(),
                new DeleteKeystoreAction()));
    }

    // Connect -> {Connect to Companion; Connect to Emulator; Connect to USB; Reset Connections}
    connectItems.add(new DropDownItem(WIDGET_NAME_WIRELESS_BUTTON, MESSAGES.AICompanionMenuItem(),
            new WirelessAction()));
    connectItems.add(
            new DropDownItem(WIDGET_NAME_EMULATOR_BUTTON, MESSAGES.emulatorMenuItem(), new EmulatorAction()));
    connectItems.add(new DropDownItem(WIDGET_NAME_USB_BUTTON, MESSAGES.usbMenuItem(), new UsbAction()));
    connectItems.add(null);
    connectItems.add(
            new DropDownItem(WIDGET_NAME_RESET_BUTTON, MESSAGES.resetConnectionsMenuItem(), new ResetAction()));
    connectItems.add(new DropDownItem(WIDGET_NAME_HARDRESET_BUTTON, MESSAGES.hardResetConnectionsMenuItem(),
            new HardResetAction()));

    // Build -> {Show Barcode; Download to Computer; Generate YAIL only when logged in as an admin}
    buildItems.add(
            new DropDownItem(WIDGET_NAME_BUILD_BARCODE, MESSAGES.showBarcodeMenuItem(), new BarcodeAction()));
    buildItems.add(new DropDownItem(WIDGET_NAME_BUILD_DOWNLOAD, MESSAGES.downloadToComputerMenuItem(),
            new DownloadAction()));
    if (AppInventorFeatures.hasYailGenerationOption() && Ode.getInstance().getUser().getIsAdmin()) {
        buildItems.add(null);
        buildItems.add(new DropDownItem(WIDGET_NAME_BUILD_YAIL, MESSAGES.generateYailMenuItem(),
                new GenerateYailAction()));
    }

    // Help -> {About, Library, Get Started, Tutorials, Troubleshooting, Forums, Report an Issue,
    //  Companion Information, Show Splash Screen}
    helpItems.add(new DropDownItem(WIDGET_NAME_ABOUT, MESSAGES.aboutMenuItem(), new AboutAction()));
    helpItems.add(null);
    Config config = Ode.getInstance().getSystemConfig();
    String libraryUrl = config.getLibraryUrl();
    if (!Strings.isNullOrEmpty(libraryUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_LIBRARY, MESSAGES.libraryMenuItem(),
                new WindowOpenAction(libraryUrl)));
    }
    String getStartedUrl = config.getGetStartedUrl();
    if (!Strings.isNullOrEmpty(getStartedUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_GETSTARTED, MESSAGES.getStartedMenuItem(),
                new WindowOpenAction(getStartedUrl)));
    }
    String extensionsUrl = config.getExtensionsUrl();
    if (!Strings.isNullOrEmpty(extensionsUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_EXTENSIONS, MESSAGES.extensionsMenuItem(),
                new WindowOpenAction(extensionsUrl)));
    }
    String tutorialsUrl = config.getTutorialsUrl();
    if (!Strings.isNullOrEmpty(tutorialsUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_TUTORIALS, MESSAGES.tutorialsMenuItem(),
                new WindowOpenAction(tutorialsUrl)));
    }
    String troubleshootingUrl = config.getTroubleshootingUrl();
    if (!Strings.isNullOrEmpty(troubleshootingUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_TROUBLESHOOTING, MESSAGES.troubleshootingMenuItem(),
                new WindowOpenAction(troubleshootingUrl)));
    }
    String forumsUrl = config.getForumsUrl();
    if (!Strings.isNullOrEmpty(forumsUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_FORUMS, MESSAGES.forumsMenuItem(),
                new WindowOpenAction(forumsUrl)));
    }
    helpItems.add(null);
    String feedbackUrl = config.getFeedbackUrl();
    if (!Strings.isNullOrEmpty(feedbackUrl)) {
        helpItems.add(new DropDownItem(WIDGET_NAME_FEEDBACK, MESSAGES.feedbackMenuItem(),
                new WindowOpenAction(feedbackUrl)));
        helpItems.add(null);
    }
    helpItems.add(new DropDownItem(WIDGET_NAME_COMPANIONINFO, MESSAGES.companionInformation(),
            new AboutCompanionAction()));
    helpItems.add(new DropDownItem(WIDGET_NAME_COMPANIONUPDATE, MESSAGES.companionUpdate(),
            new CompanionUpdateAction()));
    helpItems.add(
            new DropDownItem(WIDGET_NAME_SHOWSPLASH, MESSAGES.showSplashMenuItem(), new ShowSplashAction()));

    // Create the TopToolbar drop down menus.
    fileDropDown = new DropDownButton(WIDGET_NAME_PROJECT, MESSAGES.projectsTabName(), fileItems, false);
    connectDropDown = new DropDownButton(WIDGET_NAME_CONNECT_TO, MESSAGES.connectTabName(), connectItems,
            false);
    buildDropDown = new DropDownButton(WIDGET_NAME_BUILD, MESSAGES.buildTabName(), buildItems, false);
    helpDropDown = new DropDownButton(WIDGET_NAME_HELP, MESSAGES.helpTabName(), helpItems, false);

    // Set the DropDown Styles
    fileDropDown.setStyleName("ode-TopPanelButton");
    connectDropDown.setStyleName("ode-TopPanelButton");
    buildDropDown.setStyleName("ode-TopPanelButton");
    helpDropDown.setStyleName("ode-TopPanelButton");

    // Add the Buttons to the Toolbar.
    toolbar.add(fileDropDown);
    toolbar.add(connectDropDown);
    toolbar.add(buildDropDown);

    // Commented out language switching until we have a clean Chinese translation. (AFM)
    toolbar.add(helpDropDown);

    //Only if logged in as an admin, add the Admin Button
    if (Ode.getInstance().getUser().getIsAdmin()) {
        List<DropDownItem> adminItems = Lists.newArrayList();
        adminItems.add(new DropDownItem(WIDGET_NAME_DOWNLOAD_USER_SOURCE, MESSAGES.downloadUserSourceMenuItem(),
                new DownloadUserSourceAction()));
        adminItems.add(new DropDownItem(WIDGET_NAME_SWITCH_TO_DEBUG, MESSAGES.switchToDebugMenuItem(),
                new SwitchToDebugAction()));
        adminItems.add(new DropDownItem(WIDGET_NAME_USER_ADMIN, "User Admin", new SwitchToUserAdminAction()));
        adminDropDown = new DropDownButton(WIDGET_NAME_ADMIN, MESSAGES.adminTabName(), adminItems, false);
        adminDropDown.setStyleName("ode-TopPanelButton");
        toolbar.add(adminDropDown);
    }

    initWidget(toolbar);

}

From source file:com.google.gwt.sample.expenses.client.DenialPopup.java

License:Apache License

public DenialPopup() {
    super(false, true);
    setStyleName(Styles.common().popupPanel());
    setGlassEnabled(true);//w w w  . ja  va  2s. c o  m
    confirmButton.setWidth("11ex");
    cancelButton.setWidth("11ex");
    reasonBox.getElement().getStyle().setMarginLeft(10.0, Unit.PX);
    reasonBox.getElement().getStyle().setMarginRight(10.0, Unit.PX);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.add(new HTML("<b>Reason:</b>"));
    hPanel.add(reasonBox);
    hPanel.add(confirmButton);
    hPanel.add(cancelButton);
    setWidget(hPanel);
    cancelButton.getElement().getParentElement().getStyle().setPaddingLeft(5.0, Unit.PX);
}

From source file:com.google.gwt.sample.kitchensink.client.Layouts.java

License:Apache License

public Layouts() {
    HTML contents = new HTML("This is a <code>ScrollPanel</code> contained at "
            + "the center of a <code>DockPanel</code>.  " + "By putting some fairly large contents "
            + "in the middle and setting its size explicitly, it becomes a "
            + "scrollable area within the page, but without requiring the use of " + "an IFRAME."
            + "Here's quite a bit more meaningless text that will serve primarily "
            + "to make this thing scroll off the bottom of its visible area.  "
            + "Otherwise, you might have to make it really, really small in order "
            + "to see the nifty scroll bars!");
    ScrollPanel scroller = new ScrollPanel(contents);
    scroller.setStyleName("ks-layouts-Scroller");

    DockPanel dock = new DockPanel();
    dock.setHorizontalAlignment(DockPanel.ALIGN_CENTER);
    HTML north0 = new HTML("This is the <i>first</i> north component", true);
    HTML east = new HTML("<center>This<br>is<br>the<br>east<br>component</center>", true);
    HTML south = new HTML("This is the south component");
    HTML west = new HTML("<center>This<br>is<br>the<br>west<br>component</center>", true);
    HTML north1 = new HTML("This is the <b>second</b> north component", true);
    dock.add(north0, DockPanel.NORTH);/*from   w w  w.j av  a2s  . c  o m*/
    dock.add(east, DockPanel.EAST);
    dock.add(south, DockPanel.SOUTH);
    dock.add(west, DockPanel.WEST);
    dock.add(north1, DockPanel.NORTH);
    dock.add(scroller, DockPanel.CENTER);

    FlowPanel flow = new FlowPanel();
    for (int i = 0; i < 8; ++i)
        flow.add(new CheckBox("Flow " + i));

    HorizontalPanel horz = new HorizontalPanel();
    horz.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    horz.add(new Button("Button"));
    horz.add(new HTML("<center>This is a<br>very<br>tall thing</center>", true));
    horz.add(new Button("Button"));

    VerticalPanel vert = new VerticalPanel();
    vert.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vert.add(new Button("Small"));
    vert.add(new Button("--- BigBigBigBig ---"));
    vert.add(new Button("tiny"));

    MenuBar menu = new MenuBar();
    MenuBar menu0 = new MenuBar(true), menu1 = new MenuBar(true);
    menu.addItem("menu0", menu0);
    menu.addItem("menu1", menu1);
    menu0.addItem("child00", (Command) null);
    menu0.addItem("child01", (Command) null);
    menu0.addItem("child02", (Command) null);
    menu1.addItem("child10", (Command) null);
    menu1.addItem("child11", (Command) null);
    menu1.addItem("child12", (Command) null);

    String id = HTMLPanel.createUniqueId();
    HTMLPanel html = new HTMLPanel("This is an <code>HTMLPanel</code>.  It allows you to add "
            + "components inside existing HTML, like this:" + "<span id='" + id + "'></span>"
            + "Notice how the menu just fits snugly in there?  Cute.");
    DOM.setStyleAttribute(menu.getElement(), "display", "inline");
    html.add(menu, id);

    VerticalPanel panel = new VerticalPanel();
    panel.setSpacing(8);
    panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    panel.add(makeLabel("Dock Panel"));
    panel.add(dock);
    panel.add(makeLabel("Flow Panel"));
    panel.add(flow);
    panel.add(makeLabel("Horizontal Panel"));
    panel.add(horz);
    panel.add(makeLabel("Vertical Panel"));
    panel.add(vert);
    panel.add(makeLabel("HTML Panel"));
    panel.add(html);

    initWidget(panel);
    setStyleName("ks-layouts");
}

From source file:com.google.gwt.sample.kitchensink.client.Lists.java

License:Apache License

public Lists() {
    combo.setVisibleItemCount(1);//from  www.  j  av  a  2s  .c o m
    combo.addChangeListener(this);
    list.setVisibleItemCount(10);
    list.setMultipleSelect(true);

    for (int i = 0; i < sStrings.length; ++i)
        combo.addItem("List " + i);
    combo.setSelectedIndex(0);
    fillList(0);

    list.addChangeListener(this);

    HorizontalPanel horz = new HorizontalPanel();
    horz.setVerticalAlignment(HorizontalPanel.ALIGN_TOP);
    horz.setSpacing(8);
    horz.add(combo);
    horz.add(list);

    VerticalPanel panel = new VerticalPanel();
    panel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
    panel.add(horz);
    panel.add(echo);
    initWidget(panel);

    echoSelection();
}

From source file:com.google.gwt.sample.showcase.client.content.lists.CwStackLayoutPanel.java

License:Apache License

/**
 * Create a widget to display in the header that includes an image and some
 * text./*from   w ww.  j  av  a  2 s.c om*/
 * 
 * @param text the header text
 * @param image the {@link ImageResource} to add next to the header
 * @return the header widget
 */
@ShowcaseSource
private Widget createHeaderWidget(String text, ImageResource image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setHeight("100%");
    hPanel.setSpacing(0);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.add(new Image(image));
    HTML headerText = new HTML(text);
    headerText.setStyleName("cw-StackPanelHeader");
    hPanel.add(headerText);
    return new SimplePanel(hPanel);
}

From source file:com.google.gwt.sample.showcase.client.content.lists.CwStackPanel.java

License:Apache License

/**
 * Get a string representation of the header that includes an image and some
 * text.//from   w  w  w . j  a  v  a 2s  . c om
 *
 * @param text the header text
 * @param image the {@link ImageResource} to add next to the header
 * @return the header as a string
 */
@ShowcaseSource
private String getHeaderString(String text, ImageResource image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(0);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.add(new Image(image));
    HTML headerText = new HTML(text);
    headerText.setStyleName("cw-StackPanelHeader");
    hPanel.add(headerText);

    // Return the HTML string for the panel
    return hPanel.getElement().getString();
}

From source file:com.google.sampling.experiential.client.EsmPanel.java

License:Open Source License

public EsmPanel(final SignalScheduleDAO schedule) {
    MyConstants myConstants = GWT.create(MyConstants.class);
    this.schedule = schedule;
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setSpacing(2);/* w  w  w .ja  v  a 2s .c o  m*/
    initWidget(verticalPanel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(2);
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellVerticalAlignment(horizontalPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setWidth("");

    Label lblFrequency = new Label(myConstants.frequency() + ":");
    lblFrequency.setStyleName("gwt-Label-Header");
    horizontalPanel.add(lblFrequency);
    ValueSpinnerFixed frequencySpinner = new ValueSpinnerFixed(schedule.getEsmFrequency(), 0, 100);
    frequencySpinner.getTextBox().setWidth("18px");
    frequencySpinner.setWidth("35px");
    horizontalPanel.add(frequencySpinner);
    frequencySpinner.getSpinner().addSpinnerListener(new SpinnerListener() {
        public void onSpinning(long value) {
            schedule.setEsmFrequency((int) value);
        }
    });

    Label lblPeriod = new Label(myConstants.period() + ": ");
    lblPeriod.setStyleName("gwt-Label-Header");
    horizontalPanel.add(lblPeriod);

    final ListBox listBox = new ListBox();
    for (int i = 0; i < SignalScheduleDAO.ESM_PERIODS.length; i++) {
        listBox.addItem(SignalScheduleDAO.ESM_PERIODS_NAMES[i]);
    }
    horizontalPanel.add(listBox);
    listBox.setVisibleItemCount(1);
    Integer period = schedule.getEsmPeriodInDays();
    if (period == null) {
        period = SignalScheduleDAO.DEFAULT_ESM_PERIOD;
        schedule.setEsmPeriodInDays(SignalScheduleDAO.DEFAULT_ESM_PERIOD);
    }
    listBox.setSelectedIndex(period);
    listBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            schedule.setEsmPeriodInDays(listBox.getSelectedIndex());
        }
    });
    verticalPanel.add(horizontalPanel);

    HorizontalPanel weekendsPanel = new HorizontalPanel();
    weekendsPanel.setSpacing(2);
    weekendsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(weekendsPanel);
    weekendsPanel.setWidth("");
    Label lblWeekends = new Label(myConstants.includeWeekends() + ": ");
    lblWeekends.setStyleName("gwt-Label-Header");
    weekendsPanel.add(lblWeekends);

    final CheckBox weekendsBox = new CheckBox("");
    weekendsPanel.add(weekendsBox);
    weekendsBox.setValue(schedule.getEsmWeekends());
    weekendsBox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            schedule.setEsmWeekends(weekendsBox.getValue());
        }

    });

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    horizontalPanel_1.setSpacing(2);
    horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(horizontalPanel_1);
    horizontalPanel_1.setWidth("");

    Label lblStartHour = new Label(myConstants.startTime() + ":");
    lblStartHour.setStyleName("gwt-Label-Header");
    horizontalPanel_1.add(lblStartHour);
    lblStartHour.setWidth("83px");

    Date setTime = null;
    if (schedule.getEsmStartHour() != null) {
        setTime = new Date();
        long offset = schedule.getEsmStartHour();
        int hours = (int) (offset / (60 * 60 * 1000));
        int minutes = (int) (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);
        setTime.setHours(hours);
        setTime.setMinutes(minutes);
        setTime.setSeconds(0);
    } else {
        Date now = new Date();
        now.setMinutes(0);
        now.setSeconds(0);
        setTime = now;
    }

    final TimePickerFixed startTimeBox = new TimePickerFixed(setTime, DateTimeFormat.getFormat("aa"),
            DateTimeFormat.getFormat("hh"), DateTimeFormat.getFormat("mm"), null);

    horizontalPanel_1.add(startTimeBox);

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    horizontalPanel_2.setSpacing(2);
    horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(horizontalPanel_2);
    horizontalPanel_2.setWidth("");
    startTimeBox.addValueChangeHandler(new ValueChangeHandler() {
        public void onValueChange(ValueChangeEvent event) {
            Date dateTime = startTimeBox.getDateTime();
            long offset = (dateTime.getHours() * 60 * 60 * 1000) + (dateTime.getMinutes() * 60 * 1000);
            schedule.setEsmStartHour(offset);
        }
    });

    Label lblEndTime = new Label(myConstants.endTime() + ":  ");
    lblEndTime.setStyleName("gwt-Label-Header");
    horizontalPanel_2.add(lblEndTime);
    lblEndTime.setWidth("83px");

    setTime = null;
    if (schedule.getEsmEndHour() != null) {
        setTime = new Date();
        long offset = schedule.getEsmEndHour();
        int hours = (int) (offset / (60 * 60 * 1000));
        int minutes = (int) (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);
        setTime.setHours(hours);
        setTime.setMinutes(minutes);
    } else {
        Date now = new Date();
        now.setMinutes(0);
        now.setSeconds(0);
        setTime = now;
    }

    final TimePickerFixed endTimePicker = new TimePickerFixed(setTime, DateTimeFormat.getFormat("aa"),
            DateTimeFormat.getFormat("hh"), DateTimeFormat.getFormat("mm"), null);

    horizontalPanel_2.add(endTimePicker);
    endTimePicker.addValueChangeHandler(new ValueChangeHandler() {
        public void onValueChange(ValueChangeEvent event) {
            Date dateTime = endTimePicker.getDateTime();
            long offset = (dateTime.getHours() * 60 * 60 * 1000) + (dateTime.getMinutes() * 60 * 1000);
            schedule.setEsmEndHour(offset);
        }
    });

    TimeoutPanel timeoutPanel = new TimeoutPanel(schedule);
    verticalPanel.add(timeoutPanel);
    timeoutPanel.setWidth("286px");

    MinimumBufferPanel minimumBufferPanel = new MinimumBufferPanel(schedule);
    verticalPanel.add(minimumBufferPanel);
    minimumBufferPanel.setWidth("286px");

    SnoozePanel snoozePanel = new SnoozePanel(schedule);
    verticalPanel.add(snoozePanel);
    snoozePanel.setWidth("286px");

}