List of usage examples for com.vaadin.ui FormLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:org.jumpmind.metl.ui.views.admin.MailServerPanel.java
License:Open Source License
public MailServerPanel(final ApplicationContext context, TabbedPanel tabbedPanel) { this.context = context; this.tabbedPanel = tabbedPanel; final GlobalSetting hostNameSetting = getGlobalSetting(MailSession.SETTING_HOST_NAME, "localhost"); final GlobalSetting transportSetting = getGlobalSetting(MailSession.SETTING_TRANSPORT, "smtp"); final GlobalSetting portSetting = getGlobalSetting(MailSession.SETTING_PORT_NUMBER, "25"); final GlobalSetting fromSetting = getGlobalSetting(MailSession.SETTING_FROM, "metl@localhost"); final GlobalSetting usernameSetting = getGlobalSetting(MailSession.SETTING_USERNAME, ""); final GlobalSetting passwordSetting = getGlobalSetting(MailSession.SETTING_PASSWORD, ""); final GlobalSetting useTlsSetting = getGlobalSetting(MailSession.SETTING_USE_TLS, "false"); final GlobalSetting useAuthSetting = getGlobalSetting(MailSession.SETTING_USE_AUTH, "false"); FormLayout form = new FormLayout(); form.setSpacing(true); ImmediateUpdateTextField hostField = new ImmediateUpdateTextField("Host name") { protected void save(String value) { saveSetting(hostNameSetting, value); }/*from w w w .jav a2 s . c om*/ }; hostField.setValue(hostNameSetting.getValue()); hostField.setWidth(25f, Unit.EM); form.addComponent(hostField); hostField.focus(); NativeSelect transportField = new NativeSelect("Transport"); transportField.addItem("smtp"); transportField.addItem("smtps"); transportField.select(transportSetting.getValue() == null ? "smtp" : transportSetting.getValue()); transportField.setNullSelectionAllowed(false); transportField.setImmediate(true); transportField.setWidth(10f, Unit.EM); transportField.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { saveSetting(transportSetting, (String) event.getProperty().getValue()); } }); form.addComponent(transportField); ImmediateUpdateTextField portField = new ImmediateUpdateTextField("Port") { protected void save(String value) { saveSetting(portSetting, value); } }; portField.setValue(portSetting.getValue()); portField.setWidth(25f, Unit.EM); form.addComponent(portField); ImmediateUpdateTextField fromField = new ImmediateUpdateTextField("From Address") { protected void save(String value) { saveSetting(fromSetting, value); } }; fromField.setValue(fromSetting.getValue()); fromField.setWidth(25f, Unit.EM); form.addComponent(fromField); CheckBox tlsField = new CheckBox("Use TLS", Boolean.valueOf(useTlsSetting.getValue())); tlsField.setImmediate(true); tlsField.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { saveSetting(useTlsSetting, ((Boolean) event.getProperty().getValue()).toString()); } }); form.addComponent(tlsField); final ImmediateUpdateTextField userField = new ImmediateUpdateTextField("Username") { protected void save(String value) { saveSetting(usernameSetting, value); } }; userField.setValue(usernameSetting.getValue()); userField.setWidth(25f, Unit.EM); final ImmediateUpdatePasswordField passwordField = new ImmediateUpdatePasswordField("Password") { protected void save(String value) { saveSetting(passwordSetting, value); } }; passwordField.setValue(passwordSetting.getValue()); passwordField.setWidth(25f, Unit.EM); CheckBox authField = new CheckBox("Use Authentication", Boolean.valueOf(useAuthSetting.getValue())); authField.setImmediate(true); authField.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { Boolean isEnabled = (Boolean) event.getProperty().getValue(); saveSetting(useAuthSetting, isEnabled.toString()); userField.setEnabled(isEnabled); passwordField.setEnabled(isEnabled); } }); form.addComponent(authField); userField.setEnabled(authField.getValue()); form.addComponent(userField); passwordField.setEnabled(authField.getValue()); form.addComponent(passwordField); Button testButton = new Button("Test Connection"); testButton.addClickListener(new TestClickListener()); form.addComponent(testButton); addComponent(form); setMargin(true); }
From source file:org.jumpmind.metl.ui.views.admin.NotificationEditPanel.java
License:Open Source License
public NotificationEditPanel(final ApplicationContext context, final Notification notification) { this.context = context; this.notification = notification; sampleSubjectByEvent = new HashMap<String, String>(); sampleSubjectByEvent.put(Notification.EventType.FLOW_START.toString(), "Flow $(_flowName) started"); sampleSubjectByEvent.put(Notification.EventType.FLOW_END.toString(), "Flow $(_flowName) ended"); sampleSubjectByEvent.put(Notification.EventType.FLOW_ERROR.toString(), "Flow $(_flowName) - ERROR"); sampleMessageByEvent = new HashMap<String, String>(); sampleMessageByEvent.put(Notification.EventType.FLOW_START.toString(), "Started flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)"); sampleMessageByEvent.put(Notification.EventType.FLOW_END.toString(), "Ended flow $(_flowName) on agent $(_agent) at $(_time) on $(_date)"); sampleMessageByEvent.put(Notification.EventType.FLOW_ERROR.toString(), "Error in flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)\n\n$(_errorText)"); FormLayout form = new FormLayout(); form.setSizeFull();/*from ww w . j a va 2 s . c o m*/ form.setSpacing(true); levelField = new NativeSelect("Level"); for (Notification.Level level : Notification.Level.values()) { levelField.addItem(level.toString()); } levelField.setNullSelectionAllowed(false); levelField.setImmediate(true); levelField.setWidth(15f, Unit.EM); levelField.addValueChangeListener(new LevelFieldListener()); form.addComponent(levelField); linkField = new ComboBox("Linked To"); linkField.setNullSelectionAllowed(false); linkField.setImmediate(true); linkField.setWidth(15f, Unit.EM); linkField.addValueChangeListener(new LinkFieldListener()); form.addComponent(linkField); eventField = new NativeSelect("Event"); eventField.setNullSelectionAllowed(false); eventField.setImmediate(true); eventField.setWidth(15f, Unit.EM); eventField.addValueChangeListener(new EventFieldListener()); form.addComponent(eventField); nameField = new ImmediateUpdateTextField("Name") { protected void save(String value) { notification.setName(value); saveNotification(); } }; nameField.setValue(StringUtils.trimToEmpty(notification.getName())); nameField.setWidth(20f, Unit.EM); nameField.setDescription("Display name for the notification"); form.addComponent(nameField); ImmediateUpdateTextArea recipientsField = new ImmediateUpdateTextArea("Recipients") { protected void save(String value) { notification.setRecipients(value); saveNotification(); } }; recipientsField.setValue(StringUtils.trimToEmpty(notification.getRecipients())); recipientsField.setColumns(20); recipientsField.setRows(10); recipientsField.setInputPrompt("address1@example.com\r\naddress2@example.com"); recipientsField.setDescription("Email addresses of recipients, separated by commas."); form.addComponent(recipientsField); subjectField = new ImmediateUpdateTextField("Subject") { protected void save(String value) { notification.setSubject(value); saveNotification(); } }; subjectField.setValue(StringUtils.trimToEmpty(notification.getSubject())); subjectField.setWidth(40f, Unit.EM); subjectField.setDescription("The subject of the email can contain..."); form.addComponent(subjectField); messageField = new ImmediateUpdateTextArea("Message") { protected void save(String value) { notification.setMessage(value); saveNotification(); } }; messageField.setValue(StringUtils.trimToEmpty(notification.getMessage())); messageField.setColumns(40); messageField.setRows(10); messageField.setDescription("The body of the email can contain..."); form.addComponent(messageField); CheckBox enableField = new CheckBox("Enabled", notification.isEnabled()); enableField.setImmediate(true); enableField.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { notification.setEnabled((Boolean) event.getProperty().getValue()); saveNotification(); } }); form.addComponent(enableField); if (notification.getLevel() == null) { isInit = true; levelField.setValue(Notification.Level.GLOBAL.toString()); notification.setLevel(Notification.Level.GLOBAL.toString()); notification.setNotifyType(Notification.NotifyType.MAIL.toString()); updateLinks(); updateEventTypes(); updateName(); } else { levelField.setValue(notification.getLevel()); updateLinks(); updateEventTypes(); linkField.setValue(notification.getLinkId()); eventField.setValue(notification.getEventType()); isInit = true; } addComponent(form); setMargin(true); autoSave = true; }
From source file:org.jumpmind.metl.ui.views.admin.UserEditPanel.java
License:Open Source License
public UserEditPanel(ApplicationContext context, User user) { this.context = context; this.user = user; FormLayout form = new FormLayout(); form.setSpacing(true); TextField loginField = new TextField("Login ID", StringUtils.trimToEmpty(user.getLoginId())); form.addComponent(loginField);// www. j a va2 s .c o m loginField.addValueChangeListener(new LoginChangeListener()); loginField.focus(); TextField nameField = new TextField("Full Name", StringUtils.trimToEmpty(user.getName())); nameField.addValueChangeListener(new NameChangeListener()); form.addComponent(nameField); PasswordField passwordField = new PasswordField("Password", NOCHANGE); passwordField.addValueChangeListener(new PasswordChangeListener()); form.addComponent(passwordField); List<Group> groups = context.getConfigurationService().findGroups(); groupsById = new HashMap<String, Group>(); TwinColSelect groupSelect = new TwinColSelect(); for (Group group : groups) { groupSelect.addItem(group.getId()); groupSelect.setItemCaption(group.getId(), group.getName()); groupsById.put(group.getId(), group); } lastGroups = new HashSet<String>(); for (Group group : user.getGroups()) { lastGroups.add(group.getId()); } groupSelect.setValue(lastGroups); groupSelect.setRows(20); groupSelect.setNullSelectionAllowed(true); groupSelect.setMultiSelect(true); groupSelect.setImmediate(true); groupSelect.setLeftColumnCaption("Available groups"); groupSelect.setRightColumnCaption("Selected groups"); groupSelect.addValueChangeListener(new GroupChangeListener()); form.addComponent(groupSelect); addComponent(form); setMargin(true); }
From source file:org.jumpmind.metl.ui.views.deploy.EditAgentDeploymentPanel.java
License:Open Source License
public EditAgentDeploymentPanel(ApplicationContext context, AgentDeployment agentDeployment, AgentDeploymentChangeListener listener, TabbedPanel tabbedPanel) { this.context = context; this.agentDeployment = agentDeployment; this.listener = listener; this.tabbedPanel = tabbedPanel; VerticalLayout vlay = new VerticalLayout(); FormLayout form = new FormLayout(); form.setSpacing(true); form.setMargin(true);/*from w w w . ja v a 2s .co m*/ form.addComponent(getNameComponent()); form.addComponent(getLogLevelComponent()); form.addComponent(getStartTypeComponent()); vlay.addComponent(form); cronLayout = new HorizontalLayout(); cronLayout.setSpacing(true); cronLayout.setMargin(true); cronLayout.addComponent(getScheduleComponent("Second")); cronLayout.addComponent(getScheduleComponent("Minute")); cronLayout.addComponent(getScheduleComponent("Hour")); cronLayout.addComponent(getScheduleComponent("Day")); cronLayout.addComponent(getScheduleComponent("Month")); cronLayout.addComponent(getScheduleComponent("Day of Week")); cronLayout.addComponent(getScheduleComponent("Year")); vlay.addComponent(cronLayout); FormLayout cronForm = new FormLayout(); cronForm.setSpacing(true); cronForm.setMargin(true); cronForm.addComponent(getCronComponent()); vlay.addComponent(cronForm); table = new Table(); table.setSizeFull(); BeanItemContainer<AgentDeploymentParameter> container = new BeanItemContainer<AgentDeploymentParameter>( AgentDeploymentParameter.class); table.setContainerDataSource(container); table.setEditable(true); table.setSelectable(true); table.setTableFieldFactory(new EditFieldFactory()); table.setVisibleColumns("name", "value"); table.setColumnHeaders("Parameter Name", "Value"); container.addAll(agentDeployment.getAgentDeploymentParameters()); setSplitPosition(60f); setFirstComponent(vlay); setSecondComponent(table); updateScheduleEnable(); updateScheduleFields(); }
From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorOptions.java
License:Open Source License
/** * Creates the upper right component of the options grid. * Creation includes the initialization of {@link #m_filePathField}. * * @return the upper right component in the options grid. *//* w w w . ja v a 2 s . c om*/ private Component createUpperRightComponent() { HorizontalLayout upperRight = new HorizontalLayout(); upperRight.setSizeFull(); FormLayout fileNameDisplay = new FormLayout(); fileNameDisplay.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); fileNameDisplay.setSizeFull(); m_filePathField = new TextField(); m_filePathField.setWidth("100%"); m_filePathField.setEnabled(true); m_filePathField.setReadOnly(true); fileNameDisplay.addComponent(m_filePathField); fileNameDisplay.setSpacing(true); FormLayout filePathDisplay = new FormLayout(); filePathDisplay.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); filePathDisplay.setSizeFull(); filePathDisplay.addComponent(m_filePathField); filePathDisplay.setSpacing(true); upperRight.addComponent(filePathDisplay); upperRight.setExpandRatio(filePathDisplay, 2f); HorizontalLayout placeHolder = new HorizontalLayout(); placeHolder.setWidth(CmsMessageBundleEditorTypes.OPTION_COLUMN_WIDTH_PX); upperRight.addComponent(placeHolder); return upperRight; }
From source file:org.opennms.features.topology.app.internal.ui.info.DefaultEdgeInfoPanelItem.java
License:Open Source License
@Override protected Component getComponent(EdgeRef ref, GraphContainer container) { FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false); formLayout.setMargin(false);//ww w. j a v a2 s. c o m if (ref instanceof AbstractEdge) { AbstractEdge edge = (AbstractEdge) ref; formLayout.addComponent(createLabel("Source", edge.getSource().getVertex().getLabel())); formLayout.addComponent(createLabel("Target", edge.getTarget().getVertex().getLabel())); } return formLayout; }
From source file:org.opennms.features.topology.app.internal.ui.info.DefaultEdgeInfoPanelItemProvider.java
License:Open Source License
private Component createComponent(EdgeRef ref) { FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false); formLayout.setMargin(false);//from www .j a v a 2 s . c om if (ref instanceof AbstractEdge) { AbstractEdge edge = (AbstractEdge) ref; formLayout.addComponent(createLabel("Source", edge.getSource().getVertex().getLabel())); formLayout.addComponent(createLabel("Target", edge.getTarget().getVertex().getLabel())); } return formLayout; }
From source file:org.opennms.features.topology.app.internal.ui.info.DefaultVertexInfoPanelItem.java
License:Open Source License
@Override protected Component getComponent(VertexRef ref, GraphContainer container) { FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false); formLayout.setMargin(false);//from ww w.j av a 2 s . c om formLayout.addComponent(createLabel("Name", ref.getLabel())); formLayout.addComponent(createLabel("ID", String.format("%s:%s", ref.getNamespace(), ref.getId()))); if (ref instanceof AbstractVertex) { AbstractVertex vertex = (AbstractVertex) ref; formLayout.addComponent(createLabel("Icon Key", vertex.getIconKey())); if (vertex.getIpAddress() != null) { formLayout.addComponent(createLabel("IP Address", vertex.getIpAddress())); } } return formLayout; }
From source file:org.opennms.features.topology.app.internal.ui.info.DefaultVertexInfoPanelItemProvider.java
License:Open Source License
private Component createComponent(VertexRef ref) { FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false); formLayout.setMargin(false);// w ww. j a v a2 s. com formLayout.addComponent(createLabel("Name", ref.getLabel())); formLayout.addComponent(createLabel("ID", String.format("%s:%s", ref.getNamespace(), ref.getId()))); if (ref instanceof AbstractVertex) { AbstractVertex vertex = (AbstractVertex) ref; formLayout.addComponent(createLabel("Icon Key", vertex.getIconKey())); if (vertex.getIpAddress() != null) { formLayout.addComponent(createLabel("IP Address", vertex.getIpAddress())); } } return formLayout; }
From source file:org.opennms.features.topology.app.internal.ui.info.NodeInfoPanelItem.java
License:Open Source License
@Override protected Component getComponent(VertexRef ref, GraphContainer container) { if (ref instanceof AbstractVertex && ((AbstractVertex) ref).getNodeID() != null) { AbstractVertex vertex = ((AbstractVertex) ref); OnmsNode node = nodeDao.get(vertex.getNodeID()); if (node != null) { FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false); formLayout.setMargin(false); formLayout.addComponent(createLabel("Node ID", "" + node.getId())); final HorizontalLayout nodeButtonLayout = new HorizontalLayout(); Button nodeButton = createButton(node.getLabel(), null, null, event -> new NodeInfoWindow(vertex.getNodeID()).open()); nodeButton.setStyleName(BaseTheme.BUTTON_LINK); nodeButtonLayout.addComponent(nodeButton); nodeButtonLayout.setCaption("Node Label"); formLayout.addComponent(nodeButtonLayout); if (!Strings.isNullOrEmpty(node.getSysObjectId())) { formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId())); }//from w ww . ja v a2 s.c om return formLayout; } } return null; }