List of usage examples for com.vaadin.ui ComboBox ComboBox
public ComboBox()
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static void manageIndicators(final Main main, final Base base) { String currentTime = main.getUIState().time; boolean showYears = currentTime.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();/* ww w . ja v a 2s. c om*/ content.setSpacing(true); final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); table.addContainerProperty("Indikaattori", Label.class, null); if (showYears) table.addContainerProperty("Vuosi", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setEditable(false); table.setColumnExpandRatio("Indikaattori", 2.0f); if (showYears) table.setColumnExpandRatio("Vuosi", 0.0f); makeIndicatorTable(main, base, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); abstract class IndicatorButtonListener implements Button.ClickListener { private static final long serialVersionUID = -7551250112503063540L; protected Indicator getPossibleSelection() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (selected.size() != 1) return null; return (Indicator) selected.iterator().next(); } @SuppressWarnings("unchecked") protected Collection<Indicator> getSelection() { return (Collection<Indicator>) table.getValue(); } protected Map<Base, List<Indicator>> getSelectionByParent(Database database) { return indicatorsByParent(database, getSelection()); } } final Button removeIndicators = new Button("Poista", new IndicatorButtonListener() { private static final long serialVersionUID = -2538054127519468282L; public void buttonClick(ClickEvent event) { Collection<Indicator> selection = getSelection(); for (Indicator i : selection) { Base owner = i.getOwner(database); if (owner == null) continue; owner.removeIndicator(i); } final Set<Base> bases = new HashSet<Base>(); final Strategiakartta map = database.getMap(base); bases.add(map); for (Tavoite t : map.tavoitteet) { bases.add(t); for (Painopiste p : t.painopisteet) { bases.add(p); } } for (Base b : bases) { for (Meter meter : b.getMeters(database)) { Indicator indicator = meter.getPossibleIndicator(database); if (selection.contains(indicator)) { b.removeMeter(meter); } } } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); removeIndicators.addStyleName(ValoTheme.BUTTON_TINY); final Button moveUp = new Button("Siirr ylemms", new IndicatorButtonListener() { private static final long serialVersionUID = -635232943884881464L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Indicator>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveIndicatorsUp(entry.getValue()); } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); moveUp.addStyleName(ValoTheme.BUTTON_TINY); final Button moveDown = new Button("Siirr alemmas", new IndicatorButtonListener() { private static final long serialVersionUID = 2779521990166604444L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Indicator>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveIndicatorsDown(entry.getValue()); } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); moveDown.addStyleName(ValoTheme.BUTTON_TINY); final Button modify = new Button("Mrit"); modify.addClickListener(new IndicatorButtonListener() { private static final long serialVersionUID = 5149432436059288486L; public void buttonClick(ClickEvent event) { Indicator indicator = getPossibleSelection(); if (indicator == null) return; editIndicator(main, base, indicator); } }); modify.addStyleName(ValoTheme.BUTTON_TINY); final TextField indicatorText = new TextField(); indicatorText.setWidth("100%"); indicatorText.addStyleName(ValoTheme.TEXTFIELD_TINY); indicatorText.setCaption("Tunniste"); List<Datatype> types = Datatype.enumerate(database); final ComboBox datatypeSelect = new ComboBox(); datatypeSelect.setWidth("100%"); datatypeSelect.setNullSelectionAllowed(false); datatypeSelect.addStyleName(ValoTheme.COMBOBOX_TINY); datatypeSelect.setCaption("Tietotyyppi"); for (Datatype dt : types) datatypeSelect.addItem(dt); final Button addIndicator = new Button("Lis ptasolle", new Button.ClickListener() { private static final long serialVersionUID = -2395147866745115337L; public void buttonClick(ClickEvent event) { String text = indicatorText.getValue(); Object dt = datatypeSelect.getValue(); if (text.isEmpty() || dt == null || dt.equals(datatypeSelect.getNullSelectionItemId())) return; base.addIndicator(Indicator.create(database, text, (Datatype) dt)); makeIndicatorTable(main, base, table); Updates.update(main, true); } }); addIndicator.addStyleName(ValoTheme.BUTTON_TINY); final Button addSubIndicator = new Button("Lis valitun alle", new IndicatorButtonListener() { private static final long serialVersionUID = -2395147866745115337L; public void buttonClick(ClickEvent event) { Indicator indicator = getPossibleSelection(); if (indicator == null) return; String text = indicatorText.getValue(); Object dt = datatypeSelect.getValue(); if (text.isEmpty() || dt == null || dt.equals(datatypeSelect.getNullSelectionItemId())) return; indicator.addIndicator(Indicator.create(database, text, (Datatype) dt)); makeIndicatorTable(main, base, table); Updates.update(main, true); } }); addSubIndicator.addStyleName(ValoTheme.BUTTON_TINY); final Runnable setStates = new Runnable() { @Override public void run() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeIndicators.setEnabled(true); moveUp.setEnabled(true); moveDown.setEnabled(true); if (selected.size() == 1) { modify.setEnabled(true); addSubIndicator.setEnabled(true); } else { addSubIndicator.setEnabled(false); modify.setEnabled(false); } } else { moveUp.setEnabled(false); moveDown.setEnabled(false); removeIndicators.setEnabled(false); addSubIndicator.setEnabled(false); modify.setEnabled(false); } } }; table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1188285609779556446L; @Override public void valueChange(ValueChangeEvent event) { setStates.run(); } }); setStates.run(); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidthUndefined(); hl2.addComponent(modify); hl2.setComponentAlignment(modify, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(modify, 0.0f); hl2.addComponent(removeIndicators); hl2.setComponentAlignment(removeIndicators, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(removeIndicators, 0.0f); hl2.addComponent(moveUp); hl2.setComponentAlignment(moveUp, Alignment.TOP_LEFT); hl2.setExpandRatio(moveUp, 0.0f); hl2.addComponent(moveDown); hl2.setComponentAlignment(moveDown, Alignment.TOP_LEFT); hl2.setExpandRatio(moveDown, 0.0f); HorizontalLayout hl3 = new HorizontalLayout(); hl3.setSpacing(true); hl3.setWidth("100%"); hl3.addComponent(addIndicator); hl3.setComponentAlignment(addIndicator, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addIndicator, 0.0f); hl3.addComponent(addSubIndicator); hl3.setComponentAlignment(addSubIndicator, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addSubIndicator, 0.0f); hl3.addComponent(indicatorText); hl3.setComponentAlignment(indicatorText, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(indicatorText, 1.0f); hl3.addComponent(datatypeSelect); hl3.setComponentAlignment(datatypeSelect, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(datatypeSelect, 2.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl2, 0.0f); content.addComponent(hl3); content.setComponentAlignment(hl3, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl3, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); final Window dialog = Dialogs.makeDialog(main, "650px", "800px", "Hallitse indikaattoreita", "Sulje", content, buttons); }
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
public static void manageMeters(final Main main, final Base base) { String currentTime = main.getUIState().time; boolean showYears = currentTime.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();//from ww w . j a v a 2s .c om content.setSpacing(true); final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); table.addContainerProperty("Mittari", Label.class, null); if (showYears) table.addContainerProperty("Vuosi", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setEditable(false); table.setColumnExpandRatio("Mittari", 2.0f); if (showYears) table.setColumnExpandRatio("Vuosi", 0.0f); makeMeterTable(main, base, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); abstract class MeterButtonListener implements Button.ClickListener { private static final long serialVersionUID = -6640950006518632633L; protected Meter getPossibleSelection() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (selected.size() != 1) return null; return (Meter) selected.iterator().next(); } @SuppressWarnings("unchecked") protected Collection<Meter> getSelection() { return (Collection<Meter>) table.getValue(); } protected Map<Base, List<Meter>> getSelectionByParent(Database database) { return metersByParent(database, getSelection()); } } final Button removeMeters = new Button("Poista", new MeterButtonListener() { private static final long serialVersionUID = 2957964892664902859L; public void buttonClick(ClickEvent event) { for (Meter r : getSelection()) { Base owner = r.getOwner(database); if (owner != null) owner.removeMeter(r); } makeMeterTable(main, base, table); Updates.update(main, true); } }); removeMeters.addStyleName(ValoTheme.BUTTON_TINY); final Button moveUp = new Button("Siirr ylemms", new MeterButtonListener() { private static final long serialVersionUID = 8434251773337788784L; public void buttonClick(ClickEvent event) { Map<Base, List<Meter>> sel = getSelectionByParent(database); if (sel == null) return; for (Map.Entry<Base, List<Meter>> entry : sel.entrySet()) { entry.getKey().moveMetersUp(entry.getValue()); } makeMeterTable(main, base, table); Updates.update(main, true); } }); moveUp.addStyleName(ValoTheme.BUTTON_TINY); final Button moveDown = new Button("Siirr alemmas", new MeterButtonListener() { private static final long serialVersionUID = -5382367112305541842L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Meter>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveMetersDown(entry.getValue()); } makeMeterTable(main, base, table); Updates.update(main, true); } }); moveDown.addStyleName(ValoTheme.BUTTON_TINY); final Button modify = new Button("Mrit"); modify.addClickListener(new MeterButtonListener() { private static final long serialVersionUID = -7109999546516429095L; public void buttonClick(ClickEvent event) { Meter meter = getPossibleSelection(); if (meter == null) return; editMeter(main, base, meter); } }); modify.addStyleName(ValoTheme.BUTTON_TINY); final ComboBox indicatorSelect = new ComboBox(); indicatorSelect.setWidth("100%"); indicatorSelect.setNullSelectionAllowed(false); indicatorSelect.addStyleName(ValoTheme.COMBOBOX_TINY); indicatorSelect.setCaption("Mrittj"); final Strategiakartta map = database.getMap(base); // Indikaattorit for (Indicator i : map.getIndicators(database)) { MeterSpec spec = new MeterSpec(database, i); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } // Enumeraatiot for (Datatype enu : Datatype.enumerate(database)) { if (enu instanceof EnumerationDatatype) { MeterSpec spec = new MeterSpec(database, enu); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } } // Sisnrakennetut { MeterSpec spec = new MeterSpec(database, MeterSpec.IMPLEMENTATION); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } indicatorSelect.setTextInputAllowed(false); final Button addMeter = new Button("Lis ptasolle", new Button.ClickListener() { private static final long serialVersionUID = -5178621686299637238L; public void buttonClick(ClickEvent event) { MeterSpec spec = (MeterSpec) indicatorSelect.getValue(); Object source = spec.getSource(); if (source instanceof Indicator) { Indicator ind = (Indicator) source; Meter.addIndicatorMeter(main, base, ind, Property.AIKAVALI_KAIKKI); } else if (source instanceof EnumerationDatatype) { EnumerationDatatype dt = (EnumerationDatatype) source; Indicator ind = Indicator.create(database, "Uusi " + dt.getId(database), dt); ind.update(main, base, dt.getDefaultValue(), false, "", "Alkuarvo"); ind.update(main, base, dt.getDefaultForecast(), true, "", "Alkuarvo"); Meter.addIndicatorMeter(main, base, ind, Property.AIKAVALI_KAIKKI); } makeMeterTable(main, base, table); Updates.update(main, true); } }); addMeter.addStyleName(ValoTheme.BUTTON_TINY); final Button addSubmeter = new Button("Lis valitun alle", new MeterButtonListener() { private static final long serialVersionUID = -1250285092312682737L; public void buttonClick(ClickEvent event) { Meter meter = getPossibleSelection(); if (meter == null) return; MeterSpec spec = (MeterSpec) indicatorSelect.getValue(); Object source = spec.getSource(); if (source instanceof Indicator) { Indicator ind = (Indicator) source; Meter.addIndicatorMeter(main, meter, ind, Property.AIKAVALI_KAIKKI); } else if (source instanceof EnumerationDatatype) { EnumerationDatatype dt = (EnumerationDatatype) source; Indicator ind = Indicator.create(database, "Uusi " + dt.getId(database), dt); ind.update(main, base, dt.getDefaultValue(), false, "", "Alkuarvo"); ind.update(main, base, dt.getDefaultForecast(), true, "", "Alkuarvo"); Meter.addIndicatorMeter(main, meter, ind, Property.AIKAVALI_KAIKKI); } makeMeterTable(main, base, table); Updates.update(main, true); } }); addSubmeter.addStyleName(ValoTheme.BUTTON_TINY); final Runnable setStates = new Runnable() { @Override public void run() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeMeters.setEnabled(true); moveUp.setEnabled(true); moveDown.setEnabled(true); if (selected.size() == 1) { modify.setEnabled(true); addSubmeter.setEnabled(true); } else { addSubmeter.setEnabled(false); modify.setEnabled(false); } } else { moveUp.setEnabled(false); moveDown.setEnabled(false); removeMeters.setEnabled(false); addSubmeter.setEnabled(false); modify.setEnabled(false); } } }; table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 6439090862804667322L; @Override public void valueChange(ValueChangeEvent event) { setStates.run(); } }); setStates.run(); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidthUndefined(); hl2.addComponent(modify); hl2.setComponentAlignment(modify, Alignment.TOP_LEFT); hl2.setExpandRatio(modify, 0.0f); hl2.addComponent(removeMeters); hl2.setComponentAlignment(removeMeters, Alignment.TOP_LEFT); hl2.setExpandRatio(removeMeters, 0.0f); hl2.addComponent(moveUp); hl2.setComponentAlignment(moveUp, Alignment.TOP_LEFT); hl2.setExpandRatio(moveUp, 0.0f); hl2.addComponent(moveDown); hl2.setComponentAlignment(moveDown, Alignment.TOP_LEFT); hl2.setExpandRatio(moveDown, 0.0f); HorizontalLayout hl3 = new HorizontalLayout(); hl3.setSpacing(true); hl3.setWidth("100%"); hl3.addComponent(addMeter); hl3.setComponentAlignment(addMeter, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addMeter, 0.0f); hl3.addComponent(addSubmeter); hl3.setComponentAlignment(addSubmeter, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addSubmeter, 0.0f); hl3.addComponent(indicatorSelect); hl3.setComponentAlignment(indicatorSelect, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(indicatorSelect, 1.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); content.setExpandRatio(hl2, 0.0f); content.addComponent(hl3); content.setComponentAlignment(hl3, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl3, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); final Window dialog = Dialogs.makeDialog(main, "450px", "600px", "Hallitse mittareita", "Sulje", content, buttons); }
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//from w w w . j a v a 2s .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:fi.vtt.RVaadin.RContainer.java
License:Apache License
/** * <p>//from w w w . jav a 2 s . co m * Returns a Vaadin ComboBox object with an implicit ValueChangeListener * that writes the selected options directly to the R workspace. See * {@link RContainer#getListSelect} for examples, and how to (re)set the * values and set the listener explicitly. * </p> * * @param optionsInName * The R character vector name to contain the different choices. * Repeated elements will be ignored. * @param selectedOutName * The R character variable to immediately write the selection * to. * @return Vaadin ComboBox object. */ public ComboBox getComboBox(String optionsInName, final String selectedOutName) { final ComboBox combo = new ComboBox(); combo.setNullSelectionAllowed(false); buildSelectOptions(combo, optionsInName); buildSelectListener(combo, selectedOutName); return combo; }
From source file:fr.amapj.view.engine.enumselector.EnumSearcher.java
License:Open Source License
/** * Permet de crer une combo box permettant de choisir parmi une liste de Enum * avec possibilit d'indiquer comment afficher les libelles * // ww w. ja va 2s. c o m * @param binder * @param title * @param enumeration donne la liste afficher * @param propertyId * @return */ static public <T extends Enum<T>> HorizontalLayout createEnumSearcher(FieldGroup binder, String title, String propertyId, T... enumsToExcludes) { Class<T> enumeration = binder.getItemDataSource().getItemProperty(propertyId).getType(); if (enumeration.isEnum() == false) { throw new AmapjRuntimeException("Le champ " + title + " n'est pas de type enum"); } HelpInfo metaData = MetaDataEnum.getHelpInfo(enumeration); ComboBox comboBox = new ComboBox(); comboBox.setWidth("300px"); EnumSet<T> enums = EnumSet.allOf(enumeration); for (T en : enums) { if (isAllowed(en, enumsToExcludes)) { String caption = getCaption(metaData, en); comboBox.addItem(en); comboBox.setItemCaption(en, caption); } } binder.bind(comboBox, propertyId); comboBox.setImmediate(true); HorizontalLayout hl = new HorizontalLayout(); hl.setCaption(title); hl.addComponent(comboBox); if (metaData != null) { Button aide = new Button(); aide.setIcon(FontAwesome.QUESTION_CIRCLE); aide.addStyleName("borderless-colored"); aide.addStyleName("question-mark"); aide.addClickListener(e -> handleAide(metaData)); hl.addComponent(aide); } return hl; }
From source file:fr.amapj.view.views.common.contratselector.ContratSelectorPart.java
License:Open Source License
public HorizontalLayout getChoixContratComponent() { // Partie choix du contrat HorizontalLayout toolbar1 = new HorizontalLayout(); toolbar1.addStyleName("contrat-selectorpart"); Label pLabel = new Label("Producteur"); pLabel.addStyleName("combobox"); pLabel.setSizeUndefined();//from www .ja v a 2 s.co m producteurBox = new Searcher(SearcherList.PRODUCTEUR, null, allowedProducteurs); producteurBox.setImmediate(true); producteurBox.addValueChangeListener(e -> handleProducteurChange()); Label cLabel = new Label("Contrat"); cLabel.addStyleName("combobox"); cLabel.setSizeUndefined(); contratBox = new ComboBox(); contratBox.setImmediate(true); contratBox.setWidth("300px"); contratBox.addValueChangeListener(e -> handleContratChange()); reinitButton = new Button("Changer de contrat"); reinitButton.addClickListener(e -> handleReinit()); toolbar1.addComponent(pLabel); toolbar1.addComponent(producteurBox); toolbar1.addComponent(cLabel); toolbar1.addComponent(contratBox); if (onlyOneProducteur == false) { toolbar1.addComponent(reinitButton); toolbar1.setExpandRatio(reinitButton, 1); toolbar1.setComponentAlignment(reinitButton, Alignment.TOP_RIGHT); contratBox.setEnabled(false); } else { // Ceci est ncessaire pour conserver un alignement correct Label tf = new Label(""); toolbar1.addComponent(tf); toolbar1.setExpandRatio(tf, 1); toolbar1.setComponentAlignment(tf, Alignment.TOP_RIGHT); } toolbar1.setSpacing(true); toolbar1.setWidth("100%"); return toolbar1; }
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. c om 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:info.magnolia.ui.dialog.formdialog.ItemFormView.java
License:Open Source License
private void createLocaleSelector() { languageSelector = new ComboBox(); languageSelector.setSizeUndefined(); languageSelector.setImmediate(true); languageSelector.setNullSelectionAllowed(false); languageSelector.setTextInputAllowed(false); languageSelector.addValueChangeListener(new Property.ValueChangeListener() { @Override//from ww w . j ava2s.com public void valueChange(Property.ValueChangeEvent event) { updateLocale((Locale) event.getProperty().getValue()); } }); }
From source file:info.magnolia.ui.form.field.factory.SelectFieldFactory.java
License:Open Source License
/** * Used to initialize the desired subclass of AbstractSelect field component. Subclasses can override this method. *///from w w w . j a v a2 s. co m protected AbstractSelect createSelectionField() { return new ComboBox(); }
From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java
public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker, final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes, final NodeType nodeType) { super("Add New Node"); setModal(true);/*from w w w.j a va 2 s . c om*/ setWidth(650, Unit.PIXELS); setHeight(450, Unit.PIXELS); GridLayout content = new GridLayout(1, 3); content.setSizeFull(); content.setMargin(true); content.setSpacing(true); HorizontalLayout topContent = new HorizontalLayout(); topContent.setSpacing(true); content.addComponent(topContent); topContent.addComponent(new Label("Nodes:")); final ComboBox hadoopNodes = new ComboBox(); hadoopNodes.setId("HadoopNodesCb"); hadoopNodes.setImmediate(true); hadoopNodes.setTextInputAllowed(false); hadoopNodes.setNullSelectionAllowed(false); hadoopNodes.setRequired(true); hadoopNodes.setWidth(200, Unit.PIXELS); for (EnvironmentContainerHost node : nodes) { hadoopNodes.addItem(node); hadoopNodes.setItemCaption(node, node.getHostname()); } if (nodes.size() == 0) { return; } hadoopNodes.setValue(nodes.iterator().next()); topContent.addComponent(hadoopNodes); final Button addNodeBtn = new Button("Add"); addNodeBtn.setId("AddSelectedNode"); topContent.addComponent(addNodeBtn); final Button ok = new Button("Ok"); addNodeBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addNodeBtn.setEnabled(false); ok.setEnabled(false); showProgress(); EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue(); final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), nodeType); executorService.execute(new Runnable() { public void run() { while (track) { TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY, trackID); if (po != null) { setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n" + po.getLog()); if (po.getState() != OperationState.RUNNING) { hideProgress(); ok.setEnabled(true); break; } } else { setOutput("Product operation not found. Check logs"); break; } try { Thread.sleep(1000); } catch (InterruptedException ex) { break; } } } }); } }); outputTxtArea = new TextArea("Operation output"); outputTxtArea.setId("outputTxtArea"); outputTxtArea.setRows(13); outputTxtArea.setColumns(43); outputTxtArea.setImmediate(true); outputTxtArea.setWordwrap(true); content.addComponent(outputTxtArea); indicator = new Label(); indicator.setId("indicator"); indicator.setIcon(new ThemeResource("img/spinner.gif")); indicator.setContentMode(ContentMode.HTML); indicator.setHeight(11, Unit.PIXELS); indicator.setWidth(50, Unit.PIXELS); indicator.setVisible(false); ok.setId("btnOk"); ok.setStyleName("default"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //close window track = false; close(); } }); HorizontalLayout bottomContent = new HorizontalLayout(); bottomContent.addComponent(indicator); bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT); bottomContent.addComponent(ok); content.addComponent(bottomContent); content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT); setContent(content); }