List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:com.ocs.dynamo.ui.composite.form.ModelBasedSearchForm.java
License:Apache License
/** * Builds the layout that contains the various search filters * // w ww .ja v a 2 s . c o m * @param entityModel * the entity model * @return */ protected Layout constructFilterLayout() { if (nrOfColumns == 1) { form = new FormLayout(); // don't use all the space unless it's a popup window if (!getFormOptions().isPopup()) { form.setStyleName(DynamoConstants.CSS_CLASS_HALFSCREEN); } } else { // create a number of form layouts next to each others form = new GridLayout(nrOfColumns, 1); form.setSizeFull(); for (int i = 0; i < nrOfColumns; i++) { FormLayout column = new FormLayout(); column.setMargin(true); subForms.add(column); form.addComponent(column); } } // add any extra fields List<Component> extra = constructExtraSearchFields(); for (Component c : extra) { if (nrOfColumns == 1) { form.addComponent(c); } else { int index = fieldsAdded % nrOfColumns; subForms.get(index).addComponent(c); } fieldsAdded++; } // iterate over the searchable attributes and add a field for each iterate(getEntityModel().getAttributeModels()); return form; }
From source file:com.ocs.dynamo.ui.composite.form.UploadForm.java
License:Apache License
@Override protected void doBuildLayout(Layout main) { FormLayout form = new FormLayout(); form.setMargin(true);/*w ww. j ava2 s . c o m*/ if (ScreenMode.VERTICAL.equals(screenMode)) { form.setStyleName(DynamoConstants.CSS_CLASS_HALFSCREEN); } main.addComponent(form); // add custom components doBuildForm(form); // add file upload field UploadReceiver receiver = new UploadReceiver(); Upload upload = new Upload(message("ocs.uploadform.title"), receiver); upload.addSucceededListener(receiver); form.addComponent(upload); if (showCancelButton) { Button cancelButton = new Button(message("ocs.cancel")); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { cancel(); } }); main.addComponent(cancelButton); } }
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create the component to take a snapshot. * // www .ja v a 2 s .c om * @return the component */ @SuppressWarnings("serial") private final AbstractComponent createTakeSnap() { final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); final FormLayout takeSnapLayout = new FormLayout(); takeSnapLayout.setMargin(true); takeSnapLayout.setImmediate(true); takeSnapLayout.setWidth(null); layout.addComponent(takeSnapLayout); layout.setComponentAlignment(takeSnapLayout, Alignment.MIDDLE_CENTER); // Enter name final TextField vvrName = new TextField("Name", ""); takeSnapLayout.addComponent(vvrName); // take button final Button take = new Button("Take snapshot"); layout.addComponent(take); layout.setComponentAlignment(take, Alignment.MIDDLE_CENTER); take.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { model.takeDeviceSnapshot(vvrName.getValue()); Notification.show("New snapshot created", Notification.Type.TRAY_NOTIFICATION); } catch (final Exception e) { final ErrorWindow err = new ErrorWindow("Snapshot not taken: " + e.getMessage()); err.add(model); } } }); return layout; }
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create attributes component.//from w ww . j a v a 2 s.co m * * @return the component */ private final AbstractComponent createAttributes() { final VerticalLayout layout = new VerticalLayout(); final FormLayout deviceAttributesLayout = new FormLayout(); deviceAttributesLayout.setMargin(true); deviceAttributesLayout.setWidth(null); deviceAttributesLayout.setImmediate(true); layout.addComponent(deviceAttributesLayout); layout.setComponentAlignment(deviceAttributesLayout, Alignment.MIDDLE_CENTER); // Enter NAME WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceName(value); } @Override public String getStringValue() { return model.getDeviceName(); } }, "Name", deviceAttributesLayout, model); // Enter DESCRIPTION WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceDescription(value); } @Override public String getStringValue() { return model.getDeviceDescription(); } }, "Description", deviceAttributesLayout, model); // Enter UUID (not editable) final TextField deviceUUID = new TextField("UUID", model.getItemUuid().toString()); deviceUUID.setReadOnly(true); deviceUUID.setWidth("300px"); deviceAttributesLayout.addComponent(deviceUUID); // Enter active final TextField deviceActive = new TextField("Active"); if (model.isDeviceActive()) { deviceActive.setValue("yes"); } else { deviceActive.setValue("no"); } deviceActive.setReadOnly(true); deviceActive.setSizeFull(); deviceAttributesLayout.addComponent(deviceActive); // Enter read only final TextField deviceReadOnly = new TextField("Read Only"); if (model.isDeviceReadOnly()) { deviceReadOnly.setValue("yes"); } else { deviceReadOnly.setValue("no"); } deviceReadOnly.setReadOnly(true); deviceReadOnly.setSizeFull(); deviceAttributesLayout.addComponent(deviceReadOnly); // Enter size WebUiUtils.createFieldLong(new LongAttributeOperation() { @Override public void setLongValue(final long value) { model.setDeviceSize(value); } @Override public long getLongValue() { return model.getDeviceSize(); } }, "Size", deviceAttributesLayout, model); // Enter IQN WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceIqn(value); } @Override public String getStringValue() { return model.getDeviceIqn(); } }, "IQN", deviceAttributesLayout, model); // Enter Alias WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setDeviceIscsiAlias(value); } @Override public String getStringValue() { return model.getDeviceIscsiAlias(); } }, "iSCSI Alias", deviceAttributesLayout, model); // Enter iscsi block size WebUiUtils.createFieldInteger(new IntegerAttributeOperation() { @Override public void setIntegerValue(final int value) { model.setDeviceIscsiBlockSize(value); } @Override public int getIntegerValue() { return model.getDeviceIscsiBlockSize(); } }, "iSCSI Block Size", deviceAttributesLayout, model, true); return layout; }
From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java
License:Apache License
/** * Create the component to create a device. * //from w ww.ja v a2s.co m * @return the component */ @SuppressWarnings("serial") private final AbstractComponent createDevice() { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); final FormLayout createDeviceLayout = new FormLayout(); createDeviceLayout.setMargin(true); createDeviceLayout.setWidth(null); createDeviceLayout.setImmediate(true); layout.addComponent(createDeviceLayout); layout.setComponentAlignment(createDeviceLayout, Alignment.MIDDLE_CENTER); // Enter name final TextField deviceName = new TextField("Name", ""); createDeviceLayout.addComponent(deviceName); // Enter size final TextField deviceSize = new TextField("Size", ""); createDeviceLayout.addComponent(deviceSize); // Create button final Button create = new Button("Create device"); layout.addComponent(create); layout.setComponentAlignment(create, Alignment.MIDDLE_CENTER); create.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { model.createDevice(deviceName.getValue(), Long.valueOf(deviceSize.getValue())); Notification.show("New device created", Notification.Type.TRAY_NOTIFICATION); } catch (final NumberFormatException e) { final ErrorWindow err = new ErrorWindow("Size must be a valid number"); err.add(model); } catch (final Exception e) { final ErrorWindow err = new ErrorWindow("Device not created: " + e.getMessage()); err.add(model); } } }); return layout; }
From source file:com.oodrive.nuage.webui.component.SnapshotItemComponent.java
License:Apache License
/** * Create the component for the snapshot attributes * /* w w w.ja v a 2s. c o m*/ * @return the component */ private final AbstractComponent createAttributes() { final VerticalLayout layout = new VerticalLayout(); final FormLayout snapshotAttributesLayout = new FormLayout(); snapshotAttributesLayout.setMargin(true); snapshotAttributesLayout.setWidth(null); snapshotAttributesLayout.setImmediate(true); layout.addComponent(snapshotAttributesLayout); layout.setComponentAlignment(snapshotAttributesLayout, Alignment.MIDDLE_CENTER); // Enter NAME WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setSnapshotName(value); } @Override public String getStringValue() { return model.getSnapshotName(); } }, "Name", snapshotAttributesLayout, model); // Enter DESCRIPTION WebUiUtils.createFieldString(new StringAttributeOperation() { @Override public void setStringValue(final String value) { model.setSnapshotDescription(value); } @Override public String getStringValue() { return model.getSnapshotDescription(); } }, "Description", snapshotAttributesLayout, model); // Enter UUID (not editable) final TextField snapUUID = new TextField("UUID", model.getItemUuid().toString()); snapUUID.setReadOnly(true); snapUUID.setWidth("300px"); snapshotAttributesLayout.addComponent(snapUUID); return layout; }
From source file:com.oodrive.nuage.webui.component.window.VvrAttributesWindow.java
License:Apache License
@SuppressWarnings("serial") @Override//from w w w. ja va 2 s . c o m public final Window init(final AbstractItemModel model) { // Cast model in vvrModel final VvrModel vvrModel = (VvrModel) model; // Add new window final Window vvrAttributesWindow = new Window("VVR Attributes"); vvrAttributesWindow.center(); vvrAttributesWindow.setWidth("400px"); vvrAttributesWindow.setResizable(false); final VerticalLayout layout = new VerticalLayout(); vvrAttributesWindow.setContent(layout); layout.setMargin(true); final FormLayout vvrAttributesLayout = new FormLayout(); layout.addComponent(vvrAttributesLayout); vvrAttributesLayout.setMargin(true); // Enter NAME String value = vvrModel.getVvrName(); if (value == null) { value = ""; } final TextField name = new TextField("Name", value); name.setSizeFull(); vvrAttributesLayout.addComponent(name); // Enter description value = vvrModel.getVvrDescription(); if (value == null) { value = ""; } final TextField desc = new TextField("Description", value); desc.setSizeFull(); vvrAttributesLayout.addComponent(desc); // Enter name final TextField vvrUUID = new TextField("UUID"); vvrUUID.setValue(vvrUuid.toString()); vvrUUID.setReadOnly(true); vvrUUID.setSizeFull(); vvrAttributesLayout.addComponent(vvrUUID); // OK button final HorizontalLayout hzlayout = new HorizontalLayout(); layout.addComponent(hzlayout); hzlayout.setSizeFull(); final Button okButton = new Button("OK"); hzlayout.addComponent(okButton); hzlayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); okButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { WaitingComponent.executeBackground(vvrModel, new Background() { @Override public void processing() { vvrModel.setVvrName(name.getValue()); vvrModel.setVvrDescription(desc.getValue()); } @Override public void postProcessing() { } }); vvrAttributesWindow.close(); } }); // Cancel button final Button cancelButton = new Button("Cancel"); hzlayout.addComponent(cancelButton); hzlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // Just close the window vvrAttributesWindow.close(); } }); return vvrAttributesWindow; }
From source file:com.oodrive.nuage.webui.component.window.VvrCreateWindow.java
License:Apache License
@SuppressWarnings("serial") @Override//ww w .j a v a 2s .co m public final Window init(final AbstractItemModel model) { // Add new window vvrCreateWindow.center(); final FormLayout vvrCreateLayout = new FormLayout(); vvrCreateLayout.setMargin(true); vvrCreateWindow.setContent(vvrCreateLayout); vvrCreateWindow.setResizable(false); vvrCreateWindow.setClosable(false); // Enter name final TextField vvrName = new TextField("Name"); vvrName.setValue(""); vvrCreateLayout.addComponent(vvrName); // Enter decription final TextField vvrDescription = new TextField("Description"); vvrDescription.setValue(""); vvrCreateLayout.addComponent(vvrDescription); // Button create final Button vvrCreateButton = new Button("Create"); vvrCreateLayout.addComponent(vvrCreateButton); vvrCreateButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { ((VvrManagerModel) model).createVvr(vvrName.getValue(), vvrDescription.getValue()); Notification.show("New VVR created", Notification.Type.TRAY_NOTIFICATION); postProcessing.execute(); } catch (final Exception e) { final ErrorWindow err = new ErrorWindow("VVR not created: " + e.getMessage()); err.add(model); } } }); return vvrCreateWindow; }
From source file:com.peergreen.webconsole.scope.deployment.internal.components.DeployableWindow.java
License:Open Source License
public Component getContent() { FormLayout content = new FormLayout(); content.setSpacing(true);/*from ww w .j a v a 2s .c o m*/ content.setMargin(true); Label name = new Label(deployableEntry.getName()); name.setCaption("Name"); content.addComponent(name); Label uri = new Label(deployableEntry.getUri().toString()); uri.setCaption("URI"); content.addComponent(uri); VerticalLayout status = new VerticalLayout(); status.setCaption("Status"); content.addComponent(status); if (report == null) { // is not deployed yet status.addComponent(new Label("Ready to be deployed")); } else { if (report.getExceptions().size() == 0) { status.addComponent(new Label("<p style=\"color:#329932\">Deployed</p>", ContentMode.HTML)); } else { for (ArtifactError artifactError : report.getExceptions()) { for (ArtifactErrorDetail detail : artifactError.getDetails()) { ExceptionView exceptionView = new ExceptionView(detail); status.addComponent(exceptionView); } } } VerticalLayout endPointsLayout = new VerticalLayout(); for (Endpoint endpoint : report.getEndpoints()) { try { Link link = new Link(endpoint.getURI().toString(), new ExternalResource(endpoint.getURI().toURL())); link.setTargetName("_blank"); endPointsLayout.addComponent(link); } catch (MalformedURLException e) { endPointsLayout.addComponent(new Label(endpoint.getURI().toString())); } } if (endPointsLayout.getComponentCount() > 0) { content.addComponent(endPointsLayout); endPointsLayout.setCaption("End points"); } } return content; }
From source file:com.peergreen.webconsole.scope.home.extensions.PeergreenNewsFeedFrame.java
License:Open Source License
/** * News popup// w ww .j av a 2 s . co m * * @param feedMessage * @return */ private Window getNewsDescription(FeedMessage feedMessage) { FormLayout fields = new FormLayout(); fields.setWidth("35em"); fields.setSpacing(true); fields.setMargin(true); Label label = new Label("<a href=\"" + feedMessage.getLink() + "\">" + feedMessage.getLink().substring(0, 50) + "..." + "</a>"); label.setContentMode(ContentMode.HTML); label.setSizeUndefined(); label.setCaption("URL"); fields.addComponent(label); String description = feedMessage.getDescription(); if (description.length() > 1000) { description = description.substring(0, 999) + "..."; } Label desc = new Label(description); desc.setContentMode(ContentMode.HTML); desc.setCaption("Description"); fields.addComponent(desc); Button ok = new Button("Close"); ok.addStyleName("wide"); ok.addStyleName("default"); final Window w = new DefaultWindow(feedMessage.getTitle(), fields, ok); w.center(); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { w.close(); } }); return w; }