Example usage for com.vaadin.ui Panel addStyleName

List of usage examples for com.vaadin.ui Panel addStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Panel addStyleName.

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.expressui.core.view.page.DashboardPage.java

License:Open Source License

/**
 * Adds a component to the dashboard./*from  www.  j  a va 2  s. c om*/
 *
 * @param component   component to add
 * @param caption     caption to display above component
 * @param startRow    start row coordinate in Dashboard grid
 * @param startColumn start column coordinate in Dashboard grid
 * @param endRow      end row coordinate in Dashboard grid
 * @param endColumn   end column coordinate in Dashboard grid
 */
public void addComponent(Component component, String caption, int startRow, int startColumn, int endRow,
        int endColumn) {
    if (component instanceof TypedComponent && !((TypedComponent) component).isViewAllowed())
        return;

    Panel panel = new Panel(caption);
    panel.addStyleName(ChameleonTheme.PANEL_BUBBLE);
    HorizontalLayout panelLayout = new HorizontalLayout();
    panelLayout.setSizeUndefined();
    panel.setSizeUndefined();

    setWidthAndHeightIfNotNull(component);

    panel.setContent(panelLayout);
    panelLayout.setMargin(true);
    panelLayout.setSpacing(true);
    panelLayout.addComponent(component);
    int rows = Math.max(rootLayout.getRows() - 1, endRow);
    int columns = Math.max(rootLayout.getColumns() - 1, endColumn);

    if (rootLayout.getRows() < rows) {
        rootLayout.setRows(rows);
    }
    if (rootLayout.getColumns() < columns) {
        rootLayout.setColumns(columns);
    }

    removeComponent(startRow, startColumn);
    rootLayout.addComponent(panel, startColumn - 1, startRow - 1, endColumn - 1, endRow - 1);
}

From source file:com.expressui.sample.view.LoginPage.java

License:Open Source License

@PostConstruct
@Override/*from ww w .j  a va2  s.  c  o  m*/
public void postConstruct() {
    super.postConstruct();

    setSizeFull();

    LoginForm loginForm = new LoginForm();
    loginForm.addStyleName("border");
    loginForm.setSizeUndefined();
    loginForm.setLoginButtonCaption(uiMessageSource.getMessage("loginPage.button"));
    loginForm.setUsernameCaption(uiMessageSource.getMessage("loginPage.username"));
    loginForm.setPasswordCaption(uiMessageSource.getMessage("loginPage.password"));
    loginForm.addListener(new LoginHandler());

    Panel panel = new Panel();
    panel.addStyleName("loginPage");
    panel.addStyleName("border");
    panel.setSizeUndefined();
    panel.setCaption(uiMessageSource.getMessage("loginPage.caption"));
    panel.addComponent(loginForm);
    panel.addComponent(new Label(uiMessageSource.getMessage("loginPage.tip")));

    addComponent(panel);
    setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
}

From source file:com.github.tempora.view.MainView.java

License:Apache License

public MainView() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.addStyleName("outlined");
    vlayout.addStyleName("bg");
    vlayout.setSizeFull();/* w ww.  ja  v  a 2  s.  com*/
    vlayout.setMargin(true);
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.addStyleName("outlined");
    hlayout.setSizeFull();
    setContent(vlayout);

    // Title
    Label caption = new Label("Tempora");
    caption.setStyleName("logo-label", true);
    caption.setWidth(null);
    vlayout.addComponent(caption);
    vlayout.setExpandRatio(caption, 0.2f);

    vlayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    vlayout.addComponent(hlayout);
    vlayout.setExpandRatio(hlayout, 0.7f);

    //
    // General information about the User's mailbox
    //
    final Panel generalInfoPanel = new Panel("<center>General Information</center>");
    generalInfoPanel.addStyleName("frame-bg-general-info");
    generalInfoPanel.setSizeFull();

    this.currentHistoryId = new Label("0");
    currentHistoryId.setStyleName("general-info-count", true);
    currentHistoryId.setCaption("History ID");

    this.messagesTotal = new Label("0");
    messagesTotal.setStyleName("general-info-count", true);
    messagesTotal.setCaption("Messages Total");

    this.threadsTotal = new Label("0");
    threadsTotal.setCaption("Threads Total");
    threadsTotal.setStyleName("general-info-count", true);

    FormLayout mailboxInfoLayout = new FormLayout(messagesTotal, currentHistoryId, threadsTotal);
    VerticalLayout mailboxInfoMainLayout = new VerticalLayout(mailboxInfoLayout);
    mailboxInfoMainLayout.setSizeFull();
    mailboxInfoMainLayout.setMargin(true);
    generalInfoPanel.setContent(mailboxInfoMainLayout);

    //
    // Stats
    //
    final Panel statsPanel = new Panel("<center>Statistics</center>");
    statsPanel.addStyleName("frame-bg-stats");
    statsPanel.setSizeFull();

    this.bodyAvgSize = new Label("0");
    bodyAvgSize.setCaption("Body Avg. Size");
    bodyAvgSize.setStyleName("stats-count", true);

    FormLayout statsLayout = new FormLayout(bodyAvgSize);
    VerticalLayout statsMainLayout = new VerticalLayout(statsLayout);
    statsMainLayout.setSizeFull();
    statsMainLayout.setMargin(true);
    statsPanel.setContent(statsMainLayout);

    //
    // Top 5
    //
    Panel top5Panel = new Panel("<center>Top 5</center>");
    top5Panel.addStyleName("frame-bg-top5");

    // Top 5 Senders
    Panel top5SendersPanel = new Panel("<center>Senders</center>");
    top5SendersPanel.addStyleName("frame-bg-top5");
    top5SendersPanel.setSizeFull();
    this.top5Senders = new Label("NO DATA", ContentMode.PREFORMATTED);
    top5Senders.setSizeUndefined();
    top5SendersPanel.setContent(top5Senders);

    // Top 5 Title Tags
    Panel top5TitleTagsPanel = new Panel("<center>Title Tags</center>");
    top5TitleTagsPanel.addStyleName("frame-bg-top5");
    top5TitleTagsPanel.setSizeFull();
    this.top5TitleTags = new Label("NO DATA", ContentMode.PREFORMATTED);
    top5TitleTags.setSizeUndefined();
    top5TitleTagsPanel.setContent(top5TitleTags);

    top5Panel.setSizeFull();

    VerticalLayout top5MainLayout = new VerticalLayout(top5SendersPanel, top5TitleTagsPanel);
    top5MainLayout.setMargin(true);
    top5MainLayout.setSpacing(true);
    top5MainLayout.setSizeFull();
    top5MainLayout.setComponentAlignment(top5SendersPanel, Alignment.MIDDLE_CENTER);
    top5MainLayout.setComponentAlignment(top5TitleTagsPanel, Alignment.MIDDLE_CENTER);
    top5Panel.setContent(top5MainLayout);

    hlayout.setSpacing(true);
    hlayout.addComponent(generalInfoPanel);
    hlayout.addComponent(statsPanel);
    hlayout.addComponent(top5Panel);

    this.currentUserEmail = new Label("-");
    currentUserEmail.setCaption("Email");

    Button reloadButton = new Button("\u27F3 Reload");
    reloadButton.addClickListener(e -> {
        getSession().getSession().invalidate();
        getUI().getPage().reload();
    });

    HorizontalLayout infoHLayout = new HorizontalLayout();
    infoHLayout.addStyleName("outlined");
    infoHLayout.setSizeFull();
    infoHLayout.setSpacing(true);
    infoHLayout.setMargin(true);

    infoHLayout.addComponent(reloadButton);
    reloadButton.setWidth(null);
    infoHLayout.setComponentAlignment(reloadButton, Alignment.BOTTOM_LEFT);

    infoHLayout.addComponent(currentUserEmail);
    currentUserEmail.setWidth(null);
    infoHLayout.setComponentAlignment(currentUserEmail, Alignment.BOTTOM_RIGHT);

    vlayout.addComponent(infoHLayout);
    vlayout.setExpandRatio(infoHLayout, 0.5f);
}

From source file:com.klwork.explorer.ui.task.ProcessInstanceEventsPanel.java

License:Apache License

public void initAddEventInput(HorizontalLayout hLayout) {
    Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be
    // attached to panels or windows
    textFieldPanel.addStyleName(Reindeer.PANEL_LIGHT);
    VerticalLayout textFieldPanelLayout = new VerticalLayout();
    textFieldPanel.setContent(textFieldPanelLayout);

    textFieldPanel.setWidth(100, Unit.PERCENTAGE);
    hLayout.addComponent(textFieldPanel);
    hLayout.setExpandRatio(textFieldPanel, 1.0f);

    commentInputField = new TextField();
    commentInputField.setWidth(100, Unit.PERCENTAGE);
    textFieldPanelLayout.addComponent(commentInputField);

    // Hack to catch keyboard 'enter'
    textFieldPanel.addActionHandler(new Handler() {
        public void handleAction(Action action, Object sender, Object target) {
            addNewComment(commentInputField.getValue().toString());
        }//ww w.ja v a2  s.  c om

        public Action[] getActions(Object target, Object sender) {
            return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) };
        }
    });
}

From source file:com.klwork.explorer.ui.task.TaskEventsPanel.java

License:Apache License

public void initAddEventInput(HorizontalLayout hLayout) {
    Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be attached to panels or windows
    textFieldPanel.addStyleName(Reindeer.PANEL_LIGHT);
    VerticalLayout textFieldPanelLayout = new VerticalLayout();
    textFieldPanel.setContent(textFieldPanelLayout);

    textFieldPanel.setWidth(100, Unit.PERCENTAGE);
    hLayout.addComponent(textFieldPanel);
    hLayout.setExpandRatio(textFieldPanel, 1.0f);

    commentInputField = new TextField();
    commentInputField.setWidth(100, Unit.PERCENTAGE);
    textFieldPanelLayout.addComponent(commentInputField);

    // Hack to catch keyboard 'enter'
    textFieldPanel.addActionHandler(new Handler() {
        public void handleAction(Action action, Object sender, Object target) {
            addNewComment(commentInputField.getValue().toString());
        }/*from  ww w  . j  av a2  s. co m*/

        public Action[] getActions(Object target, Object sender) {
            return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) };
        }
    });
}

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initInformationPanel() {
    Panel infoPanel = new Panel();
    infoPanel.addStyleName(Reindeer.PANEL_LIGHT);
    infoPanel.setSizeFull();//from   w  w w .jav a2s.  c  o  m

    profilePanelLayout.addComponent(infoPanel);
    profilePanelLayout.setExpandRatio(infoPanel, 1.0f); // info panel should take all the remaining width available

    // All the information sections are put under each other in a vertical layout
    this.infoPanelLayout = new VerticalLayout();
    infoPanel.setContent(infoPanelLayout);
    //
    initAboutSection();
    //?
    initContactSection();

}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.DayWidget.java

public DayWidget() {

    //Creating Panel
    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setWidth("876px");
    iPanel.setHeight("41px");

    ProgressBar iDayProgressBar = new ProgressBar();
    iDayProgressBar.setCaption("Period 3, 10th October");
    iDayProgressBar.setWidth("875px");
    iDayProgressBar.setValue(0.3f);/*ww  w.j  av a  2 s.co m*/
    addComponent(iDayProgressBar);

    //Adding Panel to Vertical Layout
    addComponent(iPanel);
    VerticalLayout iVerticalLayout = new VerticalLayout();

    GridLayout iGridLayout = new GridLayout(9, 1);
    iGridLayout.setWidth("1000px");
    iGridLayout.setHeight("40px");

    for (int i = 1; i <= 8; i++) {

        HourWidget iHourAtAGlanceWidget = new HourWidget(i, 8);
        iHourAtAGlanceWidget.setSizeFull();
        iGridLayout.addComponent(iHourAtAGlanceWidget);
        iGridLayout.setColumnExpandRatio(i, 1);
    }

    iVerticalLayout.addComponent(iGridLayout);
    iPanel.setContent(iVerticalLayout);

}

From source file:com.logicbomb.newschool.MyAppWidgetSet.LoginWidget.java

public LoginWidget() {
    setMargin(true);/*from w  w w  .ja va2  s .co  m*/
    setSpacing(true);

    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setSizeUndefined();

    addComponent(iPanel);

    TextField iTextField = new TextField("Username");
    iTextField.setWidth("300px");
    iTextField.setRequired(true);
    iTextField.setInputPrompt("Your username (eg. joe@email.com)");
    iTextField.setIcon(FontAwesome.USER);
    iTextField.addValidator(new EmailValidator("Username must be an email address"));
    iTextField.setInvalidAllowed(true);
    iTextField.focus();

    PasswordField iPasswordField = new PasswordField("Password");
    iPasswordField.setIcon(FontAwesome.KEY);
    iPasswordField.setWidth("300px");
    iPasswordField.setRequired(true);
    iPasswordField.setValue("");
    iPasswordField.setNullRepresentation("");

    Button iButton = new Button("Login");
    iButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label("Login Successfully"));
        }
    });

    FormLayout iFormLayout = new FormLayout();
    iFormLayout.setSpacing(true);
    iFormLayout.setMargin(true);
    iFormLayout.addComponent(iTextField);
    iFormLayout.addComponent(iPasswordField);
    iFormLayout.addComponent(iButton);
    iPanel.setContent(iFormLayout);

}

From source file:com.lst.deploymentautomation.vaadin.core.AppFormConnector.java

License:Open Source License

@Override
public void setContent(Component content) {
    if (content == null) {
        //rendering failed; show a sad face to show how sorry we are
        VerticalLayout layout = new VerticalLayout();
        Label fail = new Label(":-(");
        fail.addStyleName("screen-failed-to-render");
        layout.addComponent(fail);/*  w  w w .  j  a  v a  2  s.  com*/
        layout.setExpandRatio(fail, 1);
        layout.setComponentAlignment(fail, Alignment.MIDDLE_LEFT);
        layout.setSizeFull();

        view.setContent(layout);

    } else {
        //if the component has either natural or absolute size, wrap it
        //in a scrollable panel with full size and nice margin
        if (content.getHeightUnits() != Unit.PERCENTAGE) {
            final Panel panel = new Panel();
            panel.addStyleName("l-border-none");
            panel.setContent(content);
            panel.setSizeFull();
            content = panel;
        }

        view.setContent(content);
    }
}

From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    LspsUI ui = (LspsUI) getUI();/*from w w  w .ja  va 2 s.com*/
    Person user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection(ui, user);
    layout.addComponent(substitution);

    Label spacer2 = new Label();
    spacer2.setHeight("10px");
    layout.addComponent(spacer2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}