List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:org.opennms.features.vaadin.mibcompiler.MibCompilerPanel.java
License:Open Source License
/** * Instantiates a new MIB tree panel./* ww w . j a v a 2 s.c o m*/ * * @param dataCollectionDao the OpenNMS Data Collection Configuration DAO * @param eventsDao the OpenNMS Events Configuration DAO * @param eventsProxy the OpenNMS Events Proxy * @param mibParser the MIB parser * @param logger the logger */ public MibCompilerPanel(final DataCollectionConfigDao dataCollectionDao, final EventConfDao eventsDao, final EventProxy eventsProxy, final MibParser mibParser, final Logger logger) { super("MIB Compiler"); if (dataCollectionDao == null) throw new RuntimeException("dataCollectionDao cannot be null."); if (eventsProxy == null) throw new RuntimeException("eventProxy cannot be null."); if (eventsDao == null) throw new RuntimeException("eventsDao cannot be null."); this.eventsDao = eventsDao; this.eventsProxy = eventsProxy; this.dataCollectionDao = dataCollectionDao; logger.info("Reading MIBs from " + MIBS_ROOT_DIR); // Make sure MIB directories exist if (!MIBS_COMPILED_DIR.exists()) { if (!MIBS_COMPILED_DIR.mkdirs()) { throw new RuntimeException( "Unable to create directory for compiled MIBs (" + MIBS_COMPILED_DIR + ")"); } } if (!MIBS_PENDING_DIR.exists()) { if (!MIBS_PENDING_DIR.mkdirs()) { throw new RuntimeException( "Unable to create directory for pending MIBs (" + MIBS_PENDING_DIR + ")"); } } // Parser Configuration this.mibParser = mibParser; mibParser.setMibDirectory(MIBS_COMPILED_DIR); // Initialize Toolbar MibUploadButton upload = new MibUploadButton(MIBS_PENDING_DIR, MIBS_COMPILED_DIR, logger) { @Override public void uploadHandler(String filename) { addTreeItem(filename, PENDING); } }; VerticalLayout layout = new VerticalLayout(); layout.addComponent(upload); // Initialize MIB Tree mibsTree = new Tree("MIB Tree"); initMibTree(logger); final Label label = new Label( "<p>Use the right-click context menu over the MIB tree files, to display the compiler operations.</p>"); label.setContentMode(ContentMode.HTML); layout.addComponent(label); layout.addComponent(mibsTree); // Panel Setup setSizeFull(); addStyleName("light"); layout.setComponentAlignment(upload, Alignment.TOP_RIGHT); layout.setExpandRatio(mibsTree, 1); setContent(layout); }
From source file:org.opennms.features.vaadin.mibcompiler.MibConsolePanel.java
License:Open Source License
/** * Instantiates a new MIB Console Panel. *///from w w w. ja v a2 s .co m public MibConsolePanel() { super("MIB Console"); addStyleName("light"); Button clearButton = new Button("Clear Log"); clearButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { logContent.removeAllComponents(); } }); VerticalLayout layout = new VerticalLayout(); layout.addComponent(clearButton); layout.setComponentAlignment(clearButton, Alignment.TOP_RIGHT); logContent = new VerticalLayout(); layout.addComponent(logContent); setSizeFull(); setContent(layout); }
From source file:org.opennms.features.vaadin.nodemaps.internal.InvalidConfigurationWindow.java
License:Open Source License
public InvalidConfigurationWindow() { setModal(true);// w ww .j a v a 2s .co m setResizable(false); setWidth(500, Unit.PIXELS); setHeight(250, Unit.PIXELS); setCaption("Configuration Error"); final Button btnClose = new Button("OK", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); final String errorMessage = getErrorLabel(); final Label label = new Label(errorMessage, ContentMode.HTML); VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSpacing(true); rootLayout.setMargin(true); rootLayout.addComponent(label); rootLayout.addComponent(btnClose); rootLayout.setExpandRatio(label, 1.0f); rootLayout.setComponentAlignment(btnClose, Alignment.BOTTOM_RIGHT); setContent(rootLayout); center(); }
From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceEdgeEditWindow.java
License:Open Source License
/** * Constructor//from w w w .j a v a 2 s. c o m * * @param businessService the Business Service DTO instance to be configured * @param businessServiceManager the Business Service Manager */ @SuppressWarnings("unchecked") public BusinessServiceEdgeEditWindow(final BusinessService businessService, final BusinessServiceManager businessServiceManager, final Edge edge) { super("Business Service Edge Edit"); /** * Basic window setup */ setModal(true); setClosable(false); setResizable(false); setWidth(650, Unit.PIXELS); setHeight(325, Unit.PIXELS); /** * Creating the root layout... */ final VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSpacing(true); rootLayout.setMargin(false); /** * ...and the nested layout */ final FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setMargin(true); /** * type selector box */ m_typeSelect = new NativeSelect("Type"); m_typeSelect.setId("edgeTypeSelector"); m_typeSelect.setMultiSelect(false); m_typeSelect.setNewItemsAllowed(false); m_typeSelect.setNullSelectionAllowed(false); m_typeSelect.setRequired(true); m_typeSelect.addItem(EdgeType.CHILD_SERVICE); m_typeSelect.setItemCaption(EdgeType.CHILD_SERVICE, "Child Service"); m_typeSelect.addItem(EdgeType.IP_SERVICE); m_typeSelect.setItemCaption(EdgeType.IP_SERVICE, "IP Service"); m_typeSelect.addItem(EdgeType.REDUCTION_KEY); m_typeSelect.setItemCaption(EdgeType.REDUCTION_KEY, "Reduction Key"); m_typeSelect.setWidth(100.0f, Unit.PERCENTAGE); formLayout.addComponent(m_typeSelect); // List of child services m_childServiceComponent = new ComboBox("Child Service"); m_childServiceComponent.setId("childServiceList"); m_childServiceComponent.setInputPrompt("No child service selected"); m_childServiceComponent.setNewItemsAllowed(false); m_childServiceComponent.setNullSelectionAllowed(false); m_childServiceComponent.setWidth(100.0f, Unit.PERCENTAGE); m_childServiceComponent.setVisible(false); m_childServiceComponent.setImmediate(true); m_childServiceComponent.setValidationVisible(true); m_childServiceComponent.setFilteringMode(FilteringMode.CONTAINS); m_childServiceComponent.addItems(businessServiceManager.getFeasibleChildServices(businessService).stream() .sorted(Ordering.natural().onResultOf(s -> BusinessServiceEditWindow.describeBusinessService(s))) .collect(Collectors.toList())); m_childServiceComponent.getItemIds().forEach(item -> m_childServiceComponent.setItemCaption(item, BusinessServiceEditWindow.describeBusinessService((BusinessService) item))); formLayout.addComponent(m_childServiceComponent); // List of IP services m_ipServiceComponent = new ComboBox("IP Service"); m_ipServiceComponent.setId("ipServiceList"); m_ipServiceComponent.setInputPrompt("No IP service selected"); m_ipServiceComponent.setNewItemsAllowed(false); m_ipServiceComponent.setNullSelectionAllowed(false); m_ipServiceComponent.setWidth(100.0f, Unit.PERCENTAGE); m_ipServiceComponent.setVisible(false); m_ipServiceComponent.setImmediate(true); m_ipServiceComponent.setValidationVisible(true); m_ipServiceComponent.setFilteringMode(FilteringMode.CONTAINS); m_ipServiceComponent.addItems(businessServiceManager.getAllIpServices().stream() .sorted(Ordering.natural().onResultOf(s -> BusinessServiceEditWindow.describeIpService(s))) .collect(Collectors.toList())); m_ipServiceComponent.getItemIds().forEach(item -> m_ipServiceComponent.setItemCaption(item, BusinessServiceEditWindow.describeIpService((IpService) item))); formLayout.addComponent(m_ipServiceComponent); /** * reduction key input field */ m_reductionKeyComponent = new TextField("Reduction Key"); m_reductionKeyComponent.setId("reductionKeyField"); m_reductionKeyComponent.setWidth(100.0f, Unit.PERCENTAGE); m_reductionKeyComponent.setVisible(false); m_reductionKeyComponent.setImmediate(true); m_reductionKeyComponent.setValidationVisible(true); formLayout.addComponent(m_reductionKeyComponent); /** * the friendly name */ m_friendlyNameField = new TextField("Friendly Name"); m_friendlyNameField.setId("friendlyNameField"); m_friendlyNameField.setWidth(100.0f, Unit.PERCENTAGE); m_friendlyNameField.setVisible(false); m_friendlyNameField.setImmediate(true); m_friendlyNameField.setValidationVisible(true); m_friendlyNameField.setNullSettingAllowed(true); m_friendlyNameField.setNullRepresentation(""); m_friendlyNameField.setMaxLength(FRIENDLY_NAME_MAXLENGTH); formLayout.addComponent(m_friendlyNameField); /** * show and hide components */ m_typeSelect.addValueChangeListener(event -> { m_childServiceComponent.setVisible(m_typeSelect.getValue() == EdgeType.CHILD_SERVICE); m_childServiceComponent.setRequired(m_typeSelect.getValue() == EdgeType.CHILD_SERVICE); m_ipServiceComponent.setVisible(m_typeSelect.getValue() == EdgeType.IP_SERVICE); m_ipServiceComponent.setRequired(m_typeSelect.getValue() == EdgeType.IP_SERVICE); m_reductionKeyComponent.setVisible(m_typeSelect.getValue() == EdgeType.REDUCTION_KEY); m_reductionKeyComponent.setRequired(m_typeSelect.getValue() == EdgeType.REDUCTION_KEY); m_friendlyNameField.setVisible(m_typeSelect.getValue() == EdgeType.REDUCTION_KEY || m_typeSelect.getValue() == EdgeType.IP_SERVICE); }); /** * map function field */ m_mapFunctionSelect = new NativeSelect("Map Function", ImmutableList.builder().add(Decrease.class) .add(Identity.class).add(Ignore.class).add(Increase.class).add(SetTo.class).build()); m_mapFunctionSelect.setId("mapFunctionSelector"); m_mapFunctionSelect.setNullSelectionAllowed(false); m_mapFunctionSelect.setMultiSelect(false); m_mapFunctionSelect.setNewItemsAllowed(false); m_mapFunctionSelect.setRequired(true); m_mapFunctionSelect.setWidth(100.0f, Unit.PERCENTAGE); /** * setting the captions for items */ m_mapFunctionSelect.getItemIds() .forEach(itemId -> m_mapFunctionSelect.setItemCaption(itemId, ((Class<?>) itemId).getSimpleName())); formLayout.addComponent(m_mapFunctionSelect); /** * severity selection field */ m_mapFunctionSeveritySelect = new NativeSelect("Severity"); m_mapFunctionSeveritySelect.setMultiSelect(false); m_mapFunctionSeveritySelect.setNewItemsAllowed(false); m_mapFunctionSeveritySelect.setNullSelectionAllowed(false); m_mapFunctionSeveritySelect.setRequired(false); m_mapFunctionSeveritySelect.addItem(Status.CRITICAL); m_mapFunctionSeveritySelect.setItemCaption(Status.CRITICAL, "Critical"); m_mapFunctionSeveritySelect.addItem(Status.MAJOR); m_mapFunctionSeveritySelect.setItemCaption(Status.MAJOR, "Major"); m_mapFunctionSeveritySelect.addItem(Status.MINOR); m_mapFunctionSeveritySelect.setItemCaption(Status.MINOR, "Minor"); m_mapFunctionSeveritySelect.addItem(Status.WARNING); m_mapFunctionSeveritySelect.setItemCaption(Status.WARNING, "Warning"); m_mapFunctionSeveritySelect.addItem(Status.NORMAL); m_mapFunctionSeveritySelect.setItemCaption(Status.NORMAL, "Normal"); m_mapFunctionSeveritySelect.addItem(Status.INDETERMINATE); m_mapFunctionSeveritySelect.setItemCaption(Status.INDETERMINATE, "Indeterminate"); m_mapFunctionSeveritySelect.setWidth(100.0f, Unit.PERCENTAGE); m_mapFunctionSeveritySelect.setEnabled(false); m_mapFunctionSeveritySelect.setImmediate(true); m_mapFunctionSeveritySelect.setValidationVisible(true); formLayout.addComponent(m_mapFunctionSeveritySelect); /** * hide or show additional severity input field */ m_mapFunctionSelect.addValueChangeListener(event -> { m_mapFunctionSeveritySelect.setEnabled(SetTo.class.equals(m_mapFunctionSelect.getValue())); m_mapFunctionSeveritySelect.setRequired(SetTo.class.equals(m_mapFunctionSelect.getValue())); }); /** * the weight input field */ m_weightField = new TextField("Weight"); m_weightField.setId("weightField"); m_weightField.setRequired(true); m_weightField.setWidth(100.0f, Unit.PERCENTAGE); m_weightField.addValidator(value -> { try { int intValue = Integer.parseInt((String) value); if (intValue <= 0) { throw new Validator.InvalidValueException("Weight must be > 0"); } } catch (final NumberFormatException e) { throw new Validator.InvalidValueException("Weight must be a number"); } }); m_weightField.setImmediate(true); m_weightField.setValidationVisible(true); formLayout.addComponent(m_weightField); /** * setting the defaults */ m_typeSelect.setValue(EdgeType.CHILD_SERVICE); m_mapFunctionSelect.setValue(Identity.class); m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE); m_weightField.setValue(Integer.toString(Edge.DEFAULT_WEIGHT)); /** * add the button layout... */ final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setMargin(true); /** * ...and the save button */ final Button saveButton = new Button(edge == null ? "Add Edge" : "Update Edge"); saveButton.setId("saveEdgeButton"); saveButton.addClickListener(UIHelper.getCurrent(TransactionAwareUI.class) .wrapInTransactionProxy((Button.ClickListener) event -> { if (!m_weightField.isValid()) return; if (!m_ipServiceComponent.isValid()) return; if (!m_childServiceComponent.isValid()) return; if (!m_reductionKeyComponent.isValid()) return; final MapFunction mapFunction = getMapFunction(); final int weight = Integer.parseInt(m_weightField.getValue()); /** * in the case edge is not null, remove the old object... */ if (edge != null) { businessService.removeEdge(edge); } /** * ...and add the new edge */ switch ((EdgeType) m_typeSelect.getValue()) { case CHILD_SERVICE: businessService.addChildEdge((BusinessService) m_childServiceComponent.getValue(), mapFunction, weight); break; case IP_SERVICE: businessService.addIpServiceEdge((IpService) m_ipServiceComponent.getValue(), mapFunction, weight, m_friendlyNameField.getValue()); break; case REDUCTION_KEY: businessService.addReductionKeyEdge(m_reductionKeyComponent.getValue(), mapFunction, weight, m_friendlyNameField.getValue()); break; } close(); })); buttonLayout.addComponent(saveButton); /** * ...and a cancel button */ final Button cancelButton = new Button("Cancel"); cancelButton.setId("cancelEdgeButton"); cancelButton.addClickListener((Button.ClickListener) event -> close()); buttonLayout.addComponent(cancelButton); /** * when edge is not null, fill the components with values */ if (edge != null) { edge.accept(new EdgeVisitor<Void>() { @Override public Void visit(IpServiceEdge edge) { m_typeSelect.setValue(EdgeType.IP_SERVICE); for (IpService ipService : (Collection<IpService>) m_ipServiceComponent.getItemIds()) { if (ipService.getId() == edge.getIpService().getId()) { m_ipServiceComponent.setValue(ipService); break; } } m_friendlyNameField.setValue(edge.getFriendlyName()); m_ipServiceComponent.setEnabled(false); return null; } @Override public Void visit(ReductionKeyEdge edge) { m_typeSelect.setValue(EdgeType.REDUCTION_KEY); m_reductionKeyComponent.setValue(edge.getReductionKey()); m_friendlyNameField.setValue(edge.getFriendlyName()); m_reductionKeyComponent.setEnabled(false); return null; } @Override public Void visit(ChildEdge edge) { m_typeSelect.setValue(EdgeType.CHILD_SERVICE); m_childServiceComponent.setValue(edge.getChild()); m_childServiceComponent.setEnabled(false); return null; } }); m_typeSelect.setEnabled(false); m_mapFunctionSelect.setValue(edge.getMapFunction().getClass()); edge.getMapFunction().accept(new MapFunctionVisitor<Void>() { @Override public Void visit(Decrease decrease) { m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE); return null; } @Override public Void visit(Identity identity) { m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE); return null; } @Override public Void visit(Ignore ignore) { m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE); return null; } @Override public Void visit(Increase increase) { m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE); return null; } @Override public Void visit(SetTo setTo) { m_mapFunctionSeveritySelect.setValue(((SetTo) edge.getMapFunction()).getStatus()); return null; } }); m_weightField.setValue(String.valueOf(edge.getWeight())); } /** * now set the root layout */ rootLayout.addComponent(formLayout); rootLayout.addComponent(buttonLayout); rootLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); setContent(rootLayout); }
From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceEditWindow.java
License:Open Source License
/** * Constructor//ww w . j av a2 s . c om * * @param businessService the Business Service DTO instance to be configured */ @SuppressWarnings("unchecked") public BusinessServiceEditWindow(BusinessService businessService, BusinessServiceManager businessServiceManager) { /** * set window title... */ super("Business Service Edit"); m_businessService = businessService; /** * ...and basic properties */ setModal(true); setClosable(false); setResizable(false); setWidth(650, Unit.PIXELS); setHeight(550, Unit.PIXELS); /** * create set for Business Service names */ m_businessServiceNames = businessServiceManager.getAllBusinessServices().stream() .map(BusinessService::getName).collect(Collectors.toSet()); if (m_businessService.getName() != null) { m_businessServiceNames.remove(m_businessService.getName()); } /** * construct the main layout */ VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); /** * add saveBusinessService button */ Button saveButton = new Button("Save"); saveButton.setId("saveButton"); saveButton.addClickListener( UIHelper.getCurrent(TransactionAwareUI.class).wrapInTransactionProxy(new Button.ClickListener() { private static final long serialVersionUID = -5985304347211214365L; @Override public void buttonClick(Button.ClickEvent event) { if (!m_thresholdTextField.isValid() || !m_nameTextField.isValid()) { return; } final ReductionFunction reductionFunction = getReduceFunction(); businessService.setName(m_nameTextField.getValue().trim()); businessService.setReduceFunction(reductionFunction); businessService.save(); close(); } private ReductionFunction getReduceFunction() { try { final ReductionFunction reductionFunction = ((Class<? extends ReductionFunction>) m_reduceFunctionNativeSelect .getValue()).newInstance(); reductionFunction.accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { highestSeverityAbove.setThreshold((Status) m_thresholdStatusSelect.getValue()); return null; } @Override public Void visit(Threshold threshold) { threshold.setThreshold(Float.parseFloat(m_thresholdTextField.getValue())); return null; } }); return reductionFunction; } catch (final InstantiationException | IllegalAccessException e) { throw Throwables.propagate(e); } } })); /** * add the cancel button */ Button cancelButton = new Button("Cancel"); cancelButton.setId("cancelButton"); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 5306168797758047745L; @Override public void buttonClick(Button.ClickEvent event) { close(); } }); /** * add the buttons to a HorizontalLayout */ HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton); buttonLayout.addComponent(cancelButton); /** * instantiate the input fields */ m_nameTextField = new TextField("Business Service Name"); m_nameTextField.setId("nameField"); m_nameTextField.setNullRepresentation(""); m_nameTextField.setNullSettingAllowed(true); m_nameTextField.setValue(businessService.getName()); m_nameTextField.setWidth(100, Unit.PERCENTAGE); m_nameTextField.setRequired(true); m_nameTextField.focus(); m_nameTextField.addValidator(new AbstractStringValidator("Name must be unique") { private static final long serialVersionUID = 1L; @Override protected boolean isValidValue(String value) { return value != null && !m_businessServiceNames.contains(value); } }); verticalLayout.addComponent(m_nameTextField); /** * create the reduce function component */ m_reduceFunctionNativeSelect = new NativeSelect("Reduce Function", ImmutableList.builder() .add(HighestSeverity.class).add(Threshold.class).add(HighestSeverityAbove.class).build()); m_reduceFunctionNativeSelect.setId("reduceFunctionNativeSelect"); m_reduceFunctionNativeSelect.setWidth(100.0f, Unit.PERCENTAGE); m_reduceFunctionNativeSelect.setNullSelectionAllowed(false); m_reduceFunctionNativeSelect.setMultiSelect(false); m_reduceFunctionNativeSelect.setImmediate(true); m_reduceFunctionNativeSelect.setNewItemsAllowed(false); /** * setting the captions for items */ m_reduceFunctionNativeSelect.getItemIds().forEach( itemId -> m_reduceFunctionNativeSelect.setItemCaption(itemId, ((Class<?>) itemId).getSimpleName())); verticalLayout.addComponent(m_reduceFunctionNativeSelect); m_thresholdTextField = new TextField("Threshold"); m_thresholdTextField.setId("thresholdTextField"); m_thresholdTextField.setRequired(false); m_thresholdTextField.setEnabled(false); m_thresholdTextField.setImmediate(true); m_thresholdTextField.setWidth(100.0f, Unit.PERCENTAGE); m_thresholdTextField.setValue("0.0"); m_thresholdTextField.addValidator(v -> { if (m_thresholdTextField.isEnabled()) { try { final float value = Float.parseFloat(m_thresholdTextField.getValue()); if (0.0f >= value || value > 1.0) { throw new NumberFormatException(); } } catch (final NumberFormatException e) { throw new Validator.InvalidValueException("Threshold must be a positive number"); } } }); verticalLayout.addComponent(m_thresholdTextField); /** * Status selection for "Highest Severity Above" */ m_thresholdStatusSelect = new NativeSelect("Threshold"); m_thresholdStatusSelect.setId("thresholdStatusSelect"); m_thresholdStatusSelect.setRequired(false); m_thresholdStatusSelect.setEnabled(false); m_thresholdStatusSelect.setImmediate(true); m_thresholdStatusSelect.setWidth(100.0f, Unit.PERCENTAGE); m_thresholdStatusSelect.setMultiSelect(false); m_thresholdStatusSelect.setNewItemsAllowed(false); m_thresholdStatusSelect.setNullSelectionAllowed(false); for (Status eachStatus : Status.values()) { m_thresholdStatusSelect.addItem(eachStatus); } m_thresholdStatusSelect.setValue(Status.INDETERMINATE); m_thresholdStatusSelect.getItemIds() .forEach(itemId -> m_thresholdStatusSelect.setItemCaption(itemId, ((Status) itemId).getLabel())); verticalLayout.addComponent(m_thresholdStatusSelect); m_reduceFunctionNativeSelect.addValueChangeListener(ev -> { boolean thresholdFunction = m_reduceFunctionNativeSelect.getValue() == Threshold.class; boolean highestSeverityAboveFunction = m_reduceFunctionNativeSelect .getValue() == HighestSeverityAbove.class; setVisible(m_thresholdTextField, thresholdFunction); setVisible(m_thresholdStatusSelect, highestSeverityAboveFunction); }); if (Objects.isNull(businessService.getReduceFunction())) { m_reduceFunctionNativeSelect.setValue(HighestSeverity.class); } else { m_reduceFunctionNativeSelect.setValue(businessService.getReduceFunction().getClass()); businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { m_thresholdStatusSelect.setValue(highestSeverityAbove.getThreshold()); return null; } @Override public Void visit(Threshold threshold) { m_thresholdTextField.setValue(String.valueOf(threshold.getThreshold())); return null; } }); } /** * create the edges list box */ m_edgesListSelect = new ListSelect("Edges"); m_edgesListSelect.setId("edgeList"); m_edgesListSelect.setWidth(100.0f, Unit.PERCENTAGE); m_edgesListSelect.setRows(10); m_edgesListSelect.setNullSelectionAllowed(false); m_edgesListSelect.setMultiSelect(false); refreshEdges(); HorizontalLayout edgesListAndButtonLayout = new HorizontalLayout(); edgesListAndButtonLayout.setWidth(100.0f, Unit.PERCENTAGE); VerticalLayout edgesButtonLayout = new VerticalLayout(); edgesButtonLayout.setWidth(110.0f, Unit.PIXELS); edgesButtonLayout.setSpacing(true); Button addEdgeButton = new Button("Add Edge"); addEdgeButton.setId("addEdgeButton"); addEdgeButton.setWidth(110.0f, Unit.PIXELS); addEdgeButton.addStyleName("small"); edgesButtonLayout.addComponent(addEdgeButton); addEdgeButton.addClickListener((Button.ClickListener) event -> { final BusinessServiceEdgeEditWindow window = new BusinessServiceEdgeEditWindow(businessService, businessServiceManager, null); window.addCloseListener(e -> refreshEdges()); this.getUI().addWindow(window); }); Button editEdgeButton = new Button("Edit Edge"); editEdgeButton.setId("editEdgeButton"); editEdgeButton.setEnabled(false); editEdgeButton.setWidth(110.0f, Unit.PIXELS); editEdgeButton.addStyleName("small"); edgesButtonLayout.addComponent(editEdgeButton); editEdgeButton.addClickListener((Button.ClickListener) event -> { final BusinessServiceEdgeEditWindow window = new BusinessServiceEdgeEditWindow(businessService, businessServiceManager, (Edge) m_edgesListSelect.getValue()); window.addCloseListener(e -> refreshEdges()); this.getUI().addWindow(window); }); final Button removeEdgeButton = new Button("Remove Edge"); removeEdgeButton.setId("removeEdgeButton"); removeEdgeButton.setEnabled(false); removeEdgeButton.setWidth(110.0f, Unit.PIXELS); removeEdgeButton.addStyleName("small"); edgesButtonLayout.addComponent(removeEdgeButton); m_edgesListSelect.addValueChangeListener((Property.ValueChangeListener) event -> { removeEdgeButton.setEnabled(event.getProperty().getValue() != null); editEdgeButton.setEnabled(event.getProperty().getValue() != null); }); removeEdgeButton.addClickListener((Button.ClickListener) event -> { if (m_edgesListSelect.getValue() != null) { removeEdgeButton.setEnabled(false); ((Edge) m_edgesListSelect.getValue()).delete(); refreshEdges(); } }); edgesListAndButtonLayout.setSpacing(true); edgesListAndButtonLayout.addComponent(m_edgesListSelect); edgesListAndButtonLayout.setExpandRatio(m_edgesListSelect, 1.0f); edgesListAndButtonLayout.addComponent(edgesButtonLayout); edgesListAndButtonLayout.setComponentAlignment(edgesButtonLayout, Alignment.BOTTOM_CENTER); verticalLayout.addComponent(edgesListAndButtonLayout); /** * create the attributes list box */ m_attributesListSelect = new ListSelect("Attributes"); m_attributesListSelect.setId("attributeList"); m_attributesListSelect.setWidth(100.0f, Unit.PERCENTAGE); m_attributesListSelect.setRows(10); m_attributesListSelect.setNullSelectionAllowed(false); m_attributesListSelect.setMultiSelect(false); refreshAttributes(); HorizontalLayout attributesListAndButtonLayout = new HorizontalLayout(); attributesListAndButtonLayout.setWidth(100.0f, Unit.PERCENTAGE); VerticalLayout attributesButtonLayout = new VerticalLayout(); attributesButtonLayout.setWidth(110.0f, Unit.PIXELS); attributesButtonLayout.setSpacing(true); Button addAttributeButton = new Button("Add Attribute"); addAttributeButton.setId("addAttributeButton"); addAttributeButton.setWidth(110.0f, Unit.PIXELS); addAttributeButton.addStyleName("small"); attributesButtonLayout.addComponent(addAttributeButton); addAttributeButton.addClickListener((Button.ClickListener) event -> { KeyValueInputDialogWindow keyValueInputDialogWindow = new KeyValueInputDialogWindow() .withKeyFieldName("Key").withValueFieldName("Value").withCaption("Attribute").withKey("") .withValue("").withOkAction(new KeyValueInputDialogWindow.Action() { @Override public void execute(KeyValueInputDialogWindow window) { m_businessService.getAttributes().put(window.getKey(), window.getValue()); refreshAttributes(); } }).withKeyValidator(new AbstractStringValidator("Key must not be empty") { private static final long serialVersionUID = 1L; @Override protected boolean isValidValue(String value) { return !Strings.isNullOrEmpty(value); } }).withKeyValidator(new AbstractStringValidator("Key must be unique") { private static final long serialVersionUID = 1L; @Override protected boolean isValidValue(String value) { return !m_businessService.getAttributes().containsKey(value); } }).focusKey(); this.getUI().addWindow(keyValueInputDialogWindow); keyValueInputDialogWindow.focus(); }); Button editAttributeButton = new Button("Edit Attribute"); editAttributeButton.setId("editAttributeButton"); editAttributeButton.setEnabled(false); editAttributeButton.setWidth(110.0f, Unit.PIXELS); editAttributeButton.addStyleName("small"); attributesButtonLayout.addComponent(editAttributeButton); editAttributeButton.addClickListener((Button.ClickListener) event -> { Map.Entry<String, String> entry = (Map.Entry<String, String>) m_attributesListSelect.getValue(); KeyValueInputDialogWindow keyValueInputDialogWindow = new KeyValueInputDialogWindow() .withKeyFieldName("Key").withValueFieldName("Value").withCaption("Attribute") .withKey(entry.getKey()).disableKey().withValue(entry.getValue()) .withOkAction(new KeyValueInputDialogWindow.Action() { @Override public void execute(KeyValueInputDialogWindow window) { m_businessService.getAttributes().put(window.getKey(), window.getValue()); refreshAttributes(); } }).focusValue(); this.getUI().addWindow(keyValueInputDialogWindow); keyValueInputDialogWindow.focus(); }); final Button removeAttributeButton = new Button("Remove Attribute"); removeAttributeButton.setId("removeAttributeButton"); removeAttributeButton.setEnabled(false); removeAttributeButton.setWidth(110.0f, Unit.PIXELS); removeAttributeButton.addStyleName("small"); attributesButtonLayout.addComponent(removeAttributeButton); m_attributesListSelect.addValueChangeListener((Property.ValueChangeListener) event -> { removeAttributeButton.setEnabled(event.getProperty().getValue() != null); editAttributeButton.setEnabled(event.getProperty().getValue() != null); }); removeAttributeButton.addClickListener((Button.ClickListener) event -> { if (m_attributesListSelect.getValue() != null) { removeAttributeButton.setEnabled(false); m_businessService.getAttributes() .remove(((Map.Entry<String, String>) m_attributesListSelect.getValue()).getKey()); refreshAttributes(); } }); attributesListAndButtonLayout.setSpacing(true); attributesListAndButtonLayout.addComponent(m_attributesListSelect); attributesListAndButtonLayout.setExpandRatio(m_attributesListSelect, 1.0f); attributesListAndButtonLayout.addComponent(attributesButtonLayout); attributesListAndButtonLayout.setComponentAlignment(attributesButtonLayout, Alignment.BOTTOM_CENTER); verticalLayout.addComponent(attributesListAndButtonLayout); /** * now add the button layout to the main layout */ verticalLayout.addComponent(buttonLayout); verticalLayout.setExpandRatio(buttonLayout, 1.0f); verticalLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); /** * set the window's content */ setContent(verticalLayout); }
From source file:org.ow2.sirocco.cloudmanager.AddressAllocationWizard.java
License:Open Source License
public AddressAllocationWizard() { super("Address Allocation"); this.center(); this.setClosable(false); this.setModal(true); this.setResizable(false); VerticalLayout content = new VerticalLayout(); content.setMargin(true);/*ww w.j av a 2 s .c o m*/ this.wizard = new Wizard(); this.wizard.addListener(this); this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement"); this.wizard.setHeight("300px"); this.wizard.setWidth("560px"); content.addComponent(this.wizard); content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER); this.setContent(content); }
From source file:org.ow2.sirocco.cloudmanager.ConfirmDialog.java
License:Open Source License
private ConfirmDialog(final String caption, final String question, final String option, final String okLabel, final String cancelLabel, final ConfirmationDialogCallback callback) { super(caption); this.center(); this.setClosable(false); this.setModal(true); this.setResizable(false); VerticalLayout content = new VerticalLayout(); content.setMargin(true);/* w w w .ja va2 s . c om*/ content.setWidth("400px"); content.setHeight("150px"); this.callback = callback; if (question != null) { Label label = new Label(question); content.addComponent(label); } if (option != null) { this.optionBox = new CheckBox(option); content.addComponent(this.optionBox); } final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); this.okButton = new Button(okLabel, this); this.cancelButton = new Button(cancelLabel, this); this.cancelButton.focus(); buttonLayout.addComponent(this.okButton); buttonLayout.addComponent(this.cancelButton); content.addComponent(buttonLayout); content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); this.setContent(content); }
From source file:org.ow2.sirocco.cloudmanager.KeyPairImportDialog.java
License:Open Source License
public KeyPairImportDialog(final DialogCallback callback) { super("Import Key Pair"); this.callback = callback; this.center(); this.setClosable(false); this.setModal(true); this.setResizable(false); VerticalLayout content = new VerticalLayout(); content.setSizeFull();/*w w w .j a v a2 s. c o m*/ content.setMargin(true); content.setSpacing(true); content.setWidth("500px"); content.setHeight("250px"); FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true); form.setSpacing(true); this.nameField = new TextField("Name"); this.nameField.setWidth("50%"); this.nameField.setRequired(true); this.nameField.setRequiredError("Please enter a name for your key pair"); form.addComponent(this.nameField); this.publicKeyField = new TextArea("Public Key"); this.publicKeyField.setWidth("100%"); this.publicKeyField.setRequired(true); this.publicKeyField.setRequiredError("Please enter a name for your key pair"); form.addComponent(this.publicKeyField); content.addComponent(form); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); this.okButton = new Button("Ok", this); this.cancelButton = new Button("Cancel", this); this.cancelButton.focus(); buttonLayout.addComponent(this.okButton); buttonLayout.addComponent(this.cancelButton); content.addComponent(buttonLayout); content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); this.setContent(content); }
From source file:org.ow2.sirocco.cloudmanager.MachineCreationWizard.java
License:Open Source License
public MachineCreationWizard() { super("Machine Creation"); this.center(); this.setClosable(false); this.setModal(true); this.setResizable(false); VerticalLayout content = new VerticalLayout(); content.setMargin(true);//from w w w . ja va2 s. c o m this.wizard = new Wizard(); this.wizard.addListener(this); this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement"); this.placementStep.setListener(new Property.ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { MachineCreationWizard.this.updateProviderSpecificResources(); } }); this.wizard.addStep(this.metadataStep = new Util.MetadataStep(this.wizard), "metadata"); this.wizard.addStep(this.imageStep = new ImageStep(), "Image"); this.wizard.addStep(this.configStep = new ConfigStep(), "Hardware"); this.wizard.addStep(this.networkStep = new NetworkStep(), "Network"); this.wizard.addStep(this.keyPairStep = new KeyPairStep(), "Key pair"); this.wizard.addStep(this.userDataStep = new UserDataStep(), "User data"); this.wizard.addStep(this.hostPlacementStep = new HostPlacementStep(), "Placement Constraints"); this.wizard.setHeight("300px"); this.wizard.setWidth("700px"); content.addComponent(this.wizard); content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER); this.setContent(content); }
From source file:org.ow2.sirocco.cloudmanager.MachineImageRegisterWizard.java
License:Open Source License
public MachineImageRegisterWizard() { super("Register Image"); this.center(); this.setClosable(false); this.setModal(true); this.setResizable(false); VerticalLayout content = new VerticalLayout(); content.setMargin(true);/*from www .j ava 2s . c o m*/ this.wizard = new Wizard(); this.wizard.addListener(this); this.wizard.addStep(this.placementStep = new Util.PlacementStep(this.wizard), "placement"); this.wizard.addStep(this.imageStep = new ImageStep(), "Image attributes"); this.wizard.setHeight("300px"); this.wizard.setWidth("560px"); content.addComponent(this.wizard); content.setComponentAlignment(this.wizard, Alignment.TOP_CENTER); this.setContent(content); }