List of usage examples for com.vaadin.ui ComboBox ComboBox
protected ComboBox(DataCommunicator<T> dataCommunicator)
From source file:org.jumpmind.vaadin.ui.common.ReadOnlyTextAreaDialog.java
License:Open Source License
public ReadOnlyTextAreaDialog(final String title, final String value, Table table, Object[] primaryKeys, IDatabasePlatform platform, boolean isEncodedInHex, boolean isLob) { super(title); this.table = table; this.primaryKeys = primaryKeys; this.platform = platform; this.column = table == null ? null : table.getColumnWithName(title); wrapper = new VerticalLayout(); wrapper.setMargin(true);/* w w w . j a va2s . c om*/ wrapper.setSizeFull(); textField = new TextArea(); textField.setSizeFull(); textField.setWordwrap(false); wrapper.addComponent(textField); addComponent(wrapper, 1); buttonLayout = new HorizontalLayout(); buttonLayout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); buttonLayout.setSpacing(true); buttonLayout.setWidth(100, Unit.PERCENTAGE); addComponent(buttonLayout); if (value != null && isEncodedInHex) { displayBox = new ComboBox("Display As"); displayBox.addItem("Hex"); displayBox.addItem("Text"); displayBox.addItem("Decimal"); displayBox.setNullSelectionAllowed(false); displayBox.select("Hex"); displayBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { updateTextField((String) displayBox.getValue(), value); } }); buttonLayout.addComponent(displayBox); } if (table != null && isLob) { buildUploadButton(title, value); buildDownloadButton(title); } Label spacer = new Label(); buttonLayout.addComponent(spacer); buttonLayout.setExpandRatio(spacer, 1); Button closeButton = buildCloseButton(); buttonLayout.addComponent(closeButton); buttonLayout.setComponentAlignment(closeButton, Alignment.BOTTOM_RIGHT); textField.setValue(value); textField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { if (displayBox != null) { updateTextField((String) displayBox.getValue(), value); } else { textField.setValue(value); } } }); }
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 a 2 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.DbImportDialog.java
License:Open Source License
protected void createImportLayout() { importLayout = new VerticalLayout(); importLayout.setSizeFull();/* w ww. j a va 2 s . c o m*/ 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.jumpmind.vaadin.ui.sqlexplorer.TableSelectionLayout.java
License:Open Source License
protected void createTableSelectionLayout(String titleKey) { this.addComponent(new Label(titleKey)); HorizontalLayout schemaChooserLayout = new HorizontalLayout(); schemaChooserLayout.setWidth(100, Unit.PERCENTAGE); schemaChooserLayout.setSpacing(true); this.addComponent(schemaChooserLayout); catalogSelect = new ComboBox("Catalog"); catalogSelect.setImmediate(true);//w w w . j a va 2 s . c om CommonUiUtils.addItems(getCatalogs(), catalogSelect); schemaChooserLayout.addComponent(catalogSelect); if (selectedTablesSet.iterator().hasNext()) { catalogSelect.select(selectedTablesSet.iterator().next().getCatalog()); } else { catalogSelect.select(databasePlatform.getDefaultCatalog()); } schemaSelect = new ComboBox("Schema"); schemaSelect.setImmediate(true); CommonUiUtils.addItems(getSchemas(), schemaSelect); schemaChooserLayout.addComponent(schemaSelect); if (selectedTablesSet.iterator().hasNext()) { schemaSelect.select(selectedTablesSet.iterator().next().getSchema()); } else { schemaSelect.select(databasePlatform.getDefaultSchema()); } Label spacer = new Label(); schemaChooserLayout.addComponent(spacer); schemaChooserLayout.setExpandRatio(spacer, 1); filterField = new TextField(); filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); filterField.setIcon(FontAwesome.SEARCH); filterField.setInputPrompt("Filter Tables"); filterField.setNullRepresentation(""); filterField.setImmediate(true); filterField.setTextChangeEventMode(TextChangeEventMode.LAZY); filterField.setTextChangeTimeout(200); filterField.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = 1L; public void textChange(TextChangeEvent event) { filterField.setValue(event.getText()); refreshTableOfTables(); } }); schemaChooserLayout.addComponent(filterField); schemaChooserLayout.setComponentAlignment(filterField, Alignment.BOTTOM_RIGHT); listOfTablesTable = CommonUiUtils.createTable(); listOfTablesTable.setImmediate(true); listOfTablesTable.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { CheckBox checkBox = (CheckBox) event.getItem().getItemProperty("selected").getValue(); checkBox.setValue(!checkBox.getValue()); } }); listOfTablesTable.addContainerProperty("selected", CheckBox.class, null); listOfTablesTable.setColumnWidth("selected", UiConstants.TABLE_SELECTED_COLUMN_WIDTH); listOfTablesTable.setColumnHeader("selected", ""); listOfTablesTable.addContainerProperty("table", String.class, null); listOfTablesTable.setColumnHeader("table", ""); listOfTablesTable.setSizeFull(); this.addComponent(listOfTablesTable); this.setExpandRatio(listOfTablesTable, 1); schemaSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { refreshTableOfTables(); } }); catalogSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { refreshTableOfTables(); } }); refreshTableOfTables(); }
From source file:org.milleni.dunning.ui.prcstart.CompleteFinansTaskPanel.java
License:Apache License
protected void initPageTitle() { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, UNITS_PERCENTAGE); layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); layout.setSpacing(true);/*from w w w.j a v a2 s .c o m*/ layout.setMargin(false, false, true, false); addDetailComponent(layout); Embedded databaseImage = new Embedded(null, Images.DATABASE_50); layout.addComponent(databaseImage); Label groupName = new Label("Finans Task Tamamla"); groupName.setSizeUndefined(); groupName.addStyleName(Reindeer.LABEL_H2); layout.addComponent(groupName); layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT); layout.setExpandRatio(groupName, 1.0f); yasalOrTakipCombo = new ComboBox("Yasal Surec Durumu"); yasalOrTakipCombo.addItem(yasalTakip); yasalOrTakipCombo.addItem(takipDisiBirak); }
From source file:org.opencms.ui.dataview.CmsDataViewPanel.java
License:Open Source License
/** * Changes the displayed filters to a new set.<p> * * @param newFilters the new filters/*from w w w . jav a2 s . c o m*/ */ public void updateFilters(List<CmsDataViewFilter> newFilters) { if (newFilters.isEmpty()) { m_filterContainer.setVisible(false); } if (m_filters.equals(newFilters)) { return; } m_filterContainer.removeAllComponents(); m_filters = newFilters; m_filterMap.clear(); for (CmsDataViewFilter filter : newFilters) { m_filterMap.put(filter.getId(), filter); final CmsDataViewFilter finalFilter = filter; ComboBox select = new ComboBox(filter.getNiceName()); select.setWidth("175px"); select.setNullSelectionAllowed(false); select.setPageLength(0); Map<String, String> options = filter.getOptions(); for (Map.Entry<String, String> entry : options.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); select.addItem(key); select.setItemCaption(key, value); } select.setValue(filter.getValue()); if (filter.getHelpText() != null) { select.setDescription(filter.getHelpText()); } select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { String newValue = (String) (event.getProperty().getValue()); updateFilter(finalFilter.getId(), newValue); } }); m_filterContainer.addComponent(select); } }
From source file:org.opennms.features.topology.app.internal.operations.AddVertexToGroupOperation.java
License:Open Source License
@Override public void execute(List<VertexRef> targets, final OperationContext operationContext) { if (targets == null || targets.isEmpty()) { return;/*from w ww. j a va 2s . com*/ } final Logger log = LoggerFactory.getLogger(this.getClass()); final GraphContainer graphContainer = operationContext.getGraphContainer(); final Collection<VertexRef> vertices = removeChildren(operationContext.getGraphContainer(), determineTargets(targets.get(0), operationContext.getGraphContainer().getSelectionManager())); final Collection<Vertex> vertexIds = graphContainer.getBaseTopology().getRootGroup(); final Collection<Vertex> groupIds = findGroups(graphContainer.getBaseTopology(), vertexIds); final UI window = operationContext.getMainWindow(); final Window groupNamePrompt = new GroupWindow("Add This Item To a Group", "300px", "210px"); // Define the fields for the form final PropertysetItem item = new PropertysetItem(); item.addItemProperty("Group", new ObjectProperty<String>(null, String.class)); // field factory for the form FormFieldFactory fieldFactory = new FormFieldFactory() { private static final long serialVersionUID = 2963683658636386720L; public Field<?> createField(Item item, Object propertyId, Component uiContext) { // Identify the fields by their Property ID. String pid = (String) propertyId; if ("Group".equals(pid)) { final ComboBox select = new ComboBox("Group"); for (Vertex childId : groupIds) { log.debug("Adding child: {}, {}", childId.getId(), childId.getLabel()); select.addItem(childId.getId()); select.setItemCaption(childId.getId(), childId.getLabel()); } select.setNewItemsAllowed(false); select.setNullSelectionAllowed(false); select.setRequired(true); select.setRequiredError("You must select a group"); select.addValidator(new Validator() { private static final long serialVersionUID = -2466240291882827117L; @Override public void validate(Object value) throws InvalidValueException { if (isValid(value)) return; throw new InvalidValueException(String.format("You cannot add group '%s' to itself.", select.getItemCaption(value))); }; /** * Ensures that if only one element is selected that this element cannot be added to itself. * If there are more than one elements selected, we assume as valid. */ private boolean isValid(Object value) { if (vertices.size() > 1) return true; // more than 1 -> assume valid final String groupId = (String) select.getValue(); // only one, check if we want to assign to ourself for (VertexRef eachVertex : vertices) { if (groupId.equals(eachVertex.getId())) { return false; } } return true; } }); return select; } return null; // Invalid field (property) name. } }; // create the form final Form promptForm = new Form() { private static final long serialVersionUID = 8310646938173207767L; @Override public void commit() throws SourceException, InvalidValueException { super.commit(); String groupId = (String) getField("Group").getValue(); Vertex group = graphContainer.getBaseTopology() .getVertex(graphContainer.getBaseTopology().getVertexNamespace(), groupId); log.debug("Field value: {}", group.getId()); for (VertexRef eachChild : vertices) { if (eachChild == group) { log.warn("Ignoring group:(id={},label={}), because otherwise we should add it to itself.", eachChild.getId(), eachChild.getLabel()); continue; } log.debug("Adding item:(id={},label={}) to group:(id={},label={})", eachChild.getId(), eachChild.getLabel(), group.getId(), group.getLabel()); graphContainer.getBaseTopology().setParent(eachChild, group); } graphContainer.getBaseTopology().save(); graphContainer.redoLayout(); } }; // Buffer changes to the datasource promptForm.setBuffered(true); // You must set the FormFieldFactory before you set the data source promptForm.setFormFieldFactory(fieldFactory); promptForm.setItemDataSource(item); promptForm.setDescription("Please select a group."); // Footer Button ok = new Button("OK"); ok.addClickListener(new ClickListener() { private static final long serialVersionUID = 7388841001913090428L; @Override public void buttonClick(ClickEvent event) { try { promptForm.validate(); promptForm.commit(); window.removeWindow(groupNamePrompt); // Close the prompt window } catch (InvalidValueException exception) { promptForm.setComponentError( new UserError(exception.getMessage(), ContentMode.TEXT, ErrorLevel.WARNING)); } } }); Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 8780989646038333243L; @Override public void buttonClick(ClickEvent event) { window.removeWindow(groupNamePrompt); // Close the prompt window } }); promptForm.setFooter(new HorizontalLayout()); promptForm.getFooter().addComponent(ok); promptForm.getFooter().addComponent(cancel); groupNamePrompt.setContent(promptForm); window.addWindow(groupNamePrompt); }
From source file:org.opennms.features.topology.app.internal.operations.RemoveVertexFromGroupOperation.java
License:Open Source License
@Override public void execute(final List<VertexRef> targets, final OperationContext operationContext) { if (targets == null || targets.isEmpty() || targets.size() != 1) { return;/*from w w w . j a v a 2 s . c o m*/ } final Logger log = LoggerFactory.getLogger(this.getClass()); final GraphContainer graphContainer = operationContext.getGraphContainer(); final VertexRef currentGroup = targets.get(0); final Collection<? extends Vertex> children = graphContainer.getBaseTopology().getChildren(currentGroup); for (Vertex child : children) { log.debug("Child ID: {}", child.getId()); } final UI window = operationContext.getMainWindow(); final Window groupNamePrompt = new Window("Remove item from this Group"); groupNamePrompt.setModal(true); groupNamePrompt.setResizable(false); groupNamePrompt.setHeight("180px"); groupNamePrompt.setWidth("300px"); // Define the fields for the form final PropertysetItem item = new PropertysetItem(); item.addItemProperty("Item", new ObjectProperty<String>(null, String.class)); FormFieldFactory fieldFactory = new FormFieldFactory() { private static final long serialVersionUID = 243277720538924081L; @Override public Field<?> createField(Item item, Object propertyId, Component uiContext) { // Identify the fields by their Property ID. String pid = (String) propertyId; if ("Item".equals(pid)) { ComboBox select = new ComboBox("Item"); for (Vertex child : children) { log.debug("Adding child: {}, {}", child.getId(), child.getLabel()); select.addItem(child.getId()); select.setItemCaption(child.getId(), child.getLabel()); } select.setNewItemsAllowed(false); select.setNullSelectionAllowed(false); return select; } return null; // Invalid field (property) name. } }; // TODO Add validator for name value final Form promptForm = new Form() { private static final long serialVersionUID = 2067414790743946906L; @Override public void commit() { super.commit(); String childId = (String) getField("Item").getValue(); log.debug("Field value: {}", childId); LoggerFactory.getLogger(this.getClass()).debug("Removing item from group: {}", childId); Vertex grandParent = graphContainer.getBaseTopology().getParent(currentGroup); GraphProvider topologyProvider = graphContainer.getBaseTopology(); // Relink the child to the grandparent group (or null if it is null) topologyProvider.setParent(graphContainer.getBaseTopology() .getVertex(graphContainer.getBaseTopology().getVertexNamespace(), childId), grandParent); // Save the topology topologyProvider.save(); graphContainer.redoLayout(); } }; // Buffer changes to the datasource promptForm.setBuffered(true); // You must set the FormFieldFactory before you set the data source promptForm.setFormFieldFactory(fieldFactory); promptForm.setItemDataSource(item); Button ok = new Button("OK"); ok.addClickListener(new ClickListener() { private static final long serialVersionUID = 7388841001913090428L; @Override public void buttonClick(ClickEvent event) { promptForm.commit(); // Close the prompt window window.removeWindow(groupNamePrompt); } }); promptForm.getFooter().addComponent(ok); Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 8780989646038333243L; @Override public void buttonClick(ClickEvent event) { // Close the prompt window window.removeWindow(groupNamePrompt); } }); promptForm.getFooter().addComponent(cancel); groupNamePrompt.setContent(promptForm); window.addWindow(groupNamePrompt); }
From source file:org.opennms.features.vaadin.datacollection.GroupFieldFactory.java
License:Open Source License
public Field createField(Item item, Object propertyId, Component uiContext) { if ("name".equals(propertyId)) { final TextField f = new TextField("Group Name"); f.setRequired(true);/*from w ww.ja va2s . c o m*/ f.setWidth("100%"); return f; } if ("ifType".equals(propertyId)) { final ComboBox f = new ComboBox("ifType Filter"); f.addItem("ignore"); f.addItem("all"); f.setNullSelectionAllowed(false); f.setRequired(true); f.setImmediate(true); f.setNewItemsAllowed(true); f.setNewItemHandler(new NewItemHandler() { public void addNewItem(String newItemCaption) { if (!f.containsId(newItemCaption)) { f.addItem(newItemCaption); f.setValue(newItemCaption); } } }); return f; } if ("mibObjCollection".equals(propertyId)) { final MibObjField f = new MibObjField(resourceTypes); f.setCaption("MIB Objects"); f.setRequired(true); f.setImmediate(true); f.setWidth("100%"); return f; } return null; }
From source file:org.opennms.features.vaadin.datacollection.IncludeCollectionWindow.java
License:Open Source License
/** * Instantiates a new include collection window. * //w w w .j a v a 2s . c om * @param dataCollectionConfigDao the data collection configuration DAO * @param container the source list of elements * @param wrapper the current selected value */ public IncludeCollectionWindow(final DataCollectionConfigDao dataCollectionConfigDao, final OnmsBeanContainer<IncludeCollectionWrapper> container, final IncludeCollectionWrapper wrapper) { setCaption("Include SystemDef/DataCollectionGroup"); setModal(true); setWidth("400px"); setHeight("2000px"); setResizable(false); setClosable(false); addStyleName("dialog"); final ComboBox valueField = new ComboBox("Value"); valueField.setEnabled(false); valueField.setRequired(true); valueField.setImmediate(true); valueField.setNewItemsAllowed(false); valueField.setNullSelectionAllowed(false); final ComboBox typeField = new ComboBox("Type"); typeField.setRequired(true); typeField.setImmediate(true); typeField.setNewItemsAllowed(false); typeField.setNullSelectionAllowed(false); typeField.addItem(IncludeCollectionWrapper.DC_GROUP); typeField.addItem(IncludeCollectionWrapper.SYSTEM_DEF); typeField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String selected = (String) typeField.getValue(); if (selected == null) { return; } // Get available fields. // FIXME If a new dcGroup is added, DataCollectionConfigDao is not able to reach it. List<String> values = selected.equals(IncludeCollectionWrapper.SYSTEM_DEF) ? dataCollectionConfigDao.getAvailableSystemDefs() : dataCollectionConfigDao.getAvailableDataCollectionGroups(); // Remove already selected for (IncludeCollectionWrapper obj : container.getOnmsBeans()) { if (obj.getType().equals(selected)) { values.remove(obj.getValue()); } } // Updating combo-box valueField.removeAllItems(); for (String v : values) { valueField.addItem(v); } if (wrapper.getValue() != null) { valueField.addItem(wrapper.getValue()); } valueField.setEnabled(valueField.getItemIds().size() > 1); } }); formLayout.setImmediate(true); formLayout.setWidth("100%"); formLayout.addComponent(typeField); formLayout.addComponent(valueField); formEditor.bind(typeField, "type"); formEditor.bind(valueField, "value"); formEditor.setItemDataSource(wrapper); final HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addComponent(okButton); toolbar.addComponent(cancelButton); final VerticalLayout layout = new VerticalLayout(); layout.addComponent(formLayout); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT); layout.setMargin(true); setContent(layout); }