Search in sources :

Example 1 with TableViewerCreatorColumn

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

the class MergeOrderDialog method createDialogArea.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite tableComposite = new Composite(composite, SWT.None);
    tableComposite.setLayout(new GridLayout());
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = WIDTH;
    gridData.minimumWidth = WIDTH;
    gridData.heightHint = HEIGHT;
    gridData.minimumHeight = HEIGHT;
    tableComposite.setLayoutData(gridData);
    final TableViewerCreator tableViewerCreator = new TableViewerCreator(tableComposite);
    tableViewerCreator.setBorderVisible(true);
    tableViewerCreator.setCheckboxInFirstColumn(false);
    tableViewerCreator.setColumnsResizableByDefault(true);
    tableViewerCreator.setColumnsSortableByDefault(true);
    tableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
    Table table = tableViewerCreator.createTable();
    table.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MergeOrderDialog.Order"));
    column.setModifiable(true);
    column.setWidth(50);
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MergeOrderDialog.CurrentOrderConnection"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {

        public String get(Connection bean) {
            return String.valueOf(connectionList.indexOf(bean) + 1);
        }

        public void set(Connection bean, String value) {
        // bean.setName(value);
        }
    });
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MergeOrderDialog.ConnectionName"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {

        public String get(Connection bean) {
            return getDisplayStr(bean);
        }

        public void set(Connection bean, String value) {
        // bean.setName(value);
        }
    });
    column.setModifiable(false);
    column.setWidth(200);
    tableViewerCreator.init(connectionList);
    Composite buttonComposite = new Composite(composite, SWT.None);
    buttonComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    Button moveUp = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    moveUp.setToolTipText(Messages.getString("MergeOrderDialog.MoveUp"));
    moveUp.setImage(ImageProvider.getImage(EImage.UP_ICON));
    moveUp.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
            Connection connection = (Connection) selection.getFirstElement();
            int connId = connectionList.indexOf(connection);
            if (connId > 0) {
                Collections.swap(connectionList, connId - 1, connId);
                tableViewerCreator.getTableViewer().refresh();
            }
        }
    });
    Button moveDown = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    moveDown.setToolTipText(Messages.getString("MergeOrderDialog.MoveDown"));
    moveDown.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
    if (getMergeNode() != null && getMergeNode().isReadOnly()) {
        moveUp.setEnabled(false);
        moveDown.setEnabled(false);
    }
    final int nbConn = getConnectionQty();
    moveDown.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
            if (selection.size() > 0) {
                Connection connection = (Connection) selection.getFirstElement();
                int connId = connectionList.indexOf(connection);
                if (connId < (nbConn - 1)) {
                    Collections.swap(connectionList, connId + 1, connId);
                    tableViewerCreator.getTableViewer().refresh();
                }
            }
        }
    });
    return composite;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 2 with TableViewerCreatorColumn

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

the class OutputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        @Override
        public String get(OutputColumnTableEntry bean) {
            return bean.getExpression();
        }

        @Override
        public void set(OutputColumnTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
            tableViewerCreatorForColumns.getTableViewer().refresh(bean);
        }
    });
    column.setModifiable(true);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.OUTPUTS }, false);
    column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        @Override
        public String get(OutputColumnTableEntry bean) {
            return bean.getMetadataColumn().getLabel();
        }

        @Override
        public void set(OutputColumnTableEntry bean, String value) {
            bean.getMetadataColumn().setLabel(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
}
Also used : OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 3 with TableViewerCreatorColumn

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

the class MetadataTableEditorViewExt method configurePreviewColumns.

/**
     * qzhang Comment method "configurePreviewColumns".
     * 
     * @param tableViewerCreator
     */
private void configurePreviewColumns(TableViewerCreator<IMetadataColumn> tableViewerCreator) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setId(ID_COLUMN_PREVIEW);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("RowGenTableEditor2.Preview.TitleText"));
    column.setBeanPropertyAccessors(getPreviewAccessor());
    column.setModifiable(false);
    column.setWeight(10);
    column.setMinimumWidth(110);
    column.setWidth(120);
}
Also used : TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 4 with TableViewerCreatorColumn

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

the class MetadataTableEditorViewExt method configureFunctionColumns.

/**
     * qzhang Comment method "configureFunctionColumns".
     * 
     * @param tableViewerCreator
     */
private void configureFunctionColumns(TableViewerCreator<IMetadataColumn> tableViewerCreator) {
    //$NON-NLS-1$
    CellEditorValueAdapter comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor("String");
    final TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    final ComboBoxCellEditor functComboBox = new ComboBoxCellEditor();
    functComboBox.create(tableViewerCreator.getTable());
    CCombo functCombo = (CCombo) functComboBox.getControl();
    functCombo.setEditable(false);
    column.setCellEditor(functComboBox, comboValueAdapter);
    // if (functComboBox.getControl() instanceof CCombo) {
    // final CCombo combo = (CCombo) functComboBox.getControl();
    // combo.addSelectionListener(new SelectionAdapter() {
    //
    // /*
    // * (non-Javadoc)
    // *
    // * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
    // */
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // if (getTable() != null) {
    // generatorUI.updateFunParameter(getTable());
    // }
    // }
    // });
    // }
    column.setId(ID_COLUMN_FUNCTION);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("RowGenTableEditor2.Fuctions.TitleText"));
    column.setBeanPropertyAccessors(getFunctionAccessor(functComboBox));
    column.setModifiable(true);
    column.setWeight(10);
    column.setWidth(45);
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 5 with TableViewerCreatorColumn

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

the class ExtractionLoopWithJSONXPathEditorView method createColumns.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.commons.ui.swt.advanced.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
     * .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
     */
@Override
protected void createColumns(TableViewerCreator<JSONXPathLoopDescriptor> tableViewerCreator, final Table table) {
    CellEditorValueAdapter intValueAdapter = new CellEditorValueAdapter() {

        @Override
        public Object getOriginalTypedValue(final CellEditor cellEditor, Object value) {
            try {
                return new Integer(value.toString());
            } catch (Exception ex) {
                return null;
            }
        }

        @Override
        public Object getCellEditorTypedValue(final CellEditor cellEditor, Object value) {
            if (value != null) {
                return String.valueOf(value);
            }
            //$NON-NLS-1$
            return "";
        }
    };
    // //////////////////////////////////////////////////////////////////////////////////////
    // column for mouse selection
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle("");
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    column.setWidth(15);
    // //////////////////////////////////////////////////////////////////////////////////////
    // X Path Query
    column = new TableViewerCreatorColumn(tableViewerCreator);
    xPathColumn = column;
    column.setTitle("Absolute path expression");
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<JSONXPathLoopDescriptor, String>() {

        @Override
        public String get(JSONXPathLoopDescriptor bean) {
            return bean.getAbsoluteXPathQuery();
        }

        @Override
        public void set(JSONXPathLoopDescriptor bean, String value) {
            String currentFlag = ConvertJSONString.getCurrentFlag();
            bean.setAbsoluteXPathQuery(value);
            bean.setFlag(currentFlag);
        }
    });
    xPathCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
    column.setCellEditor(xPathCellEditor);
    xPathCellEditor.addListener(new DialogErrorForCellEditorListener(xPathCellEditor, column) {

        @Override
        public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
            if (state == CELL_EDITOR_STATE.APPLYING) {
            // linker.onXPathValueChanged(table, newValue.toString(), itemIndex);
            }
        }

        @Override
        public String validateValue(String newValue, int beanPosition) {
            return linker.validateXPathExpression(newValue);
        }
    });
    column.setModifiable(true);
    column.setWeight(30);
    column.setMinimumWidth(50);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    // //////////////////////////////////////////////////////////////////////////////////////
    // //////////////////////////////////////////////////////////////////////////////////////
    // Loop limit
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle("Loop limit");
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<JSONXPathLoopDescriptor, Integer>() {

        @Override
        public Integer get(JSONXPathLoopDescriptor bean) {
            return bean.getLimitBoucle();
        }

        @Override
        public void set(JSONXPathLoopDescriptor bean, Integer value) {
            if (value != null) {
                bean.setLimitBoucle(value.intValue());
            } else {
                bean.setLimitBoucle(0);
            }
        }
    });
    column.setModifiable(true);
    column.setWidth(59);
    column.setCellEditor(new TextCellEditor(table), intValueAdapter);
}
Also used : JSONXPathLoopDescriptor(org.talend.repository.model.json.JSONXPathLoopDescriptor) TextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal) CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ConvertJSONString(org.talend.repository.json.util.ConvertJSONString) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Aggregations

TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)38 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)14 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)9 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)8 CCombo (org.eclipse.swt.custom.CCombo)6 Color (org.eclipse.swt.graphics.Color)6 IColumnColorProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)6 TextCellEditorWithProposal (org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal)6 CheckboxTableEditorContent (org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent)6 List (java.util.List)5 ColumnCellModifier (org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)5 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)5 DialogErrorForCellEditorListener (org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener)5 CellEditor (org.eclipse.jface.viewers.CellEditor)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Image (org.eclipse.swt.graphics.Image)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3