List of usage examples for com.vaadin.ui TextField setValue
@Override public void setValue(String value)
From source file:org.lucidj.newview.NewView.java
License:Apache License
private boolean component_fill_artifact_options(FormLayout form) { if (test_debug_artifact_options) { TextField email = new TextField("Email"); email.setValue("viking@surface.mars"); email.setWidth("50%"); email.setRequired(true);/*ww w . j a v a 2 s . com*/ form.addComponent(email); TextField location = new TextField("Location"); location.setValue("Mars, Solar System"); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); } return (test_debug_artifact_options); }
From source file:org.lunifera.examples.runtime.web.vaadin.databinding.DatabindingDemoUI.java
License:Open Source License
private void row4(GridLayout layout) { Slider slider = new Slider("width"); slider.setImmediate(true);/*ww w . j a va 2s . c o m*/ slider.setBuffered(false); slider.setWidth("150px"); layout.addComponent(slider, 0, 3); TextField heightInput = new TextField("height"); heightInput.setImmediate(true); heightInput.setBuffered(false); layout.addComponent(heightInput, 1, 3); slider.setMax(200); slider.setValue(20d); heightInput.setValue("10px"); TextField input2 = new TextField("sizeable"); layout.addComponent(input2, 2, 3); dbc.bindValue(VaadinObservables.observeWidth(input2), VaadinObservables.observeValue(slider), null, new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE).setConverter(new IConverter() { @Override public Object getToType() { return String.class; } @Override public Object getFromType() { return Object.class; } @Override public Object convert(Object fromObject) { double value = (Double) fromObject; return String.format("%s%s", Double.toString(value), Unit.PIXELS.getSymbol()); } })); dbc.bindValue(VaadinObservables.observeHeight(input2), VaadinObservables.observeValue(heightInput)); }
From source file:org.mpavel.app.views.LoginView.java
License:Apache License
public LoginView(final String fragmentAndParameters) { setCaption("Login"); VerticalLayout layout = new VerticalLayout(); final TextField username = new TextField("Username"); layout.addComponent(username);//ww w .j a v a 2 s . com final PasswordField password = new PasswordField("Password"); layout.addComponent(password); final CheckBox rememberMe = new CheckBox("Remember Me"); layout.addComponent(rememberMe); username.focus(); // TODO: Remove these two lines before production release username.setValue("admin"); password.setValue("admin"); if (ApplicationSecurity.isRemembered()) { username.setValue(ApplicationSecurity.whoIsRemembered()); rememberMe.setValue(ApplicationSecurity.isRemembered()); password.focus(); } @SuppressWarnings("serial") final Button login = new Button("Login", new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Navigator navigator = UI.getCurrent().getNavigator(); if (ApplicationSecurity.login(username.getValue(), password.getValue(), rememberMe.getValue())) { final String location = (fragmentAndParameters == null) ? ApplicationView.NAME : fragmentAndParameters; navigator.navigateTo(location); } else { navigator.navigateTo(LoginView.NAME); } } }); layout.addComponent(login); setContent(layout); }
From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java
License:Apache License
private Component createTaskSummary(UserTask task) { // TextField name = new TextField("Name"); // name.setValue(task.getName()); // name.setReadOnly(true); // name.setWidth("100%"); TextField priority = new TextField("Priority"); priority.setValue(Integer.toString(task.getPriority())); priority.setReadOnly(true);//from w ww . j a va 2s . com TextField status = new TextField("Status"); status.setValue(task.getStatus().getDescription()); status.setReadOnly(true); TextArea description = new TextArea("Description"); description.setSizeFull(); description.setValue(task.getDescription()); description.setReadOnly(true); description.setRows(3); ComponentContainer buttons = createSummaryButtons(task); VerticalLayout secondColumnFields = new VerticalLayout(); secondColumnFields.setMargin(false); secondColumnFields.setSizeFull(); secondColumnFields.addComponent(priority); secondColumnFields.addComponent(status); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSizeFull(); fieldsLayout.setMargin(false); fieldsLayout.setSpacing(false); fieldsLayout.addComponent(description); fieldsLayout.addComponent(secondColumnFields); fieldsLayout.setExpandRatio(description, 4.0f); fieldsLayout.setExpandRatio(secondColumnFields, 1.0f); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(false); mainLayout.setSizeFull(); mainLayout.addComponent(fieldsLayout); mainLayout.addComponent(buttons); mainLayout.setComponentAlignment(buttons, Alignment.TOP_LEFT); mainLayout.setExpandRatio(fieldsLayout, 1.0f); Panel panel = new Panel("Summary"); panel.setStyleName("background-transparent"); panel.setContent(mainLayout); return panel; }
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.LicenceDescriptorPanel.java
License:Apache License
/** * updates the metadata fields from the licence string * if unable to read the metadata then returns false * @param licenceStr/*from www . j av a 2 s.c om*/ * @return true if metadata read, false if not */ public boolean updateMetadata(String licenceStr) { boolean success = false; if (licenceStr != null) { LicenceMetadata licenceMetadata = null; try { licenceMetadata = Licence.getUnverifiedMetadata(licenceStr); } catch (Exception e) { // can't decode string licenceMetadata will be null } if (licenceMetadata == null) { //create empty licenceMetadata panel licenceMetadata = new LicenceMetadata(); licenceMetadata.setStartDate(null); licenceMetadata.setProductId("cannot decode licence string"); success = false; } else success = true; productIdTextField.setReadOnly(false); productIdTextField .setValue((licenceMetadata.getProductId() == null) ? "" : licenceMetadata.getProductId()); productIdTextField.setReadOnly(noUpdate); featureRepositoryTextField.setReadOnly(false); featureRepositoryTextField.setValue( (licenceMetadata.getFeatureRepository() == null) ? "" : licenceMetadata.getFeatureRepository()); featureRepositoryTextField.setReadOnly(noUpdate); Format formatter = new SimpleDateFormat("yyyy-MM-dd"); startDateTextField.setReadOnly(false); startDateTextField.setValue((licenceMetadata.getStartDate() == null) ? "" : formatter.format(licenceMetadata.getStartDate())); startDateTextField.setReadOnly(noUpdate); expiryDateTextField.setReadOnly(false); expiryDateTextField.setValue((licenceMetadata.getExpiryDate() == null) ? "" : formatter.format(licenceMetadata.getExpiryDate())); expiryDateTextField.setReadOnly(noUpdate); durationTextField.setReadOnly(false); durationTextField .setValue((licenceMetadata.getDuration() == null) ? "" : licenceMetadata.getDuration()); durationTextField.setReadOnly(noUpdate); licenseeTextField.setReadOnly(false); licenseeTextField .setValue((licenceMetadata.getLicensee() == null) ? "" : licenceMetadata.getLicensee()); licenseeTextField.setReadOnly(noUpdate); licensorTextField.setReadOnly(false); licensorTextField .setValue((licenceMetadata.getLicensor() == null) ? "" : licenceMetadata.getLicensor()); licensorTextField.setReadOnly(noUpdate); maxSizeSystemIdsTextField.setReadOnly(false); maxSizeSystemIdsTextField.setValue( (licenceMetadata.getMaxSizeSystemIds() == null) ? "" : licenceMetadata.getMaxSizeSystemIds()); maxSizeSystemIdsTextField.setReadOnly(noUpdate); // display systemIds if present systemIdsVerticalLayout.removeAllComponents(); // add error messages if system ids defined when not expected Label l1 = new Label(); l1.setContentMode(ContentMode.HTML); Integer licenceMetadataMaxSizeSystemIds = null; try { licenceMetadataMaxSizeSystemIds = Integer.parseInt(licenceMetadata.getMaxSizeSystemIds()); } catch (Exception e) { } if (licenceMetadataMaxSizeSystemIds == null || licenceMetadataMaxSizeSystemIds == 0) { // if maxSizeSystemIds=0 check if systemId's list has entries (an error) if (licenceMetadata.getSystemIds() == null || licenceMetadata.getSystemIds().isEmpty()) { l1.setValue("<div style=\"color: green;\">" + "All SystemId's Accepted" + "</div>"); } else { l1.setValue("<div style=\"color: red;\">" + "Licence Error: MaxSizeSystemIds=0 but " + licenceMetadata.getSystemIds().size() + " systemId's are defined" + "</div>"); } systemIdsVerticalLayout.addComponent(l1); } else if (licenceMetadata.getSystemIds() == null || licenceMetadata.getSystemIds().isEmpty()) { l1.setValue("<div style=\"color: green;\">" + "No SystemId's Defined" + "</div>"); systemIdsVerticalLayout.addComponent(l1); } else if (licenceMetadata.getSystemIds().size() > licenceMetadataMaxSizeSystemIds) { l1.setValue("<div style=\"color: red;\">Licence Error: more system id's defined in licence (" + licenceMetadata.getSystemIds().size() + ") than allowed in maxSizeSystemIds=" + licenceMetadata.getMaxSizeSystemIds() + "</div>"); systemIdsVerticalLayout.addComponent(l1); } // add system id strings if present if (licenceMetadata.getSystemIds() != null) { for (String systemId : licenceMetadata.getSystemIds()) { Label systemIdField = new Label(); systemIdField.setImmediate(true); systemIdField.setWidth("400px"); systemIdField.setHeight("-1px"); systemIdField.setValue(systemId); systemIdsVerticalLayout.addComponent(systemIdField); } } // display licence options if present licenceOptionsVerticalLayout.removeAllComponents(); if (licenceMetadata.getOptions() == null || licenceMetadata.getOptions().isEmpty()) { Label l = new Label("No Licence Options Defined"); licenceOptionsVerticalLayout.addComponent(l); } else { for (OptionMetadata option : licenceMetadata.getOptions()) { TextField optionField = new TextField(); optionField.setImmediate(true); optionField.setWidth("400px"); optionField.setHeight("-1px"); optionField.setCaption(option.getName()); optionField.setValue(option.getValue()); optionField.setDescription(option.getDescription()); optionField.setReadOnly(noUpdate); licenceOptionsVerticalLayout.addComponent(optionField); } } mainLayout.markAsDirty(); } return success; }
From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java
License:Open Source License
/** * Creates the west area layout including the * accordion and tree views./* w w w. jav a2 s .c o m*/ * * @return */ @SuppressWarnings("serial") private Layout createWestLayout() { m_tree = createTree(); final TextField filterField = new TextField("Filter"); filterField.setTextChangeTimeout(200); final Button filterBtn = new Button("Filter"); filterBtn.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { GCFilterableContainer container = m_tree.getContainerDataSource(); container.removeAllContainerFilters(); String filterString = (String) filterField.getValue(); if (!filterString.equals("") && filterBtn.getCaption().toLowerCase().equals("filter")) { container.addContainerFilter(LABEL_PROPERTY, (String) filterField.getValue(), true, false); filterBtn.setCaption("Clear"); } else { filterField.setValue(""); filterBtn.setCaption("Filter"); } } }); HorizontalLayout filterArea = new HorizontalLayout(); filterArea.addComponent(filterField); filterArea.addComponent(filterBtn); filterArea.setComponentAlignment(filterBtn, Alignment.BOTTOM_CENTER); m_treeAccordion = new Accordion(); m_treeAccordion.addTab(m_tree, m_tree.getTitle()); m_treeAccordion.setWidth("100%"); m_treeAccordion.setHeight("100%"); AbsoluteLayout absLayout = new AbsoluteLayout(); absLayout.setWidth("100%"); absLayout.setHeight("100%"); absLayout.addComponent(filterArea, "top: 25px; left: 15px;"); absLayout.addComponent(m_treeAccordion, "top: 75px; left: 15px; right: 15px; bottom:25px;"); return absLayout; }
From source file:org.opennms.features.vaadin.dashboard.config.ui.DashletSpecEditor.java
License:Open Source License
/** * Constructor for the DashletSpecEditor. * * @param wallboardEditor the {@link WallboardEditor} wallboard editor this editor belongs to * @param dashletSelector the {@link DashletSelector} used to query available {@link DashletFactory} instances * @param dashletSpec the associated {@link DashletSpec} instance *//* ww w . ja va 2s .c o m*/ public DashletSpecEditor(WallboardEditor wallboardEditor, DashletSelector dashletSelector, DashletSpec dashletSpec) { /** * Setting the member fields */ this.m_wallboardEditor = wallboardEditor; this.m_dashletSpec = dashletSpec; this.m_dashletSelector = dashletSelector; /** * Setting defaults */ DashletFactory dashletFactory = dashletSelector.getDashletFactoryForName(dashletSpec.getDashletName()); final Map<String, String> requiredParameters = dashletFactory.getRequiredParameters(); for (Map.Entry<String, String> entry : requiredParameters.entrySet()) { if (!dashletSpec.getParameters().containsKey(entry.getKey())) { dashletSpec.getParameters().put(entry.getKey(), requiredParameters.get(entry.getKey())); } } /** * Setting up this component with size and layout */ setWidth(100.0f, Unit.PERCENTAGE); GridLayout gridLayout = new GridLayout(); gridLayout.setColumns(6); gridLayout.setRows(1); gridLayout.setMargin(true); /** * Priority field setup, layout and adding listener and validator */ final TextField priorityField = new TextField(); priorityField.setValue(String.valueOf(dashletSpec.getPriority())); priorityField.setImmediate(true); priorityField.setCaption("Priority"); priorityField.setDescription("Priority of this dashlet"); priorityField.addValidator(new AbstractStringValidator("Only numbers allowed here") { @Override protected boolean isValidValue(String s) { try { Integer.parseInt(s); } catch (NumberFormatException numberFormatException) { return false; } return true; } }); priorityField.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (priorityField.isValid()) { m_dashletSpec.setPriority(Integer.valueOf((String) valueChangeEvent.getProperty().getValue())); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Priority"); } } }); /** * Boost priority field setup, layout and adding listener and validator */ final TextField boostPriorityField = new TextField(); boostPriorityField.setValue(String.valueOf(dashletSpec.getBoostPriority())); boostPriorityField.setImmediate(true); boostPriorityField.setCaption("Boost-Priority"); boostPriorityField.setDescription("Boost priority of this dashlet"); boostPriorityField.addValidator(new AbstractStringValidator("Only numbers allowed here") { @Override protected boolean isValidValue(String s) { try { Integer.parseInt(s); } catch (NumberFormatException numberFormatException) { return false; } return true; } }); boostPriorityField.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (boostPriorityField.isValid()) { m_dashletSpec .setBoostPriority(Integer.valueOf((String) valueChangeEvent.getProperty().getValue())); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Priority"); } } }); /** * Duration field setup, layout and adding listener and validator */ final TextField durationField = new TextField(); durationField.setValue(String.valueOf(dashletSpec.getDuration())); durationField.setImmediate(true); durationField.setCaption("Duration"); durationField.setDescription("Duration for this dashlet"); durationField.addValidator(new AbstractStringValidator("Only numbers allowed here") { @Override protected boolean isValidValue(String s) { try { Integer.parseInt(s); } catch (NumberFormatException numberFormatException) { return false; } return true; } }); durationField.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (durationField.isValid()) { m_dashletSpec.setDuration(Integer.valueOf((String) valueChangeEvent.getProperty().getValue())); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Duration"); } } }); /** * Boost duration field setup, layout and adding listener and validator */ final TextField boostDurationField = new TextField(); boostDurationField.setValue(String.valueOf(dashletSpec.getBoostDuration())); boostDurationField.setImmediate(true); boostDurationField.setCaption("Boost-Duration"); boostDurationField.setDescription("Boost duration for this dashlet"); boostDurationField.addValidator(new AbstractStringValidator("Only numbers allowed here") { @Override protected boolean isValidValue(String s) { try { Integer.parseInt(s); } catch (NumberFormatException numberFormatException) { return false; } return true; } }); boostDurationField.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (boostDurationField.isValid()) { m_dashletSpec .setBoostDuration(Integer.valueOf((String) valueChangeEvent.getProperty().getValue())); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Duration"); } } }); boolean boostable = m_dashletSelector.getDashletFactoryForName(m_dashletSpec.getDashletName()) .isBoostable(); boostPriorityField.setEnabled(boostable); boostDurationField.setEnabled(boostable); /** * Setting up the dashlet selection */ m_dashletSelect = new NativeSelect(); m_dashletSelect.setCaption("Dashlet"); updateDashletSelection(dashletSelector.getDashletFactoryList()); m_dashletSelect.setImmediate(true); m_dashletSelect.setNewItemsAllowed(false); m_dashletSelect.setNullSelectionItemId("Undefined"); m_dashletSelect.setNullSelectionAllowed(false); m_dashletSelect.select(dashletSpec.getDashletName()); m_dashletSelect.setDescription("Dashlet selection"); m_dashletSelect.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (m_savingDisabled) { return; } if (valueChangeEvent.getProperty().getValue() == null) { m_dashletSpec.setDashletName("Undefined"); } else { m_dashletSpec.setDashletName(valueChangeEvent.getProperty().getValue().toString()); m_dashletSelect.removeItem("Undefined"); } m_dashletSpec.getParameters().clear(); Map<String, String> requiredParameters = m_dashletSelector .getDashletFactoryForName(m_dashletSpec.getDashletName()).getRequiredParameters(); for (Map.Entry<String, String> entry : requiredParameters.entrySet()) { m_dashletSpec.getParameters().put(entry.getKey(), entry.getValue()); } m_propertiesButton.setEnabled(requiredParameters.size() > 0); boolean boostable = m_dashletSelector.getDashletFactoryForName(m_dashletSpec.getDashletName()) .isBoostable(); boostPriorityField.setEnabled(boostable); boostDurationField.setEnabled(boostable); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Dashlet"); } }); m_titleField = new TextField(); m_titleField.setValue(dashletSpec.getTitle()); m_titleField.setImmediate(true); m_titleField.setCaption("Title"); m_titleField.setDescription("Title for this dashlet instance"); m_titleField.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent valueChangeEvent) { m_dashletSpec.setTitle((String) valueChangeEvent.getProperty().getValue()); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Title"); } }); FormLayout f1 = new FormLayout(); f1.addComponent(m_dashletSelect); f1.addComponent(m_titleField); /** * Adding the required input fields and buttons to several {@link FormLayout} instances for better layout. */ FormLayout f2 = new FormLayout(); f2.addComponent(priorityField); f2.addComponent(durationField); FormLayout f3 = new FormLayout(); f3.addComponent(boostPriorityField); f3.addComponent(boostDurationField); /** * Adding the properties button... */ m_propertiesButton = new Button("Properties"); m_propertiesButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { DashletConfigurationWindow configurationWindow = m_dashletSelector .getDashletFactoryForName(m_dashletSpec.getDashletName()) .configurationWindow(m_dashletSpec); getUI().addWindow(configurationWindow); } }); m_propertiesButton.setEnabled(m_dashletSelector.getDashletFactoryForName(m_dashletSpec.getDashletName()) .getRequiredParameters().size() > 0); m_propertiesButton.setStyleName("small"); m_propertiesButton.setDescription("Open properties dialog for this dashlet"); /** * ...and the remove button */ Button removeButton = new Button("Remove"); removeButton.setDescription("Remove this dashlet entry"); FormLayout f4 = new FormLayout(); f4.addComponent(m_propertiesButton); f4.addComponent(removeButton); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { m_wallboardEditor.removeDashletSpecEditor(DashletSpecEditor.this); } }); removeButton.setStyleName("small"); Button upButton = new Button(); upButton.setStyleName("small"); upButton.setIcon(new ThemeResource("../runo/icons/16/arrow-up.png")); upButton.setDescription("Move this a dashlet entry one position up"); Button downButton = new Button(); downButton.setStyleName("small"); downButton.setIcon(new ThemeResource("../runo/icons/16/arrow-down.png")); downButton.setDescription("Move this a dashlet entry one position down"); FormLayout f5 = new FormLayout(); f5.addComponent(upButton); f5.addComponent(downButton); Button previewButton = new Button("Preview"); previewButton.setStyleName("small"); previewButton.setDescription("Preview this single dashlet entry"); Wallboard wallboard = new Wallboard(); wallboard.getDashletSpecs().add(m_dashletSpec); previewButton.addClickListener(new PreviewClickListener(this, wallboard)); FormLayout f6 = new FormLayout(); f6.addComponent(previewButton); upButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { m_wallboardEditor.swapDashletSpec(m_dashletSpec, -1); } }); downButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { m_wallboardEditor.swapDashletSpec(m_dashletSpec, +1); } }); /** * Adding the different {@link FormLayout} instances to a {@link GridLayout} */ f1.setMargin(true); f2.setMargin(true); f3.setMargin(true); f4.setMargin(true); f5.setMargin(true); f6.setMargin(true); gridLayout.addComponent(f1); gridLayout.addComponent(f2); gridLayout.addComponent(f3); gridLayout.addComponent(f4); gridLayout.addComponent(f5); gridLayout.addComponent(f6); setContent(gridLayout); }
From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardEditor.java
License:Open Source License
/** * Constructor used for instantiating a new object. * * @param dashletSelector the {@link DashletSelector} to be used * @param wallboard the associated {@link Wallboard} instance *//*w w w. j a v a2 s . c om*/ public WallboardEditor(DashletSelector dashletSelector, Wallboard wallboard) { /** * Setting the member fields */ this.m_dashletSelector = dashletSelector; this.m_wallboard = wallboard; /** * Adding the {@link DashletSpec} instances */ for (DashletSpec dashletSpec : wallboard.getDashletSpecs()) { addDashletSpec(dashletSpec); } /** * Setting up layout component and adding text field and button */ setMargin(true); HorizontalLayout upperHorizontalLayout = new HorizontalLayout(); Label label = new Label("Ops Board configuration"); label.addStyleName("configuration-title"); upperHorizontalLayout.addComponent(label); upperHorizontalLayout.addComponent(label); Button helpButton = new Button("Help"); helpButton.setDescription("Display help and usage"); helpButton.setStyleName("small"); helpButton.addClickListener(new HelpClickListener(this, m_dashletSelector)); upperHorizontalLayout.addComponent(helpButton); upperHorizontalLayout.setWidth(100, Unit.PERCENTAGE); upperHorizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); upperHorizontalLayout.setComponentAlignment(helpButton, Alignment.MIDDLE_RIGHT); addComponent(upperHorizontalLayout); HorizontalLayout horizontalLayout = new HorizontalLayout(); final Button addButton = new Button("Add dashlet"); addButton.setStyleName("small"); addButton.setDescription("Add a new dashlet instance"); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { addDashletSpec(new DashletSpec()); } }); final TextField titleField = new TextField(); titleField.setDescription("Title for this Ops Board configuration"); titleField.setValue(wallboard.getTitle()); titleField.setImmediate(true); titleField.addValidator(new AbstractStringValidator("Title must be unique") { @Override protected boolean isValidValue(String s) { return (!WallboardProvider.getInstance().containsWallboard(s) || WallboardProvider.getInstance().getWallboard(s).equals(m_wallboard)) && !"".equals(s); } }); titleField.addTextChangeListener(new FieldEvents.TextChangeListener() { public void textChange(FieldEvents.TextChangeEvent textChangeEvent) { AbstractTextField source = (AbstractTextField) textChangeEvent.getSource(); source.setValue(textChangeEvent.getText()); if (source.isValid()) { m_tab.setCaption(textChangeEvent.getText()); m_wallboard.setTitle(textChangeEvent.getText()); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Title"); } } }); titleField.setCaption("Title"); final Button previewButton = new Button("Preview"); previewButton.setDescription("Preview this Ops Board configuration"); previewButton.setStyleName("small"); previewButton.addClickListener(new PreviewClickListener(this, m_wallboard)); /** * Adding the layout components to this component */ FormLayout formLayout1 = new FormLayout(); formLayout1.addComponent(titleField); horizontalLayout.addComponent(formLayout1); FormLayout formLayout2 = new FormLayout(); formLayout2.addComponent(addButton); horizontalLayout.addComponent(formLayout2); FormLayout formLayout3 = new FormLayout(); formLayout3.addComponent(previewButton); horizontalLayout.addComponent(formLayout3); addComponent(horizontalLayout); addComponent(m_verticalLayout); }
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 w w.j ava 2 s .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.MibObjFieldFactory.java
License:Open Source License
@Override public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { if (propertyId.equals("oid")) { final TextField field = new TextField(); field.setSizeFull();/*from w w w .j av a2s.c om*/ field.setRequired(true); field.setImmediate(true); field.addValidator(new RegexpValidator("^\\.[.\\d]+$", "Invalid OID {0}")); return field; } if (propertyId.equals("instance")) { final ComboBox field = new ComboBox(); field.setSizeFull(); field.setRequired(true); field.setImmediate(true); field.setNullSelectionAllowed(false); field.setNewItemsAllowed(true); field.setNewItemHandler(new NewItemHandler() { @Override public void addNewItem(String newItemCaption) { if (!field.containsId(newItemCaption)) { field.addItem(newItemCaption); field.setValue(newItemCaption); } } }); field.addItem("0"); field.addItem("ifIndex"); for (String rt : resourceTypes) { field.addItem(rt); } return field; } if (propertyId.equals("alias")) { final TextField field = new TextField(); field.setSizeFull(); field.setRequired(true); field.setImmediate(true); field.addValidator(new StringLengthValidator( "Invalid alias. It should not contain more than 19 characters.", 1, 19, false)); return field; } if (propertyId.equals("type")) { final TextField field = new TextField(); field.setSizeFull(); field.setRequired(true); field.setImmediate(true); field.addValidator(new RegexpValidator( "^(?i)(counter|gauge|timeticks|integer|octetstring|string)?\\d*$", // Based on NumericAttributeType and StringAttributeType "Invalid type {0}. Valid types are: counter, gauge, timeticks, integer, octetstring, string")); return field; } return null; }