List of usage examples for com.vaadin.ui FormLayout setWidth
@Override public void setWidth(String width)
From source file:de.escidoc.admintool.view.resource.FormLayoutFactory.java
License:Open Source License
public static FormLayout create() { final FormLayout formLayout = new FormLayout(); formLayout.setMargin(true);// w w w. j a v a 2 s.com formLayout.setWidth("800px"); formLayout.setHeight("100%"); return formLayout; }
From source file:fr.univlorraine.mondossierweb.views.windows.PreferencesApplicationWindow.java
License:Apache License
/** * Cre une fentre d'dition des preferences applicative * @param prfrence diter//from www . jav a2 s.co m */ public PreferencesApplicationWindow(PreferencesApplication prefApp) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Formulaire */ fieldGroup = new BeanFieldGroup<>(PreferencesApplication.class); fieldGroup.setItemDataSource(prefApp); fieldGroup.setFieldFactory(new FieldGroupFieldFactory() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("rawtypes") public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) { if (fieldType == NativeSelect.class) { final NativeSelect field = new NativeSelect(); field.addItem("true"); field.addItem("false"); field.setNullSelectionAllowed(false); field.setImmediate(true); //field.setValue(centre.getTemSrv()); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { field.setValue(event.getProperty().getValue()); } }); return fieldType.cast(field); } else { final TextField field = new TextField(); field.setImmediate(true); field.addTextChangeListener(new FieldEvents.TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { if (!field.isReadOnly()) { field.setValue(event.getText()); } } }); return fieldType.cast(field); } } }); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".confAppTable." + fieldName, null, getLocale()); //Si on est sur un parametre booleen if (fieldName.equals("valeur") && estUneValeurBooleenne(prefApp.getValeur())) { //On forme le nativeSelect Field<?> field = fieldGroup.buildAndBind(caption, fieldName, NativeSelect.class); formLayout.addComponent(field); } else { Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } formLayout.addComponent(field); } } fieldGroup.getField("prefId").setReadOnly(prefApp.getPrefId() != null); fieldGroup.getField("prefDesc").setReadOnly(prefApp.getPrefDesc() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); /* Enregistre la conf saisie */ configController.saveAppParameter(prefApp); /* Ferme la fentre */ close(); } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:fr.univlorraine.mondossierweb.views.windows.SwapUtilisateurWindow.java
License:Apache License
/** * Cre une fentre d'dition du swap utilisateur * @param swap utilisateur diter//from www.java 2 s . c o m */ public SwapUtilisateurWindow(UtilisateurSwap swap, boolean ajout) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ if (ajout) { setCaption(applicationContext.getMessage(NAME + ".title.ajout", null, getLocale())); } else { setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); } /* Formulaire */ fieldGroup = new BeanFieldGroup<>(UtilisateurSwap.class); fieldGroup.setItemDataSource(swap); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".swapUserTable." + fieldName, null, getLocale()); Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } if (field instanceof DateField) { ((DateField) field).setResolution(DateField.RESOLUTION_MIN); } formLayout.addComponent(field); } //fieldGroup.getField("loginCible").setReadOnly(swap.getLoginCible() != null); fieldGroup.getField("loginSource").setReadOnly(swap.getLoginSource() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); boolean commitok = true; if (ajout) { //On regarde si le login source n'est pas dj dans la table String loginSource = (String) fieldGroup.getField("loginSource").getValue(); if (configController.getSwapUtilisateur(loginSource) != null) { commitok = false; //afficher message d'erreur Notification.show(applicationContext.getMessage(NAME + ".error.loginexistant", null, UI.getCurrent().getLocale()), Notification.Type.ERROR_MESSAGE); } } if (commitok) { /* Enregistre le swap saisie */ configController.saveSwap(swap); /* Ferme la fentre */ close(); } } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:info.magnolia.messages.app.MessagesViewImpl.java
License:Open Source License
@Inject public MessagesViewImpl(SimpleTranslator i18n) { this.i18n = i18n; // create form and data item final Message message = new Message(); // message POJO BeanItem<Message> messageItem = new BeanItem<Message>(message); final FieldGroup form = new FieldGroup(); form.setItemDataSource(messageItem); Field<String> subjectField = createSubjectTextField(); Field<String> messageBodyField = createMessageBodyTextField(); Field<?> typeField = createTypeSelectionField(); Field<?> scopeField = createScopeSelectionField(); userOrGroupIdField = createUserOrGroupIdTextField(); // disable user/group field if not necessary scopeField.addValueChangeListener(new ValueChangeListener() { @Override/*from w w w .j a va 2s . c o m*/ public void valueChange(ValueChangeEvent event) { updateUserOrGroupField((String) event.getProperty().getValue()); } }); form.bind(subjectField, "title"); form.bind(messageBodyField, "content"); form.bind(typeField, "type"); form.bind(scopeField, "scope"); form.bind(userOrGroupIdField, "user"); // FieldGroup overrides fields' own enabled property with its own. updateUserOrGroupField(message.getScope()); FormLayout layout = new FormLayout(); layout.addComponent(subjectField); layout.addComponent(messageBodyField); layout.addComponent(typeField); layout.addComponent(scopeField); layout.addComponent(userOrGroupIdField); layout.setSpacing(true); layout.setMargin(false); layout.setWidth("100%"); // send button NativeButton sendButton = new NativeButton(i18n.translate("messages-app.app.button.sendMessage"), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { form.commit(); String subject = message.getTitle(); String content = message.getContent(); MessageType type = message.getType(); String scope = message.getScope(); if (MESSAGE_SCOPE_LOCAL.equals(scope)) { listener.handleLocalMessage(type, subject, content); } else if (MESSAGE_SCOPE_GLOBAL.equals(scope)) { listener.handleGlobalMessage(type, subject, content); } else if (MESSAGE_SCOPE_GROUP.equals(scope)) { // message is bound to FieldGroup - hence the group name is to be retrieved from the user field of the message final String groupName = message.getUser(); listener.handleGroupMessage(groupName, type, subject, content); } else { // User... final String userName = message.getUser(); listener.handleUserMessage(userName, type, subject, content); } } catch (CommitException e) { } } }); sendButton.addStyleName("btn-dialog"); sendButton.addStyleName("commit"); // reset button NativeButton resetButton = new NativeButton(i18n.translate("messages-app.app.button.reset"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { message.reset(); form.discard(); } }); resetButton.addStyleName("btn-dialog"); resetButton.addStyleName("cancel"); HorizontalLayout buttons = new HorizontalLayout(); buttons.addStyleName("buttons"); buttons.setSpacing(true); buttons.addComponent(sendButton); buttons.addComponent(resetButton); layout.addComponent(buttons); // intro text Label intro = new Label(i18n.translate("messages-app.app.label.intro"), ContentMode.HTML); intro.addStyleName("intro"); CssLayout container = new CssLayout(); container.setSizeFull(); container.addStyleName("small-app-panel"); container.addComponent(layout); CssLayout root = new CssLayout(); root.setSizeFull(); root.setWidth("900px"); root.setStyleName("small-app"); root.addComponent(intro); root.addComponent(container); component = root; }
From source file:my.vaadin.profile.Forms.java
public Forms() { setSpacing(true);/* w ww . ja va2s .co m*/ setMargin(true); Label title = new Label("Signup Form"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("900px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); //StringGenerator sg = new StringGenerator(); TextField zID = new TextField("zID"); zID.setValue("z123456"); zID.setRequired(true); form.addComponent(zID); TextField name = new TextField("Name"); name.setValue("loreum"); //name.setWidth("50%"); form.addComponent(name); PasswordField pw = new PasswordField("Set Password"); pw.setRequired(true); form.addComponent(pw); DateField birthday = new DateField("Birthday"); birthday.setDateFormat("dd-MM-yyyy"); birthday.setValue(new java.util.Date()); form.addComponent(birthday); OptionGroup gender = new OptionGroup("Gender"); gender.addItem("Male"); gender.addItem("Female"); //sex.select("Male"); gender.addStyleName("horizontal"); form.addComponent(gender); section = new Label("Class Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); TextField classID = new TextField("Class ID"); classID.setValue("INFS2605"); classID.setRequired(true); //classID.setWidth("50%"); form.addComponent(classID); TextField groupID = new TextField("Group ID"); groupID.setValue("1"); //groupID.setWidth("50%"); groupID.setRequired(true); form.addComponent(groupID); Button confirm = new Button("Confirm"); confirm.addStyleName("primary"); form.addComponent(confirm); 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(confirm); }
From source file:org.apache.usergrid.chop.webapp.view.chart.layout.ChartLayout.java
License:Apache License
private FormLayout addFormLayout() { FormLayout formLayout = new FormLayout(); formLayout.setWidth("250px"); formLayout.setHeight("250px"); formLayout.addStyleName("outlined"); formLayout.setSpacing(true);//from w w w .j a va 2 s. com addComponent(formLayout, "left: 10px; top: 10px;"); return formLayout; }
From source file:org.apache.usergrid.chop.webapp.view.user.UserLayout.java
License:Apache License
private FormLayout addFormLayout(int x, int y) { FormLayout formLayout = new FormLayout(); formLayout.setWidth(String.format("%spx", x)); formLayout.setHeight(String.format("%spx", y)); formLayout.addStyleName("outlined"); formLayout.setSpacing(true);/* w w w. j a v a 2 s.c o m*/ addComponent(formLayout, "left: 350px; top: 50px;"); return formLayout; }
From source file:org.opencms.ui.dialogs.CmsCopyMoveDialog.java
License:Open Source License
/** * Initializes the form fields.<p> * * @return the form component/*w w w . j a v a2 s . co m*/ */ private FormLayout initForm() { FormLayout form = new FormLayout(); form.setWidth("100%"); m_targetPath = new CmsPathSelectField(); m_targetPath.setCaption( CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_TARGET_0)); m_targetPath.setFileSelectCaption( CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_SELECT_TARGET_CAPTION_0)); m_targetPath.setResourceFilter(CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireFolder()); m_targetPath.setWidth("100%"); form.addComponent(m_targetPath); if (m_dialogMode != DialogMode.move) { m_actionCombo = new ComboBox(); m_actionCombo .setCaption(CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_COPYPAGE_COPY_MODE_0)); m_actionCombo.setNullSelectionAllowed(false); m_actionCombo.setNewItemsAllowed(false); m_actionCombo.setWidth("100%"); // m_actionCombo.addItem(Action.automatic); // m_actionCombo.setItemCaption( // Action.automatic, // CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_AUTOMATIC_0)); // m_actionCombo.setValue(Action.automatic); if (m_context.getResources().size() == 1) { if (m_context.getResources().get(0).isFile()) { m_actionCombo.addItem(Action.copy_all); m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_AS_NEW_0)); m_actionCombo.addItem(Action.copy_sibling_all); m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_CREATE_SIBLING_0)); if (m_dialogMode == DialogMode.copy_and_move) { m_actionCombo.addItem(Action.move); m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_FILE_0)); } } else { CmsResource folder = m_context.getResources().get(0); m_hasContainerPageDefaultFile = hasContainerPageDefaultFile(folder); if (m_hasContainerPageDefaultFile) { m_actionCombo.addItem(Action.container_page_automatic); m_actionCombo.setItemCaption(Action.container_page_automatic, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_AUTOMATIC_0)); m_actionCombo.addItem(Action.container_page_copy); m_actionCombo.setItemCaption(Action.container_page_copy, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONTAINERPAGE_COPY_0)); m_actionCombo.addItem(Action.container_page_reuse); m_actionCombo.setItemCaption(Action.container_page_reuse, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONTAINERPAGE_REUSE_0)); } if (CmsResourceTypeFolderSubSitemap.isSubSitemap(folder)) { m_actionCombo.addItem(Action.sub_sitemap); m_actionCombo.setItemCaption(Action.sub_sitemap, CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_SUBSITEMAP_0)); } m_actionCombo.addItem(Action.copy_sibling_mixed); m_actionCombo.setItemCaption(Action.copy_sibling_mixed, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_NO_SIBLINGS_0)); m_actionCombo.addItem(Action.copy_all); m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_0)); m_actionCombo.addItem(Action.copy_sibling_all); m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils.getMessageText( org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_CREATE_SIBLINGS_0)); if (m_dialogMode == DialogMode.copy_and_move) { m_actionCombo.addItem(Action.move); m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils.getMessageText( org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_FOLDER_0)); } } } else { m_actionCombo.addItem(Action.copy_sibling_mixed); m_actionCombo.setItemCaption(Action.copy_sibling_mixed, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_NO_SIBLINGS_0)); m_actionCombo.addItem(Action.copy_all); m_actionCombo.setItemCaption(Action.copy_all, CmsVaadinUtils.getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_ALL_0)); m_actionCombo.addItem(Action.copy_sibling_all); m_actionCombo.setItemCaption(Action.copy_sibling_all, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_CREATE_SIBLINGS_0)); if (m_dialogMode == DialogMode.copy_and_move) { m_actionCombo.addItem(Action.move); m_actionCombo.setItemCaption(Action.move, CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MOVE_MOVE_RESOURCES_0)); } } m_actionCombo.setItemStyleGenerator(new ItemStyleGenerator() { private static final long serialVersionUID = 1L; public String getStyle(ComboBox source, Object itemId) { String style = null; if (m_defaultActions.contains(itemId)) { style = "bold"; } return style; } }); form.addComponent(m_actionCombo); } if (m_context.getResources().size() > 1) { m_overwriteExisting = new CheckBox(CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_COPY_MULTI_OVERWRITE_0)); m_overwriteExisting.setValue(Boolean.FALSE); form.addComponent(m_overwriteExisting); } return form; }
From source file:org.opencms.ui.dialogs.CmsProjectSelectDialog.java
License:Open Source License
/** * Initializes the form component.<p> * * @return the form component//w w w.ja va 2 s .c o m */ private FormLayout initForm() { FormLayout form = new FormLayout(); form.setWidth("100%"); IndexedContainer sites = CmsVaadinUtils.getAvailableSitesContainer(m_context.getCms(), CAPTION_PROPERTY); m_siteComboBox = prepareComboBox(sites, org.opencms.workplace.Messages.GUI_LABEL_SITE_0); m_siteComboBox.select(m_context.getCms().getRequestContext().getSiteRoot()); form.addComponent(m_siteComboBox); ValueChangeListener changeListener = new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { submit(); } }; m_siteComboBox.addValueChangeListener(changeListener); IndexedContainer projects = CmsVaadinUtils.getProjectsContainer(m_context.getCms(), CAPTION_PROPERTY); m_projectComboBox = prepareComboBox(projects, org.opencms.workplace.Messages.GUI_LABEL_PROJECT_0); CmsUUID currentProjectId = m_context.getCms().getRequestContext().getCurrentProject().getUuid(); if (projects.containsId(currentProjectId)) { m_projectComboBox.select(currentProjectId); } else { try { CmsUUID ouProject = OpenCms.getOrgUnitManager().readOrganizationalUnit(m_context.getCms(), m_context.getCms().getRequestContext().getOuFqn()).getProjectId(); if (projects.containsId(ouProject)) { m_projectComboBox.select(ouProject); } } catch (CmsException e) { LOG.error("Error while reading current OU.", e); } } form.addComponent(m_projectComboBox); m_projectComboBox.addValueChangeListener(changeListener); return form; }
From source file:org.opencms.ui.dialogs.CmsPublishScheduledDialog.java
License:Open Source License
/** * Initializes the form fields.<p> * * @return the form component/*w w w . jav a2s. c o m*/ */ private FormLayout initForm() { FormLayout form = new FormLayout(); form.setWidth("100%"); m_dateField = new CmsDateField(); m_dateField.setCaption(CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_LABEL_DATE_PUBLISH_SCHEDULED_0)); form.addComponent(m_dateField); m_includeSubResources = new CheckBox(CmsVaadinUtils .getMessageText(org.opencms.workplace.commons.Messages.GUI_PUBLISH_MULTI_SUBRESOURCES_0)); if (hasFolders()) { form.addComponent(m_includeSubResources); } return form; }