List of usage examples for com.vaadin.ui FormLayout addComponent
@Override public void addComponent(Component c)
From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java
License:Apache License
@Override public <T extends Serializable> void addRequestInputFormFields(final FormLayout panelContent, final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties, final String buttonLabel, final ClickListener buttonListener) { final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType); fieldGroup.setItemDataSource(item);//from w ww . j a va 2 s.co m fieldGroup.setReadOnly(true); for (final String property : displayProperties) { final Field<?> buildAndBind; if (property.contains(HIDDEN_FIELD_NAME)) { buildAndBind = fieldGroup.buildAndBind(property, property, PasswordField.class); } else { buildAndBind = fieldGroup.buildAndBind(property); } buildAndBind.setId(MessageFormat.format("{0}.{1}", buttonLabel, property)); buildAndBind.setReadOnly(false); buildAndBind.setWidth(ContentSize.HALF_SIZE); panelContent.addComponent(buildAndBind); } final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds(); for (final Object property : unboundPropertyIds) { LOGGER.debug(LOG_MSG_PROPERTY, property); } final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth("50%"); final Button button = new Button(buttonLabel, new CommitFormWrapperClickListener(fieldGroup, buttonListener)); button.setId(buttonLabel); button.setWidth("25%"); button.setIcon(FontAwesome.PAW); verticalLayout.addComponent(button); verticalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); panelContent.addComponent(verticalLayout); }
From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java
License:Apache License
@Override public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties) { final Panel formPanel = new Panel(); formPanel.setSizeFull();//from w ww. jav a2s . co m panelContent.addComponent(formPanel); panelContent.setExpandRatio(formPanel, ContentRatio.GRID); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType); fieldGroup.setItemDataSource(item); fieldGroup.setReadOnly(true); for (final String property : displayProperties) { final Field<?> buildAndBind = fieldGroup.buildAndBind(property); buildAndBind.setWidth(ContentSize.FULL_SIZE); formContent.addComponent(buildAndBind); } final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds(); for (final Object property : unboundPropertyIds) { LOGGER.debug(LOG_MSG_PROPERTY, property); } }
From source file:com.hack23.cia.web.impl.ui.application.views.user.document.pagemode.DocumentDataPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" }) @Override/*w w w . j a va 2s . c o m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout panelContent = createPanelContent(); final String pageId = getPageId(parameters); final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager() .getDataContainer(DocumentElement.class); final DataContainer<DocumentContentData, String> documentContentDataDataContainer = getApplicationManager() .getDataContainer(DocumentContentData.class); getApplicationManager().getDataContainer(CommitteeProposalComponentData.class); final DocumentElement documentElement = documentElementDataContainer.load(pageId); if (documentElement != null) { getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId); LabelFactory.createHeader2Label(panelContent, DOCUMENT_DATA); final List<DocumentContentData> documentContentlist = documentContentDataDataContainer .getAllBy(DocumentContentData_.id, pageId); if (!documentContentlist.isEmpty()) { final Panel formPanel = new Panel(); formPanel.setSizeFull(); panelContent.addComponent(formPanel); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final Label htmlContent = new Label(documentContentlist.get(0).getContent(), ContentMode.HTML); formContent.addComponent(htmlContent); panelContent.setExpandRatio(formPanel, ContentRatio.GRID); } panel.setContent(panelContent); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId); } return panelContent; }
From source file:com.haulmont.cuba.web.LoginWindow.java
License:Apache License
protected FormLayout createLoginFormLayout(int fieldWidth, boolean localesSelectVisible) { FormLayout loginFormLayout = new FormLayout(); loginFormLayout.setStyleName("cuba-login-form"); loginFormLayout.setSpacing(true);// w w w .j a va2s. co m loginFormLayout.setSizeUndefined(); loginField.setCaption(messages.getMainMessage("loginWindow.loginField", resolvedLocale)); loginFormLayout.addComponent(loginField); loginField.setWidth(fieldWidth + "px"); loginField.setStyleName("username-field"); loginFormLayout.setComponentAlignment(loginField, Alignment.MIDDLE_CENTER); passwordField.setCaption(messages.getMainMessage("loginWindow.passwordField", resolvedLocale)); passwordField.setWidth(fieldWidth + "px"); passwordField.setAutocomplete(true); passwordField.setStyleName("password-field"); loginFormLayout.addComponent(passwordField); loginFormLayout.setComponentAlignment(passwordField, Alignment.MIDDLE_CENTER); if (localesSelectVisible) { localesSelect.setCaption(messages.getMainMessage("loginWindow.localesSelect", resolvedLocale)); localesSelect.setWidth(fieldWidth + "px"); localesSelect.setNullSelectionAllowed(false); loginFormLayout.addComponent(localesSelect); loginFormLayout.setComponentAlignment(localesSelect, Alignment.MIDDLE_CENTER); } if (rememberMeAllowed) { rememberMeCheckBox.setCaption(messages.getMainMessage("loginWindow.rememberMe", resolvedLocale)); rememberMeCheckBox.setStyleName("remember-me"); loginFormLayout.addComponent(rememberMeCheckBox); loginFormLayout.setComponentAlignment(rememberMeCheckBox, Alignment.MIDDLE_CENTER); } okButton.setCaption(messages.getMainMessage("loginWindow.okButton", resolvedLocale)); okButton.addClickListener(submitListener); okButton.setStyleName("cuba-login-submit"); okButton.setIcon(WebComponentsHelper.getIcon("app/images/login-button.png")); loginFormLayout.addComponent(okButton); loginFormLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); return loginFormLayout; }
From source file:com.hivesys.dashboard.view.preferences.PreferencesView.java
License:Apache License
public PreferencesView() { user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName()); setSpacing(true);/* w w w.j av a2 s.co m*/ setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); firstNameField = new TextField("First Name"); firstNameField.setWidth("50%"); form.addComponent(firstNameField); lastNameField = new TextField("Last Name"); lastNameField.setWidth("50%"); form.addComponent(lastNameField); titleField = new ComboBox("Title"); titleField.setInputPrompt("Please specify"); titleField.addItem("Mr."); titleField.addItem("Mrs."); titleField.addItem("Ms."); titleField.setNewItemsAllowed(true); form.addComponent(titleField); usernameField = new TextField("Username"); usernameField.setRequired(true); form.addComponent(usernameField); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); form.addComponent(sexField); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("50%"); emailField.setRequired(true); form.addComponent(emailField); locationField = new TextField("Location"); locationField.setWidth("50%"); locationField.setNullRepresentation(""); form.addComponent(locationField); phoneField = new TextField("Phone"); phoneField.setWidth("50%"); phoneField.setNullRepresentation(""); form.addComponent(phoneField); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); websiteField = new TextField("Website"); websiteField.setInputPrompt("http://"); websiteField.setWidth("100%"); form.addComponent(websiteField); bioField = new RichTextArea("Bio"); bioField.setWidth("100%"); bioField.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bioField); Button edit = new Button("Edit", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bioField.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bioField.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); fieldGroup = new BeanFieldGroup<>(User.class); fieldGroup.bindMemberFields(this); fieldGroup.setItemDataSource(user); form.setReadOnly(true); bioField.setReadOnly(true); }
From source file:com.jain.common.authenticate.LoginAction.java
License:Apache License
private void createFieldGroup(VerticalLayout layout) { I18NProvider provider = DefaultI18NResourceProvider.instance(); userName = new TextField("user.name"); userName.setCursorPosition(0);//from w ww .j ava 2 s .c om userName.setRequired(true); userName.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "user.name.title", JAction.LOGIN.getDisplayName())); userName.setDescription("user.name"); userName.setSizeFull(); userName.setStyleName(JNStyleConstants.J_FIELD); password = new PasswordField("password"); password.setRequired(true); password.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "password.title", JAction.LOGIN.getDisplayName())); password.setDescription("password"); password.setSizeFull(); password.setStyleName(JNStyleConstants.J_FIELD); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setStyleName(ApplicationTheme.VIEW); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); verticalLayout.setWidth("100%"); FormLayout formLayout = new FormLayout(); formLayout.setStyleName(ApplicationTheme.ALTERNATE_VIEW); formLayout.setSpacing(true); formLayout.setMargin(true); formLayout.setWidth("100%"); formLayout.addComponent(userName); formLayout.addComponent(password); verticalLayout.addComponent(formLayout); layout.addComponent(verticalLayout); }
From source file:com.logicbomb.newschool.MyAppWidgetSet.LoginWidget.java
public LoginWidget() { setMargin(true);/* ww w .ja v a2 s.co m*/ setSpacing(true); Panel iPanel = new Panel(); iPanel.addStyleName("backColorWhite"); iPanel.setSizeUndefined(); addComponent(iPanel); TextField iTextField = new TextField("Username"); iTextField.setWidth("300px"); iTextField.setRequired(true); iTextField.setInputPrompt("Your username (eg. joe@email.com)"); iTextField.setIcon(FontAwesome.USER); iTextField.addValidator(new EmailValidator("Username must be an email address")); iTextField.setInvalidAllowed(true); iTextField.focus(); PasswordField iPasswordField = new PasswordField("Password"); iPasswordField.setIcon(FontAwesome.KEY); iPasswordField.setWidth("300px"); iPasswordField.setRequired(true); iPasswordField.setValue(""); iPasswordField.setNullRepresentation(""); Button iButton = new Button("Login"); iButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addComponent(new Label("Login Successfully")); } }); FormLayout iFormLayout = new FormLayout(); iFormLayout.setSpacing(true); iFormLayout.setMargin(true); iFormLayout.addComponent(iTextField); iFormLayout.addComponent(iPasswordField); iFormLayout.addComponent(iButton); iPanel.setContent(iFormLayout); }
From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java
License:Open Source License
private VerticalLayout createUserDataSection(LspsUI ui, Person user) { VerticalLayout userData = new VerticalLayout(); Label userDataHeader = new Label("<h2>" + ui.getMessage("settings.userSection") + "</h2>", ContentMode.HTML);/*from w w w. j a v a 2 s.c o m*/ userData.addComponent(userDataHeader); FormLayout userDataContent = new FormLayout(); if ((userRights.contains(OsRights.CHANGE_OWN_PASSWORD)) || (userRights.contains(OsRights.MANAGE_PERSON))) { this.passwordField = new PasswordField(ui.getMessage("settings.password")); passwordField.setWidth("100%"); userDataContent.addComponent(passwordField); this.confirmation = new PasswordField(ui.getMessage("settings.passwordVerification")); confirmation.setWidth("100%"); userDataContent.addComponent(confirmation); } this.email = new TextField(ui.getMessage("settings.email")); email.setWidth("100%"); email.setValue(user.getEmail()); email.setNullRepresentation(""); userDataContent.addComponent(email); this.telephone = new TextField(ui.getMessage("settings.phoneNumber")); telephone.setWidth("100%"); telephone.setValue(user.getPhone()); telephone.setNullRepresentation(""); userDataContent.addComponent(telephone); userData.addComponent(userDataContent); return userData; }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * @param audioFile/*from ww w. j a v a 2s . com*/ * @return */ private CssLayout addDetails(AudioFile audioFile) { CssLayout details = new CssLayout(); details.setWidth("100%"); Label title = new Label("<h3>" + audioFile.getArtist() + "–" + audioFile.getTitle() + "</h3>", ContentMode.HTML); details.addComponent(title); title.setSizeUndefined(); TabSheet tabs = new TabSheet(); tabs.addStyleName(Runo.TABSHEET_SMALL); tabs.setWidth("100%"); tabs.setHeight("180px"); details.addComponent(tabs); FormLayout formLayout = new FormLayout(); tabs.addTab(formLayout, "Info"); Label text = new Label(audioFile.getTitle()); text.setCaption("Title:"); formLayout.addComponent(text); text = new Label(audioFile.getArtist()); text.setCaption("Artist:"); formLayout.addComponent(text); text = new Label(audioFile.getAlbum()); text.setCaption("Album:"); formLayout.addComponent(text); text = new Label(audioFile.getGenre()); text.setCaption("Genre:"); formLayout.addComponent(text); text = new Label(audioFile.getPrice() + "$"); text.setCaption("Price"); formLayout.addComponent(text); formLayout = new FormLayout(); tabs.addTab(formLayout, "Decription"); text = new Label(audioFile.getAbout()); formLayout.addComponent(text); formLayout = new FormLayout(); tabs.addTab(formLayout, "Lyrics"); text = new Label(audioFile.getLyrics()); formLayout.addComponent(text); return details; }
From source file:com.mcparland.john.vaadin_cookbook.CRUD.java
License:Apache License
/** * Create the form for the given item.//from w w w . jav a2 s . c o m * * @param item * the item. * @return a layout for the form. */ @SuppressWarnings("serial") private Layout createForm(Item item) { FormLayout layout = new FormLayout(); layout.setSpacing(true); layout.setMargin(true); final FieldGroup group = new FieldGroup(item); for (Object propertyId : group.getUnboundPropertyIds()) { layout.addComponent(group.buildAndBind(propertyId)); } Button button = new Button("Commmit"); button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { group.commit(); } catch (CommitException e) { Notification.show(e.getCause().getMessage(), Notification.Type.ERROR_MESSAGE); } } }); layout.addComponent(button); return layout; }