List of usage examples for com.vaadin.ui Button setStyleName
@Override public void setStyleName(String style)
From source file:org.opennms.features.topology.app.internal.ui.info.NodeInfoPanelItemProvider.java
License:Open Source License
private Component createComponent(AbstractVertex ref) { Preconditions.checkState(ref.getNodeID() != null, "no Node ID defined."); OnmsNode node = nodeDao.get(ref.getNodeID()); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false);/*from ww w . ja v a2s . co m*/ formLayout.setMargin(false); formLayout.addComponent(createLabel("Node ID", "" + node.getId())); final HorizontalLayout nodeButtonLayout = new HorizontalLayout(); Button nodeButton = createButton(node.getLabel(), null, null, event -> new NodeInfoWindow(ref.getNodeID()).open()); nodeButton.setStyleName(BaseTheme.BUTTON_LINK); nodeButtonLayout.addComponent(nodeButton); nodeButtonLayout.setCaption("Node Label"); formLayout.addComponent(nodeButtonLayout); if (!Strings.isNullOrEmpty(node.getSysObjectId())) { formLayout.addComponent(createLabel("Enterprise OID", node.getSysObjectId())); } return formLayout; }
From source file:org.opennms.features.topology.plugins.browsers.AlarmIdColumnLinkGenerator.java
License:Open Source License
@Override public Object generateCell(final Table source, Object itemId, Object columnId) { if (source == null) return null; // no source Property<Integer> alarmIdProperty = source.getContainerProperty(itemId, alarmIdPropertyName); final Integer alarmId = alarmIdProperty.getValue(); if (alarmId == null) return null; // no value // create Link Button button = new Button("" + alarmId); button.setStyleName(BaseTheme.BUTTON_LINK); button.addClickListener(new ClickListener() { private static final long serialVersionUID = 3698209256202413810L; @Override/* w ww. j av a 2 s . c om*/ public void buttonClick(ClickEvent event) { // try if alarm is there, otherwise show information dialog OnmsAlarm alarm = alarmDao.get(alarmId); if (alarm == null) { new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table."); return; } // alarm still exists, show alarm details final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId; LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment); try { source.getUI().addWindow( new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarmId; } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); return button; }
From source file:org.opennms.features.topology.plugins.browsers.NodeSelectionLinkGenerator.java
License:Open Source License
@Override public Object generateCell(final Table source, final Object itemId, Object columnId) { final Property<Integer> nodeIdProperty = source.getContainerProperty(itemId, m_nodeIdProperty); Object cellValue = m_generator.generateCell(source, itemId, columnId); if (cellValue == null) { return null; } else {/*from ww w . ja v a 2s.c o m*/ if (nodeIdProperty.getValue() == null) { return cellValue; } else { Button button = new Button(cellValue.toString()); button.setStyleName(BaseTheme.BUTTON_LINK); button.setDescription(nodeIdProperty.getValue().toString()); button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Integer nodeId = nodeIdProperty.getValue(); String nodeLabel = (String) source.getContainerProperty(itemId, m_nodeLabelProperty) .getValue(); VertexRef vertexRef = new DefaultVertexRef("nodes", String.valueOf(nodeId), nodeLabel); fireVertexUpdatedEvent(vertexRef); } }); return button; } } }
From source file:org.opennms.features.topology.plugins.topo.application.browsers.ApplicationSelectionLinkGenerator.java
License:Open Source License
@Override public Object generateCell(final Table source, final Object itemId, Object columnId) { final Property<Integer> idProperty = source.getContainerProperty(itemId, idPropertyName); final Property<String> labelProperty = source.getContainerProperty(itemId, labelPropertyName); Object cellValue = columnGenerator.generateCell(source, itemId, columnId); if (cellValue == null) { return null; } else {//from ww w .j a v a 2 s . co m if (idProperty.getValue() == null) { return cellValue; } else { Button button = new Button(cellValue.toString()); button.setStyleName(BaseTheme.BUTTON_LINK); button.setDescription(idProperty.getValue().toString()); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Integer applicationId = idProperty.getValue(); String applicationName = labelProperty.getValue(); ApplicationVertex vertex = new ApplicationVertex(applicationId.toString(), applicationName); fireVertexUpdatedEvent(vertex); } }); return button; } } }
From source file:org.opennms.features.topology.plugins.topo.bsm.browsers.BusinessServicesSelectionLinkGenerator.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public Object generateCell(final Table source, final Object itemId, Object columnId) { final Property<Long> idProperty = source.getContainerProperty(itemId, m_idPropertyName); final Property<String> labelProperty = source.getContainerProperty(itemId, m_labelPropertyName); final Object cellValue = m_columnGenerator.generateCell(source, itemId, columnId); if (cellValue == null) { return null; } else {/* w w w. ja va 2 s. c o m*/ if (idProperty.getValue() == null) { return cellValue; } else { Button button = new Button(cellValue.toString()); button.setStyleName(BaseTheme.BUTTON_LINK); button.setDescription(idProperty.getValue().toString()); button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { Long businessServiceId = idProperty.getValue(); String businessServiceLabel = labelProperty.getValue(); BusinessServiceVertex vertex = new BusinessServiceVertex(businessServiceId, businessServiceLabel, 0 /* does not matter in this case*/); fireVertexUpdatedEvent(vertex); } }); return button; } } }
From source file:org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexInfoPanelItem.java
License:Open Source License
@Override protected Component getComponent(VertexRef ref, GraphContainer container) { final FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false);/* w w w.j a v a 2s .c om*/ formLayout.setMargin(false); ((AbstractBusinessServiceVertex) ref).accept(new BusinessServiceVertexVisitor<Void>() { @Override public Void visit(BusinessServiceVertex vertex) { final BusinessService businessService = businessServiceManager .getBusinessServiceById(vertex.getServiceId()); formLayout.addComponent(createLabel("Reduce function", getReduceFunctionDescription(businessService.getReduceFunction()))); // Apply Reduce Function specific details businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { return null; } @Override // Threshold is not very transparent, we add an Explain Button in these cases public Void visit(Threshold threshold) { final Button explainButton = createButton("Explain", "Explain the Threshold function", FontAwesome.TABLE, (Button.ClickListener) event -> { ThresholdExplanationWindow explainWindow = new ThresholdExplanationWindow( SimulationAwareStateMachineFactory .createSimulatedStateMachine(businessServiceManager, container.getCriteria()) .explain(businessService, (Threshold) businessService.getReduceFunction())); UI.getCurrent().addWindow(explainWindow); }); explainButton.setStyleName(BaseTheme.BUTTON_LINK); formLayout.addComponent(explainButton); return null; } }); return null; } @Override public Void visit(IpServiceVertex vertex) { IpService ipService = businessServiceManager.getIpServiceById(vertex.getIpServiceId()); formLayout.addComponent(createLabel("Interface", ipService.getIpAddress())); formLayout.addComponent(createLabel("Service", ipService.getServiceName())); if (!ipService.getServiceName().equals(vertex.getLabel())) { formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel())); } return null; } @Override public Void visit(ReductionKeyVertex vertex) { formLayout.addComponent(createLabel("Reduction Key", vertex.getReductionKey())); if (!vertex.getReductionKey().equals(vertex.getLabel())) { formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel())); } return null; } }); return formLayout; }
From source file:org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexInfoPanelItemProvider.java
License:Open Source License
private Component createComponent(AbstractBusinessServiceVertex ref, GraphContainer graphContainer) { final FormLayout formLayout = new FormLayout(); formLayout.setSpacing(false);//from w ww . j av a 2 s . c om formLayout.setMargin(false); ref.accept(new BusinessServiceVertexVisitor<Void>() { @Override public Void visit(BusinessServiceVertex vertex) { final BusinessService businessService = businessServiceManager .getBusinessServiceById(vertex.getServiceId()); formLayout.addComponent(createLabel("Reduce function", getReduceFunctionDescription(businessService.getReduceFunction()))); // Apply Reduce Function specific details businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { return null; } @Override // Threshold is not very transparent, we add an Explain Button in these cases public Void visit(Threshold threshold) { final Button explainButton = createButton("Explain", "Explain the Threshold function", FontAwesome.TABLE, (Button.ClickListener) event -> { ThresholdExplanationWindow explainWindow = new ThresholdExplanationWindow( SimulationAwareStateMachineFactory .createSimulatedStateMachine(businessServiceManager, graphContainer.getCriteria()) .explain(businessService, (Threshold) businessService.getReduceFunction())); UI.getCurrent().addWindow(explainWindow); }); explainButton.setStyleName(BaseTheme.BUTTON_LINK); formLayout.addComponent(explainButton); return null; } @Override public Void visit(ExponentialPropagation exponentialPropagation) { return null; } }); return null; } @Override public Void visit(IpServiceVertex vertex) { IpService ipService = businessServiceManager.getIpServiceById(vertex.getIpServiceId()); formLayout.addComponent(createLabel("Interface", ipService.getIpAddress())); formLayout.addComponent(createLabel("Service", ipService.getServiceName())); if (!ipService.getServiceName().equals(vertex.getLabel())) { formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel())); } return null; } @Override public Void visit(ReductionKeyVertex vertex) { formLayout.addComponent(createLabel("Reduction Key", vertex.getReductionKey())); if (!vertex.getReductionKey().equals(vertex.getLabel())) { formLayout.addComponent(createLabel("Friendly Name", vertex.getLabel())); } return null; } }); return formLayout; }
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 *///from w w w. j a v a2 s. c om 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.CriteriaBuilderComponent.java
License:Open Source License
/** * This method updates the criteria components. */// w ww . j a v a 2s.co m private void renderComponents() { m_criteriaLayout.removeAllComponents(); boolean isFirst = true; boolean isLast; for (int i = 0; i < m_criteriaRestrictionComponents.size(); i++) { final CriteriaRestrictionComponent criteriaRestrictionComponent = m_criteriaRestrictionComponents .get(i); final int index = i; isLast = (i == m_criteriaRestrictionComponents.size() - 1); criteriaRestrictionComponent.getRightLayout().removeAllComponents(); Button plusButton = new Button(); plusButton.setStyleName("small"); plusButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png")); plusButton.setDescription("Add a new criteria entry"); Button minusButton = new Button(); minusButton.setStyleName("small"); minusButton.setIcon(new ThemeResource("../runo/icons/16/document-delete.png")); minusButton.setDescription("Remove this criteria entry"); Button upButton = new Button(); upButton.setStyleName("small"); upButton.setIcon(new ThemeResource("../runo/icons/16/arrow-up.png")); upButton.setDescription("Move this a criteria 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 criteria entry one position down"); criteriaRestrictionComponent.getRightLayout().addComponent(upButton); criteriaRestrictionComponent.getRightLayout().addComponent(downButton); criteriaRestrictionComponent.getRightLayout().addComponent(plusButton); criteriaRestrictionComponent.getRightLayout().addComponent(minusButton); if (m_criteriaRestrictionComponents.size() == 1) { minusButton.setEnabled(false); upButton.setEnabled(false); downButton.setEnabled(false); } else { if (isFirst) { upButton.setEnabled(false); } if (isLast) { downButton.setEnabled(false); } } upButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Collections.swap(m_criteriaRestrictionComponents, index, index - 1); renderComponents(); } }); downButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Collections.swap(m_criteriaRestrictionComponents, index, index + 1); renderComponents(); } }); minusButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { m_criteriaRestrictionComponents.remove(criteriaRestrictionComponent); renderComponents(); } }); plusButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent clickEvent) { m_criteriaRestrictionComponents.add(index + 1, new CriteriaRestrictionComponent(m_criteriaBuilderHelper, "Limit(10)")); renderComponents(); } }); isFirst = false; m_criteriaLayout.addComponent(criteriaRestrictionComponent); } }
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 a 2 s . c o m 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); }