Example usage for com.vaadin.ui Label addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:fi.semantum.strategia.widget.Tag.java

License:Open Source License

public static void updateRelatedTags(final Main main, boolean canWrite) {

    final Database database = main.getDatabase();

    final Base base = main.getUIState().currentItem;

    Collection<Tag> tags = base.getRelatedTags(database);
    if (!tags.isEmpty() || canWrite) {

        HorizontalLayout tagHeader = new HorizontalLayout();
        tagHeader.setSpacing(true);//from  w ww  .ja v  a2s.  c om

        Label header2 = new Label("Aihetunnisteet");
        header2.setHeight("32px");
        header2.addStyleName(ValoTheme.LABEL_HUGE);
        header2.addStyleName(ValoTheme.LABEL_BOLD);
        tagHeader.addComponent(header2);
        tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER);

        if (canWrite) {
            final Image editTags = new Image("", new ThemeResource("tag_blue_edit.png"));
            editTags.setHeight("24px");
            editTags.setWidth("24px");
            editTags.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = -6140867347404571880L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editTags);
                    Utils.editTags(main, "Muokkaa aihetunnisteita", main.getUIState().currentItem);
                }

            });
            tagHeader.addComponent(editTags);
            tagHeader.setComponentAlignment(editTags, Alignment.BOTTOM_CENTER);
        }

        main.properties.addComponent(tagHeader);
        main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER);

        HorizontalLayout divider = new HorizontalLayout();
        main.properties.addComponent(divider);
        main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER);

        VerticalLayout left = new VerticalLayout();
        left.setSpacing(true);
        left.setWidth("400px");
        left.setMargin(true);
        divider.addComponent(left);
        VerticalLayout right = new VerticalLayout();
        right.setSpacing(true);
        right.setWidth("400px");
        right.setMargin(true);
        divider.addComponent(right);

        Set<Tag> monitoredTags = getMonitoredTags(database, base);

        int i = 0;
        for (final Tag tag : tags) {

            final boolean monitor = base.hasMonitorTag(database, tag);
            String tagId = tag.getId(database);

            HorizontalLayout hl = new HorizontalLayout();
            hl.setSpacing(true);
            hl.setHeight("37px");

            Button tagButton = Utils.tagButton(database, "list", tagId, i++);
            left.addComponent(tagButton);
            left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT);

            if (canWrite) {
                Button b = new Button();
                b.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                b.setIcon(FontAwesome.TIMES_CIRCLE);
                b.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = -4473258383318654850L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        base.removeRelatedTags(database, tag);
                        Utils.loseFocus(main.properties);
                        Updates.update(main, true);
                    }

                });
                hl.addComponent(b);
                hl.setComponentAlignment(b, Alignment.MIDDLE_LEFT);
            }

            if (base instanceof Strategiakartta) {

                Button tagButton2 = new Button();
                tagButton2.setCaption(monitor ? "Seurataan toteutuksessa" : "Ei seurata toteutuksessa");
                tagButton2.addStyleName(monitor ? "greenButton" : "redButton");
                tagButton2.addStyleName(ValoTheme.BUTTON_SMALL);
                tagButton2.setWidth("200px");
                if (canWrite) {
                    tagButton2.addClickListener(new ClickListener() {

                        private static final long serialVersionUID = -1769769368034323594L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            if (monitor) {
                                base.removeMonitorTags(database, tag);
                            } else {
                                base.assertMonitorTags(database, tag);
                            }
                            Utils.loseFocus(main.properties);
                            Updates.update(main, true);
                        }

                    });
                    tagButton2.setEnabled(true);
                } else {
                    tagButton2.setEnabled(false);
                }

                hl.addComponent(tagButton2);
                hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT);

            } else {

                if (monitoredTags.contains(tag)) {
                    Label l = new Label(" toteuttaa seurattavaa aihetta ");
                    hl.addComponent(l);
                    hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);
                }

            }

            right.addComponent(hl);
            right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT);

        }

    }

}

From source file:fi.semantum.strategia.widget.Tag.java

License:Open Source License

public static void updateMonitoredTags(final Main main, boolean canWrite) {

    final Database database = main.getDatabase();

    final Base base = main.getUIState().currentItem;

    if (!(base instanceof Tavoite || base instanceof Painopiste))
        return;/*from  w ww  . j  a va2s.  c  om*/

    Set<Tag> monitoredTags = getMonitoredTags(database, base);
    monitoredTags.removeAll(base.getRelatedTags(database));
    Map<String, Base> implementors = new HashMap<String, Base>();
    for (Base impl : Utils.getImplementationSet(database, base)) {
        for (Tag i : impl.getRelatedTags(database)) {
            if (monitoredTags.contains(i)) {
                implementors.put(i.uuid, impl);
            }
        }
    }

    if (!monitoredTags.isEmpty() || canWrite) {

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

        Label header2 = new Label("Seurattavat aihetunnisteet");
        header2.setHeight("32px");
        header2.addStyleName(ValoTheme.LABEL_HUGE);
        header2.addStyleName(ValoTheme.LABEL_BOLD);
        tagHeader.addComponent(header2);
        tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER);

        main.properties.addComponent(tagHeader);
        main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER);

        HorizontalLayout divider = new HorizontalLayout();
        main.properties.addComponent(divider);
        main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER);

        VerticalLayout left = new VerticalLayout();
        left.setSpacing(true);
        left.setWidth("400px");
        left.setMargin(true);
        divider.addComponent(left);
        VerticalLayout right = new VerticalLayout();
        right.setSpacing(true);
        right.setWidth("400px");
        right.setMargin(true);
        divider.addComponent(right);

        int i = 0;
        for (final Tag tag : monitoredTags) {

            String tagId = tag.getId(database);

            HorizontalLayout hl = new HorizontalLayout();
            hl.setSpacing(true);
            hl.setHeight("37px");

            Button tagButton = Utils.tagButton(database, "inferred", tagId, i++);
            left.addComponent(tagButton);
            left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT);

            Base implementor = implementors.get(tag.uuid);
            if (implementor != null) {

                String desc = implementor.getId(database);
                if (desc.isEmpty())
                    desc = implementor.getText(database);

                Label tagLabel = new Label("Toteutetaan ylemmll tasolla: " + desc);
                hl.addComponent(tagLabel);
                hl.setComponentAlignment(tagLabel, Alignment.MIDDLE_LEFT);

            } else {

                Button tagButton2 = new Button();
                tagButton2.setCaption("Merkitse toteuttajaksi");
                tagButton2.addStyleName("redButton");
                tagButton2.addStyleName(ValoTheme.BUTTON_SMALL);
                tagButton2.setWidth("200px");
                if (canWrite) {
                    tagButton2.addClickListener(new ClickListener() {

                        private static final long serialVersionUID = -1769769368034323594L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            base.assertRelatedTags(database, tag);
                            Utils.loseFocus(main.properties);
                            Updates.update(main, true);
                        }

                    });
                    tagButton2.setEnabled(true);
                } else {
                    tagButton2.setEnabled(false);
                }
                hl.addComponent(tagButton2);
                hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT);

            }

            right.addComponent(hl);
            right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT);

        }

    }

}

From source file:fr.amapj.view.engine.basicform.BasicFormListPart.java

License:Open Source License

private void buildMainArea() {

    createColumn();//from w  w w .ja v  a 2s. c o  m

    // Create a persistent person container
    listPartContainer = new BeanItemContainer(getClazz());
    onPopupClose();

    // Add a nested property to a many-to-one property
    for (ColumnInfo colInfo : colInfos) {
        if (colInfo.isNested()) {
            listPartContainer.addNestedContainerProperty(colInfo.propertyId);
        }
    }

    // Set up sorting if the natural order is not appropriate
    listPartContainer.sort(orderByInfo, new boolean[] { true, true });

    // Bind it to a component
    beanTable = createTable(listPartContainer);

    // Gestion de la liste des colonnes visibles
    List<String> colNames = new ArrayList<String>();
    for (ColumnInfo colInfo : colInfos) {
        colNames.add(colInfo.propertyId);
    }
    beanTable.setVisibleColumns(colNames.toArray());

    // Gestion des titres de colonnes
    for (ColumnInfo colInfo : colInfos) {
        beanTable.setColumnHeader(colInfo.propertyId, colInfo.title);
    }

    beanTable.setSelectable(true);
    beanTable.setImmediate(true);

    // Activation au desactivation des boutons delete et edit
    beanTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            setModificationsEnabled(event.getProperty().getValue() != null);
        }

        private void setModificationsEnabled(boolean b) {
            Long id = IdentifiableUtil.getIdOfSelectedItem(beanTable);
            if ((id != null) && (b == true) && (isAccessAllowed(id) == false)) {
                b = false;
            }

            deleteButton.setEnabled(b);
            editButton.setEnabled(b);
            enableSpecificButton(b);
        }
    });

    beanTable.setSizeFull();

    beanTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                beanTable.select(event.getItemId());
            }
        }
    });

    HorizontalLayout toolbar = new HorizontalLayout();

    Label title = new Label(getListPartTitle());
    title.setSizeUndefined();
    title.addStyleName("stdlistpart-text-title");

    newButton = new Button("Ajouter");
    newButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleAjouter();
        }
    });
    newButton.addStyleName(ChameleonTheme.BUTTON_BIG);

    deleteButton = new Button("Supprimer");
    deleteButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleSupprimer();

        }
    });
    deleteButton.setEnabled(false);
    deleteButton.addStyleName(ChameleonTheme.BUTTON_BIG);

    editButton = new Button("Editer");
    editButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleEditer();

        }
    });
    editButton.setEnabled(false);
    editButton.addStyleName(ChameleonTheme.BUTTON_BIG);

    searchField = new TextField();
    searchField.setInputPrompt(getListPartInputPrompt());
    searchField.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            textFilter = event.getText();
            updateFilters();
        }
    });
    searchField.addStyleName(ChameleonTheme.TEXTFIELD_BIG);
    searchField.setWidth("50%");

    toolbar.addComponent(newButton);
    toolbar.addComponent(deleteButton);
    toolbar.addComponent(editButton);
    addSpecificButton(toolbar);
    toolbar.addComponent(searchField);
    toolbar.setWidth("100%");
    toolbar.setExpandRatio(searchField, 1);
    toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);

    setMargin(true);
    setSpacing(true);

    addComponent(title);
    addComponent(toolbar);
    Component c = getExtraComponent();
    if (c != null) {
        addComponent(c);
    }

    addComponent(beanTable);
    setExpandRatio(beanTable, 1);
    setSizeFull();

}

From source file:fr.amapj.view.engine.excelgenerator.TelechargerPopup.java

License:Open Source License

protected void createContent(VerticalLayout contentLayout) {

    contentLayout.addStyleName("popup-telecharger");

    Label l = new Label("Veuillez cliquer sur le lien du fichier que vous souhaitez tlcharger");
    l.addStyleName("titre");
    contentLayout.addComponent(l);/* ww  w.ja va2  s . co  m*/

    // Calcul des liens
    List<CoreGenerator> gs = new ArrayList<CoreGenerator>();
    for (Item item : items) {
        if (item.generator != null) {
            gs.add(item.generator);
        }
    }
    List<FileInfoDTO> fileInfoDTOs = new CoreGeneratorService().getFileInfo(gs);

    // Affichage 
    int i = 0;
    for (Item item : items) {
        if (item.generator != null) {
            FileInfoDTO fileInfoDTO = fileInfoDTOs.get(i);
            addLink(contentLayout, fileInfoDTO);
            i++;
        } else {
            Label lab = new Label(item.label, ContentMode.HTML);
            lab.addStyleName("separateur");
            contentLayout.addComponent(lab);
        }
    }
}

From source file:fr.amapj.view.engine.grid.booleangrid.PopupBooleanGrid.java

License:Open Source License

private void constructHeaderLine(VerticalLayout mainLayout, GridHeaderLine line) {
    HorizontalLayout header1 = new HorizontalLayout();
    if (line.height != -1) {
        header1.setHeight(line.height + "px");
    }/*from  w ww. j  a  v  a2s. c  o m*/

    int index = 0;
    for (String str : line.cells) {
        Label dateLabel = new Label(str);
        dateLabel.setSizeFull();
        if (line.styleName != null) {
            dateLabel.addStyleName(line.styleName);
        }

        if (index == 0) {
            dateLabel.setWidth((param.largeurCol + 5) + "px");
        } else {
            dateLabel.setWidth((param.largeurCol + 2) + "px");
        }

        header1.addComponent(dateLabel);
        index++;

    }
    mainLayout.addComponent(header1);
}

From source file:fr.amapj.view.engine.grid.booleangrid.PopupBooleanGrid.java

License:Open Source License

private void addRow(int lig) {
    List<Object> cells = new ArrayList<Object>();

    Label dateLabel = new Label(param.leftPartLine.get(lig));
    dateLabel.addStyleName("big");
    dateLabel.addStyleName("align-center");
    dateLabel.setWidth(param.largeurCol + "px");
    cells.add(dateLabel);//from ww  w.  ja  v  a  2s .c  o  m

    if (param.leftPartLine2 != null) {
        dateLabel = new Label(param.leftPartLine2.get(lig));
        dateLabel.addStyleName("big");
        dateLabel.addStyleName("align-center");
        dateLabel.setWidth(param.largeurCol + "px");
        cells.add(dateLabel);
    }

    for (int j = 0; j < param.nbCol; j++) {
        boolean box = param.box[lig][j];

        CheckBox checkbox = new CheckBox();
        checkbox.setValue(box);
        checkbox.addStyleName("align-center");
        checkbox.addStyleName("big");
        checkbox.setWidth((param.largeurCol - 10) + "px");
        cells.add(checkbox);
    }

    table.addItem(cells.toArray(), new Integer(lig));

}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

protected void createContent(VerticalLayout mainLayout) {
    setType(PopupType.CENTERFIT);/*  ww  w.  j a  v a  2  s  .  c om*/
    loadParam();

    if (param.messageSpecifique != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique);
        messageSpeLabel.addStyleName("popup-currency-vector-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    if (param.messageSpecifique2 != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique2, ContentMode.HTML);
        messageSpeLabel.addStyleName("popup-currency-vector-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    if (param.messageSpecifique3 != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique3, ContentMode.HTML);
        messageSpeLabel.addStyleName("popup-currency-vector-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    if (param.avoirInitial != 0) {
        // Footer 1 avec le montant total des paiements
        HorizontalLayout footer1 = new HorizontalLayout();
        footer1.setWidth("350px");
        fillFooter(footer1, "Avoir initial", param.avoirInitial);

        // Footer 2 pour avoir un espace
        HorizontalLayout footer2 = new HorizontalLayout();
        footer2.setWidth("200px");
        footer2.setHeight("20px");

        mainLayout.addComponent(footer1);
        mainLayout.addComponent(footer2);
    }

    // Construction des headers
    for (GridHeaderLine line : param.headerLines) {
        constructHeaderLine(mainLayout, line);
    }

    // Construction de la table de saisie
    table = new Table();
    table.addStyleName("no-vertical-lines");
    table.addStyleName("no-horizontal-lines");
    table.addStyleName("no-stripes");

    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);

    // Colonne de gauche contenant un libell
    table.addContainerProperty(new Integer(-1), Label.class, null);
    table.setColumnWidth(new Integer(-1), param.largeurCol);

    // colonne de droite correspondant  la saisie des quantites
    Class clzz;
    if (param.readOnly) {
        clzz = Label.class;
    } else {
        clzz = TextField.class;
    }
    table.addContainerProperty(new Integer(0), clzz, null);
    table.setColumnWidth(new Integer(0), param.largeurCol);

    // Convertion du vecteur en un tableau
    boolean[][] excluded = new boolean[param.excluded.length][1];
    for (int i = 0; i < param.excluded.length; i++) {
        excluded[i][0] = param.excluded[i];
    }

    if (param.readOnly == false) {
        shortCutManager = new ShortCutManager(param.nbLig, 1, excluded);
        shortCutManager.addShorcut(this.getWindow());
    }

    // Creation de toutes les cellules pour la saisie
    for (int i = 0; i < param.nbLig; i++) {
        addRow(i);
    }

    if (param.readOnly) {
        table.setEditable(false);
    } else {
        table.setEditable(true);
    }
    table.setSelectable(true);
    table.setSortEnabled(false);
    table.setPageLength(getPageLength());

    // Footer 0 pour avoir un espace
    HorizontalLayout footer0 = new HorizontalLayout();
    footer0.setWidth("200px");
    footer0.setHeight("20px");

    // Construction globale
    mainLayout.addComponent(table);
    mainLayout.addComponent(footer0);

    if ((param.readOnly == true) || (param.computeLastLine == false)) {
        // Footer 1 avec le montant total des paiements
        HorizontalLayout footer1 = new HorizontalLayout();
        footer1.setWidth("350px");
        montantTotalPaiement = fillFooter(footer1, "Montant total paiements", getMontantTotalPaiement());

        // Footer 2 pour avoir un espace
        HorizontalLayout footer2 = new HorizontalLayout();
        footer2.setWidth("200px");
        footer2.setHeight("20px");

        // Footer 3 avec le prix total du contrat
        HorizontalLayout footer3 = new HorizontalLayout();
        footer3.setWidth("350px");
        fillFooter(footer3, "Montant total d", param.montantCible);

        mainLayout.addComponent(footer1);
        mainLayout.addComponent(footer2);
        mainLayout.addComponent(footer3);
    } else {
        // Footer 1 avec le prix total
        HorizontalLayout footer1 = new HorizontalLayout();
        footer1.setWidth("350px");
        fillFooter(footer1, "Montant total  rgler", param.montantCible);
        mainLayout.addComponent(footer1);
    }
}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

private Label fillFooter(HorizontalLayout footer1, String message, int montantCible) {

    Label dateLabel = new Label(message);
    dateLabel.addStyleName("prix");
    dateLabel.setSizeFull();/*from  w w w.  j  av  a 2  s  .  co m*/
    footer1.addComponent(dateLabel);
    footer1.setExpandRatio(dateLabel, 1.0f);

    Label prixTotal = new Label(new CurrencyTextFieldConverter().convertToString(montantCible));
    prixTotal.addStyleName("prix");
    prixTotal.setSizeFull();
    footer1.addComponent(prixTotal);
    footer1.setExpandRatio(prixTotal, 1.0f);

    return prixTotal;
}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

private void constructHeaderLine(VerticalLayout mainLayout, GridHeaderLine line) {
    HorizontalLayout header1 = new HorizontalLayout();
    header1.setWidth(getLargeurTotal());
    if (line.height != -1) {
        header1.setHeight(line.height + "px");
    }//from  w  w  w. j a v a 2s.co  m

    for (String str : line.cells) {
        Label dateLabel = new Label(str);
        if (line.styleName != null) {
            dateLabel.addStyleName(line.styleName);
        }
        header1.addComponent(dateLabel);
        dateLabel.setSizeFull();
        header1.setExpandRatio(dateLabel, 1.0f);
    }
    mainLayout.addComponent(header1);
}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

private void addRow(int lig) {
    List<Object> cells = new ArrayList<Object>();

    Label dateLabel = new Label(param.leftPartLine.get(lig));
    dateLabel.addStyleName("date-saisie");
    dateLabel.setWidth(param.largeurCol + "px");

    cells.add(dateLabel);/* w  ww.  j  a v  a 2s. c  om*/

    int qte = param.montant[lig];
    boolean isExcluded = isExcluded(lig);

    if (param.readOnly) {
        //
        String txt;

        if (isExcluded) {
            txt = "XXXXXX";
        } else if (qte == 0) {
            txt = "";
        } else {
            txt = "" + new CurrencyTextFieldConverter().convertToString(qte);
        }
        Label tf = new Label(txt);
        tf.addStyleName("cell-voir");
        tf.setWidth((param.largeurCol - 10) + "px");
        cells.add(tf);
    } else {
        if (isExcluded) {
            TextField tf = new TextField();
            tf.setValue("XXXXXX");
            tf.setEnabled(false);
            tf.addStyleName("cell-voir");
            tf.setWidth((param.largeurCol - 10) + "px");
            cells.add(tf);
        } else {
            //
            // Si derniere ligne : on  autorise les nombres ngatifs (sauf si on en mode de saisie de la dernire ligne)
            boolean allowNegativeNumber = (lig == param.nbLig - 1) && (param.computeLastLine == true);
            final TextField tf = BaseUiTools.createCurrencyField("", allowNegativeNumber);
            tf.setData(new GridIJData(lig, 0));
            tf.setConvertedValue(new Integer(qte));
            tf.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    try {
                        updateModele();
                    } catch (ErreurSaisieException e) {
                        NotificationHelper.displayNotificationMontant();
                    }
                }
            });

            tf.addStyleName("cell-saisie");
            tf.setWidth((param.largeurCol - 10) + "px");
            shortCutManager.registerTextField(tf);
            cells.add(tf);

            // Si derniere ligne : on desactive la saisie , sauf si pas de recalcul
            if ((lig == param.nbLig - 1) && (param.computeLastLine == true)) {
                tf.setEnabled(false);
                lastLineTextField = tf;
            }
        }

    }

    table.addItem(cells.toArray(), new Integer(lig));

}