List of usage examples for com.vaadin.ui HorizontalLayout setVisible
@Override public void setVisible(boolean visible)
From source file:com.cerebro.gorgone.landingpage.SignInWindow.java
private Component setFirstStep() { VerticalLayout firstStep = new VerticalLayout(); firstStep.setMargin(true);//from w w w . jav a 2 s. com // Body HorizontalLayout body = new HorizontalLayout(); FormLayout datiIniziali = new FormLayout(); TextField nomePG = new TextField("Nome del Personaggio"); nomePG.setRequired(true); TextField cognomePG = new TextField("Cognome del Personaggio"); cognomePG.setRequired(true); OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio"); sessoPG.setRequired(true); sessoPG.addItems("Maschio", "Femmina"); ComboBox razzaPG = new ComboBox("Razza"); razzaPG.setRequired(true); Slider age = new Slider("Et"); age.setImmediate(true); age.setWidth("200px"); age.setVisible(false); HorizontalLayout ageDescription = new HorizontalLayout(); ageDescription.setHeight("250px"); Label ageText = new Label("Valore dell'et: "); Label ageValue = new Label(age.getValue().toString()); Label periodoVita = new Label(""); ageDescription.addComponents(ageText, ageValue, periodoVita); age.addValueChangeListener((Property.ValueChangeEvent event) -> { System.out.println("Valore: " + age.getValue().toString()); ageValue.setValue(age.getValue().toString()); Double value = (100 * (age.getValue()) / (age.getMax())); if (value < 14) { periodoVita.setValue("Bambino"); } else if (value > 14 && value < 24) { periodoVita.setValue("Adolescenza"); } else if (value > 24 && value < 73) { periodoVita.setValue("Et adulta"); } else if (value > 73) { periodoVita.setValue("Et anziana"); } }); ageDescription.addComponents(ageText, ageValue, periodoVita); ageDescription.setVisible(false); datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG, age, ageDescription); Panel descrizioneRazza = new Panel(); CssLayout descrizioneRazzaContent = new CssLayout(); descrizioneRazza.setWidth("400px"); descrizioneRazza.setHeight("500px"); descrizioneRazza.setContent(descrizioneRazzaContent); // Dettagli di popolazione e comportamento ComboBox TableQuery tq_races = new TableQuery(DatabaseTables.RACES_TABLE, connPool); tq_races.setVersionColumn(DatabaseTables.RACES_VERSION); SQLContainer container_races = null; try { container_races = new SQLContainer(tq_races); } catch (Exception ex) { logger.error(ex.getMessage()); } razzaPG.setContainerDataSource(container_races); razzaPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); razzaPG.setItemCaptionPropertyId(DatabaseTables.RACES_NAME); razzaPG.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (razzaPG.getValue() != null) { logger.info("Razza selezionata: " + razzaPG.getValue()); age.setVisible(true); ageDescription.setVisible(true); descrizioneRazzaContent.removeAllComponents(); Item item = razzaPG.getContainerDataSource().getItem(razzaPG.getValue()); race = (String) item.getItemProperty(DatabaseTables.RACES_NAME).getValue(); Label nameRace = new Label(race); FileResource imageSrc = new FileResource( new File(MyUI.basePath + item.getItemProperty(DatabaseTables.RACES_IMAGE).getValue())); Image imageRace = new Image(null, imageSrc); imageRace.setWidth("200px"); Label descriptionRace = new Label( (String) item.getItemProperty(DatabaseTables.RACES_DESCRIPTION).getValue(), ContentMode.HTML); min_age = (int) item.getItemProperty(DatabaseTables.RACES_MIN_AGE).getValue(); max_age = (int) item.getItemProperty(DatabaseTables.RACES_MAX_AGE).getValue(); age.setMin(min_age); age.setMax(max_age); strenght = (int) item.getItemProperty(DatabaseTables.RACES_STRENGHT).getValue(); resistance = (int) item.getItemProperty(DatabaseTables.RACES_RESISTANCE).getValue(); agility = (int) item.getItemProperty(DatabaseTables.RACES_AGILITY).getValue(); intelligence = (int) item.getItemProperty(DatabaseTables.RACES_INTELLIGENCE).getValue(); wisdom = (int) item.getItemProperty(DatabaseTables.RACES_WISDOM).getValue(); charm = (int) item.getItemProperty(DatabaseTables.RACES_CHARM).getValue(); Label min_ageL = new Label("Et minima: " + min_age); Label max_ageL = new Label("Et masima " + max_age); // Panel levels = new Panel(); // VerticalLayout levelsContent = new VerticalLayout(); // levels.setContent(levelsContent); // Label strenghtL = new Label("Forza: " + strenght); // levelsContent.addComponents(strenghtL); String levelTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>" + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght + "</td>" + "<td>" + resistance + "</td>" + "<td>" + agility + "</td>" + "<td>" + intelligence + "</td>" + "<td>" + wisdom + "</td>" + "<td>" + charm + "</td>" + "</tr></table>"; Label levels = new Label(levelTable, ContentMode.HTML); descrizioneRazzaContent.addComponents(nameRace, imageRace, descriptionRace, min_ageL, max_ageL, levels); } } }); body.addComponents(datiIniziali, descrizioneRazza); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { user.setNomePG(nomePG.getValue()); user.setCognomePG(cognomePG.getValue()); user.setSessoPG(sessoPG.getValue().toString()); user.setRazzaPG(race); user.setEtaPG(age.getValue().toString()); user.setForzaPG(strenght); user.setResistenzaPG(resistance); user.setAgilitaPG(agility); user.setIntelligenzaPG(intelligence); user.setSaggezzaPG(wisdom); user.setCarismaPG(charm); this.setContent(setSecondStep()); }); footer.addComponents(next, createCancelButton()); firstStep.addComponents(setHeader("2/4"), body, footer); return firstStep; }
From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java
License:Open Source License
private Component generateMemberBlock(final SimpleUser member) { CssLayout memberBlock = new CssLayout(); memberBlock.addStyleName("member-block"); VerticalLayout blockContent = new VerticalLayout(); HorizontalLayout blockTop = new HorizontalLayout(); blockTop.setSpacing(true);/*from w ww . jav a 2 s . c om*/ Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getAvatarid(), 100); blockTop.addComponent(memberAvatar); VerticalLayout memberInfo = new VerticalLayout(); HorizontalLayout layoutButtonDelete = new HorizontalLayout(); layoutButtonDelete.setVisible(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER)); layoutButtonDelete.setWidth("100%"); Label emptylb = new Label(""); layoutButtonDelete.addComponent(emptylb); layoutButtonDelete.setExpandRatio(emptylb, 1.0f); Button deleteBtn = new Button(); deleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { UserService userService = ApplicationContextUtil .getSpringBean(UserService.class); userService.pendingUserAccounts(Arrays.asList(member.getUsername()), AppContext.getAccountId()); EventBusFactory.getInstance() .post(new UserEvent.GotoList(UserListViewImpl.this, null)); } } }); } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); layoutButtonDelete.addComponent(deleteBtn); memberInfo.addComponent(layoutButtonDelete); ButtonLink userAccountLink = new ButtonLink(member.getDisplayName()); userAccountLink.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new UserEvent.GotoRead(UserListViewImpl.this, member.getUsername())); } }); userAccountLink.setWidth("100%"); userAccountLink.setHeight("100%"); memberInfo.addComponent(userAccountLink); Label memberEmailLabel = new Label( "<a href='mailto:" + member.getUsername() + "'>" + member.getUsername() + "</a>", ContentMode.HTML); memberEmailLabel.addStyleName("member-email"); memberEmailLabel.setWidth("100%"); memberInfo.addComponent(memberEmailLabel); Label memberSinceLabel = new Label("Member since: " + AppContext.formatDate(member.getRegisteredtime())); memberSinceLabel.addStyleName("member-email"); memberSinceLabel.setWidth("100%"); memberInfo.addComponent(memberSinceLabel); if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getRegisterstatus())) { final VerticalLayout waitingNotLayout = new VerticalLayout(); Label infoStatus = new Label("Waiting for accept invitation"); infoStatus.addStyleName("member-email"); waitingNotLayout.addComponent(infoStatus); ButtonLink resendInvitationLink = new ButtonLink("Resend Invitation", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { UserService userService = ApplicationContextUtil.getSpringBean(UserService.class); userService.updateUserAccountStatus(member.getUsername(), member.getAccountId(), RegisterStatusConstants.VERIFICATING); waitingNotLayout.removeAllComponents(); Label statusEmail = new Label("Sending invitation email"); statusEmail.addStyleName("member-email"); waitingNotLayout.addComponent(statusEmail); } }); resendInvitationLink.setStyleName("link"); resendInvitationLink.addStyleName("member-email"); waitingNotLayout.addComponent(resendInvitationLink); memberInfo.addComponent(waitingNotLayout); } else if (RegisterStatusConstants.ACTIVE.equals(member.getRegisterstatus())) { Label lastAccessTimeLbl = new Label("Logged in " + DateTimeUtils.getPrettyDateValue(member.getLastaccessedtime(), AppContext.getUserLocale())); lastAccessTimeLbl.addStyleName("member-email"); memberInfo.addComponent(lastAccessTimeLbl); } else if (RegisterStatusConstants.VERIFICATING.equals(member.getRegisterstatus())) { Label infoStatus = new Label("Sending invitation email"); infoStatus.addStyleName("member-email"); memberInfo.addComponent(infoStatus); } blockTop.addComponent(memberInfo); blockTop.setExpandRatio(memberInfo, 1.0f); blockTop.setWidth("100%"); blockContent.addComponent(blockTop); if (member.getRoleid() != null) { String memberRoleLinkPrefix = "<a href=\"" + AccountLinkBuilder.generatePreviewFullRoleLink(member.getRoleid()) + "\""; Label memberRole = new Label(); memberRole.setContentMode(ContentMode.HTML); if (member.getIsAccountOwner() != null && member.getIsAccountOwner()) { memberRole.setValue(memberRoleLinkPrefix + "style=\"color: #B00000;\">" + "Account Owner" + "</a>"); } else { memberRole.setValue(memberRoleLinkPrefix + "style=\"color:gray;font-size:12px;\">" + member.getRoleName() + "</a>"); } memberRole.setSizeUndefined(); blockContent.addComponent(memberRole); blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT); } else if (member.getIsAccountOwner() != null && member.getIsAccountOwner() == Boolean.TRUE) { Label memberRole = new Label(); memberRole.setContentMode(ContentMode.HTML); memberRole.setValue("<a style=\"color: #B00000;\">" + "Account Owner" + "</a>"); memberRole.setSizeUndefined(); blockContent.addComponent(memberRole); blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT); } else { Label lbl = new Label(); lbl.setHeight("10px"); blockContent.addComponent(lbl); } blockContent.setWidth("100%"); memberBlock.addComponent(blockContent); return memberBlock; }
From source file:com.ocs.dynamo.ui.composite.dialog.EntityPopupDialog.java
License:Apache License
@Override protected void doBuildButtonBar(HorizontalLayout buttonBar) { // in read-only mode, display only an "OK" button that closes the dialog buttonBar.setVisible(formOptions.isReadOnly()); if (formOptions.isReadOnly()) { Button okButton = new Button(messageService.getMessage("ocs.ok")); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1889018073135108348L; @Override//from ww w . j av a2 s . c om public void buttonClick(ClickEvent event) { close(); } }); buttonBar.addComponent(okButton); } }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private HorizontalLayout getPC() { VerticalLayout cAgentInfo = new VerticalLayout(); final HorizontalLayout cPlaceholder = new HorizontalLayout(); cAgentInfo.setMargin(new MarginInfo(true, true, true, true)); cAgentInfo.setStyleName("c_details_test"); final VerticalLayout cLBody = new VerticalLayout(); cLBody.setStyleName("c_body_visible"); tb = new Table("Linked child accounts"); // addLinksTable(); final VerticalLayout cAllProf = new VerticalLayout(); HorizontalLayout cProfActions = new HorizontalLayout(); final FormLayout cProfName = new FormLayout(); cProfName.setStyleName("frm_profile_name"); cProfName.setSizeUndefined();// w ww . j a va 2s. co m final Label lbProf = new Label(); final TextField tFProf = new TextField(); lbProf.setCaption("Profile Name: "); lbProf.setValue("Certified Authorized User."); tFProf.setCaption(lbProf.getCaption()); cProfName.addComponent(lbProf); final Button btnEdit = new Button(); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setStyleName("btn_link"); btnEdit.setDescription("Edit profile name"); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel Profile name editting."); Button btnAdd = new Button("+"); // btnAdd.setIcon(FontAwesome.EDIT); btnAdd.setStyleName("btn_link"); btnAdd.setDescription("Set new profile"); Button btnRemove = new Button("-"); // btnRemove.setIcon(FontAwesome.EDIT); btnRemove.setStyleName("btn_link"); btnRemove.setDescription("Remove current profile"); // cProf.addComponent(cProfName); cProfActions.addComponent(btnEdit); cProfActions.addComponent(btnCancel); cProfActions.addComponent(btnAdd); cProfActions.addComponent(btnRemove); btnCancel.setVisible(false); cAllProf.addComponent(cProfName); cAllProf.addComponent(cProfActions); cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER); cLBody.addComponent(cAllProf); // cLBody.addComponent(tb); tb.setSelectable(true); cAgentInfo.addComponent(cLBody); btnLink = new Button("Add New Link"); btnLink.setIcon(FontAwesome.LINK); btnLink.setDescription("Link new account."); // cLBody.addComponent(btnLink); // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT); btnLink.addClickListener(new LinkClickHandler()); cPlaceholder.setVisible(false); addLinkUserContainer(); cPlaceholder.setWidth("100%"); cLBody.addComponent(cPlaceholder); cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER); HorizontalLayout c = new HorizontalLayout(); c.addComponent(cAgentInfo); btnEdit.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -8427226211153164650L; @Override public void buttonClick(ClickEvent event) { if (btnEdit.getIcon().equals(FontAwesome.EDIT)) { tFProf.setValue(lbProf.getValue()); tFProf.selectAll(); cProfName.replaceComponent(lbProf, tFProf); btnEdit.setIcon(FontAwesome.SAVE); btnCancel.setVisible(true); return; } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) { lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); return; } lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnCancel.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -2870045546205986347L; @Override public void buttonClick(ClickEvent event) { cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder)); btnRemove.addClickListener(new RemoveProfileHandler(pop)); return c; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.AddPatientView.java
License:Open Source License
/** * initializes the hla typing registration layout * /* w ww . ja v a 2 s . c o m*/ * @return */ void hlaTypingLayout() { hlaLayout.removeAllComponents(); hlaLayout.setWidth("100%"); hlaLayout.setVisible(false); hlaLayout.setMargin(new MarginInfo(true, false, false, false)); hlaLayout.setHeight(null); hlaLayout.setSpacing(true); hlaInfo = new CustomVisibilityComponent(new Label("HLA Typing")); ((Label) hlaInfo.getInnerComponent()).setHeight("24px"); Component hlaContext = Utils.questionize(hlaInfo, "Register available HLA typing for this patient (one allele per line)", "HLA Typing"); hlaLayout.addComponent(hlaContext); HorizontalLayout hlalayout = new HorizontalLayout(); VerticalLayout hlaLayout1 = new VerticalLayout(); hlaLayout1.addComponent(registerHLAI); hlaLayout1.addComponent(hlaItypes); VerticalLayout hlaLayout2 = new VerticalLayout(); hlaLayout2.addComponent(registerHLAII); hlaLayout2.addComponent(hlaIItypes); hlalayout.addComponent(hlaLayout1); hlalayout.addComponent(hlaLayout2); hlalayout.setSpacing(true); typingMethod.addItems(datahandler.getOpenBisClient().getVocabCodesForVocab("Q_HLA_TYPING_METHODS")); hlaLayout.addComponent(typingMethod); hlaLayout.addComponent(hlalayout); }
From source file:helpers.Utils.java
License:Open Source License
public static HorizontalLayout questionize(Component c, final String info, final String header) { final HorizontalLayout res = new HorizontalLayout(); res.setSpacing(true);//from w w w .j a va 2 s . co m if (c instanceof CustomVisibilityComponent) { CustomVisibilityComponent custom = (CustomVisibilityComponent) c; c = custom.getInnerComponent(); custom.addListener(new VisibilityChangeListener() { @Override public void setVisible(boolean b) { res.setVisible(b); } }); } res.setVisible(c.isVisible()); res.setCaption(c.getCaption()); c.setCaption(null); res.addComponent(c); PopupView pv = new PopupView(new Content() { @Override public Component getPopupComponent() { Label l = new Label(info, ContentMode.HTML); l.setCaption(header); l.setIcon(FontAwesome.INFO); l.setWidth("250px"); l.addStyleName("info"); return new VerticalLayout(l); } @Override public String getMinimizedValueAsHTML() { return "[?]"; } }); pv.setHideOnMouseOut(false); res.addComponent(pv); return res; }
From source file:org.accelerators.activiti.admin.ui.GroupCreateForm.java
License:Open Source License
/** * //w w w. j ava2s .c o m * @param app */ public GroupCreateForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false); // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons create = new Button(app.getMessage(Messages.Create), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(create, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Init group types types = new String[] { app.getMessage(Messages.Assignment), app.getMessage(Messages.Program), app.getMessage(Messages.Project), app.getMessage(Messages.Role), app.getMessage(Messages.Team), app.getMessage(Messages.Unit) }; // Create combo box for group types groupTypes = new ComboBox("type"); groupTypes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); for (int i = 0; i < types.length; i++) { groupTypes.addItem(types[i]); } // Propagate changes directly groupTypes.setImmediate(true); // Allow adding new group types groupTypes.setNewItemsAllowed(true); // Get available users members = new TwinColSelect(app.getMessage(Messages.Members), app.getAdminService().getUsers()); // Set column headers members.setLeftColumnCaption(app.getMessage(Messages.AvailableUsers)); members.setRightColumnCaption(app.getMessage(Messages.GroupMembers)); // Propagate changes directly members.setImmediate(true); // Set max width members.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("type")) { groupTypes.setWidth("100%"); groupTypes.setRequired(false); groupTypes.setCaption(app.getMessage(Messages.Types)); return groupTypes; } Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("id")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set error message tf.setRequiredError("Id is missing"); // Set read only tf.setReadOnly(false); } else if (propertyId.equals("name")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set error message tf.setRequiredError(app.getMessage(Messages.GroupNameIsMissing)); } field.setWidth("100%"); return field; } }); }
From source file:org.accelerators.activiti.admin.ui.GroupEditForm.java
License:Open Source License
/** * /*from ww w . jav a 2s. co m*/ * @param app */ public GroupEditForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false); // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons save = new Button(app.getMessage(Messages.Save), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(save, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Init group types types = new String[] { app.getMessage(Messages.Assignment), app.getMessage(Messages.Program), app.getMessage(Messages.Project), app.getMessage(Messages.Role), app.getMessage(Messages.Team), app.getMessage(Messages.Unit) }; // Create combo box for group types groupTypes = new ComboBox("type"); groupTypes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); for (int i = 0; i < types.length; i++) { groupTypes.addItem(types[i]); } // Propagate changes directly groupTypes.setImmediate(true); // Allow adding new group types groupTypes.setNewItemsAllowed(true); // Get available users members = new TwinColSelect(app.getMessage(Messages.Members), app.getAdminService().getUsers()); // Set column headers members.setLeftColumnCaption(app.getMessage(Messages.AvailableUsers)); members.setRightColumnCaption(app.getMessage(Messages.GroupMembers)); // Propagate changes directly members.setImmediate(true); // Set max width members.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("type")) { groupTypes.setWidth("100%"); groupTypes.setRequired(false); groupTypes.setCaption(app.getMessage(Messages.Types)); return groupTypes; } Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("id")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as read-only. Changing the id will create a new // group. tf.setReadOnly(true); // Set as required field // tf.setRequired(true); // Set error message tf.setRequiredError("Id is missing"); } else if (propertyId.equals("name")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set error message tf.setRequiredError(app.getMessage(Messages.GroupNameIsMissing)); } field.setWidth("100%"); return field; } }); }
From source file:org.accelerators.activiti.admin.ui.UserCreateForm.java
License:Open Source License
public UserCreateForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false);/*w ww . j a v a 2 s. c om*/ // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons create = new Button(app.getMessage(Messages.Create), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(create, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Get all available groups groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups()); // Set column headers groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups)); groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups)); // Propagate changes directly groups.setImmediate(true); // Max width groups.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { Field field = super.createField(item, propertyId, uiContext); field.setWidth("100%"); // field.setVisible(false); if (propertyId.equals("id")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set validator example, should not be restricted in the // admin ui // tf.addValidator(new // RegexpValidator("^[a-zA-Z0-9_-]{4,20}", // app.getMessage(Messages.InvalidUsername))); // Set error message tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing)); } else if (propertyId.equals("password")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set as secret (todo: use password field instead of text // field) tf.setSecret(true); // Set error message tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing)); } else if (propertyId.equals("email")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field, should not be required by default // in the admin ui // tf.setRequired(true); // Set error message // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing)); /* Add a validator for email and make it required */ field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError))); } else if (propertyId.equals("firstName")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } else if (propertyId.equals("lastName")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } return field; } }); }
From source file:org.accelerators.activiti.admin.ui.UserEditForm.java
License:Open Source License
public UserEditForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false);/*ww w . j ava2 s .co m*/ // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons save = new Button(app.getMessage(Messages.Save), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(save, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Get all available groups groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups()); // Set column headers groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups)); groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups)); // Propagate changes directly groups.setImmediate(true); // Max width groups.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("id")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as read-only. Changing the id will create a new user. tf.setReadOnly(true); // Set as required field //tf.setRequired(true); // Set validator example, should not be restricted in the // admin ui // tf.addValidator(new // RegexpValidator("^[a-zA-Z0-9_-]{4,20}", // app.getMessage(Messages.InvalidUsername))); // Set error message tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing)); } else if (propertyId.equals("password")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set as secret (todo: use password field instead of text // field) tf.setSecret(true); // Set error message tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing)); } else if (propertyId.equals("email")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field, should not be required by default // in the admin ui // tf.setRequired(true); // Set error message // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing)); /* Add a validator for email and make it required */ field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError))); } else if (propertyId.equals("firstName")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } else if (propertyId.equals("lastName")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } field.setWidth("100%"); return field; } }); }