Search in sources :

Example 1 with IColumnImageProvider

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

the class AbstractHL7MetadataTableEditorView method configureNameColumn.

/**
     * DOC amaumont Comment method "configureNameColumn".
     * 
     * @param tableViewerCreator
     */
protected void configureNameColumn(TableViewerCreator<B> tableViewerCreator) {
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setId(ID_COLUMN_NAME);
    //$NON-NLS-1$
    column.setTitle("User Column(Click to edit)");
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.ColumnTitle"));
    column.setBeanPropertyAccessors(getLabelAccessor());
    final Image imageKey = ImageProvider.getImage(EImage.KEY_ICON);
    final Image imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
    column.setCellEditor(cellEditor);
    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.setImageProvider(new IColumnImageProvider() {

        public Image getImage(Object element) {
            if (getKeyAccesor().get((B) element)) {
                return imageKey;
            } else {
                return imageEmpty;
            }
        }
    });
    column.setWeight(25);
    column.setModifiable(!isReadOnly());
    column.setMinimumWidth(45);
    // final TextCellEditor cellEditor = new TextCellEditor(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);
    nameColumn = column;
}
Also used : IColumnImageProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnImageProvider) CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Example 2 with IColumnImageProvider

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

the class JSONFileOutputMetadataEmfTableEditorView method configureNameColumn.

protected void configureNameColumn(TableViewerCreator<MetadataColumn> tableViewerCreator) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setId(ID_COLUMN_NAME);
    //$NON-NLS-1$
    column.setTitle("Schema List");
    column.setWidth(100);
    column.setToolTipHeader("Column");
    column.setBeanPropertyAccessors(getLabelAccessor());
    final Image imageKey = ImageProvider.getImage(EImage.KEY_ICON);
    final Image imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
    column.setCellEditor(cellEditor);
    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.setImageProvider(new IColumnImageProvider() {

        public Image getImage(Object element) {
            if (getKeyAccesor().get((MetadataColumn) element)) {
                return imageKey;
            } else {
                return imageEmpty;
            }
        }
    });
    column.setWeight(25);
    column.setModifiable(!isReadOnly());
    column.setMinimumWidth(20);
// nameColumn = column;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IColumnImageProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnImageProvider) CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) EImage(org.talend.commons.ui.runtime.image.EImage) Image(org.eclipse.swt.graphics.Image)

Aggregations

TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)2 Image (org.eclipse.swt.graphics.Image)2 EImage (org.talend.commons.ui.runtime.image.EImage)2 IColumnImageProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnImageProvider)2 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)2 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)2 DialogErrorForCellEditorListener (org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1