Example usage for com.vaadin.ui Label setWidth

List of usage examples for com.vaadin.ui Label setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Label setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.mycollab.mobile.ui.ConfirmDialog.java

License:Open Source License

private void constructUI(final String message, final String okCaption, final String cancelCaption) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeightUndefined();/*  www  . ja  va 2  s  .  c om*/
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    VerticalLayout messageWrapper = new VerticalLayout();
    messageWrapper.setStyleName("message-wrapper");
    messageWrapper.setWidth("100%");
    messageWrapper.setMargin(true);

    final Label messageDisplay = new Label(message);
    messageDisplay.setWidth("100%");
    messageWrapper.addComponent(messageDisplay);
    layout.addComponent(messageWrapper);

    HorizontalLayout controlBtn = new HorizontalLayout();
    controlBtn.setWidth("100%");

    final Button okBtn = new Button(okCaption);
    okBtn.setWidth("100%");
    okBtn.setHeight("35px");
    final Button cancelBtn = new Button(cancelCaption);
    cancelBtn.setWidth("100%");
    cancelBtn.setHeight("35px");

    ClickListener listener = (clickEvent) -> {
        ConfirmDialog.this.setConfirmed(clickEvent.getButton() == okBtn);
        if (ConfirmDialog.this.getListener() != null) {
            ConfirmDialog.this.getListener().onClose(ConfirmDialog.this);
        }
        close();
    };

    okBtn.addClickListener(listener);
    cancelBtn.addClickListener(listener);

    controlBtn.addComponent(cancelBtn);
    controlBtn.addComponent(okBtn);

    layout.addComponent(controlBtn);
    this.setContent(layout);
}

From source file:com.mycollab.mobile.ui.MobileAttachmentUtils.java

License:Open Source License

public static Component renderAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    MHorizontalLayout attachmentRow = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("attachment-row");
    attachmentRow.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setWidth("25px");
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Component thumbnail;//  ww  w  .j a v a2 s .c  o  m

    if (StringUtils.isNotBlank(attachment.getThumbnail())) {
        thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail()));
    } else {
        thumbnail = new ELabel(FileAssetsUtil.getFileIconResource(attachment.getName()).getHtml(),
                ContentMode.HTML);
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentRow.addComponent(thumbnailWrap);

    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }

    if (MimeTypesUtil.isImageType(docName)) {
        MButton b = new MButton(attachment.getTitle(), clickEvent -> {
            AttachmentPreviewView previewView = new AttachmentPreviewView(
                    VaadinResourceFactory.getResource(attachment.getPath()));
            EventBusFactory.getInstance().post(new ShellEvent.PushView(attachment, previewView));
        }).withStyleName(UIConstants.TEXT_ELLIPSIS);
        b.setWidth("100%");
        attachmentRow.with(b).expand(b);
    } else {
        Label l = new Label(attachment.getTitle());
        l.setWidth("100%");
        attachmentRow.addComponent(l);
        attachmentRow.setExpandRatio(l, 1.0f);
    }
    return attachmentRow;
}

From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java

License:Apache License

/**
 * Create delete tab in the accordion./* w w w  .  j  a  v  a  2s  .  c  o  m*/
 * 
 * @return the component.
 */
@SuppressWarnings("serial")
private final AbstractComponent createDelete() {

    /* root layout */
    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);

    final Label label = new Label("Deleting a device can be done, only if it is de-activated.");
    layout.addComponent(label);
    label.setWidth(null);
    layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    final Button deleteButton = new Button("Delete");

    layout.addComponent(deleteButton);
    layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_CENTER);

    deleteButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final DeviceDeleteWindow deleteWindow = new DeviceDeleteWindow(model.getItemUuid());
                deleteWindow.add(model);
            } catch (final Exception e) {
                LOGGER.error("Can not delete device: ", e);
            }
        }
    });
    return layout;
}

From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java

License:Apache License

/**
 * Create delete tab in the accordion.//from   w  w w  . j ava 2s  .  c o  m
 * 
 * @return the component.
 */
@SuppressWarnings("serial")
private final AbstractComponent createDelete() {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);

    final Label label = new Label("Deleting a snapshot can be done, only if it is not the root snapshot.");
    label.setWidth(null);
    layout.addComponent(label);
    layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    final Button deleteButton = new Button("Delete");

    if (model.getItemUuid().equals(model.getSnapshotParent())) {
        // Root snapshot can not be deleted
        deleteButton.setEnabled(false);
    }
    layout.addComponent(deleteButton);
    layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_CENTER);

    deleteButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final SnapshotDeleteWindow deleteWindow = new SnapshotDeleteWindow(model.getItemUuid());
                deleteWindow.add(model);
            } catch (final Exception e) {
                LOGGER.error("Can not delete snapshot:", e);
                final ErrorWindow err = new ErrorWindow("Snapshot not deleted: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return layout;
}

From source file:com.purebred.core.view.layout.LeftLabelGridLayout.java

License:Open Source License

public void addField(FormField formField) {
    HorizontalLayout fieldLayout = (HorizontalLayout) getComponent(getFieldColumn(formField),
            getRowStart(formField));//from   www .  j a  v a 2s  .  co m
    if (fieldLayout == null) {
        addFieldImpl(formField);
    } else {
        if (formField.getFieldLabel().getValue() != null) {
            Label label = formField.getFieldLabel();
            fieldLayout.addComponent(label);
            Label spacer = new Label();
            spacer.setWidth("1em");
            fieldLayout.addComponent(spacer);
        }

        Field field = formField.getField();
        fieldLayout.addComponent(field);
        Label spacer = new Label();
        spacer.setWidth("1em");
        fieldLayout.addComponent(spacer);
    }
}

From source file:com.purebred.core.view.layout.LeftLabelGridLayout.java

License:Open Source License

private void addFieldImpl(FormField formField) {
    Label label = formField.getFieldLabel();

    HorizontalLayout fieldLayout = new HorizontalLayout();
    fieldLayout.setSizeUndefined();/*w  ww . j a  v a  2s.c om*/
    Field field = formField.getField();
    fieldLayout.addComponent(field);

    Label spacer = new Label();
    spacer.setWidth("1em");

    if (formField.getColumnEnd() != null && formField.getRowEnd() != null) {
        addComponent(label, getLabelColumn(formField), getRowStart(formField), getLabelColumn(formField),
                getRowEnd(formField));

        addComponent(fieldLayout, getFieldColumn(formField), getRowStart(formField), getColumnEnd(formField),
                getRowEnd(formField));

        addComponent(spacer, getSpacerColumn(formField), getRowStart(formField), getSpacerColumn(formField),
                getRowEnd(formField));
    } else {
        addComponent(label, getLabelColumn(formField), getRowStart(formField));

        addComponent(fieldLayout, getFieldColumn(formField), getRowStart(formField));

        addComponent(spacer, getSpacerColumn(formField), getRowStart(formField));
    }
    setComponentAlignment(fieldLayout, Alignment.TOP_LEFT);
    setComponentAlignment(label, Alignment.TOP_RIGHT);
    setComponentAlignment(spacer, Alignment.TOP_LEFT);
}

From source file:com.selzlein.lojavirtual.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    ui = (LspsUI) getUI();/*  w w w .  ja va2s.  co  m*/
    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.addStyleName("l-settings");
    layout.setSizeFull();
    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();
    layout.addComponent(substitution);
    layout.setExpandRatio(substitution, 2);

    //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);
}

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

License:Open Source License

/**
 * Instantiates a new node form.//from  www.  ja  v a  2 s.c  o 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.PanelTools.java

License:Open Source License

/**
 * Instantiates a new panel tools./*w  w w . j av a 2s . c  om*/
 */
PanelTools() {

    // thisTab.setSizeFull();
    // thisTab.setWidth(Sizeable.SIZE_UNDEFINED, 0); // Default
    setHeight("200px");
    setSpacing(true);

    // External Tools Vertical Module
    SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class);
    LinkedHashMap<String, String> properties = systemInfo.getCurrentSystem().getProperties();
    if (properties != null) {
        VerticalLayout externalsLayout = new VerticalLayout();
        externalsLayout.setWidth("150px");
        externalsLayout.addStyleName("externalsLayout");
        externalsLayout.setSpacing(true);

        String EIP = properties.get(SystemInfo.PROPERTY_EIP);
        String MONyog = properties.get(SystemInfo.PROPERTY_MONYOG);
        if (EIP != null && MONyog != null) {
            String url = "http://" + EIP + MONyog;
            monyogLink = new Link("MONyog", new ExternalResource(url));
            monyogLink.setTargetName("_blank");
            monyogLink.setDescription("Open MONyog for the whole system");
            monyogLink.setIcon(new ThemeResource("img/externalLink.png"));
            monyogLink.addStyleName("icon-after-caption");
            externalsLayout.addComponent(monyogLink);
            externalsLayout.setComponentAlignment(monyogLink, Alignment.BOTTOM_CENTER);
        }

        phpUrl = properties.get(SystemInfo.PROPERTY_PHPMYADMIN);
        if (phpUrl != null) {
            phpLink = new Link("phpMyAdmin", null);
            phpLink.setTargetName("_blank");
            phpLink.setDescription("Open phpMyAdmin for the selected node");
            phpLink.setIcon(new ThemeResource("img/externalLink.png"));
            phpLink.addStyleName("icon-after-caption");
            externalsLayout.addComponent(phpLink);
            externalsLayout.setComponentAlignment(phpLink, Alignment.BOTTOM_CENTER);
        }

        addComponent(externalsLayout);
        setComponentAlignment(externalsLayout, Alignment.MIDDLE_CENTER);

    }

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

    // Scripting layout placeholder
    VerticalLayout placeholderLayout = new VerticalLayout();
    placeholderLayout.addStyleName("placeholderLayout");
    placeholderLayout.setSizeUndefined();

    Label placeholderLabel = new Label("Links to external tools");
    placeholderLabel.addStyleName("instructions");
    placeholderLayout.addComponent(placeholderLabel);

    addComponent(placeholderLayout);
    setComponentAlignment(placeholderLayout, Alignment.MIDDLE_CENTER);

}

From source file:com.squadd.javaBeans.ChatMessage.java

public static HorizontalLayout createChatLine2(ChatMessage message, ChatView view) {
    Integer from = message.getIdFrom();
    Integer to = message.getIdTo();
    String body = message.getBody();

    HorizontalLayout chatLine = new HorizontalLayout();

    String formattedDate = message.getFormattedDate();

    Label timeLabel = new Label(formattedDate);

    timeLabel.setWidth("10%");
    chatLine.addComponent(timeLabel);/* ww  w.  j av a  2 s  . c  om*/

    Label nameLabel = new Label(from + ": ");
    nameLabel.setWidth("15%");
    chatLine.addComponent(nameLabel);

    Label messageLabel = new Label(body);
    chatLine.addComponent(messageLabel);
    chatLine.setExpandRatio(messageLabel, 1);
    return chatLine;
}