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

The following are Jave code examples for showing how to use setNewItemsAllowed() 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: SecureBPMN   File: SelectUsersPopupWindow.java   Source Code and License Vote up 6 votes
protected void selectUser(String userId, String userName) {
  if (!selectedUsersTable.containsId(userId)) {
    Item item = selectedUsersTable.addItem(userId);
    item.getItemProperty("userName").setValue(userName);
    
    if (showRoles) {
      ComboBox comboBox = new ComboBox(null, Arrays.asList(
              i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR),
              i18nManager.getMessage(Messages.TASK_ROLE_IMPLEMENTER),
              i18nManager.getMessage(Messages.TASK_ROLE_MANAGER),
              i18nManager.getMessage(Messages.TASK_ROLE_SPONSOR)));
      comboBox.select(i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR));
      comboBox.setNewItemsAllowed(true);
      item.getItemProperty("role").setValue(comboBox);
    }
  }
}
 
Example 2
Project: dhconvalidator   File: UserSwitchPanel.java   Source Code and License Vote up 6 votes
/**
 * Setup UI.
 */
private void initComponents() {
	List<User> users = UserList.INSTANCE.getUsers();
	userSwitchBox = new ComboBox(Messages.getString("UserSwitchPanel.boxCaption")); //$NON-NLS-1$
	setUsers(users);
	User current = (User) VaadinSession.getCurrent().getAttribute(SessionStorageKey.USER.name());
	userSwitchBox.setValue(current);
	
	userSwitchBox.setDescription(
		Messages.getString("UserSwitchPanel.boxDescription")); //$NON-NLS-1$
	userSwitchBox.setNewItemsAllowed(false);
	userSwitchBox.setNullSelectionAllowed(false);
	
	addComponent(userSwitchBox);
	btReload = new Button(Messages.getString("UserSwitchPanel.reloadCaption")); //$NON-NLS-1$
	btReload.setStyleName(BaseTheme.BUTTON_LINK);
	btReload.addStyleName("plain-link"); //$NON-NLS-1$
	
	addComponent(btReload);
}
 
Example 3
Project: FiWare-Template-Handler   File: SelectUsersPopupWindow.java   Source Code and License Vote up 6 votes
protected void selectUser(String userId, String userName) {
  if (!selectedUsersTable.containsId(userId)) {
    Item item = selectedUsersTable.addItem(userId);
    item.getItemProperty("userName").setValue(userName);
    
    if (showRoles) {
      ComboBox comboBox = new ComboBox(null, Arrays.asList(
              i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR),
              i18nManager.getMessage(Messages.TASK_ROLE_IMPLEMENTER),
              i18nManager.getMessage(Messages.TASK_ROLE_MANAGER),
              i18nManager.getMessage(Messages.TASK_ROLE_SPONSOR)));
      comboBox.select(i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR));
      comboBox.setNewItemsAllowed(true);
      item.getItemProperty("role").setValue(comboBox);
    }
  }
}
 
Example 4
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 5
Project: KrishnasSpace   File: BasicFormImpl.java   Source Code and License Vote up 5 votes
/**
 * @param caption
 * @param bindName
 * @param container
 *            TODO
 * @return
 */
private ComboBox getComboBox(String caption, String bindName,
		Container container) {
	ComboBox comboBox = new ComboBox(caption);
	comboBox.setImmediate(true);
	comboBox.setValidationVisible(false);
	comboBox.setNewItemsAllowed(false);
	comboBox.setFilteringMode(FilteringMode.CONTAINS);
	comboBox.setNullSelectionAllowed(false);
	fieldGroup.bind(comboBox, bindName);
	comboBox.setContainerDataSource(container);
	return comboBox;
}
 
Example 6
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 7
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 8
Project: metl   File: EditTransformerPanel.java   Source Code and License Vote up 5 votes
public Field<?> createField(final Container dataContainer, final Object itemId, final Object propertyId,
        com.vaadin.ui.Component uiContext) {
    final ComponentAttribSetting setting = (ComponentAttribSetting) itemId;
    Field<?> field = null;

    if (propertyId.equals("value") && (setting.getValue() == null || !setting.getValue().contains("\n"))) {
        final ComboBox combo = new ComboBox();
        combo.setWidth(100, Unit.PERCENTAGE);
        String[] functions = ModelAttributeScriptHelper.getSignatures();
        for (String function : functions) {
            combo.addItem(function);
        }
        combo.setPageLength(functions.length > 20 ? 20 : functions.length);
        if (setting.getValue() != null && !combo.getItemIds().contains(setting.getValue())) {
            combo.addItem(setting.getValue());
        }
        combo.setImmediate(true);
        combo.setNewItemsAllowed(true);
        combo.addValueChangeListener(new ValueChangeListener() {
            public void valueChange(ValueChangeEvent event) {
                setting.setValue((String) combo.getValue());
                context.getConfigurationService().save(setting);
            }
        });
        field = combo;
    }
    return field;
}
 
Example 9
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 10
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 11
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 12
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 13
Project: metl   File: PluginsPanelAddDialog.java   Source Code and License Vote up 4 votes
protected AbstractLayout buildSearchLayout() {
    FormLayout layout = new FormLayout();
    layout.setMargin(true);

    List<Plugin> existingPlugins = context.getPluginService().findPlugins();
    Set<String> groups = new HashSet<>();
    Set<String> names = new HashSet<>();
    for (Plugin plugin : existingPlugins) {
        groups.add(plugin.getArtifactGroup());
        names.add(plugin.getArtifactName());
    }

    versionSelect = new ListSelect("Versions");
    groupCombo = new ComboBox("Group");
    nameCombo = new ComboBox("Name");

    versionSelect.setRows(4);
    versionSelect.setMultiSelect(false);
    versionSelect.setNullSelectionAllowed(false);
    versionSelect.setWidth(100, Unit.PERCENTAGE);
    versionSelect.addValueChangeListener(e -> versionSelected());

    groupCombo.setWidth(100, Unit.PERCENTAGE);
    groupCombo.setNewItemsAllowed(true);
    groupCombo.addItems(groups);
    groupCombo.addValueChangeListener(e -> {
        populateNameField(nameCombo);
        setSearchButtonEnabled();
    });
    groupCombo.setNewItemHandler((newItemCaption) -> {
        groupCombo.removeItem(handEnteredGroup);
        handEnteredGroup = newItemCaption;
        groupCombo.addItem(handEnteredGroup);
        groupCombo.setValue(handEnteredGroup);
        setSearchButtonEnabled();
    });
    layout.addComponent(groupCombo);

    nameCombo.setWidth(100, Unit.PERCENTAGE);
    nameCombo.setNewItemsAllowed(true);
    nameCombo.addItems(names);
    nameCombo.addValueChangeListener(e -> {
        setSearchButtonEnabled();
    });
    nameCombo.setNewItemHandler((newItemCaption) -> {
        nameCombo.removeItem(handEnteredName);
        handEnteredName = newItemCaption;
        nameCombo.addItem(handEnteredName);
        nameCombo.setValue(handEnteredName);
        setSearchButtonEnabled();
    });
    layout.addComponent(nameCombo);

    layout.addComponent(versionSelect);

    return layout;
}
 
Example 14
Project: metl   File: EditContentRouterPanel.java   Source Code and License Vote up 4 votes
public Field<?> createField(final Container dataContainer, final Object itemId, final Object propertyId,
        com.vaadin.ui.Component uiContext) {
    final Route route = (Route) itemId;
    Field<?> field = null;
    if (propertyId.equals("matchExpression")) {
        final TextField textField = new ImmediateUpdateTextField(null) {
            @Override
            protected void save(String text) {
                route.setMatchExpression(text);
                EditContentRouterPanel.this.save();
            }
        };
        textField.setWidth(100, Unit.PERCENTAGE);
        textField.setValue(route.getMatchExpression());
        field = textField;
    } else if (propertyId.equals("targetStepId")) {
        final ComboBox combo = new ComboBox();
        combo.setWidth(100, Unit.PERCENTAGE);
        flow = context.getConfigurationService().findFlow(flow.getId());
        List<FlowStepLink> stepLinks = flow.findFlowStepLinksWithSource(flowStep.getId());
        for (FlowStepLink flowStepLink : stepLinks) {
            FlowStep comboStep = flow.findFlowStepWithId(flowStepLink.getTargetStepId());
            combo.addItem(comboStep.getId());
            combo.setItemCaption(comboStep.getId(), comboStep.getName());

            if (flowStepLink.getTargetStepId().equals(route.getTargetStepId()) || combo.getValue() == null) {
                combo.setValue(comboStep.getId());
            }
        }

        combo.setImmediate(true);
        combo.setNewItemsAllowed(false);
        combo.setNullSelectionAllowed(false);
        combo.addValueChangeListener(new ValueChangeListener() {
            public void valueChange(ValueChangeEvent event) {
                String stepId = (String) event.getProperty().getValue();
                if (stepId != null) {
                    route.setTargetStepId(stepId);
                    EditContentRouterPanel.this.save();
                }
            }
        });
        field = combo;
    }
    if (field != null) {
        field.setReadOnly(readOnly);
    }
    return field;
}