Example usage for com.vaadin.ui Label getValue

List of usage examples for com.vaadin.ui Label getValue

Introduction

In this page you can find the example usage for com.vaadin.ui Label getValue.

Prototype

public String getValue() 

Source Link

Document

Gets the text shown in the label.

Usage

From source file:com.peergreen.webconsole.scope.logs.stream.TextColumnGenerator.java

License:Open Source License

/**
 * Generates the cell containing the Date value. The column is
 * irrelevant in this use case./*from  w w  w.  j av a  2s.  c  om*/
 */
@Override
public Component generateCell(Table source, Object itemId, Object columnId) {

    BeanItem<TableEntry> item = (BeanItem<TableEntry>) source.getItem(itemId);
    TableEntry tableEntry = item.getBean();
    Property<?> prop = item.getItemProperty(columnId);
    Label label = new Label();

    String text = item.getBean().getText().replaceAll(" ", "&nbsp;");

    if (StreamType.OUT.name().equals(item.getBean().getType()) || "INFO".equals(item.getBean().getType())) {
        label.setValue("<font color='black'>".concat(text).concat("</font>"));
    } else if (StreamType.ERR.name().equals(item.getBean().getType())
            || "ERROR".equals(item.getBean().getType())) {
        label.setValue("<font color='red'>".concat(text).concat("</font>"));
    } else if ("DEBUG".equals(item.getBean().getType())) {
        label.setValue("<font color='grey'>".concat(text).concat("</font>"));
    } else if ("WARNING".equals(item.getBean().getType())) {
        label.setValue("<font color='orange'>".concat(text).concat("</font>"));
    } else if ("SEVERE".equals(item.getBean().getType())) {
        label.setValue("<font color='red'>".concat(text).concat("</font>"));
    } else {
        label.setValue("<font color='black'>".concat(text).concat("</font>"));
    }

    label.setValue("<div style='font-family:Monaco, Menlo, Consolas, monospace;font-size:small;'>"
            .concat(label.getValue().concat("</div>")));

    label.setContentMode(ContentMode.HTML);
    return label;

}

From source file:com.philippefichet.vaadincdipush.view.FirstView.java

public void renameNewUser(String login, String newLogin) {
    for (int i = 0; i < listUserLayout.getComponentCount(); i++) {
        Label l = (Label) listUserLayout.getComponent(i);
        if (l.getValue().equals(login)) {
            l.setValue(newLogin);/*w  w  w  .j a  va2  s  . co  m*/
            break;
        }
    }
}

From source file:com.philippefichet.vaadincdipush.view.FirstView.java

public void removeUser(String login) {
    for (int i = 0; i < listUserLayout.getComponentCount(); i++) {
        Label l = (Label) listUserLayout.getComponent(i);
        if (l.getValue().equals(login)) {
            listUserLayout.removeComponent(l);
            break;
        }/*from  w  w  w .  ja  v a  2  s .co  m*/
    }
}

From source file:com.selzlein.lojavirtual.vaadin.core.NavigationMenu.java

License:Open Source License

/**
 * Adds menu separator item./* w w  w.j av a  2  s.  com*/
 * Possible to add number badge for this item for showing active to-dos for example.
 * 
 * @param titleKey
 * @param badgeValue number that will appear in upper right corner of menu item
 */
public void addMenuSeparator(String titleKey, Integer badgeValue) {
    Label label = new Label(ui.getMessage(titleKey), ContentMode.HTML);
    if (badgeValue != null) {
        label.setValue(label.getValue() + "<span class=\"valo-menu-badge\">" + badgeValue + "</span>");
    }
    label.setPrimaryStyleName("valo-menu-subtitle");
    label.addStyleName("h4");
    label.setSizeUndefined();
    mainMenu.addComponent(label);
}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private HorizontalLayout getPC() {

    VerticalLayout cAgentInfo = new VerticalLayout();
    final HorizontalLayout cPlaceholder = new HorizontalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, true, true, true));
    cAgentInfo.setStyleName("c_details_test");

    final VerticalLayout cLBody = new VerticalLayout();

    cLBody.setStyleName("c_body_visible");
    tb = new Table("Linked child accounts");
    // addLinksTable();

    final VerticalLayout cAllProf = new VerticalLayout();

    HorizontalLayout cProfActions = new HorizontalLayout();
    final FormLayout cProfName = new FormLayout();

    cProfName.setStyleName("frm_profile_name");
    cProfName.setSizeUndefined();// w w w .j  a v a  2s . c om

    final Label lbProf = new Label();
    final TextField tFProf = new TextField();

    lbProf.setCaption("Profile Name: ");
    lbProf.setValue("Certified Authorized User.");

    tFProf.setCaption(lbProf.getCaption());
    cProfName.addComponent(lbProf);

    final Button btnEdit = new Button();
    btnEdit.setIcon(FontAwesome.EDIT);
    btnEdit.setStyleName("btn_link");
    btnEdit.setDescription("Edit profile name");

    final Button btnCancel = new Button();
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");
    btnCancel.setDescription("Cancel Profile name editting.");

    Button btnAdd = new Button("+");
    // btnAdd.setIcon(FontAwesome.EDIT);
    btnAdd.setStyleName("btn_link");
    btnAdd.setDescription("Set new profile");

    Button btnRemove = new Button("-");
    // btnRemove.setIcon(FontAwesome.EDIT);
    btnRemove.setStyleName("btn_link");
    btnRemove.setDescription("Remove current profile");

    // cProf.addComponent(cProfName);
    cProfActions.addComponent(btnEdit);
    cProfActions.addComponent(btnCancel);
    cProfActions.addComponent(btnAdd);
    cProfActions.addComponent(btnRemove);

    btnCancel.setVisible(false);

    cAllProf.addComponent(cProfName);
    cAllProf.addComponent(cProfActions);
    cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER);

    cLBody.addComponent(cAllProf);

    // cLBody.addComponent(tb);

    tb.setSelectable(true);

    cAgentInfo.addComponent(cLBody);

    btnLink = new Button("Add New Link");
    btnLink.setIcon(FontAwesome.LINK);
    btnLink.setDescription("Link new account.");

    // cLBody.addComponent(btnLink);
    // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT);
    btnLink.addClickListener(new LinkClickHandler());

    cPlaceholder.setVisible(false);
    addLinkUserContainer();
    cPlaceholder.setWidth("100%");

    cLBody.addComponent(cPlaceholder);
    cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER);
    HorizontalLayout c = new HorizontalLayout();
    c.addComponent(cAgentInfo);

    btnEdit.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8427226211153164650L;

        @Override
        public void buttonClick(ClickEvent event) {

            if (btnEdit.getIcon().equals(FontAwesome.EDIT)) {

                tFProf.setValue(lbProf.getValue());
                tFProf.selectAll();
                cProfName.replaceComponent(lbProf, tFProf);
                btnEdit.setIcon(FontAwesome.SAVE);
                btnCancel.setVisible(true);
                return;

            } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) {

                lbProf.setValue(tFProf.getValue());
                cProfName.replaceComponent(tFProf, lbProf);
                btnEdit.setIcon(FontAwesome.EDIT);
                btnCancel.setVisible(false);

                return;
            }
            lbProf.setValue(tFProf.getValue());
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnCancel.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -2870045546205986347L;

        @Override
        public void buttonClick(ClickEvent event) {
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder));

    btnRemove.addClickListener(new RemoveProfileHandler(pop));

    return c;

}

From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java

License:Open Source License

void addTopLayout(Disease disease, Long casesCount, boolean isOutbreak) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setMargin(false);/*w  w w  .  j a v a  2s.  com*/
    layout.setSpacing(false);
    CssStyles.style(layout, CssStyles.getDiseaseColor(disease));
    layout.setHeight(75, Unit.PIXELS);
    layout.setWidth(100, Unit.PERCENTAGE);

    VerticalLayout nameAndOutbreakLayout = new VerticalLayout();
    nameAndOutbreakLayout.setMargin(false);
    nameAndOutbreakLayout.setSpacing(false);
    nameAndOutbreakLayout.setHeight(100, Unit.PERCENTAGE);
    nameAndOutbreakLayout.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout nameLayout = new HorizontalLayout();
    nameLayout.setMargin(false);
    nameLayout.setSpacing(false);
    nameLayout.setWidth(100, Unit.PERCENTAGE);
    nameLayout.setHeight(100, Unit.PERCENTAGE);
    Label nameLabel = new Label(disease.toShortString());
    CssStyles.style(nameLabel, CssStyles.LABEL_WHITE,
            nameLabel.getValue().length() > 12 ? CssStyles.LABEL_LARGE : CssStyles.LABEL_XLARGE,
            CssStyles.LABEL_BOLD, CssStyles.ALIGN_CENTER, CssStyles.LABEL_UPPERCASE);
    nameLayout.addComponent(nameLabel);
    nameLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_CENTER);
    nameAndOutbreakLayout.addComponent(nameLayout);
    nameAndOutbreakLayout.setExpandRatio(nameLayout, 1);

    if (isOutbreak) {
        HorizontalLayout outbreakLayout = new HorizontalLayout();
        outbreakLayout.setMargin(false);
        outbreakLayout.setSpacing(false);
        CssStyles.style(outbreakLayout, CssStyles.BACKGROUND_CRITICAL);
        outbreakLayout.setWidth(100, Unit.PERCENTAGE);
        outbreakLayout.setHeight(30, Unit.PIXELS);
        Label outbreakLabel = new Label(I18nProperties.getCaption(Captions.dashboardOutbreak));
        CssStyles.style(outbreakLabel, CssStyles.LABEL_WHITE, CssStyles.ALIGN_CENTER,
                CssStyles.LABEL_UPPERCASE);
        outbreakLayout.addComponent(outbreakLabel);
        outbreakLayout.setComponentAlignment(outbreakLabel, Alignment.MIDDLE_CENTER);
        nameAndOutbreakLayout.addComponent(outbreakLayout);
    }

    layout.addComponent(nameAndOutbreakLayout);
    layout.setExpandRatio(nameAndOutbreakLayout, 1);

    HorizontalLayout countLayout = new HorizontalLayout();
    countLayout.setMargin(false);
    countLayout.setSpacing(false);
    CssStyles.style(countLayout, CssStyles.getDiseaseColor(disease), CssStyles.BACKGROUND_DARKER);
    countLayout.setHeight(100, Unit.PERCENTAGE);
    countLayout.setWidth(100, Unit.PERCENTAGE);

    Label countLabel = new Label(casesCount.toString());
    CssStyles.style(countLabel, CssStyles.LABEL_WHITE, CssStyles.LABEL_BOLD, CssStyles.LABEL_XXXLARGE,
            CssStyles.ALIGN_CENTER);
    countLayout.addComponent(countLabel);
    countLayout.setComponentAlignment(countLabel, Alignment.MIDDLE_CENTER);

    layout.addComponent(countLayout);
    layout.setExpandRatio(countLayout, 0.65f);

    addComponent(layout);
}

From source file:de.symeda.sormas.ui.samples.SampleGridComponent.java

License:Open Source License

public SampleGridComponent(Label viewTitleLabel, AbstractView samplesView) {
    setSizeFull();/*from   ww w. ja  v a 2s  .  com*/
    setMargin(false);

    this.viewTitleLabel = viewTitleLabel;
    this.samplesView = samplesView;
    originalViewTitle = viewTitleLabel.getValue();

    criteria = ViewModelProviders.of(SamplesView.class).get(SampleCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);
    }

    grid = new SampleGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createShipmentFilterBar());
    gridLayout.addComponent(grid);
    grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());

    styleGridLayout(gridLayout);
    gridLayout.setMargin(true);

    addComponent(gridLayout);
}

From source file:de.symeda.sormas.ui.task.TaskGridComponent.java

License:Open Source License

public TaskGridComponent(Label viewTitleLabel, AbstractView tasksView) {
    setSizeFull();/*from w w  w  .j a  v  a2  s.co m*/
    setMargin(false);

    this.viewTitleLabel = viewTitleLabel;
    this.tasksView = tasksView;
    originalViewTitle = viewTitleLabel.getValue();

    criteria = ViewModelProviders.of(TasksView.class).get(TaskCriteria.class);

    grid = new TaskGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createAssigneeFilterBar());
    gridLayout.addComponent(grid);
    grid.getDataProvider().addDataProviderListener(e -> updateAssigneeFilterButtons());

    gridLayout.setMargin(true);
    styleGridLayout(gridLayout);

    addComponent(gridLayout);
}

From source file:de.uni_leipzig.informatik.pcai042.boa.gui.goldstandard.GoldstandardGUI.java

License:Open Source License

/**
 * The constructor should first build the main layout, set the composition
 * root and then do any custom initialization.
 * /*  w w w .  ja  v a 2s .c o  m*/
 * The constructor will not be automatically regenerated by the visual
 * editor.
 */
public GoldstandardGUI() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // user code

    for (Type t : BoaAnnotation.Type.values()) {
        comboBoxTypes.addItem(t);
    }
    comboBoxTypes.setTextInputAllowed(false);
    listSelectAnnotations.setMultiSelect(false);
    comboBoxTypes.setNullSelectionAllowed(false);
    listSelectAnnotations.setNullSelectionAllowed(false);

    // with this layout components will get wrapped
    cssLayoutTokens = new CssLayout() {
        @Override
        protected String getCss(Component c) {
            return "float:left;margin-right:5px;";
        }
    };
    cssLayoutTokens.setWidth("100%");
    // auto; becomes vertical scroll-able since verticalLayout_tokens height
    // is also auto
    cssLayoutTokens.setHeight(SIZE_UNDEFINED, 0);
    verticalLayoutTokens.addComponent(cssLayoutTokens);

    resetComponents();

    buttonNext.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (sentence != null) {
                SentenceServer.returnSentence(sentence);
            }

            resetComponents();
            sentence = SentenceServer.getSentence();

            if (sentence == null) {
                getWindow().showNotification("No more senentences.", Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            // create new check boxes for tokens
            CheckBox checkbox;
            Label label;
            VerticalLayout vertLayout;
            for (int i = 0; i < sentence.getTokens().size(); i++) {
                checkbox = new CheckBox();
                checkbox.setImmediate(true);
                checkbox.addListener(new Property.ValueChangeListener() {
                    public void valueChange(ValueChangeEvent event) {
                        Iterator<Component> iterator = cssLayoutTokens.getComponentIterator();
                        Label l;
                        CheckBox cb;
                        VerticalLayout vl;
                        String s = "";
                        while (iterator.hasNext()) {
                            vl = (VerticalLayout) iterator.next();
                            l = (Label) vl.getComponent(0);
                            cb = (CheckBox) vl.getComponent(1);
                            if (cb.booleanValue()) {
                                s += l.getValue();
                            }
                        }
                        if (s.isEmpty())
                            s = "";
                        textFieldLabel.setReadOnly(false);
                        textFieldLabel.setValue(s);
                        textFieldLabel.setReadOnly(true);
                    }
                });
                label = new Label(sentence.getTokens().get(i));
                label.setSizeUndefined();
                vertLayout = new VerticalLayout();
                vertLayout.addComponent(label);
                vertLayout.addComponent(checkbox);
                vertLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
                vertLayout.setComponentAlignment(checkbox, Alignment.MIDDLE_CENTER);
                vertLayout.setSizeUndefined();
                cssLayoutTokens.addComponent(vertLayout);
            }
        }
    });

    buttonDiscard.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (sentence != null) {
                SentenceServer.discardSentence(sentence);
                resetComponents();
            }
        }
    });

    buttonAddAnno.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (!textFieldLabel.getValue().equals("") && comboBoxTypes.getValue() != null) {
                Iterator<Component> iterator = cssLayoutTokens.getComponentIterator();
                Label l;
                CheckBox cb;
                VerticalLayout vl;
                ArrayList<String> selected = new ArrayList<String>();
                while (iterator.hasNext()) {
                    vl = (VerticalLayout) iterator.next();
                    l = (Label) vl.getComponent(0);
                    cb = (CheckBox) vl.getComponent(1);
                    if (cb.booleanValue()) {
                        selected.add((String) l.getValue());
                        cb.setValue(false);
                    }
                }
                BoaAnnotation anno = new BoaAnnotation((Type) comboBoxTypes.getValue(), selected);
                boolean isDuplicate = false;
                boolean isColliding = false;
                for (BoaAnnotation a : sentence.getAnnotations()) {
                    if (a.getTokens().size() == anno.getTokens().size()) {
                        boolean sameTokens = true;
                        for (int i = 0; i < a.getTokens().size(); i++) {
                            sameTokens = a.getTokens().get(i) == anno.getTokens().get(i);
                            if (!sameTokens)
                                break;
                        }
                        if (sameTokens) {
                            isColliding = !(isDuplicate = a.getType().equals(anno.getType()));
                            break;
                        }
                    }
                }
                if (isDuplicate) {
                    getWindow().showNotification("Duplicate was dismissed.", Notification.TYPE_WARNING_MESSAGE);
                } else if (isColliding) {
                    getWindow().showNotification("Label is already assigned to<br/> a different type.",
                            Notification.TYPE_ERROR_MESSAGE);
                } else {
                    sentence.getAnnotations().add(anno);
                    listSelectAnnotations.addItem(anno);
                }
            } else
                getWindow().showNotification("Label or type is inavlid.", Notification.TYPE_ERROR_MESSAGE);
        }
    });

    buttonDelAnno.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (listSelectAnnotations.getValue() != null) {
                sentence.getAnnotations().remove(listSelectAnnotations.getValue());
                listSelectAnnotations.removeItem(listSelectAnnotations.getValue());
            }
        }
    });
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java

License:Open Source License

void updateContentGraph() {
    Resource resource = getGraphResourceAndParseNewGraph();

    if (resource != null) {
        graphSectionContent.removeAllComponents();
        Image graphImage = new Image("", resource);

        graphSectionContent.addComponent(graphImage);
        graphSectionContent.setComponentAlignment(graphImage, Alignment.MIDDLE_CENTER);

    } else {// w w  w .  j a  va 2  s . c o m
        Label error = new Label("Project Graph can not be computed at that time for this project");
        error.setStyleName(ValoTheme.LABEL_FAILURE);
        graphSectionContent.removeAllComponents();
        graphSectionContent.addComponent(error);
        graphSectionContent.setComponentAlignment(error, Alignment.MIDDLE_CENTER);

        LOGGER.error(String.format("%s: %s", error.getValue(), currentBean.getId()));
    }
}