List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
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();// w ww. j a v a 2 s . c om 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.common.pagemode.MainViewRegisterPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ANONYMOUS" }) @Override/*from w ww. ja va 2 s. c om*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); final String pageId = getPageId(parameters); getMenuItemFactory().createMainPageMenuBar(menuBar); final VerticalLayout registerLayout = new VerticalLayout(); registerLayout.setSizeFull(); final Panel formPanel = new Panel(); formPanel.setSizeFull(); registerLayout.addComponent(formPanel); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final RegisterUserRequest reqisterRequest = new RegisterUserRequest(); reqisterRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); reqisterRequest.setUsername(""); reqisterRequest.setEmail(""); reqisterRequest.setCountry(""); reqisterRequest.setUserpassword(""); final ClickListener reqisterListener = new RegisterUserClickListener(reqisterRequest, getApplicationManager()); getFormFactory().addRequestInputFormFields(formContent, new BeanItem<>(reqisterRequest), RegisterUserRequest.class, Arrays.asList(new String[] { "username", "email", "country", "userpassword" }), "Register", reqisterListener); content.addComponent(registerLayout); panel.setCaption(CITIZEN_INTELLIGENCE_AGENCY_MAIN); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MAIN_VIEW, ApplicationEventGroup.USER, CommonsViews.MAIN_VIEW_NAME, parameters, pageId); return content; }
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 v a 2 s.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.hack23.cia.web.impl.ui.application.views.user.document.pagemode.SearchDocumentPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" }) @Override/*w ww. j a va 2 s .com*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout panelContent = createPanelContent(); final String pageId = getPageId(parameters); getMenuItemFactory().createMainPageMenuBar(menuBar); final VerticalLayout searchLayout = new VerticalLayout(); searchLayout.setSizeFull(); panelContent.addComponent(searchLayout); final VerticalLayout searchresultLayout = new VerticalLayout(); searchresultLayout.setSizeFull(); final Panel formPanel = new Panel(); formPanel.setSizeFull(); searchresultLayout.addComponent(formPanel); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); panelContent.addComponent(searchresultLayout); final SearchDocumentRequest searchRequest = new SearchDocumentRequest(); searchRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); searchRequest.setMaxResults(MAX_RESULT_SIZE); searchRequest.setSearchExpression(""); final SearchDocumentResponseHandler handler = new SearchDocumentResponseHandler() { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void handle(final SearchDocumentResponse response) { searchresultLayout.removeAllComponents(); final BeanItemContainer<DocumentElement> documentActivityDataDataDataSource = new BeanItemContainer<>( DocumentElement.class, response.getResultElement()); getGridFactory().createBasicBeanItemGrid(searchresultLayout, documentActivityDataDataDataSource, "Document", new String[] { "rm", "createdDate", "madePublicDate", "documentType", "subType", "title", "subTitle", "status" }, new String[] { "label", "id", "hit", "relatedId", "org", "tempLabel", "numberValue", "systemDate", "kallId", "documentFormat", "documentUrlText", "documentUrlHtml", "documentStatusUrlXml", "committeeReportUrlXml" }, null, null, null); } }; final ClickListener searchListener = new SearchDocumentClickListener(searchRequest, getApplicationManager(), handler); getFormFactory().addRequestInputFormFields(formContent, new BeanItem<>(searchRequest), SearchDocumentRequest.class, Arrays.asList(new String[] { "searchExpression" }), "Search", searchListener); 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);//from www. j a v a 2 s .c o 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 ww .j av a 2s . c om*/ 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);// w ww . j a v a2 s . co m 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.klwork.explorer.ui.base.AbstractFormComponent.java
License:Apache License
/** * Inits the form./*from ww w . j av a2 s . c o m*/ */ protected void initForm() { form = new FormLayout(); form.setSizeFull(); addComponent(form); setComponentAlignment(form, Alignment.TOP_CENTER); }
From source file:com.klwork.explorer.ui.base.AbstractFormPoputWindow.java
License:Apache License
/** * Inits the form./* w w w . ja v a2 s . c om*/ */ protected void initForm() { form = new FormLayout(); form.setMargin(true); form.addStyleName(ExplorerLayout.THEME); form.setSizeFull(); //form.setValidationVisibleOnCommit(true); form.setImmediate(true); setContent(form); initFormSubComponent(); //setComponentAlignment(form, Alignment.TOP_CENTER); }
From source file:com.klwork.explorer.ui.form.FormPropertiesComponent.java
License:Apache License
protected void initForm() { form = new FormLayout(); form.setSizeFull(); addComponent(form); setComponentAlignment(form, Alignment.TOP_CENTER); }