Example usage for com.vaadin.ui VerticalLayout setCaption

List of usage examples for com.vaadin.ui VerticalLayout setCaption

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:views.ProjectView.java

License:Open Source License

public void initProjectInfos(Collection<ProjectInfo> collection) {
    projectMap = new HashMap<String, ProjectInfo>();
    projectTable.removeAllItems();//from ww  w.j a v  a  2  s .  c o  m
    for (ProjectInfo p : collection) {
        String code = p.getProjectCode();
        projectMap.put(code, p);
        List<Object> row = new ArrayList<Object>();
        row.add(code);
        row.add(p.getProjectName());
        row.add(p.getSpace());
        row.add(p.getInvestigator());
        projectTable.addItem(row.toArray(new Object[row.size()]), code);
    }

    // sort ascending by Project ID
    // projectTable.sort(new Object[] {"Sub-Project"}, new boolean[] {true});

    VerticalLayout projectInfo = new VerticalLayout();
    projectInfo.setVisible(false);
    altName = new TextField("Short Title");
    altName.setWidth("300px");
    altName.setStyleName(Styles.textStyle);
    investigator = new ComboBox("Principal Investigator", personMap.keySet());
    investigator.setStyleName(Styles.boxStyle);
    investigator.setFilteringMode(FilteringMode.CONTAINS);
    contact = new ComboBox("Contact Person", personMap.keySet());
    contact.setStyleName(Styles.boxStyle);
    contact.setFilteringMode(FilteringMode.CONTAINS);
    manager = new ComboBox("Project Manager", personMap.keySet());
    manager.setStyleName(Styles.boxStyle);
    manager.setFilteringMode(FilteringMode.CONTAINS);
    submitInfo = new Button("Change Project Information");
    projectInfo.addComponent(altName);
    projectInfo.addComponent(investigator);
    projectInfo.addComponent(contact);
    projectInfo.addComponent(manager);
    projectInfo.addComponent(submitInfo);
    projectInfo.setSpacing(true);
    addComponent(projectInfo);

    projectTable.addValueChangeListener(new ValueChangeListener() {

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

        @Override
        public void valueChange(ValueChangeEvent event) {
            projectInfo.setVisible(false);
            Object item = projectTable.getValue();
            if (item != null) {
                projectInfo.setVisible(true);
                projectInfo.setCaption(projectMap.get(item).getProjectCode());
                System.out.println(projectMap.get(item));
                altName.setValue(projectMap.get(item).getProjectName());
                investigator.setValue(projectMap.get(item).getInvestigator());
                contact.setValue(projectMap.get(item).getContact());
                manager.setValue(projectMap.get(item).getManager());
            }
        }
    });
}