List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:com.tripoin.util.ui.calendar.BeanItemContainerTestUI.java
License:Apache License
/** * Opens up a modal dialog window where an event can be modified * /* ww w . j a va 2 s . c o m*/ * @param event * The event to modify */ private void editEvent(final BasicEvent event) { Window modal = new Window("Add event"); modal.setModal(true); modal.setResizable(false); modal.setDraggable(false); modal.setWidth("300px"); final FieldGroup fieldGroup = new FieldGroup(); FormLayout formLayout = new FormLayout(); TextField captionField = new TextField("Caption"); captionField.setImmediate(true); TextField descriptionField = new TextField("Description"); descriptionField.setImmediate(true); DateField startField = new DateField("Start"); startField.setResolution(Resolution.MINUTE); startField.setImmediate(true); DateField endField = new DateField("End"); endField.setImmediate(true); endField.setResolution(Resolution.MINUTE); formLayout.addComponent(captionField); formLayout.addComponent(descriptionField); formLayout.addComponent(startField); formLayout.addComponent(endField); fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY); fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event, Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY, ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { /** * */ private static final long serialVersionUID = -3427881784024691882L; @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { fieldGroup.commit(); } catch (CommitException e1) { e1.printStackTrace(); } if (events.containsId(event)) { /* * BeanItemContainer does not notify container listeners * when the bean changes so we need to trigger a * ItemSetChange event */ BasicEvent dummy = new BasicEvent(); events.addBean(dummy); events.removeItem(dummy); } else { events.addBean(event); } } }); getUI().addWindow(modal); }
From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java
License:Apache License
private void addRebuildUIBtn() { root.addComponent(new Button("ReBuildUI", new Button.ClickListener() { @Override//from w ww . j a va 2 s. c o m public void buttonClick(Button.ClickEvent event) { root.removeComponent(form); form = new FormLayout(); root.addComponent(form); createForm(); } })); }
From source file:com.wcs.wcslib.vaadin.widget.recaptcha.demo.ConfigComponent.java
License:Apache License
private Layout createThemeconfLayout() { Layout themeLayout = new FormLayout(); themeSelect = new NativeSelect("theme", Arrays.asList("red", "white", "blackglass", "clean", "custom")); themeSelect.setImmediate(true);/* w w w. j a va 2s . com*/ themeSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { customHtmlArea.setEnabled(isCustomTheme()); customThemeWidgetField.setEnabled(isCustomTheme()); } }); themeLayout.addComponent(themeSelect); customHtmlArea = new TextArea("custom HTML", CUSTOM_HTML_SAMPLE); customHtmlArea.setEnabled(false); customHtmlArea.setRows(15); customHtmlArea.setColumns(40); themeLayout.addComponent(customHtmlArea); customThemeWidgetField = new TextField("custom_theme_widget", CUSTOM_THEME_WIDGET); customThemeWidgetField.setEnabled(false); themeLayout.addComponent(customThemeWidgetField); return themeLayout; }
From source file:cz.iivos.todo.components.InputFormLayout.java
/** * Vytvo formul s danmi pol?kami, itmi na mru (it na * mieru typov: Long, String(TextArea/TextField), Boolean(CheckBox), * Date(DateField), enum(ComboBox, SelectList, TwinColSelect...)). *//*from ww w . j av a2s. c o m*/ public void initFieldsLayout() { fieldsFL = new FormLayout(); fieldsFL.setMargin(true); fieldsFL.setSpacing(true); String propertyTypeName; // nazov typu danej property danej ent. Map<String, Class<?>> mapPar = new HashMap<>(); try { mapPar = Tools.getTypParametrov(clsT); } catch (NoSuchFieldException | SecurityException ex) { logger.warn(ex.getLocalizedMessage(), ex); return; } for (String pn : mapPar.keySet()) { propertyTypeName = mapPar.get(pn).getCanonicalName(); switch (propertyTypeName) { case "java.lang.Long": if (pn.contains("id_")) { switch (pn) { case "id_tcy": //POZN: parametry POJO by se meli jmenovat stejne ako // stloupce tabulky a identifikator by se mel jmenovat jen 'id'.. User user = securityService.getCurrentUser(); Map<String, Long> map = categoryService.findAllCategoriesIdByUser(user); InputComboBox<Long> cb; cb = new InputComboBox<>(fg, pn, map, Long.class); fieldMap.put(pn, cb); break; default: break; } } else { Component fi = bindTextField(pn); fieldMap.put(pn, fi);//fieldsFL.addComponent(fi); } break; case "java.lang.String": switch (pn) { case "description": fieldMap.put(pn, bindTextArea(pn)); break; case "title": TextField field = bindTextField(pn); field.setRequired(true); fieldMap.put(pn, field); break; default: fieldMap.put(pn, bindTextField(pn)); break; } break; case "java.lang.Boolean": switch (pn) { case "deleted": case "completed": break; default: fieldMap.put(pn, bindCheckBox(pn)); } break; case "java.util.Date": switch (pn) { case "creation_date": case "completion_date": //do nothing. tyto datumy se vypln automaticky. break; default: fieldMap.put(pn, bindUtilDateField(pn)); break; } break; case "cz.iivos.todo.enums.TaskRepetitions": Map map = Tools.makeEnumMap(TaskRepetitions.getPeriodsNames(), TaskRepetitions.getOrdinals()); InputComboBox<Integer> cb = new InputComboBox<>(fg, pn, map, Integer.class); fieldMap.put(pn, cb); break; case "cz.iivos.todo.enums.TaskWarnings": Map map1 = Tools.makeEnumMap(TaskWarnings.getWarningNames(), TaskWarnings.getOrdinals()); InputComboBox<Integer> cb1 = new InputComboBox<>(fg, pn, map1, Integer.class); fieldMap.put(pn, cb1); break; default: // do nothing break; } } this.completeForm(); fieldsFL.setEnabled(true); this.addComponent(fieldsFL); }
From source file:de.akquinet.engineering.vaadin.html5.Html5TestUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { FormLayout layout = new FormLayout(); colorField.setCaption("Color"); layout.addComponent(colorField);//from www . j av a 2 s. c o m dateField.setCaption("Date"); layout.addComponent(dateField); dateTimeField.setCaption("DateTime"); layout.addComponent(dateTimeField); dateTimeLocalField.setCaption("DateTime-local"); layout.addComponent(dateTimeLocalField); emailField.setCaption("Email"); layout.addComponent(emailField); monthField.setCaption("Month"); layout.addComponent(monthField); numberField.setCaption("Number"); layout.addComponent(numberField); numberFieldMin.setMin(2); numberFieldMin.setCaption("Number >=2"); layout.addComponent(numberFieldMin); numberFieldMinMax.setMin(2); numberFieldMinMax.setMax(10); numberFieldMinMax.setCaption("Number >=2 && <=10"); layout.addComponent(numberFieldMinMax); numberFieldMinMaxStep.setMin(2); numberFieldMinMaxStep.setMax(10); numberFieldMinMaxStep.setStep(2); numberFieldMinMaxStep.setCaption("Number >=2 && <=10 && even"); layout.addComponent(numberFieldMinMaxStep); rangeField.setMin(2); rangeField.setMax(10); rangeField.setCaption("Range between 2 and 10"); layout.addComponent(rangeField); searchField.setCaption("Search"); layout.addComponent(searchField); telField.setCaption("Tel"); layout.addComponent(telField); timeField.setCaption("Time"); layout.addComponent(timeField); urlField.setCaption("Url"); layout.addComponent(urlField); weekField.setCaption("Week"); layout.addComponent(weekField); summary.setCaption("Summary"); summary.setRows(20); summary.setColumns(80); layout.addComponent(summary); buildSummary.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { StringBuilder str = new StringBuilder(); str.append(colorField.getCaption() + ": "); str.append(colorField.getValue()); str.append("\n"); str.append(dateField.getCaption() + ": "); str.append(dateField.getValue()); str.append("\n"); str.append(dateTimeField.getCaption() + ": "); str.append(dateTimeField.getValue()); str.append("\n"); str.append(dateTimeLocalField.getCaption() + ": "); str.append(dateTimeLocalField.getValue()); str.append("\n"); str.append(emailField.getCaption() + ": "); str.append(emailField.getValue()); str.append("\n"); str.append(monthField.getCaption() + ": "); str.append(monthField.getValue()); str.append("\n"); str.append(numberField.getCaption() + ": "); str.append(numberField.getValue()); str.append("\n"); str.append(numberFieldMin.getCaption() + ": "); str.append(numberFieldMin.getValue()); str.append("\n"); str.append(numberFieldMinMax.getCaption() + ": "); str.append(numberFieldMinMax.getValue()); str.append("\n"); str.append(numberFieldMinMaxStep.getCaption() + ": "); str.append(numberFieldMinMaxStep.getValue()); str.append("\n"); str.append(rangeField.getCaption() + ": "); str.append(rangeField.getValue()); str.append("\n"); str.append(searchField.getCaption() + ": "); str.append(searchField.getValue()); str.append("\n"); str.append(telField.getCaption() + ": "); str.append(telField.getValue()); str.append("\n"); str.append(timeField.getCaption() + ": "); str.append(timeField.getValue()); str.append("\n"); str.append(urlField.getCaption() + ": "); str.append(urlField.getValue()); str.append("\n"); str.append(weekField.getCaption() + ": "); str.append(weekField.getValue()); str.append("\n"); summary.setValue(str.toString()); } }); layout.addComponent(buildSummary); setContent(layout); }
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);//from ww w.j a v a 2 s . c om formLayout.setWidth("800px"); formLayout.setHeight("100%"); return formLayout; }
From source file:de.fatalix.app.view.login.LoginView.java
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/*from ww w. j av a2 s . com*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Try anything", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
From source file:de.fatalix.bookery.view.admin.ServerSettingsLayout.java
License:Open Source License
@PostConstruct private void postInit() { addStyleName("bookery-content"); formLayout = new FormLayout(); formLayout.addStyleName("light"); formLayout.addComponents(generateFields()); formLayout.addComponents(generateStatusFields()); Button checkSolr = new Button("check", new Button.ClickListener() { @Override/*w ww .ja va 2 s. c o m*/ public void buttonClick(Button.ClickEvent event) { checkSolr(); } }); checkSolr.addStyleName(ValoTheme.BUTTON_SMALL); checkSolr.addStyleName(ValoTheme.BUTTON_FRIENDLY); formLayout.addComponent(checkSolr); Label titleLabel = new Label("General Settings"); titleLabel.addStyleName(ValoTheme.LABEL_H2); addComponents(titleLabel, formLayout); }
From source file:de.fatalix.bookery.view.login.LoginView.java
License:Open Source License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/*from w w w. ja v a2s . c o m*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription(""); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); login = new Button("login"); buttons.addComponent(login); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Ask me", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); Panel loginPanel = new Panel(loginForm); loginPanel.setWidthUndefined(); loginPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); loginPanel.addAction(new ShortcutListener("commit", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } } }); return loginPanel; }
From source file:de.fzi.fhemapi.view.vaadin.ui.ServerDetailsForm.java
License:Apache License
public ServerDetailsForm() { FormLayout layout = new FormLayout(); setCompositionRoot(layout);//from w w w. j a v a 2 s.c o m Label title = new Label("<h1> Server Details</h1>"); title.setContentMode(Label.CONTENT_XHTML); layout.addComponent(title); final TextField serverIP = new TextField("Server IP"); serverIP.setWidth(COMMON_FIELD_WIDTH); layout.addComponent(serverIP); final TextField port = new TextField("Port"); port.setWidth(COMMON_FIELD_WIDTH); layout.addComponent(port); Button applyButton = new Button("Apply"); layout.addComponent(applyButton); applyButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { // Window mainWindow = new Window(); FHEMServer server = new FHEMServer((String) serverIP.getValue(), Integer.parseInt((String) port.getValue())); getWindow().setContent(new HWindow(server)); // VaadinServletResponse response = // (VaadinServletResponse) VaadinService.getCurrentResponse(); // Cookie ipCookie = new Cookie("ip", (String)serverIP.getValue()); // Cookie portCookie = new Cookie("port", (String) port.getValue()); // ipCookie.setMaxAge(30 * 24 * 60 * 60); // ipCookie.setPath("/HWC"); // portCookie.setMaxAge(30 * 24 * 60 * 60); // portCookie.setPath("/HWC"); // response.addCookie(ipCookie); // response.addCookie(portCookie); } catch (ConnectException e) { getWindow().setContent(new Window("Could not connect to FHEM!\n Cause: " + e.getMessage())); getWindow().showNotification("Error!", e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } } }); // // VaadinServletRequest request = // (VaadinServletRequest) VaadinService.getCurrentRequest(); // if(request != null){ // Cookie[] cookies = request.getCookies(); // for (Cookie cookie : cookies) { // if (cookie.getName().equals("ip")) { // serverIP.setValue(cookie.getValue()); // }else if(cookie.getName().equals("port")){ // port.setValue(cookie.getValue()); // } // } // } }