List of usage examples for com.vaadin.ui FormLayout setSizeFull
@Override public void setSizeFull()
From source file:org.jpos.qi.eeuser.UsersView.java
License:Open Source License
private Panel createPasswordPanel() { passwordPanel = new Panel(getApp().getMessage("changePassword")); passwordPanel.setIcon(VaadinIcons.LOCK); passwordPanel.addStyleName("color1"); passwordPanel.addStyleName("margin-top-panel"); VerticalLayout panelContent = new VerticalLayout(); panelContent.setSizeFull();/*from w w w. j av a 2 s . c o m*/ panelContent.setMargin(true); panelContent.setSpacing(true); FormLayout form = new FormLayout(); form.setSizeFull(); panelContent.addComponent(form); panelContent.setExpandRatio(form, 1f); passwordBinder = new Binder<>(); passwordBinder.setReadOnly(true); binderIsReadOnly = true; if (selectedU.getId() != null) { currentPasswordField = new PasswordField(getApp().getMessage("passwordForm.currentPassword")); currentPasswordField.setWidth("80%"); passwordBinder.forField(currentPasswordField) .asRequired(getApp().getMessage("errorMessage.req", currentPasswordField.getCaption())) .withValidator(((UsersHelper) getHelper()).getCurrentPasswordMatchValidator()) .bind(string -> string, null); form.addComponent(currentPasswordField); } PasswordField newPasswordField = new PasswordField(getApp().getMessage("passwordForm.newPassword")); newPasswordField.setWidth("80%"); passwordBinder.forField(newPasswordField) .asRequired(getApp().getMessage("errorMessage.req", newPasswordField.getCaption())) .withValidator(((UsersHelper) getHelper()).getNewPasswordNotUsedValidator()) .bind(string -> string, null); form.addComponent(newPasswordField); repeatPasswordField = new PasswordField(getApp().getMessage("passwordForm.confirmPassword")); repeatPasswordField.setWidth("80%"); passwordBinder.forField(repeatPasswordField) .asRequired(getApp().getMessage("errorMessage.req", repeatPasswordField.getCaption())) .withValidator(((UsersHelper) getHelper()).getPasswordsMatchValidator(newPasswordField)) .bind(string -> string, null); form.addComponent(repeatPasswordField); passwordPanel.setVisible(forcePasswordChange); passwordPanel.setContent(panelContent); return passwordPanel; }
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(); form.setSpacing(true);/*from w w w .j a va2s. c o m*/ 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.vaadin.ui.sqlexplorer.DbExportDialog.java
License:Open Source License
protected void createOptionLayout() { optionLayout = new VerticalLayout(); optionLayout.addStyleName("v-scrollable"); optionLayout.setMargin(true);/*from w w w. j a v a2 s . c o m*/ optionLayout.setSpacing(true); optionLayout.setSizeFull(); optionLayout.addComponent(new Label("Please choose from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); optionLayout.addComponent(formLayout); optionLayout.setExpandRatio(formLayout, 1); formatSelect = new ComboBox("Format"); formatSelect.setImmediate(true); for (DbExportFormat format : DbExportFormat.values()) { formatSelect.addItem(format); } formatSelect.setNullSelectionAllowed(false); formatSelect.setValue(DbExportFormat.SQL); formatSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { DbExportFormat format = (DbExportFormat) formatSelect.getValue(); switch (format) { case SQL: compatibilitySelect.setEnabled(true); compatibilitySelect.setNullSelectionAllowed(false); setDefaultCompatibility(); data.setEnabled(true); foreignKeys.setEnabled(true); indices.setEnabled(true); quotedIdentifiers.setEnabled(true); break; case XML: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(true); foreignKeys.setEnabled(true); indices.setEnabled(true); quotedIdentifiers.setEnabled(true); break; case CSV: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(false); foreignKeys.setEnabled(false); indices.setEnabled(false); quotedIdentifiers.setEnabled(false); break; case SYM_XML: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(false); foreignKeys.setEnabled(false); indices.setEnabled(false); quotedIdentifiers.setEnabled(false); break; } } }); formatSelect.select(DbExportFormat.SQL); formLayout.addComponent(formatSelect); compatibilitySelect = new ComboBox("Compatibility"); for (Compatible compatability : Compatible.values()) { compatibilitySelect.addItem(compatability); } compatibilitySelect.setNullSelectionAllowed(false); setDefaultCompatibility(); formLayout.addComponent(compatibilitySelect); createInfo = new CheckBox("Create Tables"); formLayout.addComponent(createInfo); dropTables = new CheckBox("Drop Tables"); formLayout.addComponent(dropTables); data = new CheckBox("Insert Data"); data.setValue(true); formLayout.addComponent(data); foreignKeys = new CheckBox("Create Foreign Keys"); formLayout.addComponent(foreignKeys); indices = new CheckBox("Create Indices"); formLayout.addComponent(indices); quotedIdentifiers = new CheckBox("Qualify with Quoted Identifiers"); formLayout.addComponent(quotedIdentifiers); whereClauseField = new TextArea("Where Clause"); whereClauseField.setWidth(100, Unit.PERCENTAGE); whereClauseField.setRows(2); formLayout.addComponent(whereClauseField); exportFormatOptionGroup = new OptionGroup("Export Format"); exportFormatOptionGroup.setImmediate(true); exportFormatOptionGroup.addItem(EXPORT_AS_A_FILE); if (queryPanel != null) { exportFormatOptionGroup.addItem(EXPORT_TO_THE_SQL_EDITOR); } exportFormatOptionGroup.setValue(EXPORT_AS_A_FILE); exportFormatOptionGroup.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { setExportButtonsEnabled(); } }); formLayout.addComponent(exportFormatOptionGroup); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbFillDialog.java
License:Open Source License
protected void createOptionLayout() { optionLayout = new VerticalLayout(); optionLayout.addStyleName("v-scrollable"); optionLayout.setMargin(true);/* w ww .ja v a 2s.c o m*/ optionLayout.setSpacing(true); optionLayout.setSizeFull(); optionLayout.addComponent(new Label("Please choose from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); optionLayout.addComponent(formLayout); optionLayout.setExpandRatio(formLayout, 1); countField = new TextField("Count (# of rows to fill)"); countField.setValue("1"); countField.setTextChangeEventMode(TextChangeEventMode.EAGER); countField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { countField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(countField); intervalField = new TextField("Interval (ms)"); intervalField.setValue("0"); intervalField.setTextChangeEventMode(TextChangeEventMode.EAGER); intervalField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { intervalField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(intervalField); insertWeightField = new TextField("Insert Weight"); insertWeightField.setValue("1"); insertWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER); insertWeightField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { insertWeightField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(insertWeightField); updateWeightField = new TextField("Update Weight"); updateWeightField.setValue("0"); updateWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER); updateWeightField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { updateWeightField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(updateWeightField); deleteWeightField = new TextField("Delete Weight"); deleteWeightField.setValue("0"); deleteWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER); deleteWeightField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { deleteWeightField.setValue(event.getText()); fillButton.setEnabled(enableFillButton()); } }); formLayout.addComponent(deleteWeightField); continueBox = new CheckBox("Continue (ignore ANY errors and continue to modify)"); continueBox.setValue(true); formLayout.addComponent(continueBox); cascadeBox = new CheckBox("Fill dependent tables also."); cascadeBox.setValue(false); formLayout.addComponent(cascadeBox); cascadeSelectBox = new CheckBox("Fill dependent tables by selecting existing data."); cascadeSelectBox.setValue(false); formLayout.addComponent(cascadeSelectBox); verboseBox = new CheckBox("Turn on verbose logging during fill."); verboseBox.setValue(false); formLayout.addComponent(verboseBox); truncateBox = new CheckBox("Truncate table(s) before filling."); truncateBox.setValue(false); formLayout.addComponent(truncateBox); oGroup = new OptionGroup(); oGroup.addItem("Fill Table(s)"); oGroup.addItem("Send to Sql Editor"); oGroup.select("Fill Table(s)"); oGroup.setNullSelectionAllowed(false); formLayout.addComponent(oGroup); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbImportDialog.java
License:Open Source License
protected void createImportLayout() { importLayout = new VerticalLayout(); importLayout.setSizeFull();/*from www. jav a2 s .c om*/ importLayout.addStyleName("v-scrollable"); importLayout.setMargin(true); importLayout.setSpacing(true); importLayout.addComponent(new Label("Please select from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); importLayout.addComponent(formLayout); importLayout.setExpandRatio(formLayout, 1); formatSelect = new ComboBox("Format"); for (DbImportFormat format : DbImportFormat.values()) { formatSelect.addItem(format); } formatSelect.setNullSelectionAllowed(false); formatSelect.setValue(DbImportFormat.SQL); formatSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { DbImportFormat format = (DbImportFormat) formatSelect.getValue(); switch (format) { case SQL: listOfTablesSelect.setEnabled(false); alter.setEnabled(false); alterCase.setEnabled(false); break; case XML: listOfTablesSelect.setEnabled(false); alter.setEnabled(true); alterCase.setEnabled(true); break; case CSV: listOfTablesSelect.setEnabled(true); alter.setEnabled(false); alterCase.setEnabled(false); importButton.setEnabled(importButtonEnable()); break; case SYM_XML: listOfTablesSelect.setEnabled(false); alter.setEnabled(false); alterCase.setEnabled(false); break; } } }); formLayout.addComponent(formatSelect); catalogSelect = new ComboBox("Catalog"); catalogSelect.setImmediate(true); CommonUiUtils.addItems(getCatalogs(), catalogSelect); catalogSelect.select(databasePlatform.getDefaultCatalog()); catalogSelect.setNullSelectionAllowed(false); formLayout.addComponent(catalogSelect); schemaSelect = new ComboBox("Schema"); schemaSelect.setImmediate(true); CommonUiUtils.addItems(getSchemas(), schemaSelect); if (selectedTablesSet.iterator().hasNext()) { schemaSelect.select(selectedTablesSet.iterator().next().getSchema()); } else { schemaSelect.select(databasePlatform.getDefaultSchema()); } schemaSelect.setNullSelectionAllowed(false); schemaSelect.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { populateListOfTablesSelect(); } }); formLayout.addComponent(schemaSelect); listOfTablesSelect = new ComboBox("Tables"); populateListOfTablesSelect(); listOfTablesSelect.setEnabled(false); listOfTablesSelect.setNullSelectionAllowed(false); if (!this.selectedTablesSet.isEmpty()) { if (this.selectedTablesSet.size() == 1) { this.selectedTable = this.selectedTablesSet.iterator().next(); listOfTablesSelect.select(this.selectedTable.getName()); this.selectedTablesSet.clear(); } else { List<Table> list = new ArrayList<Table>(this.selectedTablesSet); listOfTablesSelect.select(list.get(0).getName()); this.selectedTable = list.get(0); this.selectedTablesSet.clear(); } } formLayout.addComponent(listOfTablesSelect); commitField = new TextField("Rows to Commit"); commitField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { commitField.setValue(event.getText()); if (fileSelected) { importButton.setEnabled(importButtonEnable()); } } }); commitField.setImmediate(true); commitField.setTextChangeEventMode(TextChangeEventMode.EAGER); commitField.setValue("10000"); formLayout.addComponent(commitField); force = new CheckBox("Force"); formLayout.addComponent(force); ignore = new CheckBox("Ignore"); formLayout.addComponent(ignore); replace = new CheckBox("Replace"); formLayout.addComponent(replace); alter = new CheckBox("Alter"); alter.setEnabled(false); formLayout.addComponent(alter); alterCase = new CheckBox("Alter Case"); alterCase.setEnabled(false); formLayout.addComponent(alterCase); upload = new Upload("File", new Receiver() { private static final long serialVersionUID = 1L; @Override public OutputStream receiveUpload(String filename, String mimeType) { try { file = File.createTempFile("dbimport", formatSelect.getValue().toString()); out = new FileOutputStream(file); return new BufferedOutputStream(new FileOutputStream(file)); } catch (Exception e) { log.warn(e.getMessage(), e); CommonUiUtils.notify("Failed to import " + filename, e); } return null; } }); upload.addSucceededListener(new SucceededListener() { private static final long serialVersionUID = 1L; @Override public void uploadSucceeded(SucceededEvent event) { createDbImport(); try { doDbImport(); } catch (FileNotFoundException e) { log.warn(e.getMessage(), e); Notification.show(e.getMessage()); } deleteFileAndResource(); close(); } }); upload.addChangeListener(new ChangeListener() { private static final long serialVersionUID = 1L; public void filenameChanged(ChangeEvent event) { fileSelected = true; importButton.setEnabled(importButtonEnable()); } }); upload.setButtonCaption(null); formLayout.addComponent(upload); cancelButton = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(DbImportDialog.this); } }); importButton = CommonUiUtils.createPrimaryButton("Import", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { upload.submitUpload(); } }); importButton.setEnabled(false); addComponent(importLayout, 1); addComponent(buildButtonFooter(cancelButton, importButton)); }
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. *///from w ww.j a v a2s .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.plugins.topo.bsm.info.BusinessServiceVertexStatusInfoPanelItem.java
License:Open Source License
@Override protected Component getComponent(VertexRef ref, GraphContainer container) { final BusinessServiceVertex vertex = (BusinessServiceVertex) ref; final FormLayout rootLayout = new FormLayout(); rootLayout.setSizeFull(); rootLayout.setSpacing(false);/* ww w .j a va 2s . c o m*/ rootLayout.setMargin(false); rootLayout.addStyleName("severity"); final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory .createStateMachine(businessServiceManager, container.getCriteria()); final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex); rootLayout.addComponent(createStatusLabel("Overall", overallStatus)); rootLayout.addComponent(new Label()); final BusinessServiceGraph graph = stateMachine.getGraph(); final BusinessService businessService = businessServiceManager .getBusinessServiceById(vertex.getServiceId()); final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService); for (final Edge edge : businessService.getEdges()) { // Get the topology vertex for the child to determine the display label final Vertex childVertex = businessServicesTopologyProvider .getVertex(edge.accept(new EdgeVisitor<VertexRef>() { @Override public VertexRef visit(final IpServiceEdge edge) { return new IpServiceVertex(edge.getIpService(), 0); } @Override public VertexRef visit(final ReductionKeyEdge edge) { return new ReductionKeyVertex(edge.getReductionKey(), 0); } @Override public VertexRef visit(final ChildEdge edge) { return new BusinessServiceVertex(edge.getChild(), 0); } })); final Status edgeStatus = stateMachine.getOperationalStatus(edge); rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format( "%s × %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : ""))); } return rootLayout; }
From source file:org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexStatusInfoPanelItemProvider.java
License:Open Source License
private Component createComponent(BusinessServiceVertex vertex, GraphContainer container) { final FormLayout rootLayout = new FormLayout(); rootLayout.setSizeFull(); rootLayout.setSpacing(false);//from w w w . ja v a 2 s . c om rootLayout.setMargin(false); rootLayout.addStyleName("severity"); final BusinessServiceStateMachine stateMachine = SimulationAwareStateMachineFactory .createStateMachine(businessServiceManager, container.getCriteria()); final Status overallStatus = BusinessServicesStatusProvider.getStatus(stateMachine, vertex); rootLayout.addComponent(createStatusLabel("Overall", overallStatus)); rootLayout.addComponent(new Label()); final BusinessServiceGraph graph = stateMachine.getGraph(); final BusinessService businessService = businessServiceManager .getBusinessServiceById(vertex.getServiceId()); final Set<GraphVertex> impactingVertices = getImpactingVertices(stateMachine, graph, businessService); for (final Edge edge : businessService.getEdges()) { // Get the topology vertex for the child to determine the display label final Vertex childVertex = businessServicesTopologyProvider .getVertex(edge.accept(new EdgeVisitor<VertexRef>() { @Override public VertexRef visit(final IpServiceEdge edge) { return new IpServiceVertex(edge.getIpService(), 0); } @Override public VertexRef visit(final ReductionKeyEdge edge) { return new ReductionKeyVertex(edge.getReductionKey(), 0); } @Override public VertexRef visit(final ChildEdge edge) { return new BusinessServiceVertex(edge.getChild(), 0); } })); final Status edgeStatus = stateMachine.getOperationalStatus(edge); rootLayout.addComponent(createStatusLabel(childVertex.getLabel(), edgeStatus, String.format( "%s × %d <i class=\"pull-right glyphicon %s\"></i>", edgeStatus.getLabel(), edge.getWeight(), impactingVertices.contains(graph.getVertexByEdgeId(edge.getId())) ? "glyphicon-flash" : ""))); } return rootLayout; }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewConfigurationCategoryWindow.java
License:Open Source License
/** * The constructor for instantiating this component. * * @param surveillanceViewService the surveillance view service to be used. * @param defs the column/row defs * @param def the def to be edited * @param saveActionListener the listener for the saving action *///from w ww.j av a 2 s . c o m public SurveillanceViewConfigurationCategoryWindow(final SurveillanceViewService surveillanceViewService, final Collection<?> defs, final Def def, final SaveActionListener saveActionListener) { /** * calling the super constructor */ super("Window title"); /** * Check whether this dialog is for a column or row and alter the window title */ if (def instanceof RowDef) { super.setCaption("Row definition"); } else { super.setCaption("Column definition"); } /** * Setting the modal and size properties */ setModal(true); setClosable(false); setResizable(false); setWidth(30, Sizeable.Unit.PERCENTAGE); setHeight(400, Unit.PIXELS); /** * Title and refresh seconds */ final TextField labelField = new TextField(); labelField.setValue(def.getLabel()); labelField.setImmediate(true); labelField.setCaption("Label"); labelField.setDescription("Label of this category"); labelField.setWidth(100, Unit.PERCENTAGE); /** * Creating a simple validator for the title field */ labelField.addValidator( new AbstractStringValidator("Please use an unique name for this column/row definition") { @Override protected boolean isValidValue(String s) { if ("".equals(s.trim())) { return false; } /** * check if the name clashes with other defs */ for (Def defx : (Collection<Def>) defs) { if (defx.getLabel().equals(s)) { if (defx != def) { return false; } } } return true; } }); /** * Categories table */ final Table categoriesTable = new Table(); categoriesTable.setSizeFull(); categoriesTable.setHeight(250.0f, Unit.PIXELS); categoriesTable.setCaption("Categories"); categoriesTable.setSortEnabled(true); categoriesTable.addContainerProperty("name", String.class, ""); categoriesTable.setColumnHeader("name", "Category"); categoriesTable.setColumnExpandRatio("Category", 1.0f); categoriesTable.setSelectable(true); categoriesTable.setMultiSelect(true); final List<OnmsCategory> categories = surveillanceViewService.getOnmsCategories(); final Map<Integer, OnmsCategory> categoriesMap = new HashMap<>(); for (OnmsCategory onmsCategory : categories) { categoriesTable.addItem(new Object[] { onmsCategory.getName() }, onmsCategory.getId()); categoriesMap.put(onmsCategory.getId(), onmsCategory); if (def.containsCategory(onmsCategory.getName())) { categoriesTable.select(onmsCategory.getId()); } } /** * Create form layouts... */ FormLayout baseFormLayout = new FormLayout(); baseFormLayout.setSizeFull(); baseFormLayout.setMargin(true); baseFormLayout.addComponent(labelField); baseFormLayout.addComponent(categoriesTable); /** * Creating the vertical layout... */ VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull(); verticalLayout.addComponent(baseFormLayout); verticalLayout.setExpandRatio(baseFormLayout, 1.0f); /** * Using an additional {@link com.vaadin.ui.HorizontalLayout} for layouting the buttons */ HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setMargin(true); horizontalLayout.setSpacing(true); horizontalLayout.setWidth(100, Unit.PERCENTAGE); /** * Adding the cancel button... */ Button cancel = new Button("Cancel"); cancel.setDescription("Cancel editing properties"); cancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); horizontalLayout.addComponent(cancel); horizontalLayout.setExpandRatio(cancel, 1); horizontalLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT); /** * ...and the OK button */ Button ok = new Button("Save"); ok.setDescription("Save properties and close"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Def finalDef = null; if (def instanceof RowDef) { finalDef = new RowDef(); } if (def instanceof ColumnDef) { finalDef = new ColumnDef(); } Set<Object> categories = (Set<Object>) categoriesTable.getValue(); if (!labelField.isValid()) { ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error", "Please use an unique label for this category", Notification.Type.ERROR_MESSAGE); return; } if (categories.isEmpty()) { ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error", "You must choose at least one surveillance category", Notification.Type.ERROR_MESSAGE); return; } for (Object object : categories) { Category category = new Category(); category.setName(categoriesMap.get(object).getName()); finalDef.getCategories().add(category); } finalDef.setLabel(labelField.getValue()); saveActionListener.save(finalDef); close(); } }); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); horizontalLayout.addComponent(ok); verticalLayout.addComponent(horizontalLayout); setContent(verticalLayout); }
From source file:pl.exsio.frameset.vaadin.ui.support.component.data.form.TabbedForm.java
License:Open Source License
private void initTabs() { int tabIndex = 0; for (String tabName : this.config.keySet()) { VerticalLayout outerLayout = new VerticalLayout() { {/* w ww . ja v a2s . c om*/ FormLayout tabLayout = new FormLayout(); tabLayout.setMargin(true); tabLayout.setSizeFull(); addComponent(tabLayout); } }; outerLayout.setMargin(true); outerLayout.setSizeFull(); Tab tab = this.tabs.addTab(outerLayout, tabName); tab.setCaption(t(tabName)); this.tabsMap.put(tabName, tabIndex); tabIndex++; for (String property : this.config.get(tabName)) { this.propertiesMap.put(property, tabName); } } }