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:com.rex.components.valo.Trees.java

License:Apache License

public Trees() {
    setMargin(true);//ww w . j  a v a  2 s  . com

    Label h1 = new Label("Trees");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Tree tree = new Tree();
    tree.setSelectable(true);
    tree.setMultiSelect(true);
    Container generateContainer = ReportEngineUI.generateContainer(10, true);
    tree.setContainerDataSource(generateContainer);
    tree.setDragMode(TreeDragMode.NODE);
    row.addComponent(tree);
    tree.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    tree.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    tree.expandItem(generateContainer.getItemIds().iterator().next());

    tree.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });

    // Add actions (context menu)
    tree.addActionHandler(ReportEngineUI.getActionHandler());
}

From source file:com.save.employee.request.ViewRLWindow.java

FormLayout buildFormLayout() {
    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);/*from w  w w  .  j  av a 2  s .com*/

    LiquidationForm lf = rls.getRLById(getRequestId());

    controlNo = new TextField("Control No.");
    controlNo.setWidth("100%");
    controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    controlNo.setValue(String.valueOf(lf.getControlNo()));
    controlNo.setEnabled(false);
    f.addComponent(controlNo);

    dateOfActivity = new DateField("Date of Activity: ");
    dateOfActivity.setWidth("100%");
    dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
    dateOfActivity.setValue(lf.getDateOfActivity());
    dateOfActivity.setEnabled(false);
    f.addComponent(dateOfActivity);

    area = CommonComboBox.areas();
    area.setWidth("100%");
    area.setValue(lf.getAreaId());
    area.setEnabled(false);
    f.addComponent(area);

    activity = new TextField("Activity: ");
    activity.setWidth("100%");
    activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    activity.setValue(lf.getActivity());
    activity.setEnabled(false);
    f.addComponent(activity);

    venue = new TextField("Venue: ");
    venue.setWidth("100%");
    venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    venue.setValue(lf.getVenue());
    venue.setEnabled(false);
    f.addComponent(venue);

    requirements = new TextArea("Requirements: ");
    requirements.setWidth("100%");
    requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
    requirements.setValue(lf.getRequirements());
    requirements.setEnabled(false);
    f.addComponent(requirements);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");
    h1.setCaption("Request Lodging");
    h1.addStyleName("light");
    //        h1.setReadOnly(true);

    requestLodgingPax = new TextField();
    requestLodgingPax.setWidth("100%");
    requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingPax.addStyleName("align-right");
    requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax()));
    requestLodgingPax.setEnabled(false);
    h1.addComponent(requestLodgingPax);

    requestLodgingBudget = new TextField();
    requestLodgingBudget.setWidth("100%");
    requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingBudget.addStyleName("align-right");
    requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget()));
    requestLodgingBudget.setEnabled(false);
    h1.addComponent(requestLodgingBudget);

    requestLodgingAmount = new TextField();
    requestLodgingAmount.setWidth("100%");
    requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingAmount.addStyleName("align-right");
    requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount()));
    requestLodgingAmount.setEnabled(false);
    h1.addComponent(requestLodgingAmount);

    f.addComponent(h1);
    f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setWidth("100%");
    h2.setCaption("Request Meals");
    //        h2.setReadOnly(true);

    requestMealsPax = new TextField();
    requestMealsPax.setWidth("100%");
    requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsPax.addStyleName("align-right");
    requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax()));
    requestMealsPax.setEnabled(false);
    h2.addComponent(requestMealsPax);

    requestMealsBudget = new TextField();
    requestMealsBudget.setWidth("100%");
    requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsBudget.addStyleName("align-right");
    requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget()));
    requestMealsBudget.setEnabled(false);
    h2.addComponent(requestMealsBudget);

    requestMealsAmount = new TextField();
    requestMealsAmount.setWidth("100%");
    requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsAmount.addStyleName("align-right");
    requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount()));
    requestMealsAmount.setEnabled(false);
    h2.addComponent(requestMealsAmount);

    f.addComponent(h2);
    f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT);

    HorizontalLayout h3 = new HorizontalLayout();
    h3.setWidth("100%");
    h3.setCaption("Liquidated Lodging");
    //        h3.setReadOnly(true);

    liquidateLodgingPax = new TextField();
    liquidateLodgingPax.setWidth("100%");
    liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingPax.addStyleName("align-right");
    liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax()));
    liquidateLodgingPax.setEnabled(false);
    h3.addComponent(liquidateLodgingPax);

    liquidateLodgingBudget = new TextField();
    liquidateLodgingBudget.setWidth("100%");
    liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingBudget.addStyleName("align-right");
    liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget()));
    liquidateLodgingBudget.setEnabled(false);
    h3.addComponent(liquidateLodgingBudget);

    liquidateLodgingAmount = new TextField();
    liquidateLodgingAmount.setWidth("100%");
    liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingAmount.addStyleName("align-right");
    liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount()));
    liquidateLodgingAmount.setEnabled(false);
    h3.addComponent(liquidateLodgingAmount);

    f.addComponent(h3);
    f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT);

    HorizontalLayout h4 = new HorizontalLayout();
    h4.setWidth("100%");
    h4.setCaption("Liquidated Meals");
    h4.setReadOnly(true);

    liquidateMealsPax = new TextField();
    liquidateMealsPax.setWidth("100%");
    liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsPax.addStyleName("align-right");
    liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax()));
    liquidateMealsPax.setEnabled(false);
    h4.addComponent(liquidateMealsPax);

    liquidateMealsBudget = new TextField();
    liquidateMealsBudget.setWidth("100%");
    liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsBudget.addStyleName("align-right");
    liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget()));
    liquidateMealsBudget.setEnabled(false);
    h4.addComponent(liquidateMealsBudget);

    liquidateMealsAmount = new TextField();
    liquidateMealsAmount.setWidth("100%");
    liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsAmount.addStyleName("align-right");
    liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount()));
    liquidateMealsAmount.setEnabled(false);
    h4.addComponent(liquidateMealsAmount);

    f.addComponent(h4);
    f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT);

    reimbursement = new TextField("Reimbursement: ");
    reimbursement.setWidth("50%");
    reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    reimbursement.setValue(String.valueOf(lf.getReimbursedAmount()));
    reimbursement.setEnabled(false);
    f.addComponent(reimbursement);

    f.addStyleName("light");
    f.setReadOnly(true);

    return f;
}

From source file:com.selzlein.lojavirtual.vaadin.core.NavigationMenu.java

License:Open Source License

private void buildTopMenu() {
    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    final Label title = new Label("<h3>LSPS <strong>ProcessApplication</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();//from  w  w  w.  j  a  va 2 s.  co m
    top.addComponent(title);
    top.setExpandRatio(title, 1);
    this.addComponent(top);

    final NavigationMenu menuWrapp = this;
    final Button showMenu = new Button("Menu", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuWrapp.getStyleName().contains("valo-menu-visible")) {
                menuWrapp.removeStyleName("valo-menu-visible");
            } else {
                menuWrapp.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    this.addComponent(showMenu);
}

From source file:com.skysql.manager.ui.components.ComponentButton.java

License:Open Source License

/**
 * Instantiates a new component button./*from w w w  .j  a va 2  s.  co  m*/
 *
 * @param componentInfo the component info
 */
public ComponentButton(ClusterComponent componentInfo) {
    thisButton = this;
    this.componentInfo = componentInfo;

    addStyleName("componentButton");

    componentInfo.setButton(this);
    setData(componentInfo);

    setHeight(COMPONENT_HEIGHT + 4, Unit.PIXELS);
    float componentWidth = (componentInfo.getType() == ClusterComponent.CCType.system) ? SYSTEM_WIDTH
            : NODE_WIDTH;
    setWidth(componentWidth + 8, Unit.PIXELS);

    imageLayout = new VerticalLayout();
    imageLayout.setHeight(COMPONENT_HEIGHT + 4, Unit.PIXELS);
    imageLayout.setWidth(componentWidth, Unit.PIXELS);
    //imageLayout.setMargin(new MarginInfo(true, true, false, true));
    imageLayout.setImmediate(true);

    if (componentInfo.getParentID() != null) {
        String icon = null;
        switch (componentInfo.getType()) {
        case system:
            icon = "system";
            break;

        case node:
            icon = NodeStates.getNodeIcon(componentInfo.getSystemType(), componentInfo.getState());
            break;

        default:
            // unknown component type
            break;
        }
        imageLayout.addStyleName(icon);
        //imageLayout.addStyleName(componentInfo.getType().toString());

        commandLabel = new Label();
        commandLabel.setSizeUndefined();
        imageLayout.addComponent(commandLabel);
        imageLayout.setComponentAlignment(commandLabel, Alignment.TOP_LEFT);
        //imageLayout.setExpandRatio(commandLabel, 1.0f);
        //            NodeInfo nodeInfo = (NodeInfo) componentInfo;
        //            TaskRecord taskRecord = nodeInfo.getTask();
        //            setCommandLabel(taskRecord);

        Label padding = new Label("");
        imageLayout.addComponent(padding);
        imageLayout.setComponentAlignment(padding, Alignment.MIDDLE_CENTER);

        HorizontalLayout iconsStrip = new HorizontalLayout();
        iconsStrip.addStyleName("componentInfo");
        iconsStrip.setWidth(componentInfo.getType() == ClusterComponent.CCType.node ? "60px" : "76px");
        imageLayout.addComponent(iconsStrip);
        imageLayout.setComponentAlignment(iconsStrip, Alignment.MIDDLE_CENTER);

        info = new Embedded(null, new ThemeResource("img/info.png"));
        iconsStrip.addComponent(info);
        iconsStrip.setComponentAlignment(info, Alignment.MIDDLE_LEFT);

        alert = new Embedded();
        alert.setVisible(false);
        iconsStrip.addComponent(alert);
        iconsStrip.setComponentAlignment(alert, Alignment.MIDDLE_RIGHT);

        nameLabel = new Label(componentInfo.getName());
        nameLabel.setStyleName("componentName");
        nameLabel.setSizeUndefined();
        imageLayout.addComponent(nameLabel);
        imageLayout.setComponentAlignment(nameLabel, Alignment.BOTTOM_CENTER);

    }
    addComponent(imageLayout);
    setComponentAlignment(imageLayout, Alignment.TOP_CENTER);
    setExpandRatio(imageLayout, 1.0f);

}

From source file:com.skysql.manager.ui.components.SystemLayout.java

License:Open Source License

/**
 * Instantiates a new system layout./*  w w  w. jav  a  2  s .  c o m*/
 *
 * @param systemRecord the system record
 */
public SystemLayout(SystemRecord systemRecord) {

    addStyleName("systemLayout");
    setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PERCENTAGE);
    setMargin(new MarginInfo(false, true, false, false));

    final HorizontalLayout systemHeader = new HorizontalLayout();
    systemHeader.addStyleName("panelHeaderLayout");
    systemHeader.setSpacing(true);
    systemHeader.setWidth("100%");
    systemHeader.setHeight("23px");
    addComponent(systemHeader);

    backButton = new NativeButton();
    backButton.setStyleName("backButton");
    backButton.setDescription("Back to Systems");
    systemHeader.addComponent(backButton);
    backButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {

            VaadinSession session = getSession();
            SystemInfo systemInfo = session.getAttribute(SystemInfo.class);
            OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class);
            ComponentButton button = systemInfo.getCurrentSystem().getButton();
            String parentID = systemInfo.getCurrentSystem().getParentID();
            systemInfo.setCurrentSystem(parentID);
            session.setAttribute(SystemInfo.class, systemInfo);
            ManagerUI.log("new systemID: " + parentID);
            overviewPanel.clickLayout(button, false);
            overviewPanel.refresh();
        }

    });

    final Label systemLabel = new Label("Systems");
    systemLabel.setSizeUndefined();
    systemHeader.addComponent(systemLabel);
    systemHeader.setComponentAlignment(systemLabel, Alignment.MIDDLE_LEFT);
    systemHeader.setExpandRatio(systemLabel, 1.0f);

    systemSlot = new HorizontalLayout();
    addComponent(systemSlot);

    // initialize System button
    refresh(null, null);

}

From source file:com.skysql.manager.ui.NodeForm.java

License:Open Source License

/**
 * Instantiates a new node form./*  w w w  .  j  av  a  2  s.  co  m*/
 *
 * @param node the node
 * @param description the description
 */
NodeForm(final NodeInfo node, String description) {
    this.node = node;

    setMargin(new MarginInfo(true, true, false, true));
    setSpacing(false);

    isGalera = node.getSystemType().equals(SystemTypes.Type.galera.name());

    HorizontalLayout formDescription = new HorizontalLayout();
    formDescription.setSpacing(true);

    Embedded info = new Embedded(null, new ThemeResource("img/info.png"));
    info.addStyleName("infoButton");
    String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n"
            + "     <tr bgcolor=\"#ccccff\">" + "         <th align=left>Field"
            + "         <th align=left>Description" + "     <tr>" + "         <td><code>Name</code>"
            + "         <td>Name of the Node" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Hostname</code>"
            + "         <td>In some systems, a hostname that identifies the node" + "     <tr>"
            + "         <td><code>Instance ID</code>"
            + "         <td>The instance ID field is for information only and is not used within the Manager"
            + "     <tr bgcolor=\"#eeeeff\">" + "         <td><code>Public IP</code>"
            + "         <td>In some systems, the public IP address of the node" + "     <tr>"
            + "         <td><code>Private IP</code>"
            + "         <td>The IP address that accesses the node internally to the manager";

    if (!isGalera) {
        infoText += "     <tr bgcolor=\"#eeeeff\">" + "         <td><code>Database Username</code>"
                + "         <td>Node system override for database user name" + "     <tr>"
                + "         <td><code>Database Password</code>"
                + "         <td>Node system override for database password" + "     <tr bgcolor=\"#eeeeff\">"
                + "         <td><code>Replication Username</code>"
                + "         <td>Node system override for replication user name" + "     <tr>"
                + "         <td><code>Replication Password</code>"
                + "         <td>Node system override for replication password";

    }
    infoText += " </table>" + " </blockquote>";
    info.setDescription(infoText);

    formDescription.addComponent(info);
    Label labelDescription = new Label(description);
    formDescription.addComponent(labelDescription);
    formDescription.setComponentAlignment(labelDescription, Alignment.MIDDLE_LEFT);
    addComponent(formDescription);

    addComponent(form);
    form.setImmediate(false);
    form.setFooter(null);
    form.setDescription(null);

    String value;
    if ((value = node.getName()) != null) {
        name.setValue(value);
    }
    form.addField("name", name);
    name.focus();
    name.setImmediate(true);
    name.addValidator(new NodeNameValidator(node.getName()));

    if ((value = node.getHostname()) != null) {
        hostname.setValue(value);
    }
    form.addField("hostname", hostname);

    if ((value = node.getInstanceID()) != null) {
        instanceID.setValue(value);
    }
    form.addField("instanceID", instanceID);

    if ((value = node.getPublicIP()) != null) {
        publicIP.setValue(value);
    }
    form.addField("publicIP", publicIP);

    if ((value = node.getPrivateIP()) != null) {
        privateIP.setValue(value);
    }
    form.addField("privateIP", privateIP);
    privateIP.setRequired(true);
    privateIP.setRequiredError("Private IP is a required field");

    if (!isGalera) {
        if ((value = node.getDBUsername()) != null) {
            dbUsername.setValue(value);
        }
        form.addField("dbusername", dbUsername);
        dbUsername.setRequired(true);
        dbUsername.setImmediate(false);
        dbUsername.setRequiredError("Database Username is a required field");
        dbUsername.addValidator(new UserNotRootValidator(dbUsername.getCaption()));

        if ((value = node.getDBPassword()) != null) {
            dbPassword.setValue(value);
        }
        form.addField("dbpassword", dbPassword);
        dbPassword.setRequired(true);
        dbPassword.setImmediate(false);
        dbPassword.setRequiredError("Database Password is a required field");

        if ((value = node.getDBPassword()) != null) {
            dbPassword2.setValue(value);
        }
        form.addField("dbpassword2", dbPassword2);
        dbPassword2.setRequired(true);
        dbPassword2.setImmediate(true);
        dbPassword2.setRequiredError("Confirm Password is a required field");
        dbPassword2.addValidator(new Password2Validator(dbPassword));

        if ((value = node.getRepUsername()) != null) {
            repUsername.setValue(value);
        }
        form.addField("repusername", repUsername);
        repUsername.setRequired(true);
        repUsername.setImmediate(false);
        repUsername.setRequiredError("Replication Username is a required field");
        repUsername.addValidator(new UserNotRootValidator(repUsername.getCaption()));

        if ((value = node.getRepPassword()) != null) {
            repPassword.setValue(value);
        }
        form.addField("reppassword", repPassword);
        repPassword.setRequired(true);
        repPassword.setImmediate(false);
        repPassword.setRequiredError("Replication Password is a required field");

        if ((value = node.getRepPassword()) != null) {
            repPassword2.setValue(value);
        }
        form.addField("reppassword2", repPassword2);
        repPassword2.setRequired(true);
        repPassword2.setImmediate(true);
        repPassword2.setRequiredError("Confirm Password is a required field");
        repPassword2.addValidator(new Password2Validator(repPassword));
    }

    if (node.getID() == null) {
        Layout layout = form.getLayout();

        {
            Label spacer = new Label();
            spacer.setWidth("40px");
            layout.addComponent(spacer);
        }

        HorizontalLayout optionLayout = new HorizontalLayout();
        optionLayout.addStyleName("formInfoLayout");
        optionLayout.setSpacing(true);
        optionLayout.setSizeUndefined();
        layout.addComponent(optionLayout);

        Label padding = new Label("\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0");
        optionLayout.addComponent(padding);

        Embedded info2 = new Embedded(null, new ThemeResource("img/info.png"));
        info2.addStyleName("infoButton");
        info2.setDescription(connectionInfo);
        optionLayout.addComponent(info2);

        final Validator validator = new Password2Validator(connectPassword);

        final OptionGroup connectOption = new OptionGroup("Connection options");
        connectOption.setSizeUndefined();
        connectOption.addItem(false);
        connectOption.setItemCaption(false, "Node is not available, user will run connect later");
        connectOption.addItem(true);
        connectOption.setItemCaption(true, "Node is available now, connect automatically");
        connectOption.setImmediate(true);
        connectOption.addValueChangeListener(new Property.ValueChangeListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            @Override
            public void valueChange(ValueChangeEvent event) {
                runConnect = (Boolean) event.getProperty().getValue();
                passwordOption.setVisible(runConnect);
                connectPassword.setRequired(runConnect && usePassword);
                connectPassword2.setRequired(runConnect && usePassword);
                connectKey.setRequired(runConnect && !usePassword);
                if (!runConnect) {
                    connectPassword.setVisible(false);
                    connectPassword2.setVisible(false);
                    connectPassword2.removeValidator(validator);
                    connectKey.setVisible(false);
                } else {
                    if (usePassword) {
                        connectPassword.setVisible(true);
                        connectPassword2.setVisible(true);
                        connectPassword2.addValidator(validator);
                    } else {
                        connectKey.setVisible(true);
                    }
                }
                form.setComponentError(null);
                form.setValidationVisible(false);
            }
        });
        optionLayout.addComponent(connectOption);
        optionLayout.setComponentAlignment(connectOption, Alignment.MIDDLE_LEFT);
        connectOption.select(true);

        passwordOption.addItem(true);
        passwordOption.setItemCaption(true, "Authenticate with root user");
        passwordOption.addItem(false);
        passwordOption.setItemCaption(false, "Authenticate with SSH Key");
        passwordOption.setImmediate(true);
        passwordOption.addValueChangeListener(new Property.ValueChangeListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            @Override
            public void valueChange(ValueChangeEvent event) {
                usePassword = (Boolean) event.getProperty().getValue();
                if (usePassword) {
                    connectPassword2.addValidator(validator);
                } else {
                    connectPassword2.removeValidator(validator);
                }
                connectPassword.setVisible(usePassword);
                connectPassword.setRequired(usePassword);
                connectPassword2.setVisible(usePassword);
                connectPassword2.setRequired(usePassword);
                connectKey.setVisible(!usePassword);
                connectKey.setRequired(!usePassword);
                form.setComponentError(null);
                form.setValidationVisible(false);
            }
        });
        layout.addComponent(passwordOption);
        passwordOption.select(false);

        form.addField("connectPassword", connectPassword);
        connectPassword.setImmediate(false);
        connectPassword.setRequiredError("Root Password is a required field");

        form.addField("connectPassword2", connectPassword2);
        connectPassword2.setImmediate(true);
        connectPassword2.setRequiredError("Confirm Password is a required field");

        form.addField("connectKey", connectKey);
        connectKey.setStyleName("sshkey");
        connectKey.setColumns(41);
        connectKey.setRequiredError("SSH Key is a required field");
    }

}

From source file:com.skysql.manager.ui.OverviewPanel.java

License:Open Source License

/**
 * Instantiates a new overview panel.//w  w w.j ava2  s. c o  m
 */
public OverviewPanel() {

    HorizontalLayout overviewContainer = new HorizontalLayout();
    overviewContainer.addStyleName("overviewPanel");
    overviewContainer.setWidth("100%");
    setContent(overviewContainer);

    systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
    systemRecord = systemInfo.getCurrentSystem();
    systemLayout = new SystemLayout(systemRecord);
    overviewContainer.addComponent(systemLayout);

    VerticalLayout nodesSlot = new VerticalLayout();
    nodesSlot.addStyleName("nodesSlot");
    nodesSlot.setMargin(new MarginInfo(false, false, false, false));
    overviewContainer.addComponent(nodesSlot);
    overviewContainer.setExpandRatio(nodesSlot, 1.0f);

    final HorizontalLayout nodesHeader = new HorizontalLayout();
    nodesHeader.setStyleName("panelHeaderLayout");
    nodesHeader.setWidth("100%");
    nodesSlot.addComponent(nodesHeader);
    nodesLabel = new Label(" ");
    nodesLabel.setSizeUndefined();
    nodesHeader.addComponent(nodesLabel);
    nodesHeader.setComponentAlignment(nodesLabel, Alignment.MIDDLE_CENTER);
    nodesHeader.setExpandRatio(nodesLabel, 1.0f);

    final HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    buttonsLayout.setMargin(new MarginInfo(false, true, false, false));
    nodesHeader.addComponent(buttonsLayout);
    nodesHeader.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT);

    addSystemButton = new Button("Add System...");
    addSystemButton.setDescription("Add System");
    addSystemButton.setVisible(false);
    buttonsLayout.addComponent(addSystemButton);
    addSystemButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            new SystemDialog(null, null);
        }
    });

    addNodeButton = new Button("Add Node...");
    addNodeButton.setDescription("Add Node to the current System");
    addNodeButton.setVisible(false);
    buttonsLayout.addComponent(addNodeButton);
    addNodeButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            new NodeDialog(null, null);
        }
    });

    final Button editButton = new Button("Edit");
    editButton.setDescription("Enter Editing mode");
    final Button saveButton = new Button("Done");
    saveButton.setDescription("Exit Editing mode");
    buttonsLayout.addComponent(editButton);

    editButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            buttonsLayout.replaceComponent(editButton, saveButton);
            isEditable = true;
            systemLayout.setEditable(true);
            nodesLayout.setEditable(true);
            nodesHeader.setStyleName("panelHeaderLayout-editable");
            if (systemRecord != null && !SystemInfo.SYSTEM_ROOT.equals(systemRecord.getID())) {
                addNodeButton.setVisible(true);
            } else {
                addSystemButton.setVisible(true);
            }
            if (systemRecord == null || (systemRecord != null && systemRecord.getNodes().length == 0)) {
                nodesLayout.placeholderLayout(null);
            }
        }
    });

    saveButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            buttonsLayout.replaceComponent(saveButton, editButton);
            isEditable = false;
            systemLayout.setEditable(false);
            nodesLayout.setEditable(false);
            nodesHeader.setStyleName("panelHeaderLayout");
            if (systemRecord != null && systemRecord.getNodes().length == 0) {
                nodesLayout.placeholderLayout(null);
            }
            addNodeButton.setVisible(false);
            addSystemButton.setVisible(false);
        }
    });

    Panel panel = new Panel();
    panel.setHeight(PANEL_HEIGHT, Unit.PIXELS);
    panel.addStyleName(Runo.PANEL_LIGHT);
    nodesSlot.addComponent(panel);

    nodesLayout = new NodesLayout(systemRecord);
    nodesLayout.addStyleName("nodesLayout");
    nodesLayout.setWidth("100%");
    panel.setContent(nodesLayout);

}

From source file:com.skysql.manager.ui.PanelInfo.java

License:Open Source License

/**
 * Creates the info layout./*w w w.  j a v  a  2  s.  c  o m*/
 */
private void createInfoLayout() {

    infoLayout = new VerticalLayout();
    infoLayout.addStyleName("infoLayout");
    infoLayout.setWidth(PANEL_SPLIT_X, Unit.PIXELS);
    infoLayout.setSpacing(true);
    addComponent(infoLayout);

    final HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.addStyleName("panelHeaderLayout");
    headerLayout.setWidth("100%");
    headerLayout.setSpacing(true);
    headerLayout.setMargin(new MarginInfo(false, true, false, true));
    infoLayout.addComponent(headerLayout);

    nameLabel = new Label();
    nameLabel.addStyleName("nameLabel");
    nameLabel.setSizeUndefined();
    headerLayout.addComponent(nameLabel);
    headerLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT);

    final Button editButton = new Button("Edit");
    editButton.setEnabled(false);
    headerLayout.addComponent(editButton);
    headerLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT);

    // this will become the editing function of what properties are displayed in the info layout
    /***
    final Button saveButton = new Button("Done");
    editButton.addClickListener(new Button.ClickListener() {
            
       public void buttonClick(ClickEvent event) {
    nameField = new TextField();
    nameField.setImmediate(true);
    nameField.setValue(nameLabel.getValue());
    nameField.setWidth("12em");
    nameField.focus();
    nameField.addValueChangeListener(new ValueChangeListener() {
            
       public void valueChange(ValueChangeEvent event) {
          saveButton.click();
       }
    });
    headerLayout.replaceComponent(nameLabel, nameField);
    headerLayout.setComponentAlignment(nameField, Alignment.MIDDLE_LEFT);
    headerLayout.replaceComponent(editButton, saveButton);
    headerLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_RIGHT);
       }
    });
            
    saveButton.addClickListener(new Button.ClickListener() {
            
       public void buttonClick(ClickEvent event) {
    String name = nameField.getValue();
    nameLabel.setValue(name);
    headerLayout.replaceComponent(nameField, nameLabel);
    headerLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT);
    headerLayout.replaceComponent(saveButton, editButton);
    headerLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT);
    lastComponent.setName(name);
    if (lastComponent instanceof NodeInfo) {
       //((NodeInfo) lastComponent).saveName(name);
    } else if (lastComponent instanceof SystemRecord) {
       //systemInfo.saveName(name);
    }
    ComponentButton componentButton = lastComponent.getButton();
    componentButton.setName(name);
       }
    });
     ***/

    systemLabels = new Label[systemLabelsStrings.length];
    systemGrid = createCurrentInfo(systemLabels, systemLabelsStrings);
    nodeLabels = new Label[nodeLabelsStrings.length];
    nodeGrid = createCurrentInfo(nodeLabels, nodeLabelsStrings);
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java

private Component buildTitle() {
    Label logo = new Label("PFServer <strong>Dashboard</strong>", ContentMode.HTML);
    logo.setSizeUndefined();//from w ww .  j a va 2 s.  c o m
    HorizontalLayout logoWrapper = new HorizontalLayout(logo);
    logoWrapper.setComponentAlignment(logo, Alignment.MIDDLE_CENTER);
    logoWrapper.addStyleName("valo-menu-title");
    return logoWrapper;
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java

private Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//from  w w w .  j  ava 2 s .co m
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(KeyCode.ENTER);
    signin.focus();

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {

            System.out.println("TRIGGER LOGIN");
            DashboardEventBus.post(new UserLoginRequestedEvent(username.getValue(), password.getValue()));
        }
    });
    return fields;
}