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

protected ComboBox(DataCommunicator<T> dataCommunicator) 

Source Link

Document

Constructs and initializes an empty combo box.

Usage

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.RequirementSpecComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);/*from   w  w  w. j  a  va2  s.  co  m*/
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(rs.getClass());
    binder.setItemDataSource(rs);
    Field<?> name = binder.buildAndBind(TRANSLATOR.translate("general.name"), "name");
    layout.addComponent(name);
    Field desc = binder.buildAndBind(TRANSLATOR.translate("general.description"), "description",
            TextArea.class);
    desc.setSizeFull();
    layout.addComponent(desc);
    Field<?> date = binder.buildAndBind(TRANSLATOR.translate("general.modification.data"), "modificationDate");
    layout.addComponent(date);
    date.setEnabled(false);
    SpecLevelJpaController controller = new SpecLevelJpaController(DataBaseManager.getEntityManagerFactory());
    List<SpecLevel> levels = controller.findSpecLevelEntities();
    BeanItemContainer<SpecLevel> specLevelContainer = new BeanItemContainer<>(SpecLevel.class, levels);
    ComboBox level = new ComboBox(TRANSLATOR.translate("spec.level"));
    level.setContainerDataSource(specLevelContainer);
    level.getItemIds().forEach(id -> {
        level.setItemCaption(id, TRANSLATOR.translate(((SpecLevel) id).getName()));
    });
    binder.bind(level, "specLevel");
    layout.addComponent(level);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (rs.getRequirementSpecPK() == null) {
            ((VMUI) UI.getCurrent()).displayObject(rs.getProject());
        } else {
            ((VMUI) UI.getCurrent()).displayObject(rs, false);
        }
    });
    if (edit) {
        if (rs.getRequirementSpecPK() == null) {
            //Creating a new one
            Button save = new Button(TRANSLATOR.translate("general.save"));
            save.addClickListener((Button.ClickEvent event) -> {
                try {
                    rs.setName(name.getValue().toString());
                    rs.setModificationDate(new Date());
                    rs.setSpecLevel((SpecLevel) level.getValue());
                    rs.setProject(((Project) ((VMUI) UI.getCurrent()).getSelectdValue()));
                    rs.setRequirementSpecPK(
                            new RequirementSpecPK(rs.getProject().getId(), rs.getSpecLevel().getId()));
                    new RequirementSpecJpaController(DataBaseManager.getEntityManagerFactory()).create(rs);
                    setVisible(false);
                    //Recreate the tree to show the addition
                    ((VMUI) UI.getCurrent()).updateProjectList();
                    ((VMUI) UI.getCurrent()).buildProjectTree(rs);
                    ((VMUI) UI.getCurrent()).displayObject(rs, true);
                    ((VMUI) UI.getCurrent()).updateScreen();
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(save);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        } else {
            //Editing existing one
            Button update = new Button(TRANSLATOR.translate("general.update"));
            update.addClickListener((Button.ClickEvent event) -> {
                try {
                    rs.setName(name.getValue().toString());
                    rs.setModificationDate(new Date());
                    rs.setSpecLevel((SpecLevel) level.getValue());
                    ((VMUI) UI.getCurrent()).handleVersioning(rs, () -> {
                        try {
                            new RequirementSpecJpaController(DataBaseManager.getEntityManagerFactory())
                                    .edit(rs);
                            ((VMUI) UI.getCurrent()).displayObject(rs, true);
                        } catch (NonexistentEntityException ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        } catch (Exception ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        }
                    });
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.update"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(update);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        }
    }
    binder.setReadOnly(!edit);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.StepComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);/*from w w  w.  ja  v  a 2s.com*/
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(s.getClass());
    binder.setItemDataSource(s);
    Field<?> sequence = binder.buildAndBind(TRANSLATOR.translate("general.sequence"), "stepSequence");
    layout.addComponent(sequence);
    TextArea text = new TextArea(TRANSLATOR.translate("general.text"));
    text.setConverter(new ByteToStringConverter());
    binder.bind(text, "text");
    layout.addComponent(text);
    TextArea result = new TextArea(TRANSLATOR.translate("expected.result"));
    result.setConverter(new ByteToStringConverter());
    binder.bind(result, "expectedResult");
    layout.addComponent(result);
    Field notes = binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class);
    notes.setSizeFull();
    layout.addComponent(notes);
    if (!s.getRequirementList().isEmpty() && !edit) {
        layout.addComponent(((ValidationManagerUI) UI.getCurrent()).getDisplayRequirementList(
                TRANSLATOR.translate("related.requirements"), s.getRequirementList()));
    } else {
        AbstractSelect requirements = ((ValidationManagerUI) UI.getCurrent())
                .getRequirementSelectionComponent();
        //Select the exisitng ones.
        if (s.getRequirementList() != null) {
            s.getRequirementList().forEach((r) -> {
                requirements.select(r);
            });
        }
        requirements.addValueChangeListener(event -> {
            Set<Requirement> selected = (Set<Requirement>) event.getProperty().getValue();
            s.getRequirementList().clear();
            selected.forEach(r -> {
                s.getRequirementList().add(r);
            });
        });
        layout.addComponent(requirements);
    }
    DataEntryComponent fields = new DataEntryComponent(edit);
    binder.bind(fields, "dataEntryList");
    layout.addComponent(fields);
    binder.setReadOnly(edit);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (s.getStepPK() == null) {
            ((ValidationManagerUI) UI.getCurrent())
                    .displayObject(((ValidationManagerUI) UI.getCurrent()).getTree().getValue());
        } else {
            ((ValidationManagerUI) UI.getCurrent()).displayObject(s, false);
        }
    });
    if (edit) {
        Button add = new Button(TRANSLATOR.translate("add.field"));
        add.addClickListener(listener -> {
            VMWindow w = new VMWindow();
            FormLayout fl = new FormLayout();
            ComboBox newType = new ComboBox(TRANSLATOR.translate("general.type"));
            newType.setNewItemsAllowed(false);
            newType.setTextInputAllowed(false);
            newType.addValidator(new NullValidator(TRANSLATOR.translate("message.required.field.missing")
                    .replaceAll("%f", TRANSLATOR.translate("general.type")), false));
            BeanItemContainer<DataEntryType> container = new BeanItemContainer<>(DataEntryType.class,
                    new DataEntryTypeJpaController(DataBaseManager.getEntityManagerFactory())
                            .findDataEntryTypeEntities());
            newType.setContainerDataSource(container);
            newType.getItemIds().forEach(id -> {
                DataEntryType temp = ((DataEntryType) id);
                newType.setItemCaption(id, TRANSLATOR.translate(temp.getTypeName()));
            });
            fl.addComponent(newType);
            TextField tf = new TextField(TRANSLATOR.translate("general.name"));
            fl.addComponent(tf);
            HorizontalLayout hl = new HorizontalLayout();
            Button a = new Button(TRANSLATOR.translate("general.add"));
            a.addClickListener(l -> {
                DataEntryType det = (DataEntryType) newType.getValue();
                DataEntry de = null;
                switch (det.getId()) {
                case 1:
                    de = DataEntryServer.getStringField(tf.getValue());
                    break;
                case 2:
                    de = DataEntryServer.getNumericField(tf.getValue(), null, null);
                    break;
                case 3:
                    de = DataEntryServer.getBooleanField(tf.getValue());
                    break;
                case 4:
                    de = DataEntryServer.getAttachmentField(tf.getValue());
                    break;
                }
                if (de != null) {
                    s.getDataEntryList().add(de);
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                }
                UI.getCurrent().removeWindow(w);
            });
            hl.addComponent(a);
            Button c = new Button(TRANSLATOR.translate("general.cancel"));
            c.addClickListener(l -> {
                UI.getCurrent().removeWindow(w);
            });
            hl.addComponent(c);
            fl.addComponent(hl);
            w.setContent(fl);
            UI.getCurrent().addWindow(w);
        });
        if (s.getStepPK() == null) {
            //Creating a new one
            Button save = new Button(TRANSLATOR.translate("general.save"));
            save.addClickListener(listener -> {
                try {
                    s.setExpectedResult(((TextArea) result).getValue().getBytes(encoding));
                    s.setNotes(notes.getValue() == null ? "" : notes.getValue().toString());
                    s.setStepSequence(Integer.parseInt(sequence.getValue().toString()));
                    s.setTestCase((TestCase) ((ValidationManagerUI) UI.getCurrent()).getTree().getValue());
                    s.setText(text.getValue().getBytes(encoding));
                    if (s.getRequirementList() == null) {
                        s.setRequirementList(new ArrayList<>());
                    }
                    new StepJpaController(DataBaseManager.getEntityManagerFactory()).create(s);
                    setVisible(false);
                    //Recreate the tree to show the addition
                    ((ValidationManagerUI) UI.getCurrent()).updateProjectList();
                    ((ValidationManagerUI) UI.getCurrent()).updateScreen();
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                    ((ValidationManagerUI) UI.getCurrent()).buildProjectTree(s);
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(save);
            hl.addComponent(add);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        } else {
            //Editing existing one
            Button update = new Button(TRANSLATOR.translate("general.update"));
            update.addClickListener((Button.ClickEvent event) -> {
                try {
                    s.setExpectedResult(((TextArea) result).getValue().getBytes(encoding));
                    s.setNotes(notes.getValue().toString());
                    s.setStepSequence(Integer.parseInt(sequence.getValue().toString()));
                    s.setText(text.getValue().getBytes(encoding));
                    if (s.getRequirementList() == null) {
                        s.setRequirementList(new ArrayList<>());
                    }
                    ((ValidationManagerUI) UI.getCurrent()).handleVersioning(s, () -> {
                        try {
                            new StepJpaController(DataBaseManager.getEntityManagerFactory()).edit(s);
                        } catch (NonexistentEntityException ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        } catch (Exception ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        }
                    });
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                } catch (UnsupportedEncodingException | NumberFormatException ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(update);
            hl.addComponent(add);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        }
    }
    binder.setReadOnly(!edit);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.TemplateComponent.java

License:Apache License

private void init() {
    tree = new Tree();
    tree.addItem(getTemplate());/*w w w . j  a  v a2  s. com*/
    tree.setItemIcon(getTemplate(), VaadinIcons.FILE_TREE);
    tree.setItemCaption(getTemplate(), getTemplate().getTemplateName());
    if (getTemplate().getTemplateNodeList() != null) {
        getTemplate().getTemplateNodeList().forEach(node -> {
            if (node.getTemplateNode() == null) {
                //Only root folders
                addTemplateNode(node);
            }
        });
    }
    //Select item on right click as well
    tree.addItemClickListener((ItemClickEvent event) -> {
        if (event.getSource() == tree && event.getButton() == MouseEventDetails.MouseButton.RIGHT) {
            if (event.getItem() != null) {
                Item clicked = event.getItem();
                tree.select(event.getItemId());
            }
        }
    });
    //Add context menu
    ContextMenu menu = new ContextMenu(tree, true);
    if (edit) {
        tree.addItemClickListener((ItemClickEvent event) -> {
            if (event.getButton() == MouseEventDetails.MouseButton.RIGHT) {
                menu.removeItems();
                if (tree.getValue() != null) {
                    if (tree.getValue() instanceof Template) {
                        Template t = (Template) tree.getValue();
                        if (t.getId() < 1_000) {
                            return;
                        }
                    }
                    MenuItem create = menu.addItem(TRANSLATOR.translate("general.add.child"), PROJECT_ICON,
                            (MenuItem selectedItem) -> {
                                displayChildCreationWizard();
                            });
                    MenuItem delete = menu.addItem(TRANSLATOR.translate("general.delete"), PROJECT_ICON,
                            (MenuItem selectedItem) -> {
                                displayChildDeletionWizard();
                            });
                    //Don't allow to delete the root node.
                    delete.setEnabled(!tree.isRoot(tree.getValue()));
                }
            }
        });
    }
    TextField nameField = new TextField(TRANSLATOR.translate("general.name"));
    VerticalLayout vl = new VerticalLayout();
    BeanFieldGroup binder = new BeanFieldGroup(getTemplate().getClass());
    binder.setItemDataSource(getTemplate());
    binder.bind(nameField, "templateName");
    nameField.addValueChangeListener(listener -> {
        getTemplate().setTemplateName(nameField.getValue());
    });
    nameField.setNullRepresentation("");
    ComboBox type = new ComboBox(TRANSLATOR.translate("general.type"));
    BeanItemContainer<ProjectType> container = new BeanItemContainer<>(ProjectType.class,
            new ProjectTypeJpaController(DataBaseManager.getEntityManagerFactory()).findProjectTypeEntities());
    type.setContainerDataSource(container);
    for (Object o : type.getItemIds()) {
        ProjectType id = ((ProjectType) o);
        type.setItemCaption(id, TRANSLATOR.translate(id.getTypeName()));
    }
    type.addValueChangeListener(listener -> {
        if (type.getValue() != null) {
            getTemplate().setProjectTypeId((ProjectType) type.getValue());
        }
    });
    binder.bind(type, "projectTypeId");
    vl.addComponent(nameField);
    vl.addComponent(type);
    if (template.getId() != null) {
        vl.addComponent(tree);
    }
    binder.setReadOnly(!edit);
    setContent(vl);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.UserComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);/*from w  ww.  j ava 2 s . c  o  m*/
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(user.getClass());
    binder.setItemDataSource(user);
    Field<?> fn = binder.buildAndBind(TRANSLATOR.translate("general.first.name"), "firstName", TextField.class);
    layout.addComponent(fn);
    Field<?> ln = binder.buildAndBind(TRANSLATOR.translate("general.last.name"), "lastName", TextField.class);
    layout.addComponent(ln);
    Field<?> username = binder.buildAndBind(TRANSLATOR.translate("general.username"), "username",
            TextField.class);
    layout.addComponent(username);
    PasswordField pw = (PasswordField) binder.buildAndBind(TRANSLATOR.translate("general.password"), "password",
            PasswordField.class);
    PasswordChangeListener listener = new PasswordChangeListener();
    pw.addTextChangeListener(listener);
    pw.setConverter(new UserPasswordConverter());
    layout.addComponent(pw);
    Field<?> email = binder.buildAndBind(TRANSLATOR.translate("general.email"), "email", TextField.class);
    layout.addComponent(email);
    ComboBox locale = new ComboBox(TRANSLATOR.translate("general.locale"));
    locale.setTextInputAllowed(false);
    ValidationManagerUI.getAvailableLocales().forEach(l -> {
        locale.addItem(l.toString());
    });
    if (user.getLocale() != null) {
        locale.setValue(user.getLocale());
    }
    binder.bind(locale, "locale");
    layout.addComponent(locale);
    //Status
    ComboBox status = new ComboBox(TRANSLATOR.translate("general.status"));
    new UserStatusJpaController(DataBaseManager.getEntityManagerFactory()).findUserStatusEntities()
            .forEach(us -> {
                status.addItem(us);
                status.setItemCaption(us, TRANSLATOR.translate(us.getStatus()));
            });
    binder.bind(status, "userStatusId");
    status.setTextInputAllowed(false);
    layout.addComponent(status);
    List<UserHasRole> userRoles = new ArrayList<>();
    //Project specific roles
    if (!user.getUserHasRoleList().isEmpty()) {
        Tree roles = new Tree(TRANSLATOR.translate("project.specific.role"));
        user.getUserHasRoleList().forEach(uhr -> {
            if (uhr.getProjectId() != null) {
                Project p = uhr.getProjectId();
                if (!roles.containsId(p)) {
                    roles.addItem(p);
                    roles.setItemCaption(p, p.getName());
                    roles.setItemIcon(p, VMUI.PROJECT_ICON);
                }
                roles.addItem(uhr);
                roles.setItemCaption(uhr, TRANSLATOR.translate(uhr.getRole().getRoleName()));
                roles.setChildrenAllowed(uhr, false);
                roles.setItemIcon(uhr, VaadinIcons.USER_CARD);
                roles.setParent(uhr, p);
            }
        });
        if (!roles.getItemIds().isEmpty()) {
            layout.addComponent(roles);
        }
    }
    //Roles
    if (edit && ((VMUI) UI.getCurrent()).checkRight("system.configuration")) {
        Button projectRole = new Button(TRANSLATOR.translate("manage.project.role"));
        projectRole.addClickListener(l -> {
            VMWindow w = new VMWindow(TRANSLATOR.translate("manage.project.role"));
            w.setContent(getProjectRoleManager());
            ((VMUI) UI.getCurrent()).addWindow(w);
        });
        layout.addComponent(projectRole);
        List<Role> list = new RoleJpaController(DataBaseManager.getEntityManagerFactory()).findRoleEntities();
        Collections.sort(list, (Role r1, Role r2) -> TRANSLATOR.translate(r1.getRoleName())
                .compareTo(TRANSLATOR.translate(r2.getRoleName())));
        BeanItemContainer<Role> roleContainer = new BeanItemContainer<>(Role.class, list);
        TwinColSelect roles = new TwinColSelect(TRANSLATOR.translate("general.role"));
        roles.setContainerDataSource(roleContainer);
        roles.setRows(5);
        roles.setLeftColumnCaption(TRANSLATOR.translate("available.roles"));
        roles.setRightColumnCaption(TRANSLATOR.translate("current.roles"));
        roles.setImmediate(true);
        list.forEach(r -> {
            roles.setItemCaption(r, TRANSLATOR.translate(r.getDescription()));
        });
        if (user.getUserHasRoleList() != null) {
            Set<Role> rs = new HashSet<>();
            user.getUserHasRoleList().forEach(uhr -> {
                if (uhr.getProjectId() == null) {
                    rs.add(uhr.getRole());
                }
            });
            roles.setValue(rs);
        }
        roles.addValueChangeListener(event -> {
            Set<Role> selected = (Set<Role>) event.getProperty().getValue();
            selected.forEach(r -> {
                UserHasRole temp = new UserHasRole();
                temp.setRole(r);
                temp.setVmUser(user);
                userRoles.add(temp);
            });
        });
        layout.addComponent(roles);
    } else {
        if (!user.getUserHasRoleList().isEmpty()) {
            Table roles = new Table(TRANSLATOR.translate("general.role"));
            user.getUserHasRoleList().forEach(role -> {
                roles.addItem(role.getRole());
                roles.setItemCaption(role.getRole(), TRANSLATOR.translate(role.getRole().getRoleName()));
                roles.setItemIcon(role.getRole(), VaadinIcons.USER_STAR);
            });
            layout.addComponent(roles);
        }
    }
    Button update = new Button(user.getId() == null ? TRANSLATOR.translate("general.create")
            : TRANSLATOR.translate("general.update"));
    update.addClickListener((Button.ClickEvent event) -> {
        try {
            VMUserServer us;
            String password = (String) pw.getValue();
            if (user.getId() == null) {
                us = new VMUserServer((String) username.getValue(), password, (String) fn.getValue(),
                        (String) ln.getValue(), (String) email.getValue());
            } else {
                us = new VMUserServer(user);
                us.setFirstName((String) fn.getValue());
                us.setLastName((String) ln.getValue());
                us.setEmail((String) email.getValue());
                us.setUsername((String) username.getValue());
            }
            us.setLocale((String) locale.getValue());
            if (user.getUserHasRoleList() == null) {
                user.setUserHasRoleList(new ArrayList<>());
            }
            user.getUserHasRoleList().clear();
            userRoles.forEach(uhr -> {
                UserHasRoleJpaController c = new UserHasRoleJpaController(
                        DataBaseManager.getEntityManagerFactory());
                try {
                    c.create(uhr);
                    user.getUserHasRoleList().add(uhr);
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                }
            });
            if (listener.isChanged() && !password.equals(user.getPassword())) {
                //Different password. Prompt for confirmation
                MessageBox mb = MessageBox.create();
                VerticalLayout vl = new VerticalLayout();
                Label l = new Label(TRANSLATOR.translate("password.confirm.pw.message"));
                vl.addComponent(l);
                PasswordField np = new PasswordField(Lookup.getDefault()
                        .lookup(InternationalizationProvider.class).translate("general.password"));
                vl.addComponent(np);
                mb.asModal(true)
                        .withCaption(Lookup.getDefault().lookup(InternationalizationProvider.class)
                                .translate("password.confirm.pw"))
                        .withMessage(vl).withButtonAlignment(Alignment.MIDDLE_CENTER).withOkButton(() -> {
                            try {
                                if (password.equals(MD5.encrypt(np.getValue()))) {
                                    us.setHashPassword(true);
                                    us.setPassword(np.getValue());
                                    us.write2DB();
                                    Notification.show(
                                            TRANSLATOR.translate("audit.user.account.password.change"),
                                            Notification.Type.ASSISTIVE_NOTIFICATION);
                                    ((VMUI) UI.getCurrent()).updateScreen();
                                } else {
                                    Notification.show(TRANSLATOR.translate("password.does.not.match"),
                                            Notification.Type.WARNING_MESSAGE);
                                }
                                mb.close();
                            } catch (VMException ex) {
                                Exceptions.printStackTrace(ex);
                            }
                        }, ButtonOption.focus(), ButtonOption.closeOnClick(false),
                                ButtonOption.icon(VaadinIcons.CHECK))
                        .withCancelButton(ButtonOption.icon(VaadinIcons.CLOSE)).getWindow()
                        .setIcon(ValidationManagerUI.SMALL_APP_ICON);
                mb.open();
            } else {
                us.write2DB();
            }
            ((VMUI) UI.getCurrent()).getUser().update();
            ((VMUI) UI.getCurrent()).setLocale(new Locale(us.getLocale()));
            ((VMUI) UI.getCurrent()).updateScreen();
        } catch (Exception ex) {
            LOG.log(Level.SEVERE, null, ex);
            Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(),
                    Notification.Type.ERROR_MESSAGE);
        }
    });
    Button cancel = new Button(
            Lookup.getDefault().lookup(InternationalizationProvider.class).translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        ((VMUI) UI.getCurrent()).updateScreen();
    });
    binder.setReadOnly(!edit);
    binder.setBuffered(true);
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(update);
    hl.addComponent(cancel);
    layout.addComponent(hl);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.traceability.TraceMatrix.java

License:Apache License

public Component getMenu() {
    HorizontalLayout hl = new HorizontalLayout();
    ComboBox baseline = new ComboBox(TRANSLATOR.translate("baseline.filter"));
    baseline.setTextInputAllowed(false);
    baseline.setNewItemsAllowed(false);/*from  w ww.  j  a  v  a2  s. c om*/
    Tool.extractRequirements(p).forEach(r -> {
        r.getHistoryList().forEach(h -> {
            h.getBaselineList().forEach(b -> {
                if (!baseline.containsId(b)) {
                    baseline.addItem(b);
                    baseline.setItemCaption(b, b.getBaselineName());
                }
            });
        });
    });
    baseline.addValueChangeListener(event -> {
        removeAllItems();
        Baseline b = (Baseline) baseline.getValue();
        if (b == null) {
            //None selected, no filtering
            Tool.extractRequirements(p).forEach((r) -> {
                if (r.getParentRequirementId() == null) {
                    addRequirement(r);
                }
            });
        } else {
            b.getHistoryList().forEach(h -> {
                addRequirement(h.getRequirementId());
            });
        }
    });
    hl.addComponent(baseline);
    Button export = new Button(TRANSLATOR.translate("general.export"));
    export.addClickListener(listener -> {
        //Create the Excel file
        ExcelExport excelExport = new ExcelExport(this);
        excelExport.excludeCollapsedColumns();
        excelExport.setReportTitle(TRANSLATOR.translate("trace.matrix"));
        excelExport.setDisplayTotals(false);
        excelExport.export();
    });
    hl.addComponent(export);
    return hl;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.wizard.project.ProjectTemplateStep.java

License:Apache License

public ProjectTemplateStep(ProjectCreationWizard wizard) {
    this.wizard = wizard;
    this.templates = new ComboBox(ContentProvider.TRANSLATOR.translate("template.tab.list.name"));
    this.templates.setRequired(true);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.wizard.project.ProjectTypeStep.java

License:Apache License

public ProjectTypeStep(ProjectCreationWizard wizard) {
    type = new ComboBox(TRANSLATOR.translate("general.type"));
    type.addItem("general.software");
    type.addItem("general.hardware");
    type.setTextInputAllowed(false);/*from ww w  .j  av  a 2s.c  om*/
    type.setWidth(100, Unit.PERCENTAGE);
    this.wizard = wizard;
}

From source file:nl.kpmg.lcm.ui.view.administration.components.UserCreateWindow.java

License:Apache License

private ComboBox initRolesListComboBox() {
    ComboBox rolesListComboBox = new ComboBox("Role");

    rolesListComboBox.addItem(Roles.ADMINISTRATOR);
    rolesListComboBox.setItemCaption(Roles.ADMINISTRATOR, "Administrator");

    rolesListComboBox.addItem(Roles.REMOTE_USER);
    rolesListComboBox.setItemCaption(Roles.REMOTE_USER, "Remote user");

    rolesListComboBox.addItem(Roles.API_USER);
    rolesListComboBox.setItemCaption(Roles.API_USER, "API user");

    rolesListComboBox.setTextInputAllowed(false);
    rolesListComboBox.setRequired(true);
    rolesListComboBox.setNullSelectionAllowed(false);
    rolesListComboBox.setInputPrompt("Please select one");
    rolesListComboBox.addListener(this);

    return rolesListComboBox;
}

From source file:nl.kpmg.lcm.ui.view.transfer.components.StartTransferWindow.java

License:Apache License

private FormLayout initSettingsPanel() throws UnsupportedOperationException {
    FormLayout settingsContent = new FormLayout();
    overwriteComboBox = new ComboBox("Overwrite existing data");
    overwriteComboBox.addItem("true");
    overwriteComboBox.setItemCaption("true", "true");
    overwriteComboBox.addItem("false");
    overwriteComboBox.setItemCaption("false", "false");
    writeChunkSizeField = new TextField("Write chunck size");
    varcharSizeField = new TextField("Varchar size");
    decimalPrecisionField = new TextField("Decinal precision");
    initSettings();//w ww . ja va2 s.c  om

    settingsContent.addComponent(overwriteComboBox);
    settingsContent.addComponent(writeChunkSizeField);
    settingsContent.addComponent(varcharSizeField);
    settingsContent.addComponent(decimalPrecisionField);
    settingsContent.setHeight(TAB_HEIGHT);
    settingsContent.setMargin(true);
    return settingsContent;
}

From source file:nl.kpmg.lcm.ui.view.transfer.components.StartTransferWindow.java

License:Apache License

private ComboBox initStorageListComboBox() throws UnsupportedOperationException {
    ComboBox storageListComboBox = new ComboBox("Local Storage");
    List<String> validStorageTypes = TransferValidator.getValidStorageTypes(remoteMetadata.getSourceType());
    StoragesRepresentation storages;// w ww.ja va2s  .  c  om
    try {
        storages = restClientService.getStorage();

        for (StorageRepresentation item : storages.getItems()) {
            Storage storage = item.getItem();
            if (validStorageTypes.contains(storage.getType())) {
                String name = storage.getName() + " (" + storage.getType() + ")";
                storageListComboBox.addItem(storage.getId());
                storageListComboBox.setItemCaption(storage.getId(), name);
            }
        }
    } catch (ServerException ex) {
        Notification.show("Unable to init storage list!");
        LOGGER.error("Unable to init storage list! Message:" + ex.getMessage());
    } catch (AuthenticationException | LcmBadRequestException ex) {
        LOGGER.error("Unable to init storage list!" + ex.getMessage());
        Notification.show("Unable to init storage list! Message: " + ex.getMessage());
    }
    storageListComboBox.addStyleName("margin-right-20");
    storageListComboBox.addStyleName("width-search-field");
    storageListComboBox.setRequired(true);
    storageListComboBox.setInputPrompt("Please select one");

    return storageListComboBox;
}