List of usage examples for com.vaadin.ui TwinColSelect TwinColSelect
public TwinColSelect(String caption)
From source file:com.cavisson.gui.dashboard.components.controls.NativeSelects.java
License:Apache License
public NativeSelects() { setMargin(true);/*from w w w .ja v a 2 s .c o m*/ Label h1 = new Label("Selects"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); NativeSelect select = new NativeSelect("Drop Down Select"); row.addComponent(select); ListSelect list = new ListSelect("List Select"); list.setNewItemsAllowed(true); row.addComponent(list); TwinColSelect tcs = new TwinColSelect("TwinCol Select"); tcs.setLeftColumnCaption("Left Column"); tcs.setRightColumnCaption("Right Column"); tcs.setNewItemsAllowed(true); row.addComponent(tcs); TwinColSelect tcs2 = new TwinColSelect("Sized TwinCol Select"); tcs2.setLeftColumnCaption("Left Column"); tcs2.setRightColumnCaption("Right Column"); tcs2.setNewItemsAllowed(true); tcs2.setWidth("280px"); tcs2.setHeight("200px"); row.addComponent(tcs2); for (int i = 1; i <= 10; i++) { select.addItem("Option " + i); list.addItem("Option " + i); tcs.addItem("Option " + i); tcs2.addItem("Option " + i); } }
From source file:com.kpg.diary.ui.NativeSelects.java
License:Apache License
public NativeSelects() { setMargin(true);//from w w w. ja v a 2s. c o m Label h1 = new Label("Selects"); h1.addStyleName(ValoTheme.LABEL_H2); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); row.setSpacing(true); addComponent(row); NativeSelect select = new NativeSelect("Drop Down Select"); row.addComponent(select); ListSelect list = new ListSelect("List Select"); list.setNewItemsAllowed(true); row.addComponent(list); TwinColSelect tcs = new TwinColSelect("TwinCol Select"); tcs.setLeftColumnCaption("Left Column"); tcs.setRightColumnCaption("Right Column"); tcs.setNewItemsAllowed(true); row.addComponent(tcs); TwinColSelect tcs2 = new TwinColSelect("Sized TwinCol Select"); tcs2.setLeftColumnCaption("Left Column"); tcs2.setRightColumnCaption("Right Column"); tcs2.setNewItemsAllowed(true); tcs2.setWidth("280px"); tcs2.setHeight("200px"); row.addComponent(tcs2); for (int i = 1; i <= 10; i++) { select.addItem("Option " + i); list.addItem("Option " + i); tcs.addItem("Option " + i); tcs2.addItem("Option " + i); } }
From source file:com.tenforce.lodms.extractors.views.CkanExtractFieldFactory.java
@Override public Field createField(Item item, Object propertyId, Component uiContext) { if ("baseUri".equals(propertyId)) { TextField uriField = new TextField("CKAN Url"); uriField.setRequired(true);//from w w w. ja v a 2 s .c o m uriField.setRequiredError("CKAN Url is required!"); uriField.setWidth(350, VerticalLayout.UNITS_PIXELS); uriField.setDescription("Base url of the ckan portal."); uriField.setImmediate(true); uriField.addValidator(new AbstractStringValidator(null) { @Override protected boolean isValidString(String value) { try { new URIImpl(value); return true; } catch (Exception ex) { setErrorMessage("Invalid CKAN Url: " + ex.getMessage()); return false; } } }); return uriField; } else if ("httpMethod".equals(propertyId)) { Select selector = new Select("Http Method"); selector.addItem(HttpMethod.GET); selector.addItem(HttpMethod.POST); return selector; } else if ("publisher".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("The foaf:agent responsible for this catalog."); field.setRequired(true); return field; } else if ("title".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("Title for this catalog."); field.setRequired(true); return field; } else if ("license".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("license for this catalog."); field.setRequired(true); return field; } else if ("description".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("Description for this catalog."); field.setWidth(350, VerticalLayout.UNITS_PIXELS); field.setRequired(true); return field; } else if ("ignoredKeys".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription( "A comma seperated list of attributes in the metadata that should be ignored by the extractor."); return field; } else if ("subjectPrefix".equals(propertyId)) { TextField subjectField = new TextField("Subject Prefix"); subjectField.setRequired(true); subjectField.setDescription("This prefix will be used to generate the subject url."); subjectField.setRequiredError("Subject Prefix is required!"); subjectField.setWidth(350, VerticalLayout.UNITS_PIXELS); return subjectField; } else if ("predicatePrefix".equals(propertyId)) { TextField predicateField = new TextField("Predicate Prefix"); predicateField.setRequired(true); predicateField.setDescription( "All json attributes will be prefixed with this string to generate a predicate."); predicateField.setRequiredError("Predicate Prefix is required!"); predicateField.setWidth(350, VerticalLayout.UNITS_PIXELS); return predicateField; } else if ("packageIds".equals(propertyId)) { TwinColSelect select = new TwinColSelect("Select catalog records to harvest"); select.setLeftColumnCaption("Available records"); select.setRightColumnCaption("Selected records"); select.setRows(20); select.setWidth(500, VerticalLayout.UNITS_PIXELS); return select; } else if ("allDatasets".equals(propertyId)) { CheckBox box = new CheckBox("harvest all datasets"); box.setImmediate(true); return box; } return super.createField(item, propertyId, uiContext); }
From source file:edu.kit.dama.ui.admin.workflow.DataWorkflowBasePropertiesLayout.java
License:Apache License
public TwinColSelect getEnvironmentPropertiesSelect() { if (environmentProperties == null) { String id = "environmentProperties"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); environmentProperties = new TwinColSelect("ENVIRONMENT PROPERTIES"); environmentProperties.setId(DEBUG_ID_PREFIX + id); environmentProperties.setSizeFull(); environmentProperties.setRows(8); environmentProperties.setImmediate(true); environmentProperties.addStyleName(CSSTokenContainer.BOLD_CAPTION); environmentProperties.addStyleName("colored"); }// www. ja v a 2s. c o m return environmentProperties; }
From source file:edu.kit.dama.ui.admin.workflow.ExecutionEnvironmentBasePropertiesLayout.java
License:Apache License
public TwinColSelect getEnvironmentPropertiesSelect() { if (environmentProperties == null) { String id = "providedEnvironmentProperties"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); environmentProperties = new TwinColSelect("ENVIRONMENT PROPERTIES"); environmentProperties.setId(DEBUG_ID_PREFIX + id); environmentProperties.setSizeFull(); environmentProperties.setRows(8); environmentProperties.setImmediate(true); environmentProperties.addStyleName(CSSTokenContainer.BOLD_CAPTION); environmentProperties.addStyleName("colored"); }/*from w ww. ja v a 2 s . co m*/ return environmentProperties; }
From source file:io.subutai.plugin.accumulo.ui.wizard.ConfigurationStep.java
public static TwinColSelect getTwinSelect(String title, String captionProperty, String leftTitle, String rightTitle, int rows) { TwinColSelect twinColSelect = new TwinColSelect(title); twinColSelect.setItemCaptionPropertyId(captionProperty); twinColSelect.setRows(rows);/* w w w . j a v a2s . co m*/ twinColSelect.setMultiSelect(true); twinColSelect.setImmediate(true); twinColSelect.setLeftColumnCaption(leftTitle); twinColSelect.setRightColumnCaption(rightTitle); twinColSelect.setWidth(100, Sizeable.Unit.PERCENTAGE); twinColSelect.setRequired(true); return twinColSelect; }
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 w w.j a v a2 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.component.UserComponent.java
License:Apache License
private Component getProjectRoleManager() { VerticalLayout vl = new VerticalLayout(); ProjectTreeComponent tree = new ProjectTreeComponentBuilder().setShowRequirement(false) .setShowTestCase(false).setShowExecution(false).createProjectTreeComponent(); vl.addComponent(tree);//w w w . j a va2s . co m TwinColSelect roles = new TwinColSelect(TRANSLATOR.translate("general.role")); tree.addValueChangeListener((Property.ValueChangeEvent event) -> { Project selected = (Project) tree.getValue(); if (user.getUserHasRoleList() == null) { user.setUserHasRoleList(new ArrayList<>()); } if (selected != null) { HashSet<Role> values = new HashSet<>(); user.getUserHasRoleList().forEach(uhr -> { if (uhr.getProjectId() != null && Objects.equals(uhr.getProjectId().getId(), selected.getId())) { values.add(uhr.getRole()); } }); roles.setValue(values); } }); 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); roles.setContainerDataSource(roleContainer); roles.setRows(5); roles.setLeftColumnCaption(TRANSLATOR.translate("available.roles")); roles.setRightColumnCaption(TRANSLATOR.translate("current.roles")); list.forEach(r -> { roles.setItemCaption(r, TRANSLATOR.translate(r.getDescription())); }); roles.addValueChangeListener(event -> { Set<Role> selected = (Set<Role>) event.getProperty().getValue(); UserHasRoleJpaController c = new UserHasRoleJpaController(DataBaseManager.getEntityManagerFactory()); ProjectServer ps = new ProjectServer((Project) tree.getValue()); if (ps.getUserHasRoleList().isEmpty()) { ps.setUserHasRoleList(new ArrayList<>()); } selected.forEach(r -> { //Look for the existing ones boolean found = false; for (UserHasRole uhr : ps.getUserHasRoleList()) { if (Objects.equals(uhr.getVmUser().getId(), user.getId()) && Objects.equals(uhr.getRole().getId(), r.getId())) { found = true; break; } } if (!found) { try { //Create a new one UserHasRole uhr = new UserHasRole(); uhr.setProjectId(ps.getEntity()); uhr.setRole(r); uhr.setVmUser(user.getEntity()); c.create(uhr); user.update(); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } } }); }); vl.addComponent(roles); return vl; }
From source file:org.geant.sat.ui.EntityListViewer.java
License:BSD License
/** * Creates a subwindow for editing survey details of entity. * /*from ww w. j a v a 2 s .c o m*/ * @param details * entity */ private void editSurveys(EntityDetails details) { Window subWindowNewEntity = new Window(getString("lang.window.newentity.editsids.title")); subWindowNewEntity.setModal(true); VerticalLayout subContent = new VerticalLayout(); TwinColSelect<String> selectSids = new TwinColSelect<>(getString("lang.window.newentity.editsids.sids")); selectSids.setData(details); ListAllSurveysResponse resp = getMainUI().getSatApiClient().getSurveys(); if (!verifySuccess(resp)) { return; } List<SurveyDetails> surveyDetails = resp.getSurveys(); // parse active sids List<String> activeSurveyDetails = new ArrayList<String>(); for (SurveyDetails surveyDetail : surveyDetails) { if (surveyDetail.getActive()) { activeSurveyDetails.add(surveyDetail.getSid()); } } selectSids.setItems(activeSurveyDetails); // set current sids as selection selectSids.updateSelection(details.getSids(), new HashSet<String>()); subContent.addComponent(selectSids, 0); Button editButton = new Button(getString("lang.window.newentity.buttonModify")); subContent.addComponent(editButton, 1); editButton.addClickListener(this::editedSurveys); Button cancelButton = new Button(getString("lang.window.newentity.buttonCancel")); subContent.addComponent(cancelButton, 2); cancelButton.addClickListener(this::canceledEditSurveys); subWindowNewEntity.setContent(subContent); getMainUI().addWindow(subWindowNewEntity); }
From source file:org.geant.sat.ui.EntityListViewer.java
License:BSD License
/** * Creates a subwindow for editing assessor details of entity. * /* ww w .j a v a 2s . c om*/ * @param details * entity */ private void editAssessors(EntityDetails details) { Window subWindowNewEntity = new Window(getString("lang.window.newentity.editassessors.title")); subWindowNewEntity.setWidth("80%"); subWindowNewEntity.setModal(true); VerticalLayout subContent = new VerticalLayout(); subContent.setWidth("100%"); TwinColSelect<AssessorDetails> selectAssessors = new TwinColSelect<>( getString("lang.window.newentity.editassessors.assessors")); selectAssessors.setItemCaptionGenerator(new AssessorDetailsHelper()); selectAssessors.setWidth("100%"); selectAssessors.setData(details); ListAssessorsResponse resp = getMainUI().getSatApiClient().getAssessors(); if (!verifySuccess(resp)) { return; } List<AssessorDetails> assessorDetails = resp.getAssessors(); selectAssessors.setItems(assessorDetails); selectAssessors.updateSelection( AssessorDetailsHelper.selectionToSet(assessorDetails, details.getAssessors()), new HashSet<AssessorDetails>()); subContent.addComponent(selectAssessors, 0); Button editButton = new Button(getString("lang.window.newentity.buttonModify")); subContent.addComponent(editButton, 1); editButton.addClickListener(this::editedAssessors); Button cancelButton = new Button(getString("lang.window.newentity.buttonCancel")); subContent.addComponent(cancelButton, 2); cancelButton.addClickListener(this::canceledEditAssessors); subWindowNewEntity.setContent(subContent); getMainUI().addWindow(subWindowNewEntity); }