com.vaadin.data.util.IndexedContainer - java examples

Here are the examples of the java api com.vaadin.data.util.IndexedContainer taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

25 Examples 7

19 View Complete Implementation : UploadProgressInfoWindow.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Window that shows the progress of all uploads.
 */
public clreplaced UploadProgressInfoWindow extends Window {

    private static final long serialVersionUID = 1L;

    private static final String COLUMN_PROGRESS = UIMessageIdProvider.CAPTION_ARTIFACT_UPLOAD_PROGRESS;

    private static final String COLUMN_FILE_NAME = UIMessageIdProvider.CAPTION_ARTIFACT_FILENAME;

    private static final String COLUMN_STATUS = UIMessageIdProvider.CAPTION_ARTIFACT_UPLOAD_STATUS;

    private static final String COLUMN_REASON = UIMessageIdProvider.CAPTION_ARTIFACT_UPLOAD_REASON;

    private static final String COLUMN_SOFTWARE_MODULE = UIMessageIdProvider.CAPTION_SOFTWARE_MODULE;

    private static final String STATUS_INPROGRESS = "InProgress";

    private static final String STATUS_FINISHED = "Finished";

    private static final String STATUS_FAILED = "Failed";

    private final ArtifactUploadState artifactUploadState;

    private final VaadinMessageSource i18n;

    private final Grid grid;

    private final IndexedContainer uploads;

    private final VerticalLayout mainLayout;

    private final UI ui;

    private Label windowCaption;

    private Button closeButton;

    UploadProgressInfoWindow(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState, final VaadinMessageSource i18n) {
        this.artifactUploadState = artifactUploadState;
        this.i18n = i18n;
        setPopupProperties();
        createStatusPopupHeaderComponents();
        mainLayout = new VerticalLayout();
        mainLayout.setSpacing(Boolean.TRUE);
        mainLayout.setSizeUndefined();
        setPopupSizeInMinMode();
        uploads = getGridContainer();
        grid = createGrid();
        setGridColumnProperties();
        mainLayout.addComponents(getCaptionLayout(), grid);
        mainLayout.setExpandRatio(grid, 1.0F);
        setContent(mainLayout);
        eventBus.subscribe(this);
        ui = UI.getCurrent();
    }

    @EventBusListenerMethod(scope = EventScope.UI)
    void onEvent(final FileUploadProgress fileUploadProgress) {
        switch(fileUploadProgress.getFileUploadStatus()) {
            case UPLOAD_STARTED:
                ui.access(() -> onUploadStarted(fileUploadProgress));
                break;
            case UPLOAD_IN_PROGRESS:
            case UPLOAD_FAILED:
            case UPLOAD_SUCCESSFUL:
                ui.access(() -> updateUploadProgressInfoRowObject(fileUploadProgress));
                break;
            case UPLOAD_FINISHED:
                ui.access(this::onUploadFinished);
                break;
            default:
                break;
        }
    }

    private void onUploadStarted(final FileUploadProgress fileUploadProgress) {
        updateUploadProgressInfoRowObject(fileUploadProgress);
        if (isWindowNotAlreadyAttached()) {
            maximizeWindow();
        }
        grid.scrollTo(fileUploadProgress.getFileUploadId());
    }

    private boolean isWindowNotAlreadyAttached() {
        return !UI.getCurrent().getWindows().contains(this);
    }

    private void restoreState() {
        final Indexed container = grid.getContainerDataSource();
        container.removeAllItems();
        for (final FileUploadProgress fileUploadProgress : artifactUploadState.getAllFileUploadProgressValuesFromOverallUploadProcessList()) {
            updateUploadProgressInfoRowObject(fileUploadProgress);
        }
    }

    private void setPopupProperties() {
        setId(UIComponentIdProvider.UPLOAD_STATUS_POPUP_ID);
        addStyleName(SPUIStyleDefinitions.UPLOAD_INFO);
        setImmediate(true);
        setResizable(false);
        setDraggable(true);
        setClosable(false);
        setModal(true);
    }

    private void setGridColumnProperties() {
        grid.getColumn(COLUMN_STATUS).setRenderer(new StatusRenderer());
        grid.getColumn(COLUMN_PROGRESS).setRenderer(new ProgressBarRenderer());
        grid.setColumnOrder(COLUMN_STATUS, COLUMN_PROGRESS, COLUMN_FILE_NAME, COLUMN_SOFTWARE_MODULE, COLUMN_REASON);
        setColumnWidth();
        grid.getColumn(COLUMN_STATUS).setHeaderCaption(i18n.getMessage(COLUMN_STATUS));
        grid.getColumn(COLUMN_PROGRESS).setHeaderCaption(i18n.getMessage(COLUMN_PROGRESS));
        grid.getColumn(COLUMN_FILE_NAME).setHeaderCaption(i18n.getMessage(COLUMN_FILE_NAME));
        grid.getColumn(COLUMN_SOFTWARE_MODULE).setHeaderCaption(i18n.getMessage(COLUMN_SOFTWARE_MODULE));
        grid.getColumn(COLUMN_REASON).setHeaderCaption(i18n.getMessage(COLUMN_REASON));
        grid.setFrozenColumnCount(5);
    }

    private Grid createGrid() {
        final Grid statusGrid = new Grid(uploads);
        statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
        statusGrid.setId(UIComponentIdProvider.UPLOAD_STATUS_POPUP_GRID);
        statusGrid.setSelectionMode(SelectionMode.NONE);
        statusGrid.setHeaderVisible(true);
        statusGrid.setImmediate(true);
        statusGrid.setSizeFull();
        return statusGrid;
    }

    private static IndexedContainer getGridContainer() {
        final IndexedContainer uploadContainer = new IndexedContainer();
        uploadContainer.addContainerProperty(COLUMN_STATUS, String.clreplaced, "Active");
        uploadContainer.addContainerProperty(COLUMN_FILE_NAME, String.clreplaced, null);
        uploadContainer.addContainerProperty(COLUMN_PROGRESS, Double.clreplaced, 0D);
        uploadContainer.addContainerProperty(COLUMN_REASON, String.clreplaced, "");
        uploadContainer.addContainerProperty(COLUMN_SOFTWARE_MODULE, String.clreplaced, "");
        return uploadContainer;
    }

    private HorizontalLayout getCaptionLayout() {
        final HorizontalLayout captionLayout = new HorizontalLayout();
        captionLayout.setSizeFull();
        captionLayout.setHeight("36px");
        captionLayout.addComponents(windowCaption, closeButton);
        captionLayout.setExpandRatio(windowCaption, 1.0F);
        captionLayout.addStyleName("v-window-header");
        return captionLayout;
    }

    private void createStatusPopupHeaderComponents() {
        windowCaption = new Label(i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_UPLOAD_POPUP));
        closeButton = getCloseButton();
    }

    private void setColumnWidth() {
        grid.getColumn(COLUMN_STATUS).setWidth(60);
        grid.getColumn(COLUMN_PROGRESS).setWidth(150);
        grid.getColumn(COLUMN_FILE_NAME).setWidth(200);
        grid.getColumn(COLUMN_REASON).setWidth(290);
        grid.getColumn(COLUMN_SOFTWARE_MODULE).setWidth(200);
    }

    private static clreplaced StatusRenderer extends HtmlRenderer {

        private static final long serialVersionUID = 1L;

        @Override
        public JsonValue encode(final String value) {
            if (value == null) {
                return super.encode(getNullRepresentation());
            }
            final String result;
            switch(value) {
                case STATUS_FINISHED:
                    result = "<div clreplaced=\"statusIconGreen\">" + FontAwesome.CHECK_CIRCLE.getHtml() + "</div>";
                    break;
                case STATUS_FAILED:
                    result = "<div clreplaced=\"statusIconRed\">" + FontAwesome.EXCLAMATION_CIRCLE.getHtml() + "</div>";
                    break;
                case STATUS_INPROGRESS:
                    result = "<div clreplaced=\"statusIconActive\"></div>";
                    break;
                default:
                    throw new IllegalArgumentException("Argument " + value + " wasn't expected.");
            }
            return super.encode(result);
        }
    }

    private void openWindow() {
        UI.getCurrent().addWindow(this);
        center();
    }

    protected void maximizeWindow() {
        openWindow();
        restoreState();
        artifactUploadState.setStatusPopupMinimized(false);
    }

    private void minimizeWindow() {
        artifactUploadState.setStatusPopupMinimized(true);
        closeWindow();
        if (artifactUploadState.areAllUploadsFinished()) {
            cleanupStates();
        }
    }

    /**
     * Called for every finished (succeeded or failed) upload.
     */
    private void onUploadFinished() {
        if (artifactUploadState.areAllUploadsFinished() && artifactUploadState.isStatusPopupMinimized()) {
            if (artifactUploadState.getFilesInFailedState().isEmpty()) {
                cleanupStates();
                closeWindow();
            } else {
                maximizeWindow();
            }
        }
    }

    private void cleanupStates() {
        uploads.removeAllItems();
        artifactUploadState.clearUploadTempData();
    }

    private void setPopupSizeInMinMode() {
        mainLayout.setWidth(900, Unit.PIXELS);
        mainLayout.setHeight(510, Unit.PIXELS);
    }

    private Button getCloseButton() {
        final Button closeBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.UPLOAD_STATUS_POPUP_CLOSE_BUTTON_ID, "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorder.clreplaced);
        closeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
        closeBtn.addClickListener(event -> onClose());
        return closeBtn;
    }

    private void onClose() {
        if (artifactUploadState.areAllUploadsFinished()) {
            cleanupStates();
            closeWindow();
        } else {
            minimizeWindow();
        }
    }

    private void closeWindow() {
        setWindowMode(WindowMode.NORMAL);
        setColumnWidth();
        setPopupSizeInMinMode();
        this.close();
    }

    @SuppressWarnings("unchecked")
    private void updateUploadProgressInfoRowObject(final FileUploadProgress fileUploadProgress) {
        final FileUploadId fileUploadId = fileUploadProgress.getFileUploadId();
        Item item = uploads.gereplacedem(fileUploadId);
        if (item == null) {
            item = grid.getContainerDataSource().addItem(fileUploadId);
            item.gereplacedemProperty(COLUMN_FILE_NAME).setValue(fileUploadId.getFilename());
            item.gereplacedemProperty(COLUMN_SOFTWARE_MODULE).setValue(HawkbitCommonUtil.getFormattedNameVersion(fileUploadId.getSoftwareModuleName(), fileUploadId.getSoftwareModuleVersion()));
        }
        final String status;
        final FileUploadStatus uploadStatus = fileUploadProgress.getFileUploadStatus();
        if (uploadStatus == FileUploadStatus.UPLOAD_FAILED) {
            status = STATUS_FAILED;
        } else if (uploadStatus == FileUploadStatus.UPLOAD_SUCCESSFUL) {
            status = STATUS_FINISHED;
        } else {
            status = STATUS_INPROGRESS;
        }
        item.gereplacedemProperty(COLUMN_STATUS).setValue(status);
        item.gereplacedemProperty(COLUMN_REASON).setValue(getFailureReason(fileUploadId));
        final long bytesRead = fileUploadProgress.getBytesRead();
        final long fileSize = fileUploadProgress.getContentLength();
        if (bytesRead > 0 && fileSize > 0) {
            item.gereplacedemProperty(COLUMN_PROGRESS).setValue((double) bytesRead / (double) fileSize);
        }
    }

    /**
     * Returns the failure reason for the provided fileUploadId or an empty
     * string but never <code>null</code>.
     *
     * @param fileUploadId
     * @return the failure reason or an empty String.
     */
    private String getFailureReason(final FileUploadId fileUploadId) {
        String failureReason = "";
        if (artifactUploadState.getFileUploadProgress(fileUploadId) != null) {
            failureReason = artifactUploadState.getFileUploadProgress(fileUploadId).getFailureReason();
        }
        if (StringUtils.isEmpty(failureReason)) {
            return "";
        }
        return failureReason;
    }
}

19 View Complete Implementation : TagAssignementComboBox.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Combobox that lists all available Tags that can be replacedigned to a
 * {@link Target} or {@link DistributionSet}.
 */
public clreplaced TagreplacedignementComboBox extends HorizontalLayout {

    private static final long serialVersionUID = 1L;

    private static final String NAME_PROPERTY = "name";

    private static final String COLOR_PROPERTY = "color";

    private final IndexedContainer allreplacedignableTags;

    private final transient Set<TagreplacedignmentListener> listeners = Sets.newConcurrentHashSet();

    private final ComboBox replacedignableTagsComboBox;

    private final boolean readOnlyMode;

    /**
     * Constructor.
     *
     * @param i18n
     *            the i18n
     * @param readOnlyMode
     *            if true the combobox will be disabled so no replacedignment can be
     *            done.
     */
    TagreplacedignementComboBox(final VaadinMessageSource i18n, final boolean readOnlyMode) {
        this.readOnlyMode = readOnlyMode;
        setWidth("100%");
        allreplacedignableTags = new IndexedContainer();
        allreplacedignableTags.addContainerProperty(NAME_PROPERTY, String.clreplaced, "");
        allreplacedignableTags.addContainerProperty(COLOR_PROPERTY, String.clreplaced, "");
        replacedignableTagsComboBox = new ComboBoxBuilder().setId(UIComponentIdProvider.TAG_SELECTION_ID).setPrompt(i18n.getMessage(UIMessageIdProvider.TOOLTIP_SELECT_TAG)).setValueChangeListener(this::onSelectionChanged).buildCombBox();
        addComponent(replacedignableTagsComboBox);
        replacedignableTagsComboBox.setContainerDataSource(allreplacedignableTags);
        replacedignableTagsComboBox.setNullSelectionAllowed(true);
        replacedignableTagsComboBox.addStyleName(SPUIStyleDefinitions.DETAILS_LAYOUT_STYLE);
        replacedignableTagsComboBox.addStyleName(ValoTheme.COMBOBOX_TINY);
        replacedignableTagsComboBox.setEnabled(!readOnlyMode);
        replacedignableTagsComboBox.setWidth("100%");
        clearComboBoxSelection();
    }

    /**
     * Initializes the Combobox with all replacedignable tags.
     *
     * @param replacedignableTags
     *            replacedignable tags
     */
    void initializereplacedignableTags(final List<TagData> replacedignableTags) {
        replacedignableTags.forEach(this::addreplacedignableTag);
    }

    private void onSelectionChanged(final ValueChangeEvent event) {
        final Object selectedValue = event.getProperty().getValue();
        if (!isValidTagSelection(selectedValue) || readOnlyMode) {
            return;
        }
        replacedignTag((String) selectedValue);
    }

    private void replacedignTag(final String tagName) {
        allreplacedignableTags.removeItem(tagName);
        notifyListenersTagreplacedigned(tagName);
        clearComboBoxSelection();
    }

    private boolean isValidTagSelection(final Object selectedValue) {
        return selectedValue != null && selectedValue != replacedignableTagsComboBox.getNullSelectionItemId() && selectedValue instanceof String;
    }

    /**
     * Removes all Tags from Combobox.
     */
    void removeAllTags() {
        allreplacedignableTags.removeAllItems();
        clearComboBoxSelection();
    }

    /**
     * Adds an replacedignable Tag to the combobox.
     *
     * @param tagData
     *            the data of the Tag
     */
    void addreplacedignableTag(final TagData tagData) {
        final Item item = allreplacedignableTags.addItem(tagData.getName());
        if (item == null) {
            return;
        }
        item.gereplacedemProperty(NAME_PROPERTY).setValue(tagData.getName());
        item.gereplacedemProperty(COLOR_PROPERTY).setValue(tagData.getColor());
    }

    /**
     * Removes an replacedignable tag from the combobox.
     *
     * @param tagData
     *            the {@link TagData} of the Tag that should be removed.
     */
    void removereplacedignableTag(final TagData tagData) {
        allreplacedignableTags.removeItem(tagData.getName());
    }

    /**
     * Registers an {@link TagreplacedignmentListener} on the combobox.
     *
     * @param listener
     *            the listener to register
     */
    void addTagreplacedignmentListener(final TagreplacedignmentListener listener) {
        listeners.add(listener);
    }

    /**
     * Removes a {@link TagreplacedignmentListener} from the combobox,
     *
     * @param listener
     *            the listener that should be removed.
     */
    void removeTagreplacedignmentListener(final TagreplacedignmentListener listener) {
        listeners.remove(listener);
    }

    private void notifyListenersTagreplacedigned(final String tagName) {
        listeners.forEach(listener -> listener.replacedignTag(tagName));
    }

    private void clearComboBoxSelection() {
        replacedignableTagsComboBox.select(replacedignableTagsComboBox.getNullSelectionItemId());
    }
}

19 View Complete Implementation : DistributionSetTypeSoftwareModuleSelectLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Layout for the software modules select tables for managing Distribution Set
 * Types on the Distributions View.
 */
public clreplaced DistributionSetTypeSoftwareModuleSelectLayout extends VerticalLayout {

    private static final long serialVersionUID = 1L;

    private static final String DIST_TYPE_DESCRIPTION = "description";

    private static final String DIST_TYPE_MANDATORY = "mandatory";

    private static final String STAR = " * ";

    private static final String DIST_TYPE_NAME = "name";

    private final transient SoftwareModuleTypeManagement softwareModuleTypeManagement;

    private Table selectedTable;

    private Table sourceTable;

    private IndexedContainer selectedTableContainer;

    private IndexedContainer sourceTableContainer;

    private HorizontalLayout distTypeSelectLayout;

    private final VaadinMessageSource i18n;

    /**
     * Constructor
     *
     * @param i18n
     *            VaadinMessageSource
     * @param softwareModuleTypeManagement
     *            SoftwareModuleTypeManagement
     */
    public DistributionSetTypeSoftwareModuleSelectLayout(final VaadinMessageSource i18n, final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
        this.softwareModuleTypeManagement = softwareModuleTypeManagement;
        this.i18n = i18n;
        init();
    }

    protected void init() {
        distTypeSelectLayout = createTwinColumnLayout();
        setSizeFull();
        addComponent(distTypeSelectLayout);
    }

    private HorizontalLayout createTwinColumnLayout() {
        final HorizontalLayout twinColumnLayout = new HorizontalLayout();
        twinColumnLayout.setSizeFull();
        twinColumnLayout.setWidth("400px");
        buildSourceTable();
        buildSelectedTable();
        final VerticalLayout selectButtonLayout = new VerticalLayout();
        final Button selectButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SELECT_DIST_TYPE, "", "", "arrow-button", true, FontAwesome.FORWARD, SPUIButtonStyleNoBorder.clreplaced);
        selectButton.addClickListener(event -> addSMType());
        final Button unSelectButton = SPUIComponentProvider.getButton("unselect-dist-type", "", "", "arrow-button", true, FontAwesome.BACKWARD, SPUIButtonStyleNoBorder.clreplaced);
        unSelectButton.addClickListener(event -> removeSMType());
        selectButtonLayout.addComponent(selectButton);
        selectButtonLayout.addComponent(unSelectButton);
        selectButtonLayout.setComponentAlignment(selectButton, Alignment.MIDDLE_CENTER);
        selectButtonLayout.setComponentAlignment(unSelectButton, Alignment.MIDDLE_CENTER);
        twinColumnLayout.addComponent(sourceTable);
        twinColumnLayout.addComponent(selectButtonLayout);
        twinColumnLayout.addComponent(selectedTable);
        twinColumnLayout.setComponentAlignment(sourceTable, Alignment.MIDDLE_LEFT);
        twinColumnLayout.setComponentAlignment(selectButtonLayout, Alignment.MIDDLE_CENTER);
        twinColumnLayout.setComponentAlignment(selectedTable, Alignment.MIDDLE_RIGHT);
        twinColumnLayout.setExpandRatio(sourceTable, 0.45F);
        twinColumnLayout.setExpandRatio(selectButtonLayout, 0.07F);
        twinColumnLayout.setExpandRatio(selectedTable, 0.48F);
        sourceTable.setVisibleColumns(DIST_TYPE_NAME);
        return twinColumnLayout;
    }

    private void buildSelectedTable() {
        selectedTable = new Table();
        selectedTable.setId(SPUIDefinitions.TWIN_TABLE_SELECTED_ID);
        selectedTable.setSelectable(true);
        selectedTable.setMultiSelect(true);
        selectedTable.setSortEnabled(false);
        selectedTable.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
        selectedTable.addStyleName(ValoTheme.TABLE_NO_STRIPES);
        selectedTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
        selectedTable.addStyleName(ValoTheme.TABLE_SMALL);
        selectedTable.addStyleName("dist_type_twin-table");
        selectedTable.setSizeFull();
        createSelectedTableContainer();
        selectedTable.setContainerDataSource(selectedTableContainer);
        addTooltTipToSelectedTable();
        selectedTable.setImmediate(true);
        selectedTable.setVisibleColumns(DIST_TYPE_NAME, DIST_TYPE_MANDATORY);
        selectedTable.setColumnHeaders(i18n.getMessage("header.dist.twintable.selected"), STAR);
        selectedTable.setColumnExpandRatio(DIST_TYPE_NAME, 0.75F);
        selectedTable.setColumnExpandRatio(DIST_TYPE_MANDATORY, 0.25F);
        selectedTable.setRequired(true);
    }

    private void addTooltTipToSelectedTable() {
        selectedTable.sereplacedemDescriptionGenerator(new ItemDescriptionGenerator() {

            private static final long serialVersionUID = 1L;

            @Override
            public String generateDescription(final Component source, final Object itemId, final Object propertyId) {
                final Item item = selectedTable.gereplacedem(itemId);
                final String description = (String) (item.gereplacedemProperty(DIST_TYPE_DESCRIPTION).getValue());
                if (DIST_TYPE_NAME.equals(propertyId) && !StringUtils.isEmpty(description)) {
                    return i18n.getMessage("label.description") + description;
                } else if (DIST_TYPE_MANDATORY.equals(propertyId)) {
                    return i18n.getMessage(UIMessageIdProvider.TOOLTIP_CHECK_FOR_MANDATORY);
                }
                return null;
            }
        });
    }

    private void buildSourceTable() {
        sourceTable = new Table();
        sourceTable.setId(SPUIDefinitions.TWIN_TABLE_SOURCE_ID);
        sourceTable.setSelectable(true);
        sourceTable.setMultiSelect(true);
        sourceTable.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
        sourceTable.addStyleName(ValoTheme.TABLE_NO_STRIPES);
        sourceTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
        sourceTable.addStyleName(ValoTheme.TABLE_SMALL);
        sourceTable.setImmediate(true);
        sourceTable.setSizeFull();
        sourceTable.addStyleName("dist_type_twin-table");
        sourceTable.setSortEnabled(false);
        sourceTableContainer = new IndexedContainer();
        sourceTableContainer.addContainerProperty(DIST_TYPE_NAME, String.clreplaced, "");
        sourceTableContainer.addContainerProperty(DIST_TYPE_DESCRIPTION, String.clreplaced, "");
        sourceTable.setContainerDataSource(sourceTableContainer);
        sourceTable.setVisibleColumns(DIST_TYPE_NAME);
        sourceTable.setColumnHeaders(i18n.getMessage("header.dist.twintable.available"));
        sourceTable.setColumnExpandRatio(DIST_TYPE_NAME, 1.0F);
        createSourceTableData();
        addTooltip();
        sourceTable.select(sourceTable.firsreplacedemId());
    }

    @SuppressWarnings("unchecked")
    protected void createSourceTableData() {
        sourceTableContainer.removeAllItems();
        final Iterable<SoftwareModuleType> moduleTypeBeans = softwareModuleTypeManagement.findAll(PageRequest.of(0, 1000));
        Item saveTblitem;
        for (final SoftwareModuleType swTypeTag : moduleTypeBeans) {
            saveTblitem = sourceTableContainer.addItem(swTypeTag.getId());
            saveTblitem.gereplacedemProperty(DIST_TYPE_NAME).setValue(swTypeTag.getName());
            saveTblitem.gereplacedemProperty(DIST_TYPE_DESCRIPTION).setValue(swTypeTag.getDescription());
        }
    }

    protected void addTooltip() {
        sourceTable.sereplacedemDescriptionGenerator(new ItemDescriptionGenerator() {

            private static final long serialVersionUID = 1L;

            @Override
            public String generateDescription(final Component source, final Object itemId, final Object propertyId) {
                final Item item = sourceTable.gereplacedem(itemId);
                final String description = (String) item.gereplacedemProperty(DIST_TYPE_DESCRIPTION).getValue();
                if (DIST_TYPE_NAME.equals(propertyId) && !StringUtils.isEmpty(description)) {
                    return i18n.getMessage("label.description") + description;
                }
                return null;
            }
        });
    }

    protected void createSelectedTableContainer() {
        selectedTableContainer = new IndexedContainer();
        selectedTableContainer.addContainerProperty(DIST_TYPE_NAME, String.clreplaced, "");
        selectedTableContainer.addContainerProperty(DIST_TYPE_DESCRIPTION, String.clreplaced, "");
        selectedTableContainer.addContainerProperty(DIST_TYPE_MANDATORY, CheckBox.clreplaced, null);
    }

    @SuppressWarnings("unchecked")
    private void addSMType() {
        final Set<Long> selectedIds = (Set<Long>) sourceTable.getValue();
        if (selectedIds == null) {
            return;
        }
        for (final Long id : selectedIds) {
            addTargetTableData(id);
        }
    }

    private void addTargetTableData(final Long selectedId) {
        getSelectedTableItemData(selectedId);
        sourceTable.removeItem(selectedId);
    }

    @SuppressWarnings("unchecked")
    private void getSelectedTableItemData(final Long id) {
        Item saveTblitem;
        if (selectedTableContainer != null) {
            saveTblitem = selectedTableContainer.addItem(id);
            saveTblitem.gereplacedemProperty(DIST_TYPE_NAME).setValue(sourceTable.getContainerDataSource().gereplacedem(id).gereplacedemProperty(DIST_TYPE_NAME).getValue());
            final CheckBox mandatoryCheckBox = new CheckBox();
            saveTblitem.gereplacedemProperty(DIST_TYPE_MANDATORY).setValue(mandatoryCheckBox);
            saveTblitem.gereplacedemProperty(DIST_TYPE_DESCRIPTION).setValue(sourceTable.getContainerDataSource().gereplacedem(id).gereplacedemProperty(DIST_TYPE_DESCRIPTION).getValue());
        }
    }

    @SuppressWarnings("unchecked")
    private void addSourceTableData(final Long selectedId) {
        if (sourceTableContainer != null) {
            Item saveTblitem;
            saveTblitem = sourceTableContainer.addItem(selectedId);
            saveTblitem.gereplacedemProperty(DIST_TYPE_NAME).setValue(selectedTable.getContainerDataSource().gereplacedem(selectedId).gereplacedemProperty(DIST_TYPE_NAME).getValue());
            saveTblitem.gereplacedemProperty(DIST_TYPE_DESCRIPTION).setValue(selectedTable.getContainerDataSource().gereplacedem(selectedId).gereplacedemProperty(DIST_TYPE_DESCRIPTION).getValue());
        }
    }

    private void removeSMType() {
        @SuppressWarnings("unchecked")
        final Set<Long> selectedIds = (Set<Long>) selectedTable.getValue();
        if (selectedIds == null) {
            return;
        }
        for (final Long id : selectedIds) {
            addSourceTableData(id);
            selectedTable.removeItem(id);
        }
    }

    public Table getSelectedTable() {
        return selectedTable;
    }

    public static String getDistTypeMandatory() {
        return DIST_TYPE_MANDATORY;
    }

    public static String getDistTypeDescription() {
        return DIST_TYPE_DESCRIPTION;
    }

    public static String getDistTypeName() {
        return DIST_TYPE_NAME;
    }

    public Table getSourceTable() {
        return sourceTable;
    }

    public IndexedContainer getSourceTableContainer() {
        return sourceTableContainer;
    }

    protected static boolean isMandatoryModuleType(final Item item) {
        final CheckBox mandatoryCheckBox = (CheckBox) item.gereplacedemProperty(getDistTypeMandatory()).getValue();
        return mandatoryCheckBox.getValue();
    }

    public IndexedContainer getSelectedTableContainer() {
        return selectedTableContainer;
    }

    protected static boolean isOptionalModuleType(final Item item) {
        return !isMandatoryModuleType(item);
    }

    public HorizontalLayout getDistTypeSelectLayout() {
        return distTypeSelectLayout;
    }

    public void setDistTypeSelectLayout(final HorizontalLayout distTypeSelectLayout) {
        this.distTypeSelectLayout = distTypeSelectLayout;
    }

    /**
     * Resets the tables for selecting the software modules
     */
    public void reset() {
        selectedTableContainer.removeAllItems();
        createSourceTableData();
    }
}

19 View Complete Implementation : UpdateDistributionSetTypeLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Layout for the pop-up window which is created when updating a Distribution
 * Set Type on the Distributions View.
 */
public clreplaced UpdateDistributionSetTypeLayout extends AbstractDistributionSetTypeLayout implements UpdateTag {

    private static final long serialVersionUID = 1L;

    private final transient DistributionSetManagement distributionSetManagement;

    private final String selectedTypeName;

    private IndexedContainer originalSelectedTableContainer;

    private final CloseListener closeListener;

    /**
     * Constructor
     *
     * @param i18n
     *            VaadinMessageSource
     * @param enreplacedyFactory
     *            EnreplacedyFactory
     * @param eventBus
     *            UIEventBus
     * @param permChecker
     *            SpPermissionChecker
     * @param uiNotification
     *            UINotification
     * @param softwareModuleTypeManagement
     *            SoftwareModuleTypeManagement
     * @param distributionSetTypeManagement
     *            DistributionSetTypeManagement
     * @param distributionSetManagement
     *            DistributionSetManagement
     * @param selectedTypeName
     *            the name of the distribution set type to update
     * @param closeListener
     *            CloseListener
     */
    public UpdateDistributionSetTypeLayout(final VaadinMessageSource i18n, final EnreplacedyFactory enreplacedyFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker, final UINotification uiNotification, final SoftwareModuleTypeManagement softwareModuleTypeManagement, final DistributionSetTypeManagement distributionSetTypeManagement, final DistributionSetManagement distributionSetManagement, final String selectedTypeName, final CloseListener closeListener) {
        super(i18n, enreplacedyFactory, eventBus, permChecker, uiNotification, distributionSetTypeManagement, softwareModuleTypeManagement);
        this.distributionSetManagement = distributionSetManagement;
        this.selectedTypeName = selectedTypeName;
        this.closeListener = closeListener;
        initUpdatePopup();
    }

    private void initUpdatePopup() {
        setTagDetails(selectedTypeName);
        getWindow().addCloseListener(closeListener);
    }

    @Override
    protected String getWindowCaption() {
        return getI18n().getMessage("caption.update", getI18n().getMessage("caption.type"));
    }

    @Override
    protected void saveEnreplacedy() {
        updateDistributionSetType(findEnreplacedyByName().orElseThrow(() -> new EnreplacedyNotFoundException(DistributionSetType.clreplaced, getTagName().getValue())));
    }

    @Override
    protected void buildLayout() {
        super.buildLayout();
        disableFields();
    }

    @Override
    protected void disableFields() {
        getTypeKey().setEnabled(false);
        getTagName().setEnabled(false);
    }

    @Override
    public void setTagDetails(final String selectedEnreplacedy) {
        getTwinTables().createSourceTableData();
        getTwinTables().getSelectedTable().getContainerDataSource().removeAllItems();
        final Optional<DistributionSetType> selectedDistSetType = getDistributionSetTypeManagement().getByName(selectedEnreplacedy);
        selectedDistSetType.ifPresent(selectedType -> {
            getTagName().setValue(selectedType.getName());
            getTagDesc().setValue(selectedType.getDescription());
            getTypeKey().setValue(selectedType.getKey());
            if (distributionSetManagement.countByTypeId(selectedType.getId()) <= 0) {
                getTwinTables().getDistTypeSelectLayout().setEnabled(true);
                getTwinTables().getSelectedTable().setEnabled(true);
            } else {
                getUiNotification().displayValidationError(selectedType.getName() + "  " + getI18n().getMessage("message.error.dist.set.type.update"));
                getTwinTables().getDistTypeSelectLayout().setEnabled(false);
                getTwinTables().getSelectedTable().setEnabled(false);
            }
            createOriginalSelectedTableContainer();
            selectedType.getOptionalModuleTypes().forEach(swModuleType -> addTargetTableForUpdate(swModuleType, false));
            selectedType.getMandatoryModuleTypes().forEach(swModuleType -> addTargetTableForUpdate(swModuleType, true));
            setColorPickerComponentsColor(selectedType.getColour());
        });
        disableFields();
        getWindow().setOrginaleValues();
    }

    private void createOriginalSelectedTableContainer() {
        originalSelectedTableContainer = new IndexedContainer();
        originalSelectedTableContainer.addContainerProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeName(), String.clreplaced, "");
        originalSelectedTableContainer.addContainerProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeDescription(), String.clreplaced, "");
        originalSelectedTableContainer.addContainerProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeMandatory(), CheckBox.clreplaced, null);
    }

    @SuppressWarnings("unchecked")
    private void addTargetTableForUpdate(final SoftwareModuleType swModuleType, final boolean mandatory) {
        if (getTwinTables().getSelectedTableContainer() == null) {
            return;
        }
        final Item saveTblitem = getTwinTables().getSelectedTableContainer().addItem(swModuleType.getId());
        getTwinTables().getSourceTable().removeItem(swModuleType.getId());
        saveTblitem.gereplacedemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeName()).setValue(swModuleType.getName());
        final CheckBox mandatoryCheckbox = new CheckBox("", mandatory);
        mandatoryCheckbox.setId(swModuleType.getName());
        saveTblitem.gereplacedemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeMandatory()).setValue(mandatoryCheckbox);
        final Item originalItem = originalSelectedTableContainer.addItem(swModuleType.getId());
        originalItem.gereplacedemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeName()).setValue(swModuleType.getName());
        originalItem.gereplacedemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeMandatory()).setValue(mandatoryCheckbox);
        getWindow().updateAllComponents(mandatoryCheckbox);
    }

    @SuppressWarnings("unchecked")
    private void updateDistributionSetType(final DistributionSetType existingType) {
        final List<Long> itemIds = (List<Long>) getTwinTables().getSelectedTable().gereplacedemIds();
        final DistributionSetTypeUpdate update = getEnreplacedyFactory().distributionSetType().update(existingType.getId()).description(getTagDesc().getValue()).colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
        if (distributionSetManagement.countByTypeId(existingType.getId()) <= 0 && !CollectionUtils.isEmpty(itemIds)) {
            update.mandatory(itemIds.stream().filter(itemId -> DistributionSetTypeSoftwareModuleSelectLayout.isMandatoryModuleType(getTwinTables().getSelectedTable().gereplacedem(itemId))).collect(Collectors.toList())).optional(itemIds.stream().filter(itemId -> DistributionSetTypeSoftwareModuleSelectLayout.isOptionalModuleType(getTwinTables().getSelectedTable().gereplacedem(itemId))).collect(Collectors.toList()));
        }
        final DistributionSetType updateDistSetType = getDistributionSetTypeManagement().update(update);
        getUiNotification().displaySuccess(getI18n().getMessage("message.update.success", updateDistSetType.getName()));
        getEventBus().publish(this, new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType));
    }

    @Override
    protected boolean isUpdateAction() {
        return true;
    }
}

19 View Complete Implementation : PreviewCSV.java
Copyright GNU General Public License v3.0
Author : rlsutton1
private static void addItemProperties(IndexedContainer container, String[] fieldMaps) {
    for (String key : fieldMaps) {
        container.addContainerProperty(key, String.clreplaced, null);
    }
}

19 View Complete Implementation : PreviewCSV.java
Copyright GNU General Public License v3.0
Author : rlsutton1
protected IndexedContainer buildContainerFromCSV(Reader reader, int rowLimit) throws IOException {
    IndexedContainer container = new IndexedContainer();
    try (CSVReader csvReader = new CSVReader(reader)) {
        String[] columnHeaders = null;
        String[] record;
        // Import no more than 100 records as this is only a sample
        int count = 0;
        while (((record = csvReader.readNext()) != null) && count < rowLimit) {
            if (columnHeaders == null) {
                columnHeaders = record;
                addItemProperties(container, record);
                columnHeaders = record;
            } else {
                addRow(container, record, columnHeaders);
                count++;
            }
        }
    }
    return container;
}

19 View Complete Implementation : FieldGroupSelectNestedJavaBeansView.java
Copyright The Unlicense
Author : rolandkrueger
public clreplaced FieldGroupSelectNestedJavaBeansView extends TranslatedCustomLayout {

    private final MessageProvider messageProvider;

    // @formatter:off
    private static List<Department> DEPARTMENTS = new ArrayList<Department>(Arrays.asList(new Department("Human Resources", "John Smith"), new Department("IT", "Dan Developer"), new Department("Accounting", "Jane Doe"), new Department("Engineering", "Marc Jones")));

    // @formatter:on
    private Table employeeTable;

    private TabSheet tabsheet;

    private BeanItemContainer<Employee> employeeContainer;

    private BeanItemContainer<Department> departmentBeanItemContainer;

    private IndexedContainer departmentIndexedContainer;

    public FieldGroupSelectNestedJavaBeansView(TemplateData layoutData, MessageProvider messageProvider) {
        super(layoutData);
        this.messageProvider = messageProvider;
    }

    @Override
    public View buildLayout() {
        super.buildLayout();
        buildDepartmentContainer();
        buildIndexedContainer();
        buildEmployeeContainer();
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.addComponent(buildTabsheet());
        layout.addComponent(buildEmployeeTable());
        getLayout().addComponent(layout, "layout");
        return this;
    }

    @SuppressWarnings("unchecked")
    private void buildIndexedContainer() {
        departmentIndexedContainer = new IndexedContainer();
        departmentIndexedContainer.addContainerProperty("name", String.clreplaced, "");
        departmentIndexedContainer.addContainerProperty("bean", Department.clreplaced, null);
        for (Department department : DEPARTMENTS) {
            Object itemId = departmentIndexedContainer.addItem();
            Item item = departmentIndexedContainer.gereplacedem(itemId);
            item.gereplacedemProperty("name").setValue(department.getName());
            item.gereplacedemProperty("bean").setValue(department);
        }
    }

    private TabSheet buildTabsheet() {
        tabsheet = new TabSheet();
        tabsheet.addTab(buildBeanItemContainerTab(), messageProvider.getMessage("FieldGroupSelectNestedJavaBeans.beanItemContainerTab"));
        tabsheet.addTab(buildIndexedContainerTab(), messageProvider.getMessage("FieldGroupSelectNestedJavaBeans.indexedContainerTab"));
        return tabsheet;
    }

    private void buildEmployeeContainer() {
        employeeContainer = new BeanItemContainer<Employee>(Employee.clreplaced);
        employeeContainer.addBean(new Employee("Mary", "Poppins", DEPARTMENTS.get(0)));
        employeeContainer.addBean(new Employee("Max", "Cromwell", DEPARTMENTS.get(1)));
    }

    private void buildDepartmentContainer() {
        departmentBeanItemContainer = new BeanItemContainer<Department>(Department.clreplaced);
        departmentBeanItemContainer.addAll(DEPARTMENTS);
    }

    private Table buildEmployeeTable() {
        employeeTable = new Table();
        employeeTable.setWidth("100%");
        employeeTable.setContainerDataSource(employeeContainer);
        employeeTable.setVisibleColumns("firstName", "lastName", "department");
        employeeTable.setColumnHeaders(messageProvider.getMessage("FieldGroupSelectNestedJavaBeans.firstname"), messageProvider.getMessage("FieldGroupSelectNestedJavaBeans.lastname"), messageProvider.getMessage("FieldGroupSelectNestedJavaBeans.department"));
        employeeTable.setSelectable(true);
        return employeeTable;
    }

    private Component buildBeanItemContainerTab() {
        EmployeeForm form = new EmployeeForm(employeeContainer, departmentBeanItemContainer, "FieldGroupSelectNestedJavaBeans.beanItemContainerInfo", messageProvider);
        return form;
    }

    private Component buildIndexedContainerTab() {
        EmployeeForm form = new EmployeeForm(employeeContainer, departmentIndexedContainer, "FieldGroupSelectNestedJavaBeans.indexedContainerInfo", messageProvider);
        form.getDepartmentSelector().setConverter(new IndexToDepartmentConverter(departmentIndexedContainer));
        form.getDepartmentSelector().sereplacedemCaptionMode(ItemCaptionMode.ID);
        form.getDepartmentSelector().sereplacedemCaptionPropertyId("name");
        return form;
    }
}

19 View Complete Implementation : IndexToDepartmentConverter.java
Copyright The Unlicense
Author : rolandkrueger
public clreplaced IndexToDepartmentConverter implements Converter<Object, Department> {

    private static final String BEAN_PROPERTY_ID = "bean";

    private static final long serialVersionUID = -4854942758136647077L;

    private IndexedContainer container;

    public IndexToDepartmentConverter(IndexedContainer container) {
        this.container = container;
    }

    @Override
    public Department convertToModel(Object itemID, Clreplaced<? extends Department> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
        if (itemID == null) {
            return null;
        }
        Item item = container.gereplacedem(itemID);
        if (item == null) {
            return null;
        }
        return (Department) item.gereplacedemProperty(BEAN_PROPERTY_ID).getValue();
    }

    @Override
    public Integer convertToPresentation(Department model, Clreplaced<? extends Object> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
        if (model == null) {
            return null;
        }
        for (Object itemId : container.gereplacedemIds()) {
            Item item = container.gereplacedem(itemId);
            if (model.equals((Department) item.gereplacedemProperty(BEAN_PROPERTY_ID).getValue())) {
                return (Integer) itemId;
            }
        }
        return null;
    }

    @Override
    public Clreplaced<Department> getModelType() {
        return Department.clreplaced;
    }

    @Override
    public Clreplaced<Object> getPresentationType() {
        return Object.clreplaced;
    }
}

19 View Complete Implementation : IndexToDepartmentConverter.java
Copyright The Unlicense
Author : rolandkrueger
/**
 * {@link Converter} implementation for converting the item IDs of an
 * {@link IndexedContainer} into the corresponding domain model, which is the
 * {@link Department} enreplacedy bean clreplaced in this example.
 */
public clreplaced IndexToDepartmentConverter implements Converter<Object, Department> {

    private static final String BEAN_PROPERTY_ID = "bean";

    private static final long serialVersionUID = -4854942758136647077L;

    /**
     * {@link IndexedContainer} instance that contains the Department beans in an
     * item property with ID "bean".
     */
    private IndexedContainer container;

    public IndexToDepartmentConverter(IndexedContainer container) {
        this.container = container;
    }

    @Override
    public Department convertToModel(Object itemID, Clreplaced<? extends Department> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
        // return null if the given item ID object is null to prevent
        // NullPointerExceptions
        if (itemID == null) {
            return null;
        }
        // fetch the item referenced by the given item ID from the container
        Item item = container.gereplacedem(itemID);
        if (item == null) {
            return null;
        }
        // read the property with ID "bean" from this item and return the property's
        // value as a Department instance
        return (Department) item.gereplacedemProperty(BEAN_PROPERTY_ID).getValue();
    }

    @Override
    public Integer convertToPresentation(Department model, Clreplaced<? extends Object> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
        // return null if the given model object is null to prevent
        // NullPointerExceptions
        if (model == null) {
            return null;
        }
        // walk over all item IDs in the container
        for (Object itemId : container.gereplacedemIds()) {
            // fetch the current item
            Item item = container.gereplacedem(itemId);
            // if the item's "bean" property contains the Department object preplaceded in
            // as parameter then the item's ID is returned.
            if (model.equals((Department) item.gereplacedemProperty(BEAN_PROPERTY_ID).getValue())) {
                return (Integer) itemId;
            }
        }
        return null;
    }

    @Override
    public Clreplaced<Department> getModelType() {
        return Department.clreplaced;
    }

    @Override
    public Clreplaced<Object> getPresentationType() {
        return Object.clreplaced;
    }
}

19 View Complete Implementation : NestedJavaBeansInAVaadinFieldGroupUI.java
Copyright The Unlicense
Author : rolandkrueger
@PreserveOnRefresh
public clreplaced NestedJavaBeansInAVaadinFieldGroupUI extends UI {

    private static final long serialVersionUID = -6733290242808872455L;

    private static final String DESCRIPTION = "This demo shows how to configure a FieldGroup that contains a selection component for " + "selecting a nested JavaBean property of another JavaBean enreplacedy. In this example, there is an enreplacedy bean 'Employee' " + "which contains a nested JavaBean property 'Department'. In the two forms shown on the tab-sheet you can add new Employee " + "objects to the employee table. The first form uses a BeanItemContainer as the container data source of the department " + "selection component. The second form uses an IndexedContainer as data model. For this second FieldGroup to work, it is " + "necessary to set a specific converter on the selection component which converts between item ID and Department object. Of course, for the user both forms behave exactly the same " + "which is the whole purpose of this tutorial. The difference between these two forms is only visible in code.";

    // @formatter:off
    // Master data list of available Department enreplacedies. Typically, such a list is loaded from the database.
    private static List<Department> DEPARTMENTS = new ArrayList<Department>(Arrays.asList(new Department("Human Resources", "John Smith"), new Department("IT", "Dan Developer"), new Department("Accounting", "Jane Doe"), new Department("Engineering", "Marc Jones")));

    // @formatter:on
    private EmployeeForm beanItemContainerForm;

    private EmployeeForm indexedContainerForm;

    private BeanItemContainer<Employee> employeeContainer;

    private BeanItemContainer<Department> departmentBeanItemContainer;

    private IndexedContainer departmentIndexedContainer;

    @Override
    protected void init(VaadinRequest request) {
        buildDepartmentContainer();
        buildIndexedContainer();
        buildEmployeeContainer();
        setContent(buildLayout());
    }

    private Component buildLayout() {
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        layout.setSpacing(true);
        buildBeanItemContainerForm();
        buildIndexedContainerForm();
        TabSheet tabsheet = new TabSheet();
        tabsheet.addTab(beanItemContainerForm, "Department selector's container data source: BeanItemContainer");
        tabsheet.addTab(indexedContainerForm, "Department selector's container data source: IndexedContainer");
        layout.setWidth("100%");
        layout.addComponent(new Label(DESCRIPTION));
        layout.addComponent(tabsheet);
        layout.addComponent(buildEmployeeTable());
        return layout;
    }

    private void buildBeanItemContainerForm() {
        beanItemContainerForm = new EmployeeForm(employeeContainer, departmentBeanItemContainer, "This selection component uses a <strong>com.vaadin.data.util.BeanItemContainer</strong> as its container data source:");
    }

    private Table buildEmployeeTable() {
        Table employeeTable = new Table();
        employeeTable.setWidth("100%");
        employeeTable.setContainerDataSource(employeeContainer);
        employeeTable.setVisibleColumns("firstName", "lastName", "department");
        employeeTable.setSelectable(true);
        return employeeTable;
    }

    private void buildIndexedContainerForm() {
        indexedContainerForm = new EmployeeForm(employeeContainer, departmentIndexedContainer, "This selection component uses a <strong>com.vaadin.data.util.IndexedContainer</strong> as its container data source:");
        indexedContainerForm.getDepartmentSelector().setConverter(new IndexToDepartmentConverter(departmentIndexedContainer));
        indexedContainerForm.getDepartmentSelector().sereplacedemCaptionMode(ItemCaptionMode.ID);
        indexedContainerForm.getDepartmentSelector().sereplacedemCaptionPropertyId("name");
    }

    @SuppressWarnings("unchecked")
    private void buildIndexedContainer() {
        departmentIndexedContainer = new IndexedContainer();
        departmentIndexedContainer.addContainerProperty("name", String.clreplaced, "");
        departmentIndexedContainer.addContainerProperty("bean", Department.clreplaced, null);
        for (Department department : DEPARTMENTS) {
            Object itemId = departmentIndexedContainer.addItem();
            Item item = departmentIndexedContainer.gereplacedem(itemId);
            item.gereplacedemProperty("name").setValue(department.getName());
            item.gereplacedemProperty("bean").setValue(department);
        }
    }

    private void buildDepartmentContainer() {
        departmentBeanItemContainer = new BeanItemContainer<Department>(Department.clreplaced);
        departmentBeanItemContainer.addAll(DEPARTMENTS);
    }

    private void buildEmployeeContainer() {
        employeeContainer = new BeanItemContainer<Employee>(Employee.clreplaced);
        employeeContainer.addBean(new Employee("Mary", "Poppins", DEPARTMENTS.get(0)));
        employeeContainer.addBean(new Employee("Max", "Cromwell", DEPARTMENTS.get(1)));
    }
}

18 View Complete Implementation : UploadProgressInfoWindow.java
Copyright Eclipse Public License 1.0
Author : eclipse
private static IndexedContainer getGridContainer() {
    final IndexedContainer uploadContainer = new IndexedContainer();
    uploadContainer.addContainerProperty(COLUMN_STATUS, String.clreplaced, "Active");
    uploadContainer.addContainerProperty(COLUMN_FILE_NAME, String.clreplaced, null);
    uploadContainer.addContainerProperty(COLUMN_PROGRESS, Double.clreplaced, 0D);
    uploadContainer.addContainerProperty(COLUMN_REASON, String.clreplaced, "");
    uploadContainer.addContainerProperty(COLUMN_SOFTWARE_MODULE, String.clreplaced, "");
    return uploadContainer;
}

18 View Complete Implementation : AbstractMetadataPopupLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
protected Item addItemToGrid(final M metaData) {
    final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
    final Item item = metadataContainer.addItem(metaData.getKey());
    item.gereplacedemProperty(VALUE).setValue(metaData.getValue());
    item.gereplacedemProperty(KEY).setValue(metaData.getKey());
    return item;
}

18 View Complete Implementation : AbstractMetadataPopupLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
private static IndexedContainer getMetadataContainer() {
    final IndexedContainer swcontactContainer = new IndexedContainer();
    swcontactContainer.addContainerProperty(KEY, String.clreplaced, "");
    swcontactContainer.addContainerProperty(VALUE, String.clreplaced, "");
    swcontactContainer.addContainerProperty(DELETE_BUTTON, String.clreplaced, FontAwesome.TRASH_O.getHtml());
    return swcontactContainer;
}

18 View Complete Implementation : AbstractMetadataDetailsLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
private IndexedContainer getContainer() {
    final IndexedContainer container = new IndexedContainer();
    container.addContainerProperty(METADATA_KEY, String.clreplaced, "");
    setColumnExpandRatio(METADATA_KEY, 0.7F);
    setColumnAlignment(METADATA_KEY, Align.LEFT);
    return container;
}

18 View Complete Implementation : TargetFilterQueryDetailsTable.java
Copyright Eclipse Public License 1.0
Author : eclipse
private IndexedContainer getDistSetContainer() {
    final IndexedContainer container = new IndexedContainer();
    container.addContainerProperty(TFQ_NAME, String.clreplaced, "");
    container.addContainerProperty(TFQ_QUERY, String.clreplaced, "");
    setColumnExpandRatio(TFQ_NAME, 0.4F);
    setColumnAlignment(TFQ_NAME, Align.LEFT);
    setColumnExpandRatio(TFQ_QUERY, 0.6F);
    setColumnAlignment(TFQ_QUERY, Align.LEFT);
    return container;
}

18 View Complete Implementation : PreviewCSV.java
Copyright GNU General Public License v3.0
Author : rlsutton1
private IndexedContainer buildContainerFromList(List<List<String>> data, int rowLimit) {
    IndexedContainer container = new IndexedContainer();
    String[] columnHeaders = null;
    // Import no more than 100 records as this is only a sample
    int count = 0;
    for (List<String> row : data) {
        String[] rowArray = row.toArray(new String[0]);
        if (columnHeaders == null) {
            addItemProperties(container, rowArray);
            columnHeaders = rowArray;
        } else {
            addRow(container, rowArray, columnHeaders);
            count++;
        }
        if (count > 100)
            break;
    }
    return container;
}

17 View Complete Implementation : AbstractMetadataPopupLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
protected Item updateItemInGrid(final String key) {
    final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
    final Item item = metadataContainer.gereplacedem(key);
    item.gereplacedemProperty(VALUE).setValue(valueTextArea.getValue());
    return item;
}

17 View Complete Implementation : SoftwareModuleDetailsTable.java
Copyright Eclipse Public License 1.0
Author : eclipse
private IndexedContainer getSwModuleContainer() {
    final IndexedContainer container = new IndexedContainer();
    container.addContainerProperty(SOFT_TYPE_MANDATORY, Label.clreplaced, "");
    container.addContainerProperty(SOFT_TYPE_NAME, Label.clreplaced, "");
    container.addContainerProperty(SOFT_MODULE, VerticalLayout.clreplaced, "");
    setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1F);
    setColumnExpandRatio(SOFT_TYPE_NAME, 0.4F);
    setColumnExpandRatio(SOFT_MODULE, 0.3F);
    setColumnAlignment(SOFT_TYPE_MANDATORY, Align.RIGHT);
    setColumnAlignment(SOFT_TYPE_NAME, Align.LEFT);
    setColumnAlignment(SOFT_MODULE, Align.LEFT);
    return container;
}

17 View Complete Implementation : PreviewCSV.java
Copyright GNU General Public License v3.0
Author : rlsutton1
private static void addRow(IndexedContainer container, String[] fields, String[] headers) {
    Object itemId = container.addItem();
    Item item = container.gereplacedem(itemId);
    for (int i = 0; i < headers.length; i++) {
        @SuppressWarnings("unchecked")
        Property<String> itemProperty = item.gereplacedemProperty(headers[i]);
        itemProperty.setValue(fields[i]);
    }
}

16 View Complete Implementation : EmailTargetLayout.java
Copyright GNU General Public License v3.0
Author : rlsutton1
@SuppressWarnings("unchecked")
private Item addItem(final IndexedContainer container, final String named, String email) {
    // When we are editing an email (as second time) we can end up with
    // double brackets so we strip them off here.
    if (email.startsWith("<")) {
        email = email.substring(1);
    }
    if (email.endsWith(">")) {
        email = email.substring(0, email.length() - 1);
    }
    Item item = container.gereplacedem(email);
    if (item == null) {
        item = container.addItem(email);
    }
    if (item != null) {
        item.gereplacedemProperty("id").setValue(email);
        item.gereplacedemProperty("email").setValue(email);
        String namedEmail;
        if (named != null && named.trim().length() > 0) {
            namedEmail = named + " <" + email + ">";
        } else {
            namedEmail = "<" + email + ">";
        }
        item.gereplacedemProperty("namedemail").setValue(namedEmail);
    } else {
        logger.error("Failed to find or create the recipient");
    }
    return item;
}

16 View Complete Implementation : DemoController.java
Copyright Apache License 2.0
Author : tehapo
@SuppressWarnings("unchecked")
@UiDataSource("person-list")
public Container getPersonContainer() {
    IndexedContainer container = new IndexedContainer();
    container.addContainerProperty("Name", String.clreplaced, "");
    container.addContainerProperty("Age", Integer.clreplaced, 0);
    Object itemId = container.addItem();
    container.gereplacedem(itemId).gereplacedemProperty("Name").setValue("Teemu Pöntelin");
    container.gereplacedem(itemId).gereplacedemProperty("Age").setValue(32);
    itemId = container.addItem();
    container.gereplacedem(itemId).gereplacedemProperty("Name").setValue("John Smith");
    container.gereplacedem(itemId).gereplacedemProperty("Age").setValue(35);
    return container;
}

14 View Complete Implementation : PreviewCSV.java
Copyright GNU General Public License v3.0
Author : rlsutton1
public Component getContentFromList(List<List<String>> data, String caption, int rowLimit) {
    Table table = new Table();
    table.setSizeFull();
    if (data.size() > 1) {
        IndexedContainer indexedContainer = buildContainerFromList(data, rowLimit);
        /* Finally, let's update the table with the container */
        table.setCaption(caption);
        table.setContainerDataSource(indexedContainer);
        table.setVisible(true);
    } else {
        /* Finally, let's update the table with the container */
        table.setCaption("No file selected");
        table.setVisible(true);
    }
    /* Main layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    layout.addComponent(table);
    layout.setExpandRatio(table, 1);
    return layout;
}

14 View Complete Implementation : FormHelper.java
Copyright GNU General Public License v3.0
Author : rlsutton1
@SuppressWarnings("unchecked")
static public IndexedContainer createContainerFromMap(String fieldName, Map<?, String> hashMap) {
    IndexedContainer container = new IndexedContainer();
    container.addContainerProperty(fieldName, String.clreplaced, "");
    Iterator<?> iter = hashMap.keySet().iterator();
    while (iter.hasNext()) {
        Object itemId = iter.next();
        container.addItem(itemId);
        container.gereplacedem(itemId).gereplacedemProperty(fieldName).setValue(hashMap.get(itemId));
    }
    return container;
}

13 View Complete Implementation : PreviewCSV.java
Copyright GNU General Public License v3.0
Author : rlsutton1
public Component getContentFile(File tempFile, String caption, int rowLimit) {
    Table table = new Table();
    table.setSizeFull();
    FileReader reader;
    try {
        if (tempFile.exists()) {
            reader = new FileReader(tempFile);
            IndexedContainer indexedContainer = buildContainerFromCSV(reader, rowLimit);
            reader.close();
            /* Finally, let's update the table with the container */
            table.setCaption(caption);
            table.setContainerDataSource(indexedContainer);
            table.setVisible(true);
        } else {
            /* Finally, let's update the table with the container */
            table.setCaption("No file selected");
            table.setVisible(true);
        }
    } catch (FileNotFoundException e) {
        logger.error(e, e);
        throw new RuntimeException(e);
    } catch (IOException e) {
        logger.error(e, e);
        Notification.show(e.getMessage());
    }
    /* Main layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    layout.addComponent(table);
    layout.setExpandRatio(table, 1);
    return layout;
}

4 View Complete Implementation : MainView.java
Copyright GNU General Public License v3.0
Author : AskNowQA
private Component createSelectTBSLComponent() {
    l = new VerticalLayout();
    l.setSpacing(true);
    l.setSizeFull();
    IndexedContainer ic = new IndexedContainer();
    ic.addContainerProperty("label", String.clreplaced, null);
    for (ExtendedTBSL tbsl : UserSession.getManager().tbsls) {
        ic.addItem(tbsl).gereplacedemProperty("label").setValue(tbsl.getLabel());
    }
    tbslSelector = new NativeSelect();
    tbslSelector.addStyleName("borderless");
    tbslSelector.setWidth("100%");
    tbslSelector.setHeight(null);
    tbslSelector.setNullSelectionAllowed(false);
    tbslSelector.setContainerDataSource(ic);
    tbslSelector.setImmediate(true);
    tbslSelector.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            onChangeKnowledgebase();
        }
    });
    l.addComponent(tbslSelector);
    knowledgebaseLogo = new Embedded("");
    knowledgebaseLogo.setType(Embedded.TYPE_IMAGE);
    knowledgebaseLogo.setHeight("50px");
    l.addComponent(knowledgebaseLogo);
    l.setComponentAlignment(knowledgebaseLogo, Alignment.MIDDLE_CENTER);
    l.setExpandRatio(knowledgebaseLogo, 1f);
    return l;
}