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:net.cbtltd.client.field.spinner.VolumeSlider.java

License:Apache License

/**
 * Instantiates a new volume slider./*from  w  w  w .  j av a2s.c o  m*/
 * 
 * @param min the minimum value of the spinner.
 * @param max the maximum value of the spinner.
 * @param value the initial value of the spinner.
 */
public VolumeSlider(Integer min, Integer max, Integer value) {
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setStyleName("gwt-VolumeSlider");
    horizontalPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    progressBar = new ProgressBar(min, max);
    progressBar.setProgress(value);
    //    spinner = new Spinner(listener, value, min, max, 1, 5, true, resources);
    spinner = new Spinner(listener, value, min, max, 1, 5, true);
    SimplePanel leftPanel = new SimplePanel();
    leftPanel.add(spinner.getDecrementArrow());
    leftPanel.setStyleName("decreaseArrow");
    horizontalPanel.add(leftPanel);
    horizontalPanel.add(progressBar);
    progressBar.setWidth("100%");
    horizontalPanel.setCellWidth(progressBar, "100%");
    SimplePanel rightPanel = new SimplePanel();
    rightPanel.add(spinner.getIncrementArrow());
    rightPanel.setStyleName("increaseArrow");
    horizontalPanel.add(rightPanel);
    initWidget(horizontalPanel);
}

From source file:net.cbtltd.client.form.AbstractForm.java

/**
 * Create the header for the specified panel.
 *
 * @param panel the specified panel.//w w  w .  j  a v a 2 s. c  o m
 */
protected void createHeader(HorizontalPanel panel, int index) {
    panel.clear();
    panel.addStyleName(CSS.appHeader());
    panel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);

    HTML headerLogo = new HTML();
    headerLogo.setHTML("a<span style='font-weight: 600;'>booking</span>net");
    headerLogo.addStyleName(CSS.appHeaderLogo());
    panel.add(headerLogo);

    final HorizontalPanel panelTabs = new HorizontalPanel();
    createTabs(panelTabs, index);
    panel.add(panelTabs);
    panel.add(createUtilities());
}

From source file:net.cbtltd.client.form.SessionForm.java

@Override
public void initialize() {
    AbstractField.CSS.ensureInjected();
    CSS.ensureInjected();/*  w  w w . j av a2s .com*/

    final ScrollPanel scroll = new ScrollPanel();
    add(scroll);
    final HorizontalPanel panel = new HorizontalPanel();
    panel.setWidth("100%");
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
    //panel.addStyleName(AbstractField.CSS.cbtAbstractForm());
    //panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    scroll.add(panel);

    final FlowPanel west = new FlowPanel();
    //      panel.add(west);
    final FlowPanel sessionForm = new FlowPanel();
    sessionForm.addStyleName(AbstractField.CSS.cbtAbstractControl());
    sessionForm.addStyleName(CSS.formStyle());
    sessionForm.addStyleName(CSS.magnify());
    west.add(sessionForm);

    final Frame frame = new Frame(HOSTS.cloudUrl());
    frame.setStylePrimaryName(CSS.frameStyle());
    //      panel.add(frame);

    //Rishi
    VerticalPanel frontPanel = new VerticalPanel();

    frontPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    frontPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    frontPanel.addStyleName(CSS.loginPopup());
    panel.add(frontPanel);

    // Add the header label
    Label loginFormLabel = new Label(CONSTANTS.headerLabel());
    loginFormLabel.addStyleName(CSS.frontHeaderStyle());
    frontPanel.add(loginFormLabel);

    // Create a horizontal panel to add the login window and registration window
    HorizontalPanel loginRegPanel = new HorizontalPanel();

    // Add the login Panel
    loginRegPanel.add(new LoginWindow());

    // Add the registration Panel
    VerticalPanel registrationPanel = new VerticalPanel();
    registrationPanel.addStyleName(CSS.registerForm());

    Label registerHeaderLabel = new Label("Register");
    registerHeaderLabel.addStyleName(CSS.signLabel());

    Label registerPropertyButton = new Label(CONSTANTS.registerPropertyLabel());
    registerPropertyButton.addStyleName(CSS.passwordcreateStyle());
    registerPropertyButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            AbstractRoot.renderTabs(Razor.ORGANIZATION_TAB, new Organization());
        }
    });

    Label registerTravelButton = new Label(CONSTANTS.registerTravelLabel());
    registerTravelButton.addStyleName(CSS.passwordcreateStyle());
    registerTravelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            AbstractRoot.renderTabs(Razor.ORGANIZATION_TAB, new Agent());
        }
    });

    registrationPanel.add(registerHeaderLabel);
    registrationPanel.add(registerPropertyButton);
    registrationPanel.add(registerTravelButton);

    loginRegPanel.add(registrationPanel);

    frontPanel.add(loginRegPanel);

    //-----------------------------------------------
    // Log In button
    //-----------------------------------------------
    final HTML loginButton = new HTML(CONSTANTS.loginLabel());
    loginButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            new SessionPopup().center();
        }
    });
    loginButton.addStyleName(CSS.sessionButton());
    loginButton.addStyleName(CSS.loginButton());
    loginButton.addStyleName(AbstractField.CSS.cbtGradientGreen());
    sessionForm.add(loginButton);

    final Label registerLabel = new Label(CONSTANTS.registerLabel());
    registerLabel.addStyleName(CSS.registerLabel());
    sessionForm.add(registerLabel);

    //-----------------------------------------------
    // Register Agent button
    //-----------------------------------------------
    final HTML registeragentButton = new HTML(CONSTANTS.registeragentLabel());
    registeragentButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            AbstractRoot.renderTabs(Razor.ORGANIZATION_TAB, new Agent());
        }
    });
    registeragentButton.addStyleName(CSS.sessionButton());
    registeragentButton.addStyleName(CSS.registerButton());
    registeragentButton.addStyleName(AbstractField.CSS.cbtGradientBase());
    sessionForm.add(registeragentButton);

    //-----------------------------------------------
    // Register Manager button
    //-----------------------------------------------
    final HTML registermanagerButton = new HTML(CONSTANTS.registermanagerLabel());
    registermanagerButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            AbstractRoot.renderTabs(Razor.ORGANIZATION_TAB, new Organization());
        }
    });
    registermanagerButton.addStyleName(CSS.sessionButton());
    registermanagerButton.addStyleName(CSS.registerButton());
    registermanagerButton.addStyleName(AbstractField.CSS.cbtGradientBase());
    sessionForm.add(registermanagerButton);

    //-----------------------------------------------
    // Register Affiliate button
    //-----------------------------------------------
    final HTML registercreatorButton = new HTML(CONSTANTS.registercreatorLabel());
    registercreatorButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PartyPopup.getInstance().show(Party.Type.Affiliate, null, null);
        }
    });
    registercreatorButton.addStyleName(CSS.sessionButton());
    registercreatorButton.addStyleName(CSS.registerButton());
    registercreatorButton.addStyleName(AbstractField.CSS.cbtGradientBase());
    sessionForm.add(registercreatorButton);

    Label infoLabel = new Label(CONSTANTS.infoLabel());
    infoLabel.addStyleName(CSS.registerLabel());
    sessionForm.add(infoLabel);

    //-----------------------------------------------
    // More Info button
    //-----------------------------------------------
    final HTML infoButton = new HTML(CONSTANTS.infoButton());
    infoButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Window.open(HOSTS.infoUrl(), CONSTANTS.infoTitle(),
                    "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes");
        }
    });
    infoButton.addStyleName(CSS.sessionButton());
    infoButton.addStyleName(CSS.registerButton());
    infoButton.addStyleName(AbstractField.CSS.cbtGradientBase());
    sessionForm.add(infoButton);

    FlowPanel shadow = new FlowPanel();
    shadow.addStyleName(AbstractField.CSS.cbtAbstractShadow());
    west.add(shadow);

    //      if(getUserAgent().contains("msie")) {
    //         loginButton.setVisible(false);
    //         registerLabel.setVisible(false);
    //         registeragentButton.setVisible(false);
    //         registermanagerButton.setVisible(false);
    //         sessionError.setVisible(true);
    //      }
    onRefresh();
    onReset(Session.LOGGED_OUT);
}

From source file:net.europa13.taikai.web.client.TaikaiWebEntryPoint.java

License:Open Source License

private void initLogger() {
    //*********************************************************************
    // Logger/*w ww .ja  v a2s  .  c  o m*/
    VerticalPanel logPanel = new VerticalPanel();
    VerticalPanel logPanelContents = new VerticalPanel();
    logPanel.setWidth("100%");
    logPanel.setBorderWidth(1);
    Button logClearBTN = new Button("Tm logg", new ClickListener() {

        public void onClick(Widget source) {
            Logger.clear();
        }
    });
    HorizontalPanel logPanelHeader = new HorizontalPanel();
    logPanelHeader.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    logPanelHeader.add(new HTML("<h2>Logg</h2>"));
    logPanelHeader.add(logClearBTN);

    logPanel.add(logPanelHeader);
    logPanel.add(logPanelContents);
    RootPanel.get("root_bottom").add(logPanel);

    Logger.setTarget(new PanelHtmlLogTarget(logPanelContents));
    Logger.setLevel(LogLevel.DEBUG);
}

From source file:net.officefloor.demo.chat.client.ChatWidget.java

License:Open Source License

/**
 * Initiate./*from   w  w  w. j  a  v  a2s .  c  o m*/
 */
public ChatWidget() {

    // Provide means to send a message
    HorizontalPanel messagePanel = new HorizontalPanel();
    // messagePanel.setSpacing(10);
    messagePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    this.add(messagePanel);

    // Provide message text box
    this.messageText.setStylePrimaryName("message");
    messagePanel.add(this.messageText);
    this.messageText.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            ChatWidget.this.ensureHaveUserName();
        }
    });

    // Provide send button for message
    Button sendButton = new Button("send");
    sendButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ChatWidget.this.sendChatMessage();
        }
    });
    messagePanel.add(sendButton);

    // Provide messages in scroll area
    VerticalPanel messagesPanel = new VerticalPanel();
    messagesPanel.setSize("100%", "100%");
    ScrollPanel scrollMessagesPanel = new ScrollPanel(messagesPanel);
    scrollMessagesPanel.setStylePrimaryName("messages");
    this.add(scrollMessagesPanel);

    // Provide label to display typing users
    final Label typingLabel = new Label();
    typingLabel.setStylePrimaryName("typing");
    messagesPanel.add(typingLabel);
    typingLabel.setVisible(false); // initially hidden as no typing users

    // List to contain chat messages
    Cell<ChatMessage> chatCell = new AbstractCell<ChatMessage>() {
        @Override
        public void render(Context context, ChatMessage value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<span><b>");
            sb.appendEscaped(value.getUserName());
            sb.appendHtmlConstant("</b>");
            sb.appendEscaped(" > ");
            sb.appendEscaped(value.getMessage());
            sb.appendHtmlConstant("</span>");
        }
    };
    CellList<ChatMessage> chatList = new CellList<ChatMessage>(chatCell);
    messagesPanel.add(chatList);

    // Add the data
    final ListDataProvider<ChatMessage> chatEntries = new ListDataProvider<ChatMessage>();
    chatEntries.addDataDisplay(chatList);

    // Handle listening for messages
    OfficeFloorComet.subscribe(ConversationSubscription.class, new ConversationSubscription() {
        @Override
        public void message(ChatMessage message) {

            // Determine if typing notification
            String userName = message.getUserName();
            if ((ChatWidget.this.userName == null) || (!(ChatWidget.this.userName.equals(userName)))) {
                // Not user so provide notification of typing
                if (message.isTyping()) {
                    // Include user as typing
                    if (!(ChatWidget.this.typingUserNames.contains(userName))) {
                        ChatWidget.this.typingUserNames.add(userName);
                    }
                } else {
                    // User has stopped typing
                    ChatWidget.this.typingUserNames.remove(userName);
                }
            }

            // Display typing notification
            if (ChatWidget.this.typingUserNames.size() == 0) {
                // No typing users
                typingLabel.setVisible(false);

            } else {
                // Display the typing users
                StringBuilder typingUsers = new StringBuilder();
                boolean isFirst = true;
                for (String typingUserName : ChatWidget.this.typingUserNames) {
                    if (!isFirst) {
                        typingUsers.append(", ");
                    }
                    isFirst = false;
                    typingUsers.append(typingUserName);
                }
                typingUsers.append(" ... (typing)");
                typingLabel.setText(typingUsers.toString());
                typingLabel.setVisible(true);
            }

            // Add the message (if one provided)
            String text = message.getMessage();
            if (text != null) {
                List<ChatMessage> list = chatEntries.getList();
                if (list.size() == 0) {
                    list.add(message);
                } else {
                    list.add(0, message);
                }
            }
        }
    }, null);

    // Handle submitting a message
    this.messageText.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {

            // Obtain the message text and cursor position
            String message = ChatWidget.this.messageText.getText();
            int cursorPosition = ChatWidget.this.messageText.getCursorPos();

            // Handle various scenarios of keys for sending/notification
            switch (event.getNativeKeyCode()) {
            case KeyCodes.KEY_ENTER:
                ChatWidget.this.sendChatMessage();
                break;

            case KeyCodes.KEY_BACKSPACE:
                if (ChatWidget.this.isTyping && (message.length() == 1) && (cursorPosition == 1)) {
                    // No longer typing as deleting last character
                    ChatWidget.this.sendChatMessage(false, null);
                }
                break;

            case KeyCodes.KEY_DELETE:
                if (ChatWidget.this.isTyping && (message.length() == 1) && (cursorPosition == 0)) {
                    // No longer typing as deleting last character
                    ChatWidget.this.sendChatMessage(false, null);
                }
                break;

            case KeyCodes.KEY_ALT:
            case KeyCodes.KEY_CTRL:
            case KeyCodes.KEY_DOWN:
            case KeyCodes.KEY_END:
            case KeyCodes.KEY_ESCAPE:
            case KeyCodes.KEY_HOME:
            case KeyCodes.KEY_LEFT:
            case KeyCodes.KEY_PAGEDOWN:
            case KeyCodes.KEY_PAGEUP:
            case KeyCodes.KEY_RIGHT:
            case KeyCodes.KEY_SHIFT:
            case KeyCodes.KEY_UP:
                // Do nothing
                break;

            default:
                if ((!ChatWidget.this.isTyping) && (message.length() == 0)) {
                    // Started typing a message
                    ChatWidget.this.sendChatMessage(true, null);
                }
                break;
            }
        }
    });
}

From source file:net.officefloor.demo.chat.client.ChatWidget.java

License:Open Source License

/**
 * Ensures that have user name.//from w  ww  . j  av  a 2s .  c  o  m
 */
private void ensureHaveUserName() {

    // Determine if user name already specified
    if ((this.userName != null) && (this.userName.trim().length() > 0)) {
        return; // user name specified
    }

    // No user name so obtain the user name
    final DialogBox userDialog = new DialogBox(false, true);
    HorizontalPanel userPanel = new HorizontalPanel();
    userPanel.setSpacing(10);
    userPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    userDialog.add(userPanel);
    userPanel.add(new Label("Enter name for chat"));
    final TextBox nameText = new TextBox();
    nameText.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (KeyCodes.KEY_ENTER == event.getNativeKeyCode()) {
                ChatWidget.this.enterChatName(nameText, userDialog);
            }
        }
    });
    userPanel.add(nameText);
    Button okButton = new Button("ok");
    userPanel.add(okButton);
    okButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ChatWidget.this.enterChatName(nameText, userDialog);
        }
    });
    userDialog.center();
    nameText.setFocus(true);
}

From source file:net.s17fabu.vip.gwt.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  . jav  a 2s  .c om*/
 * 
 * @param text the header text
 * @param image the {@link AbstractImagePrototype} to add next to the header
 * @return the header as a string
 */
private String getHeaderString(String text, AbstractImagePrototype image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(0);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.add(image.createImage());
    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:net.s17fabu.vip.gwt.showcase.client.Showcase.java

License:Apache License

/**
 * Create the title bar at the top of the application.
 * /*w w  w.j a  v a2 s  .c  o  m*/
 * @param constants the constant values to use
 */
private void setupTitlePanel(ShowcaseConstants constants) {
    // Get the title from the internationalized constants
    String pageTitle = "<h1>" + constants.mainTitle() + "</h1><h2>" + constants.mainSubTitle() + "</h2>";

    // Add the title and some images to the title bar
    HorizontalPanel titlePanel = new HorizontalPanel();
    titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    titlePanel.add(images.gwtLogo().createImage());
    titlePanel.add(new HTML(pageTitle));
    app.setTitleWidget(titlePanel);
}

From source file:net.scran24.admin.client.DownloadMissingFoods.java

public DownloadMissingFoods() {
    final FlowPanel contents = new FlowPanel();

    HorizontalPanel hpanel = new HorizontalPanel();

    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hpanel.setSpacing(10);//from   w w  w .  ja v a  2 s  . c  o  m

    dateFrom = new DatePicker();
    dateTo = new DatePicker();

    hpanel.add(new Label("From:"));
    hpanel.add(dateFrom);
    hpanel.add(new Label("To:"));
    hpanel.add(dateTo);

    final long day = 24 * 60 * 60 * 1000;

    final Button downloadMissingFoods = WidgetFactory.createButton("Download missing foods report",
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    long timeFrom = dateFrom.getValue().getTime();
                    long timeTo = dateTo.getValue().getTime() + day;

                    String url = GWT.getModuleBaseURL() + "../admin/downloadMissingFoods?timeFrom="
                            + Long.toString(timeFrom) + "&timeTo=" + Long.toString(timeTo);
                    Window.open(url, "_blank", "status=0,toolbar=0,menubar=0,location=0");
                }
            });

    downloadMissingFoods.getElement().addClassName("scran24-admin-button");

    downloadMissingFoods.setEnabled(false);

    dateFrom.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateTo.getValue() != null) {
                downloadMissingFoods.setEnabled(false);
            }

        }
    });

    dateTo.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateFrom.getValue() != null) {
                downloadMissingFoods.setEnabled(true);
            }
        }
    });

    contents.add(hpanel);
    contents.add(WidgetFactory.createButtonsPanel(downloadMissingFoods));

    initWidget(contents);
}

From source file:net.scran24.common.client.UiHelper.java

public static Widget createFullPageSection(Widget contents, HorizontalAlignmentConstant horizontalAlignment,
        VerticalAlignmentConstant verticalAlignment) {
    VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.addStyleName("scran24-full-page-section");

    HorizontalPanel alignPanel = new HorizontalPanel();
    alignPanel.setVerticalAlignment(verticalAlignment);
    alignPanel.setHorizontalAlignment(horizontalAlignment);
    alignPanel.setWidth("100%");
    alignPanel.setHeight("100%");

    alignPanel.add(contents);/*from   w  w w. j a  va 2s. com*/

    outerPanel.add(alignPanel);

    return outerPanel;
}