Java 类com.vaadin.ui.AbstractSelect 实例源码

项目:cuba    文件:WebWrapperUtils.java   
public static CaptionMode toCaptionMode(AbstractSelect.ItemCaptionMode captionMode) {
    if (captionMode == null) {
        return null;
    }

    switch (captionMode) {
        case ITEM:
            return CaptionMode.ITEM;
        case PROPERTY:
            return CaptionMode.PROPERTY;
        case EXPLICIT_DEFAULTS_ID:
            return CaptionMode.MAP_ENTRY;
        default:
            throw new UnsupportedOperationException("Unsupported Vaadin AbstractSelect.ItemCaptionMode");
    }
}
项目:cuba    文件:WebWrapperUtils.java   
public static AbstractSelect.ItemCaptionMode toVaadinCaptionMode(CaptionMode captionMode) {
    if (captionMode == null) {
        return null;
    }

    switch (captionMode) {
        case ITEM:
            return AbstractSelect.ItemCaptionMode.ITEM;
        case PROPERTY:
            return AbstractSelect.ItemCaptionMode.PROPERTY;
        case MAP_ENTRY:
            return AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID;
        default:
            throw new UnsupportedOperationException("Unsupported CaptionMode");
    }
}
项目:hybridbpm    文件:SystemParameterLayout.java   
public SystemParameterLayout(Parameter parameterInstance) {
    Design.read(this);
    this.parameterInstance = parameterInstance;
    if (this.parameterInstance == null) {
        this.parameterInstance = new Parameter();
    }

    for (Parameter.PARAM_TYPE type : Parameter.PARAM_TYPE.values()) {
        Item item = typeComboBox.addItem(type);
        typeComboBox.setItemCaption(type, type.name());
    }
    typeComboBox.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);

    binder.setItemDataSource(this.parameterInstance);
    binder.bind(typeComboBox, "type");
    binder.bind(name, "name");
    binder.bind(value, "value");
    binder.setBuffered(true);
}
项目:hybridbpm    文件:DocumentPermissionLayout.java   
public DocumentPermissionLayout(Document document, Permission permission) {
    Design.read(this);
    comboBoxRole.setCaption(Translate.getMessage("comboBoxRole"));
    permissionsField.setCaption(Translate.getMessage("permissionsField"));

    this.document = document;
    permission = permission == null ? new Permission() : permission;

    permissionsField.setPermissionsClass(Document.class);
    comboBoxRole.addContainerProperty(NAME, String.class, null);
    comboBoxRole.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    comboBoxRole.setItemCaptionPropertyId(NAME);
    for (Role instance : HybridbpmUI.getAccessAPI().getAllRoles()) {
        Item item = comboBoxRole.addItem(instance);
        item.getItemProperty(NAME).setValue(instance.getName());
    }
    comboBoxRole.setNullSelectionAllowed(false);

    binder.setItemDataSource(permission);
    binder.bind(permissionsField, "permissions");
    binder.bind(comboBoxRole, "out");
    binder.setBuffered(true);


}
项目:VaadHL    文件:ComponentHelper.java   
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);

}
项目:cherry-web    文件:NavigationView.java   
@Override
public void drop(DragAndDropEvent event) {
    final Transferable t = event.getTransferable();
    AbstractSelect.AbstractSelectTargetDetails dropData = ((AbstractSelect.AbstractSelectTargetDetails) event.getTargetDetails());
    Object sourceItemId = ((DataBoundTransferable) t).getItemId();
    Object targetItemId = dropData.getItemIdOver();
    VerticalDropLocation location = dropData.getDropLocation();

    Item sourceItem = tree.getItem(sourceItemId);
    NavNode sourceNode = (NavNode) sourceItem.getItemProperty("object").getValue();

    Item targetItem = tree.getItem(targetItemId);
    NavNode targetNode = (NavNode) targetItem.getItemProperty("object").getValue();

    NavigationView.this.move(sourceNode, targetNode, location);
    // Sorting goes as
          // - If dropped ON (MIDDLE) a node, we preppend it as a child
          // - If dropped on the TOP part of a node, we move/add it before the node
          // - If dropped on the BOTTOM part of a node, we move/add it after the node if it has no children, or prepend it as a child if it has children
}
项目:magnolia-handlebars    文件:SupplierPageSelectorFieldFactory.java   
@Override
protected AbstractSelect createFieldComponent() {

    final AbstractSelect supplierPageSelect = super.createFieldComponent();
    supplierPageSelect.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);

    final AbstractSelect templateSelect = findTemplateSelect();
    if (templateSelect == null) {
        throw new RuntimeException("Cannot find template ComboBox");
    }
    Property.ValueChangeListener listener = getValueChangeListener(templateSelect, supplierPageSelect);
    templateSelect.addValueChangeListener(listener);
    listener.valueChange(new Field.ValueChangeEvent(templateSelect));

    supplierPageSelect.setVisible(utils.requiresParentTemplate((String) templateSelect.getValue()));
    return supplierPageSelect;
}
项目:magnolia-handlebars    文件:SupplierPageSelectorFieldFactory.java   
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);
            }
        }
    };
}
项目:mycollab    文件:TimeZoneSelectionField.java   
public TimeZoneSelectionField(boolean isVerticalDisplay) {
    this.isVerticalDisplay = isVerticalDisplay;
    areaSelection = new ValueComboBox(false, TimezoneVal.getAreas());
    areaSelection.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setCboTimeZone((String) areaSelection.getValue());
        }
    });
    timezoneSelection = new ComboBox();
    timezoneSelection.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
    String area = (String) areaSelection.getItemIds().iterator().next();
    areaSelection.setValue(area);
    setCboTimeZone(area);
}
项目:extacrm    文件:MainSettingsForm.java   
@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;
}
项目:GlycanBuilderVaadin7Version    文件:VaadinGlycanCanvas.java   
private char[] getSelectedPositions(AbstractSelect field) {
    @SuppressWarnings("rawtypes")
    Set sel = (Set) field.getValue();

    if(sel.size() == 0){
        return new char[] { '?' };
    }else{
        char[] ret = new char[sel.size()];
        int i=0;
        for(Object obj:sel){
            ret[i] = ((String) obj).charAt(0);
            i++;
        }

        return ret;
    }
}
项目:RVaadin    文件:RContainer.java   
/**
 * 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);
        }
    }
}
项目:cuba    文件:WebTwinColumn.java   
public WebTwinColumn() {
    component = new CubaTwinColSelect() {
        @Override
        public void setPropertyDataSource(Property newDataSource) {
            super.setPropertyDataSource(new PropertyAdapter(newDataSource) {
                @Override
                public Object getValue() {
                    final Object o = itemProperty.getValue();
                    return getKeyFromValue(o);
                }

                @Override
                public void setValue(Object newValue) throws ReadOnlyException, Converter.ConversionException {
                    final Object v = getValueFromKey(newValue);
                    itemProperty.setValue(v);
                }
            });
        }

        @Override
        public Resource getItemIcon(Object itemId) {
            if (styleProvider != null) {
                @SuppressWarnings({"unchecked"})
                final Entity item = optionsDatasource.getItem(itemId);
                final String resURL = styleProvider.getItemIcon(item, isSelected(itemId));

                return resURL == null ? null : WebComponentsHelper.getResource(resURL);
            } else {
                return null;
            }
        }
    };
    attachListener(component);
    component.setImmediate(true);
    component.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
    component.setMultiSelect(true);
    component.setInvalidAllowed(false);
    component.setInvalidCommitted(true);
}
项目:cuba    文件:WebTwinColumn.java   
@Override
public void setStyleProvider(final StyleProvider styleProvider) {
    this.styleProvider = styleProvider;
    if (styleProvider != null) {
        component.setStyleGenerator(new CubaTwinColSelect.OptionStyleGenerator() {
            @Override
            public String generateStyle(AbstractSelect source, Object itemId, boolean selected) {
                final Entity item = optionsDatasource.getItem(itemId);
                return styleProvider.getStyleName(item, itemId, component.isSelected(itemId));
            }
        });
    } else {
        component.setStyleGenerator(null);
    }
}
项目:cuba    文件:WebAbstractOptionsField.java   
@Override
public void setOptionsList(List optionsList) {
    if (metaProperty != null) {
        Object currentValue = component.getValue();
        if (metaProperty.getRange().isEnum()) {
            setComponentContainerDs(createEnumContainer(optionsList));
            setCaptionMode(CaptionMode.ITEM);
        } else {
            setComponentContainerDs(createObjectContainer(optionsList));
            component.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
        }

        component.setValue(currentValue);
        this.optionsList = optionsList;
    } else if (!optionsList.isEmpty()) {
        final Object o = optionsList.iterator().next();
        if (o instanceof Enum) {
            setComponentContainerDs(createEnumContainer(optionsList));
        } else {
            setComponentContainerDs(createObjectContainer(optionsList));
        }
        setCaptionMode(CaptionMode.ITEM);
        this.optionsList = optionsList;
    } else {
        setComponentContainerDs(createObjectContainer(optionsList));
        setCaptionMode(CaptionMode.ITEM);
        this.optionsList = optionsList;
    }
}
项目:cuba    文件:WebFilterHelper.java   
@Override
public void setLookupCaptions(LookupField lookupField, Map<Object, String> captions) {
    ComboBox vLookupField = lookupField.unwrap(ComboBox.class);
    vLookupField.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);
    for (Map.Entry<Object, String> entry : captions.entrySet()) {
        vLookupField.setItemCaption(entry.getKey(), entry.getValue());
    }
}
项目:hybridbpm    文件:DevelopmentView.java   
public DevelopmentView() {
    Design.read(this);
    Responsive.makeResponsive(panelLayout);

    moduleType.addContainerProperty("NAME", String.class, null);
    moduleType.addItem(Boolean.FALSE).getItemProperty("NAME").setValue("Module");
    moduleType.addItem(Boolean.TRUE).getItemProperty("NAME").setValue("Template");
    moduleType.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    moduleType.setItemCaptionPropertyId("NAME");
    moduleType.setValue(Boolean.FALSE);
    moduleType.addValueChangeListener(this);

    btnAdd.setIcon(FontAwesome.PLUS_CIRCLE);
    btnAdd.addClickListener(this);

    btnRefresh.setIcon(FontAwesome.REFRESH);
    btnRefresh.addClickListener(this);

    btnExport.setIcon(FontAwesome.CLOUD_UPLOAD);
    btnExport.addClickListener(this);

    btnImport.setIcon(FontAwesome.CLOUD_DOWNLOAD);
    btnImport.addClickListener(this);

    btnRegenerate.setIcon(FontAwesome.WRENCH);
    btnRegenerate.addClickListener(this);

    modulesLayout.setMargin(new MarginInfo(true, false, false, false));
    modulesLayout.setExpandRatio(modulesTable, 1f);

    modulesTable.addContainerProperty("title", Component.class, null, "Title", null, Table.Align.LEFT);
    modulesTable.setColumnExpandRatio("title", 1f);
    modulesTable.addContainerProperty("updateDate", Date.class, null, "Update Date", null, Table.Align.LEFT);
    modulesTable.addContainerProperty("actions", TableButtonBar.class, null, "Actions", null, Table.Align.LEFT);
    modulesTable.setColumnWidth("updateDate", 150);
    modulesTable.setColumnWidth("actions", 80);
    modulesTable.addGeneratedColumn("updateDate", new DateColumnGenerator());
    modulesTable.setVisibleColumns("title", "updateDate", "actions");
}
项目:hybridbpm    文件:ThreeParamChartConfLayout.java   
public ThreeParamChartConfLayout(BeanFieldGroup<DiagrammePreference> preferences) {
    super(preferences);

    groupByChoice.setWidth(100, Sizeable.Unit.PERCENTAGE);
    groupByChoice.setFilteringMode(FilteringMode.CONTAINS);
    groupByChoice.setNewItemsAllowed(false);
    groupByChoice.setImmediate(true);
    groupByChoice.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    groupByChoice.setItemCaptionPropertyId("name");
    groupByChoice.setNullSelectionAllowed(true);
    groupByChoice.setRequired(false);

    sortByChoiceGroup.setWidth(100, Unit.PERCENTAGE);
    sortByChoiceGroup.setRequired(false);
    sortByChoiceGroup.setFilteringMode(FilteringMode.CONTAINS);
    sortByChoiceGroup.setNewItemsAllowed(false);
    sortByChoiceGroup.setImmediate(true);
    sortByChoiceGroup.setNullSelectionAllowed(true);

    groupByAndSortLayout.addComponent(groupByChoice);
    groupByAndSortLayout.addComponent(sortByChoiceGroup);

    groupByAndSortLayout.setExpandRatio(groupByChoice, 0.8f);
    groupByAndSortLayout.setExpandRatio(sortByChoiceGroup, 0.2f);
    groupByAndSortLayout.setSpacing(true);
    groupByAndSortLayout.setSizeFull();

    verticalLayout.addComponent(groupByAndSortLayout);

    sortByChoiceGroup.addItems((Object[])SortBy.values());
}
项目:hybridbpm    文件:TranslatedFieldValue.java   
public TranslatedFieldValue(Locale locale, String value) {
    Design.read(this);

    for (Locale l : Locale.getAvailableLocales()) {
        Item item = localeComboBox.addItem(l);
        localeComboBox.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);
        localeComboBox.setItemCaption(l, l.getDisplayName());
    }
    valueField.setValue(value);
    localeComboBox.setValue(locale);
    btnDelete.setIcon(FontAwesome.TIMES_CIRCLE);
    btnDelete.setVisible(!Locale.US.equals(locale));
    btnDelete.addClickListener(this);
    localeComboBox.setEnabled(!Locale.US.equals(locale));
}
项目:VaadHL    文件:ComponentHelper.java   
/**
 * Populate the AbstractSelect component with strings.<br>
 * Creates new datasource.<br>
 * Each entry is of type {@link IdName } .
 * 
 * @param component
 *            the component
 * @param s
 *            the comma separated string list or array of strings
 */
static public void populateIdName(AbstractSelect component, String... s) {
    BeanItemContainer<IdName> bic = new BeanItemContainer<IdName>(
            IdName.class);
    int i = 0;
    for (String sp : s)
        bic.addItem(new IdName(i++, sp));

    component.setContainerDataSource(bic);
    component.setItemCaptionPropertyId("name");

}
项目:VaadHL    文件:ComponentHelper.java   
/**
 * 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);
}
项目:SecureBPMN    文件:AbstractTablePage.java   
protected AbstractSelect createSelectComponent() {
  table = createList();

  // Set non-editable, selectable and full-size
  table.setEditable(false);
  table.setImmediate(true);
  table.setSelectable(true);
  table.setNullSelectionAllowed(false);
  table.setSortDisabled(true);
  table.setSizeFull();
  return table;
}
项目:mondo-collab-framework    文件:StartNewSessionPage.java   
private void initView() {
    this.loadingSign = new ProgressBar();
    this.loadingSign.setIndeterminate(true);
    this.loadingSign.setId("loadingSign");
    Label title = new Label("Available models");
    title.setId("label_availableModels");
    addComponent(title);

    this.availableModelsTree = new Tree();
    this.availableModelsTree.setId("tree_availableModels");
    this.availableModelsTree.setWidth(30, Unit.EM);
    Tree tree = availableModelsTree;
       tree.addContainerProperty(CAPTION_PROPERTY, String.class, "");
       tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
       tree.setItemCaptionPropertyId(CAPTION_PROPERTY);
    this.buttonStartSession = new Button("Start");
    this.buttonStartSession.setId("button_start");
    this.buttonStartSession.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            String selectedModelPath = (String) tree.getValue();
            if(selectedModelPath.endsWith(".wtspec4m")) {
                startSession(selectedModelPath);
            } 
        }
    });
    addComponent(this.buttonStartSession);
    addComponent(this.loadingSign);

    Panel treeViewContainer = new Panel();
    treeViewContainer.setId("panel_treeViewContainer");
    treeViewContainer.setContent(this.availableModelsTree);
    addComponent(treeViewContainer);
}
项目:jain-I18n    文件:I18NComponentHandlerFactory.java   
/**
 * Method to find I18NHandler for the component
 * @param component
 * @return {@link I18NComponentHandler}
 */
public static I18NComponentHandler getHandler (Component component) {
    if (componentHandler != null && component != null) {
        I18NComponentHandler handler = componentHandler.get(component.getClass());
        if (handler != null)
            return handler;
    }
    if (component instanceof Label)
        return new I18NLableHandler((Label)component);
    if (component instanceof AbstractTextField)
        return new I18NFieldHandler((AbstractTextField)component);
    if (component instanceof PopupDateField)
        return new I18NFieldHandler((PopupDateField)component);
    if (component instanceof Table)
        return new I18NTableHandler((Table)component);
    if (component instanceof AbstractSelect)
        return new I18NAbstractSelectHandler((AbstractSelect)component);
    if (component instanceof TabSheet || component.getParent() instanceof TabSheet)
        return new I18NTabSheetHandler(component);
    if  (component instanceof JUploader) 
        return new I18NJUploadHandler((JUploader) component);
    if (component instanceof MenuBar) 
        return new I18NMenuBarHandler((MenuBar) component);
    if (component instanceof AbstractComponent)
        return new I18NAbstractComponentHandler ((AbstractComponent)component);
    return  new I18NComponentHandler(component);
}
项目:jain-I18n    文件:I18NAbstractSelectHandler.java   
@SuppressWarnings("unchecked")
private void populateI18NItemCaptions(final AbstractSelect component) {
    Collection<Object> items = (Collection<Object>) component.getItemIds();
    for (Object itemId : items) {
        String i18NItemCaption = component.getItemCaption(itemId);
        i18NItemCaptions.put(itemId, i18NItemCaption);
    }
}
项目:jain-I18n    文件:I18NAbstractSelectHandler.java   
public void applyI18N(Component component, Locale locale) {
    super.applyI18N(component, locale);
    AbstractSelect select = ((AbstractSelect)component);
    for (Entry<Object, String> entry : i18NItemCaptions.entrySet()) {
        if (StringHelper.isNotEmptyWithTrim(entry.getValue())) {
            String value = provider.getTitle(locale, entry.getValue());
            select.setItemCaption(entry.getKey(), value);
        }
    }
}
项目:jain-I18n    文件:I18NFieldHandler.java   
public I18NFieldHandler(final AbstractSelect component) {
    super(component);
    if(component instanceof ComboBox)
        this.i18NInputPrompt = ((ComboBox) component).getInputPrompt();
    else
        this.i18NInputPrompt = null;
    this.i18NRequiredError = component.getRequiredError();
}
项目:metl    文件:PropertySheet.java   
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;
}
项目:metl    文件:DesignMenuBar.java   
public DesignMenuBar(DesignNavigator navigator, AbstractSelect tree) {
    super(tree, new NothingSelectAction(navigator));
    addMenuManager(ProjectVersion.class, new ProjectVersionMenuManager(navigator));
    addMenuManager(Project.class, new ProjectMenuManager(navigator));
    addMenuManager(FlowName.class, new FlowMenuManager(navigator));
    addMenuManager(ResourceName.class, new ResourceMenuManager(navigator));
    addMenuManager(ModelName.class, new ModelMenuManager(navigator));
    addMenuManager(ProjectVersionDepends.class, new ProjectDependencyMenuManager(navigator));
    addMenuManager(FolderName.class, new FolderMenuManager(navigator));
}
项目:metl    文件:AbstractMenuBar.java   
public AbstractMenuBar(AbstractSelect parent,
        ISelectedValueMenuManager nothingSelectedMenuManager) {
    addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    setWidth(100, Unit.PERCENTAGE);

    this.parent = parent;
    this.nothingSelectedMenuManager = nothingSelectedMenuManager;
    this.menuActionsByClass = new HashMap<>();
    this.parent.addValueChangeListener((e) -> valueChanged());
    this.handler = new Handler();

    contextMenu = new ContextMenu(parent, false);
    if (parent instanceof ItemClickNotifier) {
        ItemClickNotifier notifier = (ItemClickNotifier)parent;
        notifier.addItemClickListener(e->{
            if (e.getButton()==MouseButton.RIGHT && !e.isDoubleClick()) {
                contextMenu.open(e.getClientX(), e.getClientY());
            }
        });
    } else {
        parent.addContextClickListener(e->contextMenu.open(e.getClientX(), e.getClientY()));
    }

    buildMenu();

    valueChanged();
}
项目:primecloud-controller    文件:WinServerEdit.java   
@Override
public void attach() {
    setHeight(TAB_HEIGHT);
    setMargin(false, true, false, true);
    setSpacing(false);

    // サーバサイズ
    sizeSelect = new ComboBox(ViewProperties.getCaption("field.serverSize"));
    sizeSelect.setNullSelectionAllowed(false);
    form.getLayout().addComponent(sizeSelect);

    // キーペア
    keySelect = new ComboBox(ViewProperties.getCaption("field.keyPair"));
    keySelect.setNullSelectionAllowed(false);
    keySelect.addContainerProperty(KEY_CAPTION_ID, String.class, null);
    keySelect.setItemCaptionPropertyId(KEY_CAPTION_ID);
    keySelect.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    // Windowsの場合はキーペアを無効にする
    if (StringUtils.startsWith(image.getImage().getOs(), PCCConstant.OS_NAME_WIN)) {
        keySelect.setEnabled(false);
    }
    form.getLayout().addComponent(keySelect);

    // クラスタ
    clusterSelect = new ComboBox(ViewProperties.getCaption("field.cluster"));
    clusterSelect.setNullSelectionAllowed(false);
    form.getLayout().addComponent(clusterSelect);

    // ルートサイズ
    rootSizeField = new TextField(ViewProperties.getCaption("field.rootSize"));
    rootSizeField.setImmediate(true);
    form.getLayout().addComponent(rootSizeField);

    addComponent(form);
}
项目:abstractform    文件:VaadinBindingFormToolkit.java   
private void replaceFormInstanceReferences(VaadinFormInstance delegate, VaadinBindingFormInstance<?> real) {
    for (String fieldId : delegate.getFieldIds()) {
        AbstractComponent component = delegate.getComponentById(fieldId);
        if (component.getData() instanceof VaadinDataObject) {
            VaadinDataObject dataObject = (VaadinDataObject) component.getData();
            Field field = dataObject.getField();
            if (field.getType().equals(SelectorConstants.TYPE_SELECTOR)) {
                if (component instanceof Container.Viewer) {
                    final Container.Viewer viewer = (Container.Viewer) component;
                    SelectorProviderFactory factory = (SelectorProviderFactory) field
                            .getExtra(SelectorConstants.EXTRA_SELECTOR_PROVIDER_FACTORY);
                    final VaadinSelectorContainer container = new VaadinSelectorContainer(factory.createSelectorProvider(real));

                    if (viewer instanceof AbstractSelect) {
                        final AbstractSelect abstractSelect = (AbstractSelect) viewer;
                        container.addListener(new Container.ItemSetChangeListener() {

                            @Override
                            public void containerItemSetChange(ItemSetChangeEvent event) {
                                boolean readOnly = abstractSelect.isReadOnly();
                                abstractSelect.setReadOnly(false);
                                abstractSelect.sanitizeSelection();
                                abstractSelect.setReadOnly(readOnly);
                            }

                        });
                        viewer.setContainerDataSource(container);
                    }
                }
            }
        }
    }
}
项目:magnolia-handlebars    文件:SupplierPageSelectorFieldFactory.java   
@Nullable
private AbstractSelect findTemplateSelect() {
    FormSection formSection = ((FormTab) this.getParent()).getContainer();
    for (final Component sibling : formSection) {
        if (sibling instanceof AbstractSelect) {
            // @todo need better test for the component that I need
            return (AbstractSelect) sibling;
        }
    }
    return null;
}
项目:mycollab    文件:TicketComponentFactoryImpl.java   
NewTicketWindow(Date date, final Integer prjId, final Integer milestoneId, boolean isIncludeMilestone) {
    super(UserUIContext.getMessage(TicketI18nEnum.NEW));
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withCenter().withWidth("1200px").withContent(content);

    typeSelection = new ComboBox();
    typeSelection.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        typeSelection.addItem(UserUIContext.getMessage(TaskI18nEnum.SINGLE));
        typeSelection.setItemIcon(UserUIContext.getMessage(TaskI18nEnum.SINGLE), ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK));
    }

    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) {
        typeSelection.addItem(UserUIContext.getMessage(BugI18nEnum.SINGLE));
        typeSelection.setItemIcon(UserUIContext.getMessage(BugI18nEnum.SINGLE), ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));
    }

    if (isIncludeMilestone && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        typeSelection.addItem(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
        typeSelection.setItemIcon(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE), ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE));
    }

    typeSelection.setNullSelectionAllowed(false);
    if (CollectionUtils.isNotEmpty(typeSelection.getItemIds())) {
        typeSelection.select(typeSelection.getItemIds().iterator().next());
    } else {
        throw new SecureAccessException();
    }

    typeSelection.setNullSelectionAllowed(false);
    typeSelection.addValueChangeListener(valueChangeEvent -> doChange(date, prjId, milestoneId));

    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 1);
    formLayoutHelper.addComponent(typeSelection, UserUIContext.getMessage(GenericI18Enum.FORM_TYPE), 0, 0);
    formLayout = new CssLayout();
    formLayout.setWidth("100%");
    content.with(formLayoutHelper.getLayout(), formLayout);
    doChange(date, prjId, milestoneId);
}
项目:FiWare-Template-Handler    文件:AbstractTablePage.java   
protected AbstractSelect createSelectComponent() {
  table = createList();

  // Set non-editable, selectable and full-size
  table.setEditable(false);
  table.setImmediate(true);
  table.setSelectable(true);
  table.setNullSelectionAllowed(false);
  table.setSortDisabled(true);
  table.setSizeFull();
  return table;
}
项目:extacrm    文件:ComponentUtil.java   
/**
 * Заполняем поле выбора элементами перечисления
 *
 * @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));
    }
}
项目:RVaadin    文件:RContainer.java   
/**
 * Check whether a selection element is empty independent of the selection
 * mode. Works both with setMultiSelect(true) and setMultiSelect(false).
 * 
 * @param selectObj
 *            AsbtractSelect object
 * @return true if nothing is selected
 */
public boolean isSelectionEmpty(AbstractSelect selectObj) {

    /* The action depends on selection mode */
    if (selectObj.isMultiSelect()) {

        @SuppressWarnings("unchecked")
        Set<String> strSet = (Set<String>) selectObj.getValue();
        return strSet.isEmpty();

    } else {
        /* Single selection mode: If empty, the value is null. */
        return (null == selectObj.getValue());
    }
}
项目:jdal    文件:VaadinControlInitializer.java   
/**
 * {@inheritDoc}
 */
public void initialize(Object control, String property, InitializationConfig config) {
    if (this.dao == null) {
        log.warn("Nothing to do without persistent service");
        return;
    }
    Class<?> clazz = config.getType();
    PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(clazz, property);

    if (pd == null) {
        log.error("Not found property descriptor for property [" + property + "]") ;
        return;
    }

    ResolvableType propertyType = ResolvableType.forMethodReturnType(pd.getReadMethod());
    Annotation[] annotations = getAnnotations(property, clazz);
    for (Annotation a : annotations) {
        List<Object> items = null;

        if (ManyToOne.class.equals(a.annotationType()) || ManyToMany.class.equals(a.annotationType()) ) {
            items = getEntityList(propertyType, config.getSortPropertyName());

        }
        else if (Reference.class.equals(a.annotationType())) {
            Reference r = (Reference) a;
            Class<?> type = void.class.equals(r.target()) ? propertyType.resolve() : r.target();
            List<Object> entities = getEntityList(type, config.getSortPropertyName());
            items = StringUtils.isEmpty(r.property()) ?  entities : 
                getValueList(entities, r.property());   
        }

        if (items != null) {
            if (control instanceof AbstractSelect) {
                for (Object item : items) 
                    ((AbstractSelect) control).addItem(item);
            }
            break;
        }
    }
}
项目:cuba    文件:AccessGroupCompanion.java   
@Override
public void initDragAndDrop(Table<User> usersTable, Tree<Group> groupsTree, Consumer<UserGroupChangedEvent> userGroupChangedHandler) {
    com.vaadin.ui.Table vTable = usersTable.unwrap(com.vaadin.ui.Table.class);
    vTable.setDragMode(com.vaadin.ui.Table.TableDragMode.MULTIROW);

    CubaTree vTree = groupsTree.unwrap(CubaTree.class);
    vTree.setDragMode(com.vaadin.ui.Tree.TreeDragMode.NODE);
    vTree.setDropHandler(new DropHandler() {
        @Override
        public void drop(DragAndDropEvent dropEvent) {
            DataBoundTransferable transferable = (DataBoundTransferable) dropEvent.getTransferable();

            AbstractSelect.AbstractSelectTargetDetails dropData =
                    ((AbstractSelect.AbstractSelectTargetDetails) dropEvent.getTargetDetails());

            Component sourceComponent = transferable.getSourceComponent();

            List<User> users = null;
            if (sourceComponent instanceof com.vaadin.ui.Table) {
                users = new ArrayList<>(usersTable.getSelected());
            }

            if (users == null) {
                return;
            }

            if (users.isEmpty()) {
                User user = convertToEntity(vTable.getItem(transferable.getItemId()), User.class);
                users.add(user);
            }

            final Object targetItemId = dropData.getItemIdOver();
            if (targetItemId == null) {
                return;
            }
            Group group = convertToEntity(vTree.getItem(targetItemId), Group.class);
            if (group == null) {
                return;
            }

            userGroupChangedHandler.accept(new UserGroupChangedEvent(groupsTree, users, group));
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new And(AbstractSelect.AcceptItem.ALL);
        }
    });
}
项目:cuba    文件:WebAbstractOptionsBase.java   
protected void initDefaults(AbstractSelect component){
    component.setImmediate(true);
    component.setInvalidCommitted(true);
    component.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
    component.setConverter(new ObjectToObjectConverter());
}