Example usage for com.vaadin.ui ComboBox ComboBox

List of usage examples for com.vaadin.ui ComboBox ComboBox

Introduction

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

Prototype

public ComboBox() 

Source Link

Document

Constructs an empty combo box without a caption.

Usage

From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java

private ComboBox getClusterCombo() {
    clusterCombo = new ComboBox();
    clusterCombo.setId("ClusterCb");
    clusterCombo.setImmediate(true);//  w  w w. j a va2 s.c  o  m
    clusterCombo.setTextInputAllowed(false);
    clusterCombo.setWidth(200, Sizeable.Unit.PIXELS);
    clusterCombo.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            accumuloClusterConfig = (AccumuloClusterConfig) event.getProperty().getValue();
            refreshUI();
        }
    });
    return clusterCombo;
}

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())));
        }//from w w w.j ava  2 s  . c o  m
    });
    itemsPerPageSelect.select(maxRecords + "");
    Label pageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PAG) + " ", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    Label separatorLabel = new Label(" / ", 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:jp.primecloud.auto.ui.DialogConfirm.java

License:Open Source License

public DialogConfirm(String caption, String message, Buttons buttons, Layout optionLayout) {
    super(caption);

    setModal(true);/*from   w w w  . j a  v a2s.  c om*/
    setResizable(false);
    setClosable(false);
    setWidth("380px");
    addStyleName("dialog-confirm");
    setIcon(Icons.DLGWARNING.resource());

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setWidth("100%");
    layout.setMargin(false, true, false, true);
    layout.setSpacing(false);

    if (message != null && message.length() > 0) {

        // ?"\n"?"\t"???????"PREFORMATTED"??
        Label lbl;
        if (message.indexOf("\n") != -1 || message.indexOf("\t") != -1) {
            lbl = new Label(message, Label.CONTENT_PREFORMATTED);
        } else {
            lbl = new Label(message, Label.CONTENT_TEXT);
        }
        lbl.addStyleName("dialog-message");
        layout.addComponent(lbl);
    }

    // ????
    if (optionLayout != null) {
        optionLayout.addStyleName("dialog-confirm-option");
        addComponent(optionLayout);
        layout.setComponentAlignment(optionLayout, Alignment.MIDDLE_CENTER);
    }

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

    // 
    okButton = new Button(ViewProperties.getCaption("button.ok"), this, "buttonClick");
    okButton.setDescription(ViewProperties.getCaption("description.ok"));
    okButton.setData(Result.OK);
    // [Enter]?okButton
    okButton.setClickShortcut(KeyCode.ENTER);
    okButton.focus();

    cancelButton = new Button(ViewProperties.getCaption("button.cancel"), this, "buttonClick");
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.setData(Result.Cancel);

    switch (buttons) {
    case OK:
        hl.addComponent(okButton);
        break;
    case OKCancel:
        hl.addComponent(okButton);
        hl.addComponent(cancelButton);
        break;
    case OKCancelConfirm:
        hl.addComponent(okButton);
        hl.addComponent(cancelButton);
        okButton.setEnabled(false);

        confirm = new ComboBox();
        confirm.setWidth("200px");
        confirm.setImmediate(true);
        confirm.addStyleName("dialog-confirm");
        confirm.setInputPrompt(ViewProperties.getCaption("description.dialogConfirmComboBox"));
        confirm.addItem(ViewProperties.getCaption("field.dialogConfirmComboBox"));
        confirm.addListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                if (confirm.getValue() != null) {
                    okButton.setEnabled(true);
                } else {
                    okButton.setEnabled(false);
                }
            }
        });
        layout.addComponent(confirm);
        layout.setComponentAlignment(confirm, Alignment.MIDDLE_CENTER);
        break;
    default:
        break;
    }

    layout.addComponent(hl);
    layout.setComponentAlignment(hl, Alignment.BOTTOM_CENTER);
}

From source file:me.uni.emuseo.view.exhibits.form.ExhibitCategoryFieldBuilder.java

License:Open Source License

@Override
public Field<?> build(String propertyId) {
    if (propertyId.equals(categoryPropertyId)) {
        ComboBox comboBox = new ComboBox();
        comboBox.setNullSelectionAllowed(false);
        comboBox.addItems(items);//from  ww  w. j a  va  2  s.com
        for (CategoryDTO categoryDTO : items) {
            comboBox.setItemCaption(categoryDTO, categoryDTO.getName());
        }
        return comboBox;
    }
    return null;
}

From source file:me.uni.emuseo.view.settings.form.UserDetailsFieldBuilder.java

License:Open Source License

@Override
public Field<?> build(String propertyId) {
    if ("theme".equals(propertyId)) {
        ComboBox comboBox = new ComboBox();
        comboBox.setNullSelectionAllowed(true);

        List<String> availableThemes = EMuseoUtil.getAvailableThemes();
        for (String theme : availableThemes) {
            comboBox.addItem(theme);/*from   w  ww .j  av  a 2 s .co m*/
            // comboBox.setItemCaption("emuseo-theme", "E-museo");
        }
        return comboBox;
    } else if ("language".equals(propertyId)) {
        ComboBox comboBox = new ComboBox();
        comboBox.setNullSelectionAllowed(false);
        comboBox.addItem("pl");
        return comboBox;
    }
    return null;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getSelectPreviews() {
    Layout grid = getPreviewLayout("Selects");

    ComboBox combo = new ComboBox();
    addSelectItems(combo, true, 100);/*from  w ww .java 2s. c o  m*/
    grid.addComponent(combo);

    combo = new ComboBox();
    addSelectItems(combo, true, 100);
    combo.setStyleName("small");
    grid.addComponent(combo);

    combo = new ComboBox();
    addSelectItems(combo, true, 100);
    combo.setStyleName("big");
    grid.addComponent(combo);

    combo = new ComboBox();
    addSelectItems(combo, false, 5);
    combo.setStyleName("search");
    combo.setInputPrompt("Search combo");
    grid.addComponent(combo);

    combo = new ComboBox();
    addSelectItems(combo, false, 5);
    combo.setStyleName("small search");
    combo.setInputPrompt("Small search combo");
    grid.addComponent(combo);

    combo = new ComboBox();
    addSelectItems(combo, false, 5);
    combo.setStyleName("big search");
    combo.setInputPrompt("Big search combo");
    grid.addComponent(combo);

    NativeSelect s = new NativeSelect();
    addSelectItems(s, true, 10);
    grid.addComponent(s);

    s = new NativeSelect();
    addSelectItems(s, true, 10);
    s.setStyleName("small");
    grid.addComponent(s);

    s = new NativeSelect();
    addSelectItems(s, true, 10);
    s.setStyleName("big");
    grid.addComponent(s);

    combo = new ComboBox();
    addSelectItems(combo, false, 5);
    combo.setInputPrompt("Just click me");
    combo.setStyleName("select-button");
    // Must always specify width
    combo.setWidth("150px");
    grid.addComponent(combo);
    combo.setDescription(combo.getDescription()
            + "<br><strong>You must always specify an explicit width for a combobox with this style, otherwise it will not work</strong>");

    return grid;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java

License:Apache License

private Component getConfigurableTab() {
    VerticalLayout vl = new VerticalLayout();
    ComboBox options = new ComboBox();
    options.addItem(ISSUE_TYPE);//from   www .  j ava 2 s.c  om
    options.setItemCaption(ISSUE_TYPE, TRANSLATOR.translate(ISSUE_TYPE));
    options.addItem(ISSUE_RESOLUTION);
    options.setItemCaption(ISSUE_RESOLUTION, TRANSLATOR.translate(ISSUE_RESOLUTION));
    options.addItem(REQUIREMENT_TYPE);
    options.setItemCaption(REQUIREMENT_TYPE, TRANSLATOR.translate(REQUIREMENT_TYPE));
    options.setTextInputAllowed(false);
    options.addValueChangeListener((Property.ValueChangeEvent event) -> {
        Component nextComp = null;
        if (options.getValue() != null) {
            switch ((String) options.getValue()) {
            case ISSUE_TYPE:
                nextComp = displayIssueTypes();
                break;
            case ISSUE_RESOLUTION:
                nextComp = displayIssueResolutions();
                break;
            case REQUIREMENT_TYPE:
                nextComp = displayRequirementTypes();
                break;
            default:
                //Do nothing
            }
        }
        if (nextComp != null) {
            vl.removeAllComponents();
            vl.addComponent(options);
            vl.addComponent(nextComp);
        }
    });
    vl.addComponent(options);
    vl.setSizeFull();
    return vl;
}

From source file:org.activiti.explorer.ui.process.simple.editor.table.TaskTable.java

License:Apache License

protected Object addTaskRow(Object previousTaskItemId, String taskName, String taskAssignee, String taskGroups,
        String taskDescription, Boolean startWithPrevious) {

    Object newItemId = null;/*  w w  w .j a v  a 2s. c  o  m*/
    if (previousTaskItemId == null) { // add at the end of list
        newItemId = addItem();
    } else {
        newItemId = addItemAfter(previousTaskItemId);
    }
    Item newItem = getItem(newItemId);

    // name
    newItem.getItemProperty(ID_NAME).setValue(taskName == null ? "my task" : taskName);

    // assignee
    ComboBox assigneeComboBox = new ComboBox();
    assigneeComboBox.setNullSelectionAllowed(true);

    try {
        for (User user : ProcessEngines.getDefaultProcessEngine().getIdentityService().createUserQuery()
                .orderByUserFirstName().asc().list()) {
            assigneeComboBox.addItem(user.getId());
            assigneeComboBox.setItemCaption(user.getId(), user.getFirstName() + " " + user.getLastName());
        }
    } catch (Exception e) {
        // Don't do anything. Will be an empty dropdown.
    }

    if (taskAssignee != null) {
        assigneeComboBox.select(taskAssignee);
    }

    newItem.getItemProperty(ID_ASSIGNEE).setValue(assigneeComboBox);

    // groups
    ComboBox groupComboBox = new ComboBox();
    groupComboBox.setNullSelectionAllowed(true);

    try {
        for (Group group : ProcessEngines.getDefaultProcessEngine().getIdentityService().createGroupQuery()
                .orderByGroupName().asc().list()) {
            groupComboBox.addItem(group.getId());
            groupComboBox.setItemCaption(group.getId(), group.getName());
        }
    } catch (Exception e) {
        // Don't do anything. Will be an empty dropdown.
    }

    if (taskGroups != null) {
        groupComboBox.select(taskGroups);
    }

    newItem.getItemProperty(ID_GROUPS).setValue(groupComboBox);

    // description
    TextField descriptionTextField = new TextField();
    descriptionTextField.setColumns(16);
    descriptionTextField.setRows(1);
    if (taskDescription != null) {
        descriptionTextField.setValue(taskDescription);
    }
    newItem.getItemProperty(ID_DESCRIPTION).setValue(descriptionTextField);

    // concurrency
    CheckBox startWithPreviousCheckBox = new CheckBox(
            i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_START_WITH_PREVIOUS));
    startWithPreviousCheckBox.setValue(startWithPrevious == null ? false : startWithPrevious);
    newItem.getItemProperty(ID_START_WITH_PREVIOUS).setValue(startWithPreviousCheckBox);

    // actions
    newItem.getItemProperty(ID_ACTIONS).setValue(generateActionButtons(newItemId));

    return newItemId;
}

From source file:org.agocontrol.site.viewlet.dashboard.BuildingSelectPanel.java

License:Apache License

/**
 * Default constructor./*w w  w . j  ava 2 s  .co m*/
 */
public BuildingSelectPanel() {
    site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    siteContext = site.getSiteContext();
    entityManager = siteContext.getObject(EntityManager.class);
    buildingIcon = site.getIcon("building");

    layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    final Label title = new Label("Select Building");
    //title.setIcon(getSite().getIcon("inventory"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    layout.addComponent(titleLayout);
    titleLayout.setSpacing(true);
    titleLayout.setSizeFull();

    final Embedded embedded = new Embedded(null, buildingIcon);
    titleLayout.addComponent(embedded);
    titleLayout.setExpandRatio(embedded, 0.1f);
    embedded.setWidth(32, Unit.PIXELS);
    embedded.setHeight(32, Unit.PIXELS);

    buildingComboBox = new ComboBox();
    titleLayout.addComponent(buildingComboBox);
    titleLayout.setComponentAlignment(buildingComboBox, Alignment.MIDDLE_LEFT);
    titleLayout.setExpandRatio(buildingComboBox, 0.9f);
    //buildingComboBox.setWidth(100, Unit.PERCENTAGE);
    buildingComboBox.setNullSelectionAllowed(false);
    buildingComboBox.setNewItemsAllowed(false);
    buildingComboBox.setTextInputAllowed(false);
    buildingComboBox.setImmediate(true);
    buildingComboBox.setBuffered(false);

    buildingComboBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            final Element building = (Element) buildingComboBox.getValue();
            if (building != null && !building.getElementId().equals(selectedBuildingId)) {
                UI.getCurrent().getNavigator().navigateTo("default/" + building.getElementId());
            }
        }
    });

    setCompositionRoot(layout);
}

From source file:org.agocontrol.site.viewlet.dashboard.ChartPanel.java

License:Apache License

/**
 * Default constructor./*from  w  w  w . j a va  2s.c  o  m*/
 */
public ChartPanel() {
    site = ((AgoControlSiteUI) UI.getCurrent()).getSite();
    siteContext = site.getSiteContext();
    entityManager = siteContext.getObject(EntityManager.class);

    temperatureIcon = site.getIcon("temperature");
    brightnessIcon = site.getIcon("brightness");
    humidityIcon = site.getIcon("humidity");
    eventIcon = site.getIcon("event");

    layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.setStyleName(Reindeer.LAYOUT_WHITE);

    title = new Label("Record Chart");
    title.setImmediate(true);
    title.setIcon(getSite().getIcon("folder"));
    title.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(title);
    layout.setExpandRatio(title, 0);

    recordTypeComboBox = new ComboBox();
    layout.addComponent(recordTypeComboBox);
    layout.setComponentAlignment(recordTypeComboBox, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(recordTypeComboBox, 0);
    //buildingComboBox.setWidth(100, Unit.PERCENTAGE);
    recordTypeComboBox.setNullSelectionAllowed(false);
    recordTypeComboBox.setNewItemsAllowed(false);
    recordTypeComboBox.setTextInputAllowed(false);
    recordTypeComboBox.setImmediate(true);
    recordTypeComboBox.setBuffered(false);

    for (final RecordType recordType : RecordType.values()) {
        recordTypeComboBox.addItem(recordType);
    }
    recordTypeComboBox.setValue(RecordType.TEMPERATURE);
    recordTypeComboBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            refresh();
        }
    });

    chartLayout = new VerticalLayout();
    layout.addComponent(chartLayout);
    layout.setExpandRatio(chartLayout, 1);
    chartLayout.setSpacing(true);
    chartLayout.setSizeFull();

    setCompositionRoot(layout);
}