List of usage examples for com.vaadin.ui NativeSelect NativeSelect
public NativeSelect()
From source file:org.escidoc.browser.ui.useraccount.UserRolesView.java
License:Open Source License
private static NativeSelect buildRoleNameSelect() { NativeSelect roleNameSelect = new NativeSelect(); roleNameSelect.setMultiSelect(false); roleNameSelect.setNewItemsAllowed(false); roleNameSelect.setNullSelectionAllowed(false); roleNameSelect.setImmediate(true);/* w w w .ja v a 2 s . c o m*/ return roleNameSelect; }
From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicMainView.java
License:Open Source License
private Component setupBuySellForm() { VerticalLayout formContent = new VerticalLayout(); FormLayout form = new FormLayout(); //account balance this.accBalance = new Label(""); this.accBalance.setCaption("Account Balance"); //stocks list final ComboBox stocksList = new ComboBox(); stocksList.setCaption("Stock"); stocksList.setNullSelectionAllowed(false); for (String stock : DataPlaybackEngineStates.playingSymbols) { stocksList.addItem(stock);// www .jav a 2 s .c o m } //stocksList.setWidth("75%"); //side final NativeSelect orderSide = new NativeSelect(); orderSide.setCaption("Side"); orderSide.addItem(OrderType.BUY); orderSide.addItem(OrderType.SELL); //orderSide.setWidth("90%"); orderSide.setSizeFull(); orderSide.select(OrderType.BUY); orderSide.setNullSelectionAllowed(false); orderSide.setImmediate(true); //Quantity final TextField quantity = new TextField("Amount"); //quantity.setWidth("75%"); form.addComponent(accBalance); form.addComponent(stocksList); form.addComponent(orderSide); form.addComponent(quantity); formContent.addComponent(form); HorizontalLayout bBar = getBuySellForumButtons(stocksList, quantity, orderSide); formContent.addComponent(bBar); formContent.setComponentAlignment(bBar, Alignment.BOTTOM_RIGHT); //content.setComponentAlignment(nextDayB, Alignment.MIDDLE_CENTER); return formContent; }
From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicStockDataView.java
License:Open Source License
private HorizontalLayout setUpTopBar() { HorizontalLayout components = new HorizontalLayout(); components.setWidth("100%"); HorizontalLayout addChartComponents = new HorizontalLayout(); components.addComponent(addChartComponents); //create the stocks drop down list availableStocksList = new ComboBox(); addChartComponents.addComponent(availableStocksList); availableStocksList.setImmediate(true); // availableStocksList.setCaption("Stock"); availableStocksList.setNullSelectionAllowed(false); for (String stock : DataPlaybackEngineStates.playingSymbols) { availableStocksList.addItem(stock); }/*from ww w .ja v a 2 s. c o m*/ availableStocksList.select(availableStocksList.getItemIds().toArray()[0]); //available attributes list availableDataItems = new NativeSelect(); addChartComponents.addComponent(availableDataItems); // availableDataItems.setCaption("Data: "); for (TradingDataAttribute attr : setSelectableAttributes()) { availableDataItems.addItem(attr); } availableDataItems.setNullSelectionAllowed(false); availableDataItems.select(availableDataItems.getItemIds().toArray()[0]); availableDataItems.setImmediate(true); //add chart button Button addChartButton = new Button("Add"); addChartComponents.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { addPlotToChart(); } }); //Remove charts section HorizontalLayout removeChartsComponents = new HorizontalLayout(); components.addComponent(removeChartsComponents); //plotted charts list this.plottedItemsList = new ComboBox(); removeChartsComponents.addComponent(this.plottedItemsList); this.plottedItemsList.setImmediate(true); // this.plottedItemsList.setCaption("Drawn Charts"); this.plottedItemsList.setNullSelectionAllowed(true); //remove plot button Button removeChartButton = new Button("Remove"); removeChartsComponents.addComponent(removeChartButton); removeChartButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { removePlotFromChart(); } }); //clear all button Button clearAllButton = new Button("Clear All"); removeChartsComponents.addComponent(clearAllButton); clearAllButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { clearTimeline(); } }); //set the alignments components.setComponentAlignment(addChartComponents, Alignment.MIDDLE_CENTER); components.setComponentAlignment(removeChartsComponents, Alignment.MIDDLE_CENTER); components.setHeight(50, Unit.PIXELS); return components; }
From source file:org.jumpmind.vaadin.ui.common.CommonUiUtils.java
License:Open Source License
public static AbstractSelect createComboBox(String name) { NativeSelect cb = name == null ? new NativeSelect() : new NativeSelect(name); cb.setImmediate(true);//from ww w. ja v a 2 s . c om cb.setWidth(16, Unit.EM); cb.setHeight(2.15f, Unit.EM); cb.setNullSelectionAllowed(false); return cb; }
From source file:org.opennms.features.topology.netutils.internal.ping.PingForm.java
License:Open Source License
public PingForm(List<String> locations, String defaultLocation, List<InetAddress> ipAddresses, InetAddress defaultIp) {/*from w ww . jav a 2 s . c om*/ Objects.requireNonNull(locations); Objects.requireNonNull(defaultLocation); Objects.requireNonNull(ipAddresses); Objects.requireNonNull(defaultIp); PingRequest pingRequest = new PingRequest().withNumberRequests(4).withTimeout(1, TimeUnit.SECONDS) .withPackageSize(64).withInetAddress(defaultIp).withLocation(defaultLocation); // IP ipDropdown = new NativeSelect(); ipDropdown.setCaption("IP Address"); for (InetAddress eachIp : ipAddresses) { ipDropdown.addItem(eachIp); } ipDropdown.setNullSelectionAllowed(false); ipDropdown.getItemIds().forEach(eachItemId -> ipDropdown.setItemCaption(eachItemId, InetAddressUtils.toIpAddrString((InetAddress) eachItemId))); ipDropdown.setWidth(FIELD_WIDTH, Unit.PIXELS); // Packet Size packetSizeDropdown = new NativeSelect(); packetSizeDropdown.setCaption("Packet Size"); packetSizeDropdown.addItem(64); packetSizeDropdown.addItem(128); packetSizeDropdown.addItem(256); packetSizeDropdown.addItem(512); packetSizeDropdown.addItem(1024); packetSizeDropdown.addItem(2048); packetSizeDropdown.setNullSelectionAllowed(false); packetSizeDropdown.setWidth(FIELD_WIDTH, Unit.PIXELS); // Location locationDropdown = new NativeSelect(); locationDropdown.setCaption("Location"); for (String eachLocation : locations) { locationDropdown.addItem(eachLocation); } locationDropdown.setNullSelectionAllowed(false); locationDropdown.setWidth(FIELD_WIDTH, Unit.PIXELS); // Number of Requests numberOfRequestsField = new TextField(); numberOfRequestsField.setCaption("Number of Requests"); numberOfRequestsField.setRequired(true); numberOfRequestsField.setRequiredError("Must be given"); numberOfRequestsField.setNullRepresentation(""); numberOfRequestsField.setWidth(FIELD_WIDTH, Unit.PIXELS); numberOfRequestsField.addValidator((Validator) value -> { if (value != null) { if (((Integer) value).intValue() <= 0) { throw new Validator.InvalidValueException("must be > 0"); } } }); // Timeout timeoutField = new TextField(); timeoutField.setCaption("Timeout (seconds)"); timeoutField.setRequired(true); timeoutField.setRequiredError("Must be given"); timeoutField.setWidth(FIELD_WIDTH, Unit.PIXELS); timeoutField.setConverter(new StringToLongConverter() { @Override public Long convertToModel(String value, Class<? extends Long> targetType, Locale locale) throws ConversionException { Long longValue = super.convertToModel(value, targetType, locale); if (longValue != null) { return TimeUnit.MILLISECONDS.convert(longValue, TimeUnit.SECONDS); } return longValue; } @Override public String convertToPresentation(Long value, Class<? extends String> targetType, Locale locale) throws ConversionException { if (value != null) { return super.convertToPresentation(TimeUnit.SECONDS.convert(value, TimeUnit.MILLISECONDS), targetType, locale); } return super.convertToPresentation(value, targetType, locale); } }); timeoutField.addValidator(new NullValidator("Must be given", false)); timeoutField.addValidator((Validator) value -> { if (value != null) { if (((Long) value).intValue() <= 0) { throw new Validator.InvalidValueException("must be > 0"); } } }); addComponent(ipDropdown); addComponent(numberOfRequestsField); addComponent(locationDropdown); addComponent(timeoutField); addComponent(packetSizeDropdown); item = new BeanItem<>(pingRequest); binder = new FieldGroup(item); binder.bind(ipDropdown, "inetAddress"); binder.bind(numberOfRequestsField, "numberRequests"); binder.bind(timeoutField, "timeout"); binder.bind(packetSizeDropdown, "packetSize"); binder.bind(locationDropdown, "location"); binder.setBuffered(true); }
From source file:org.opennms.features.topology.netutils.internal.PingForm.java
License:Open Source License
public PingForm(InetAddress host) { Objects.requireNonNull(host); PingRequest pingRequest = new PingRequest().withNumberRequests(4).withTimeout(1, TimeUnit.SECONDS) .withPackageSize(64).withInetAddress(host); // IP//from www. j a v a 2s.c om ipDropdown = new NativeSelect(); ipDropdown.setCaption("IP Address"); ipDropdown.addItem(pingRequest.getInetAddress()); ipDropdown.setNullSelectionAllowed(false); ipDropdown.getItemIds().forEach(eachItemId -> ipDropdown.setItemCaption(eachItemId, InetAddressUtils.toIpAddrString((InetAddress) eachItemId))); ipDropdown.setWidth(FIELD_WIDTH, Unit.PIXELS); // Packet Size packetSizeDropdown = new NativeSelect(); packetSizeDropdown.setCaption("Packet Size"); packetSizeDropdown.addItem(64); packetSizeDropdown.addItem(128); packetSizeDropdown.addItem(256); packetSizeDropdown.addItem(512); packetSizeDropdown.addItem(1024); packetSizeDropdown.addItem(2048); packetSizeDropdown.setNullSelectionAllowed(false); packetSizeDropdown.setWidth(FIELD_WIDTH, Unit.PIXELS); // Number of Requests numberOfRequestsField = new TextField(); numberOfRequestsField.setCaption("Number of Requests"); numberOfRequestsField.setRequired(true); numberOfRequestsField.setRequiredError("Must be given"); numberOfRequestsField.setNullRepresentation(""); numberOfRequestsField.setWidth(FIELD_WIDTH, Unit.PIXELS); numberOfRequestsField.addValidator((Validator) value -> { if (value != null) { if (((Integer) value).intValue() <= 0) { throw new Validator.InvalidValueException("must be > 0"); } } }); // Timeout timeoutField = new TextField(); timeoutField.setCaption("Timeout (seconds)"); timeoutField.setRequired(true); timeoutField.setRequiredError("Must be given"); timeoutField.setWidth(FIELD_WIDTH, Unit.PIXELS); timeoutField.setConverter(new StringToLongConverter() { @Override public Long convertToModel(String value, Class<? extends Long> targetType, Locale locale) throws ConversionException { Long longValue = super.convertToModel(value, targetType, locale); if (longValue != null) { return TimeUnit.MILLISECONDS.convert(longValue, TimeUnit.SECONDS); } return longValue; } @Override public String convertToPresentation(Long value, Class<? extends String> targetType, Locale locale) throws ConversionException { if (value != null) { return super.convertToPresentation(TimeUnit.SECONDS.convert(value, TimeUnit.MILLISECONDS), targetType, locale); } return super.convertToPresentation(value, targetType, locale); } }); timeoutField.addValidator(new NullValidator("Must be given", false)); timeoutField.addValidator((Validator) value -> { if (value != null) { if (((Long) value).intValue() <= 0) { throw new Validator.InvalidValueException("must be > 0"); } } }); addComponent(ipDropdown); addComponent(numberOfRequestsField); addComponent(timeoutField); addComponent(packetSizeDropdown); item = new BeanItem<>(pingRequest); binder = new FieldGroup(item); binder.bind(ipDropdown, "inetAddress"); binder.bind(numberOfRequestsField, "numberRequests"); binder.bind(timeoutField, "timeout"); binder.bind(packetSizeDropdown, "packageSize"); binder.setBuffered(true); }
From source file:org.opennms.features.topology.netutils.internal.TracerouteWindow.java
License:Open Source License
/** * The TracerouteWindow method constructs a TracerouteWindow component with a size proportionate to the * width and height of the main window.// w ww . j a v a 2s . c o m * @param node * @param width Width of Main window * @param height Height of Main window */ public TracerouteWindow(final Node node, final String url) { this.tracerouteUrl = url; String label = ""; String ipAddress = ""; if (node != null) { label = node.getLabel(); ipAddress = node.getIPAddress(); } String caption = ""; /*Sets up window settings*/ if (label == null || label.equals("") || label.equalsIgnoreCase(noLabel)) { label = ""; } if (!label.equals("")) caption = " - " + label; setCaption("Traceroute" + caption); setImmediate(true); setResizable(false); /*Initialize the header of the Sub-window with the name of the selected Node*/ String nodeName = "<div style=\"text-align: center; font-size: 18pt; font-weight:bold;\">" + label + "</div>"; nodeLabel = new Label(nodeName); nodeLabel.setContentMode(ContentMode.HTML); /*Creating various layouts to encapsulate all of the components*/ VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); vSplit = new VerticalSplitPanel(); topLayout = new VerticalLayout(); bottomLayout = new VerticalLayout(); VerticalLayout form = new VerticalLayout(); GridLayout grid = new GridLayout(2, 2); grid.setWidth("420"); grid.setHeight("62"); /*Sets up IP Address dropdown with the Name as default*/ ipDropdown = new NativeSelect(); ipDropdown.addItem(ipAddress); ipDropdown.select(ipAddress); /*Creates the Numerical Output Check box and sets up the listener*/ numericalDataCheckBox = new CheckBox("Use Numerical Node Names"); numericalDataCheckBox.setImmediate(true); numericalDataCheckBox.setValue(false); /*Creates the form labels and text fields*/ Label ipLabel = new Label("IP Address: "); Label forcedHopLabel = new Label("Forced Hop IP: "); forcedHopField = new TextField(); forcedHopField.setMaxLength(15); /*Add all of the components to the GridLayout*/ grid.addComponent(ipLabel); grid.setComponentAlignment(ipLabel, Alignment.MIDDLE_LEFT); grid.addComponent(ipDropdown); grid.setComponentAlignment(ipDropdown, Alignment.MIDDLE_LEFT); grid.addComponent(forcedHopLabel); grid.setComponentAlignment(forcedHopLabel, Alignment.MIDDLE_LEFT); grid.addComponent(forcedHopField); grid.setComponentAlignment(forcedHopField, Alignment.MIDDLE_LEFT); /*Creates the Ping button and sets up the listener*/ tracerouteButton = new Button("Traceroute"); tracerouteButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { changeBrowserURL(buildURL()); } }); /*Adds components to the form and sets the width and spacing*/ form.addComponent(grid); form.addComponent(numericalDataCheckBox); form.addComponent(tracerouteButton); form.setWidth("100%"); form.setSpacing(true); /*Adds components to the Top Layout and sets the width and margins*/ topLayout.addComponent(nodeLabel); topLayout.setComponentAlignment(nodeLabel, Alignment.MIDDLE_CENTER); topLayout.addComponent(form); topLayout.setSizeFull(); topLayout.setMargin(new MarginInfo(true, true, false, true)); /*Adds components to the Bottom Layout and sets the width and margins*/ bottomLayout.setSizeFull(); bottomLayout.setMargin(true); bottomLayout.setImmediate(true); buildEmbeddedBrowser(); /*Setting first and second components for the split panel and setting the panel divider position*/ vSplit.setFirstComponent(topLayout); vSplit.setSecondComponent(bottomLayout); vSplit.setSplitPosition(splitHeight, Unit.PIXELS); vSplit.setLocked(true); /*Adds split panel to the main layout and expands the split panel to 100% of the layout space*/ mainLayout.addComponent(vSplit); mainLayout.setExpandRatio(vSplit, 1); setContent(mainLayout); }
From source file:org.opennms.features.topology.plugins.browsers.AlarmTable.java
License:Open Source License
/** * Leave OnmsVaadinContainer without generics; the Aries blueprint code cannot match up * the arguments if you put the generic types in. */// w ww .java 2s . c om public AlarmTable(final String caption, final OnmsVaadinContainer container, final AlarmRepository alarmRepo) { super(caption, container); m_alarmRepo = alarmRepo; m_ackCombo = new NativeSelect(); m_ackCombo.setNullSelectionAllowed(false); m_ackCombo.addItem(ACTION_ACKNOWLEDGE); m_ackCombo.addItem(ACTION_UNACKNOWLEDGE); m_ackCombo.addItem(ACTION_ESCALATE); m_ackCombo.addItem(ACTION_CLEAR); m_ackCombo.setValue(ACTION_ACKNOWLEDGE); // Make "Acknowledge" the default value m_submitButton = new CheckboxButton("Submit"); m_submitButton.setCombo(m_ackCombo); }
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 . j ava 2 s . 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.editors.CriteriaRestrictionComponent.java
License:Open Source License
/** * Constructor for creating ne instances of this class. * * @param criteriaBuilderHelper the {@link CriteriaBuilderHelper} to be used * @param restriction the criteria string *///from w ww .j av a2 s . co m public CriteriaRestrictionComponent(CriteriaBuilderHelper criteriaBuilderHelper, String restriction) { /** * Setting the member fields */ m_criteriaBuilderHelper = criteriaBuilderHelper; /** * Setting up this component */ setWidth(100, Unit.PERCENTAGE); m_rightLayout = new HorizontalLayout(); m_leftLayout = new HorizontalLayout(); setSpacing(true); setMargin(true); Page.getCurrent().getStyles().add(".criteriaBackground { background:#dddddd; }"); addStyleName("criteriaBackground"); /** * Adding the restriction's select box */ m_restrictionSelect = new NativeSelect(); m_restrictionSelect.setCaption("Restriction"); m_restrictionSelect.setNullSelectionAllowed(false); m_restrictionSelect.setMultiSelect(false); m_restrictionSelect.setNewItemsAllowed(false); m_restrictionSelect.setImmediate(true); m_restrictionSelect.setDescription("Restriction selection"); for (CriteriaRestriction criteriaRestriction : CriteriaRestriction.values()) { m_restrictionSelect.addItem(criteriaRestriction.name()); } /** * Parsing the criteria */ final String[] arr = restriction.split("[(),]+"); CriteriaRestriction criteriaRestriction = CriteriaRestriction.valueOf(arr[0]); m_restrictionSelect.select(criteriaRestriction.toString()); m_restrictionSelect.addValueChangeListener(new com.vaadin.data.Property.ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent valueChangeEvent) { CriteriaRestriction newCriteriaRestriction = CriteriaRestriction .valueOf(String.valueOf(valueChangeEvent.getProperty().getValue())); refreshComponents(newCriteriaRestriction); //, Arrays.copyOfRange(arr, 1, arr.length)); } }); setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); m_leftLayout.addComponent(m_restrictionSelect); m_leftLayout.setSpacing(true); refreshComponents(criteriaRestriction, Arrays.copyOfRange(arr, 1, arr.length)); /** * Adding the layouts */ addComponent(m_leftLayout); addComponent(m_rightLayout); setExpandRatio(m_leftLayout, 3.0f); setExpandRatio(m_rightLayout, 1.0f); setComponentAlignment(m_leftLayout, Alignment.MIDDLE_LEFT); setComponentAlignment(m_rightLayout, Alignment.MIDDLE_RIGHT); }