Example usage for com.vaadin.ui HorizontalLayout addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:org.jumpmind.metl.ui.views.deploy.EditAgentPanel.java

License:Open Source License

public EditAgentPanel(ApplicationContext context, TabbedPanel tabbedPanel, Agent agent) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;
    this.agent = agent;
    this.backgroundRefresherService = context.getBackgroundRefresherService();

    HorizontalLayout editAgentLayout = new HorizontalLayout();
    editAgentLayout.setSpacing(true);/*from  w w w .  j a v a  2 s. co m*/
    editAgentLayout.setMargin(new MarginInfo(true, false, false, true));
    editAgentLayout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(editAgentLayout);

    final ComboBox startModeCombo = new ComboBox("Start Mode");
    startModeCombo.setImmediate(true);
    startModeCombo.setNullSelectionAllowed(false);
    AgentStartMode[] modes = AgentStartMode.values();
    for (AgentStartMode agentStartMode : modes) {
        startModeCombo.addItem(agentStartMode.name());
    }
    startModeCombo.setValue(agent.getStartMode());
    startModeCombo.addValueChangeListener(event -> {
        agent.setStartMode((String) startModeCombo.getValue());
        context.getConfigurationService().save((AbstractObject) EditAgentPanel.this.agent);
    });

    editAgentLayout.addComponent(startModeCombo);
    editAgentLayout.setComponentAlignment(startModeCombo, Alignment.BOTTOM_LEFT);

    Button parameterButton = new Button("Parameters");
    parameterButton.addClickListener(new ParameterClickListener());
    editAgentLayout.addComponent(parameterButton);
    editAgentLayout.setComponentAlignment(parameterButton, Alignment.BOTTOM_LEFT);

    HorizontalLayout buttonGroup = new HorizontalLayout();

    final TextField hostNameField = new TextField("Hostname");
    hostNameField.setImmediate(true);
    hostNameField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    hostNameField.setTextChangeTimeout(100);
    hostNameField.setWidth(20, Unit.EM);
    hostNameField.setNullRepresentation("");
    hostNameField.setValue(agent.getHost());
    hostNameField.addValueChangeListener(event -> {
        agent.setHost((String) hostNameField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });

    buttonGroup.addComponent(hostNameField);
    buttonGroup.setComponentAlignment(hostNameField, Alignment.BOTTOM_LEFT);

    Button getHostNameButton = new Button("Get Host");
    getHostNameButton.addClickListener(event -> hostNameField.setValue(AppUtils.getHostName()));
    buttonGroup.addComponent(getHostNameButton);
    buttonGroup.setComponentAlignment(getHostNameButton, Alignment.BOTTOM_LEFT);

    editAgentLayout.addComponent(buttonGroup);
    editAgentLayout.setComponentAlignment(buttonGroup, Alignment.BOTTOM_LEFT);

    Button exportButton = new Button("Export Agent Config", event -> exportConfiguration());
    editAgentLayout.addComponent(exportButton);
    editAgentLayout.setComponentAlignment(exportButton, Alignment.BOTTOM_LEFT);

    CheckBox autoRefresh = new CheckBox("Auto Refresh", Boolean.valueOf(agent.isAutoRefresh()));
    autoRefresh.setImmediate(true);
    autoRefresh.addValueChangeListener(event -> {
        agent.setAutoRefresh(autoRefresh.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(autoRefresh);
    editAgentLayout.setComponentAlignment(autoRefresh, Alignment.BOTTOM_LEFT);

    CheckBox allowTestFlowsField = new CheckBox("Allow Test Flows", Boolean.valueOf(agent.isAllowTestFlows()));
    allowTestFlowsField.setImmediate(true);
    allowTestFlowsField.addValueChangeListener(event -> {
        agent.setAllowTestFlows(allowTestFlowsField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(allowTestFlowsField);
    editAgentLayout.setComponentAlignment(allowTestFlowsField, Alignment.BOTTOM_LEFT);

    ButtonBar buttonBar = new ButtonBar();
    addComponent(buttonBar);

    addDeploymentButton = buttonBar.addButton("Add Deployment", Icons.DEPLOYMENT);
    addDeploymentButton.addClickListener(new AddDeploymentClickListener());

    editButton = buttonBar.addButton("Edit", FontAwesome.EDIT);
    editButton.addClickListener(event -> editClicked());

    enableButton = buttonBar.addButton("Enable", FontAwesome.CHAIN);
    enableButton.addClickListener(event -> enableClicked());

    disableButton = buttonBar.addButton("Disable", FontAwesome.CHAIN_BROKEN);
    disableButton.addClickListener(event -> disableClicked());

    removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O);
    removeButton.addClickListener(event -> removeClicked());

    runButton = buttonBar.addButton("Run", Icons.RUN);
    runButton.addClickListener(event -> runClicked());

    container = new BeanItemContainer<AgentDeploymentSummary>(AgentDeploymentSummary.class);
    container.setItemSorter(new TableItemSorter());

    table = new Table();
    table.setSizeFull();
    table.setCacheRate(100);
    table.setPageLength(100);
    table.setImmediate(true);
    table.setSelectable(true);
    table.setMultiSelect(true);

    table.setContainerDataSource(container);
    table.setVisibleColumns("name", "projectName", "type", "status", "logLevel", "startType",
            "startExpression");
    table.setColumnHeaders("Deployment", "Project", "Type", "Status", "Log Level", "Start Type",
            "Start Expression");
    table.addGeneratedColumn("status", new StatusRenderer());
    table.addItemClickListener(new TableItemClickListener());
    table.addValueChangeListener(new TableValueChangeListener());
    table.setSortContainerPropertyId("type");
    table.setSortAscending(true);

    addComponent(table);
    setExpandRatio(table, 1.0f);
    refresh();
    setButtonsEnabled();
    backgroundRefresherService.register(this);
}

From source file:org.jumpmind.vaadin.ui.common.NotifyDialog.java

License:Open Source License

public NotifyDialog(String caption, String text, final Throwable ex, Type type) {
    super(caption);
    setWidth(400, Unit.PIXELS);/*from   w ww . j  a va 2s .  c  o  m*/
    setHeight(300, Unit.PIXELS);

    final HorizontalLayout messageArea = new HorizontalLayout();
    messageArea.addStyleName("v-scrollable");
    messageArea.setMargin(true);
    messageArea.setSpacing(true);
    messageArea.setSizeFull();

    text = isNotBlank(text) ? text : (ex != null ? ex.getMessage() : "");
    if (type == Type.ERROR_MESSAGE) {
        setIcon(FontAwesome.BAN);
    }

    final String message = text;

    final Label textLabel = new Label(message, ContentMode.HTML);
    messageArea.addComponent(textLabel);
    messageArea.setExpandRatio(textLabel, 1);

    content.addComponent(messageArea);
    content.setExpandRatio(messageArea, 1);

    final Button detailsButton = new Button("Details");
    detailsButton.setVisible(ex != null);
    detailsButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            detailsMode = !detailsMode;
            if (detailsMode) {
                String msg = "<pre>" + ExceptionUtils.getStackTrace(ex).trim() + "</pre>";
                msg = msg.replace("\t", "    ");
                textLabel.setValue(msg);
                detailsButton.setCaption("Message");
                messageArea.setMargin(new MarginInfo(false, false, false, true));
                setHeight(600, Unit.PIXELS);
                setWidth(1000, Unit.PIXELS);
                setPosition(getPositionX() - 300, getPositionY() - 150);
            } else {
                textLabel.setValue(message);
                detailsButton.setCaption("Details");
                messageArea.setMargin(true);
                setWidth(400, Unit.PIXELS);
                setHeight(300, Unit.PIXELS);
                setPosition(getPositionX() + 300, getPositionY() + 150);
            }
        }
    });

    content.addComponent(buildButtonFooter(detailsButton, buildCloseButton()));

}

From source file:org.jumpmind.vaadin.ui.common.PromptDialog.java

License:Open Source License

public PromptDialog(String caption, String text, String defaultValue, final IPromptListener promptListener) {
    setCaption(caption);//from  w w w  . jav  a 2  s .  com
    setModal(true);
    setResizable(false);
    setSizeUndefined();
    setClosable(false);

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

    if (isNotBlank(text)) {
        layout.addComponent(new Label(text));
    }

    final TextField field = new TextField();
    field.setWidth(100, Unit.PERCENTAGE);
    field.setNullRepresentation("");
    field.setValue(defaultValue);
    if (defaultValue != null) {
        field.setSelectionRange(0, defaultValue.length());
    }
    layout.addComponent(field);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(100, Unit.PERCENTAGE);

    Label spacer = new Label(" ");
    buttonLayout.addComponent(spacer);
    buttonLayout.setExpandRatio(spacer, 1);

    Button cancelButton = new Button("Cancel");
    cancelButton.setClickShortcut(KeyCode.ESCAPE);
    cancelButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(PromptDialog.this);
        }
    });
    buttonLayout.addComponent(cancelButton);

    Button okButton = new Button("Ok");
    okButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    okButton.setClickShortcut(KeyCode.ENTER);
    okButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (promptListener.onOk(field.getValue())) {
                UI.getCurrent().removeWindow(PromptDialog.this);
            }
        }
    });
    buttonLayout.addComponent(okButton);

    layout.addComponent(buttonLayout);

    field.focus();

}

From source file:org.jumpmind.vaadin.ui.common.ResizableWindow.java

License:Open Source License

protected HorizontalLayout buildButtonFooter(Button[] toTheLeftButtons, Button... toTheRightButtons) {
    HorizontalLayout footer = new HorizontalLayout();

    footer.setWidth("100%");
    footer.setSpacing(true);//from  w w w  . j  a  v a  2s. c o m
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    if (toTheLeftButtons != null) {
        footer.addComponents(toTheLeftButtons);
    }

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    footer.addComponents(footerText);
    footer.setExpandRatio(footerText, 1);

    if (toTheRightButtons != null) {
        footer.addComponents(toTheRightButtons);
    }

    return footer;
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java

License:Open Source License

public QueryPanel(IDb db, ISettingsProvider settingsProvider, IButtonBar buttonBar, String user) {
    this.settingsProvider = settingsProvider;
    this.db = db;
    this.user = user;
    this.buttonBar = buttonBar;
    this.sqlArea = buildSqlEditor();
    this.shortCutListeners.add(createExecuteSqlShortcutListener());

    VerticalLayout resultsLayout = new VerticalLayout();
    resultsLayout.setSizeFull();//from  ww  w  .j a v  a2s  . c o m

    resultsTabs = CommonUiUtils.createTabSheet();
    resultStatuses = new HashMap<Component, String>();

    HorizontalLayout statusBar = new HorizontalLayout();
    statusBar.addStyleName(ValoTheme.PANEL_WELL);
    statusBar.setMargin(new MarginInfo(true, true, true, true));
    statusBar.setWidth(100, Unit.PERCENTAGE);

    status = new Label("No Results");
    statusBar.addComponent(status);

    setSelectedTabChangeListener();

    resultsLayout.addComponents(resultsTabs, statusBar);
    resultsLayout.setExpandRatio(resultsTabs, 1);

    addComponents(sqlArea, resultsLayout);

    setSplitPosition(400, Unit.PIXELS);

    emptyResults = new VerticalLayout();
    emptyResults.setSizeFull();
    Label label = new Label("New results will appear here");
    label.setWidthUndefined();
    emptyResults.addComponent(label);
    emptyResults.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    resultStatuses.put(emptyResults, "No Results");

    if (!settingsProvider.get().getProperties().is(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS)) {
        createGeneralResultsTab();
    }
}

From source file:org.lucidj.browser.BrowserView.java

License:Apache License

private void build_view() {
    setMargin(new MarginInfo(true, false, true, false));

    build_toolbar();//  w  ww  .ja  v a 2s. c  om
    build_sidebar();

    insert_here_cell = new Cell(null);

    // TODO: THIS BLOCK IS ACTUALLY A FILE HEADER OBJECT
    //+++
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, Unit.PERCENTAGE);
    {
        CssLayout left_panel = new CssLayout();
        left_panel.setWidth(40, Unit.PIXELS);
        header.addComponent(left_panel);

        final HorizontalLayout caption = new HorizontalLayout();
        caption.setSpacing(true);
        caption.addStyleName("formula-header");
        caption.setWidth(100, Unit.PERCENTAGE);
        {
            //caption.addComponent (get_icon ("freepik-saturn.png"));

            VerticalLayout title_area = new VerticalLayout();
            {
                final TextField title = new TextField();
                title.setWidth(100, Unit.PERCENTAGE);
                title.setValue("Default");

                //                    final ShortcutListener handle_enter = new ShortcutListener
                //                        ("EnterShortcut", ShortcutAction.KeyCode.ENTER, null)
                //                    {
                //                        @Override
                //                        public void handleAction (Object o, Object o1)
                //                        {
                //                            Notification.show ("New title: " + title.getValue());
                //                            unfocus (title);
                //
                //                        }
                //                    };
                //
                //                    title.addFocusListener (new FieldEvents.FocusListener ()
                //                    {
                //                        @Override
                //                        public void focus (FieldEvents.FocusEvent focusEvent)
                //                        {
                //                            title.addShortcutListener (handle_enter);
                //                        }
                //                    });
                //
                //                    title.addBlurListener (new FieldEvents.BlurListener ()
                //                    {
                //                        @Override
                //                        public void blur (FieldEvents.BlurEvent blurEvent)
                //                        {
                //                            title.removeShortcutListener (handle_enter);
                //                        }
                //                    });
                title_area.addComponent(title);
            }

            caption.addComponent(title_area);
            caption.setExpandRatio(title_area, 1.0f);
        }
        header.addComponent(caption);

        CssLayout right_panel = new CssLayout();
        right_panel.setWidth(36, Unit.PIXELS);
        header.addComponent(right_panel);
        header.setExpandRatio(caption, 1.0f);
    }
    addComponent(header);
    //---

    content = new VerticalLayout();
    content.addStyleName("formula-cells");
    addComponent(content);

    synchronize_cell_view();

    // Set focus to first available object
    update_cell_focus(null, true);
}

From source file:org.lucidj.vaadinui.Login.java

License:Apache License

@Override // LoginForm
protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) {
    // Save the predefined components
    this.userNameField = userNameField;
    this.passwordField = passwordField;
    this.loginButton = loginButton;

    // Make LoginForm container full-screen
    setSizeFull();//w ww  .j  a v  a 2s  . c  o  m

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.addStyleName("login-wallpaper");

    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();
    loginPanel.setMargin(true);
    loginPanel.setSpacing(true);
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("card");

    //--------
    // HEADER
    //--------

    final HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");

    final Label title = new Label("<h3><strong>LucidJ</strong> Console</h3>", ContentMode.HTML);
    labels.addComponent(title);
    labels.setExpandRatio(title, 1);

    loginPanel.addComponent(labels);

    //--------
    // FIELDS
    //--------

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    userNameField.setImmediate(true);
    userNameField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    final ShortcutListener username_enter_listener = new ShortcutListener("Next field (Tab)",
            ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object o, Object o1) {
            passwordField.setValue("");
            passwordField.focus();
        }
    };
    userNameField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
            show_default_message();

            int new_username_length = textChangeEvent.getText().length();

            // Check for autofill
            if (userNameField.isEmpty() && new_username_length > 1 && !userNameField_filling) {
                // This is autofill
                userNameField.removeShortcutListener(username_enter_listener);
                userNameField.setCursorPosition(new_username_length);
                userNameField.setSelectionRange(0, new_username_length);
            } else {
                userNameField_filling = true;
                passwordField.setValue("");
                userNameField.addShortcutListener(username_enter_listener);
            }
        }
    });
    userNameField.addFocusListener(new FieldEvents.FocusListener() {
        @Override
        public void focus(FieldEvents.FocusEvent focusEvent) {
            // Cursor on username, Enter jump to password
            loginButton.removeClickShortcut();
            userNameField.addShortcutListener(username_enter_listener);
        }
    });
    userNameField.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent blurEvent) {
            // Cursor on password or elsewhere, enter submits
            userNameField.removeShortcutListener(username_enter_listener);
            loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        }
    });

    passwordField.setImmediate(true);
    passwordField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    passwordField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
            show_default_message();
        }
    });

    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setDisableOnClick(true);

    fields.addComponents(userNameField, passwordField, loginButton);
    fields.setComponentAlignment(loginButton, Alignment.BOTTOM_LEFT);

    loginPanel.addComponent(fields);

    //--------
    // FOOTER
    //--------

    loginPanel.addComponent(new CheckBox("Remember me", true));

    loginPanel.addComponent(message_label);
    show_default_message();

    layout.addComponent(loginPanel);
    layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    return (layout);
}

From source file:org.lunifera.runtime.web.vaadin.components.fields.BeanReferenceField.java

License:Open Source License

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//from   w w  w . j  a v a 2 s . c om
protected Component initContent() {

    HorizontalLayout root = new HorizontalLayout();
    root.addStyleName("l-beansearchfield");
    comboBox = new CustomComboBox();
    comboBox.setImmediate(true);
    comboBox.setNullSelectionAllowed(false);
    comboBox.setInvalidAllowed(false);

    BeanServiceLazyLoadingContainer container = new BeanServiceLazyLoadingContainer(searchService, type,
            sharedState);
    // add the passed container filter
    if (filter != null) {
        container.addContainerFilter(filter);
    }
    comboBox.setContainerDataSource(container);
    comboBox.setFilteringMode(FilteringMode.CONTAINS);

    if (itemCaptionPropertyId != null) {
        comboBox.setItemCaptionPropertyId(itemCaptionPropertyId);
    }

    if (itemIconPropertyId != null) {
        comboBox.setItemIconPropertyId(itemIconPropertyId);
    }

    NativeButton searchButton = new NativeButton();
    searchButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            openSearchDialog();
        }
    });
    searchButton.setWidth("26px");
    searchButton.setIcon(new ThemeResource("icons/SearchButton.png"));

    root.addComponent(comboBox);
    root.addComponent(searchButton);

    // Create the property
    comboBox.setPropertyDataSource(property);

    // Create the bindings
    // valueBinding =
    // dbc.bindValue(VaadinObservables.observeValue(comboBox),
    // PojoObservables.observeValue(property, "value"));

    return root;
}

From source file:org.milleni.dunning.ui.customer.CustomerListDetailPanel.java

License:Apache License

protected void initInstances() {
    HorizontalLayout instancesHeader = new HorizontalLayout();
    instancesHeader.setSpacing(true);//from  w  w w . ja  v  a2  s.  co  m
    instancesHeader.setWidth(100, UNITS_PERCENTAGE);
    instancesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    // addDetailComponent(instancesHeader);
    initInstancesTitle(instancesHeader);

    instancesLayout = new HorizontalLayout();
    instancesLayout.setWidth(100, UNITS_PERCENTAGE);
    addDetailComponent(instancesLayout);
    initInstancesTable();
}

From source file:org.milleni.dunning.ui.prcstart.BulkDunningProcessFinishPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);/*from w  w  w .java2  s.  co m*/
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded databaseImage = new Embedded(null, Images.DATABASE_50);
    layout.addComponent(databaseImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.MAIN_MENU_DUNNING_PROCESS_BITIR));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}