List of usage examples for com.vaadin.ui FormLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java
License:Apache License
/** * Create attributes component.//from w w w . j a v a 2s .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. * // w w w .j av a 2 s . 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 * /*from ww w .j a v a 2 s .co 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 ww . j a va 2s.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/*from w w w.ja v a2 s. c o 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 www .j ava2 s . 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/*from w w w . j a v a2 s .c om*/ * * @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; }
From source file:com.peergreen.webconsole.scope.logs.LogsScope.java
License:Open Source License
public LogsScope() { setMargin(true);/*ww w.j av a 2s . c om*/ setSpacing(true); setSizeFull(); HorizontalLayout topBar = new HorizontalLayout(); topBar.setWidth("100%"); addComponent(topBar); FormLayout form = new FormLayout(); form.setWidth("40%"); topBar.addComponent(form); TextField textFieldFilter = new TextField(); textFieldFilter.setCaption("Filter:"); textFieldFilter.setInputPrompt("filter"); textFieldFilter.setWidth("60%"); textFieldFilter.addTextChangeListener(new TextChangeListener() { @Override public void textChange(final FieldEvents.TextChangeEvent event) { container.removeAllContainerFilters(); Container.Filter or = new Or(new SimpleStringFilter("caller", event.getText().trim(), true, false), new SimpleStringFilter("text", event.getText().trim(), true, false)); Filter and = new And(or, filter); container.addContainerFilter(and); } }); topBar.addComponent(textFieldFilter); //form.setWidth("100%"); form.setSpacing(true); form.setMargin(true); HorizontalLayout systemLayout = new HorizontalLayout(); systemLayout.setCaption("JVM System streams:"); form.addComponent(systemLayout); HorizontalLayout loggerLayout = new HorizontalLayout(); loggerLayout.setCaption("Loggers:"); form.addComponent(loggerLayout); final CheckBox systemOut = new CheckBox("out"); systemOut.setValue(true); systemLayout.addComponent(systemOut); this.container = new BeanItemContainer<TableEntry>(TableEntry.class); filter = new TypeFilter(); container.addContainerFilter(filter); systemOut.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptSystemOut(value); container.addContainerFilter(filter); } }); CheckBox systemErr = new CheckBox("err"); systemLayout.addComponent(systemErr); systemErr.setValue(true); systemErr.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptSystemErr(value); container.addContainerFilter(filter); } }); CheckBox loggerInfo = new CheckBox("Info"); loggerLayout.addComponent(loggerInfo); loggerInfo.setValue(true); loggerInfo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptLoggerInfo(value); container.addContainerFilter(filter); } }); CheckBox loggerWarning = new CheckBox("Warning"); loggerLayout.addComponent(loggerWarning); loggerWarning.setValue(true); loggerWarning.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptLoggerWarning(value); container.addContainerFilter(filter); } }); CheckBox loggerError = new CheckBox("Error"); loggerLayout.addComponent(loggerError); loggerError.setValue(true); loggerError.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); container.removeAllContainerFilters(); filter.setAcceptLoggerError(value); container.addContainerFilter(filter); } }); Button clearButton = new Button("clear"); //horizontalLayout.addComponent(clearButton); clearButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { container.removeAllItems(); } }); this.table = new Table(); table.setSizeFull(); table.setImmediate(true); // Define the names and data types of columns. table.addContainerProperty("date", Date.class, null); table.addContainerProperty("type", String.class, null); table.addContainerProperty("caller", String.class, null); table.addContainerProperty("text", String.class, "empty"); table.setContainerDataSource(container); table.addGeneratedColumn("text", new TextColumnGenerator()); table.setItemDescriptionGenerator(new ItemDescriptionGenerator() { @Override public String generateDescription(Component source, Object itemId, Object propertyId) { TableEntry tableEntry = (TableEntry) itemId; return simpleDateFormat.format(tableEntry.getDate()).concat(" : ").concat(tableEntry.getType()) .concat(" : ").concat(tableEntry.getCaller()); } }); table.setVisibleColumns(new Object[] { "text" }); table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); table.setSortEnabled(true); addComponent(table); setExpandRatio(table, 1.5f); }
From source file:com.save.employee.CreateNewAccountWindow.java
FormLayout getLayout() { FormLayout f = new FormLayout(); f.setReadOnly(false);//from w w w.jav a 2 s . co m f.setSpacing(true); f.setMargin(true); final TextField employeeNo = new TextField("Employee No: "); employeeNo.setWidth("100%"); employeeNo.setRequired(true); employeeNo.setNullSettingAllowed(false); f.addComponent(employeeNo); final TextField firstname = new TextField("Firstname: "); firstname.setWidth("100%"); firstname.setRequired(true); firstname.setNullSettingAllowed(false); f.addComponent(firstname); final TextField middlename = new TextField("Middlename: "); middlename.setWidth("100%"); middlename.setRequired(true); middlename.setNullSettingAllowed(false); f.addComponent(middlename); final TextField lastname = new TextField("Lastname: "); lastname.setWidth("100%"); lastname.setRequired(true); lastname.setNullSettingAllowed(false); f.addComponent(lastname); final OptionGroup gender = new OptionGroup("Gender: "); gender.addItem("Female"); gender.addItem("Male"); gender.addStyleName("horizontal"); gender.setValue("Female"); f.addComponent(gender); final ComboBox status = new ComboBox("Status: "); status.setWidth("100%"); status.setNullSelectionAllowed(false); status.addItem("Single"); status.addItem("Married"); status.addItem("Widow"); status.addItem("Separated"); f.addComponent(status); Button saveBtn = new Button("SAVE"); saveBtn.setWidth("100%"); saveBtn.addClickListener((Button.ClickEvent event) -> { //TODO if (employeeNo.getValue().isEmpty() || employeeNo.getValue() == null) { Notification.show("Requried Emloyee ID", Notification.Type.WARNING_MESSAGE); return; } if (firstname.getValue().isEmpty() || firstname.getValue() == null) { Notification.show("Requried Firstname", Notification.Type.WARNING_MESSAGE); return; } if (middlename.getValue().isEmpty() || middlename.getValue() == null) { Notification.show("Requried Middlename", Notification.Type.WARNING_MESSAGE); return; } if (lastname.getValue().isEmpty() || lastname.getValue() == null) { Notification.show("Requried Lastname", Notification.Type.WARNING_MESSAGE); return; } if (status.getValue() == null) { Notification.show("Requried Status", Notification.Type.WARNING_MESSAGE); } if (employeeService.checkIfEmployeeNoExist(employeeNo.getValue().trim().toLowerCase())) { Notification.show("EmployeeId already Exist!", Notification.Type.ERROR_MESSAGE); return; } Employee e = new Employee(); e.setEmployeeNo(employeeNo.getValue().trim().toLowerCase()); e.setFirstname(firstname.getValue().trim().toLowerCase()); e.setMiddlename(middlename.getValue().trim().toLowerCase()); e.setLastname(lastname.getValue().trim().toLowerCase()); e.setGender(gender.getValue().toString().trim().toLowerCase()); e.setPersonalStatus(status.getValue().toString()); boolean result = employeeService.createNewAccount(e); if (result) { close(); getHsplit().setFirstComponent(new EmployeesDataGridProperties(getHsplit(), "personal")); } }); f.addComponent(saveBtn); return f; }
From source file:com.save.employee.maintenance.MRFormWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true); formType = CommonComboBox.getFormType("Select Form Type.."); formType.setValue(1);// w ww . ja v a2 s. c om formType.setWidth("60%"); form.addComponent(formType); area = CommonComboBox.areas(); area.setWidth("60%"); form.addComponent(area); plateNo = new TextField("Plate No: "); plateNo.setWidth("60%"); form.addComponent(plateNo); dateCovered = new DateField("Date Covered: "); dateCovered.setWidth("60%"); form.addComponent(dateCovered); amount = new TextField("Amount: "); amount.setWidth("60%"); amount.addStyleName("align-right"); form.addComponent(amount); description = new TextArea("Description: "); description.setWidth("100%"); description.setRows(3); form.addComponent(description); actionButton = new Button(); actionButton.setCaption("SAVE"); actionButton.setWidth("100%"); actionButton.addStyleName(ValoTheme.BUTTON_PRIMARY); actionButton.addClickListener(buttonClickListener); form.addComponent(actionButton); formType.addValueChangeListener((Property.ValueChangeEvent e) -> { if (e.getProperty().getValue().toString().equals("1")) { if (getMrId() != 0) { actionButton.setCaption("UPDATE"); } else { actionButton.setCaption("SAVE"); } panel.setCaption("MAINTENANCE FORM"); } else { if (getMrId() != 0) { actionButton.setCaption("UPDATE"); } else { actionButton.setCaption("SAVE"); } panel.setCaption("REIMBURSEMENT FORM"); } }); editForm(); viewForm(form); return form; }