Search in sources :

Example 6 with ColumnCellModifier

use of org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier in project tbd-studio-se by Talend.

the class HDFSMetadataTableEditorView method configureNameColumn.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView#configureNameColumn(org.talend.commons.ui.
     * swt.tableviewer.TableViewerCreator)
     */
@Override
protected void configureNameColumn(TableViewerCreator<MetadataColumn> tableViewerCreator) {
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setId(ID_COLUMN_NAME);
    column.setTitle("Column");
    column.setToolTipHeader("Column");
    column.setBeanPropertyAccessors(getLabelAccessor());
    final Image imageKey = ImageProvider.getImage(EImage.KEY_ICON);
    final Image imageEmpty = ImageProvider.getImage(EImage.EMPTY);
    column.setImageProvider(new IColumnImageProvider() {

        @Override
        public Image getImage(Object element) {
            if (getKeyAccesor().get((MetadataColumn) element)) {
                return imageKey;
            } else {
                return imageEmpty;
            }
        }
    });
    column.setWeight(25);
    column.setModifiable(!isReadOnly());
    column.setMinimumWidth(45);
    final ColumnCellModifier columnCellModifier = new ColumnCellModifier(column) {

        @Override
        public boolean canModify(Object bean) {
            MetadataColumn columnBean = (MetadataColumn) bean;
            TaggedValue seqKeyTV = TaggedValueHelper.getTaggedValue(HDFSConstants.IS_SEQUENCE_KEY, columnBean.getTaggedValue());
            TaggedValue seqValTV = TaggedValueHelper.getTaggedValue(HDFSConstants.IS_SEQUENCE_VALUE, columnBean.getTaggedValue());
            if (seqKeyTV != null || seqValTV != null) {
                return false;
            }
            return true;
        }
    };
    column.setColorProvider(new IColumnColorProvider() {

        @Override
        public Color getBackgroundColor(Object bean) {
            if (!columnCellModifier.canModify(bean)) {
                return READONLY_CELL_BG_COLOR;
            }
            return null;
        }

        @Override
        public Color getForegroundColor(Object bean) {
            return null;
        }
    });
    column.setColumnCellModifier(columnCellModifier);
    final TextCellEditor cellEditor = new TextCellEditorExtendTab(tableViewerCreator.getTable());
    cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {

        @Override
        public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
        }

        @Override
        public String validateValue(String newValue, int beanPosition) {
            return validateColumnName(newValue, beanPosition);
        }
    });
    column.setCellEditor(cellEditor);
}
Also used : CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) Color(org.eclipse.swt.graphics.Color) EImage(org.talend.commons.ui.runtime.image.EImage) Image(org.eclipse.swt.graphics.Image) ColumnCellModifier(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IColumnImageProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnImageProvider) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)

Aggregations

ColumnCellModifier (org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)6 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)6 Color (org.eclipse.swt.graphics.Color)5 IColumnColorProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)5 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)4 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)3 CCombo (org.eclipse.swt.custom.CCombo)3 IColumnLabelProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnLabelProvider)3 TextCellEditorWithProposal (org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 CellEditor (org.eclipse.jface.viewers.CellEditor)2 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)2 ContentProposalAdapterExtended (org.talend.commons.ui.swt.proposal.ContentProposalAdapterExtended)2 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)2 DialogErrorForCellEditorListener (org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener)2 EditableComboBoxCellEditor (org.talend.commons.ui.swt.tableviewer.celleditor.EditableComboBoxCellEditor)2 CheckboxTableEditorContent (org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2