Java Code Examples for com.vaadin.ui.ComboBox.setTextInputAllowed()

The following are Jave code examples for showing how to use setTextInputAllowed() of the com.vaadin.ui.ComboBox class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: extacrm   File: MainSettingsForm.java   Source Code and License Vote up 7 votes
@Override
protected ComponentContainer createEditFields() {
    final ExtaFormLayout form = new ExtaFormLayout();

    appTitleField = new EditField("Заголовок приложения");
    form.addComponent(appTitleField);

    iconPathField = new ComboBox("Иконка приложения");
    for (final String icon : lookup(UserSettingsService.class).getFaviconPathList()) {
        iconPathField.addItem(icon);
        iconPathField.setItemIcon(icon, new ThemeResource(getLast(Splitter.on('/').split(icon))));
    }
    iconPathField.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ICON_ONLY);
    iconPathField.setWidth(85, Unit.PIXELS);
    iconPathField.setTextInputAllowed(false);
    iconPathField.setNullSelectionAllowed(false);
    form.addComponent(iconPathField);

    isShowSalePointIdsField = new MCheckBox("Показывать раздел \"Идентификация\" в карточке торговой точки");
    form.addComponent(isShowSalePointIdsField);

    isDevServerField = new MCheckBox("Режим отладки");
    form.addComponent(isDevServerField);

    return form;
}
 
Example 2
Project: esup-ecandidat   File: CandidatureViewTemplate.java   Source Code and License Vote up 6 votes
/**
 * @param liste
 * @param libNull
 * @return une combo grace a la liste
 */
private ComboBox generateComboBox(final List<String> liste, final String libNull) {
	ComboBox sampleIdCB = new ComboBox();
	sampleIdCB.setPageLength(20);
	sampleIdCB.setTextInputAllowed(false);
	BeanItemContainer<String> dataList = new BeanItemContainer<>(String.class);
	dataList.addBean(applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()));
	if (libNull != null) {
		dataList.addBean(libNull);
	}
	dataList.addAll(liste);
	sampleIdCB
			.setNullSelectionItemId(applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()));
	sampleIdCB.setContainerDataSource(dataList);
	sampleIdCB.setImmediate(true);
	return sampleIdCB;
}
 
Example 3
Project: osc-core   File: BindSecurityGroupWindow.java   Source Code and License Vote up 6 votes
private ComboBox getPolicyComboBox(List<PolicyDto> policyDtoList) {
	ComboBox policy = new ComboBox("Select Policy");
	policy.setTextInputAllowed(false);
	policy.setNullSelectionAllowed(false);
	policy.setImmediate(true);
	policy.setRequired(true);
	policy.setRequiredError("Policy cannot be empty");

	BeanItemContainer<PolicyDto> policyListContainer = new BeanItemContainer<>(PolicyDto.class,
			policyDtoList);
	policy.setContainerDataSource(policyListContainer);
	policy.setItemCaptionPropertyId("policyName");

	if (policyListContainer.size() > 0) {
		policy.select(policyListContainer.getIdByIndex(0));
	}

	policy.setEnabled(false);

	return policy;
}
 
Example 4
Project: osc-core   File: BaseDAWindow.java   Source Code and License Vote up 6 votes
private ComboBox createDomainComboBox(List<DomainDto> dl) {
    ComboBox domainComboBox = new ComboBox();
    BeanItemContainer<DomainDto> domainContainer = new BeanItemContainer<DomainDto>(DomainDto.class, dl);
    ApplianceManagerConnectorDto mc = (ApplianceManagerConnectorDto) this.managerConnector.getValue();

    domainComboBox.setContainerDataSource(domainContainer);
    domainComboBox.setTextInputAllowed(false);
    domainComboBox.setNullSelectionAllowed(false);
    domainComboBox.setItemCaptionPropertyId("name");
    domainComboBox.setEnabled(mc.isPolicyMappingSupported());

    if (domainComboBox.getItemIds().size() > 0) {
        domainComboBox.select(domainContainer.getIdByIndex(0));
    }
    return domainComboBox;
}
 
Example 5
Project: osc-core   File: BaseDAWindow.java   Source Code and License Vote up 6 votes
private ComboBox createEncapsulationTypeComboBox(VirtualizationType virtualizationType,
        List<TagEncapsulationType> types) {
    ComboBox encapsulationType = new ComboBox();
    encapsulationType.setTextInputAllowed(false);
    encapsulationType.setNullSelectionAllowed(true);

    BeanItemContainer<TagEncapsulationType> encapsulationTypeContainer = new BeanItemContainer<TagEncapsulationType>(
            TagEncapsulationType.class, types);
    encapsulationType.setContainerDataSource(encapsulationTypeContainer);
    ApplianceManagerConnectorDto currentMc = (ApplianceManagerConnectorDto) this.managerConnector.getValue();

    if (!virtualizationType.isOpenstack() || (currentMc != null && !currentMc.isPolicyMappingSupported())) {
        encapsulationType.setEnabled(false);
    }
    return encapsulationType;
}
 
Example 6
Project: hypothesis   File: ExportScorePresenterImpl.java   Source Code and License Vote up 6 votes
private void buildSelection() {
	exportSelectionType = new ComboBox();
	exportSelectionType.setTextInputAllowed(false);
	exportSelectionType.setNullSelectionAllowed(false);
	exportSelectionType.setEnabled(false);

	exportSelectionType.addItem(Messages.getString("Caption.Item.Selected"));
	exportSelectionType.addItem(Messages.getString("Caption.Item.All"));
	exportSelectionType.select(Messages.getString("Caption.Item.Selected"));

	exportSelectionType.addValueChangeListener(new Property.ValueChangeListener() {
		public void valueChange(ValueChangeEvent event) {
			allTestsSelected = exportSelectionType.getValue().equals(Messages.getString("Caption.Item.All"));
			mainEvent.fire(new MainUIEvent.PackSelectionChangedEvent());
		}
	});
}
 
Example 7
Project: hypothesis   File: UserManagementPresenterImpl.java   Source Code and License Vote up 6 votes
@Override
protected ComboBox buildSelection() {
	final ComboBox selectionType = new ComboBox();
	selectionType.setTextInputAllowed(false);
	selectionType.setNullSelectionAllowed(false);

	selectionType.addItem(Messages.getString("Caption.Item.Selected"));
	selectionType.addItem(Messages.getString("Caption.Item.All"));
	selectionType.select(Messages.getString("Caption.Item.Selected"));

	selectionType.addValueChangeListener(e -> {
		allSelected = selectionType.getValue().equals(Messages.getString("Caption.Item.All"));
		mainEvent.fire(new MainUIEvent.UserSelectionChangedEvent());
	});

	return selectionType;
}
 
Example 8
Project: hypothesis   File: GroupManagementPresenterImpl.java   Source Code and License Vote up 6 votes
@Override
protected ComboBox buildSelection() {
	final ComboBox selectionType = new ComboBox();
	selectionType.setTextInputAllowed(false);
	selectionType.setNullSelectionAllowed(false);

	selectionType.addItem(Messages.getString("Caption.Item.Selected"));
	selectionType.addItem(Messages.getString("Caption.Item.All"));
	selectionType.select(Messages.getString("Caption.Item.Selected"));

	selectionType.addValueChangeListener(e -> {
		allSelected = selectionType.getValue().equals(Messages.getString("Caption.Item.All"));
		mainEvent.fire(new MainUIEvent.GroupSelectionChangedEvent());
	});

	return selectionType;
}
 
Example 9
Project: VaadinUtils   File: FormHelper.java   Source Code and License Vote up 6 votes
public ComboBox bindEnumField(ComboBox comboBox, AbstractLayout form, ValidatingFieldGroup<E> group,
		String fieldLabel, String fieldName, Class<?> clazz)
{
	ComboBox field = comboBox;
	field.setCaption(fieldLabel);
	field.setContainerDataSource(createContainerFromEnumClass(fieldName, clazz));
	field.setItemCaptionPropertyId(fieldName);
	// field.setCaption(fieldLabel);
	field.setNewItemsAllowed(false);
	field.setNullSelectionAllowed(false);
	field.setTextInputAllowed(true);
	field.setWidth(STANDARD_COMBO_WIDTH);
	field.setPopupWidth("100%");

	field.setImmediate(true);
	field.setId(fieldLabel.replace(" ", ""));
	addValueChangeListeners(field);
	doBinding(group, fieldName, field);

	form.addComponent(field);
	return field;
}
 
Example 10
Project: osc-core   File: BindSecurityGroupWindow.java   Source Code and License Vote up 5 votes
private ComboBox getFailurePolicyComboBox() {
	ComboBox failurePolicy = new ComboBox("Select Failure Policy");
	failurePolicy.setTextInputAllowed(false);
	failurePolicy.setNullSelectionAllowed(false);
	failurePolicy.setImmediate(true);
	failurePolicy.setRequired(true);
	failurePolicy.setRequiredError("Failure Policy cannot be empty");

	failurePolicy.addItems(FailurePolicyType.FAIL_OPEN, FailurePolicyType.FAIL_CLOSE);
	failurePolicy.select(FailurePolicyType.FAIL_OPEN);
	failurePolicy.setEnabled(false);

	return failurePolicy;
}
 
Example 11
Project: KrishnasSpace   File: FilterGrid.java   Source Code and License Vote up 5 votes
/**
 * @param filterRow
 * @return
 */
private HeaderCell setCategoryFilter(HeaderRow filterRow) {
	HeaderCell categoryFilter = filterRow.getCell(CATEGORY);
	ComboBox comboBox = new ComboBox();
	comboBox.setHeight(100, Unit.PERCENTAGE);
	comboBox.setImmediate(true);
	comboBox.setNewItemsAllowed(false);
	comboBox.setTextInputAllowed(false);
	comboBox.addValueChangeListener(getCategoryFilterListener());
	comboBox.setContainerDataSource(getCategoryDataSource());
	categoryFilter.setComponent(comboBox);
	return categoryFilter;
}
 
Example 12
Project: metl   File: EditXmlFormatPanel.java   Source Code and License Vote up 5 votes
protected void buildGrid() {
    grid = new Grid();
    grid.setSelectionMode(SelectionMode.NONE);
    grid.setSizeFull();
    grid.setEditorEnabled(!readOnly);
    container = new BeanItemContainer<Record>(Record.class);
    grid.setContainerDataSource(container);
    grid.setColumns("entityName", "attributeName", "xpath");
    HeaderRow filterRow = grid.appendHeaderRow();

    addColumn("entityName", filterRow);

    addColumn("attributeName", filterRow);

    ComboBox combo = new ComboBox();
    combo.addValueChangeListener(e->saveXPathSettings());
    combo.setWidth(100, Unit.PERCENTAGE);
    combo.setImmediate(true);
    combo.setNewItemsAllowed(true);
    combo.setInvalidAllowed(true);
    combo.setTextInputAllowed(true);
    combo.setScrollToSelectedItem(true);
    combo.setFilteringMode(FilteringMode.CONTAINS);
    grid.getColumn("xpath").setEditorField(combo).setExpandRatio(1);
    addShowPopulatedFilter("xpath", filterRow);
    grid.setEditorBuffered(false);
    addComponent(grid);
    setExpandRatio(grid, 1);
}
 
Example 13
Project: VaadinUtils   File: FormHelper.java   Source Code and License Vote up 5 votes
public <L> ComboBox bindComboBox(AbstractLayout form, ValidatingFieldGroup<E> fieldGroup, String fieldName,
		String fieldLabel, Collection<?> options)
{
	ComboBox field = new SplitComboBox(fieldLabel, options);
	field.setNewItemsAllowed(false);
	field.setNullSelectionAllowed(false);
	field.setTextInputAllowed(true);
	field.setWidth(STANDARD_COMBO_WIDTH);
	field.setPopupWidth("100%");
	field.setImmediate(true);
	form.addComponent(field);
	addValueChangeListeners(field);
	doBinding(group, fieldName, field);
	return field;
}
 
Example 14
Project: VaadinUtils   File: FormHelper.java   Source Code and License Vote up 5 votes
public <L> ComboBox bindComboBox(AbstractLayout form, ValidatingFieldGroup<E> fieldGroup, String fieldName,
		String fieldLabel, Container options)
{
	ComboBox field = new SplitComboBox(fieldLabel, options);
	field.setNewItemsAllowed(false);
	field.setNullSelectionAllowed(false);
	field.setTextInputAllowed(true);
	field.setWidth(STANDARD_COMBO_WIDTH);
	field.setPopupWidth("100%");
	field.setImmediate(true);
	form.addComponent(field);
	addValueChangeListeners(field);
	doBinding(group, fieldName, field);
	return field;
}
 
Example 15
Project: VaadinUtils   File: ReportParameterReportChooser.java   Source Code and License Vote up 5 votes
/**
 * 
 * @param caption
 * @param defaultValue
 * @param parameterName
 * @param enumClass
 */
public ReportParameterReportChooser(String caption, T defaultValue, String parameterName, Class<T> enumClass)
{
	super(caption, parameterName);
	field = new ComboBox(caption);
	this.enumClass = enumClass;
	field.setContainerDataSource(FormHelper.createContainerFromEnumClass("value", enumClass));
	field.setNewItemsAllowed(false);
	field.setNullSelectionAllowed(false);
	field.setTextInputAllowed(false);
	field.setValue(defaultValue);
}
 
Example 16
Project: VaadinUtils   File: ReportParameterEnum.java   Source Code and License Vote up 5 votes
/**
 * 
 * @param caption
 * @param defaultValue
 * @param parameterName
 * @param enumClass
 */
public ReportParameterEnum(String caption, T defaultValue, String parameterName, Class<T> enumClass)
{
	super(caption, parameterName);
	field = new ComboBox(caption);
	this.enumClass = enumClass;
	field.setContainerDataSource(FormHelper.createContainerFromEnumClass("value", enumClass));
	field.setNewItemsAllowed(false);
	field.setNullSelectionAllowed(false);
	field.setTextInputAllowed(false);
	field.setValue(defaultValue);
}
 
Example 17
Project: scoutmaster   File: RaffleAllocationChildView.java   Source Code and License Vote up 5 votes
@Override
protected Component buildEditor(final ValidatingFieldGroup<RaffleAllocation> fieldGroup2)
{
	final MultiColumnFormLayout<RaffleAllocation> overviewForm = new MultiColumnFormLayout<RaffleAllocation>(1,
			this.fieldGroup);
	overviewForm.setColumnFieldWidth(0, 240);
	overviewForm.setColumnLabelWidth(0, 110);
	// overviewForm.setColumnExpandRatio(0, 1.0f);
	overviewForm.setSizeFull();

	final FormHelper<RaffleAllocation> formHelper = overviewForm.getFormHelper();

	final ComboBox allocatedTo = formHelper.new EntityFieldBuilder<Contact>().setLabel("Allocated To")
			.setField(RaffleAllocation_.allocatedTo).setListFieldName(Contact_.fullname).build();
	allocatedTo.setFilteringMode(FilteringMode.CONTAINS);
	allocatedTo.setTextInputAllowed(true);
	allocatedTo.setNullSelectionAllowed(true);
	allocatedTo.setDescription("The person the book has been allocated to.");

	overviewForm.bindDateField("Date Allocated", RaffleAllocation_.dateAllocated, "yyyy-MM-dd", Resolution.DAY);

	final ComboBox issuedBy = formHelper.new EntityFieldBuilder<Contact>().setLabel("Issued By")
			.setField(RaffleAllocation_.issuedBy).setListFieldName(Contact_.fullname).build();
	issuedBy.setFilteringMode(FilteringMode.CONTAINS);
	issuedBy.setTextInputAllowed(true);
	issuedBy.setDescription("The leader that issued the book to the member.");
	issuedBy.setNullSelectionAllowed(true);

	overviewForm.bindDateField("Date Issued", RaffleAllocation_.dateIssued, "yyyy-MM-dd", Resolution.DAY);

	final TextField bookCountField = overviewForm.bindTextField("Book Count", "bookCount");
	bookCountField.setReadOnly(true);

	overviewForm.bindTextAreaField("Notes", RaffleAllocation_.notes, 6);

	return overviewForm;
}
 
Example 18
Project: scoutmaster   File: ChildRelationshipView.java   Source Code and License Vote up 5 votes
@Override
protected Component buildEditor(final ValidatingFieldGroup<Relationship> fieldGroup2)
{
	final SMMultiColumnFormLayout<Relationship> relationshipForm = new SMMultiColumnFormLayout<Relationship>(1,
			this.fieldGroup);
	relationshipForm.setColumnFieldWidth(0, 180);

	final FormHelper<Relationship> formHelper = relationshipForm.getFormHelper();

	/**
	 * The type of relationship. e.g. Parent of
	 */
	final ComboBox type = formHelper.new EntityFieldBuilder<RelationshipType>().setLabel("Relationship")
			.setField(Relationship_.type).setListFieldName(RelationshipType_.lhs).build();
	type.setFilteringMode(FilteringMode.CONTAINS);
	type.setTextInputAllowed(true);

	/**
	 * The contact we are related to.
	 */
	this.relatedTo = formHelper.new EntityFieldBuilder<Contact>().setLabel("Related To").setField(Relationship_.rhs)
			.setListFieldName(Contact_.fullname).build();
	this.relatedTo.setFilteringMode(FilteringMode.CONTAINS);
	this.relatedTo.setTextInputAllowed(true);

	@SuppressWarnings("unchecked")
	final JPAContainer<Relationship> rhscontainer = (JPAContainer<Relationship>) this.relatedTo
			.getContainerDataSource();
	rhscontainer.sort(new String[]
	{ Contact_.lastname.getName(), Contact_.firstname.getName() }, new boolean[]
	{ true, true });

	return relationshipForm;
}
 
Example 19
Project: academ   File: PanelAlcance.java   Source Code and License Vote up 5 votes
public void cargarResultadosAlcances(List<ResultadoAprendizajeBO>list) {
	tableResultadoAlcance.removeAllItems();
	for(int i = 1; i<list.size(); i++){
		ComboBox box = new ComboBox();
		box.addItem("Introduce");
		box.addItem("Enseña");
		box.addItem("Aplica");
		box.setNullSelectionAllowed(false);
		box.setTextInputAllowed(false);
		tableResultadoAlcance.addItem(new Object[] {list.get(i).getNivelDeConocimiento().getDescripcion(),box}, new Integer(i));
	}
}
 
Example 20
Project: esup-ecandidat   File: GridFormatting.java   Source Code and License Vote up 4 votes
/**
 * Ajoute un filtre de Boolean sur une liste de colonnes
 * 
 * @param filterRow
 * @param container
 * @param property
 * @param labelTrue
 * @param labelFalse
 * @param labelNull
 */
private void addBooleanFilter(String property, String labelTrue, String labelFalse, String labelNull) {
	HeaderCell cell = getFilterCell(property);
	ComboBox cbOuiNon = new ComboBox();
	cbOuiNon.setTextInputAllowed(false);

	List<BooleanPresentation> liste = new ArrayList<BooleanPresentation>();
	BooleanPresentation nullObject = new BooleanPresentation(BooleanValue.ALL,
			applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()), null);
	liste.add(nullObject);

	if (labelTrue != null) {
		liste.add(new BooleanPresentation(BooleanValue.TRUE, labelTrue, FontAwesome.CHECK_SQUARE_O));
	}
	if (labelFalse != null) {
		liste.add(new BooleanPresentation(BooleanValue.FALSE, labelFalse, FontAwesome.SQUARE_O));
	}
	if (labelNull != null) {
		liste.add(new BooleanPresentation(BooleanValue.NULL, labelNull, FontAwesome.HOURGLASS_HALF));
	}

	BeanItemContainer<BooleanPresentation> containerOuiNon = new BeanItemContainer<BooleanPresentation>(
			BooleanPresentation.class, liste);
	cbOuiNon.setNullSelectionItemId(nullObject);
	cbOuiNon.setImmediate(true);
	cbOuiNon.setContainerDataSource(containerOuiNon);
	cbOuiNon.setItemCaptionPropertyId("libelle");
	cbOuiNon.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	cbOuiNon.setItemIconPropertyId("icone");
	cbOuiNon.setWidth(100, Unit.PERCENTAGE);
	cbOuiNon.addStyleName(ValoTheme.COMBOBOX_TINY);

	cbOuiNon.addValueChangeListener(change -> {
		container.removeContainerFilters(property);
		if (cbOuiNon.getValue() != null) {
			BooleanPresentation value = (BooleanPresentation) cbOuiNon.getValue();
			if (value != null) {
				BooleanValue booleanValue = value.getValeur();
				switch (booleanValue) {
				case TRUE:
					container.addContainerFilter(new Equal(property, true));
					break;
				case FALSE:
					container.addContainerFilter(new Equal(property, false));
					break;
				case NULL:
					container.addContainerFilter(new Equal(property, null));
					break;
				default:
					break;
				}
			}
			fireFilterListener();
		}
	});
	cell.setComponent(cbOuiNon);
}
 
Example 21
Project: cuba   File: SettingsWindow.java   Source Code and License Vote up 4 votes
@Override
public void init(Map<String, Object> params) {
    Boolean changeThemeEnabledParam = (Boolean) params.get("changeThemeEnabled");
    if (changeThemeEnabledParam != null) {
        changeThemeEnabled = changeThemeEnabledParam;
    }

    AppWorkArea.Mode mode = userSettingsTools.loadAppWindowMode();
    msgTabbed = getMessage("modeTabbed");
    msgSingle = getMessage("modeSingle");

    modeOptions.setOptionsList(Arrays.asList(msgTabbed, msgSingle));
    if (mode == AppWorkArea.Mode.TABBED)
        modeOptions.setValue(msgTabbed);
    else
        modeOptions.setValue(msgSingle);

    ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
    Set<String> supportedThemes = themeRepository.getAvailableThemes();
    appThemeField.setOptionsList(new ArrayList<>(supportedThemes));

    String userAppTheme = userSettingsTools.loadAppWindowTheme();
    appThemeField.setValue(userAppTheme);

    ComboBox vAppThemeField = (ComboBox) WebComponentsHelper.unwrap(appThemeField);
    vAppThemeField.setTextInputAllowed(false);
    appThemeField.setEditable(changeThemeEnabled);

    initTimeZoneFields();

    User user = userSession.getUser();
    changePasswordBtn.setAction(new BaseAction("changePassw")
            .withCaption(getMessage("changePassw"))
            .withHandler(event -> {
                Window passwordDialog = openWindow("sec$User.changePassword", OpenType.DIALOG,
                        ParamsMap.of("currentPasswordRequired", true));
                passwordDialog.addCloseListener(actionId -> {
                    // move focus back to window
                    changePasswordBtn.requestFocus();
                });
            }));

    if (!user.equals(userSession.getCurrentOrSubstitutedUser())
            || ExternalUserCredentials.isLoggedInWithExternalAuth(userSession)) {
        changePasswordBtn.setEnabled(false);
    }

    Map<String, Locale> locales = globalConfig.getAvailableLocales();
    TreeMap<String, Object> options = new TreeMap<>();
    for (Map.Entry<String, Locale> entry : locales.entrySet()) {
        options.put(entry.getKey(), messages.getTools().localeToString(entry.getValue()));
    }
    appLangField.setOptionsMap(options);
    appLangField.setValue(userManagementService.loadOwnLocale());

    Action commitAction = new BaseAction("commit")
            .withCaption(messages.getMainMessage("actions.Ok"))
            .withShortcut(clientConfig.getCommitShortcut())
            .withHandler(event ->
                    commit()
            );
    addAction(commitAction);
    okBtn.setAction(commitAction);

    cancelBtn.setAction(new BaseAction("cancel")
            .withCaption(messages.getMainMessage("actions.Cancel"))
            .withHandler(event ->
                    cancel()
            ));

    initDefaultScreenField();
}
 
Example 22
Project: flightservice   File: FlightMaintenanceView.java   Source Code and License Vote up 4 votes
private FormLayout createForm() {
	TextField numberTextField = new TextField("Number");
	numberTextField.setRequired(true);
	numberTextField.setRequiredError("Please enter a flight number!");
	numberTextField.setNullRepresentation("");
	numberTextField.addValidator(new RegexpValidator("\\w\\w\\d\\d\\d", "Please enter a valid flight number!"));

	TextField airlineTextField = new TextField("Airline");
	airlineTextField.setRequired(true);
	airlineTextField.setRequiredError("Please enter an airline!");
	airlineTextField.setNullRepresentation("");

	ComboBox departureAirportField = new ComboBox("Departure Airport");
	departureAirportField.setTextInputAllowed(false);
	departureAirportField.setRequired(true);
	departureAirportField.setRequiredError("Please select a depature airport!");
	departureAirportField.setItemCaptionPropertyId("name");
	departureAirportField.setContainerDataSource(airportContainer);

	ComboBox destinationAirportField = new ComboBox("Destination Airport");
	destinationAirportField.setTextInputAllowed(false);
	destinationAirportField.setRequired(true);
	destinationAirportField.setRequiredError("Please select a destination airport!");
	destinationAirportField.setItemCaptionPropertyId("name");
	destinationAirportField.setContainerDataSource(airportContainer);

	TextField priceField = new TextField("Price");
	priceField.setRequired(true);
	priceField.setRequiredError("Please enter a price!");
	priceField.setNullRepresentation("");
	priceField.setConverter(new StringToBigDecimalConverter());
	priceField.addValidator(new BigDecimalRangeValidator("Please enter a valid price!", new BigDecimal("0.01"), null));

	DateField departureField = new DateField("Departure Date");
	departureField.setDateFormat("dd.MM.yyyy");
	departureField.setRequired(true);
	departureField.setRequiredError("Please enter a departure date!");
	departureField.addValidator(new DateRangeValidator("Please enter departure date in the future!", new Date(), null, Resolution.DAY));

	flightFieldGroup.bind(numberTextField, "number");
	flightFieldGroup.bind(airlineTextField, "airline");
	flightFieldGroup.bind(departureAirportField, "departureAirport");
	flightFieldGroup.bind(destinationAirportField, "destinationAirport");
	flightFieldGroup.bind(priceField, "price");
	flightFieldGroup.bind(departureField, "date");

	return new FormLayout(numberTextField, airlineTextField, departureAirportField, destinationAirportField, priceField, departureField);
}
 
Example 23
Project: ExpressZip   File: FindLayersViewComponent.java   Source Code and License Vote up 4 votes
private void setupAddFilterWindow(Window window) {
	// General variables

	// Layouts
	GridLayout mainLayout = new GridLayout(1, 3);
	HorizontalLayout axisLayout = new HorizontalLayout();
	HorizontalLayout criteriaLayout = new HorizontalLayout();
	HorizontalLayout buttonLayout = new HorizontalLayout();
	hznCriteria = criteriaLayout;

	// Buttons
	ExpressZipButton btnAdd = new ExpressZipButton("Add", Style.ACTION);
	btnAdd.setClickShortcut(KeyCode.ENTER);
	btnAdd.addStyleName("primary");
	ExpressZipButton btnCancel = new ExpressZipButton("Cancel", Style.ACTION);

	// Fields
	ComboBox cmbAxis = new ComboBox();
	cmbAxis.setTextInputAllowed(false);
	cmbAxis.setNullSelectionAllowed(false);

	// Labels
	Label lblAxis = new Label("Axis");

	btnAdd.addListener(filterButtonListener);
	btnCancel.addListener(filterButtonListener);

	for (Filter.AxisFilters f : Filter.axisArray) {
		cmbAxis.addItem(filter.getNameOfFilter(f));
	}
	cmbAxis.setImmediate(true);
	cmbAxis.addListener(axisSelectedListener);
	cmbAxis.setValue(filter.getNameOfFilter(Filter.axisArray[0]));

	mainLayout.addComponent(axisLayout, 0, 0);
	mainLayout.addComponent(criteriaLayout, 0, 1);
	mainLayout.addComponent(buttonLayout, 0, 2);
	mainLayout.setSpacing(true);

	axisLayout.setSpacing(true);

	axisLayout.addComponent(lblAxis);
	axisLayout.addComponent(cmbAxis);
	axisLayout.setExpandRatio(lblAxis, .2f);
	axisLayout.setExpandRatio(cmbAxis, .8f);
	axisLayout.setComponentAlignment(lblAxis, Alignment.MIDDLE_LEFT);
	axisLayout.setComponentAlignment(cmbAxis, Alignment.MIDDLE_LEFT);
	axisLayout.setSizeFull();

	criteriaLayout.setSizeFull();

	buttonLayout.setSpacing(true);
	buttonLayout.addComponent(btnAdd);
	buttonLayout.addComponent(btnCancel);
	buttonLayout.setComponentAlignment(btnAdd, Alignment.BOTTOM_RIGHT);
	buttonLayout.setComponentAlignment(btnCancel, Alignment.BOTTOM_RIGHT);
	buttonLayout.setExpandRatio(btnAdd, 1f);
	buttonLayout.setExpandRatio(btnCancel, 0f);
	buttonLayout.setSizeFull();

	mainLayout.setRowExpandRatio(0, 1f);
	mainLayout.setRowExpandRatio(1, 1f);
	mainLayout.setRowExpandRatio(2, 1f);
	mainLayout.setSizeFull();

	window.addComponent(mainLayout);
	window.getContent().setSizeFull();
}
 
Example 24
Project: VaadinUtils   File: BaseCrudView.java   Source Code and License Vote up 4 votes
private void buildActionLayout()
{
	actionLayout = new HorizontalLayout();
	actionLayout.setWidth("100%");
	actionLayout.setMargin(new MarginInfo(false, true, false, false));

	actionLabel = new Label("&nbsp;Action");
	actionLabel.setContentMode(ContentMode.HTML);
	actionLabel.setWidth("50");

	actionGroupLayout.addStyleName("v-component-group");
	actionLayout.addComponent(actionGroupLayout);
	actionGroupLayout.addComponent(actionLabel);

	actionCombo = new ComboBox(null);
	actionCombo.setWidth("160");
	actionCombo.setNullSelectionAllowed(false);
	actionCombo.setTextInputAllowed(false);
	actionGroupLayout.addComponent(actionCombo);

	addCrudActions();
	actionGroupLayout.addComponent(actionApplyButton);
	actionApplyButton.setId("applyButton");

	actionMessage = new Label("", ContentMode.HTML);
	actionGroupLayout.addComponent(actionMessage);

	String newButtonLabel = getNewButtonLabel();
	if (newButtonLabel == null)
	{
		newButtonLabel = "";
	}
	actionNewButton.setCaption(newButtonLabel);
	actionNewButton.setId("CrudNewButton-" + newButtonLabel.replace(" ", ""));
	actionLayout.addComponent(actionNewButton);

	actionLayout.setComponentAlignment(actionGroupLayout, Alignment.MIDDLE_LEFT);
	actionLayout.setComponentAlignment(actionNewButton, Alignment.MIDDLE_RIGHT);
	actionLayout.setExpandRatio(actionGroupLayout, 1.0f);
	actionLayout.setHeight("35");
}
 
Example 25
Project: scoutmaster   File: RaffleView.java   Source Code and License Vote up 4 votes
private void buildOverviewTab()
{
	final SMMultiColumnFormLayout<Raffle> overviewForm = new SMMultiColumnFormLayout<Raffle>(1, this.fieldGroup);
	overviewForm.setColumnFieldWidth(0, 300);
	overviewForm.setSizeFull();

	overviewForm.bindTextField("Name", Raffle_.name);
	overviewForm.bindTextAreaField("Notes", Raffle_.notes, 6);
	overviewForm.bindDateField("Start Date", Raffle_.startDate, "yyyy/MM/dd", Resolution.DAY);
	overviewForm.bindDateField("Collect By Date", Raffle_.collectionsDate, "yyyy/MM/dd", Resolution.DAY)
			.setDescription("The date the raffle ticksets need to be collected by.");
	overviewForm.bindDateField("Return Date", Raffle_.returnDate, "yyyy/MM/dd", Resolution.DAY)
			.setDescription("The date the raffle ticksets need to be returned to Branch.");

	final FormHelper<Raffle> formHelper = overviewForm.getFormHelper();
	final ComboBox groupRaffleManager = formHelper.new EntityFieldBuilder<Contact>()
			.setLabel("Group Raffle Manager").setField(Raffle_.groupRaffleManager)
			.setListFieldName(Contact_.fullname).build();
	groupRaffleManager.setFilteringMode(FilteringMode.CONTAINS);
	groupRaffleManager.setTextInputAllowed(true);
	groupRaffleManager.setDescription("The Group member responsible for organising the Raffle.");

	final ComboBox branchRaffleConact = formHelper.new EntityFieldBuilder<Contact>()
			.setLabel("Branch Raffle Contact").setField(Raffle_.branchRaffleContact)
			.setListFieldName(Contact_.fullname).build();
	branchRaffleConact.setFilteringMode(FilteringMode.CONTAINS);
	branchRaffleConact.setTextInputAllowed(true);
	branchRaffleConact.setDescription("The Branch person who is a main contact for Raffle issues.");

	overviewForm.bindTextField("Book No. Prefix", Raffle_.raffleNoPrefix)
			.setDescription("If raffle books have a non-numeric prefix for the ticket no's enter it here.");
	overviewForm.bindTextField("Tickets per Book", Raffle_.ticketsPerBook);
	overviewForm.bindTextField("Total Tickets Sold", Raffle_.totalTicketsSold).setReadOnly(true);
	overviewForm.bindTextField("Tickets Outstanding", Raffle_.ticketsOutstanding).setReadOnly(true);
	overviewForm.bindTextField("Sales Price per Ticket", Raffle_.salePricePerTicket)
			.setDescription("The amount each ticket is to be sold for.");
	overviewForm.bindTextField("Revenue Target", Raffle_.revenueTarget)
			.setDescription("The amount the Group is aiming to raise via the Raffle.");

	overviewForm.bindTextField("Revenue Raised", Raffle_.revenueRaised).setReadOnly(true);

	this.tabs.addTab(overviewForm, "Raffle");
}
 
Example 26
Project: scoutmaster   File: ImportMatchFields.java   Source Code and License Vote up 4 votes
@Override
public Component getContent()
{
	try
	{
		if (this.reset)
		{
			this.reset = false;
			this.layout = new GridLayout(3, 1);
			this.layout.setMargin(true);
			this.layout.setSpacing(true);
			// layout.setSizeFull();

			final String[] headers = getHeaders();

			final Class<? extends Importable> importable = this.importView.getType().getEntityClass();
			final EntityAdaptor<?> adaptor = EntityAdaptor.create(importable);

			final ArrayList<FormFieldImpl> fields = adaptor.getFields();
			for (final String header : headers)
			{
				final Label headerLabel = new Label(header);
				this.layout.addComponent(headerLabel);
				headerLabel.setWidth("" + 160);

				final Label mapToLabel = new Label("--Maps to-->");
				this.layout.addComponent(mapToLabel);
				mapToLabel.setWidth("" + 100);

				final ComboBox box = new ComboBox(null, fields);
				box.setNullSelectionAllowed(true);
				box.setInputPrompt("--Please Select--");
				box.setNullSelectionItemId("--Please Select--");
				box.setTextInputAllowed(false);
				// ComboBox box = layout.addComponent("", fields);
				this.layout.addComponent(box);
				this.mappings.add(box);
				this.layout.newLine();
			}
		}
	}
	catch (final IOException e)
	{
		Notification.show("An error occured trying to read the CSV file: " + e.getMessage(), Type.ERROR_MESSAGE);
	}

	return this.layout;
}
 
Example 27
Project: scoutmaster   File: GroupDetailStep.java   Source Code and License Vote up 4 votes
@Override
public Component getContent()
{
	if (form == null)
	{
		form = new SimpleFormLayout();
		form.setMargin(true);

		final Label label = new Label("<h1>Please enter your Group's details.</h1>", ContentMode.HTML);
		label.setContentMode(ContentMode.HTML);

		form.addComponent(label);

		groupName = new TextField("Group Name");
		form.addComponent(groupName);

		groupTypeField = new ComboBox("Group Type");
		groupTypeField.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
		groupTypeField.setTextInputAllowed(false);
		groupTypeField.setRequired(true);
		loadGroupTypes();
		form.addComponent(groupTypeField);

		phoneNo = new TextField("Phone No.");
		form.addComponent(phoneNo);
		street = new TextField("Street");
		form.addComponent(street);
		city = new TextField("City/Suburb");
		form.addComponent(city);
		state = new TextField("State");
		form.addComponent(state);
		postcode = new TextField("Postcode/Zip Code");
		form.addComponent(postcode);

		countries = new ComboBox("Country");
		loadCountries(countries);
		form.addComponent(countries);

		groupName.addValidator(
				new StringLengthValidator("Group Name must be between 6 and 255 characters long.", 6, 255, false));
		groupName.addValidator(value -> {
			// tell the user if their group name is unique.
			GroupDao groupDao = new DaoFactory().getGroupDao();
			String groupNameString = ((String) value).trim();
			if (groupNameString.length() > 0)
			{
				if (groupDao.findByName(groupNameString) != null)
					throw new Validator.InvalidValueException("Group name already exists. Please choose another.");
			}

		});
	}

	return form;
}
 
Example 28
Project: scoutmaster   File: SelectRaffleStep.java   Source Code and License Vote up 4 votes
AbstractLayout buildNewRaffleLayout(final ValidatingFieldGroup<Raffle> fieldGroup)
{
	final SMMultiColumnFormLayout<Raffle> overviewForm = new SMMultiColumnFormLayout<Raffle>(1, fieldGroup);
	overviewForm.setColumnFieldWidth(0, 300);
	overviewForm.setSizeFull();

	overviewForm.bindTextField("Name", Raffle_.name);
	overviewForm.bindTextAreaField("Notes", Raffle_.notes, 6);
	overviewForm.bindDateField("Start Date", Raffle_.startDate, "yyyy/MM/dd", Resolution.DAY);
	overviewForm.bindDateField("Collect By Date", Raffle_.collectionsDate, "yyyy/MM/dd", Resolution.DAY)
	.setDescription("The date the raffle ticksets need to be collected by.");
	overviewForm.bindDateField("Return Date", Raffle_.returnDate, "yyyy/MM/dd", Resolution.DAY).setDescription(
			"The date the raffle ticksets need to be returned to Branch.");

	final FormHelper<Raffle> formHelper = overviewForm.getFormHelper();
	final ComboBox groupRaffleManager = formHelper.new EntityFieldBuilder<Contact>()
			.setLabel("Group Raffle Manager").setField(Raffle_.groupRaffleManager)
			.setListFieldName(Contact_.fullname).build();
	groupRaffleManager.setFilteringMode(FilteringMode.CONTAINS);
	groupRaffleManager.setTextInputAllowed(true);
	groupRaffleManager.setDescription("The Group member responsible for organising the Raffle.");

	final ComboBox branchRaffleConact = formHelper.new EntityFieldBuilder<Contact>()
			.setLabel("Branch Raffle Contact").setField(Raffle_.branchRaffleContact)
			.setListFieldName(Contact_.fullname).build();
	branchRaffleConact.setFilteringMode(FilteringMode.CONTAINS);
	branchRaffleConact.setTextInputAllowed(true);
	branchRaffleConact.setDescription("The Branch person who is a main contact for Raffle issues.");

	overviewForm.bindTextField("Book No. Prefix", Raffle_.raffleNoPrefix).setDescription(
			"If raffle books have a non-numeric prefix for the ticket no's enter it here.");
	overviewForm.bindTextField("Tickets per Book", Raffle_.ticketsPerBook);
	overviewForm.bindTextField("Total Tickets Sold", Raffle_.totalTicketsSold).setReadOnly(true);
	overviewForm.bindTextField("Tickets Outstanding", Raffle_.ticketsOutstanding).setReadOnly(true);
	overviewForm.bindTextField("Sales Price per Ticket", Raffle_.salePricePerTicket).setDescription(
			"The amount each ticket is to be sold for.");
	overviewForm.bindTextField("Revenue Target", Raffle_.revenueTarget).setDescription(
			"The amount the Group is aiming to raise via the Raffle.");

	overviewForm.bindTextField("Revenue Raised", Raffle_.revenueRaised).setReadOnly(true);

	return overviewForm;

}
 
Example 29
Project: scoutmaster   File: RaffleBookChildView.java   Source Code and License Vote up 4 votes
@Override
protected Component buildEditor(final ValidatingFieldGroup<RaffleBook> fieldGroup2)
{
	final MultiColumnFormLayout<RaffleBook> overviewForm = new MultiColumnFormLayout<RaffleBook>(1, this.fieldGroup);
	overviewForm.setColumnFieldWidth(0, 240);
	overviewForm.setColumnLabelWidth(0, 110);
	overviewForm.setSizeFull();

	final FormHelper<RaffleBook> formHelper = overviewForm.getFormHelper();

	overviewForm.bindTextField("Ticket Count", RaffleBook_.ticketCount);
	overviewForm.bindTextField("First No.", RaffleBook_.firstNo);

	this.allocatedTo = formHelper.new EntityFieldBuilder<Contact>().setLabel("Allocated To")
			.setField(new Path(RaffleBook_.raffleAllocation, RaffleAllocation_.allocatedTo).getName())
			.setListFieldName(Contact_.fullname).setListClass(Contact.class).build();
	this.allocatedTo.setFilteringMode(FilteringMode.CONTAINS);
	this.allocatedTo.setTextInputAllowed(true);
	this.allocatedTo.setNullSelectionAllowed(true);
	this.allocatedTo.setDescription("The person the book has been allocated to.");
	// you can't edit the allocation.
	this.allocatedTo.setReadOnly(true);

	overviewForm.bindTextField("Tickets Returned?", RaffleBook_.ticketsReturned).setDescription(
			"The no. of tickets that have been returned.");

	overviewForm.bindTextField("Amount Returned?", RaffleBook_.amountReturned).setDescription(
			"The amount of money returned for this book.");

	overviewForm.bindDateField("Date Returned", RaffleBook_.dateReturned, "yyyy-MM-dd", Resolution.DAY)
	.setDescription("The date the money and tickets for this book were returned");

	final ComboBox collectedBy = formHelper.new EntityFieldBuilder<Contact>().setLabel("Collected By")
			.setField(RaffleBook_.collectedBy).setListFieldName(Contact_.fullname).build();
	collectedBy.setFilteringMode(FilteringMode.CONTAINS);
	collectedBy.setTextInputAllowed(true);
	collectedBy.setDescription("The leader that collected the ticket stubs and money.");

	overviewForm.bindBooleanField("Receipt Issued?", RaffleBook_.receiptIssued).setDescription(
			"Has a receipt been issued for the return of this book?");

	overviewForm.bindTextAreaField("Notes", RaffleBook_.notes, 6);

	return overviewForm;
}
 
Example 30
Project: academ   File: ConsolidadoEvaluacion.java   Source Code and License Vote up 4 votes
public void cargarTemas(List<TemaBO> temas, List<List<CalificacionRolBO>> calificaciones, List<Integer> promediosG) {

		tablaConsolidado.removeAllItems();

		for(int i =0;i< temas.size();i++)
		{
			TemaBO tema = temas.get(i);
			boolean calificado = false;
			ArrayList<Object>info = new ArrayList<Object>();
			info.add(tema.getId());
			info.add(tema.getNombre());
			for(int j=0;j<calificaciones.size();j++)
			{
				List<CalificacionRolBO> calificacionesRol = calificaciones.get(j);
				if( i < calificacionesRol.size() )
				{
					int nivel = calificacionesRol.get(i).getNivelDeConocimiento().getId();
					info.add( nivel + "");
					calificado = true;
				}
				else
				{
					calificado = false;
					info.add("NC");
				}
			}
			ComboBox caja = new ComboBox();
			caja.setNullSelectionAllowed(false);
			caja.setTextInputAllowed(false);
			for(int j=0;j<5;j++)
			{
				caja.addItem(j);
			}
			if( calificado )
				caja.select( promediosG.get(i));
		
			info.add(caja);
			info.add( new CheckBox() );
			tablaConsolidado.addItem(info.toArray(), tema);
		}
	}