List of usage examples for com.vaadin.ui CheckBox CheckBox
public CheckBox()
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.PluginManagerUIMainPanel.java
License:Apache License
@AutoGenerated private VerticalLayout buildSystemIdPanel() { // common part: create layout systemIdPanel = new VerticalLayout(); systemIdPanel.setImmediate(true);/* w ww .j a v a2 s. c o m*/ systemIdPanel.setDescription("System Id Settings"); systemIdPanel.setWidth("-1px"); systemIdPanel.setHeight("-1px"); systemIdPanel.setMargin(true); systemIdPanel.setSpacing(true); // currentKarafUrlTextField currentKarafUrlTextField = new TextField(); currentKarafUrlTextField.setCaption("Current Karaf URL"); currentKarafUrlTextField.setImmediate(true); currentKarafUrlTextField.setWidth("100.0%"); currentKarafUrlTextField.setHeight("-1px"); systemIdPanel.addComponent(currentKarafUrlTextField); // karafInstanceSelectedTextField karafInstanceSelectedTextField = new TextField(); karafInstanceSelectedTextField.setCaption("Current Karaf Instance Name"); karafInstanceSelectedTextField.setImmediate(true); karafInstanceSelectedTextField.setWidth("100.0%"); karafInstanceSelectedTextField.setHeight("-1px"); systemIdPanel.addComponent(karafInstanceSelectedTextField); // karafLastUpdatedTextField karafLastUpdatedTextField = new TextField(); karafLastUpdatedTextField.setCaption("Current Instance Last Updated"); karafLastUpdatedTextField.setImmediate(true); karafLastUpdatedTextField.setWidth("100.0%"); karafLastUpdatedTextField.setHeight("-1px"); systemIdPanel.addComponent(karafLastUpdatedTextField); // systemIdTxtField systemIdTxtField = new TextField(); systemIdTxtField.setCaption("Current Instance System Id"); systemIdTxtField.setImmediate(true); systemIdTxtField.setDescription("Actual System Id of the selected Karaf Instance"); systemIdTxtField.setWidth("100.0%"); systemIdTxtField.setHeight("-1px"); systemIdPanel.addComponent(systemIdTxtField); // manifestSystemIdTextField manifestSystemIdTextField = new TextField(); manifestSystemIdTextField.setCaption("Manifest System Id"); manifestSystemIdTextField.setImmediate(true); manifestSystemIdTextField.setDescription("System Id Expected for Manifest download"); manifestSystemIdTextField.setWidth("100.0%"); manifestSystemIdTextField.setHeight("-1px"); systemIdPanel.addComponent(manifestSystemIdTextField); // updateSystemIdButton updateSystemIdButton = new Button(); updateSystemIdButton.setCaption("Set Karaf to Manifest System Id"); updateSystemIdButton.setImmediate(true); updateSystemIdButton.setDescription( "Sets the systemId of the selected Karaf instance to the value in the System Id field"); updateSystemIdButton.setWidth("-1px"); updateSystemIdButton.setHeight("-1px"); systemIdPanel.addComponent(updateSystemIdButton); // generateRandomManifestSystemIdButton generateRandomManifestSystemIdButton = new Button(); generateRandomManifestSystemIdButton.setCaption("Generate Random Manifest System Id"); generateRandomManifestSystemIdButton.setImmediate(true); generateRandomManifestSystemIdButton.setDescription( "Generates a new random system id and sets this value in the selected karaf instance"); generateRandomManifestSystemIdButton.setWidth("-1px"); generateRandomManifestSystemIdButton.setHeight("-1px"); systemIdPanel.addComponent(generateRandomManifestSystemIdButton); // remoteIsAccessibleCheckBox remoteIsAccessibleCheckBox = new CheckBox(); remoteIsAccessibleCheckBox.setCaption(" Remote is Accessible"); remoteIsAccessibleCheckBox.setImmediate(false); remoteIsAccessibleCheckBox.setDescription( "Check if Remote cannot be direcly updated using ReST commands. (i.e behind firewall)"); remoteIsAccessibleCheckBox.setWidth("-1px"); remoteIsAccessibleCheckBox.setHeight("-1px"); systemIdPanel.addComponent(remoteIsAccessibleCheckBox); // allowUpdateMessagesCheckBox allowUpdateMessagesCheckBox = new CheckBox(); allowUpdateMessagesCheckBox.setCaption(" Allow Status Update from Remote"); allowUpdateMessagesCheckBox.setImmediate(false); allowUpdateMessagesCheckBox.setDescription("Status update messages are allowed from remote"); allowUpdateMessagesCheckBox.setWidth("-1px"); allowUpdateMessagesCheckBox.setHeight("-1px"); systemIdPanel.addComponent(allowUpdateMessagesCheckBox); systemIdPanel.setComponentAlignment(allowUpdateMessagesCheckBox, new Alignment(33)); return systemIdPanel; }
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.ProductDescriptorPanel.java
License:Apache License
@AutoGenerated private VerticalLayout buildVerticalLayout_2() { // common part: create layout verticalLayout_2 = new VerticalLayout(); verticalLayout_2.setImmediate(false); verticalLayout_2.setWidth("100.0%"); verticalLayout_2.setHeight("100.0%"); verticalLayout_2.setMargin(false);/* w ww .ja v a 2 s. c om*/ verticalLayout_2.setSpacing(true); // horizontalLayout_1 horizontalLayout_1 = buildHorizontalLayout_1(); verticalLayout_2.addComponent(horizontalLayout_1); // systemPluginCheckBox systemPluginCheckBox = new CheckBox(); systemPluginCheckBox.setCaption("System Plugin"); systemPluginCheckBox.setImmediate(true); systemPluginCheckBox.setDescription("System Plugins cannot be removed by the plugin manager"); systemPluginCheckBox.setWidth("-1px"); systemPluginCheckBox.setHeight("-1px"); verticalLayout_2.addComponent(systemPluginCheckBox); // productNameTextField productNameTextField = new TextField(); productNameTextField.setCaption("Product Name"); productNameTextField.setImmediate(true); productNameTextField.setWidth("100.0%"); productNameTextField.setHeight("-1px"); verticalLayout_2.addComponent(productNameTextField); verticalLayout_2.setExpandRatio(productNameTextField, 1.0f); // productIdTextField productIdTextField = new TextField(); productIdTextField.setCaption("Product Id"); productIdTextField.setImmediate(true); productIdTextField.setWidth("100.0%"); productIdTextField.setHeight("-1px"); verticalLayout_2.addComponent(productIdTextField); verticalLayout_2.setExpandRatio(productIdTextField, 1.0f); // featureRepositoryTextField featureRepositoryTextField = new TextField(); featureRepositoryTextField.setCaption("Feature Repository URL"); featureRepositoryTextField.setImmediate(true); featureRepositoryTextField.setWidth("100.0%"); featureRepositoryTextField.setHeight("-1px"); verticalLayout_2.addComponent(featureRepositoryTextField); verticalLayout_2.setExpandRatio(featureRepositoryTextField, 1.0f); // packageingDescriptorTextField packageingDescriptorTextField = new TextField(); packageingDescriptorTextField.setCaption("Packaging Descriptor"); packageingDescriptorTextField.setImmediate(true); packageingDescriptorTextField .setDescription("Provides a locator for the Karaf kar or rpm which delivered this feature"); packageingDescriptorTextField.setWidth("100.0%"); packageingDescriptorTextField.setHeight("-1px"); verticalLayout_2.addComponent(packageingDescriptorTextField); verticalLayout_2.setExpandRatio(packageingDescriptorTextField, 1.0f); // productDescriptionTextArea productDescriptionTextArea = new TextArea(); productDescriptionTextArea.setCaption("Product Description"); productDescriptionTextArea.setImmediate(true); productDescriptionTextArea.setWidth("100.0%"); productDescriptionTextArea.setHeight("6.0em"); verticalLayout_2.addComponent(productDescriptionTextArea); verticalLayout_2.setExpandRatio(productDescriptionTextArea, 1.0f); // productUrlTextField productUrlTextField = new TextField(); productUrlTextField.setCaption("Product URL"); productUrlTextField.setImmediate(true); productUrlTextField.setWidth("100.0%"); productUrlTextField.setHeight("-1px"); verticalLayout_2.addComponent(productUrlTextField); verticalLayout_2.setExpandRatio(productUrlTextField, 1.0f); // licenceTypeTextField licenceTypeTextField = new TextField(); licenceTypeTextField.setCaption("Licence Type"); licenceTypeTextField.setImmediate(true); licenceTypeTextField.setWidth("100.0%"); licenceTypeTextField.setHeight("-1px"); licenceTypeTextField.setNullSettingAllowed(true); verticalLayout_2.addComponent(licenceTypeTextField); verticalLayout_2.setExpandRatio(licenceTypeTextField, 1.0f); // organizationTextField organizationTextField = new TextField(); organizationTextField.setCaption("Organization"); organizationTextField.setImmediate(true); organizationTextField.setWidth("100.0%"); organizationTextField.setHeight("-1px"); organizationTextField.setNullSettingAllowed(true); verticalLayout_2.addComponent(organizationTextField); verticalLayout_2.setExpandRatio(organizationTextField, 1.0f); return verticalLayout_2; }
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.ProductDescriptorPanel.java
License:Apache License
@AutoGenerated private HorizontalLayout buildHorizontalLayout_1() { // common part: create layout horizontalLayout_1 = new HorizontalLayout(); horizontalLayout_1.setImmediate(false); horizontalLayout_1.setWidth("100.0%"); horizontalLayout_1.setHeight("100.0%"); horizontalLayout_1.setMargin(false); horizontalLayout_1.setSpacing(true); // licenceRequiredCheckBox licenceRequiredCheckBox = new CheckBox(); licenceRequiredCheckBox.setCaption("Licence Key Required"); licenceRequiredCheckBox.setDescription( "If a Licence Key is required the module will not start without a valid licence installed"); licenceRequiredCheckBox.setImmediate(true); licenceRequiredCheckBox.setWidth("-1px"); licenceRequiredCheckBox.setHeight("-1px"); horizontalLayout_1.addComponent(licenceRequiredCheckBox); // spacelabel_1 spacelabel_1 = new Label(); spacelabel_1.setImmediate(false);//from w w w . j a v a2 s .c om spacelabel_1.setWidth("-1px"); spacelabel_1.setHeight("-1px"); spacelabel_1.setValue("Label"); horizontalLayout_1.addComponent(spacelabel_1); horizontalLayout_1.setExpandRatio(spacelabel_1, 1.0f); // licenceAuthenticatedLabel licenceAuthenticatedLabel = new Label(); licenceAuthenticatedLabel.setImmediate(true); licenceAuthenticatedLabel .setDescription("State of licence authentication for the systemId of this karaf instance"); licenceAuthenticatedLabel.setWidth("-1px"); licenceAuthenticatedLabel.setHeight("-1px"); licenceAuthenticatedLabel.setValue("Label"); horizontalLayout_1.addComponent(licenceAuthenticatedLabel); return horizontalLayout_1; }
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.SimpleInstanceListEditor.java
License:Apache License
@AutoGenerated private VerticalLayout buildVerticalLayout_3() { // common part: create layout verticalLayout_3 = new VerticalLayout(); verticalLayout_3.setImmediate(false); verticalLayout_3.setWidth("-1px"); verticalLayout_3.setHeight("-1px"); verticalLayout_3.setMargin(true);/*from w w w .j a va2 s .c om*/ verticalLayout_3.setSpacing(true); // instructionLabel instructionLabel = new Label(); instructionLabel.setImmediate(false); instructionLabel.setWidth("100.0%"); instructionLabel.setHeight("-1px"); instructionLabel.setValue("Label"); verticalLayout_3.addComponent(instructionLabel); // karafInstanceSelectedTextField karafInstanceSelectedTextField = new TextField(); karafInstanceSelectedTextField.setCaption("Instance Name"); karafInstanceSelectedTextField.setImmediate(false); karafInstanceSelectedTextField.setWidth("100.0%"); karafInstanceSelectedTextField.setHeight("-1px"); verticalLayout_3.addComponent(karafInstanceSelectedTextField); // currentKarafUrlTextField currentKarafUrlTextField = new TextField(); currentKarafUrlTextField.setCaption("Instance Url"); currentKarafUrlTextField.setImmediate(false); currentKarafUrlTextField.setWidth("100.0%"); currentKarafUrlTextField.setHeight("-1px"); verticalLayout_3.addComponent(currentKarafUrlTextField); // instanceUsernameTextField instanceUsernameTextField = new TextField(); instanceUsernameTextField.setCaption("Instance User Name"); instanceUsernameTextField.setImmediate(false); instanceUsernameTextField.setWidth("100.0%"); instanceUsernameTextField.setHeight("-1px"); verticalLayout_3.addComponent(instanceUsernameTextField); // instancePasswordTextField instancePasswordTextField = new TextField(); instancePasswordTextField.setCaption("Instance Password"); instancePasswordTextField.setImmediate(false); instancePasswordTextField.setWidth("100.0%"); instancePasswordTextField.setHeight("-1px"); verticalLayout_3.addComponent(instancePasswordTextField); // remoteIsAccessibleCheckBox remoteIsAccessibleCheckBox = new CheckBox(); remoteIsAccessibleCheckBox.setCaption(" Remote is Accessible"); remoteIsAccessibleCheckBox.setImmediate(false); remoteIsAccessibleCheckBox.setDescription( "Check if Remote cannot be direcly updated using ReST commands. (i.e behind firewall)"); remoteIsAccessibleCheckBox.setWidth("-1px"); remoteIsAccessibleCheckBox.setHeight("-1px"); verticalLayout_3.addComponent(remoteIsAccessibleCheckBox); // allowUpdateMessagesCheckBox allowUpdateMessagesCheckBox = new CheckBox(); allowUpdateMessagesCheckBox.setCaption(" Allow Status Update from Remote"); allowUpdateMessagesCheckBox.setImmediate(false); allowUpdateMessagesCheckBox.setDescription("Status update messages are allowed from remote"); allowUpdateMessagesCheckBox.setWidth("-1px"); allowUpdateMessagesCheckBox.setHeight("-1px"); verticalLayout_3.addComponent(allowUpdateMessagesCheckBox); // saveKarafInstanceManifestButton saveKarafInstanceManifestButton = new Button(); saveKarafInstanceManifestButton.setCaption("Update / Save Karaf Instance"); saveKarafInstanceManifestButton.setImmediate(true); saveKarafInstanceManifestButton.setWidth("-1px"); saveKarafInstanceManifestButton.setHeight("-1px"); verticalLayout_3.addComponent(saveKarafInstanceManifestButton); // messageTextArea messageTextArea = new TextArea(); messageTextArea.setImmediate(true); messageTextArea.setWidth("-1px"); messageTextArea.setHeight("-1px"); verticalLayout_3.addComponent(messageTextArea); return verticalLayout_3; }
From source file:org.opennms.features.topology.plugins.browsers.CheckboxGenerator.java
License:Open Source License
@Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<Integer> property = source.getContainerProperty(itemId, m_valueProperty); if (property.getValue() == null) { return null; } else {/*from ww w .j a va 2 s . c o m*/ if (SecurityContextHolder.getContext().toString().contains(Authentication.ROLE_READONLY)) { // Do not render the checkboxes for read-only users return null; } else { final CheckBox button = new CheckBox(); button.setData(property.getValue()); button.setValue(isSelected((Integer) property.getValue())); button.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 2991986878904005830L; @Override public void valueChange(ValueChangeEvent event) { if (Boolean.TRUE.equals(event.getProperty().getValue())) { m_selectedCheckboxes.add(property.getValue()); m_notSelectedCheckboxes.remove(property.getValue()); } else { m_selectedCheckboxes.remove(property.getValue()); m_notSelectedCheckboxes.add(property.getValue()); } } }); m_checkboxes.add(button); return button; } } }
From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardOverview.java
License:Open Source License
/** * Constructor for creating new instances. * * @param wallboardConfigView the {@link WallboardConfigView} *//*from w w w. j ava2s .c o m*/ public WallboardOverview(WallboardConfigView wallboardConfigView) { /** * Setting the member fields */ this.m_wallboardConfigView = wallboardConfigView; /** * Setting up the layout component */ setSizeFull(); setMargin(true); setSpacing(true); Label label = new Label("Overview"); label.addStyleName("configuration-title"); Button button = new Button("Help"); button.setStyleName("small"); button.setDescription("Display help and usage"); button.addClickListener(new HelpClickListener(this, m_wallboardConfigView.getDashletSelector())); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(label); horizontalLayout.addComponent(button); horizontalLayout.setWidth(100, Unit.PERCENTAGE); horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); horizontalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); addComponent(horizontalLayout); /** * Adding the table with the required {@link Table.ColumnGenerator} objects */ m_table = new Table(); m_table.setSizeFull(); m_table.addGeneratedColumn("Edit", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Edit"); button.setDescription("Edit this Ops Board configuration"); button.setStyleName("small"); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { m_wallboardConfigView.openWallboardEditor((Wallboard) itemId); } }); return button; } }); m_table.addGeneratedColumn("Remove", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Remove"); button.setDescription("Delete this Ops Board configuration"); button.setStyleName("small"); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { m_wallboardConfigView.removeTab(((Wallboard) itemId).getTitle()); WallboardProvider.getInstance().removeWallboard((Wallboard) itemId); refreshTable(); } }); return button; } }); m_table.addGeneratedColumn("Preview", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Preview"); button.setDescription("Preview this Ops Board configuration"); button.setStyleName("small"); button.addClickListener(new PreviewClickListener(WallboardOverview.this, (Wallboard) itemId)); return button; } }); m_table.addGeneratedColumn("Default", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Ops Board configuration the default"); final Wallboard wallboard = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(wallboard.isDefault()); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { for (Wallboard wallboard1 : m_beanItemContainer.getItemIds()) { wallboard1.setDefault(false); } } wallboard.setDefault(newValue); m_table.refreshRowCache(); WallboardProvider.getInstance().save(); } }); return checkBox; } }); refreshTable(); /** * Adding the table */ addComponent(m_table); setExpandRatio(m_table, 1.0f); }
From source file:org.opennms.features.vaadin.dashboard.dashlets.BSMConfigurationWindow.java
License:Open Source License
/** * Constructor for instantiating new objects of this class. * * @param dashletSpec the {@link DashletSpec} to be edited *///from www . j a v a2 s. c o m public BSMConfigurationWindow(DashletSpec dashletSpec) { /** * Setting the members */ m_dashletSpec = dashletSpec; /** * Setting up the base layouts */ setHeight(91, Unit.PERCENTAGE); setWidth(60, Unit.PERCENTAGE); /** * Retrieve the config... */ boolean filterByName = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(), "filterByName"); String nameValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "nameValue", ""); boolean filterByAttribute = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(), "filterByAttribute"); String attributeKey = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "attributeKey", ""); String attributeValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "attributeValue", ""); boolean filterBySeverity = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(), "filterBySeverity"); String severityValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "severityValue", Status.WARNING.name()); String severityCompareOperator = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "severityCompareOperator", BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name()); String orderBy = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "orderBy", BusinessServiceSearchCriteriaBuilder.Order.Name.name()); String orderSequence = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "orderSequence", BusinessServiceSearchCriteriaBuilder.Sequence.Ascending.name()); int resultsLimit = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "resultsLimit", 10); int columnCountBoard = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "columnCountBoard", 10); int columnCountPanel = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "columnCountPanel", 5); /** * Adding the "Filter By Name" panel */ m_filterByNameCheckBox = new CheckBox(); m_filterByNameCheckBox.setCaption("Enable"); m_filterByNameCheckBox.setDescription("Filter by Business Service name"); VerticalLayout nameLayout = new VerticalLayout(); nameLayout.setSpacing(true); nameLayout.setMargin(true); nameLayout.setSizeFull(); m_nameTextField = new TextField("Name (REGEXP)"); m_nameTextField.setEnabled(false); addToComponent(nameLayout, m_filterByNameCheckBox); addToComponent(nameLayout, m_nameTextField); Panel namePanel = new Panel(); namePanel.setCaption("Filter by Name"); namePanel.setContent(nameLayout); m_filterByNameCheckBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { m_nameTextField.setEnabled(m_filterByNameCheckBox.getValue()); } }); m_nameTextField.setValue(nameValue); m_filterByNameCheckBox.setValue(filterByName); /** * Adding the "Filter By Attribute" panel */ m_filterByAttributeCheckBox = new CheckBox(); m_filterByAttributeCheckBox.setCaption("Enable"); m_filterByAttributeCheckBox.setDescription("Filter by Business Service attribute"); VerticalLayout attributeLayout = new VerticalLayout(); attributeLayout.setSpacing(true); attributeLayout.setMargin(true); attributeLayout.setSizeFull(); m_attributeKeyTextField = new TextField("Key"); m_attributeKeyTextField.setEnabled(false); m_attributeValueTextField = new TextField("Value (REGEXP)"); m_attributeValueTextField.setEnabled(false); addToComponent(attributeLayout, m_filterByAttributeCheckBox); addToComponent(attributeLayout, m_attributeKeyTextField); addToComponent(attributeLayout, m_attributeValueTextField); Panel attributePanel = new Panel(); attributePanel.setCaption("Filter by Attribute"); attributePanel.setContent(attributeLayout); m_filterByAttributeCheckBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { m_attributeKeyTextField.setEnabled(m_filterByAttributeCheckBox.getValue()); m_attributeValueTextField.setEnabled(m_filterByAttributeCheckBox.getValue()); } }); m_attributeKeyTextField.setValue(attributeKey); m_attributeValueTextField.setValue(attributeValue); m_filterByAttributeCheckBox.setValue(filterByAttribute); /** * Adding the "Filter By Severity" panel */ m_filterBySeverityCheckBox = new CheckBox(); m_filterBySeverityCheckBox.setCaption("Enable"); m_filterBySeverityCheckBox.setDescription("Filter by Business Service severity"); VerticalLayout severityLayout = new VerticalLayout(); severityLayout.setSpacing(true); severityLayout.setMargin(true); severityLayout.setSizeFull(); m_severitySelect = new NativeSelect("Severity"); m_severitySelect.setEnabled(false); m_severitySelect.setNullSelectionAllowed(false); m_severitySelect.setMultiSelect(false); for (Status eachStatus : Status.values()) { m_severitySelect.addItem(eachStatus.name()); } m_compareOperatorSelect = new NativeSelect("Comparator"); m_compareOperatorSelect.setEnabled(false); m_compareOperatorSelect.setNullSelectionAllowed(false); m_compareOperatorSelect.setMultiSelect(false); m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Lower.name()); m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.LowerOrEqual.name()); m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Equal.name()); m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name()); m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Greater.name()); addToComponent(severityLayout, m_filterBySeverityCheckBox); addToComponent(severityLayout, m_severitySelect); addToComponent(severityLayout, m_compareOperatorSelect); Panel severityPanel = new Panel(); severityPanel.setCaption("Filter by Severity"); severityPanel.setContent(severityLayout); m_filterBySeverityCheckBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { m_severitySelect.setEnabled(m_filterBySeverityCheckBox.getValue()); m_compareOperatorSelect.setEnabled(m_filterBySeverityCheckBox.getValue()); } }); m_severitySelect.setValue(severityValue); m_compareOperatorSelect.setValue(severityCompareOperator); m_filterBySeverityCheckBox.setValue(filterBySeverity); /** * Adding the "Results" panel */ VerticalLayout limitLayout = new VerticalLayout(); limitLayout.setSpacing(true); limitLayout.setMargin(true); limitLayout.setSizeFull(); m_limitTextField = new TextField("Limit"); m_orderBy = new NativeSelect("Order by"); m_orderBy.setNullSelectionAllowed(false); m_orderBy.setMultiSelect(false); m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Name.name()); m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Severity.name()); m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Level.name()); m_orderSequence = new NativeSelect("Asc/Desc "); m_orderSequence.setNullSelectionAllowed(false); m_orderSequence.setMultiSelect(false); m_orderSequence.addItem("Ascending"); m_orderSequence.addItem("Descending"); m_columnCountBoardTextField = new TextField("Ops Board Column Count"); m_columnCountBoardTextField.addValidator(new AbstractStringValidator("Number greater zero expected") { @Override protected boolean isValidValue(String value) { try { int i = Integer.parseInt(value); return i > 0; } catch (NumberFormatException e) { return false; } } }); m_columnCountPanelTextField = new TextField("Ops Panel Column Count"); m_columnCountPanelTextField.addValidator(new AbstractStringValidator("Number greater zero expected") { @Override protected boolean isValidValue(String value) { try { int i = Integer.parseInt(value); return i > 0; } catch (NumberFormatException e) { return false; } } }); addToComponent(limitLayout, m_limitTextField); addToComponent(limitLayout, m_orderBy); addToComponent(limitLayout, m_orderSequence); addToComponent(limitLayout, m_columnCountBoardTextField); addToComponent(limitLayout, m_columnCountPanelTextField); Panel limitPanel = new Panel(); limitPanel.setSizeFull(); limitPanel.setCaption("Results"); limitPanel.setContent(limitLayout); m_limitTextField.setValue(String.valueOf(resultsLimit)); m_orderBy.setValue(orderBy); m_orderSequence.setValue(orderSequence); m_columnCountBoardTextField.setValue(String.valueOf(columnCountBoard)); m_columnCountPanelTextField.setValue(String.valueOf(columnCountPanel)); m_limitTextField.addValidator(new AbstractStringValidator("Number greater or equal zero expected") { @Override protected boolean isValidValue(String value) { try { int i = Integer.parseInt(value); return i >= 0; } catch (NumberFormatException e) { return false; } } }); /** * Create the main layout... */ VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth(100, Unit.PERCENTAGE); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); verticalLayout.addComponent(namePanel); verticalLayout.addComponent(attributePanel); HorizontalLayout bottomLayout = new HorizontalLayout(severityPanel, limitPanel); bottomLayout.setSpacing(true); bottomLayout.setSizeFull(); bottomLayout.setWidth(100, Unit.PERCENTAGE); verticalLayout.addComponent(bottomLayout); /** * Using an additional {@link HorizontalLayout} for layouting the buttons */ HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); Label label = new Label("Note: Multiple enabled filter constraints will be combined by a logical AND."); buttonLayout.addComponent(label); buttonLayout.setExpandRatio(label, 1.0f); /** * Adding the cancel button... */ Button cancel = new Button("Cancel"); cancel.setDescription("Cancel editing"); cancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); buttonLayout.addComponent(cancel); buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT); /** * ...and the OK button */ Button ok = new Button("Save"); ok.setDescription("Save properties and close"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!m_limitTextField.isValid() || !m_columnCountPanelTextField.isValid() || !m_columnCountBoardTextField.isValid()) { return; } m_dashletSpec.getParameters().put("filterByName", (m_filterByNameCheckBox.getValue() ? "true" : "false")); if (m_filterByNameCheckBox.getValue()) { m_dashletSpec.getParameters().put("nameValue", m_nameTextField.getValue()); } else { m_dashletSpec.getParameters().put("nameValue", ""); } m_dashletSpec.getParameters().put("filterByAttribute", (m_filterByAttributeCheckBox.getValue() ? "true" : "false")); if (m_filterByAttributeCheckBox.getValue()) { m_dashletSpec.getParameters().put("attributeKey", m_attributeKeyTextField.getValue()); m_dashletSpec.getParameters().put("attributeValue", m_attributeValueTextField.getValue()); } else { m_dashletSpec.getParameters().put("attributeKey", ""); m_dashletSpec.getParameters().put("attributeValue", ""); } m_dashletSpec.getParameters().put("filterBySeverity", (m_filterBySeverityCheckBox.getValue() ? "true" : "false")); if (m_filterBySeverityCheckBox.getValue() && m_severitySelect.getValue() != null) { m_dashletSpec.getParameters().put("severityValue", m_severitySelect.getValue().toString()); } else { m_dashletSpec.getParameters().put("severityValue", Status.WARNING.getLabel()); } if (m_filterBySeverityCheckBox.getValue() && m_compareOperatorSelect.getValue() != null) { m_dashletSpec.getParameters().put("severityCompareOperator", m_compareOperatorSelect.getValue().toString()); } else { m_dashletSpec.getParameters().put("severityCompareOperator", BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name()); } if (m_orderBy.getValue() != null) { m_dashletSpec.getParameters().put("orderBy", m_orderBy.getValue().toString()); } else { m_dashletSpec.getParameters().put("orderBy", BusinessServiceSearchCriteriaBuilder.Order.Name.name()); } if (m_orderSequence.getValue() != null) { m_dashletSpec.getParameters().put("orderSequence", m_orderSequence.getValue().toString()); } else { m_dashletSpec.getParameters().put("orderSequence", "Ascending"); } m_dashletSpec.getParameters().put("resultsLimit", m_limitTextField.getValue().toString()); m_dashletSpec.getParameters().put("columnCountBoard", m_columnCountBoardTextField.getValue().toString()); m_dashletSpec.getParameters().put("columnCountPanel", m_columnCountPanelTextField.getValue().toString()); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties"); close(); } }); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonLayout.addComponent(ok); /** * Adding the layout and setting the content */ verticalLayout.addComponent(buttonLayout); setContent(verticalLayout); }
From source file:org.opennms.features.vaadin.dashboard.dashlets.ChartsConfigurationWindow.java
License:Open Source License
/** * Constructor for instantiating new objects of this class. * * @param dashletSpec the {@link DashletSpec} to be edited *///from w w w . j av a 2 s.c o m public ChartsConfigurationWindow(DashletSpec dashletSpec) { /** * Setting the members */ m_dashletSpec = dashletSpec; /** * Setting up the base layouts */ setHeight(410, Unit.PIXELS); setWidth(40, Unit.PERCENTAGE); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth(100, Unit.PERCENTAGE); horizontalLayout.setSpacing(true); horizontalLayout.setMargin(true); FormLayout formLayout = new FormLayout(); formLayout.setWidth(100, Unit.PERCENTAGE); formLayout.setSpacing(true); formLayout.setMargin(true); /** * Adding the checkboxes */ m_maximizeWidth = new CheckBox(); m_maximizeWidth.setCaption("Maximize width"); m_maximizeWidth.setDescription("Maximize width"); m_maximizeHeight = new CheckBox(); m_maximizeHeight.setCaption("Maximize height"); m_maximizeHeight.setDescription("Maximize height"); String maximizeWidthString = m_dashletSpec.getParameters().get("maximizeWidth"); String maximizeHeightString = m_dashletSpec.getParameters().get("maximizeHeight"); boolean maximizeHeight = ("true".equals(maximizeHeightString) || "yes".equals(maximizeHeightString) || "1".equals(maximizeHeightString)); boolean maximizeWidth = ("true".equals(maximizeWidthString) || "yes".equals(maximizeWidthString) || "1".equals(maximizeWidthString)); m_maximizeWidth.setValue(maximizeWidth); m_maximizeHeight.setValue(maximizeHeight); m_chartSelect = new NativeSelect(); m_chartSelect.setDescription("Select chart to be displayed"); m_chartSelect.setCaption("Chart"); m_chartSelect.setNullSelectionAllowed(false); m_chartSelect.setInvalidAllowed(false); m_chartSelect.setNewItemsAllowed(false); String firstChartName = null; try { Iterator<BarChart> it = ChartUtils.getChartCollectionIterator(); while (it.hasNext()) { BarChart chartConfig = (BarChart) it.next(); if (firstChartName == null) { firstChartName = chartConfig.getName(); } m_chartSelect.addItem(chartConfig.getName()); } } catch (Exception e) { e.printStackTrace(); } String chartName = m_dashletSpec.getParameters().get("chart"); if (chartName == null || "".equals(chartName)) { chartName = firstChartName; } final Panel panel = new Panel(); panel.setWidth(230, Unit.PIXELS); panel.setCaption("Preview"); formLayout.addComponent(m_chartSelect); Page.getCurrent().getStyles().add(".preview { width:225px; }"); m_chartSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String newImage = "/opennms/charts?chart-name=" + valueChangeEvent.getProperty().getValue(); Image image = new Image(null, new ExternalResource(newImage)); image.setStyleName("preview"); panel.setContent(image); } }); m_chartSelect.setValue(chartName); m_chartSelect.setImmediate(true); formLayout.addComponent(m_maximizeWidth); formLayout.addComponent(m_maximizeHeight); horizontalLayout.addComponent(formLayout); horizontalLayout.addComponent(panel); /** * Using an additional {@link com.vaadin.ui.HorizontalLayout} for layouting the buttons */ HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); /** * Adding the cancel button... */ Button cancel = new Button("Cancel"); cancel.setDescription("Cancel editing"); cancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); buttonLayout.addComponent(cancel); buttonLayout.setExpandRatio(cancel, 1.0f); buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT); /** * ...and the OK button */ Button ok = new Button("Save"); ok.setDescription("Save properties and close"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_dashletSpec.getParameters().put("maximizeWidth", (m_maximizeWidth.getValue() ? "true" : "false")); m_dashletSpec.getParameters().put("maximizeHeight", (m_maximizeHeight.getValue() ? "true" : "false")); m_dashletSpec.getParameters().put("chart", String.valueOf(m_chartSelect.getValue())); WallboardProvider.getInstance().save(); ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties"); close(); } }); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonLayout.addComponent(ok); /** * Adding the layout and setting the content */ //verticalLayout.addComponent(buttonLayout); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponent(horizontalLayout); verticalLayout.addComponent(buttonLayout); setContent(verticalLayout); }
From source file:org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.NameEditForm.java
License:Open Source License
private void initFields() { nonEditableField = new TextField(); nonEditableField.setWidth(400, Unit.PIXELS); nonEditableField.setReadOnly(true);//from w w w . ja va 2 s.c om nonEditableField.setEnabled(false); editableField = new TextField(); editableField.setWidth(400, Unit.PIXELS); editableField.setRequired(true); editableField.setRequiredError("You must provide a value."); editableField.setValidationVisible(false); editableField.setBuffered(false); editableField.setImmediate(true); editableField.addValidator(nameValidator); editableField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (!blockListenerOrValidators) { controller.validateCurrentSelection(); } } }); editableField.setTextChangeTimeout(200); editableField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { editableField.setComponentError(null); editableField.setValue(event.getText()); editableField.validate(); } }); selectedField = new CheckBox(); selectedField.setCaption("selected"); selectedField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateEnabledState(); if (!selectedField.getValue()) { editableField.discard(); } if (!blockListenerOrValidators) { try { blockListenerOrValidators = true; controller.fireSelectionValueChanged(getData(), getItemId(), selectedField.getValue()); } finally { blockListenerOrValidators = false; } } } }); contentLayout.addComponent(selectedField); contentLayout.addComponent(editableField); contentLayout.addComponent(nonEditableField); }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewsConfigList.java
License:Open Source License
/** * Constructor for creating this component. * * @param surveillanceViewService the surveillance view service to be used */// w w w.j av a 2s . c om public SurveillanceViewsConfigList(SurveillanceViewService surveillanceViewService) { /** * set the fields */ this.m_surveillanceViewService = surveillanceViewService; /** * Loading the config */ reloadSurveillanceViews(); /** * Setting up the layout component */ setSizeFull(); setMargin(true); setSpacing(true); Label label = new Label("Surveillance View Configurations"); label.addStyleName("configuration-title"); /* Button button = new Button("Help"); button.setStyleName("small"); button.setDescription("Display help and usage"); */ /** * button.addClickListener(new HelpClickListener(this, m_wallboardConfigView.getDashletSelector())); */ Button addButton = new Button("Add"); addButton.setStyleName("small"); addButton.setDescription("Add surveillance view configuration"); addButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String newName; int i = 0; do { i++; newName = "Untitled #" + i; } while (SurveillanceViewProvider.getInstance().containsView(newName)); View view = new View(); view.setName(newName); getUI().addWindow(new SurveillanceViewConfigurationWindow(m_surveillanceViewService, view, new SurveillanceViewConfigurationWindow.SaveActionListener() { @Override public void save(View view) { m_beanItemContainer.addItem(view); SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getViews() .add(view); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Surveillance View"); m_table.refreshRowCache(); m_table.sort(new Object[] { "name" }, new boolean[] { true }); } })); } }); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(label); // horizontalLayout.addComponent(button); horizontalLayout.setWidth(100, Unit.PERCENTAGE); horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); // horizontalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); addComponent(horizontalLayout); addComponent(addButton); /** * Adding the table with the required {@link com.vaadin.ui.Table.ColumnGenerator} objects */ m_table = new Table(); m_table.setContainerDataSource(m_beanItemContainer); m_table.setSizeFull(); m_table.sort(new Object[] { "name" }, new boolean[] { true }); m_table.addGeneratedColumn("Edit", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Edit"); button.setDescription("Edit this Surveillance View configuration"); button.setStyleName("small"); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { getUI().addWindow(new SurveillanceViewConfigurationWindow(m_surveillanceViewService, m_beanItemContainer.getItem(itemId).getBean(), new SurveillanceViewConfigurationWindow.SaveActionListener() { @Override public void save(View view) { View oldView = m_beanItemContainer.getItem(itemId).getBean(); m_beanItemContainer.removeItem(itemId); m_beanItemContainer.addItem(view); SurveillanceViewProvider.getInstance().replaceView(oldView, view); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Surveillance view"); m_table.refreshRowCache(); m_table.sort(new Object[] { "name" }, new boolean[] { true }); } })); } }); return button; } } ); m_table.addGeneratedColumn("Remove", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Remove"); button.setDescription("Delete this Surveillance View configuration"); button.setStyleName("small"); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { SurveillanceViewProvider.getInstance().removeView((View) itemId); m_beanItemContainer.removeItem(itemId); } }); return button; } }); m_table.addGeneratedColumn("Preview", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Preview"); button.setDescription("Preview this Surveillance View configuration"); button.setStyleName("small"); button.addClickListener(new PreviewClickListener(m_surveillanceViewService, SurveillanceViewsConfigList.this, (View) itemId)); return button; } } ); m_table.addGeneratedColumn("Default", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Surveillance View configuration the default"); final View view = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration() .getDefaultView().equals(view.getName())); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration() .setDefaultView(view.getName()); } m_table.refreshRowCache(); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Default surveillance view"); } }); return checkBox; } } ); m_table.setVisibleColumns(new Object[] { "name", "Edit", "Remove", "Preview", "Default" }); m_table.setColumnHeader("name", "Name"); /** * Adding the table */ addComponent(m_table); setExpandRatio(m_table, 1.0f); }