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

项目:cuba    文件:WebTree.java   
@Override
public void setCaptionMode(CaptionMode captionMode) {
    if (this.captionMode != captionMode) {
        this.captionMode = captionMode;
        switch (captionMode) {
            case ITEM:
                component.setItemCaptionMode(ItemCaptionMode.ITEM);
                break;

            case PROPERTY:
                component.setItemCaptionMode(ItemCaptionMode.PROPERTY);
                break;

            default:
                throw new UnsupportedOperationException();
        }
    }
}
项目: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);

}
项目:metl    文件:ChangeDependencyVersionDialog.java   
@SuppressWarnings("unchecked")
protected Panel buildPossibleTargetVersions(ProjectVersion targetProjectVersion) {

    Panel possibleTargetVersionsPanel = new Panel("Available Target Versions");        
    possibleTargetVersionsPanel.addStyleName(ValoTheme.PANEL_SCROLL_INDICATOR);
    possibleTargetVersionsPanel.setSizeFull();

    IndexedContainer container = new IndexedContainer();
    optionGroup = new OptionGroup("Project Version", container);
    optionGroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
    optionGroup.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    optionGroup.setItemCaptionPropertyId("versionLabel");
    optionGroup.addStyleName("indent");

    List<ProjectVersion> projectVersions = configService.findProjectVersionsByProject(targetProjectVersion.getProject());        
    container.addContainerProperty("versionLabel", String.class, null); 
    for (ProjectVersion version : projectVersions) {
        Item item = container.addItem(version.getId());
        item.getItemProperty("versionLabel").setValue(version.getVersionLabel()); 
        if (targetProjectVersion.getId().equalsIgnoreCase(version.getId())) {
            optionGroup.setItemEnabled(version.getId(), false);
        }
    }
    possibleTargetVersionsPanel.setContent(optionGroup);
    return possibleTargetVersionsPanel;
}
项目:incubator-openaz    文件:SelectPDPGroupWindow.java   
private void initializeSelect(Set<PDPGroup> groups) {
    //
    // Initialize GUI properties
    //
    this.listSelectPDPGroup.setImmediate(true);
    this.listSelectPDPGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    this.listSelectPDPGroup.setNullSelectionAllowed(false);
    this.listSelectPDPGroup.setNewItemsAllowed(false);
    this.listSelectPDPGroup.setMultiSelect(false);
    //
    // Add items
    //
    for (PDPGroup group : groups) {
        this.listSelectPDPGroup.addItem(group);
        this.listSelectPDPGroup.setItemCaption(group, group.getName());
    }
    //
    // Listen to events
    //
    this.listSelectPDPGroup.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.setupButtons();
        }
    });
}
项目:incubator-openaz    文件:PolicyEditorWindow.java   
protected void initializeSelect() {
    this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
    this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
    this.listSelectAlgorithm.setNullSelectionAllowed(false);

    if (this.policy.getRuleCombiningAlgId() == null) {
        this.policy.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue());
    }
    this.listSelectAlgorithm.setValue(JPAUtils.findRuleAlgorithm(this.policy.getRuleCombiningAlgId()).getId());
}
项目:incubator-openaz    文件:PolicySetEditorWindow.java   
protected void initializeSelect() {
    this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
    this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
    this.listSelectAlgorithm.setNullSelectionAllowed(false);

    if (this.policySet.getPolicyCombiningAlgId() == null) {
        this.policySet.setPolicyCombiningAlgId(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue());
    }
    this.listSelectAlgorithm.setValue(JPAUtils.findPolicyAlgorithm(this.policySet.getPolicyCombiningAlgId()).getId());
}
项目:incubator-openaz    文件:AttributeStandardSelectorComponent.java   
private void initializeCategories() {
    //
    // Remove any filters
    //
    AttributeStandardSelectorComponent.categories.removeAllContainerFilters();
    //
    // Initialize data source & GUI properties
    //
    this.comboBoxCategories.setContainerDataSource(AttributeStandardSelectorComponent.categories);
    this.comboBoxCategories.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxCategories.setItemCaptionPropertyId("xacmlId");
    this.comboBoxCategories.setImmediate(true);
    this.comboBoxCategories.setNullSelectionAllowed(false);
    //
    // Set default selection
    //
    Category defaultCategory;
    if (this.attribute == null || this.attribute.getCategoryBean() == null) {
        defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
    } else {
        defaultCategory = this.attribute.getCategoryBean();
    }
    if (defaultCategory != null) {
        this.comboBoxCategories.select(defaultCategory.getId());
    }
    //
    // Respond to events
    //
    this.comboBoxCategories.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.setupAttributeIDs();
            self.fireAttributeChanged(self.getAttribute());
        }
    });
}
项目:incubator-openaz    文件:AttributeDictionarySelectorComponent.java   
protected void initializeCategoryFilter() {
    //
    // Remove any filters
    //
    AttributeDictionarySelectorComponent.categories.removeAllContainerFilters();
    //
    // Initialize data source and GUI properties
    //
    this.comboBoxCategoryFilter.setContainerDataSource(AttributeDictionarySelectorComponent.categories);
    this.comboBoxCategoryFilter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxCategoryFilter.setItemCaptionPropertyId("xacmlId");
    this.comboBoxCategoryFilter.setImmediate(true);
    //
    // Respond to events
    //
    this.comboBoxCategoryFilter.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Clear any existing filters
            //
            AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
            //
            // Get the current selection
            //
            Object id = self.comboBoxCategoryFilter.getValue();
            //
            // Is anything currently selected?
            //
            if (id != null) {
                //
                // Yes - add the new filter into the container
                //
                AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("categoryBean", AttributeDictionarySelectorComponent.categories.getItem(id).getEntity()));
            }
        }
    });
}
项目:incubator-openaz    文件:AttributeDictionarySelectorComponent.java   
protected void initializeAttributes() {
    //
    // Remove any filters
    //
    AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
    //
    // Initialize data source and GUI properties
    //
    this.listSelectAttribute.setContainerDataSource(AttributeDictionarySelectorComponent.attributes);
    this.listSelectAttribute.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.listSelectAttribute.setItemCaptionPropertyId("xacmlId");
    this.listSelectAttribute.setImmediate(true);
    this.listSelectAttribute.setHeight(7, Unit.EM);
    //
    // Filter by datatype
    //
    if (this.datatype != null) {
        AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("datatypeBean", this.datatype));
    }
    //
    // Is there a default selection?  Is there an id?
    //
    if (this.initialAttribute != null && this.initialAttribute.getId() != 0) {
        this.listSelectAttribute.select(this.initialAttribute.getId());
    }
    //
    // Respond to events
    //
    this.listSelectAttribute.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.fireAttributeChanged(self.getAttribute());
        }
    });
}
项目: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);
}
项目:metl    文件:SelectFlowsPanel.java   
public SelectFlowsPanel(ApplicationContext context, String introText,
        boolean includeTestFlows) {
    this.context = context;

    tree.setMultiSelect(true);
    tree.addContainerProperty("name", String.class, "");
    tree.setItemCaptionPropertyId("name");
    tree.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    tree.addExpandListener(event -> {
        Object itemId = event.getItemId();
        if (itemId instanceof ProjectVersion) {
            addFlowsToVersion((ProjectVersion) itemId, includeTestFlows);
        }
    });
    addProjects();

    setSpacing(true);
    setSizeFull();        
    addComponent(new Label(introText));

    Panel scrollable = new Panel();
    scrollable.addStyleName(ValoTheme.PANEL_BORDERLESS);
    scrollable.addStyleName(ValoTheme.PANEL_SCROLL_INDICATOR);
    scrollable.setSizeFull();
    scrollable.setContent(tree);
    addComponent(scrollable);
    setExpandRatio(scrollable, 1.0f);

    Set<Object> selected = new HashSet<>();
    if (firstProject != null) {
        selected.add(firstProject);
    }
    tree.setValue(selected);
    tree.focus();
}
项目:mycollab    文件:PageReadViewImpl.java   
void displayVersions(String path) {
    List<PageVersion> pageVersions = pageService.getPageVersions(path);
    if (pageVersions.size() > 0) {
        final ComboBox pageSelection = new ComboBox();
        content.addComponent(pageSelection);
        pageSelection.setNullSelectionAllowed(false);
        pageSelection.setTextInputAllowed(false);

        pageSelection.addValueChangeListener(valueChangeEvent -> {
            selectedVersion = (PageVersion) pageSelection.getValue();
            if (selectedVersion != null) {
                Page page = pageService.getPageByVersion(beanItem.getPath(), selectedVersion.getName());
                page.setPath(beanItem.getPath());
                previewForm.setBean(page);
                ((PagePreviewFormLayout) previewLayout).displayPageInfo(page);
            }
        });

        pageSelection.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
        pageSelection.setNullSelectionAllowed(false);

        for (int i = 0; i < pageVersions.size(); i++) {
            PageVersion version = pageVersions.get(i);
            pageSelection.addItem(version);
            pageSelection.setItemCaption(version, getVersionDisplay(version, i));
        }

        if (pageVersions.size() > 0) {
            pageSelection.setValue(pageVersions.get(pageVersions.size() - 1));
        }
    }
}
项目:XACML    文件:SelectPDPGroupWindow.java   
private void initializeSelect(Set<PDPGroup> groups) {
    //
    // Initialize GUI properties
    //
    this.listSelectPDPGroup.setImmediate(true);
    this.listSelectPDPGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    this.listSelectPDPGroup.setNullSelectionAllowed(false);
    this.listSelectPDPGroup.setNewItemsAllowed(false);
    this.listSelectPDPGroup.setMultiSelect(false);
    //
    // Add items
    //
    for (PDPGroup group : groups) {
        this.listSelectPDPGroup.addItem(group);
        this.listSelectPDPGroup.setItemCaption(group, group.getName());
    }
    //
    // Listen to events
    //
    this.listSelectPDPGroup.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.setupButtons();
        }
    });
}
项目:XACML    文件:PolicyEditorWindow.java   
protected void initializeSelect() {
    this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
    this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
    this.listSelectAlgorithm.setNullSelectionAllowed(false);

    if (this.policy.getRuleCombiningAlgId() == null) {
        this.policy.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue());
    }
    this.listSelectAlgorithm.setValue(JPAUtils.findRuleAlgorithm(this.policy.getRuleCombiningAlgId()).getId());
}
项目:XACML    文件:PolicySetEditorWindow.java   
protected void initializeSelect() {
    this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
    this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
    this.listSelectAlgorithm.setNullSelectionAllowed(false);

    if (this.policySet.getPolicyCombiningAlgId() == null) {
        this.policySet.setPolicyCombiningAlgId(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue());
    }
    this.listSelectAlgorithm.setValue(JPAUtils.findPolicyAlgorithm(this.policySet.getPolicyCombiningAlgId()).getId());
}
项目:XACML    文件:AttributeStandardSelectorComponent.java   
private void initializeCategories() {
    //
    // Remove any filters
    //
    AttributeStandardSelectorComponent.categories.removeAllContainerFilters();
    //
    // Initialize data source & GUI properties
    //
    this.comboBoxCategories.setContainerDataSource(AttributeStandardSelectorComponent.categories);
    this.comboBoxCategories.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxCategories.setItemCaptionPropertyId("xacmlId");
    this.comboBoxCategories.setImmediate(true);
    this.comboBoxCategories.setNullSelectionAllowed(false);
    //
    // Set default selection
    //
    Category defaultCategory;
    if (this.attribute == null || this.attribute.getCategoryBean() == null) {
        defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
    } else {
        defaultCategory = this.attribute.getCategoryBean();
    }
    if (defaultCategory != null) {
        this.comboBoxCategories.select(defaultCategory.getId());
    }
    //
    // Respond to events
    //
    this.comboBoxCategories.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.setupAttributeIDs();
            self.fireAttributeChanged(self.getAttribute());
        }
    });
}
项目:XACML    文件:AttributeDictionarySelectorComponent.java   
protected void initializeCategoryFilter() {
    //
    // Remove any filters
    //
    AttributeDictionarySelectorComponent.categories.removeAllContainerFilters();
    //
    // Initialize data source and GUI properties
    //
    this.comboBoxCategoryFilter.setContainerDataSource(AttributeDictionarySelectorComponent.categories);
    this.comboBoxCategoryFilter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxCategoryFilter.setItemCaptionPropertyId("xacmlId");
    this.comboBoxCategoryFilter.setImmediate(true);
    //
    // Respond to events
    //
    this.comboBoxCategoryFilter.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Clear any existing filters
            //
            AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
            //
            // Get the current selection
            //
            Object id = self.comboBoxCategoryFilter.getValue();
            //
            // Is anything currently selected?
            //
            if (id != null) {
                //
                // Yes - add the new filter into the container
                //
                AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("categoryBean", AttributeDictionarySelectorComponent.categories.getItem(id).getEntity()));
            }
        }
    });
}
项目:jdal    文件:ComboBoxFieldBuilder.java   
/**
 * {@inheritDoc}
 */
public Field<?> build(Class<?> clazz, String name) {
    ComboBox combo = new ComboBox();
    fillComboBox(combo, clazz, name);
    combo.setItemCaptionMode(ItemCaptionMode.ID);

    return combo;
}
项目:esup-ecandidat    文件:CtrCandOdfCandidatureWindow.java   
/**
 * Crée une fenêtre de choix pour le gestionnaire : proposition ou candidature simple
 * @param message
 */
public CtrCandOdfCandidatureWindow(String message) {
    /* Style */
    setWidth(630, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    /* Titre */
    setCaption(applicationContext.getMessage("candidature.gest.window", null, UI.getCurrent().getLocale()));

    /* Texte */
    layout.addComponent(new Label(message));
    layout.addComponent(new Label(applicationContext.getMessage("candidature.gest.window.choice", null, UI.getCurrent().getLocale())));

    /*Le container d'options*/
    BeanItemContainer<SimpleTablePresentation> optContainer = new BeanItemContainer<SimpleTablePresentation>(SimpleTablePresentation.class);
    SimpleTablePresentation optionClassique = new SimpleTablePresentation(ConstanteUtils.OPTION_CLASSIQUE,applicationContext.getMessage("candidature.gest.window.choice.classique", null, UI.getCurrent().getLocale()),null);
    SimpleTablePresentation optionProposition = new SimpleTablePresentation(ConstanteUtils.OPTION_PROP,applicationContext.getMessage("candidature.gest.window.choice.proposition", null, UI.getCurrent().getLocale()),null);
    optContainer.addItem(optionClassique);
    optContainer.addItem(optionProposition);

    optionGroupAction.setContainerDataSource(optContainer);
    optionGroupAction.addStyleName(StyleConstants.OPTION_GROUP_HORIZONTAL);
    optionGroupAction.setItemCaptionPropertyId(SimpleTablePresentation.CHAMPS_TITLE);
    optionGroupAction.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    optionGroupAction.setValue(optionClassique);

    layout.addComponent(optionGroupAction);
    layout.setComponentAlignment(optionGroupAction, Alignment.MIDDLE_CENTER);


    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    OneClickButton btnNon = new OneClickButton(applicationContext.getMessage("confirmWindow.btnNon", null, UI.getCurrent().getLocale()),FontAwesome.TIMES);
    btnNon.addClickListener(e -> close());
    buttonsLayout.addComponent(btnNon);
    buttonsLayout.setComponentAlignment(btnNon, Alignment.MIDDLE_LEFT);

    OneClickButton btnOui = new OneClickButton(applicationContext.getMessage("confirmWindow.btnOui", null, UI.getCurrent().getLocale()),FontAwesome.CHECK);
    btnOui.setIcon(FontAwesome.CHECK);
    btnOui.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnOui.addClickListener(e -> {
        SimpleTablePresentation option = (SimpleTablePresentation)optionGroupAction.getValue();
        odfCandidatureListener.btnOkClick(option.getCode());
        close();
    });
    buttonsLayout.addComponent(btnOui);
    buttonsLayout.setComponentAlignment(btnOui, Alignment.MIDDLE_RIGHT);

    /* Centre la fenêtre */
    center();
}
项目:esup-ecandidat    文件:GridFormatting.java   
/**
 * 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);
}
项目:cuba    文件:CubaColorPickerSelect.java   
public CubaColorPickerSelect() {
    super();
    range.setItemCaptionMode(ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
    range.setTextInputAllowed(false);
}
项目:incubator-openaz    文件:AttributeDictionary.java   
protected void initializeCategoryComboFilter() {
    //
    // Set data source
    //
    this.comboBoxFilterCategory.setContainerDataSource(self.categories);
    this.comboBoxFilterCategory.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxFilterCategory.setItemCaptionPropertyId("xacmlId");
    //
    // Initialize GUI properties
    //
    this.comboBoxFilterCategory.setNullSelectionAllowed(true);
    this.comboBoxFilterCategory.setImmediate(true);
    //
    // Respond to value changes
    //
    this.comboBoxFilterCategory.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;
        Filter currentFilter = null;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Remove filter
            //
            if (currentFilter != null) {
                self.attributes.removeContainerFilter(this.currentFilter);
                this.currentFilter = null;
            }
            //
            // Set the new one
            //
            Object id = self.comboBoxFilterCategory.getValue();
            if (id == null) {
                return;
            }
            Category cat = self.categories.getItem(id).getEntity();
            this.currentFilter = new Compare.Equal("categoryBean", cat);
            self.attributes.addContainerFilter(this.currentFilter);
        }
    });
}
项目:incubator-openaz    文件:AttributeDictionary.java   
protected void initializeDatatypeComboFilter() {
    //
    // Set data source
    //
    this.comboBoxFilterDatatype.setContainerDataSource(self.datatypes);
    this.comboBoxFilterDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxFilterDatatype.setItemCaptionPropertyId("xacmlId");
    //
    // Initialize GUI properties
    //
    this.comboBoxFilterDatatype.setNullSelectionAllowed(true);
    this.comboBoxFilterDatatype.setImmediate(true);
    //
    // Respond to value changes
    //
    this.comboBoxFilterDatatype.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;
        Filter currentFilter = null;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Remove filter
            //
            if (currentFilter != null) {
                self.attributes.removeContainerFilter(this.currentFilter);
                this.currentFilter = null;
            }
            //
            // Set the new one
            //
            Object id = self.comboBoxFilterDatatype.getValue();
            if (id == null) {
                return;
            }
            Datatype cat = self.datatypes.getItem(id).getEntity();
            this.currentFilter = new Compare.Equal("datatypeBean", cat);
            self.attributes.addContainerFilter(this.currentFilter);
        }
    });
}
项目:mycollab    文件:FollowingTicketSearchPanel.java   
@Override
public ComponentContainer constructBody() {
    MHorizontalLayout basicSearchBody = new MHorizontalLayout().withMargin(true);

    GridLayout selectionLayout = new GridLayout(5, 2);
    selectionLayout.setSpacing(true);
    selectionLayout.setMargin(true);
    selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
    basicSearchBody.addComponent(selectionLayout);

    Label summaryLb = new Label("Summary:");
    summaryLb.setWidthUndefined();
    selectionLayout.addComponent(summaryLb, 0, 0);

    summaryField = new TextField();
    summaryField.setWidth("100%");
    summaryField.setInputPrompt(UserUIContext.getMessage(GenericI18Enum.ACTION_QUERY_BY_TEXT));
    selectionLayout.addComponent(summaryField, 1, 0);

    Label typeLb = new Label("Type:");
    typeLb.setWidthUndefined();

    selectionLayout.addComponent(typeLb, 0, 1);

    MHorizontalLayout typeSelectWrapper = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, false));
    selectionLayout.addComponent(typeSelectWrapper, 1, 1);

    this.taskSelect = new CheckBox(UserUIContext.getMessage(TaskI18nEnum.SINGLE), true);
    this.taskSelect.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK));

    this.bugSelect = new CheckBox(UserUIContext.getMessage(BugI18nEnum.SINGLE), true);
    this.bugSelect.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));

    this.riskSelect = new CheckBox(UserUIContext.getMessage(RiskI18nEnum.SINGLE), true);
    this.riskSelect.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.RISK));

    typeSelectWrapper.with(this.taskSelect, this.bugSelect, this.riskSelect);

    Label projectLb = new Label("Project:");
    projectLb.setWidthUndefined();
    selectionLayout.addComponent(projectLb, 2, 0);

    projectField = new UserInvolvedProjectsListSelect();
    projectField.setWidth("300px");
    projectField.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    projectField.setNullSelectionAllowed(false);
    projectField.setMultiSelect(true);
    projectField.setRows(4);
    selectionLayout.addComponent(projectField, 3, 0, 3, 1);

    MButton queryBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SUBMIT), clickEvent -> doSearch())
            .withStyleName(WebThemes.BUTTON_ACTION);
    selectionLayout.addComponent(queryBtn, 4, 0);

    return basicSearchBody;
}
项目:mycollab    文件:ProjectNotificationSettingViewComponent.java   
public ProjectNotificationSettingViewComponent(final ProjectNotificationSetting bean) {
    super(UserUIContext.getMessage(ProjectSettingI18nEnum.VIEW_TITLE));

    MVerticalLayout body = new MVerticalLayout().withMargin(new MarginInfo(true, false, false, false));
    body.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final OptionGroup optionGroup = new OptionGroup(null);
    optionGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);

    optionGroup.addItem(NotificationType.Default.name());
    optionGroup.setItemCaption(NotificationType.Default.name(), UserUIContext
            .getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING));

    optionGroup.addItem(NotificationType.None.name());
    optionGroup.setItemCaption(NotificationType.None.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING));

    optionGroup.addItem(NotificationType.Minimal.name());
    optionGroup.setItemCaption(NotificationType.Minimal.name(), UserUIContext
            .getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING));

    optionGroup.addItem(NotificationType.Full.name());
    optionGroup.setItemCaption(NotificationType.Full.name(), UserUIContext
            .getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING));

    optionGroup.setWidth("100%");
    body.with(optionGroup);

    String levelVal = bean.getLevel();
    if (levelVal == null) {
        optionGroup.select(NotificationType.Default.name());
    } else {
        optionGroup.select(levelVal);
    }

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        try {
            bean.setLevel((String) optionGroup.getValue());
            ProjectNotificationSettingService projectNotificationSettingService = AppContextUtil.getSpringBean(ProjectNotificationSettingService.class);

            if (bean.getId() == null) {
                projectNotificationSettingService.saveWithSession(bean, UserUIContext.getUsername());
            } else {
                projectNotificationSettingService.updateWithSession(bean, UserUIContext.getUsername());
            }
            NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS),
                    UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
        } catch (Exception e) {
            throw new MyCollabException(e);
        }
    }).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION);
    body.addComponent(saveBtn);

    this.addComponent(body);
}
项目:mycollab    文件:CrmNotificationSettingViewImpl.java   
@Override
public void showNotificationSettings(final CrmNotificationSetting notification) {
    this.removeAllComponents();

    MVerticalLayout bodyWrapper = new MVerticalLayout();
    bodyWrapper.setSizeFull();

    MVerticalLayout body = new MVerticalLayout().withMargin(new MarginInfo(true, false, false, false));

    final OptionGroup optionGroup = new OptionGroup(null);
    optionGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);

    optionGroup.addItem(NotificationType.Default.name());
    optionGroup.setItemCaption(NotificationType.Default.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING));

    optionGroup.addItem(NotificationType.None.name());
    optionGroup.setItemCaption(NotificationType.None.name(), UserUIContext
            .getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING));

    optionGroup.addItem(NotificationType.Minimal.name());
    optionGroup.setItemCaption(NotificationType.Minimal.name(),
            UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING));

    optionGroup.addItem(NotificationType.Full.name());
    optionGroup.setItemCaption(NotificationType.Full.name(), UserUIContext
            .getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING));

    optionGroup.setHeight("100%");

    body.with(optionGroup).withAlign(optionGroup, Alignment.MIDDLE_LEFT).expand(optionGroup);

    String levelVal = notification.getLevel();
    if (levelVal == null) {
        optionGroup.select(NotificationType.Default.name());
    } else {
        optionGroup.select(levelVal);
    }

    Button updateBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_UPDATE_LABEL), clickEvent -> {
        try {
            notification.setLevel((String) optionGroup.getValue());
            CrmNotificationSettingService crmNotificationSettingService = AppContextUtil
                    .getSpringBean(CrmNotificationSettingService.class);
            if (notification.getId() == null) {
                crmNotificationSettingService.saveWithSession(notification, UserUIContext.getUsername());
            } else {
                crmNotificationSettingService.updateWithSession(notification, UserUIContext.getUsername());
            }
            NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS),
                    UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
        } catch (Exception e) {
            throw new MyCollabException(e);
        }
    }).withIcon(FontAwesome.REFRESH).withStyleName(WebThemes.BUTTON_ACTION);
    body.with(updateBtn).withAlign(updateBtn, Alignment.BOTTOM_LEFT);

    bodyWrapper.addComponent(body);
    this.addComponent(bodyWrapper);
}
项目:XACML    文件:AttributeValueEditorWindow.java   
protected void initializeCombo() {
    this.comboBoxDatatype.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
    this.comboBoxDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxDatatype.setItemCaptionPropertyId("xacmlId");
    this.comboBoxDatatype.setFilteringMode(FilteringMode.CONTAINS);
    this.comboBoxDatatype.setImmediate(true);
    this.comboBoxDatatype.setNullSelectionAllowed(false);
    this.comboBoxDatatype.setConverter(new SingleSelectConverter<Object>(this.comboBoxDatatype));
    //
    // Select a value if its defined
    //
    if (this.datatypeRestriction != null) {
        this.comboBoxDatatype.select(this.datatypeRestriction.getId());
    } else if (this.value.getDataType() != null) {
        this.comboBoxDatatype.select(JPAUtils.findDatatype(this.value.getDataType()).getId());
    }
    //
    // Can the user change the datatype?
    //
    if (this.datatypeRestriction != null) {
        this.comboBoxDatatype.setEnabled(false);
        return;
    }
    //
    // Listen to events
    //
    this.comboBoxDatatype.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Object id = self.comboBoxDatatype.getValue();
            assert (id != null);
            //
            // Get the entity and save it
            //
            EntityItem<Datatype> entity = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().getItem(id);
            self.value.setDataType(entity.getEntity().getXacmlId());
            //
            // Reset the validator
            //
            self.textFieldValue.removeAllValidators();
            Validator validator = ValidatorFactory.newInstance(entity.getEntity());
            if (validator != null) {
                self.textFieldValue.addValidator(validator);
            }
        }
    });
}
项目:XACML    文件:AttributeDictionarySelectorComponent.java   
protected void initializeAttributes() {
    //
    // Remove any filters
    //
    AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
    //
    // Initialize data source and GUI properties
    //
    this.listSelectAttribute.setContainerDataSource(AttributeDictionarySelectorComponent.attributes);
    this.listSelectAttribute.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.listSelectAttribute.setItemCaptionPropertyId("xacmlId");
    this.listSelectAttribute.setImmediate(true);
    this.listSelectAttribute.setHeight(7, Unit.EM);
    //
    // Filter by datatype
    //
    if (this.datatype != null) {
        AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("datatypeBean", this.datatype));
    }
    //
    // Is there a default selection?
    //
    if (this.initialAttribute != null) {
        //
        // Make sure it has an id. Do I really need to check?
        //
        if (this.initialAttribute.getId() != 0) {
            this.listSelectAttribute.select(this.initialAttribute.getId());
        }
    }
    //
    // Respond to events
    //
    this.listSelectAttribute.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.fireAttributeChanged(self.getAttribute());
        }
    });
}
项目:XACML    文件:AttributeDictionary.java   
protected void initializeCategoryComboFilter() {
    //
    // Set data source
    //
    this.comboBoxFilterCategory.setContainerDataSource(self.categories);
    this.comboBoxFilterCategory.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxFilterCategory.setItemCaptionPropertyId("xacmlId");
    //
    // Initialize GUI properties
    //
    this.comboBoxFilterCategory.setNullSelectionAllowed(true);
    this.comboBoxFilterCategory.setImmediate(true);
    //
    // Respond to value changes
    //
    this.comboBoxFilterCategory.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;
        Filter currentFilter = null;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Remove filter
            //
            if (currentFilter != null) {
                self.attributes.removeContainerFilter(this.currentFilter);
                this.currentFilter = null;
            }
            //
            // Set the new one
            //
            Object id = self.comboBoxFilterCategory.getValue();
            if (id == null) {
                return;
            }
            Category cat = self.categories.getItem(id).getEntity();
            this.currentFilter = new Compare.Equal("categoryBean", cat);
            self.attributes.addContainerFilter(this.currentFilter);
        }
    });
}
项目:XACML    文件:AttributeDictionary.java   
protected void initializeDatatypeComboFilter() {
    //
    // Set data source
    //
    this.comboBoxFilterDatatype.setContainerDataSource(self.datatypes);
    this.comboBoxFilterDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    this.comboBoxFilterDatatype.setItemCaptionPropertyId("xacmlId");
    //
    // Initialize GUI properties
    //
    this.comboBoxFilterDatatype.setNullSelectionAllowed(true);
    this.comboBoxFilterDatatype.setImmediate(true);
    //
    // Respond to value changes
    //
    this.comboBoxFilterDatatype.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;
        Filter currentFilter = null;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Remove filter
            //
            if (currentFilter != null) {
                self.attributes.removeContainerFilter(this.currentFilter);
                this.currentFilter = null;
            }
            //
            // Set the new one
            //
            Object id = self.comboBoxFilterDatatype.getValue();
            if (id == null) {
                return;
            }
            Datatype cat = self.datatypes.getItem(id).getEntity();
            this.currentFilter = new Compare.Equal("datatypeBean", cat);
            self.attributes.addContainerFilter(this.currentFilter);
        }
    });
}
项目:extacrm    文件:ProductField.java   
@Override
    protected Component initContent() {
        // A vertical layout with undefined width
        final VerticalLayout box = new VerticalLayout();
        box.setSizeUndefined();

        final ComboBox productSelect = new ComboBox();
        productSelect.setInputPrompt("Выберите продукт...");
        productSelect.setImmediate(true);
        productSelect.setNullSelectionAllowed(false);

        // Инициализация контейнера
        final ExtaDbContainer<TProduct> clientsCont = new ExtaDbContainer<>(productCls);
        clientsCont.addContainerFilter(new Compare.Equal("active", true));
        clientsCont.sort(new Object[]{"name"}, new boolean[]{true});

        // Устанавливаем контент выбора
        productSelect.setFilteringMode(FilteringMode.CONTAINS);
        productSelect.setContainerDataSource(clientsCont);
        productSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY);
        productSelect.setItemCaptionPropertyId("name");
        productSelect.addStyleName(ExtaTheme.COMBOBOX_BORDERLESS);

        productSelect.setPropertyDataSource(getPropertyDataSource());
        productSelect.addValueChangeListener(e -> setValue((TProduct) productSelect.getConvertedValue()));
//        productSelect.setValue(getValue());
        clientsCont.setSingleSelectConverter(productSelect);

        productSelect.setWidth(100, Unit.PERCENTAGE);
        box.addComponent(productSelect);
        // The layout shrinks to fit this label
        final Label label = new Label(getFieldTextLabel());
        label.addStyleName("ea-widthfittin-label");
        label.setWidthUndefined();
        label.setHeight("0px"); // Hide: Could be 0px
        box.addComponent(label);

        addValueChangeListener(e -> label.setValue(getFieldTextLabel()));

        return box;
    }
项目:VaadinUtils    文件:FormHelper.java   
public ComboBox build()
{
    Preconditions.checkNotNull(listField, "ListField may not be null");
    Preconditions.checkArgument(group == null || field != null, "Field may not be null");
    if (builderForm == null)
    {
        builderForm = form;
    }
    Preconditions.checkNotNull(builderForm, "Form may not be null");

    if (component == null)
    {
        component = new SplitComboBox(label);
    }
    component.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    if (label != null)
    {
        component.setCaption(label);
        component.setId(label.replace(" ", ""));
    }

    if (container == null)
    {
        Preconditions.checkNotNull(listClazz, "listClazz may not be null");
        container = JpaBaseDao.getGenericDao(listClazz).createVaadinContainer();

    }

    // Preconditions.checkState(container.getContainerPropertyIds().contains(listField),
    // listField
    // + " is not valid, valid listFieldNames are " +
    // container.getContainerPropertyIds().toString());

    ContainerAdaptor<L> adaptor = ContainerAdaptorFactory.getAdaptor(container);
    if (adaptor.getSortableContainerPropertyIds().contains(listField))
    {
        adaptor.sort(new String[] { listField }, new boolean[] { true });
    }

    component.setItemCaptionPropertyId(listField);
    component.setContainerDataSource(container);
    SingleSelectConverter<L> converter = new SingleSelectConverter<>(component);
    component.setConverter(converter);
    component.setNewItemsAllowed(false);
    component.setNullSelectionAllowed(false);
    component.setTextInputAllowed(true);
    component.setWidth(STANDARD_COMBO_WIDTH);
    component.setPopupWidth("100%");
    component.setImmediate(true);
    addValueChangeListeners(component);
    if (group != null)
    {
        Collection<? extends Object> ids = null;
        if (group.getContainer() != null)
        {
            ids = group.getContainer().getContainerPropertyIds();
        }
        else if (group.getItemDataSource() != null)
        {
            ids = group.getItemDataSource().getItemPropertyIds();
        }

        Preconditions.checkNotNull(ids,
                "The group must have either a Container or an ItemDataSource attached.");

        Preconditions.checkState(ids.contains(field),
                field + " is not valid, valid listFieldNames are " + ids.toString());

        doBinding(group, field, component);
    }
    builderForm.addComponent(component);
    return component;
}
项目:VaadinUtils    文件:FormHelper.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
public SplitListSelect build()
{
    Preconditions.checkNotNull(label, "label may not be null");
    Preconditions.checkNotNull(listField, "colField Property may not be null");
    if (builderForm == null)
    {
        builderForm = form;
    }
    Preconditions.checkNotNull(builderForm, "Form may not be null");

    if (component == null)
    {
        component = new SplitListSelect(label);
    }

    component.setCaption(label);
    component.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    component.setItemCaptionPropertyId(listField);

    if (container == null)
    {
        Preconditions.checkNotNull(listClazz, "listClazz may not be null");
        container = JpaBaseDao.getGenericDao(listClazz).createVaadinContainer();
    }

    Preconditions.checkState(container.getContainerPropertyIds().contains(listField), listField
            + " is not valid, valid listFields are " + container.getContainerPropertyIds().toString());

    if (container.getSortableContainerPropertyIds().contains(listField))
    {
        container.sort(new String[] { listField }, new boolean[] { true });
    }

    component.setContainerDataSource(container);

    if (this.multiSelect == true)
    {
        component.setConverter(new MultiSelectConverter(component, Set.class));
        component.setMultiSelect(true);
    }
    else
    {
        SingleSelectConverter<L> converter = new SingleSelectConverter<>(component);
        component.setConverter(converter);
    }

    component.setWidth("100%");
    component.setImmediate(true);
    component.setNullSelectionAllowed(false);
    component.setId(label.replace(" ", ""));

    if (group != null && field != null)
    {
        Preconditions.checkState(group.getContainer().getContainerPropertyIds().contains(field),
                field + " is not valid, valid listFieldNames are "
                        + group.getContainer().getContainerPropertyIds().toString());

        doBinding(group, field, component);
    }
    builderForm.addComponent(component);

    return component;
}
项目:VaadinUtils    文件:FormHelper.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
public SplitTwinColSelect build()
{
    Preconditions.checkNotNull(label, "label may not be null");
    Preconditions.checkNotNull(listField, "colField Property may not be null");
    Preconditions.checkArgument(group == null || field != null, "Field may not be null");
    if (builderForm == null)
    {
        builderForm = form;
    }
    Preconditions.checkNotNull(builderForm, "Form may not be null");

    if (component == null)
    {
        component = new SplitTwinColSelect(label);
    }

    component.setCaption(label);
    component.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    component.setItemCaptionPropertyId(listField);
    component.setLeftColumnCaption(leftColumnCaption);
    component.setRightColumnCaption(rightColumnCaption);

    if (container == null)
    {
        Preconditions.checkNotNull(listClazz, "listClazz may not be null");
        container = JpaBaseDao.getGenericDao(listClazz).createVaadinContainer();
    }

    Preconditions.checkState(container.getContainerPropertyIds().contains(listField), listField
            + " is not valid, valid listFields are " + container.getContainerPropertyIds().toString());

    ContainerAdaptor<L> adaptor = ContainerAdaptorFactory.getAdaptor(container);
    if (adaptor.getSortableContainerPropertyIds().contains(listField))
    {
        adaptor.sort(new String[] { listField }, new boolean[] { true });
    }

    component.setContainerDataSource(container);
    component.setConverter(new MultiSelectConverter(component, Set.class));

    component.setWidth("100%");
    component.setId(label.replace(" ", ""));
    component.setImmediate(true);
    component.setNullSelectionAllowed(true);
    component.setBuffered(true);
    addValueChangeListeners(component);

    if (group != null)
    {
        Preconditions.checkState(group.getContainer().getContainerPropertyIds().contains(field),
                field + " is not valid, valid listFieldNames are "
                        + group.getContainer().getContainerPropertyIds().toString());

        doBinding(group, field, component);
    }
    builderForm.addComponent(component);

    return component;
}
项目:scoutmaster    文件:GroupDetailStep.java   
@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;
}
项目:jdal    文件:FormUtils.java   
/**
 * 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);
}