本文整理汇总了Java中com.vaadin.ui.AbstractSelect.addItem方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractSelect.addItem方法的具体用法?Java AbstractSelect.addItem怎么用?Java AbstractSelect.addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.AbstractSelect
的用法示例。
在下文中一共展示了AbstractSelect.addItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateWIdsSkip
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
public static void populateWIdsSkip(AbstractSelect as, String[] s,
Integer[] skip) {
Set<Integer> se = new HashSet<Integer>(Arrays.asList(skip));
as.removeAllItems();
int i = 0;
for (String sp : s) {
if (!se.contains(i)) {
as.addItem(i);
as.setItemCaption(i, sp);
}
i++;
}
as.setItemCaptionMode(ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
}
示例2: getValueChangeListener
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
private Property.ValueChangeListener getValueChangeListener(final AbstractSelect templateComboBox,
final AbstractSelect supplierPageSelect) {
final Map<String, String> parentTemplates = utils.getParentTemplates();
return new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
String templateId = (String) templateComboBox.getValue();
boolean requiresSupplierPage = parentTemplates.containsKey(templateId);
if (requiresSupplierPage) {
supplierPageSelect.removeAllItems();
String parentTemplateId = parentTemplates.get(templateId);
final Map<String, String> pages = utils.findPagesUsingTemplate(parentTemplateId);
for (Map.Entry<String, String> entry : pages.entrySet()) {
supplierPageSelect.addItem(entry.getValue());
supplierPageSelect.setItemCaption(entry.getValue(), entry.getKey());
}
supplierPageSelect.setRequired(true);
supplierPageSelect.setVisible(true);
} else {
supplierPageSelect.setValue(null);
supplierPageSelect.setRequired(false);
supplierPageSelect.setVisible(false);
}
}
};
}
示例3: buildSelectOptions
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
/**
* A workhorse for {@link RContainer#getOptionGroup} and
* {@link RContainer#getListSelect} to initiate the selection options by
* reading them from an R character vector.
*
* @param selectObj
* Selection object
* @param optionsInName
* The R character vector to read the different options. Repeated
* values are ignored.
*/
public void buildSelectOptions(final AbstractSelect selectObj,
String optionsInName) {
/* Clean the possible old values */
selectObj.removeAllItems();
String[] optionsIn = getStrings(optionsInName);
if (optionsIn == null) {
Notification.show("RVaadin: Cannot find selection element"
+ " values from " + optionsInName,
Notification.Type.ERROR_MESSAGE);
} else {
for (String str : optionsIn) {
selectObj.addItem(str);
}
}
}
示例4: populateWIds
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
/**
* Populate the AbstractSelect component with strings.<br>
* The Itemid is an integer = the index of the string in the sequence ,
* starting from 0
*
* @param as
* component
* @param s
* comma separated string list or array of strings
*/
static public void populateWIds(AbstractSelect as, String... s) {
int i = 0;
as.removeAllItems();
for (String sp : s) {
as.addItem(i);
as.setItemCaption(i, sp);
i++;
}
as.setItemCaptionMode(ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
}
示例5: createResourceCombo
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
protected AbstractSelect createResourceCombo(XMLSetting definition,
AbstractObjectWithSettings obj, ResourceCategory category) {
IConfigurationService configurationService = context.getConfigurationService();
FlowStep step = getSingleFlowStep();
String projectVersionId = step.getComponent().getProjectVersionId();
final AbstractSelect combo = new ComboBox(definition.getName());
combo.setImmediate(true);
combo.setDescription(definition.getDescription());
combo.setNullSelectionAllowed(false);
combo.setRequired(definition.isRequired());
Set<XMLResourceDefinition> types = context.getDefinitionFactory()
.getResourceDefinitions(projectVersionId, category);
if (types != null) {
String[] typeStrings = new String[types.size()];
int i = 0;
for (XMLResourceDefinition type : types) {
typeStrings[i++] = type.getId();
}
List<Resource> resources =
configurationService.findResourcesByTypes(projectVersionId, true, typeStrings);
if (resources != null) {
for (Resource resource : resources) {
combo.addItem(resource.getId());
combo.setItemCaption(resource.getId(), resource.getName());
}
combo.setValue(obj.get(definition.getId()));
}
}
combo.addValueChangeListener(
event -> saveSetting(definition.getId(), (String) combo.getValue(), obj));
combo.setReadOnly(readOnly);
return combo;
}
示例6: fillSelectByEnum
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
/**
* Заполняем поле выбора элементами перечисления
*
* @param component поле выбора
* @param cls тип перечисления
*/
public static <TEnum extends Enum<TEnum>> void fillSelectByEnum(final AbstractSelect component,
final Class<TEnum> cls) {
final Converter<String, TEnum> converter = VaadinSession.getCurrent().getConverterFactory()
.createConverter(String.class, cls);
for (final TEnum en : EnumSet.allOf(cls)) {
component.addItem(en);
component.setItemCaption(en, converter.convertToPresentation(en, null, null));
}
}
示例7: addResourceCombo
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
protected void addResourceCombo(XMLComponentDefinition componentDefintion, FormLayout formLayout, final Component component) {
if (componentDefintion == null) {
log.error("Could not find a component defintion for: " + component.getName() + " " + component.getType());
} else {
IConfigurationService configurationService = context.getConfigurationService();
FlowStep step = getSingleFlowStep();
if (componentDefintion.getResourceCategory() != null && componentDefintion.getResourceCategory() != ResourceCategory.NONE
&& step != null) {
final AbstractSelect resourcesCombo = new ComboBox("Resource");
resourcesCombo.setImmediate(true);
String projectVersionId = step.getComponent().getProjectVersionId();
Set<XMLResourceDefinition> types = context.getDefinitionFactory().getResourceDefinitions(projectVersionId,
componentDefintion.getResourceCategory());
if (types != null) {
String[] typeStrings = new String[types.size()];
int i = 0;
for (XMLResourceDefinition type : types) {
typeStrings[i++] = type.getId();
}
List<Resource> resources = new ArrayList<>(configurationService.findResourcesByTypes(projectVersionId, true, typeStrings));
if (resources != null) {
for (Resource resource : resources) {
resourcesCombo.addItem(resource);
}
resourcesCombo.setValue(component.getResource());
}
}
resourcesCombo.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void valueChange(ValueChangeEvent event) {
component.setResource((Resource) resourcesCombo.getValue());
context.getConfigurationService().save(component);
}
});
formLayout.addComponent(resourcesCombo);
}
}
}
示例8: addAllItems
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
public void addAllItems(AbstractSelect select,Object [] objects){
for(Object obj:objects){
select.addItem(obj);
}
}
示例9: addItemList
import com.vaadin.ui.AbstractSelect; //导入方法依赖的package包/类
/**
* Add a List of objects to a combo
* @param combo combo to add items
* @param items items to add
*/
public static void addItemList(AbstractSelect combo, List<?> items) {
combo.setItemCaptionMode(ItemCaptionMode.ID);
for (Object item : items)
combo.addItem(item);
}