Example usage for com.vaadin.ui CssLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundMenus() {
    Layout grid = getPreviewLayout("Compound Menus");

    Label title = new Label("Sidebar Menu");
    title.setStyleName("h1");
    grid.addComponent(title);//  w  w w. j  av a 2 s.c  o m
    ((GridLayout) grid).newLine();

    Label menus = new Label(
            "<strong>The sidebar menu</strong> control is just a set of labels and buttons inside a CssLayout or a VerticalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.<br><br>You can also use the <a href=\"http://vaadin.com/forum/-/message_boards/message/119172\">DetachedTabs add-on</a> inside the sidebar-menu, it will style automatically.<br><br><strong>Note: only NativeButtons are styled inside the menu, normal buttons are left untouched.</strong>",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label(
            "CssLayout.setStyleName(\"sidebar-menu\")\n  +  Label\n  +  NativeButton\n  +  NativeButton\n\t...\n  +  Label\n  +  DetachedTabs\n\t...",
            Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    SidebarMenu sidebar = new SidebarMenu();
    sidebar.setWidth("200px");
    sidebar.addComponent(new Label("Fruits"));
    NativeButton b = new NativeButton("Apples");
    b.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    sidebar.addButton(b);
    sidebar.setSelected(b);
    sidebar.addButton(new NativeButton("Oranges"));
    sidebar.addButton(new NativeButton("Bananas"));
    sidebar.addButton(new NativeButton("Grapes"));
    sidebar.addComponent(new Label("Vegetables"));
    sidebar.addButton(new NativeButton("Tomatoes"));
    sidebar.addButton(new NativeButton("Cabbages"));
    sidebar.addButton(new NativeButton("Potatoes"));
    sidebar.addButton(new NativeButton("Carrots"));
    grid.addComponent(sidebar);
    ((GridLayout) grid).setColumnExpandRatio(0, 1);
    ((GridLayout) grid).setColumnExpandRatio(1, 1);

    title = new Label("Toolbar");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    CssLayout toolbars = new CssLayout();

    menus = new Label(
            "<strong>Toolbar</strong> is a simple CssLayout with a stylename. It provides the background and a little padding for its contents. Normally you will want to put buttons inside it, but segment controls fit in nicely as well.",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label("CssLayout.setStyleName(\"toolbar\")", Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    CssLayout toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    Button b2 = new Button("Action");
    b2.setStyleName("small");
    toolbar.addComponent(b2);

    Segment segment = new Segment();
    segment.addStyleName("segment-alternate");
    b2 = new Button("Apples");
    b2.setStyleName("small");
    b2.addStyleName("down");
    segment.addButton(b2);
    b2 = new Button("Oranges");
    b2.setStyleName("small");
    segment.addButton(b2);
    toolbar.addComponent(segment);

    b2 = new Button("Notes");
    b2.setStyleName("small borderless");
    b2.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    b2 = new Button("Action");
    b2.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    b2.setStyleName("borderless");
    toolbar.addComponent(b2);

    b2 = new Button("Action 2");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/user.png"));
    toolbar.addComponent(b2);

    b2 = new Button("Action 3");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    grid.addComponent(toolbars);

    return grid;
}

From source file:net.pkhsolutions.pecsapp.ui.components.PagePanel.java

License:Open Source License

private void updateLayout(Property.ValueChangeEvent event) {
    final PageLayout layout = Objects.requireNonNull(model.getLayout().getValue());
    if (layout.getOrientation().equals(PageOrientation.PORTRAIT)) {
        page.setWidth(layout.getPageSize().getWidthMm(), Unit.MM);
        page.setHeight(layout.getPageSize().getHeightMm(), Unit.MM);
    } else {//from  ww  w  .  j  a  v  a2  s .c o m
        page.setWidth(layout.getPageSize().getHeightMm(), Unit.MM);
        page.setHeight(layout.getPageSize().getWidthMm(), Unit.MM);
    }
    page.removeAllComponents();
    final float rowHeight = page.getHeight() / layout.getRows();
    final float cellWidth = page.getWidth() / layout.getColumns();
    rows = new CssLayout[layout.getRows()];
    cells = new PictureLayout[layout.getRows()][layout.getColumns()];
    for (int i = 0; i < layout.getRows(); ++i) {
        CssLayout row = new CssLayout();
        row.addStyleName("page-row");
        row.setWidth("100%");
        row.setHeight(rowHeight, page.getHeightUnits());
        page.addComponent(row);
        rows[i] = row;
        for (int j = 0; j < layout.getColumns(); ++j) {
            PictureLayout cell = new PictureLayout(model.getPictureModel(j, i));
            cell.addStyleName("page-row-cell");
            cell.setWidth(cellWidth, page.getWidthUnits());
            cell.setHeight("100%");
            row.addComponent(cell);
            cells[i][j] = cell;
        }
    }
}

From source file:org.eclipse.skalli.view.internal.window.NewProjectPanel.java

License:Open Source License

/**
 * Renders the content of the panel./*ww w. ja  v  a  2 s  .co m*/
 */
private void renderContent(VerticalLayout content) {

    CssLayout layout = new CssLayout();
    layout.setWidth("600px"); //$NON-NLS-1$
    content.addComponent(layout);
    content.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

    Label title = new Label("<h2>" + "Available Project Templates" + "</h2>", Label.CONTENT_XHTML); //$NON-NLS-1$//$NON-NLS-3$
    layout.addComponent(title);

    TreeSet<RadioSelect.Entry> entries = new TreeSet<RadioSelect.Entry>();
    for (ProjectTemplate projectTemplate : projectTemplates) {
        entries.add(new RadioSelect.Entry(projectTemplate.getId(), projectTemplate.getDisplayName(),
                projectTemplate.getDescription(), projectTemplate.getRank()));
    }
    select = new RadioSelect("", entries); //$NON-NLS-1$
    layout.addComponent(select);

    renderButtons(content);

    // for ui debugging
    content.setDebugId(DEBUG_ID_CONTENT);
}

From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanel.java

License:Open Source License

private Label renderMessageArea(VerticalLayout layout) {
    CssLayout messageArea = new CssLayout();
    messageArea.setMargin(true);//from   w w w .  ja v a 2 s.c  o  m
    messageArea.setWidth(PANEL_WIDTH);
    Label label = new Label("", Label.CONTENT_XHTML); //$NON-NLS-1$
    label.addStyleName(STYLE_ISSUES);
    label.setVisible(false);
    messageArea.addComponent(label);
    layout.addComponent(messageArea);
    layout.setComponentAlignment(messageArea, Alignment.MIDDLE_CENTER);
    return label;
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.ResourcePropertiesViewHelper.java

License:Open Source License

public Panel generatePropertiesView() {
    // Item title
    String resourceType = resourceProxy.getType().toString();
    if (this.type != null && this.type.length() > 0) {
        resourceType = this.type;
    }/*from w  ww .j av  a  2s. c o  m*/
    final Label titleLabel = new Label(resourceType.substring(0, 1).toUpperCase()
            + resourceType.substring(1).toLowerCase() + ": " + resourceProxy.getName());
    titleLabel.setDescription("header");
    titleLabel.setStyleName("h2 fullwidth");

    // HR Ruler
    final Label descRuler = new Label("<hr/>", Label.CONTENT_RAW);
    descRuler.setStyleName("hr");

    // ItemProperties View
    final CssLayout propertiesView = new CssLayout();
    propertiesView.setWidth("100%");
    propertiesView.setHeight("100%");

    final Label descMetadata1 = new Label("ID: " + resourceProxy.getId());
    final Label descMetadata2 = new Label(
            LAST_MODIFIED_BY + " " + resourceProxy.getModifier() + " on " + resourceProxy.getModifiedOn(),
            Label.CONTENT_XHTML);

    final Panel pnlPropertiesLeft = buildLeftPanel();
    pnlPropertiesLeft.setWidth("40%");
    pnlPropertiesLeft.setHeight("20px");
    pnlPropertiesLeft.setStyleName(FLOAT_LEFT);
    pnlPropertiesLeft.addStyleName(Runo.PANEL_LIGHT);
    pnlPropertiesLeft.getLayout().setMargin(false);
    pnlPropertiesLeft.addComponent(descMetadata1);

    final Panel pnlPropertiesRight = buildRightPanel();
    pnlPropertiesRight.setWidth("60%");
    pnlPropertiesRight.setHeight("20px");
    pnlPropertiesRight.setStyleName(FLOAT_RIGHT);
    pnlPropertiesRight.addStyleName(Runo.PANEL_LIGHT);
    pnlPropertiesRight.getLayout().setMargin(false);
    pnlPropertiesRight.addComponent(descMetadata2);

    propertiesView.addComponent(pnlPropertiesLeft);
    propertiesView.addComponent(pnlPropertiesRight);

    Panel viewHandler = buildmainView();

    new BreadCrumbMenu(viewHandler, breadCrumbModel, serviceLocation);

    viewHandler.addComponent(titleLabel);
    viewHandler.addComponent(descRuler);
    viewHandler.addComponent(propertiesView);

    return viewHandler;
}

From source file:org.escidoc.browser.layout.NavigationSimpleLayout.java

License:Open Source License

private CssLayout newHeaderButton(final TreeDataSource ds) {
    CssLayout cssLayout = new CssLayout();
    cssLayout.setWidth("97%");
    cssLayout.setMargin(false);/*from w ww.jav a  2 s . c o m*/

    ThemeResource plusIcon = new ThemeResource("images/assets/plus.png");

    final Button createGroupButton = new Button();
    createGroupButton.setStyleName(BaseTheme.BUTTON_LINK);
    createGroupButton.addStyleName("floatright paddingtop3");
    createGroupButton.setWidth("20px");
    createGroupButton.setIcon(plusIcon);
    createGroupButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
            showCreateGroupView();
        }

        private void showCreateGroupView() {
            router.getMainWindow().addWindow(
                    new CreateGroupView(repositories.group(), router.getMainWindow(), ds).modalWindow());
        }

    });
    cssLayout.addComponent(createGroupButton);
    return cssLayout;
}

From source file:org.escidoc.browser.ui.maincontent.ContainerMetadataRecordsView.java

License:Open Source License

private static void buildPanelHeader(CssLayout cssLayout, String name) {
    cssLayout.addStyleName("v-accordion-item-caption v-caption v-captiontext");
    cssLayout.setWidth("100%");
    cssLayout.setMargin(false);//from  w  w  w  .j ava 2s.  c om

    final Label nameofPanel = new Label(name, Label.CONTENT_RAW);
    nameofPanel.setStyleName("accordion v-captiontext");
    nameofPanel.setWidth("70%");
    cssLayout.addComponent(nameofPanel);
}

From source file:org.escidoc.browser.ui.maincontent.ContainerView.java

License:Open Source License

private VerticalLayout buildVlResourceProperties() {
    // common part: create layout
    VerticalLayout vlResourceProperties = new VerticalLayout();
    vlResourceProperties.setImmediate(false);
    vlResourceProperties.setWidth("100.0%");
    vlResourceProperties.setHeight("100.0%");
    vlResourceProperties.setMargin(false);

    CssLayout cssLayout = new CssLayout();
    cssLayout.setWidth("100%");
    cssLayout.setHeight("100%");

    // creating the properties / without the breadcrump
    createProperties(cssLayout);//ww  w.j ava2s.c  o  m
    vlResourceProperties.addComponent(cssLayout);
    return vlResourceProperties;
}

From source file:org.escidoc.browser.ui.maincontent.ItemContent.java

License:Open Source License

private void buildPanelHeader(CssLayout cssLayout, String name) {
    cssLayout.addStyleName("v-accordion-item-caption v-caption v-captiontext");
    cssLayout.setWidth("100%");
    cssLayout.setMargin(false);/* w  w  w.  j  a  va2  s  .  c o m*/

    final Label nameofPanel = new Label(name, Label.CONTENT_RAW);
    nameofPanel.setStyleName("accordion v-captiontext");
    nameofPanel.setWidth("70%");
    cssLayout.addComponent(nameofPanel);

}

From source file:org.escidoc.browser.ui.maincontent.SearchAdvancedView.java

License:Open Source License

public SearchAdvancedView(final Router router, final EscidocServiceLocation serviceLocation) {
    this.router = router;
    this.serviceLocation = serviceLocation;
    setWidth("100.0%");
    setHeight("85%");
    setMargin(true);/*from   w  w w  .j  av  a  2s .c  om*/

    // CssLayout to hold the BreadCrumb
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setWidth("60%");
    cssLayout.setCaption("Advanced Search");
    // Css Hack * Clear Div
    final Label lblClear = new Label();
    lblClear.setStyleName("clear");

    txtTitle = new TextField();
    txtTitle.setInputPrompt("Title");
    txtTitle.setImmediate(false);
    txtDescription = new TextField();
    txtDescription.setInputPrompt("Description");
    txtDescription.setImmediate(false);
    // Clean Divs
    cssLayout.addComponent(lblClear);

    txtCreator = new TextField();
    txtCreator.setInputPrompt("Creator");
    txtCreator.setImmediate(false);
    // DatePicker for CreationDate
    creationDate = new PopupDateField();
    creationDate.setInputPrompt("Creation date");
    creationDate.setResolution(PopupDateField.RESOLUTION_DAY);
    creationDate.setImmediate(false);

    // Dropdown for MimeType
    final String[] mimetypes = new String[] { "application/octet-stream", "text/html", "audio/aiff",
            "video/avi", "image/bmp", "application/book", "text/plain", "image/gif", "image/jpeg", "audio/midi",
            "video/quicktime", "audio/mpeg", "application/xml", "text/xml" };
    mimes = new ComboBox();

    for (final String mimetype : mimetypes) {
        mimes.addItem(mimetype);
    }
    mimes.setInputPrompt("Mime Types");
    mimes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH);
    mimes.setImmediate(true);

    // Dropdown for Resource Type
    final String[] resourcearr = new String[] { "Context", "Container", "Item" };
    resource = new ComboBox();
    for (final String element : resourcearr) {
        resource.addItem(element);
    }
    resource.setInputPrompt("Resource Type");
    resource.setFilteringMode(Filtering.FILTERINGMODE_OFF);
    resource.setImmediate(true);

    txtFullText = new TextField();
    txtFullText.setInputPrompt("FullText");
    txtFullText.setImmediate(false);

    final Button bSearch = new Button("Search", this, "onClick");
    bSearch.setDescription("Search Tooltip");

    // Placing the elements in the design:
    txtTitle.setWidth("50%");
    txtTitle.setStyleName("floatleft paddingtop20 ");
    cssLayout.addComponent(txtTitle);

    txtDescription.setWidth("50%");
    txtDescription.setStyleName("floatright paddingtop20 ");
    cssLayout.addComponent(txtDescription);

    txtCreator.setWidth("50%");
    txtCreator.setStyleName("floatleft paddingtop20");
    cssLayout.addComponent(txtCreator);

    creationDate.setWidth("50%");
    creationDate.setStyleName("floatright");
    cssLayout.addComponent(creationDate);

    // Clean Divs
    cssLayout.addComponent(lblClear);

    mimes.setWidth("45%");
    mimes.setStyleName("floatleft");
    cssLayout.addComponent(mimes);

    resource.setWidth("45%");
    resource.setStyleName("floatright");
    cssLayout.addComponent(resource);

    txtFullText.setWidth("70%");
    txtFullText.setStyleName("floatleft");
    cssLayout.addComponent(txtFullText);

    bSearch.setStyleName("floatright");
    cssLayout.addComponent(bSearch);

    addComponent(cssLayout);
    this.setComponentAlignment(cssLayout, VerticalLayout.ALIGNMENT_HORIZONTAL_CENTER,
            VerticalLayout.ALIGNMENT_VERTICAL_CENTER);
}