List of usage examples for com.vaadin.ui ComboBox addValueChangeListener
@Override
public Registration addValueChangeListener(HasValue.ValueChangeListener<T> listener)
From source file:fi.semantum.strategia.widget.EnumerationDatatype.java
License:Open Source License
@Override public AbstractField<?> getEditor(final Main main, final Base base, final Indicator indicator, final boolean forecast, final CommentCallback callback) { final Object value = forecast ? indicator.getForecast() : indicator.getValue(); final ComboBox combo = new ComboBox(); for (String s : enumeration) { combo.addItem(s);// ww w . j a v a 2 s . com } combo.setStyleName(ValoTheme.COMBOBOX_TINY); combo.select(value); combo.setNullSelectionAllowed(false); combo.setWidth("100%"); if (main.canWrite(base)) { combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3547126051252580446L; @Override public void valueChange(ValueChangeEvent event) { indicator.updateWithComment(main, base, combo.getValue(), forecast, new AbstractCommentCallback() { @Override public void canceled() { combo.select(value); if (callback != null) callback.canceled(); } @Override public void runWithComment(String shortComment, String comment) { if (callback != null) callback.runWithComment(shortComment, comment); } }); } }); } else { combo.setReadOnly(true); } return combo; }
From source file:fi.semantum.strategia.widget.NumberTrafficValuation.java
License:Open Source License
@Override public Runnable getEditor(VerticalLayout layout, final Main main, final Meter meter) { Indicator indicator = meter.getPossibleIndicator(main.getDatabase()); String unit = indicator.getUnit(); final ComboBox combo = new ComboBox("Valitse mittarin mritystapa"); combo.addItem(State.INCREASE3); combo.addItem(State.DECREASE3); combo.addItem(State.INCREASE2); combo.addItem(State.DECREASE2); combo.setInvalidAllowed(false);// w w w . j a va2 s . c om combo.setNullSelectionAllowed(false); combo.setWidth("100%"); combo.addStyleName(ValoTheme.COMBOBOX_TINY); layout.addComponent(combo); layout.setComponentAlignment(combo, Alignment.TOP_CENTER); layout.setExpandRatio(combo, 0.0f); final VerticalLayout vl1 = new VerticalLayout(); vl1.setHeight("50px"); vl1.setWidth("100%"); vl1.setStyleName("redBlock"); layout.addComponent(vl1); layout.setComponentAlignment(vl1, Alignment.TOP_CENTER); layout.setExpandRatio(vl1, 0.0f); final Label l1 = new Label(" > " + df.format(greenLimit.doubleValue()) + " " + unit); l1.setSizeUndefined(); l1.addStyleName(ValoTheme.LABEL_LARGE); vl1.addComponent(l1); vl1.setComponentAlignment(l1, Alignment.MIDDLE_CENTER); HorizontalLayout hl1 = new HorizontalLayout(); hl1.setSpacing(true); layout.addComponent(hl1); layout.setComponentAlignment(hl1, Alignment.TOP_LEFT); final TextField tf1 = new TextField(); tf1.setValue(df.format(greenLimit.doubleValue())); tf1.setWidth("150px"); tf1.setCaption("Suurempi raja-arvo"); tf1.setStyleName(ValoTheme.TEXTFIELD_TINY); tf1.setValidationVisible(true); hl1.addComponent(tf1); Label unit1 = new Label(); unit1.setSizeUndefined(); unit1.setCaption(""); unit1.setValue(unit); hl1.addComponent(unit1); hl1.setComponentAlignment(unit1, Alignment.MIDDLE_LEFT); final VerticalLayout vl2 = new VerticalLayout(); vl2.setHeight("50px"); vl2.setWidth("100%"); vl2.addStyleName("yellowBlock"); layout.addComponent(vl2); layout.setComponentAlignment(vl2, Alignment.TOP_CENTER); layout.setExpandRatio(vl2, 0.0f); final Label l2 = new Label(); l2.setSizeUndefined(); l2.addStyleName(ValoTheme.LABEL_LARGE); vl2.addComponent(l2); vl2.setComponentAlignment(l2, Alignment.MIDDLE_CENTER); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); layout.addComponent(hl2); layout.setComponentAlignment(hl2, Alignment.TOP_LEFT); final TextField tf2 = new TextField(); tf2.setWidth("150px"); tf2.setCaption("Pienempi raja-arvo"); tf2.setStyleName(ValoTheme.TEXTFIELD_TINY); tf2.setValidationVisible(true); hl2.addComponent(tf2); hl2.setComponentAlignment(tf2, Alignment.TOP_CENTER); Label unit2 = new Label(); unit2.setSizeUndefined(); unit2.setCaption(""); unit2.setValue("" + unit); hl2.addComponent(unit2); hl2.setComponentAlignment(unit2, Alignment.MIDDLE_LEFT); final VerticalLayout vl3 = new VerticalLayout(); vl3.setHeight("50px"); vl3.setWidth("100%"); vl3.addStyleName("greenBlock"); layout.addComponent(vl3); layout.setComponentAlignment(vl3, Alignment.TOP_CENTER); layout.setExpandRatio(vl3, 0.0f); final Label l3 = new Label(); l3.setSizeUndefined(); l3.addStyleName(ValoTheme.LABEL_LARGE); vl3.addComponent(l3); vl3.setComponentAlignment(l3, Alignment.MIDDLE_CENTER); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 8396168732300003038L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; State currentState = getState(); if (currentState.equals(combo.getValue())) return; if (State.DECREASE3.equals(combo.getValue())) { makeThree = true; if (State.INCREASE3.equals(currentState)) { swap(); } else if (State.INCREASE2.equals(currentState)) { redLimit = greenLimit; greenLimit = null; } } else if (State.INCREASE3.equals(combo.getValue())) { makeThree = true; if (State.DECREASE3.equals(currentState)) { swap(); } else if (State.DECREASE2.equals(currentState)) { greenLimit = redLimit; redLimit = null; } } else if (State.INCREASE2.equals(combo.getValue())) { if (State.DECREASE3.equals(currentState)) { greenLimit = redLimit; } else if (State.DECREASE2.equals(currentState)) { greenLimit = redLimit; } redLimit = null; makeThree = false; } else if (State.DECREASE2.equals(combo.getValue())) { if (State.INCREASE3.equals(currentState)) { redLimit = greenLimit; } else if (State.INCREASE2.equals(currentState)) { redLimit = greenLimit; } greenLimit = null; makeThree = false; } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); tf1.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -5484608577999300097L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; if (State.DECREASE3.equals(combo.getValue())) { if (makeThree) greenLimit = redLimit; redLimit = new BigDecimal(tf1.getValue()); } else if (State.INCREASE3.equals(combo.getValue())) { if (makeThree) redLimit = greenLimit; greenLimit = new BigDecimal(tf1.getValue()); } else if (State.INCREASE2.equals(combo.getValue())) { greenLimit = new BigDecimal(tf1.getValue()); } else if (State.DECREASE2.equals(combo.getValue())) { redLimit = new BigDecimal(tf1.getValue()); } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); tf2.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 5825320869230527588L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; // This should not happen! if (State.INCREASE2.equals(combo.getValue()) || State.DECREASE2.equals(combo.getValue())) return; if (State.DECREASE3.equals(combo.getValue())) { greenLimit = new BigDecimal(tf2.getValue()); } else if (State.INCREASE3.equals(combo.getValue())) { redLimit = new BigDecimal(tf2.getValue()); } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); return null; }
From source file:fi.semantum.strategia.widget.Property.java
License:Open Source License
public static void updateProperties(final Main main, final Base base, boolean canWrite) { final Database database = main.getDatabase(); String headerText = main.getUIState().currentItem.getCaption(database); main.propertyCells.add(Utils.excelRow(headerText)); Label header = new Label(headerText); header.setWidth("800px"); header.addStyleName("propertyHeader"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); main.properties.addComponent(header); main.properties.setComponentAlignment(header, Alignment.MIDDLE_CENTER); ArrayList<Pair> sorted = new ArrayList<Pair>(main.getUIState().currentItem.properties); Collections.sort(sorted, new Comparator<Pair>() { @Override/* w ww . j a v a 2 s . c o m*/ public int compare(Pair arg0, Pair arg1) { final Property p0 = database.find(arg0.first); final Property p1 = database.find(arg1.first); return p0.getId(database).compareTo(p1.getId(database)); } }); Property typeProperty = Property.find(database, Property.TYPE); for (Pair pair : sorted) { // Skip type if (typeProperty.uuid.equals(pair.first)) continue; final Property p = database.find(pair.first); String value = pair.second; final HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); String label = p.getText(database); main.propertyCells.add(Utils.excelRow(label, value)); Label l = new Label(label); l.setWidth("450px"); l.addStyleName("propertyName"); hl.addComponent(l); List<String> enumeration = p.getEnumeration(database); if (enumeration.isEmpty()) { final TextField tf = new TextField(); tf.setValue(value); tf.setWidth("350px"); hl.addComponent(tf); hl.setComponentAlignment(tf, Alignment.MIDDLE_LEFT); tf.setReadOnly(p.readOnly); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 7729833503749464603L; @Override public void valueChange(ValueChangeEvent event) { Utils.loseFocus(hl); if (p.set(main, main.getUIState().currentItem, tf.getValue())) Updates.update(main, true); } }); tf.setReadOnly(!canWrite); } else { final ComboBox combo = new ComboBox(); combo.setWidth("350px"); combo.setInvalidAllowed(false); combo.setNullSelectionAllowed(false); for (String e : enumeration) { combo.addItem(e); } combo.select(p.getEnumerationValue(database, value)); combo.setPageLength(0); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3511164709346832901L; @Override public void valueChange(ValueChangeEvent event) { Utils.loseFocus(hl); if (p.set(main, main.getUIState().currentItem, combo.getValue().toString())) Updates.update(main, true); } }); combo.setReadOnly(!canWrite); hl.addComponent(combo); hl.setComponentAlignment(combo, Alignment.MIDDLE_LEFT); } hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); main.properties.addComponent(hl); main.properties.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); } }
From source file:fr.amapj.view.engine.popup.formpopup.fieldlink.FieldLink.java
License:Open Source License
public FieldLink(ValidatorManager validatorManager, List<Enum<?>> actives, ComboBox box) { this.validatorManager = validatorManager; this.actives = actives; this.box = box; notNull = new NotNullValidatorConditionnalFieldLink(); notNull.checkIf(this); box.addValueChangeListener(e -> valueChanged()); }
From source file:fr.amapj.view.views.saisiecontrat.PopupSaisieJoker.java
License:Open Source License
private ComboBox createComboBox(ContratLigDTO dateJoker, SimpleDateFormat df) { ComboBox comboBox = new ComboBox(); comboBox.setImmediate(true);/*from ww w . j a v a 2 s .co m*/ LocalDate now = DateUtils.getLocalDate(); for (ContratLigDTO lig : contratDTO.contratLigs) { // if (contratDTO.isFullExcludedLine(lig.i) == false) { // On ajoute uniquement les dates qui sont modifiables if (new ContratAboManager().isModifiable(lig, contratDTO, now)) { String caption = df.format(lig.date); comboBox.addItem(lig); comboBox.setItemCaption(lig, caption); } } } if (dateJoker != null) { comboBox.select(dateJoker); } comboBox.addValueChangeListener(e -> updateTitre()); return comboBox; }
From source file:gov.va.ehtac.appsonfhir.ui.DestinationControl.java
public DestinationControl() { setCaption("Push Patient Resources to other Entities"); session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes(); final VerticalComponentGroup content = new VerticalComponentGroup(); final ComboBox baseURLCBX = new ComboBox("Destination"); baseURLCBX.addItem("42CFRPart2"); baseURLCBX.addItem("Military Health Systems"); baseURLCBX.addItem("Tricare"); baseURLCBX.addItem("Dept. of Veterans Affairs"); baseURLCBX.addItem("HHS ONC - Health Infomation Exchange(HIE)"); baseURLCBX.addItem("FHIR/VA - Health Information Exchange (HIE)"); baseURLCBX.setTextInputAllowed(false); baseURLCBX.addValueChangeListener(new ComboBox.ValueChangeListener() { @Override// w ww. j av a2s . com public void valueChange(Property.ValueChangeEvent event) { String caption = (String) baseURLCBX.getValue(); String newURL = getEndpoint(caption); session.setTransmitURL(newURL); setTabDisplayName(caption); System.out.println("BASEURL: " + newURL); } }); baseURLCBX.setImmediate(true); content.addComponent(baseURLCBX); final Button submitButton = new Button("Transmit Immunizations"); submitButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (session.getTransmitURL().equals(session.getBaseURL())) { Notification.show("Source and Destination Cannot Be Same", Notification.Type.ERROR_MESSAGE); } else { session.getPofPatient().copyToHIE(session.getContext(), session.getTransmitURL()); } } }); submitButton.setImmediate(true); setContent(new CssLayout(content, submitButton)); }
From source file:gov.va.ehtac.appsonfhir.ui.Settings.java
public Settings() { setCaption("Resource Server Selection"); session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes(); final VerticalComponentGroup content = new VerticalComponentGroup(); final ComboBox baseURLCBX = new ComboBox("Resource Server"); baseURLCBX.addItem("42CFRPart2"); baseURLCBX.addItem("Military Health Systems"); baseURLCBX.addItem("Tricare"); baseURLCBX.addItem("Dept. of Veterans Affairs"); baseURLCBX.addItem("HHS ONC - Health Infomation Exchange(HIE)"); baseURLCBX.addItem("FHIR/VA - Health Information Exchange (HIE)"); baseURLCBX.setTextInputAllowed(false); baseURLCBX.addValueChangeListener(new ComboBox.ValueChangeListener() { @Override/* ww w . j a v a 2 s. co m*/ public void valueChange(Property.ValueChangeEvent event) { String caption = (String) baseURLCBX.getValue(); String newURL = getEndpoint(caption); ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes().setBaseURL(newURL); setTabDisplayName(caption); System.out.println("BASEURL: " + newURL); } }); baseURLCBX.setImmediate(true); content.addComponent(baseURLCBX); setContent(new CssLayout(content)); }
From source file:io.subutai.plugin.accumulo.ui.wizard.ConfigurationStep.java
public ConfigurationStep(final Accumulo accumulo, final Hadoop hadoop, final Zookeeper zookeeper, final EnvironmentManager environmentManager, final Wizard wizard) { this.environmentManager = environmentManager; this.wizard = wizard; this.hadoop = hadoop; this.zookeeper = zookeeper; this.accumulo = accumulo; if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) { //hadoop combo final ComboBox hadoopClustersCombo = getCombo("Hadoop cluster"); hadoopClustersCombo.setId("hadoopClusterscb"); //zookeeper combo final ComboBox zkClustersCombo = getCombo("Zookeeper cluster"); zkClustersCombo.setId("zkClustersCombo"); //master nodes final ComboBox masterNodeCombo = getCombo("Master node"); masterNodeCombo.setId("masterNodeCombo"); final ComboBox gcNodeCombo = getCombo("GC node"); gcNodeCombo.setId("gcNodeCombo"); final ComboBox monitorNodeCombo = getCombo("Monitor node"); monitorNodeCombo.setId("monitorNodeCombo"); //accumulo init controls TextField clusterNameTxtFld = getTextField("Cluster name", "Cluster name", 20); clusterNameTxtFld.setId("clusterNameTxtFld"); TextField instanceNameTxtFld = getTextField("Instance name", "Instance name", 20); instanceNameTxtFld.setId("instanceNameTxtFld"); TextField passwordTxtFld = getTextField("Password", "Password", 20); passwordTxtFld.setId("passwordTxtFld"); //tracers final TwinColSelect tracersSelect = getTwinSelect("Tracers", "hostname", "Available Nodes", "Selected Nodes", 4); tracersSelect.setId("TracersSelect"); //slave nodes final TwinColSelect slavesSelect = getTwinSelect("Slaves", "hostname", "Available Nodes", "Selected Nodes", 4); slavesSelect.setId("SlavesSelect"); //get existing hadoop clusters List<HadoopClusterConfig> hadoopClusters = hadoop.getClusters(); //fill hadoopClustersCombo with hadoop cluster infos for (HadoopClusterConfig hadoopClusterInfo : hadoopClusters) { hadoopClustersCombo.addItem(hadoopClusterInfo); hadoopClustersCombo.setItemCaption(hadoopClusterInfo, hadoopClusterInfo.getClusterName()); }/*from w ww . ja v a 2s . com*/ //try to find hadoop cluster info based on one saved in the configuration if (wizard.getConfig().getHadoopClusterName() != null) { hadoop.getCluster(wizard.getConfig().getHadoopClusterName()); } //select if saved found if (!hadoopClusters.isEmpty()) { //select first one if saved not found hadoopClustersCombo.setValue(hadoopClusters.iterator().next()); fillZookeeperComboBox(zkClustersCombo, zookeeper, hadoopClusters.iterator().next().getEnvironmentId()); } // fill selection controls with hadoop nodes if (hadoopClustersCombo.getValue() != null) { HadoopClusterConfig hadoopInfo = (HadoopClusterConfig) hadoopClustersCombo.getValue(); wizard.getConfig().setHadoopClusterName(hadoopInfo.getClusterName()); setComboDS(masterNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(gcNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(monitorNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setTwinSelectDS(tracersSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); setTwinSelectDS(slavesSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); } //on hadoop cluster change reset all controls and config hadoopClustersCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { HadoopClusterConfig hadoopInfo = (HadoopClusterConfig) event.getProperty().getValue(); //reset relevant controls setComboDS(masterNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(gcNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(monitorNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setTwinSelectDS(tracersSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); setTwinSelectDS(slavesSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); //reset relevant properties wizard.getConfig().setMasterNode(null); wizard.getConfig().setGcNode(null); wizard.getConfig().setMonitor(null); wizard.getConfig().setTracers(null); wizard.getConfig().setSlaves(null); wizard.getConfig().setHadoopClusterName(hadoopInfo.getClusterName()); fillZookeeperComboBox(zkClustersCombo, zookeeper, hadoopInfo.getEnvironmentId()); } } }); //restore master node if back button is pressed if (wizard.getConfig().getMasterNode() != null) { masterNodeCombo.setValue(wizard.getConfig().getMasterNode()); } //restore gc node if back button is pressed if (wizard.getConfig().getGcNode() != null) { gcNodeCombo.setValue(wizard.getConfig().getGcNode()); } //restore monitor node if back button is pressed if (wizard.getConfig().getMonitor() != null) { monitorNodeCombo.setValue(wizard.getConfig().getMonitor()); } //add value change handler masterNodeCombo.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { String masterNode = (String) event.getProperty().getValue(); wizard.getConfig().setMasterNode(masterNode); } } }); //add value change handler gcNodeCombo.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { String gcNode = (String) event.getProperty().getValue(); wizard.getConfig().setGcNode(gcNode); } } }); //add value change handler monitorNodeCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { String monitor = (String) event.getProperty().getValue(); wizard.getConfig().setMonitor(monitor); } } }); //restore tracers if back button is pressed if (!CollectionUtil.isCollectionEmpty(wizard.getConfig().getTracers())) { tracersSelect.setValue(wizard.getConfig().getTracers()); } //restore slaves if back button is pressed if (!CollectionUtil.isCollectionEmpty(wizard.getConfig().getSlaves())) { slavesSelect.setValue(wizard.getConfig().getSlaves()); } clusterNameTxtFld.setValue(wizard.getConfig().getInstanceName()); clusterNameTxtFld.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { wizard.getConfig().setClusterName(event.getProperty().getValue().toString().trim()); } }); instanceNameTxtFld.setValue(wizard.getConfig().getInstanceName()); instanceNameTxtFld.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { wizard.getConfig().setInstanceName(event.getProperty().getValue().toString().trim()); } }); passwordTxtFld.setValue(wizard.getConfig().getPassword()); passwordTxtFld.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { wizard.getConfig().setPassword(event.getProperty().getValue().toString().trim()); } }); //add value change handler tracersSelect.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { Set<String> nodes = new HashSet<>(); Set<EnvironmentContainerHost> nodeList = (Set<EnvironmentContainerHost>) event.getProperty() .getValue(); for (EnvironmentContainerHost host : nodeList) { nodes.add(host.getId()); } wizard.getConfig().setTracers(nodes); } } }); //add value change handler slavesSelect.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { Set<String> nodes = new HashSet<>(); Set<EnvironmentContainerHost> nodeList = (Set<EnvironmentContainerHost>) event.getProperty() .getValue(); for (EnvironmentContainerHost host : nodeList) { nodes.add(host.getId()); } wizard.getConfig().setSlaves(nodes); } } }); Button next = new Button("Next"); next.setId("confNext2"); next.addStyleName("default"); //check valid configuration next.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (Strings.isNullOrEmpty(wizard.getConfig().getClusterName())) { show("Please, enter cluster name"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getZookeeperClusterName())) { show("Please, select Zookeeper cluster"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getHadoopClusterName())) { show("Please, select Hadoop cluster"); } else if (wizard.getConfig().getMasterNode() == null) { show("Please, select master node"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getInstanceName())) { show("Please, specify instance name"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getPassword())) { show("Please, specify password"); } else if (wizard.getConfig().getGcNode() == null) { show("Please, select gc node"); } else if (wizard.getConfig().getMonitor() == null) { show("Please, select monitor"); } else if (CollectionUtil.isCollectionEmpty(wizard.getConfig().getTracers())) { show("Please, select tracer(s)"); } else if (CollectionUtil.isCollectionEmpty(wizard.getConfig().getSlaves())) { show("Please, select slave(s)"); } else { wizard.next(); } } }); Button back = new Button("Back"); back.setId("confBack2"); back.addStyleName("default"); back.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.back(); } }); setSizeFull(); VerticalLayout content = new VerticalLayout(); content.setSizeFull(); content.setSpacing(true); content.setMargin(true); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.addComponent(new Label("Please, specify installation settings")); layout.addComponent(content); HorizontalLayout masters = new HorizontalLayout(); masters.setMargin(new MarginInfo(true, false, false, false)); masters.setSpacing(true); masters.addComponent(hadoopClustersCombo); masters.addComponent(zkClustersCombo); masters.addComponent(masterNodeCombo); masters.addComponent(gcNodeCombo); masters.addComponent(monitorNodeCombo); HorizontalLayout credentials = new HorizontalLayout(); credentials.setMargin(new MarginInfo(true, false, false, false)); credentials.setSpacing(true); credentials.addComponent(clusterNameTxtFld); credentials.addComponent(instanceNameTxtFld); credentials.addComponent(passwordTxtFld); HorizontalLayout buttons = new HorizontalLayout(); buttons.setMargin(new MarginInfo(true, false, false, false)); buttons.setSpacing(true); buttons.addComponent(back); buttons.addComponent(next); content.addComponent(masters); content.addComponent(credentials); content.addComponent(tracersSelect); content.addComponent(slavesSelect); content.addComponent(buttons); setContent(layout); } }
From source file:io.subutai.plugin.accumulo.ui.wizard.ConfigurationStep.java
private void fillZookeeperComboBox(ComboBox zkClustersCombo, Zookeeper zookeeper, String environmentId) { zkClustersCombo.removeAllItems();/* ww w .jav a 2s .c om*/ zkClustersCombo.setValue(null); List<ZookeeperClusterConfig> zookeeperClusterConfigs = new ArrayList<>(); List<ZookeeperClusterConfig> zkClusters = zookeeper.getClusters(); //fill zkClustersCombo with zk cluster infos for (final ZookeeperClusterConfig zookeeperClusterConfig : zkClusters) { if (zookeeperClusterConfig.getEnvironmentId().equals(environmentId)) { zkClustersCombo.addItem(zookeeperClusterConfig); zkClustersCombo.setItemCaption(zookeeperClusterConfig, zookeeperClusterConfig.getClusterName()); zookeeperClusterConfigs.add(zookeeperClusterConfig); } } //try to find zk cluster info based on one saved in the configuration ZookeeperClusterConfig zookeeperClusterConfig = null; if (wizard.getConfig().getZookeeperClusterName() != null) { zookeeperClusterConfig = zookeeper.getCluster(wizard.getConfig().getZookeeperClusterName()); } //select if saved found if (zookeeperClusterConfig != null) { zkClustersCombo.setValue(zookeeperClusterConfig); zkClustersCombo.setItemCaption(zookeeperClusterConfig, zookeeperClusterConfig.getClusterName()); } else if (!zookeeperClusterConfigs.isEmpty()) { //select first one if saved not found zkClustersCombo.setValue(zookeeperClusterConfigs.iterator().next()); } if (zkClustersCombo.getValue() != null) { ZookeeperClusterConfig zkConfig = (ZookeeperClusterConfig) zkClustersCombo.getValue(); wizard.getConfig().setZookeeperClusterName(zkConfig.getClusterName()); } zkClustersCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { ZookeeperClusterConfig zkConfig = (ZookeeperClusterConfig) event.getProperty().getValue(); wizard.getConfig().setZookeeperClusterName(zkConfig.getClusterName()); } } }); }
From source file:life.qbic.components.OfferGeneratorTab.java
License:Open Source License
/** * adds all the listeners to the offer generator tab * @param db: database instance to query * @param managerTabs: TabSheet holding the three tabs (Offer Generator, Offer Manager and Package Manager) * @param selectedProjectComboBox: ComboBox for selecting the project for the offer to generate * @param completeButton: button to complete the offer * @param addPackLayout: vertical layout which holds the twin select for selecting the packages, the package * description panel and the button to complete the offer * @param selectPackagesTwinColSelect: TwinSelect to select the packages for the current offer * @param packageDescriptionPanel: panel holding the descriptions labels for the selected packages * @param packageDescriptionLabel: label holding the description for the packages * @param twinColSelectFilter: text field for filtering the left side of the TwinColSelect */// w w w .j a v a2s . c om private static void addListeners(Database db, TabSheet managerTabs, ComboBox selectedProjectComboBox, Button completeButton, VerticalLayout addPackLayout, TwinColSelect selectPackagesTwinColSelect, Panel packageDescriptionPanel, Label packageDescriptionLabel, TextField twinColSelectFilter) { final float[] totalPrice = new float[1]; final String[] descriptionText = new String[1]; final String[][] offerGeneratorPackageNames = new String[1][1]; final String[][] offerGeneratorPackageIds = new String[1][1]; selectedProjectComboBox.addValueChangeListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = 6871999698387032993L; @Override public void valueChange(Property.ValueChangeEvent event) { if (selectedProjectComboBox.getValue() == null) { displayNotification("oO! No project selected!", "Please select a project to proceed, otherwise we are going to have a situation here! ;)", "error"); } else { addPackLayout.addComponent(twinColSelectFilter); addPackLayout.addComponent(selectPackagesTwinColSelect); addPackLayout.addComponent(packageDescriptionPanel); addPackLayout.addComponent(completeButton); } } }); selectPackagesTwinColSelect.addValueChangeListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = -5813954665588509117L; @Override public void valueChange(Property.ValueChangeEvent event) { // get the packages (package_id: package_name) as comma separated string and remove the leading and trailing bracket String selectedPackages = selectPackagesTwinColSelect.getValue().toString().substring(1); selectedPackages = selectedPackages.substring(0, selectedPackages.length() - 1); // in case there is no package selected, we do nothing if (selectedPackages.length() == 0) { return; } // init the arrays holding the package names and package ids offerGeneratorPackageNames[0] = selectedPackages.split(","); offerGeneratorPackageIds[0] = selectedPackages.split(","); // split the package id and the package name for (int i = 0; i < offerGeneratorPackageNames[0].length; i++) { offerGeneratorPackageIds[0][i] = offerGeneratorPackageIds[0][i].split(": ", 2)[0]; offerGeneratorPackageNames[0][i] = offerGeneratorPackageNames[0][i].split(": ", 2)[1]; } // TODO: value change listener does not trigger if the last element from the twin col select gets deselected System.out.println("packages in twin col select:"); System.out.println(selectPackagesTwinColSelect.getValue()); // there is a package for the current project, so we enable the complete offer button if (selectPackagesTwinColSelect.getValue() != null) { completeButton.setEnabled(true); } else { completeButton.setEnabled(false); } assert offerGeneratorPackageNames[0].length == offerGeneratorPackageIds[0].length; // iterate over all of the packages for the current offer and add their price and description to the view descriptionText[0] = ""; totalPrice[0] = 0; for (int i = 0; i < offerGeneratorPackageNames[0].length; i++) { int currentPackageId = Integer.valueOf(offerGeneratorPackageIds[0][i].trim()); // calculate the total offer price try { totalPrice[0] += Float.parseFloat(db.getPriceFromPackageId(currentPackageId, "internal")); } catch (NullPointerException e) { displayNotification("Package price is null!", "The package price of the package " + offerGeneratorPackageIds[0][i] + ": " + offerGeneratorPackageNames[0][i] + " is null. Please remove the " + "package from the offer or update the " + "package price on the package manager tab. Otherwise " + "bad stuff is expected to happen..", "error"); } // get the description for the current package descriptionText[0] = descriptionText[0] + "<tr><td><p><b>" + offerGeneratorPackageIds[0][i] + ": " + offerGeneratorPackageNames[0][i] + "</b><br>" + db.getPackageDescriptionFromPackageId(currentPackageId) + "</td><td align='right' valign='top'>" + db.getPriceFromPackageId(currentPackageId, "internal") + "</td>" + "</p></tr>"; // add the description and the total price to the view if (offerGeneratorPackageNames[0][i].length() != 0) packageDescriptionLabel.setValue( "<table width='100%'><tr><td><p style='color:red;'><b>Package Name and Description</b></p>" + "</td><td align='right'><p style='color:red;'><b>Price</b></p></td></tr><tr> </tr>" + descriptionText[0] + "<tr><td><p style='color:red;'><b>Grand Total</b> (excl. Taxes)</p></td><td align='right'>" + "<p style='color:red;'><b>" + totalPrice[0] + "</b></p></td></tr></table>"); else packageDescriptionLabel.setValue("No description available!"); } } }); completeButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 8181926819540586585L; @Override public void buttonClick(Button.ClickEvent event) { // get some fields for the current offer String offerProjectReference = selectedProjectComboBox.getValue().toString(); String dateToday = new SimpleDateFormat("yyyyMMdd").format(new Date()); String offerNumber = dateToday + "_" + offerProjectReference; String offerFacility = db.getPIFromProjectRef(offerProjectReference); String offerName = db.getShortTitleFromProjectRef(offerProjectReference); String offerDescription = db.getLongDescFromProjectRef(offerProjectReference); // register the new offer in the database; NOTE: internal has no functionality anymore, so we simply set it to // true int offerId = db.registerNewOffer(offerNumber, offerProjectReference, offerFacility, offerName, offerDescription, totalPrice[0], new Date(), "temp", true); // TODO: if a liferay instance is running uncomment this and remove the call to db.registerNewOffer above /* offerId = db.registerNewOffer(offerNumber, offerProjectReference, offerFacility, offerName, offerDescription, totalPrice, dNow, LiferayAndVaadinUtils.getUser().getScreenName(), externalPriceSelectedCheckBox.getValue()); */ // iterate over the packages from the current offer and insert them also in the database for (String packageId : offerGeneratorPackageIds[0]) { int currentPackageId = Integer.valueOf(packageId); float packageUnitPrice = Float.valueOf(db.getPriceFromPackageId(currentPackageId, "internal")); db.insertOrUpdateOffersPackages(offerId, currentPackageId, packageUnitPrice); } displayNotification("Perfect! Offer successfully saved in the Database!", "Next step is to modify, finalize and send it to the customer. Keep in mind that the " + "description of the offer is still missing. Please go ahead and complete it. Fingers crossed!", "success"); // change view to offer manager managerTabs.setSelectedTab(1); } }); }