List of usage examples for com.vaadin.ui ComboBox ComboBox
public ComboBox(String caption, Collection<T> options)
From source file:com.lizardtech.expresszip.vaadin.ExportOptionsViewComponent.java
License:Apache License
public ExportOptionsViewComponent(ExportProps exportProps) { this.exportProps = exportProps; listeners = new ArrayList<ExportOptionsViewListener>(); txtJobName = new TextField(JOB_NAME); txtEmail = new TextField(EMAIL_ADDRESS); txtUserNotation = new TextField(JOB_USER_NOTATION); numTilesLabel = new Label(); exportSizeEstimate = new Label(); outputFormatComboBox = new ComboBox(OUTPUT_FORMAT, OUTPUT_FORMATS); outputFormatComboBox.setTextInputAllowed(false); outputFormatComboBox.addListener(griddingValuesChangeListener); setSizeFull();/* w ww . j av a 2s. c o m*/ /** * Setup output resolution */ exportSizeComboBox = new ComboBox(null, exportSizes); exportSizeComboBox.setNullSelectionAllowed(false); exportSizeComboBox.setNewItemsAllowed(false); exportSizeComboBox.setTextInputAllowed(false); exportSizeComboBox.setImmediate(true); exportSizeComboBox.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { Object choice = event.getProperty().getValue(); String value = ""; if (SMALL.equals(choice)) { gridCheckbox.setValue(Boolean.FALSE); gridCheckbox.setEnabled(false); value = "512"; } else if (MEDIUM.equals(choice)) { gridCheckbox.setValue(Boolean.FALSE); gridCheckbox.setEnabled(false); value = "1280"; } else if (LARGE.equals(choice)) { gridCheckbox.setValue(Boolean.FALSE); gridCheckbox.setEnabled(false); value = "5000"; } boolean custom = CUSTOM.equals(choice); if (!custom) { if (NATIVE.equals(choice)) { txtGroundResolution.setValue(Double.toString(maximumResolution)); } else { if (getExportProps().getAspectRatio() > 1.0d) { txtDimHeight.setValue(value); } else txtDimWidth.setValue(value); } } txtDimWidth.setEnabled(custom); txtDimHeight.setEnabled(custom); txtGroundResolution.setEnabled(custom); } }); // Add Output Resolution to view HorizontalLayout dimensionsLayout = new HorizontalLayout(); dimensionsLayout.addComponent(txtDimWidth); dimensionsLayout.addComponent(txtDimHeight); dimensionsLayout.setSpacing(true); dimensionsLayout.setWidth("100%"); // Format dimensions layout txtDimHeight.setMaxLength(10); txtDimHeight.setWidth("100%"); txtDimHeight.setImmediate(true); txtDimHeight.addListener(heightValChangeListener); txtDimHeight.setRequired(true); txtDimHeight.addValidator(new WidthHeightValidator()); txtDimWidth.setMaxLength(10); txtDimWidth.setWidth("100%"); txtDimWidth.setImmediate(true); txtDimWidth.addListener(widthValChangeListener); txtDimWidth.setRequired(true); txtDimWidth.addValidator(new WidthHeightValidator()); // Format Ground Resolution layout txtGroundResolution.setValue("0"); txtGroundResolution.setImmediate(true); txtGroundResolution.addListener(groundResValChangeListener); txtGroundResolution.setRequired(true); txtGroundResolution.addValidator(new GroundResolutionValidator()); vrtOutputResolution = new VerticalLayout(); vrtOutputResolution.setSpacing(true); vrtOutputResolution.addComponent(exportSizeComboBox); vrtOutputResolution.addComponent(dimensionsLayout); txtGroundResolution.setWidth("75%"); vrtOutputResolution.addComponent(txtGroundResolution); vrtOutputResolution.setComponentAlignment(txtGroundResolution, Alignment.BOTTOM_CENTER); /** * Setup Gridding options */ // Add Gridding option to view griddingLayout = new VerticalLayout(); griddingLayout.setSpacing(true); // Format GridCheckbox layout griddingLayout.addComponent(gridCheckbox); gridCheckbox.setImmediate(true); gridCheckbox.setValue(false); gridCheckbox.addListener(griddingModeChangeListener); xPixelsTextBox.setWidth("100%"); xPixelsTextBox.setImmediate(true); xPixelsTextBox.addValidator(new TileWidthValidator()); xPixelsTextBox.addListener(griddingValuesChangeListener); yPixelsTextBox.setWidth("100%"); yPixelsTextBox.setImmediate(true); yPixelsTextBox.addValidator(new TileHeightValidator()); yPixelsTextBox.addListener(griddingValuesChangeListener); xDistanceTextBox.setWidth("100%"); xDistanceTextBox.setImmediate(true); xDistanceTextBox.addValidator(new TileGeoXValidator()); xDistanceTextBox.addListener(griddingValuesChangeListener); yDistanceTextBox.setWidth("100%"); yDistanceTextBox.setImmediate(true); yDistanceTextBox.addValidator(new TileGeoYValidator()); yDistanceTextBox.addListener(griddingValuesChangeListener); // Format gridding options xTilesTextBox.setWidth("100%"); xTilesTextBox.setImmediate(true); xTilesTextBox.addValidator(new TileXDivisorValidator()); xTilesTextBox.addListener(griddingValuesChangeListener); yTilesTextBox.setWidth("100%"); yTilesTextBox.setImmediate(true); yTilesTextBox.addValidator(new TileYDivisorValidator()); yTilesTextBox.addListener(griddingValuesChangeListener); optGridOpt.setValue(GRID_TILE_DIMENSIONS); optGridOpt.setImmediate(true); optGridOpt.addListener(griddingModeChangeListener); HorizontalLayout hznGridOptions = new HorizontalLayout(); griddingLayout.addComponent(hznGridOptions); hznGridOptions.setWidth("100%"); hznGridOptions.setSpacing(true); hznGridOptions.addComponent(optGridOpt); VerticalLayout vrtGridComboFields = new VerticalLayout(); hznGridOptions.addComponent(vrtGridComboFields); vrtGridComboFields.setWidth("100%"); hznGridOptions.setExpandRatio(vrtGridComboFields, 1.0f); HorizontalLayout hznTileDim = new HorizontalLayout(); hznTileDim.setWidth("100%"); vrtGridComboFields.addComponent(hznTileDim); hznTileDim.addComponent(xPixelsTextBox); hznTileDim.addComponent(yPixelsTextBox); HorizontalLayout hznDistanceDim = new HorizontalLayout(); hznDistanceDim.setWidth("100%"); vrtGridComboFields.addComponent(hznDistanceDim); hznDistanceDim.addComponent(xDistanceTextBox); hznDistanceDim.addComponent(yDistanceTextBox); HorizontalLayout hznDivideGrid = new HorizontalLayout(); hznDivideGrid.setWidth("100%"); vrtGridComboFields.addComponent(hznDivideGrid); hznDivideGrid.addComponent(xTilesTextBox); hznDivideGrid.addComponent(yTilesTextBox); hznDivideGrid.setSpacing(true); hznTileDim.setSpacing(true); hznDistanceDim.setSpacing(true); /** * Format options panel */ // Add Format options to view formatOptionsLayout = new VerticalLayout(); formatOptionsLayout.setWidth("100%"); formatOptionsLayout.setSpacing(true); formatOptionsLayout.setMargin(true); // Format outputformat formatOptionsLayout.addComponent(outputFormatComboBox); outputFormatComboBox.setNullSelectionAllowed(false); formatOptionsLayout.addComponent(packageComboBox); packageComboBox.addItem(ExportProps.OutputPackageFormat.TAR); packageComboBox.addItem(ExportProps.OutputPackageFormat.ZIP); packageComboBox.setNullSelectionAllowed(false); packageComboBox.setTextInputAllowed(false); packageComboBox.setValue(ExportProps.OutputPackageFormat.ZIP); /** * Job Details */ // Set Jobname panel jobDetailsLayout = new VerticalLayout(); jobDetailsLayout.setSpacing(true); jobDetailsLayout.setMargin(true); jobDetailsLayout.addComponent(txtJobName); txtJobName.setRequired(true); txtJobName.setRequiredError("Please enter a job name."); txtJobName.setWidth("100%"); txtJobName.setImmediate(true); String jobname_regexp = "^[ A-Za-z0-9._-]{1,128}$"; txtJobName.addValidator(new RegexpValidator(jobname_regexp, "Job names should be alpha-numeric, less than 128 characters and may include spaces, dashes and underscores")); txtJobName.addValidator(new JobNameUniqueValidator( "A job by that name already exists in your configured export directory")); txtJobName.addListener(resolutionValuesChangeListener); jobDetailsLayout.addComponent(txtUserNotation); txtUserNotation.setWidth("100%"); txtUserNotation.setImmediate(true); String usernotation_regexp = "^[ A-Za-z0-9_-]{0,32}$"; txtUserNotation.addValidator(new RegexpValidator(usernotation_regexp, "User names should be alpha-numeric, less than 32 characters and may include spaces, dashes and underscores")); txtUserNotation.addListener(resolutionValuesChangeListener); // Format Email boolean enableEmail = new BackgroundExecutor.Factory().getBackgroundExecutor().getMailServices() .isValidEmailConfig(); txtEmail.setEnabled(enableEmail); if (enableEmail) { jobDetailsLayout.addComponent(txtEmail); txtEmail.setWidth("100%"); txtEmail.setInputPrompt("enter your email address"); txtEmail.setImmediate(true); txtEmail.addValidator(new EmailValidator("Invalid format for email address.")); txtEmail.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateSubmitEnabledState(); } }); } VerticalLayout exportSummary = new VerticalLayout(); exportSummary.addComponent(numTilesLabel); exportSummary.addComponent(exportSizeEstimate); jobDetailsLayout.addComponent(new Panel(("Export summary"), exportSummary)); // Set submit and back buttons // Add listeners to all fields backButton = new ExpressZipButton("Back", Style.STEP); backButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { ((ExpressZipWindow) getApplication().getMainWindow()).regressToPrev(); } }); submitButton = new ExpressZipButton("Submit", Style.STEP); submitButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { txtJobName.validate(); } catch (InvalidValueException e) { txtJobName.requestRepaint(); updateSubmitEnabledState(); return; } for (ExportOptionsViewListener listener : listeners) { listener.submitJobEvent(getExportProps()); } } }); accordian = new Accordion(); accordian.addStyleName("expresszip"); accordian.setImmediate(true); accordian.addTab(jobDetailsLayout, JOB_DETAILS); accordian.addTab(formatOptionsLayout, FORMAT_OPTIONS); accordian.setSizeFull(); outputDetails = new VerticalLayout(); outputDetails.setMargin(true); outputDetails.setSpacing(true); outputDetails.addComponent(new Panel(DIMENSIONS, vrtOutputResolution)); outputDetails.addComponent(new Panel(TILING, griddingLayout)); accordian.addTab(outputDetails, EXPORT_CONFIGURATION); HorizontalLayout backSubmitLayout = new HorizontalLayout(); backSubmitLayout.setWidth("100%"); backSubmitLayout.addComponent(backButton); backSubmitLayout.addComponent(submitButton); backSubmitLayout.setComponentAlignment(backButton, Alignment.BOTTOM_LEFT); backSubmitLayout.setComponentAlignment(submitButton, Alignment.BOTTOM_RIGHT); VerticalLayout navLayout = new VerticalLayout(); navLayout.addComponent(backSubmitLayout); navLayout.setSpacing(true); ThemeResource banner = new ThemeResource("img/ProgressBar3.png"); navLayout.addComponent(new Embedded(null, banner)); // add scrollbars around formLayout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); layout.setSpacing(true); Label step = new Label("Step 3: Configure Export Options"); step.addStyleName("step"); layout.addComponent(step); layout.addComponent(accordian); layout.setExpandRatio(accordian, 1.0f); layout.addComponent(navLayout); layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER); setCompositionRoot(layout); outputFormatComboBox.select(OUTPUT_FORMATS.get(0)); forceGriddingCheck(); updateGriddingEnabledState(); }
From source file:com.terralcode.frontend.vista.widgets.alumno.AlumnoVista.java
private Component buildEstadoOcupacional() { // containerEstadosOcupacional = new BeanItemContainer<>(EstadoOcupacional.class); // containerEstadosOcupacional.addAll(estadoOcupacionalService.findAll()); // estadosOcupacionalField = new OptionGroup("Estado Ocupacional"); // estadosOcupacionalField.setContainerDataSource(containerEstadosOcupacional); // estadosOcupacionalField.addStyleName("horizontal"); // estadosOcupacionalField.setWidth("30%"); ComboBox combo = new ComboBox("Estado Ocupacional", estadoOcupacionalService.findAll()); combo.setItemCaptionPropertyId("description"); // combo. return combo; }
From source file:com.terralcode.frontend.vista.widgets.alumno.AlumnoVista.java
private Component buildNivelEstudios() { // containerNivelEstudios = new BeanItemContainer<>(NivelEstudios.class); // containerNivelEstudios.addAll(nivelEstudiosService.findAll()); // nivelEstudiosField = new OptionGroup("Nivel Estudios"); // nivelEstudiosField.setContainerDataSource(containerNivelEstudios); // nivelEstudiosField.addStyleName("horizontal"); // nivelEstudiosField.setWidth("30%"); ComboBox combo = new ComboBox("Estado Ocupacional", nivelEstudiosService.findAll()); combo.setItemCaptionPropertyId("description"); // combo. return combo; }
From source file:componentwrappers.OpenbisInfoComboBox.java
License:Open Source License
public OpenbisInfoComboBox(String label, String description, List<String> data) { super(description, new ComboBox(label, data)); inner.setStyleName(Styles.boxTheme); ((ComboBox) inner).setFilteringMode(FilteringMode.CONTAINS); }
From source file:de.catma.ui.analyzer.querybuilder.FreqPanel.java
License:Open Source License
private Component createSearchPanel() { HorizontalLayout searchPanel = new HorizontalLayout(); searchPanel.setMargin(true, false, false, false); searchPanel.setSpacing(true);/* w ww . j a va2 s . c o m*/ List<FreqComparator> freqComparators = new ArrayList<FreqComparator>(); exactlyFreqComp = new FreqComparator("exactly", "="); freqComparators.add(exactlyFreqComp); freqComparators.add(new FreqComparator("greaterThan", ">")); freqComparators.add(new FreqComparator("lessThan", ">")); freqComparators.add(new FreqComparator("greaterOrEqualThan", ">=")); freqComparators.add(new FreqComparator("lessOrEqualThan", "<=")); freqComparators.add(new FreqComparator("between", "=", true)); searchPanel.addComponent(new Label("The word shall appear")); freqComparatorCombo = new ComboBox(null, freqComparators); freqComparatorCombo.setImmediate(true); freqComparatorCombo.setNewItemsAllowed(false); freqComparatorCombo.setNullSelectionAllowed(false); freqComparatorCombo.setInvalidAllowed(false); searchPanel.addComponent(freqComparatorCombo); freq1Input = new TextField(); freq1Input.setImmediate(true); freq1Input.addValidator(new IntegerValueValidator(true, false)); freq1Input.setInvalidAllowed(false); freq1Input.setRequired(true); searchPanel.addComponent(freq1Input); searchPanel.setExpandRatio(freq1Input, 0.5f); andLabel = new Label("and"); searchPanel.addComponent(andLabel); freq2Input = new TextField(); freq2Input.setImmediate(true); freq2Input.addValidator(new IntegerValueValidator(false, false)); freq2Input.setInvalidAllowed(false); searchPanel.addComponent(freq2Input); searchPanel.setExpandRatio(freq2Input, 0.5f); searchPanel.addComponent(new Label("times.")); return searchPanel; }
From source file:de.catma.ui.analyzer.querybuilder.WordPanel.java
License:Open Source License
private void initComponents() { setSpacing(true);/* w w w . java 2s . c o m*/ setMargin(true); setSizeFull(); String next = " first "; if (withPositionBox) { next = " next "; } Label startsWithLabel = new Label("The" + next + "word starts with"); addComponent(startsWithLabel, 0, 0); startsWithField = new TextField(); startsWithField.setImmediate(true); addComponent(startsWithField, 1, 0); Label containsLabel = new Label("The" + next + "word contains"); addComponent(containsLabel, 0, 1); containsField = new TextField(); containsField.setImmediate(true); addComponent(containsField, 1, 1); Label endsWithLabel = new Label("The" + next + "word ends with"); addComponent(endsWithLabel, 0, 2); endsWithField = new TextField(); endsWithField.setImmediate(true); addComponent(endsWithField, 1, 2); Label exactLabel = new Label("The" + next + "word is exactly"); addComponent(exactLabel, 0, 3); exactField = new TextField(); exactField.setImmediate(true); addComponent(exactField, 1, 3); if (withPositionBox) { List<PositionItem> options = new ArrayList<PositionItem>(); for (int i = 1; i <= 10; i++) { options.add(new PositionItem(i, i + " word" + (i == 1 ? "" : "s") + " after the previous word")); } Label positionLabel = new Label("The position of this word is"); addComponent(positionLabel, 0, 4); positionBox = new ComboBox("", options); positionBox.setImmediate(true); addComponent(positionBox, 1, 4); positionBox.setNullSelectionAllowed(false); positionBox.setNewItemsAllowed(false); positionBox.setValue(options.get(0)); btRemove = new Button("Remove"); addComponent(btRemove, 0, 5, 1, 5); setComponentAlignment(btRemove, Alignment.MIDDLE_CENTER); } }
From source file:de.catma.ui.repository.wizard.ComboBoxColumnGenerator.java
License:Open Source License
public Component generateCell(Table source, Object itemId, Object columnId) { // Get the object stored in the cell as a property Property prop = source.getItem(itemId).getItemProperty(columnId); ComboBox comboBox = new ComboBox(null, options); comboBox.setNullSelectionAllowed(false); comboBox.setPropertyDataSource(prop); comboBox.setImmediate(true);/*w w w . j a v a2s .co m*/ if (valueChangeListenerGenerator != null) { comboBox.addValueChangeListener( valueChangeListenerGenerator.generateValueChangeListener(source, itemId, columnId)); } return comboBox; }
From source file:de.escidoc.admintool.view.resource.OrgUnitViewComponentFactory.java
License:Open Source License
public static ComboBox createMetadataComboBox(final ValueChangeListener listener) { final ComboBox metadataComboBox = new ComboBox(ViewConstants.METADATA_LABEL, Arrays.asList( new String[] { ViewConstants.PUB_MAN_METADATA, ViewConstants.RAW_XML, ViewConstants.FREE_FORM })); metadataComboBox.setNewItemsAllowed(false); metadataComboBox.setWidth(150, Sizeable.UNITS_PIXELS); metadataComboBox.addListener(listener); metadataComboBox.setImmediate(true); return metadataComboBox; }
From source file:de.kaiserpfalzEdv.vaadin.LayoutHelper.java
License:Apache License
public <T> ComboBox createJpaComboBox(final EntityManager em, final Class<?> clasz, final String displayColumn, final String caption, final int tabIndex, final int startColumn, final int startRow, final int endColumn, final int endRow) { JPAContainer<T> data = createJpaContainer(em, clasz, displayColumn); ComboBox result = new ComboBox(i18n.get(caption), data); result.setInputPrompt(i18n.get(caption + ".prompt")); result.setScrollToSelectedItem(true); result.setItemCaptionPropertyId(displayColumn); result.setTextInputAllowed(true);//from w ww . j av a 2 s .com result.setConverter(new SingleSelectConverter<Long>(result)); addToLayout(result, tabIndex, startColumn, startRow, endColumn, endRow); return result; }
From source file:de.kaiserpfalzEdv.vaadin.ui.defaultviews.editor.impl.BaseEditorImpl.java
License:Apache License
protected ComboBox createComboBox(final String i18nBase, final String displayName, final int tabIndex, final Class<? extends BaseEntity> clasz) { JPAContainer container = presenter.getContainer(clasz); container.getEntityProvider().setLazyLoadingDelegate(null); ComboBox result = new ComboBox(presenter.translate(i18nBase), container); result.setTabIndex(tabIndex);/* ww w . j a v a 2 s.c o m*/ result.setWidth(100f, PERCENTAGE); result.setItemCaptionPropertyId(displayName); result.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); result.setConverter(new SingleSelectConverter<Long>(result)); return result; }