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:de.catma.ui.tagger.TaggerView.java

License:Open Source License

private void initComponents(Application application) {
    setSizeFull();//w  w  w  . java2s  . co m

    VerticalLayout taggerPanel = new VerticalLayout();

    taggerPanel.setSpacing(true);

    Label helpLabel = new Label();

    helpLabel.setIcon(new ClassResource("ui/resources/icon-help.gif", application));
    helpLabel.setWidth("20px");
    helpLabel.setDescription("<h3>Hints</h3>" + "<h4>Tag this Source Document</h4>"
            + "<ol><li>First you have to tell CATMA which Tagset you want to use. "
            + "Open a Tag Library from the Repository Manager and drag a Tagset to the \"Active Tagsets\" section.</li>"
            + "<li>Now you can mark the text sequence you want to tag.</li><li>Click the colored button of the desired Tag to apply it to the marked sequence.</li></ol> "
            + "When you click on a tagged text, i. e. a text that is underlined with colored bars, you should see "
            + "the available Tag Instances in the section on the lower right of this view.");
    pager = new Pager(taggerID, 80, 30);

    tagger = new Tagger(taggerID, pager, this);
    tagger.addStyleName("tagger");
    tagger.setWidth("550px");

    taggerPanel.addComponent(tagger);

    //      Panel actionPanel = new Panel(new HorizontalLayout());
    //      ((HorizontalLayout)actionPanel.getContent()).setSpacing(true);

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

    taggerPanel.addComponent(actionPanel);

    pagerComponent = new PagerComponent(pager, new PageChangeListener() {

        public void pageChanged(int number) {
            tagger.setPage(number);
        }
    });

    actionPanel.addComponent(helpLabel);

    actionPanel.addComponent(pagerComponent);

    btAnalyze = new Button("Analyze Document");
    btAnalyze.setEnabled(repository instanceof IndexedRepository);
    actionPanel.addComponent(btAnalyze);

    linesPerPageSlider = new Slider("page size zoom", 1, 100, "%");
    linesPerPageSlider.setImmediate(true);
    linesPerPageSlider.setWidth("150px");

    actionPanel.addComponent(linesPerPageSlider);

    markupPanel = new MarkupPanel(repository, new ColorButtonListener() {

        private boolean enabled = false;

        public void colorButtonClicked(TagDefinition tagDefinition) {
            if (enabled) {
                tagger.addTagInstanceWith(tagDefinition);
            } else {
                getWindow().showNotification(
                        "Information", "Please select a User Markup Collection "
                                + " to store your markup first!<br>" + "See 'Active Markup Collections'.",
                        Notification.TYPE_TRAY_NOTIFICATION);
            }
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
    }, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            boolean selected = evt.getNewValue() != null;
            @SuppressWarnings("unchecked")
            List<TagReference> tagReferences = (List<TagReference>) (selected ? evt.getNewValue()
                    : evt.getOldValue());

            tagger.setVisible(tagReferences, selected);
        }
    }, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            @SuppressWarnings("unchecked")
            Set<TagDefinition> removedTagDefinitions = (Set<TagDefinition>) evt.getOldValue();
            pager.removeTagInstances(removedTagDefinitions);
            tagger.setPage(pager.getCurrentPageNumber());
        }
    });

    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.addComponent(taggerPanel);
    splitPanel.addComponent(markupPanel);
    addComponent(splitPanel);
}

From source file:de.escidoc.admintool.view.EscidocPagedTable.java

License:Open Source License

public HorizontalLayout createControls() {
    // final Label itemsPerPageLabel = new Label("Items per page:");
    final Label pageLabel = new Label("Page:&nbsp;", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    final Label separatorLabel = new Label("&nbsp;/&nbsp;", Label.CONTENT_XHTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), Label.CONTENT_XHTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                @SuppressWarnings("boxing")
                final int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);/* www  .jav  a  2s . c  o  m*/
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("20px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    final HorizontalLayout controlBar = new HorizontalLayout();
    final HorizontalLayout pageSize = new HorizontalLayout();
    final HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button("<<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(0);
        }
    });
    final Button previous = new Button("<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(">", new ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        public void buttonClick(final ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(">>", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(BaseTheme.BUTTON_LINK);
    previous.setStyleName(BaseTheme.BUTTON_LINK);
    next.setStyleName(BaseTheme.BUTTON_LINK);
    last.setStyleName(BaseTheme.BUTTON_LINK);

    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth("100%");
    controlBar.setExpandRatio(pageSize, 1);
    addListener(new PageChangeListener() {
        @SuppressWarnings("boxing")
        public void pageChanged(final PagedTableChangeEvent event) {
            previous.setEnabled(true);
            next.setEnabled(true);
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(getTotalAmountOfPages());
        }
    });
    return controlBar;
}

From source file:de.escidoc.admintool.view.user.UserAddView.java

License:Open Source License

private Component createLayout(final String nameLabel, final AbstractTextField textField, final int leftMargin,
        final boolean required) {

    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(37, UNITS_PIXELS);//from  w  w  w  . jav a  2 s . com
    hor.addComponent(new Label(" "));

    final String text = Constants.P_ALIGN_RIGHT + nameLabel + Constants.P;
    Label l;
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setWidth(leftMargin + Constants.PX);

    if (required) {
        hor.addComponent(new Label("&nbsp;<span style=\"color:red; position:relative; top:13px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }
    hor.addComponent(textField);
    hor.setComponentAlignment(textField, Alignment.BOTTOM_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}

From source file:de.escidoc.admintool.view.user.UserAddView.java

License:Open Source License

private Component createLayout(final VerticalLayout build) {
    final HorizontalLayout hLayout = new HorizontalLayout();

    final Label textLabel = new Label(
            Constants.P_ALIGN_RIGHT + ViewConstants.ORGANIZATION_UNITS_LABEL + Constants.P,
            Label.CONTENT_XHTML);
    hLayout.addComponent(textLabel);/*from   w w w.j a  v  a2 s.  c  om*/
    textLabel.setSizeUndefined();
    textLabel.setWidth(111 + Constants.PX);

    hLayout.addComponent(textLabel);
    hLayout.addComponent(build);
    return hLayout;
}

From source file:de.escidoc.admintool.view.user.UserEditForm.java

License:Open Source License

private VerticalLayout createLayout(final String rolesLabel, final Table table, final int labelWidth,
        final int roleListHeight, final boolean b, final Button[] buttons) {

    final HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setHeight(roleListHeight + Constants.PX);
    hLayout.addComponent(new Label(" "));

    final Label textLabel = new Label(Constants.P_ALIGN_RIGHT + rolesLabel + "   " + Constants.P,
            Label.CONTENT_XHTML);
    textLabel.setSizeUndefined();// w w  w .j  a v  a 2  s .  c o  m
    textLabel.setWidth(labelWidth + Constants.PX);
    hLayout.addComponent(textLabel);
    hLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT);
    hLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    hLayout.addComponent(table);
    hLayout.setComponentAlignment(table, Alignment.MIDDLE_RIGHT);
    hLayout.addComponent(new Label(" &nbsp; ", Label.CONTENT_XHTML));

    final VerticalLayout vLayout = new VerticalLayout();
    vLayout.addComponent(hLayout);

    final HorizontalLayout hl = new HorizontalLayout();
    final Label la = new Label("&nbsp;", Label.CONTENT_XHTML);
    la.setSizeUndefined();
    la.setWidth(labelWidth + Constants.PX);
    hl.addComponent(la);

    for (final Button button : buttons) {
        hl.addComponent(button);
    }
    vLayout.addComponent(hl);
    hLayout.setSpacing(false);

    return vLayout;
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component.
 * //from   w w w  .  j  ava  2  s. c  o  m
 * @param label
 *            The label in front of the control.
 * @param comp
 *            The component to display.
 * @param width
 *            the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance.
 * @param required
 *            should it be marked with an asterisk.
 * @return The component in an horizontal layout. A blank in front and afterwards is inserted.
 */
public static synchronized HorizontalLayout create(final String label, final Component comp, final int width,
        final boolean required) {

    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(Constants.DEFAULT_HEIGHT);
    hor.addComponent(new Label(" "));

    final String text = Constants.P_ALIGN_RIGHT + label + Constants.P;
    Label l;
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setSizeUndefined();
    l.setWidth(width + Constants.PX);
    hor.setComponentAlignment(l, Alignment.BOTTOM_RIGHT);

    if (required) {
        hor.addComponent(new Label("&nbsp;<span style=\"color:red; position:relative; top:13px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }
    hor.addComponent(comp);
    hor.setComponentAlignment(comp, Alignment.BOTTOM_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component.
 * /*  w  w  w  .  j a  va  2s. co m*/
 * @param label
 *            The label in front of the control.
 * @param comp
 *            The component to display.
 * @param width
 *            the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance.
 * @param required
 *            should it be marked with an asterisk.
 * @return The component in an horizontal layout. A blank in front and afterwards is inserted.
 */
public static synchronized HorizontalLayout create(final String label, final CheckBox comp, final int width,
        final boolean required) {
    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(Constants.DEFAULT_HEIGHT);
    hor.addComponent(new Label(" "));
    final String text = Constants.P_ALIGN_RIGHT + label + Constants.P;
    Label l;
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setSizeUndefined();
    l.setWidth(width + Constants.PX);
    hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT);

    if (required) {
        hor.addComponent(new Label("&nbsp;<span style=\"color:red; position:relative; top:13px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }
    hor.addComponent(comp);
    hor.setComponentAlignment(comp, Alignment.BOTTOM_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component.
 * // w  w w.j  av a2s  .c om
 * @param label
 *            The label in front of the control.
 * @param comp
 *            The component to display.
 * @param width
 *            the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance.
 * @param height
 *            the height of the layout
 * @param required
 *            should it be marked with an asterisk.
 * @return The component in an horizontal layout. A blank in front and afterwards is inserted.
 */
public static synchronized HorizontalLayout create(final String label, final Component comp, final int width,
        final int height, final boolean required) {
    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(height + Constants.PX);
    hor.addComponent(new Label(" "));
    final String text = Constants.P_ALIGN_RIGHT + label + Constants.P;
    Label l;
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setSizeUndefined();
    l.setWidth(width + Constants.PX);
    hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT);

    if (required) {
        hor.addComponent(new Label(
                "&nbsp;<span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }
    hor.addComponent(comp);
    hor.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component.
 * //  w w  w . j  a v a2  s  .c o  m
 * @param label
 *            The label in front of the control.
 * @param comp
 *            The component to display.
 * @param labelWidth
 *            the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance.
 * @param height
 * @param required
 *            should it be marked with an asterisk.
 * @param buttons
 * @return The component in an horizontal layout. A blank in front and afterwards is inserted.
 */
public static synchronized VerticalLayout create(final String label, final Component comp, final int labelWidth,
        final int height, final boolean required, final Button[] buttons) {

    final HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSpacing(false);
    hLayout.setHeight(height + Constants.PX);
    hLayout.addComponent(new Label(" "));
    final Label textLabel = new Label(Constants.P_ALIGN_RIGHT + label + Constants.P, Label.CONTENT_XHTML);
    hLayout.addComponent(textLabel);
    textLabel.setSizeUndefined();
    textLabel.setWidth(labelWidth + Constants.PX);
    hLayout.setComponentAlignment(textLabel, Alignment.MIDDLE_RIGHT);

    if (required) {
        hLayout.addComponent(new Label(
                "&nbsp;<span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hLayout.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }
    hLayout.addComponent(comp);
    hLayout.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT);
    hLayout.addComponent(new Label(" &nbsp; ", Label.CONTENT_XHTML));

    final VerticalLayout vLayout = new VerticalLayout();
    vLayout.addComponent(hLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    vLayout.addComponent(buttonLayout);

    final Label la = new Label("&nbsp;", Label.CONTENT_XHTML);
    la.setSizeUndefined();
    la.setWidth(labelWidth + 7 + Constants.PX);

    buttonLayout.addComponent(la);
    for (final Button b : buttons) {
        buttonLayout.addComponent(b);
    }

    return vLayout;
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component.
 * // w  ww .j  a v  a 2 s .  c o  m
 * @param label
 *            The label in front of the control.
 * @param accordion
 *            The accordion to display.
 * @param width
 *            the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance.
 * @param height
 * @param required
 *            should it be marked with an asterisk.
 * @return The component in an horizontal layout. A blank in front and afterwards is inserted.
 */
public static synchronized HorizontalLayout create(final String label, final Accordion accordion,
        final int width, final int height, final boolean required) {
    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(height + Constants.PX);
    hor.addComponent(new Label(" "));
    final String text = Constants.P_ALIGN_RIGHT + label + Constants.P;
    Label l;
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setSizeUndefined();
    l.setWidth(width + Constants.PX);
    hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT);
    if (required) {
        hor.addComponent(new Label(
                "&nbsp;<span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }

    final Panel pan = new Panel();
    pan.setSizeFull();
    // Have it take all space available in the layout.
    accordion.setSizeFull();
    // Some components to put in the Accordion.

    final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n\t<X>\n\t\t<today>\n\t\t</today>\n\t\t<today/>\n\t\t<today/>\n\t</X>\n</root>";

    for (int i = 0; i < 30; i++) {
        accordion.addTab(new Label(xml, Label.CONTENT_PREFORMATTED), "Tab" + i, null);
    }

    pan.addComponent(accordion);
    // pan.setSizeUndefined();
    pan.setWidth(accordion.getWidth() + Constants.PX);
    // pan.setHeight("500px");
    pan.setStyleName(Reindeer.PANEL_LIGHT);
    hor.addComponent(pan);
    hor.setComponentAlignment(pan, Alignment.MIDDLE_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}