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:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);//from w  w  w.j a  va 2s .  c o m
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

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

License:Open Source License

private Layout getLabelPreviews() {
    Layout grid = getPreviewLayout("Labels");

    Label label = new Label("<h4>Paragraph Header</h4>Plain text, lorem ipsum dolor sit amet consectetur amit.",
            Label.CONTENT_XHTML);
    label.setWidth("200px");
    grid.addComponent(label);// www .j ava2s. c  o m

    label = new Label("Big plain text, lorem ipsum dolor sit amet consectetur amit.");
    label.setWidth("200px");
    label.setStyleName("big");
    grid.addComponent(label);

    label = new Label("Small plain text, lorem ipsum dolor sit amet consectetur amit.");
    label.setWidth("200px");
    label.setStyleName("small");
    grid.addComponent(label);

    label = new Label("Tiny plain text, lorem ipsum dolor sit amet consectetur amit.");
    label.setWidth("200px");
    label.setStyleName("tiny");
    grid.addComponent(label);

    label = new Label("<h1>Top Level Header</h1>", Label.CONTENT_XHTML);
    label.setSizeUndefined();
    grid.addComponent(label);
    label.setDescription(
            "Label.addStyleName(\"h1\");<br>or<br>new Label(\"&lt;h1&gt;Top Level Header&lt;/h1&gt;\", Label.CONTENT_XHTML);");

    label = new Label("<h2>Second Header</h2>", Label.CONTENT_XHTML);
    label.setSizeUndefined();
    grid.addComponent(label);
    label.setDescription(
            "Label.addStyleName(\"h2\");<br>or<br>new Label(\"&lt;h2&gt;Second Header&lt;/h2&gt;\", Label.CONTENT_XHTML);");

    label = new Label("<h3>Subtitle</h3>", Label.CONTENT_XHTML);
    label.setSizeUndefined();
    grid.addComponent(label);
    label.setDescription(
            "Label.addStyleName(\"h3\");<br>or<br>new Label(\"&lt;h3&gt;Subtitle&lt;/h3&gt;\", Label.CONTENT_XHTML);");

    label = new Label("<h4>Paragraph Header</h4>Plain text, lorem ipsum dolor sit amet consectetur amit.",
            Label.CONTENT_XHTML);
    label.setWidth("200px");
    label.setStyleName("color");
    grid.addComponent(label);

    label = new Label("Big plain text, lorem ipsum dolor sit amet consectetur amit.");
    label.setWidth("200px");
    label.setStyleName("big color");
    grid.addComponent(label);

    label = new Label("Small plain text, lorem ipsum dolor sit amet consectetur amit.");
    label.setWidth("200px");
    label.setStyleName("small color");
    grid.addComponent(label);

    label = new Label("Tiny plain text, lorem ipsum dolor sit amet consectetur amit.");
    label.setWidth("200px");
    label.setStyleName("tiny color");
    grid.addComponent(label);

    label = new Label("Top Level Header");
    label.setSizeUndefined();
    label.setStyleName("h1 color");
    grid.addComponent(label);

    label = new Label("Second Header");
    label.setSizeUndefined();
    label.setStyleName("h2 color");
    grid.addComponent(label);

    label = new Label("Subtitle");
    label.setSizeUndefined();
    label.setStyleName("h3 color");
    grid.addComponent(label);

    label = new Label("Warning text, lorem ipsum dolor sit.");
    label.setStyleName("warning");
    grid.addComponent(label);

    label = new Label("Error text, lorem ipsum dolor.");
    label.setStyleName("error");
    grid.addComponent(label);

    label = new Label("Big warning text");
    label.setStyleName("big warning");
    grid.addComponent(label);

    label = new Label("Big error text");
    label.setStyleName("big error");
    grid.addComponent(label);

    label = new Label("Loading text...");
    label.setStyleName("h3 loading");
    grid.addComponent(label);

    label = new Label("1");
    label.setSizeUndefined();
    label.addStyleName("numeral");
    label.addStyleName("green");
    grid.addComponent(label);

    label = new Label("2");
    label.setSizeUndefined();
    label.addStyleName("numeral");
    label.addStyleName("yellow");
    grid.addComponent(label);

    label = new Label("3");
    label.setSizeUndefined();
    label.addStyleName("numeral");
    label.addStyleName("blue");
    grid.addComponent(label);

    label = new Label("1");
    label.setSizeUndefined();
    label.addStyleName("numeral");
    label.addStyleName("green");
    label.addStyleName("big");
    grid.addComponent(label);

    label = new Label("2");
    label.setSizeUndefined();
    label.addStyleName("numeral");
    label.addStyleName("yellow");
    label.addStyleName("big");
    grid.addComponent(label);

    label = new Label("3");
    label.setSizeUndefined();
    label.addStyleName("numeral");
    label.addStyleName("blue");
    label.addStyleName("big");
    grid.addComponent(label);

    return grid;
}

From source file:nl.amc.biolab.nsg.display.component.DataElementForm.java

License:Open Source License

public void setDataElement(DataElement dataElement, List<NsgProperty> metadata) {
    if (dataElement == null) {
        return;//ww  w .  ja v a2  s  .c  om
    }

    removeAllComponents();

    setDataSource(dataElement);

    Map<String, String> fields = fieldService.getFieldHeaders(DataElement.class.getName());

    for (String k : fields.keySet()) {
        addLabelField(k, fields.get(k));
    }

    //metadata
    if (metadata != null) {
        Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);
        space.setWidth("100%");
        space.setHeight("10px");
        getLayout().addComponent(space);

        Table table = new Table();
        table.setWidth("100%");
        table.setHeight("360px");
        table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
        table.setSelectable(false);
        table.setCaption("properties");
        table.addContainerProperty("key", String.class, null);
        table.addContainerProperty("value", String.class, null);
        for (NsgProperty p : metadata) {
            table.addItem(new Object[] { p.getDescription(), p.getValue() }, p);
        }
        getLayout().addComponent(table);
    }
}

From source file:nl.amc.biolab.nsg.display.component.MainUI.java

License:Open Source License

private VerticalLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(false);/*from   www. j a  v a 2s  . c o  m*/
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    mainLayout.setMargin(false);
    mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // topPanel
    topPanel = buildTopPanel();
    mainLayout.addComponent(topPanel);
    mainLayout.setExpandRatio(topPanel, 1.0f);
    mainLayout.setComponentAlignment(topPanel, new Alignment(33));

    // horizontal rule
    Label hr = new Label("<hr/>", Label.CONTENT_XHTML);
    hr.addStyleName("horizontal-separator");
    hr.setWidth("100%");
    hr.setHeight("2px");
    mainLayout.addComponent(hr);
    mainLayout.setComponentAlignment(hr, new Alignment(33));

    // mainSplitPanel
    mainSplitPanel = buildMainSplitPanel();
    mainLayout.addComponent(mainSplitPanel);
    mainLayout.setExpandRatio(mainSplitPanel, 1.0f);

    return mainLayout;
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    final VaadinTestApplication app = (VaadinTestApplication) getApplication();
    logger.info("Getting attached to. Displaying " + processingStatus);
    final Processing processing = processingStatus.getProcessing();
    if (processingStatus == null || processing == null) {
        return;/*from w ww.  java  2s. co m*/
    }

    setDataSource(processingStatus);
    setData(processingStatus);
    logger.info("Continuing being attached to. Displaying " + processingStatus.getStatus() + " for "
            + processing.getDescription() + " with status " + processing.getStatus());

    removeAllComponents();

    addLabelField("processing.description", "Description");
    addLabelField("processing.date", "Creation date");
    final String processingUpdateDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
            .format(userDataService.getLastestUpdate(processing)); // when the status is last updated

    //dataelements
    if (processingStatus.getSubmissionIOs().size() != 0) {
        Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);
        space.setWidth("100%");
        space.setHeight("10px");
        getLayout().addComponent(space);
        submissionTable = new Table();
        submissionTable.setWidth("100%");
        submissionTable.setHeight("300px");
        submissionTable.setSelectable(true);
        submissionTable.setMultiSelect(true);
        submissionTable.setImmediate(true);
        submissionTable.addContainerProperty("input", Label.class, null);
        submissionTable.addContainerProperty("output", Label.class, null);
        submissionTable.addContainerProperty("view history", VerticalLayout.class, null);
        submissionTable.addContainerProperty("status", VerticalLayout.class, null);
        submissionTable.setColumnExpandRatio("input", 30f);
        submissionTable.setColumnExpandRatio("output", 20f);
        submissionTable.setColumnExpandRatio("view history", 20f);
        submissionTable.setColumnExpandRatio("status", 30f);

        for (Map<List<SubmissionIO>, List<SubmissionIO>> map : processingStatus.getSubmissionIOs()) {
            for (List<SubmissionIO> submissionIOinputs : map.keySet()) {
                if (submissionIOinputs.isEmpty()) {
                    logger.error("Skipping a submission with no inputs in processing: "
                            + processingStatus.getProcessing().getDbId());

                    continue;
                }

                //inputs
                StringBuffer inputValue = new StringBuffer();

                for (SubmissionIO submissionIOinput : submissionIOinputs) {
                    DataElement inputElement = submissionIOinput.getDataElement();

                    inputValue.append("<a href='" + userDataService.getDownloadURI(inputElement.getDbId())
                            + "' target='_blank'>" + inputElement.getName() + "</a><br />");
                }

                Label input = new Label(inputValue.toString(), Label.CONTENT_XHTML);
                input.setWidth("-1px");

                //outputs
                VerticalLayout historyLayout = new VerticalLayout();
                historyLayout.setWidth("100%");

                StringBuffer downloadValue = new StringBuffer();
                Label download = null;

                final List<SubmissionIO> outputs = map.get(submissionIOinputs);

                if (outputs.isEmpty()) {
                    download = new Label("No output available", Label.CONTENT_XHTML);
                } else {
                    for (SubmissionIO submissionIOoutput : outputs) {
                        final DataElement outputElement = submissionIOoutput.getDataElement();

                        if (submissionIOoutput.getDataElement().getExisting()) {
                            downloadValue.append("<a href='")
                                    .append(userDataService.getDownloadURI(outputElement.getDbId()))
                                    .append("' target='_blank'>download output</a><br />");
                        }

                        NativeButton viewHistoryButton = new NativeButton("history");

                        viewHistoryButton.addListener(new Button.ClickListener() {
                            private static final long serialVersionUID = 4280267926508263057L;

                            @Override
                            public void buttonClick(ClickEvent event) {
                                final String htmlContent = userDataService
                                        .getDataHistory(outputElement.getDbId());
                                showHTML(htmlContent, app);
                            }
                        });

                        historyLayout.addComponent(viewHistoryButton);
                    }

                    download = new Label(downloadValue.toString(), Label.CONTENT_XHTML);
                    download.setWidth("-1px");
                }

                // status
                VerticalLayout statusLayout = makeSubmissionStatusLayout(submissionIOinputs, processing, app);

                //add table item
                submissionTable.addItem(new Object[] { input, download, historyLayout, statusLayout }, null);
            }
        }

        getLayout().addComponent(submissionTable);
    }

    //total status
    Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);

    space.setWidth("100%");
    space.setHeight("10px");

    getLayout().addComponent(space);

    LabelField f = new LabelField();
    LabelField lastUpdateDateFieled = new LabelField();

    lastUpdateDateFieled.setLabelValue("<span style='font-size: 12px'><b>Last updated on:</b>&nbsp;</span>",
            processingUpdateDate);
    f.setLabelValue("<span style='font-size: 12px'><b>Overall status:</b>&nbsp;</span>",
            getStatus(processingStatus.getStatus(), null, false));

    getLayout().addComponent(f);
    getLayout().addComponent(lastUpdateDateFieled);
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

private VerticalLayout makeSubmissionStatusLayout(List<SubmissionIO> submissionIOinputs,
        final Processing processing, final VaadinTestApplication app) {
    StringBuffer statusValue = new StringBuffer();
    VerticalLayout statusLayout = new VerticalLayout();
    statusLayout.setWidth("100%");
    final Submission submission = submissionIOinputs.get(0).getSubmission(); // There is at least one input!
    //get status information
    String submissionStatus = submission.getLastStatus().getValue();
    logger.info("Status is " + submissionStatus);
    Date lastUpdateDate = processing.getDate();
    final Iterator<Status> iterator = submission.getStatuses().iterator();
    Status st = null;/* w ww  .  j  a va  2 s.  com*/
    while (iterator.hasNext()) {
        st = iterator.next();
    }
    if (st != null) {
        lastUpdateDate = st.getTimestamp();
    }
    String submissionUpdateDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(lastUpdateDate); // when the status is last updated

    nl.amc.biolab.datamodel.objects.Error error = null;
    List<nl.amc.biolab.datamodel.objects.Error> errors = submissionIOinputs.get(0).getSubmission().getErrors();

    if (submissionIOinputs.get(0).getSubmission().getErrors() != null
            && submissionIOinputs.get(0).getSubmission().getErrors().size() > 0) {
        error = errors.get(errors.size() - 1);
    }

    if (error != null) {
        logger.info("Error message is " + error.getMessage());
    }

    statusValue.append(getStatus(submissionStatus, error, userDataService.isNSGAdmin())).append("\n");

    logger.info(statusValue);

    createSubmissionButtons(app, submissionIOinputs.get(0), error);

    Label status = new Label(statusValue.toString(), Label.CONTENT_XHTML);
    status.setDescription("Last updated on " + submissionUpdateDate);
    status.setWidth("80%");

    String aborted = "Aborted";

    if (aborted.equals(submissionStatus)) {
        statusLayout.addComponent(status);
        statusLayout.addComponent(remarksButton);
    } else {
        statusLayout.addComponent(status);
    }

    return statusLayout;
}

From source file:nl.kpmg.lcm.ui.view.administration.components.RemoteLcmCreateWindow.java

License:Apache License

private HorizontalLayout createLayoutForLabel(Label label) {
    HorizontalLayout labelLayout = new HorizontalLayout();
    label.setWidth("70%");
    labelLayout.setWidth("100%");
    labelLayout.addStyleName("margin-top-10");
    labelLayout.addComponent(label);//from   ww w .j  a va 2 s. c om

    return labelLayout;
}

From source file:org.activiti.explorer.ui.management.deployment.DeploymentDetailPanel.java

License:Apache License

protected void addResourceLinks() {
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId());
    Collections.sort(resourceNames); // small nr of elements, so we can do it in-memory

    if (!resourceNames.isEmpty()) {
        Label resourceHeader = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_RESOURCES));
        resourceHeader.setWidth("95%");
        resourceHeader.addStyleName(ExplorerLayout.STYLE_H3);
        resourceHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
        addDetailComponent(resourceHeader);

        // resources
        VerticalLayout resourceLinksLayout = new VerticalLayout();
        resourceLinksLayout.setSpacing(true);
        resourceLinksLayout.setMargin(true, false, false, false);
        addDetailComponent(resourceLinksLayout);

        for (final String resourceName : resourceNames) {
            StreamResource.StreamSource streamSource = new StreamSource() {
                public InputStream getStream() {
                    return repositoryService.getResourceAsStream(deployment.getId(), resourceName);
                }//  w  w w  . j  a va2  s . c om
            };
            Link resourceLink = new Link(resourceName,
                    new StreamResource(streamSource, resourceName, ExplorerApp.get()));
            resourceLinksLayout.addComponent(resourceLink);
        }
    }
}

From source file:org.adho.dhconvalidator.ui.DHConvalidatorExample.java

@Override
protected void init(VaadinRequest request) {
    try {/*from w w w  . ja  v  a  2s  .  c  o m*/
        Messages.setLocaleProvider(VaadinSessionLocaleProvider.INSTANCE);

        VerticalLayout content = new VerticalLayout();
        content.setMargin(true);
        content.setSpacing(true);

        setContent(content);

        HeaderPanel headerPanel = new HeaderPanel(null);
        headerPanel.getBackLink().setVisible(false);

        content.addComponent(headerPanel);

        // prepare downloader for input file
        Button btGetInputfile = new Button(Messages.getString("DHConvalidatorExample.btInputCaption"));
        content.addComponent(btGetInputfile);

        FileDownloader inputFileDownloader = new FileDownloader(new StreamResource(new StreamSource() {

            @Override
            public InputStream getStream() {
                return Thread.currentThread().getContextClassLoader().getResourceAsStream(
                        "/org/adho/dhconvalidator/conversion/example/1_Digital_Humanities.odt");
            }
        }, "1_Digital_Humanities.odt"));
        inputFileDownloader.extend(btGetInputfile);

        // prepare downloader for output file
        Button btGetOutputfile = new Button(
                Messages.getString("DHConvalidatorExample.btConversionResultCaption"));
        content.addComponent(btGetOutputfile);

        FileDownloader outputFileDownloader = new FileDownloader(new StreamResource(new StreamSource() {

            @Override
            public InputStream getStream() {
                return Thread.currentThread().getContextClassLoader().getResourceAsStream(
                        "/org/adho/dhconvalidator/conversion/example/1_Digital_Humanities.dhc");
            }
        }, "1_Digital_Humanities.dhc"));
        outputFileDownloader.extend(btGetOutputfile);

        // setup visual feedback
        Label preview = new Label("", ContentMode.HTML);
        preview.addStyleName("tei-preview");
        preview.setWidth("800px");

        content.addComponent(preview);
        content.setComponentAlignment(preview, Alignment.MIDDLE_CENTER);

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();

        IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "/org/adho/dhconvalidator/conversion/example/1_Digital_Humanities.html"), buffer);

        preview.setValue(buffer.toString("UTF-8"));

        Page.getCurrent().setTitle(Messages.getString("DHConvalidatorExample.title"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.adho.dhconvalidator.ui.ServiceSelectionPanel.java

/** Setup UI. */
private void initComponents() {
    User user = (User) VaadinSession.getCurrent().getAttribute(SessionStorageKey.USER.name());
    if (user.isAdmin()) {
        UserSwitchPanel userSwitchPanel = new UserSwitchPanel();
        addCenteredComponent(userSwitchPanel, Alignment.TOP_RIGHT);
    }/*w w w  . ja v  a 2 s.co  m*/

    Label infoLabel = new Label(Messages.getString("ServiceSelectionPanel.intro"), ContentMode.HTML);
    infoLabel.setWidth("600px");
    addCenteredComponent(infoLabel);

    VerticalLayout option1Panel = new VerticalLayout();
    option1Panel.setSpacing(true);
    option1Panel.setMargin(new MarginInfo(true, false, true, false));
    addCenteredComponent(option1Panel);

    Label option1Label = new Label(Messages.getString("ServiceSelectionPanel.option1Info"), ContentMode.HTML);
    option1Panel.addComponent(option1Label);

    btTemplateGeneration = new Button(Messages.getString("ServiceSelectionPanel.option1"));
    option1Panel.addComponent(btTemplateGeneration);

    VerticalLayout option2Panel = new VerticalLayout();
    option2Panel.setSpacing(true);
    addCenteredComponent(option2Panel);

    Label option2Label = new Label(Messages.getString("ServiceSelectionPanel.option2Info"), ContentMode.HTML);
    option2Panel.addComponent(option2Label);

    btConversion = new Button(Messages.getString("ServiceSelectionPanel.option2"));
    option2Panel.addComponent(btConversion);

    VerticalLayout option3Panel = new VerticalLayout();
    option3Panel.setSpacing(true);
    option3Panel.setMargin(new MarginInfo(true, false, true, false));
    addCenteredComponent(option3Panel);

    Label option3Label = new Label(Messages.getString("ServiceSelectionPanel.option3Info"), ContentMode.HTML);
    option3Panel.addComponent(option3Label);

    btConfTool = new Button(Messages.getString("ServiceSelectionPanel.option3"));
    option3Panel.addComponent(btConfTool);
}