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(float width, Unit unit) 

Source Link

Usage

From source file:org.vaadin.arborgraph.demo.DemoApplication.java

License:Open Source License

private Label getHelpLabel(String help) {
    Label retval = new Label();

    retval.addStyleName("help");
    retval.setDescription(help);/*from   w w  w.  j  a va 2s .  c  o  m*/
    retval.setWidth(18, Sizeable.UNITS_PIXELS);
    retval.setHeight(18, Sizeable.UNITS_PIXELS);

    return retval;
}

From source file:org.vaadin.tori.component.AuthoringComponent.java

License:Apache License

private void updateAttachmentList() {
    attachmentsLayout.removeAllComponents();
    attachmentsLayout.setVisible(!attachments.isEmpty());
    for (final Entry<String, byte[]> entry : attachments.entrySet()) {
        final String fileName = entry.getKey();
        final int fileSize = entry.getValue().length;
        final String caption = String.format("%s (%s KB)", fileName, fileSize / 1024);

        final Label nameComponent = new Label();
        nameComponent.addStyleName("namelabel");
        nameComponent.setValue(caption);
        nameComponent.setWidth(300.0f, Unit.PIXELS);
        try {/*from   w ww.  j  a v a  2  s  . c  o  m*/
            nameComponent.addStyleName(fileName.substring(fileName.lastIndexOf(".") + 1));
        } catch (final IndexOutOfBoundsException e) {
            // NOP
        }

        final HorizontalLayout wrapperLayout = new HorizontalLayout();
        wrapperLayout.addStyleName("filerow");
        wrapperLayout.addComponent(nameComponent);

        final Label deleteLabel = new Label();
        deleteLabel.addStyleName("deleteattachment");

        wrapperLayout.addComponent(deleteLabel);
        wrapperLayout.addLayoutClickListener(new LayoutClickListener() {
            @Override
            public void layoutClick(final LayoutClickEvent event) {
                if (event.getChildComponent() == deleteLabel) {
                    attachments.remove(entry.getKey());
                    updateAttachmentList();
                }
            }
        });

        attachmentsLayout.addComponent(wrapperLayout);

    }
}

From source file:org.vaadin.tori.component.RecentBar.java

License:Apache License

private void addTitleLabel(final HorizontalLayout barLayout) {
    Label headingLabel = ComponentUtil.getHeadingLabel("MOST RECENT", HeadingLevel.H4);
    headingLabel.setWidth(110.0f, Unit.PIXELS);
    barLayout.addComponent(headingLabel);
    barLayout.setComponentAlignment(headingLabel, Alignment.MIDDLE_LEFT);
}

From source file:ru.codeinside.gses.webui.form.GridForm.java

License:Mozilla Public License

void buildControls(final FieldTree.Entry entry, int level) {
    switch (entry.type) {
    case ITEM://from   w  w w .j  a  v a  2 s .  c  om
    case BLOCK:
        if (!entry.readable)
            break; // ?   ? ? ?,       
        if (isNotBlank(entry.caption)) {
            Label caption = new Label(entry.caption);
            caption.setStyleName("right");
            if (entry.type == FieldTree.Type.BLOCK) {
                caption.addStyleName("bold");
            }
            caption.setWidth(300, UNITS_PIXELS);
            caption.setHeight(100, UNITS_PERCENTAGE);
            gridLayout.addComponent(caption, level, entry.index, valueColumn - 1, entry.index);
            gridLayout.setComponentAlignment(caption, Alignment.TOP_RIGHT);
        }
        final Component sign = entry.sign;
        if (sign != null) {
            gridLayout.addComponent(sign, valueColumn + 1, entry.index);
            gridLayout.setComponentAlignment(sign, Alignment.TOP_LEFT);
            if (!entry.readOnly) {
                entry.field.addListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(Property.ValueChangeEvent event) {
                        entry.field.removeListener(this);
                        gridLayout.removeComponent(sign);
                        entry.sign = null;
                    }
                });
            }
        }
        // ???  
        addField(entry.path, entry.field);
        break;
    case CONTROLS:
        HorizontalLayout layout = new HorizontalLayout();
        layout.setImmediate(true);
        layout.setSpacing(true);
        layout.setMargin(false, false, true, false);
        Button plus = createButton("+");
        Button minus = createButton("-");
        layout.addComponent(plus);
        layout.addComponent(minus);
        FieldTree.Entry block = getBlock(entry);
        plus.addListener(new AppendAction(entry, minus));
        minus.addListener(new RemoveAction(entry, plus));
        if (block.field != null) {
            final StringBuilder sb = new StringBuilder();
            if (!isBlank(block.caption)) {
                sb.append(' ').append('\'').append(block.caption).append('\'');
            }
            if (block.field.getDescription() != null) {
                sb.append(' ').append('(').append(block.field.getDescription()).append(')');
            }
            plus.setDescription("" + sb);
            minus.setDescription("" + sb);
        }
        updateCloneButtons(plus, minus, block);
        gridLayout.addComponent(layout, valueColumn, entry.index, valueColumn, entry.index);
        break;
    case CLONE:
        int y = entry.index;
        int dy = entry.getControlsCount() - 1;
        Label cloneCaption = new Label(entry.cloneIndex + ")");
        cloneCaption.setWidth(20, UNITS_PIXELS);
        cloneCaption.setStyleName("right");
        cloneCaption.addStyleName("bold");
        gridLayout.addComponent(cloneCaption, level - 1, y, level - 1, y + dy);
        gridLayout.setComponentAlignment(cloneCaption, Alignment.TOP_RIGHT);
        break;
    case ROOT:
        break;
    default:
        throw new IllegalStateException(
                "??? ?  ? " + entry.type);
    }

    if (entry.items != null) { //  ?  ?
        if (entry.type == FieldTree.Type.BLOCK) {
            level++;
        }
        for (FieldTree.Entry child : entry.items) {
            buildControls(child, level);
        }
    }
}

From source file:VaadinIRC.GUI.channelGUI.java

License:Open Source License

/**
 * Adds standard channel message to the channel textarea. Repaints the panel and scrolls to bottom.
 * @param username Message sender's nickname.
 * @param newMessage Message to be sent.
 *//*from  w w w. j av  a2  s.  c o m*/
public void addStandardChannelMessage(String username, String newMessage) {
    channelMessages++;
    if (channelMessages > settings.MAX_CHANNEL_MESSAGES) {
        panelMessages.removeAllComponents();
        channelMessages = 0;
    }

    newMessage = IRCHelper.removeTags(newMessage);
    newMessage = IRCHelper.convertURLsToHTMLLinks(newMessage);
    newMessage = IRCHelper.formatIRCTextToHTML(newMessage);

    Label label = new Label(IRCHelper.getTimestamp(false) + "<b>" + username + "</b> " + newMessage);
    label.setContentMode(Label.CONTENT_RAW);
    label.setWidth(550, Sizeable.UNITS_PIXELS);
    panelMessages.addComponent(label);

    // Scroll messages panel to bottom message
    panelMessages.setScrollTop(Short.MAX_VALUE);
    panelMessages.requestRepaint();

    ircInterface.setNewActivityToTab(channelName);
    ircInterface.pushChangesToClient();
}

From source file:VaadinIRC.GUI.channelGUI.java

License:Open Source License

/**
 * Adds new message to the channel textarea, repaints the panel and scrolls to bottom.
 * @param newMessage Message to be added.
 *//*  www .java2 s.c om*/
public void addMessageToChannelTextarea(String newMessage) {
    channelMessages++;
    if (channelMessages > settings.MAX_CHANNEL_MESSAGES) {
        panelMessages.removeAllComponents();
        System.out.println("Removing all labels!!!");
        channelMessages = 0;
    }

    newMessage = IRCHelper.removeTags(newMessage);
    newMessage = IRCHelper.convertURLsToHTMLLinks(newMessage);

    Label label = new Label(IRCHelper.getTimestamp(false) + newMessage);
    label.setContentMode(Label.CONTENT_RAW);
    label.setWidth(100, Sizeable.UNITS_PERCENTAGE);
    panelMessages.addComponent(label);

    // Scroll messages panel to bottom message
    panelMessages.setScrollTop(Short.MAX_VALUE);
    panelMessages.requestRepaint();

    ircInterface.setNewActivityToTab(channelName);
    ircInterface.pushChangesToClient();
}