Example usage for com.vaadin.ui Label setValue

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

Introduction

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

Prototype

public void setValue(String value) 

Source Link

Document

Sets the text to be shown in the label.

Usage

From source file:it.vige.greenarea.bpm.custom.ui.form.DettaglioMissioneField.java

License:Apache License

public DettaglioMissioneField(FormProperty formProperty,
        GreenareaAbstractFormPropertyRenderer<T> greenareaAbstractFormPropertyRenderer, Missione missione) {
    I18nManager i18nManager = get().getI18nManager();
    String caption = i18nManager.getMessage(DETTAGLIO_MISSIONE_TITLE);
    setSpacing(true);//from  w w w  .j ava 2  s .com
    setCaption(caption);
    setHeight(Sizeable.SIZE_UNDEFINED, 0);
    Label missionIdLabel = new Label();
    missionIdLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_ID_MISSIONE) + " " + missione.getNome());
    missionIdLabel.setStyleName("missione_label");
    Label missionDateLabel = new Label();
    missionDateLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_DATA_MISSIONE) + " "
            + giornata.format(missione.getDataInizio()));
    missionDateLabel.setStyleName("missione_label");
    Label agencyCodeLabel = new Label();
    agencyCodeLabel.setValue(
            i18nManager.getMessage(DETTAGLIO_MISSIONE_CODICE_FILIALE) + " " + missione.getCodiceFiliale());
    agencyCodeLabel.setStyleName("missione_label");
    Label rankingLabel = new Label();
    rankingLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_RANKING));
    Embedded rankingImage = null;
    if (missione.getRanking() != null) {
        if (missione.getRanking().equals(VERDE))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_green.png"));
        else if (missione.getRanking().equals(GIALLO))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_orange.png"));
        else if (missione.getRanking().equals(ROSSO))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_red.png"));
        rankingImage.setWidth(20, UNITS_PIXELS);
        rankingImage.setStyleName("missione_label");
    }
    Label mobilityCreditLabel = new Label();
    mobilityCreditLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_CREDITO_DI_MOBILITA) + " "
            + missione.getCreditoMobilita());
    mobilityCreditLabel.setStyleName("missione_label");
    addComponent(missionIdLabel);
    addComponent(missionDateLabel);
    addComponent(agencyCodeLabel);
    addComponent(rankingLabel);
    if (rankingImage != null)
        addComponent(rankingImage);
    addComponent(mobilityCreditLabel);
    setStyleName("dettaglio-missione");

    policyDetailsButton = new Button();
    policyDetailsButton.setCaption(i18nManager.getMessage(DETTAGLIO_MISSIONE_BUTTON));
    final GreenareaAbstractFormPropertyRenderer<?> fGreenareaAbstractFormPropertyRenderer = greenareaAbstractFormPropertyRenderer;
    policyDetailsButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            fGreenareaAbstractFormPropertyRenderer.getGreenareaFormPropertiesForm().getSubmitFormButton()
                    .click();
        }
    });

    addComponent(policyDetailsButton);

    // Invisible textfield, only used as wrapped field
    wrappedField = new TextField();
    wrappedField.setVisible(false);
    addComponent(wrappedField);
}

From source file:it.vige.greenarea.bpm.custom.ui.form.DettaglioMissioneSTField.java

License:Apache License

public DettaglioMissioneSTField(FormProperty formProperty,
        GreenareaAbstractFormPropertyRenderer<T> greenareaAbstractFormPropertyRenderer, Missione missione) {
    I18nManager i18nManager = get().getI18nManager();
    String caption = i18nManager.getMessage(DETTAGLIO_MISSIONE_TITLE);
    setSpacing(true);//from  w w w .jav  a  2  s  .com
    setCaption(caption);
    setHeight(Sizeable.SIZE_UNDEFINED, 0);
    Label opLabel = new Label();
    opLabel.setValue(
            i18nManager.getMessage(DETTAGLIO_MISSIONE_OPERATORE_LOGISTICO) + " " + missione.getCompagnia());
    opLabel.setStyleName("missione_label");
    Label missionIdLabel = new Label();
    missionIdLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_ID_MISSIONE) + " " + missione.getNome());
    missionIdLabel.setStyleName("missione_label");
    Label missionDateLabel = new Label();
    missionDateLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_DATA_MISSIONE) + " "
            + giornata.format(missione.getDataInizio()));
    missionDateLabel.setStyleName("missione_label");
    Label agencyCodeLabel = new Label();
    agencyCodeLabel.setValue(
            i18nManager.getMessage(DETTAGLIO_MISSIONE_CODICE_FILIALE) + " " + missione.getCodiceFiliale());
    agencyCodeLabel.setStyleName("missione_label");
    Label rankingLabel = new Label();
    rankingLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_RANKING));
    Embedded rankingImage = null;
    if (missione.getRanking() != null) {
        if (missione.getRanking().equals(VERDE))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_green.png"));
        else if (missione.getRanking().equals(GIALLO))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_orange.png"));
        else if (missione.getRanking().equals(ROSSO))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_red.png"));
        rankingImage.setWidth(20, UNITS_PIXELS);
        rankingImage.setStyleName("missione_label");
    }
    Label mobilityCreditLabel = new Label();
    mobilityCreditLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_CREDITO_DI_MOBILITA) + " "
            + missione.getCreditoMobilita());
    mobilityCreditLabel.setStyleName("missione_label");
    addComponent(opLabel);
    addComponent(missionIdLabel);
    addComponent(missionDateLabel);
    addComponent(agencyCodeLabel);
    addComponent(rankingLabel);
    if (rankingImage != null)
        addComponent(rankingImage);
    addComponent(mobilityCreditLabel);
    setStyleName("dettaglio-missione");

    policyDetailsButton = new Button();
    policyDetailsButton.setCaption(i18nManager.getMessage(DETTAGLIO_MISSIONE_BUTTON));
    final GreenareaAbstractFormPropertyRenderer<?> fGreenareaAbstractFormPropertyRenderer = greenareaAbstractFormPropertyRenderer;
    policyDetailsButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            fGreenareaAbstractFormPropertyRenderer.getGreenareaFormPropertiesForm().getSubmitFormButton()
                    .click();
        }
    });

    addComponent(policyDetailsButton);

    // Invisible textfield, only used as wrapped field
    wrappedField = new TextField();
    wrappedField.setVisible(false);
    addComponent(wrappedField);
}

From source file:it.vige.greenarea.bpm.custom.ui.form.DettaglioMissioneTRField.java

License:Apache License

public DettaglioMissioneTRField(FormProperty formProperty,
        GreenareaAbstractFormPropertyRenderer<T> greenareaAbstractFormPropertyRenderer, Missione missione) {
    I18nManager i18nManager = get().getI18nManager();
    String caption = i18nManager.getMessage(DETTAGLIO_MISSIONE_TITLE);
    setSpacing(true);//from   ww w  .j a  v  a 2 s  . c o m
    setCaption(caption);
    setHeight(Sizeable.SIZE_UNDEFINED, 0);
    Label opLabel = new Label();
    opLabel.setValue(
            i18nManager.getMessage(DETTAGLIO_MISSIONE_OPERATORE_LOGISTICO) + " " + missione.getCompagnia());
    opLabel.setStyleName("missione_label");
    Label missionIdLabel = new Label();
    missionIdLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_ID_MISSIONE) + " " + missione.getNome());
    missionIdLabel.setStyleName("missione_label");
    Label missionDateLabel = new Label();
    missionDateLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_DATA_MISSIONE) + " "
            + giornata.format(missione.getDataInizio()));
    missionDateLabel.setStyleName("missione_label");
    Label agencyCodeLabel = new Label();
    agencyCodeLabel.setValue(
            i18nManager.getMessage(DETTAGLIO_MISSIONE_CODICE_FILIALE) + " " + missione.getCodiceFiliale());
    agencyCodeLabel.setStyleName("missione_label");
    Label rankingLabel = new Label();
    rankingLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_RANKING));
    Embedded rankingImage = null;
    if (missione.getRanking() != null) {
        if (missione.getRanking().equals(VERDE))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_green.png"));
        else if (missione.getRanking().equals(GIALLO))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_orange.png"));
        else if (missione.getRanking().equals(ROSSO))
            rankingImage = new Embedded(null, new ThemeResource("img/circle_red.png"));
        rankingImage.setWidth(20, UNITS_PIXELS);
        rankingImage.setStyleName("missione_label");
    }
    Label mobilityCreditLabel = new Label();
    mobilityCreditLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_CREDITO_DI_MOBILITA) + " "
            + missione.getCreditoMobilita());
    mobilityCreditLabel.setStyleName("missione_label");
    addComponent(opLabel);
    addComponent(missionIdLabel);
    addComponent(missionDateLabel);
    addComponent(agencyCodeLabel);
    addComponent(rankingLabel);
    if (rankingImage != null)
        addComponent(rankingImage);
    addComponent(mobilityCreditLabel);
    setStyleName("dettaglio-missione");

    policyDetailsButton = new Button();
    policyDetailsButton.setCaption(i18nManager.getMessage(DETTAGLIO_MISSIONE_BUTTON));
    final GreenareaAbstractFormPropertyRenderer<?> fGreenareaAbstractFormPropertyRenderer = greenareaAbstractFormPropertyRenderer;
    policyDetailsButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            fGreenareaAbstractFormPropertyRenderer.getGreenareaFormPropertiesForm().getSubmitFormButton()
                    .click();
        }
    });

    addComponent(policyDetailsButton);

    // Invisible textfield, only used as wrapped field
    wrappedField = new TextField();
    wrappedField.setVisible(false);
    addComponent(wrappedField);
}

From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaPagedTable.java

License:Apache License

@Override
public HorizontalLayout createControls() {
    I18nManager I18nManager = get().getI18nManager();
    final PagedTableContainer container = (PagedTableContainer) getContainerDataSource();
    Label itemsPerPageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PER_PAGINA));
    final ComboBox itemsPerPageSelect = new ComboBox();

    itemsPerPageSelect.addItem("3");
    itemsPerPageSelect.addItem("10");
    itemsPerPageSelect.addItem("25");
    itemsPerPageSelect.addItem("50");
    itemsPerPageSelect.setImmediate(true);
    itemsPerPageSelect.setNullSelectionAllowed(false);
    itemsPerPageSelect.setWidth("50px");
    itemsPerPageSelect.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue())));
        }/*w ww  .j a v a  2 s  .c om*/
    });
    itemsPerPageSelect.select(maxRecords + "");
    Label pageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PAG) + "&nbsp;", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    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(com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("20px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

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

        public void buttonClick(ClickEvent event) {
            setCurrentPage(0);
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    final Button previous = new Button("<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(ClickEvent event) {
            previousPage();
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    final Button next = new Button(">", new ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        public void buttonClick(ClickEvent event) {
            nextPage();
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    final Button last = new Button(">>", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
            if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) {
                Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()];
                GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm
                        .getComponent(1);
                FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0);
                FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent
                        .getRenderer(formProperty);
                greenareaFormPropertiesComponent.getForm()
                        .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId())
                        .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " "
                                + selectable.getValue());
            }
        }
    });
    first.setStyleName(Reindeer.BUTTON_LINK);
    previous.setStyleName(Reindeer.BUTTON_LINK);
    next.setStyleName(Reindeer.BUTTON_LINK);
    last.setStyleName(Reindeer.BUTTON_LINK);

    itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption");
    itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox");
    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");

    itemsPerPageLabel.addStyleName("pagedtable-label");
    itemsPerPageSelect.addStyleName("pagedtable-combobox");
    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.addComponent(itemsPerPageLabel);
    pageSize.addComponent(itemsPerPageSelect);
    pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT);
    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() {
        public void pageChanged(PagedTableChangeEvent event) {
            first.setEnabled(container.getStartIndex() > 0);
            previous.setEnabled(container.getStartIndex() > 0);
            next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(getTotalAmountOfPages());
            itemsPerPageSelect.setValue(String.valueOf(getPageLength()));
        }
    });
    controlBar.setStyleName("pagination");
    return controlBar;
}

From source file:it.vige.greenarea.bpm.custom.ui.LoginPanel.java

License:Apache License

private void initGuidonia() {
    HorizontalLayout panel = new HorizontalLayout();
    panel.setHeight(90, UNITS_PIXELS);/*from   w  w  w  .  ja va2s . c  o m*/
    Label title = new Label();
    title.addStyleName(LABEL_H1);
    title.setWidth(80, UNITS_PIXELS);

    if (get().getEnvironment().equals(ALFRESCO)) {
        title.addStyleName(STYLE_WORKFLOW_CONSOLE_LOGO);
    } else {
        title.addStyleName(STYLE_APPLICATION_MINI_GUIDONIA);
    }
    Label city = new Label();
    city.addStyleName(LABEL_H1);
    city.setValue(i18nManager.getMessage(GUIDONIA_TITLE));
    city.addStyleName(STYLE_APPLICATION_TITLE_GUIDONIA);
    city.setWidth(310, UNITS_PIXELS);

    panel.addComponent(title);
    panel.addComponent(city);

    sperimentazioni.addComponent(panel);
}

From source file:it.vige.greenarea.bpm.custom.ui.LoginPanel.java

License:Apache License

private void initLivorno() {
    HorizontalLayout panel = new HorizontalLayout();
    panel.setHeight(90, UNITS_PIXELS);//  www.ja  va 2s .c o m
    Label title = new Label();
    title.addStyleName(LABEL_H1);
    title.setWidth(80, UNITS_PIXELS);

    if (get().getEnvironment().equals(ALFRESCO)) {
        title.addStyleName(STYLE_WORKFLOW_CONSOLE_LOGO);
    } else {
        title.addStyleName(STYLE_APPLICATION_MINI_LIVORNO);
    }
    Label city = new Label();
    city.addStyleName(LABEL_H1);
    city.setValue(i18nManager.getMessage(LIVORNO_TITLE));
    city.addStyleName(STYLE_APPLICATION_TITLE_LIVORNO);
    city.setWidth(310, UNITS_PIXELS);

    panel.addComponent(title);
    panel.addComponent(city);

    sperimentazioni.addComponent(panel);
}

From source file:it.vige.greenarea.bpm.custom.ui.LoginPanel.java

License:Apache License

private void initPomezia() {
    HorizontalLayout panel = new HorizontalLayout();
    panel.setHeight(90, UNITS_PIXELS);//from   w  w w  .j  a v a2  s  .  com
    Label title = new Label();
    title.addStyleName(LABEL_H1);
    title.setWidth(80, UNITS_PIXELS);

    if (get().getEnvironment().equals(ALFRESCO)) {
        title.addStyleName(STYLE_WORKFLOW_CONSOLE_LOGO);
    } else {
        title.addStyleName(STYLE_APPLICATION_MINI_POMEZIA);
    }
    Label city = new Label();
    city.addStyleName(LABEL_H1);
    city.setValue(i18nManager.getMessage(POMEZIA_TITLE));
    city.addStyleName(STYLE_APPLICATION_TITLE_POMEZIA);
    city.setWidth(310, UNITS_PIXELS);

    panel.addComponent(title);
    panel.addComponent(city);

    sperimentazioni.addComponent(panel);
}

From source file:life.qbic.components.OfferGeneratorTab.java

License:Open Source License

/**
 * adds all the listeners to the offer generator tab
 * @param db: database instance to query
 * @param managerTabs: TabSheet holding the three tabs (Offer Generator, Offer Manager and Package Manager)
 * @param selectedProjectComboBox: ComboBox for selecting the project for the offer to generate
 * @param completeButton: button to complete the offer
 * @param addPackLayout: vertical layout which holds the twin select for selecting the packages, the package
 *                     description panel and the button to complete the offer
 * @param selectPackagesTwinColSelect: TwinSelect to select the packages for the current offer
 * @param packageDescriptionPanel: panel holding the descriptions labels for the selected packages
 * @param packageDescriptionLabel: label holding the description for the packages
 * @param twinColSelectFilter: text field for filtering the left side of the TwinColSelect
 *//*  w w  w . j a  v  a 2s.  c o  m*/
private static void addListeners(Database db, TabSheet managerTabs, ComboBox selectedProjectComboBox,
        Button completeButton, VerticalLayout addPackLayout, TwinColSelect selectPackagesTwinColSelect,
        Panel packageDescriptionPanel, Label packageDescriptionLabel, TextField twinColSelectFilter) {

    final float[] totalPrice = new float[1];
    final String[] descriptionText = new String[1];
    final String[][] offerGeneratorPackageNames = new String[1][1];
    final String[][] offerGeneratorPackageIds = new String[1][1];

    selectedProjectComboBox.addValueChangeListener(new Property.ValueChangeListener() {

        /**
         *
         */
        private static final long serialVersionUID = 6871999698387032993L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (selectedProjectComboBox.getValue() == null) {
                displayNotification("oO! No project selected!",
                        "Please select a project to proceed, otherwise we are going to have a situation here! ;)",
                        "error");
            } else {
                addPackLayout.addComponent(twinColSelectFilter);
                addPackLayout.addComponent(selectPackagesTwinColSelect);
                addPackLayout.addComponent(packageDescriptionPanel);
                addPackLayout.addComponent(completeButton);
            }
        }
    });

    selectPackagesTwinColSelect.addValueChangeListener(new Property.ValueChangeListener() {

        /**
         *
         */
        private static final long serialVersionUID = -5813954665588509117L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {

            // get the packages (package_id: package_name) as comma separated string and remove the leading and trailing bracket
            String selectedPackages = selectPackagesTwinColSelect.getValue().toString().substring(1);
            selectedPackages = selectedPackages.substring(0, selectedPackages.length() - 1);

            // in case there is no package selected, we do nothing
            if (selectedPackages.length() == 0) {
                return;
            }

            // init the arrays holding the package names and package ids
            offerGeneratorPackageNames[0] = selectedPackages.split(",");
            offerGeneratorPackageIds[0] = selectedPackages.split(",");

            // split the package id and the package name
            for (int i = 0; i < offerGeneratorPackageNames[0].length; i++) {
                offerGeneratorPackageIds[0][i] = offerGeneratorPackageIds[0][i].split(": ", 2)[0];
                offerGeneratorPackageNames[0][i] = offerGeneratorPackageNames[0][i].split(": ", 2)[1];
            }

            // TODO: value change listener does not trigger if the last element from the twin col select gets deselected
            System.out.println("packages in twin col select:");
            System.out.println(selectPackagesTwinColSelect.getValue());

            // there is a package for the current project, so we enable the complete offer button
            if (selectPackagesTwinColSelect.getValue() != null) {
                completeButton.setEnabled(true);
            } else {
                completeButton.setEnabled(false);
            }

            assert offerGeneratorPackageNames[0].length == offerGeneratorPackageIds[0].length;

            // iterate over all of the packages for the current offer and add their price and description to the view
            descriptionText[0] = "";
            totalPrice[0] = 0;
            for (int i = 0; i < offerGeneratorPackageNames[0].length; i++) {

                int currentPackageId = Integer.valueOf(offerGeneratorPackageIds[0][i].trim());

                // calculate the total offer price
                try {
                    totalPrice[0] += Float.parseFloat(db.getPriceFromPackageId(currentPackageId, "internal"));
                } catch (NullPointerException e) {
                    displayNotification("Package price is null!",
                            "The package price of the package " + offerGeneratorPackageIds[0][i] + ": "
                                    + offerGeneratorPackageNames[0][i] + " is null. Please remove the "
                                    + "package from the offer or update the "
                                    + "package price on the package manager tab. Otherwise "
                                    + "bad stuff is expected to happen..",
                            "error");
                }

                // get the description for the current package
                descriptionText[0] = descriptionText[0] + "<tr><td><p><b>" + offerGeneratorPackageIds[0][i]
                        + ": " + offerGeneratorPackageNames[0][i] + "</b><br>"
                        + db.getPackageDescriptionFromPackageId(currentPackageId)
                        + "</td><td align='right' valign='top'>"
                        + db.getPriceFromPackageId(currentPackageId, "internal") + "</td>" + "</p></tr>";

                // add the description and the total price to the view
                if (offerGeneratorPackageNames[0][i].length() != 0)
                    packageDescriptionLabel.setValue(
                            "<table width='100%'><tr><td><p style='color:red;'><b>Package Name and Description</b></p>"
                                    + "</td><td align='right'><p style='color:red;'><b>Price</b></p></td></tr><tr> </tr>"
                                    + descriptionText[0]
                                    + "<tr><td><p style='color:red;'><b>Grand Total</b> (excl. Taxes)</p></td><td align='right'>"
                                    + "<p style='color:red;'><b>" + totalPrice[0]
                                    + "</b></p></td></tr></table>");
                else
                    packageDescriptionLabel.setValue("No description available!");
            }
        }

    });

    completeButton.addClickListener(new Button.ClickListener() {

        /**
         *
         */
        private static final long serialVersionUID = 8181926819540586585L;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            // get some fields for the current offer
            String offerProjectReference = selectedProjectComboBox.getValue().toString();
            String dateToday = new SimpleDateFormat("yyyyMMdd").format(new Date());
            String offerNumber = dateToday + "_" + offerProjectReference;
            String offerFacility = db.getPIFromProjectRef(offerProjectReference);
            String offerName = db.getShortTitleFromProjectRef(offerProjectReference);
            String offerDescription = db.getLongDescFromProjectRef(offerProjectReference);

            // register the new offer in the database; NOTE: internal has no functionality anymore, so we simply set it to
            // true
            int offerId = db.registerNewOffer(offerNumber, offerProjectReference, offerFacility, offerName,
                    offerDescription, totalPrice[0], new Date(), "temp", true);

            // TODO: if a liferay instance is running uncomment this and remove the call to db.registerNewOffer above
            /*        offerId =
                        db.registerNewOffer(offerNumber, offerProjectReference, offerFacility, offerName,
                            offerDescription, totalPrice, dNow,
                            LiferayAndVaadinUtils.getUser().getScreenName(), externalPriceSelectedCheckBox.getValue());
                    */

            // iterate over the packages from the current offer and insert them also in the database
            for (String packageId : offerGeneratorPackageIds[0]) {
                int currentPackageId = Integer.valueOf(packageId);
                float packageUnitPrice = Float.valueOf(db.getPriceFromPackageId(currentPackageId, "internal"));
                db.insertOrUpdateOffersPackages(offerId, currentPackageId, packageUnitPrice);
            }

            displayNotification("Perfect! Offer successfully saved in the Database!",
                    "Next step is to modify, finalize and send it to the customer. Keep in mind that the "
                            + "description of the offer is still missing. Please go ahead and complete it. Fingers crossed!",
                    "success");

            // change view to offer manager
            managerTabs.setSelectedTab(1);
        }
    });
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileForbidden.java

License:Open Source License

public CoordMobileForbidden() {
    setSizeFull();//ww  w  .j a  v a2  s.  co  m
    Label forbiddenMessage = new Label();
    // forbiddenMessage.setContentMode(ContentMode.HTML);
    // forbiddenMessage.setValue("<h1>The following Messir operation is not allowed in this context</h1>");
    forbiddenMessage.setValue("The following Messir operation is not allowed in this context");
    forbiddenMessage.setSizeUndefined();
    addComponent(forbiddenMessage);
    setComponentAlignment(forbiddenMessage, Alignment.MIDDLE_CENTER);
}

From source file:lv.polarisit.demosidemenu.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*from w ww.  j ava 2s  .c  o  m*/
    menuItems.put("MessageView", "First Message");
    menuItems.put("MessageView1", "Second Message");
    /*
    menuItems.put("labels", "Labels");
    menuItems.put("buttons-and-links", "Buttons & Links");
    menuItems.put("textfields", "Text Fields");
    menuItems.put("datefields", "Date Fields");
    menuItems.put("comboboxes", "Combo Boxes");
    menuItems.put("selects", "Selects");
    menuItems.put("checkboxes", "Check Boxes & Option Groups");
    menuItems.put("sliders", "Sliders & Progress Bars");
    menuItems.put("colorpickers", "Color Pickers");
    menuItems.put("menubars", "Menu Bars");
    menuItems.put("trees", "Trees");
    menuItems.put("tables", "Tables");
    menuItems.put("dragging", "Drag and Drop");
    menuItems.put("panels", "Panels");
    menuItems.put("splitpanels", "Split Panels");
    menuItems.put("tabs", "Tabs");
    menuItems.put("accordions", "Accordions");
    menuItems.put("popupviews", "Popup Views");
    // menuItems.put("calendar", "Calendar");
    menuItems.put("forms", "Forms");
    */
    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    menu.addComponent(createThemeSelect());

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    /*
    final StringGenerator sg = new StringGenerator();
    final MenuItem settingsItem = settings.addItem(sg.nextString(true)
        + " " + sg.nextString(true) + sg.nextString(false),
        new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"),
        null);
            
    settingsItem.addItem("Edit Profile", null);
    settingsItem.addItem("Preferences", null);
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", null);
                */
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    Label label = null;
    int count = -1;
    for (final Entry<String, String> item : menuItems.entrySet()) {
        if (item.getKey().equals("labels")) {
            label = new Label("Components", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("panels")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Containers", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("forms")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Other", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        if (count == 2) {
            b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>");
        }
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        //            b.setIcon(testIcon.get());
        menuItemsLayout.addComponent(b);
        count++;
    }
    if (label != null)
        label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}