/** * Instantiates a new persist selector strategy field. */ public PersistSelectorStrategyField() { combo.setCaption("Class Name"); combo.addItem("org.opennms.netmgt.collectd.PersistAllSelectorStrategy"); // To avoid requires opennms-services combo.addItem("org.opennms.netmgt.collectd.PersistRegexSelectorStrategy"); // To avoid requires opennms-services combo.setNullSelectionAllowed(false); combo.setRequired(true); combo.setImmediate(true); combo.setNewItemsAllowed(true); combo.setNewItemHandler(new NewItemHandler() { public void addNewItem(String newItemCaption) { if (!combo.containsId(newItemCaption)) { combo.addItem(newItemCaption); combo.setValue(newItemCaption); } } }); table.setCaption("Parameters"); table.setContainerDataSource(container); table.setStyleName(Runo.TABLE_SMALL); table.setVisibleColumns(new Object[]{"key", "value"}); table.setColumnHeader("key", "Parameter Name"); table.setColumnHeader("value", "Parameter Value"); table.setColumnExpandRatio("value", 1); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("125px"); table.setWidth("100%"); add = new Button("Add", (Button.ClickListener) this); delete = new Button("Delete", (Button.ClickListener) this); toolbar.addComponent(add); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable()); VerticalLayout layout = new VerticalLayout(); layout.addComponent(combo); layout.addComponent(table); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); setCompositionRoot(layout); }
/** * Instantiates a new storage strategy field. */ public StorageStrategyField() { combo.setCaption("Class Name"); combo.addItem(IndexStorageStrategy.class.getName()); combo.addItem(SiblingColumnStorageStrategy.class.getName()); combo.setNullSelectionAllowed(false); combo.setRequired(true); combo.setNewItemsAllowed(true); combo.setNewItemHandler(new NewItemHandler() { public void addNewItem(String newItemCaption) { if (!combo.containsId(newItemCaption)) { combo.addItem(newItemCaption); combo.setValue(newItemCaption); } } }); table.setCaption("Parameters"); table.setContainerDataSource(container); table.setStyleName(Runo.TABLE_SMALL); table.setVisibleColumns(new Object[]{"key", "value"}); table.setColumnHeader("key", "Parameter Name"); table.setColumnHeader("value", "Parameter Value"); table.setColumnExpandRatio("value", 1); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("125px"); table.setWidth("100%"); add = new Button("Add", (Button.ClickListener) this); delete = new Button("Delete", (Button.ClickListener) this); toolbar.addComponent(add); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable()); VerticalLayout layout = new VerticalLayout(); layout.addComponent(combo); layout.addComponent(table); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); setWriteThrough(false); setCompositionRoot(layout); }
private TargetLine insertTargetLine(final int row) { final List<EmailAddressType> targetTypes = getTargetTypes(); EmailForm.this.grid.insertRow(row); this.grid.setCursorY(row); this.grid.setCursorX(0); final TargetLine line = new TargetLine(); line.row = row; line.targetTypeCombo = new ComboBox(null, targetTypes); line.targetTypeCombo.setWidth("100"); line.targetTypeCombo.select(targetTypes.get(0)); this.grid.addComponent(line.targetTypeCombo); line.targetAddress = new ComboBox(null); this.grid.addComponent(line.targetAddress); line.targetAddress.setImmediate(true); line.targetAddress.setTextInputAllowed(true); line.targetAddress.setInputPrompt("Enter Contact Name or email address"); line.targetAddress.setWidth("100%"); line.targetAddress.addValidator(new EmailValidator("Please enter a valid email address.")); line.targetAddress.setContainerDataSource(getValidEmailContacts()); line.targetAddress.setItemCaptionPropertyId("namedemail"); line.targetAddress.setNewItemsAllowed(true); line.targetAddress.setNewItemHandler(new NewItemHandler() { private static final long serialVersionUID = 1L; @Override public void addNewItem(final String newItemCaption) { final IndexedContainer container = (IndexedContainer) line.targetAddress.getContainerDataSource(); final Item item = addItem(container, "", newItemCaption); if (item != null) { line.targetAddress.addItem(item.getItemProperty("id").getValue()); line.targetAddress.setValue(item.getItemProperty("id").getValue()); } } }); line.minusButton = new Button("-"); line.minusButton.setDescription("Click to remove this email address line."); line.minusButton.setData(line); line.minusButton.setStyleName(Reindeer.BUTTON_SMALL); this.grid.addComponent(line.minusButton); final Action1<ClickEvent> minusClickAction = new MinusClickAction(); line.buttonSubscription = ButtonEventSource.fromActionOf(line.minusButton).subscribe(minusClickAction); this.lines.add(line); return line; }
/** * Adds an handler for new items * @param newItemHandler New items handler */ public void setNewItemHandler(NewItemHandler newItemHandler) { getInternalField().setNewItemHandler(newItemHandler); }
/** * Gets the handler for new items * @return the new items handler */ public NewItemHandler getNewItemHandler() { return getInternalField().getNewItemHandler(); }