Example usage for com.vaadin.ui Component setWidth

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

Introduction

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

Prototype

public void setWidth(String width);

Source Link

Document

Sets the width of the component using String presentation.

Usage

From source file:com.scsb.crpro.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * //from   ww  w  .jav  a2s.  c o  m
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.scsb.vaadin.composite.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * //  ww  w. j a  va  2  s.  co m
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("./images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("./images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("./images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("./images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:de.steinwedel.messagebox.MessageBox.java

License:Apache License

/**
 * Sets an icon to the message dialog.//from  www  .  j  a  v  a  2  s.  c o m
 *
 * @param icon   An embedded resource
 * @param width  The width i.e. "48px"
 * @param height The height i.e. "48px"
 * @return The {@link MessageBox} instance itself
 */
public MessageBox withIcon(Component icon, String width, String height) {
    if (this.icon != null) {
        contentLayout.removeComponent(this.icon);
    }

    this.icon = icon;

    if (icon != null) {
        contentLayout.addComponent(icon, 0);
        contentLayout.setComponentAlignment(icon, Alignment.MIDDLE_CENTER);
        icon.setWidth(width);
        icon.setHeight(height);
    }
    return this;
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabTalk.java

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();/*from www.  j  a  va2 s  . com*/
    VerticalLayout leftVL = this.getLeftLayout();

    leftVL.setSpacing(true);

    Label missionLab = new Label("Authors, this is your team space.");
    leftVL.addComponent(missionLab);
    leftVL.setComponentAlignment(missionLab, Alignment.TOP_LEFT);
    missionLab.addStyleName("m-actionplan-mission-title-text");

    ActionPlan ap = ActionPlan.getTL(apId);

    Label missionContentLab;
    Game g = Game.getTL();
    if (!isMockup)
        missionContentLab = new HtmlLabel(ap.getTalkItOverInstructions());
    else {
        missionContentLab = new HtmlLabel(g.getDefaultActionPlanTalkText());
    }

    leftVL.addComponent(missionContentLab);
    leftVL.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT);
    leftVL.addStyleName("m-actionplan-mission-content-text");

    Label sp;
    leftVL.addComponent(sp = new Label());
    sp.setHeight("1px");
    leftVL.setExpandRatio(sp, 1.0f);

    VerticalLayout rightVL = getRightLayout();
    rightVL.setSpacing(true);

    Label lab;
    rightVL.addComponent(lab = new Label());
    lab.setHeight("15px");

    rightVL.addComponent(nonAuthorLabel = new Label("This is a space for plan authors to communicate."));
    nonAuthorLabel.setVisible(false);

    rightVL.addComponent(chatEntryComponent);
    chatEntryComponent.setWidth("100%");

    if (isGameMasterOrAdmin) {
        HorizontalLayout hl = new HorizontalLayout();
        rightVL.addComponent(hl);
        hl.setWidth("100%");

        hl.addComponent(sp = new Label());
        sp.setWidth("1px");
        hl.setExpandRatio(sp, 1.0f);

        viewAllButt = new ToggleLinkButton("View all", "View unhidden only", "m-actionplan-comment-text");
        viewAllButt.setToolTips("Temporarily show all messages, including those marked \"hidden\" (gm)",
                "Temporarily hide messages marked \"hidden\" (gm)");
        viewAllButt.addStyleName("m-actionplan-comments-button");
        viewAllButt.addOnListener(new ViewAllListener());
        viewAllButt.addOffListener(new ViewUnhiddenOnlyListener());
        hl.addComponent(viewAllButt);

        hl.addComponent(sp = new Label());
        sp.setWidth("8px");
    }
    Component comp = createChatScroller(rightVL);
    comp.setWidth("99%");
    rightVL.setExpandRatio(comp, 1.0f);
    comp.setHeight("99%");
    fillChatScrollerTL();
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java

License:Open Source License

private void showFavoritesOrBuilds2(Component c) {
    //getRightLayout().setSizeUndefined();  // if layout is full size, content goes in center, we want top
    getRightLayout().addComponent(c);// w  w  w.java2s .  c om
    getRightLayout().setComponentAlignment(c, Alignment.TOP_CENTER);
    c.setWidth("670px");
    c.setHeight("720px");
    lastTable = c;
}

From source file:info.magnolia.ui.vaadin.richtext.TextAreaStretcher.java

License:Open Source License

public TextAreaStretcher() {
    registerRpc(new TextAreaStretcherServerRpc() {
        @Override//from   w  w w  .j a v a  2  s  .c o m
        public void toggle(int initialWidth, int initialHeight) {
            getState().isCollapsed = !getState().isCollapsed;
            final Component parent = (Component) getParent();
            if (getState().isCollapsed) {
                // Restore size info from the state.
                parent.setWidth(getState().collapsedStateWidth);
                parent.setHeight(getState().collapsedStateHeight);
            } else {

                // We save the initial dimensions and clear size info from the state.
                getState().collapsedStateHeight = parent.getHeight() + parent.getHeightUnits().toString();
                getState().collapsedStateWidth = parent.getWidth() + parent.getWidthUnits().toString();
                parent.setWidth("");
                parent.setHeight("");
            }
        }
    });
}

From source file:org.activiti.explorer.ui.management.identity.UserDetailPanel.java

License:Apache License

protected void loadPicture() {
    Component pictureComponent = null;
    final Picture userPicture = identityService.getUserPicture(user.getId());
    if (userPicture != null) {
        StreamResource imageresource = new StreamResource(new StreamSource() {
            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                return userPicture.getInputStream();
            }/* w  w w .ja v  a 2 s  .c  o m*/
        }, user.getId() + "." + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()),
                ExplorerApp.get());
        pictureComponent = new Embedded(null, imageresource);
    } else {
        pictureComponent = new Label("");
    }
    pictureComponent.setHeight("200px");
    pictureComponent.setWidth("200px");
    pictureComponent.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);
    userDetailsLayout.addComponent(pictureComponent);
    userDetailsLayout.setComponentAlignment(pictureComponent, Alignment.MIDDLE_CENTER);
}

From source file:org.apache.tamaya.ui.views.login.LoginBox.java

License:Apache License

private void addForm() {
    FormLayout loginForm = new FormLayout();
    MessageProvider mp = ServiceContextManager.getServiceContext().getService(MessageProvider.class);
    username = new TextField(mp.getMessage("default.label.username"));
    password = new PasswordField(mp.getMessage("default.label.password"));
    loginForm.addComponents(username, password);
    addComponent(loginForm);// w  w  w  . j  ava  2 s. c  om
    loginForm.setSpacing(true);
    for (Component component : loginForm) {
        component.setWidth("100%");
    }
    username.focus();
}

From source file:org.hip.vif.web.util.UploadComponent.java

License:Open Source License

/** Constructor
 *
 * @param inDownloads {@link QueryResult} the existing download files to display
 * @param inTask {@link IBibliographyTask}
 * @throws VException/*ww w  .java  2  s .  c  om*/
 * @throws SQLException */
public UploadComponent(final QueryResult inDownloads, final IBibliographyTask inTask)
        throws VException, SQLException {
    super();
    hasDownloads = false;
    dialog = createDialog(inTask);

    layout = createLayout();
    setCompositionRoot(layout);
    layout.setStyleName("vif-upload"); //$NON-NLS-1$

    dropBox = createDropBox(inTask);
    layout.addComponent(dropBox);
    upload = createUpload(inTask);
    layout.addComponent(upload);
    Component lLast = upload;

    downloadDelete = createDeleteFileButton(inTask);
    if (inDownloads.hasMoreElements()) {
        // add button to delete file and download link to download layout
        hasDownloads = true;
        final GeneralDomainObject lDownload = inDownloads.next();
        final DownloadFileLink lDownloadLink = new DownloadFileLink(
                BeanWrapperHelper.getString(DownloadTextHome.KEY_LABEL, lDownload),
                BeanWrapperHelper.getLong(DownloadTextHome.KEY_ID, lDownload));
        layout.addComponent(downloadDelete);
        layout.addComponent(lDownloadLink);
        lLast = lDownloadLink;
    } else {
        final Component lSpace = RiplaViewHelper.createSpacer();
        layout.addComponent(lSpace);
        lLast = lSpace;
    }
    lLast.setWidth("100%"); //$NON-NLS-1$
    layout.setExpandRatio(lLast, 1);
    layout.setComponentAlignment(lLast, Alignment.MIDDLE_LEFT);
}

From source file:org.hip.vif.web.util.UploadComponent.java

License:Open Source License

private void addComponents(final Component... inComponents) { // NOPMD
    for (final Component lComponent : inComponents) {
        layout.addComponent(lComponent);
    }//from  ww w  .  j a v  a2 s.c o  m
    final Component lLast = inComponents[inComponents.length - 1];
    lLast.setWidth("100%"); //$NON-NLS-1$
    layout.setExpandRatio(lLast, 1);
    layout.setComponentAlignment(lLast, Alignment.MIDDLE_LEFT);
}