List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:eu.hurion.hello.vaadin.shiro.application.LoginScreen.java
License:Apache License
public LoginScreen(final HerokuShiroApplication app) { setSizeFull();//from w w w .ja v a 2 s .c o m final Panel loginPanel = new Panel("Login"); loginPanel.setWidth("300px"); final FormLayout content = new FormLayout(); content.setSizeFull(); user = new TextField("User"); content.addComponent(user); password = new PasswordField("Password"); content.addComponent(password); final Button loginButton = new Button("Log in"); content.setHeight("150px"); loginButton.addClickListener(new ShiroLoginListener(app)); content.addComponent(loginButton); loginPanel.setContent(content); addComponent(loginPanel); setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); final HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); addComponent(footer); }
From source file:eu.maxschuster.vaadin.signaturefield.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle(pageTitle);/*from www .j a v a 2 s . c o m*/ final VerticalLayout margin = new VerticalLayout(); setContent(margin); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("658px"); margin.addComponent(layout); margin.setComponentAlignment(layout, Alignment.TOP_CENTER); final Label header1 = new Label(pageTitle); header1.addStyleName("h1"); header1.setSizeUndefined(); layout.addComponent(header1); layout.setComponentAlignment(header1, Alignment.TOP_CENTER); final TabSheet tabSheet = new TabSheet(); tabSheet.setWidth("100%"); layout.addComponent(tabSheet); layout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER); final Panel signaturePanel = new Panel(); signaturePanel.addStyleName("signature-panel"); signaturePanel.setWidth("100%"); tabSheet.addTab(signaturePanel, "Demo"); final VerticalLayout signatureLayout = new VerticalLayout(); signatureLayout.setMargin(true); signatureLayout.setSpacing(true); signatureLayout.setSizeFull(); signaturePanel.setContent(signatureLayout); final SignatureField signatureField = new SignatureField(); signatureField.setWidth("100%"); signatureField.setHeight("318px"); signatureField.setPenColor(Color.ULTRAMARINE); signatureField.setBackgroundColor("white"); signatureField.setConverter(new StringToDataUrlConverter()); signatureField.setPropertyDataSource(dataUrlProperty); signatureField.setVelocityFilterWeight(0.7); signatureLayout.addComponent(signatureField); signatureLayout.setComponentAlignment(signatureField, Alignment.MIDDLE_CENTER); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); signatureLayout.addComponent(buttonLayout); final Button clearButton = new Button("Clear", new ClickListener() { @Override public void buttonClick(ClickEvent event) { signatureField.clear(); } }); buttonLayout.addComponent(clearButton); buttonLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_LEFT); final Label message = new Label("Sign above"); message.setSizeUndefined(); buttonLayout.addComponent(message); buttonLayout.setComponentAlignment(message, Alignment.MIDDLE_CENTER); final ButtonLink saveButtonLink = new ButtonLink("Save", null); saveButtonLink.setTargetName("_blank"); buttonLayout.addComponent(saveButtonLink); buttonLayout.setComponentAlignment(saveButtonLink, Alignment.MIDDLE_RIGHT); final Panel optionsPanel = new Panel(); optionsPanel.setSizeFull(); tabSheet.addTab(optionsPanel, "Options"); final FormLayout optionsLayout = new FormLayout(); optionsLayout.setMargin(true); optionsLayout.setSpacing(true); optionsPanel.setContent(optionsLayout); final ComboBox mimeTypeComboBox = new ComboBox(null, mimeTypeContainer); optionsLayout.addComponent(mimeTypeComboBox); mimeTypeComboBox.setItemCaptionPropertyId("mimeType"); mimeTypeComboBox.setNullSelectionAllowed(false); mimeTypeComboBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { MimeType mimeType = (MimeType) event.getProperty().getValue(); signatureField.setMimeType(mimeType); } }); mimeTypeComboBox.setValue(MimeType.PNG); mimeTypeComboBox.setCaption("Result MIME-Type"); final CheckBox immediateCheckBox = new CheckBox("immediate", false); optionsLayout.addComponent(immediateCheckBox); immediateCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean immediate = (Boolean) event.getProperty().getValue(); signatureField.setImmediate(immediate); } }); final CheckBox readOnlyCheckBox = new CheckBox("readOnly", false); optionsLayout.addComponent(readOnlyCheckBox); readOnlyCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean readOnly = (Boolean) event.getProperty().getValue(); signatureField.setReadOnly(readOnly); mimeTypeComboBox.setReadOnly(readOnly); clearButton.setEnabled(!readOnly); } }); final CheckBox requiredCheckBox = new CheckBox("required (causes bug that clears field)", false); optionsLayout.addComponent(requiredCheckBox); requiredCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean required = (Boolean) event.getProperty().getValue(); signatureField.setRequired(required); } }); final CheckBox clearButtonEnabledButton = new CheckBox("clearButtonEnabled", false); optionsLayout.addComponent(clearButtonEnabledButton); clearButtonEnabledButton.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean clearButtonEnabled = (Boolean) event.getProperty().getValue(); signatureField.setClearButtonEnabled(clearButtonEnabled); } }); final Panel resultPanel = new Panel("Results:"); resultPanel.setWidth("100%"); layout.addComponent(resultPanel); final VerticalLayout resultLayout = new VerticalLayout(); resultLayout.setMargin(true); resultPanel.setContent(resultLayout); final Image stringPreviewImage = new Image("String preview image:"); stringPreviewImage.setWidth("500px"); resultLayout.addComponent(stringPreviewImage); final Image dataUrlPreviewImage = new Image("DataURL preview image:"); dataUrlPreviewImage.setWidth("500px"); resultLayout.addComponent(dataUrlPreviewImage); final TextArea textArea = new TextArea("DataURL:"); textArea.setWidth("100%"); textArea.setHeight("300px"); resultLayout.addComponent(textArea); final Label emptyLabel = new Label(); emptyLabel.setCaption("Is Empty:"); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); resultLayout.addComponent(emptyLabel); signatureField.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String signature = (String) event.getProperty().getValue(); stringPreviewImage.setSource(signature != null ? new ExternalResource(signature) : null); textArea.setValue(signature); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); } }); dataUrlProperty.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { try { final DataUrl signature = (DataUrl) event.getProperty().getValue(); dataUrlPreviewImage.setSource( signature != null ? new ExternalResource(serializer.serialize(signature)) : null); StreamResource streamResource = null; if (signature != null) { StreamSource streamSource = new StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(signature.getData()); } }; MimeType mimeType = MimeType.valueOfMimeType(signature.getMimeType()); String extension = null; switch (mimeType) { case JPEG: extension = "jpg"; break; case PNG: extension = "png"; break; } streamResource = new StreamResource(streamSource, "signature." + extension); streamResource.setMIMEType(signature.getMimeType()); streamResource.setCacheTime(0); } saveButtonLink.setResource(streamResource); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } } }); }
From source file:facs.components.Settings.java
License:Open Source License
private void addNewDevice() { final Window subWindow = new Window("Add Device"); FormLayout form = new FormLayout(); form.setMargin(true);/* w w w .j a v a2s . c o m*/ final TextField name = new TextField(); name.setImmediate(true); name.addValidator(new StringLengthValidator("The name must be 1-85 letters long (Was {0}).", 1, 85, true)); name.setCaption("Name of new device"); form.addComponent(name); final TextArea description = new TextArea(); description.setImmediate(true); description.addValidator( new StringLengthValidator("The name must be 1-255 letters long (Was {0}).", 1, 255, true)); description.setCaption("Description"); form.addComponent(description); final OptionGroup restricted = new OptionGroup("Is Device restricted by operators?"); restricted.addItem("yes"); restricted.setMultiSelect(true); form.addComponent(restricted); HorizontalLayout buttons = new HorizontalLayout(); Button save = new Button("save"); buttons.addComponent(save); Button discard = new Button("discard"); discard.setDescription("discarding will abort the process of adding a new device into the databse."); buttons.addComponent(discard); buttons.setSpacing(true); form.addComponent(buttons); subWindow.setContent(form); form.setMargin(true); form.setSpacing(true); buttons.setMargin(true); buttons.setSpacing(true); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setWidth("50%"); // Open it in the UI UI.getCurrent().addWindow(subWindow); discard.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = -5808910314649620731L; @Override public void buttonClick(ClickEvent event) { subWindow.close(); } }); save.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 3748395242651585005L; @Override public void buttonClick(ClickEvent event) { if (name.isValid() && description.isValid()) { Set<String> restr = (Set<String>) restricted.getValue(); int deviceId = DBManager.getDatabaseInstance().addDevice(name.getValue(), description.getValue(), (restr.size() == 1)); DeviceBean bean = new DeviceBean(deviceId, name.getValue(), description.getValue(), (restr.size() == 1)); devicesGrid.addRow(bean); } else { Notification.show("Failed to add device to database."); } } }); // DeviceBean db = new DeviceBean(0, "Device 1","some description1", false); // TODO // add to database /* * boolean added = false;//DBManager.getDatabaseInstance().addDevice(db); //TODO test //add to * grid if(added){ devicesGrid.addRow(db); }else{ //TODO log failed operation * Notification.show("Failed to add device to database.", Type.ERROR_MESSAGE); } */ }
From source file:fi.jasoft.remoteconnection.ServerExampleUI.java
License:Apache License
private void buildUI() { FormLayout vl = new FormLayout(); setContent(vl);//from w ww .j av a 2 s.co m // Our id myId = new Label("Connecting..."); myId.setCaption("My id:"); vl.addComponent(myId); // Remote id final TextField remoteId = new TextField(); remoteId.setWidth("100%"); NativeButton connectToRemote = new NativeButton("Connect", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final RemoteChannel channel = peer.openChannel(remoteId.getValue()); channel.addConnectedListener(new ConnectedListener() { @Override public void connected(String channelId) { remoteId.setReadOnly(true); event.getButton().setVisible(false); Notification.show("Connected to " + channelId, Type.TRAY_NOTIFICATION); } }); } }); HorizontalLayout hl = new HorizontalLayout(remoteId, connectToRemote); hl.setExpandRatio(remoteId, 1); hl.setWidth("100%"); hl.setCaption("Remote id: "); vl.addComponent(hl); // Message display where messages are displayed messages = new TextArea(); messages.setWidth("100%"); vl.addComponent(messages); // Message field final TextField message = new TextField(); message.setWidth("100%"); NativeButton send = new NativeButton("Send", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // Show message in message window messages.setValue( messages.getValue() + peer.getConfiguration().getId() + " >> " + message.getValue() + "\n"); // Broadcast the message to all connected peers peer.broadcast(message.getValue()); message.setValue(""); } }); hl = new HorizontalLayout(message, send); hl.setExpandRatio(message, 1); hl.setWidth("100%"); hl.setCaption("Send message: "); vl.addComponent(hl); }
From source file:fi.racetrace.adminpanel.ui.CustomerForm.java
License:Open Source License
public CustomerForm(Item customer) { FormLayout layout = new FormLayout(); layout.addComponent(name);// w w w .j a va2 s .com layout.addComponent(descriptionField); final FieldGroup binder = new FieldGroup(customer); binder.bindMemberFields(this); HorizontalLayout buttonPanel = new HorizontalLayout(); layout.addComponent(buttonPanel); buttonPanel.addComponent(new Button("Discard", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { binder.discard(); Notification.show("Discarded!"); } })); buttonPanel.addComponent(new Button("Save", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { binder.commit(); Notification.show("Changes saved!"); } catch (CommitException e) { Notification.show("An error occurred!"); } } })); setContent(layout); }
From source file:fi.racetrace.adminpanel.ui.EventForm.java
License:Open Source License
public EventForm(fi.racetrace.adminpanel.data.Event event) { FormLayout layout = new FormLayout(); layout.addComponent(name);// w w w .ja v a 2s .co m layout.addComponent(descriptionField); layout.addComponent(start); layout.addComponent(end); final FieldGroup binder = new FieldGroup(new BeanItem<fi.racetrace.adminpanel.data.Event>(event)); binder.bindMemberFields(this); HorizontalLayout buttonPanel = new HorizontalLayout(); layout.addComponent(buttonPanel); buttonPanel.addComponent(new Button("Discard", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { binder.discard(); Notification.show("Discarded!"); } })); buttonPanel.addComponent(new Button("Save", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { binder.commit(); Notification.show("Changes saved!"); } catch (CommitException e) { Notification.show("An error occurred!"); } } })); setContent(layout); }
From source file:fi.racetrace.adminpanel.ui.SessionForm.java
License:Open Source License
public SessionForm(Session session) { latLogPicker = new VolLatLngPicker(session.getCenterLon(), session.getCenterLat()); FormLayout layout = new FormLayout(); layout.addComponent(name);/* w ww . j a v a 2s. c om*/ layout.addComponent(descriptionField); layout.addComponent(start); layout.addComponent(end); layout.addComponent(zoom); layout.addComponent(centerLat); layout.addComponent(centerLon); layout.addComponent(latLogPicker); latLogPicker.setLatField(centerLat); latLogPicker.setLonField(centerLon); final FieldGroup binder = new FieldGroup(new BeanItem<Session>(session)); binder.bindMemberFields(this); HorizontalLayout buttonPanel = new HorizontalLayout(); layout.addComponent(buttonPanel); buttonPanel.addComponent(new Button("Discard", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { binder.discard(); Notification.show("Discarded!"); } })); buttonPanel.addComponent(new Button("Save", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { binder.commit(); Notification.show("Changes saved!"); } catch (CommitException e) { Notification.show("An error occurred!"); } } })); setContent(layout); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void modifyAccount(final Main main) { final Database database = main.getDatabase(); FormLayout content = new FormLayout(); content.setSizeFull();//w ww .ja v a 2 s. c o m final Label l = new Label(main.account.getId(database)); l.setCaption("Kyttjn nimi:"); l.setWidth("100%"); content.addComponent(l); final TextField tf = new TextField(); tf.setWidth("100%"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); tf.setCaption("Kyttjn nimi:"); tf.setId("loginUsernameField"); tf.setValue(main.account.getText(database)); content.addComponent(tf); final TextField tf2 = new TextField(); tf2.setWidth("100%"); tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); tf2.setCaption("Shkpostiosoite:"); tf2.setId("loginUsernameField"); tf2.setValue(main.account.getEmail()); content.addComponent(tf2); final PasswordField pf = new PasswordField(); pf.setCaption("Vanha salasana:"); pf.addStyleName(ValoTheme.TEXTFIELD_SMALL); pf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); pf.setWidth("100%"); pf.setId("loginPasswordField"); content.addComponent(pf); final PasswordField pf2 = new PasswordField(); pf2.setCaption("Uusi salasana:"); pf2.addStyleName(ValoTheme.TEXTFIELD_SMALL); pf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); pf2.setWidth("100%"); pf2.setId("loginPasswordField"); content.addComponent(pf2); final PasswordField pf3 = new PasswordField(); pf3.setCaption("Uusi salasana uudestaan:"); pf3.addStyleName(ValoTheme.TEXTFIELD_SMALL); pf3.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); pf3.setWidth("100%"); pf3.setId("loginPasswordField"); content.addComponent(pf3); final Label err = new Label("Vr kyttjtunnus tai salasana"); err.addStyleName(ValoTheme.LABEL_FAILURE); err.addStyleName(ValoTheme.LABEL_TINY); err.setVisible(false); content.addComponent(err); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); Button apply = new Button("Tee muutokset"); buttons.addComponent(apply); final Window dialog = Dialogs.makeDialog(main, "450px", "480px", "Kyttjtilin asetukset", "Poistu", content, buttons); apply.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1992235622970234624L; public void buttonClick(ClickEvent event) { String valueHash = Utils.hash(pf.getValue()); if (!valueHash.equals(main.account.getHash())) { err.setValue("Vr salasana"); err.setVisible(true); return; } if (pf2.isEmpty()) { err.setValue("Tyhj salasana ei kelpaa"); err.setVisible(true); return; } if (!pf2.getValue().equals(pf3.getValue())) { err.setValue("Uudet salasanat eivt tsm"); err.setVisible(true); return; } main.account.text = tf.getValue(); main.account.email = tf2.getValue(); main.account.hash = Utils.hash(pf2.getValue()); Updates.update(main, true); main.removeWindow(dialog); } }); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void addMap(final Main main, final Strategiakartta parent) { final Database database = main.getDatabase(); FormLayout content = new FormLayout(); content.setSizeFull();// ww w. jav a 2s .c o m // final TextField tf = new TextField(); // tf.setCaption("Kartan tunniste:"); // tf.setValue("tunniste"); // tf.setWidth("100%"); // content.addComponent(tf); final TextField tf2 = new TextField(); tf2.setCaption("Kartan nimi:"); tf2.setValue("Uusi kartta"); tf2.setWidth("100%"); content.addComponent(tf2); final ComboBox combo = new ComboBox(); combo.setCaption("Kartan tyyppi:"); combo.setNullSelectionAllowed(false); combo.setWidth("100%"); content.addComponent(combo); Collection<Base> subs = Strategiakartta.availableLevels(database); for (Base b : subs) { combo.addItem(b.uuid); combo.setItemCaption(b.uuid, b.getText(database)); combo.select(b.uuid); } HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(true); Button ok = new Button("Lis"); buttons.addComponent(ok); final Window dialog = Dialogs.makeDialog(main, "450px", "340px", "Lis alatason kartta", "Peruuta", content, buttons); ok.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1422158448876521843L; public void buttonClick(ClickEvent event) { String name = tf2.getValue(); String typeUUID = (String) combo.getValue(); Base type = database.find(typeUUID); database.newMap(main, parent, "", name, type); Updates.updateJS(main, true); main.removeWindow(dialog); } }); }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void addImplementationMap(final Main main, final Tavoite goal) { final Database database = main.getDatabase(); try {/*from ww w .j a va 2s .c o m*/ Base subType = goal.getPossibleSubmapType(database); if (subType != null) { goal.ensureImplementationMap(main); Updates.updateJS(main, true); return; } } catch (Exception e) { e.printStackTrace(); return; } FormLayout content = new FormLayout(); content.setSizeFull(); final ComboBox combo = new ComboBox(); combo.setCaption("Kartan tyyppi:"); combo.setNullSelectionAllowed(false); combo.setWidth("100%"); content.addComponent(combo); Collection<Base> subs = Strategiakartta.availableLevels(database); for (Base b : subs) { combo.addItem(b.uuid); combo.setItemCaption(b.uuid, b.getText(database)); combo.select(b.uuid); } HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(true); Button ok = new Button("Lis"); buttons.addComponent(ok); final Window dialog = Dialogs.makeDialog(main, "450px", "340px", "Lis alatason kartta", "Peruuta", content, buttons); ok.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1422158448876521843L; public void buttonClick(ClickEvent event) { String typeUUID = (String) combo.getValue(); Base type = database.find(typeUUID); Strategiakartta parent = database.getMap(goal); Strategiakartta newMap = database.newMap(main, parent, "", "", type); newMap.addRelation(Relation.find(database, Relation.IMPLEMENTS), goal); for (Painopiste pp : goal.painopisteet) { Tavoite.createCopy(main, newMap, pp); } Updates.updateJS(main, true); main.removeWindow(dialog); } }); }