本文整理汇总了Java中com.vaadin.ui.ComboBox.setNewItemsAllowed方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.setNewItemsAllowed方法的具体用法?Java ComboBox.setNewItemsAllowed怎么用?Java ComboBox.setNewItemsAllowed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.ComboBox
的用法示例。
在下文中一共展示了ComboBox.setNewItemsAllowed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectUser
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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);
}
}
}
示例2: initComponents
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
* 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);
}
示例3: bindEnumField
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例4: getComboBox
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
* @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;
}
示例5: setCategoryFilter
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
* @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;
}
示例6: buildGrid
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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);
}
示例7: createField
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例8: bindComboBox
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例9: ReportParameterReportChooser
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
*
* @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);
}
示例10: ReportParameterEnum
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
*
* @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);
}
示例11: buildSearchLayout
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例12: createField
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}