Search in sources :

Example 11 with TableViewerCreator

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator 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 12 with TableViewerCreator

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

the class DataMapTableView method addTablesListeners.

/**
     * DOC amaumont Comment method "addTableForColumnsListeners".
     */
private void addTablesListeners() {
    tableViewerCreatorForColumns.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        @Override
        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

        @Override
        public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
    tableViewerForEntries.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int[] selectionIndices = tableViewerForEntries.getTable().getSelectionIndices();
            if (selectionIndices.length > 0) {
                selectThisDataMapTableView();
                onSelectedEntries(event.getSelection(), selectionIndices);
                // bug 18414
                MetadataTableEditorView metadataTableEditorView = null;
                if (getZone() == Zone.INPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getInputMetaEditorView();
                } else if (getZone() == Zone.OUTPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getOutputMetaEditorView();
                }
                if (metadataTableEditorView != null) {
                    metadataTableEditorView.getTableViewerCreator().refresh();
                }
            }
        }
    });
    tableForEntries.addListener(SWT.DragDetect, new Listener() {

        @Override
        public void handleEvent(Event event) {
            onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
        }
    });
    tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (forceExecuteSelectionEvent) {
                forceExecuteSelectionEvent = false;
                onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
            }
        }
    });
    tableForEntries.addListener(SWT.KeyDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForColumns, event);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<IColumnEntry>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<IColumnEntry> event) {
            TableViewerCreator tableViewerCreator = tableViewerCreatorForColumns;
            ITableEntry tableEntry = event.bean;
            parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    if (abstractDataMapTable instanceof OutputTable) {
        OutputTable outputTable = (OutputTable) abstractDataMapTable;
        outputTable.getWhereTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getWhereTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, extendedTableViewerForFilters);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, entendedTableViewerForOtherClauses);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
    }
}
Also used : SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) FocusListener(org.eclipse.swt.events.FocusListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) KeyListener(org.eclipse.swt.events.KeyListener) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 13 with TableViewerCreator

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

the class DataMapTableView method onOutputTableFiltersModified.

protected void onOutputTableFiltersModified(ModifiedBeanEvent<FilterTableEntry> event, AbstractExtendedTableViewer<FilterTableEntry> _extendedTableViewerForFilters) {
    TableViewerCreator tableViewerCreator = _extendedTableViewerForFilters.getTableViewerCreator();
    ITableEntry tableEntry = event.bean;
    parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry)

Example 14 with TableViewerCreator

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

the class OutputDataMapTableView method initTableFilters.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#initTableConstraints()
     */
@Override
protected void initTableFilters(Composite parent) {
    /**
         * create whereFiltersTable
         */
    // createFiltersTable(parent);
    //$NON-NLS-1$
    filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalWhereClauses");
    extendedTableViewerForFilters = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getWhereTableFiltersEntriesModel(), parent) {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
             * getTableConstraintSize()
             */
        @Override
        protected int getTableConstraintSize() {
            int retSize = 0;
            if (abstractDataMapTable instanceof OutputTable) {
                retSize = ((OutputTable) abstractDataMapTable).getWhereFilterEntries().size();
            }
            return retSize;
        }

        @Override
        protected void setTextCellEditor(TextCellEditor textEditor) {
            if (textEditor != null) {
                whereConstraintExpressionTextEditor = (Text) textEditor.getControl();
            }
        }
    };
    // correct partially layout problem with GTK when cell editor value is applied
    ((ExtendedTableViewerForFilters) extendedTableViewerForFilters).createFiltersTable();
    TableViewerCreator tableViewerCreatorForWhereClauses = extendedTableViewerForFilters.getTableViewerCreator();
    tableViewerCreatorForWhereClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
    List<FilterTableEntry> whereEntries = ((OutputTable) getDataMapTable()).getWhereFilterEntries();
    tableViewerCreatorForWhereClauses.init(whereEntries);
    /**
         * create otherFiltersTable
         */
    IComponent component = getMapperManager().getComponent().getComponent();
    if (component != null && "tELTOracleMap".equals(component.getName())) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses.oracle");
    } else {
        //$NON-NLS-1$
        filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses");
    }
    entendedTableViewerForOtherClauses = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getOtherTableFiltersEntriesModel(), parent) {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
             * getTableConstraintSize()
             */
        @Override
        public int getTableConstraintSize() {
            int retSize = 0;
            if (abstractDataMapTable instanceof OutputTable) {
                retSize = ((OutputTable) abstractDataMapTable).getOtherFilterEntries().size();
            }
            return retSize;
        }

        @Override
        protected void setTextCellEditor(TextCellEditor textEditor) {
            if (textEditor != null) {
                otherConstraintExpressionTextEditor = (Text) textEditor.getControl();
            }
        }
    };
    ((ExtendedTableViewerForFilters) entendedTableViewerForOtherClauses).createFiltersTable();
    TableViewerCreator tableViewerCreatorForOtherClauses = entendedTableViewerForOtherClauses.getTableViewerCreator();
    tableViewerCreatorForOtherClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
    List<FilterTableEntry> otherEntries = ((OutputTable) getDataMapTable()).getOtherFilterEntries();
    tableViewerCreatorForOtherClauses.init(otherEntries);
    // updateGridDataHeightForTableConstraints(entendedTableViewerForOtherClauses.getTable());
    updateGridDataHeightForTableConstraints();
    if (WindowSystem.isGTK()) {
        tableViewerCreatorForWhereClauses.layout();
        entendedTableViewerForOtherClauses.getTableViewerCreator().layout();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) IComponent(org.talend.core.model.components.IComponent) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 15 with TableViewerCreator

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

the class MapperManager method retrieveTableViewerCreator.

public TableViewerCreator retrieveTableViewerCreator(ITableEntry dataMapTableEntry) {
    DataMapTableView view = retrieveDataMapTableView(dataMapTableEntry);
    TableViewerCreator tableViewerCreator = null;
    if (view != null) {
        if (dataMapTableEntry instanceof AbstractInOutTableEntry || dataMapTableEntry instanceof VarTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForColumns();
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForFilters();
        }
    }
    return tableViewerCreator;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Aggregations

TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)36 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Point (org.eclipse.swt.graphics.Point)14 TableViewerCreatorColumnNotModifiable (org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)11 HashMap (java.util.HashMap)10 Map (java.util.Map)10 CCombo (org.eclipse.swt.custom.CCombo)8 IElementParameter (org.talend.core.model.process.IElementParameter)8 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)8 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)6 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)6 TableViewer (org.eclipse.jface.viewers.TableViewer)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 ILineSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)4 LineSelectionEvent (org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)4 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)4