Search in sources :

Example 1 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView 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 2 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class TabFolderEditors method createMetadataEditorTab.

/**
     * DOC amaumont Comment method "createMetadataEditor".
     */
private void createMetadataEditorTab() {
    CTabItem item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.schemaEditor"));
    SashForm inOutMetaEditorContainer = new SashForm(tabFolderEditors, SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
    item.setControl(inOutMetaEditorContainer);
    CommandStack commandStack = mapperManager.getCommandStack();
    inputMetaEditor = new MetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
    inputMetaEditor.setCurrentDbms(dbmsId);
    inputMetaEditor.setShowDbTypeColumn(true, false, true);
    inputMetaEditor.setShowDbColumnName(true, false);
    inputMetaEditor.setShowPatternColumn(false);
    inputMetaEditor.setShowTalendTypeColumn(false);
    inputMetaEditor.initGraphicComponents();
    inputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
    outputMetaEditor = new MetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
    outputMetaEditor.setCurrentDbms(dbmsId);
    outputMetaEditor.setShowDbTypeColumn(true, false, true);
    outputMetaEditor.setShowDbColumnName(true, false);
    outputMetaEditor.setShowTalendTypeColumn(false);
    outputMetaEditor.setShowPatternColumn(false);
    outputMetaEditor.initGraphicComponents();
    outputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) CommandStack(org.eclipse.gef.commands.CommandStack) RowLayout(org.eclipse.swt.layout.RowLayout) CTabItem(org.eclipse.swt.custom.CTabItem) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 3 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class MapperManager method isTableOfInputMetadataEditor.

/**
     * DOC amaumont Comment method "isTableOfInputMetadataEditor".
     * 
     * @param table
     * @return
     */
public boolean isTableOfInputMetadataEditor(Table table) {
    MetadataTableEditorView inputEditorView = uiManager.getInputMetaEditorView();
    Table tableEditorView = inputEditorView.getTable();
    return tableEditorView == table;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) Table(org.eclipse.swt.widgets.Table) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 4 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class CompleteDropTargetListener method drop.

// private void showInfos(DropTargetEvent event) {
// System.out.println(event);
// System.out.println("event.feedback=" + event.feedback);
// System.out.println("event.detail=" + event.detail);
// System.out.println("event.operations=" + event.operations);
//
// System.out.println("DND.DROP_DEFAULT=" + DND.DROP_DEFAULT);
// System.out.println("DND.DROP_COPY=" + DND.DROP_COPY);
// System.out.println("DND.DROP_MOVE=" + DND.DROP_MOVE);
// System.out.println("DND.DROP_LINK=" + DND.DROP_LINK);
// System.out.println("DND.DROP_TARGET_MOVE=" + DND.DROP_TARGET_MOVE);
// }
//
@Override
public void drop(DropTargetEvent event) {
    super.drop(event);
    retrieveInsertionIndicator().setVisible(false);
    UIManager uiManager = getUiManager();
    DraggedData draggedData = TableEntriesTransfer.getInstance().getDraggedData();
    DropContextAnalyzer analyzer = analyzeDropTarget(event, draggedData);
    // System.out.println("\n>>drop");
    // System.out.println(event);
    Point cursorPosition = new Point(event.x, event.y);
    // int startInsertAtThisIndex = getItemIndexWhereInsertFromPosition(cursorPosition);
    int startInsertAtThisIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTable, cursorPosition);
    IDbLanguage currentLanguage = getMapperManager().getCurrentLanguage();
    DataMapTableView dataMapTableViewTarget = getMapperManager().retrieveDataMapTableView(draggableTable);
    Zone zoneTarget = dataMapTableViewTarget.getZone();
    uiManager.selectDataMapTableView(dataMapTableViewTarget, true, false);
    MetadataTableEditorView metadataEditorView = getUiManager().getMetadataEditorView(dataMapTableViewTarget.getZone());
    List<TransferableEntry> transferableEntryList = draggedData.getTransferableEntryList();
    int currentIndex = startInsertAtThisIndex;
    uiManager.clearLastCreatedInOutColumnEntries();
    draggableTable.deselectAll();
    ITableEntry currentEntryTarget = getEntryFromPosition(cursorPosition);
    ArrayList<String> columnsBeingAdded = new ArrayList<String>();
    ArrayList<Integer> columnIndicesToSelect = new ArrayList<Integer>();
    ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded = new ArrayList<ITableEntry>();
    ArrayList<IMetadataColumn> metadataColumnsBeingAdded = new ArrayList<IMetadataColumn>();
    boolean targetTableIsFiltersTable = analyzer.targetTableIsFiltersTable();
    boolean atLeastOneEntryInserted = false;
    boolean insertionEntryMode = analyzer.isInsertionEntryMode();
    boolean mapEachSourceToNextTargets = analyzer.isMapOneToOneMode();
    TableViewerCreator tableViewerCreatorTarget = null;
    if (targetTableIsFiltersTable) {
        if (analyzer.targetTableIsWhereFiltersTable()) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForWhereFilters();
        } else {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForOtherFilters();
        }
    } else {
        tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForColumns();
    }
    // MapperDropCommand dropCommand = new MapperDropCommand();
    // MetadataEditorEvent metadataEditorEvent = new MetadataEditorEvent(MetadataEditorEvent.TYPE.ADD);
    ITableEntry lastEntryTarget = null;
    for (TransferableEntry transferableEntry : transferableEntryList) {
        ITableEntry tableEntrySource = transferableEntry.getTableEntrySource();
        IMetadataColumn metadataColumnDragged = transferableEntry.getMetadataColumn();
        Zone zoneSourceEntry = (Zone) transferableEntry.getZoneSourceEntry();
        TableEntryLocation tableEntryLocationTarget = new TableEntryLocation(dataMapTableViewTarget.getDataMapTable().getName(), tableEntrySource.getName());
        if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.INPUTS && tableEntrySource.getParentName().equals(tableEntryLocationTarget.tableName)) {
            continue;
        } else if (currentEntryTarget != null && !insertionEntryMode) {
            modifyExistingEntry(uiManager, analyzer, currentLanguage, currentEntryTarget, columnIndicesToSelect, tableViewerCreatorTarget, lastEntryTarget, tableEntrySource, zoneSourceEntry);
        } else {
            String columnName = transferableEntry.getTableEntrySource().getName();
            tableEntryLocationTarget = getMapperManager().findUniqueLocation(tableEntryLocationTarget, dataMapTableViewTarget.getDataMapTable());
            columnName = tableEntryLocationTarget.columnName;
            if (currentEntryTarget == null && analyzer.isMapOneToOneMode()) {
                currentIndex = tableViewerCreatorTarget.getInputList().size();
                columnIndicesToSelect.add(currentIndex);
            }
            if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.OUTPUTS) {
                insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
                insertOutpuEntryCopyToOtherOutput(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else {
            // throw new IllegalStateException("Drop case not found !");
            }
            columnsBeingAdded.add(columnName);
        }
        lastEntryTarget = currentEntryTarget;
        if (mapEachSourceToNextTargets && currentEntryTarget != null) {
            currentEntryTarget = getNextEntryTarget(currentEntryTarget, tableViewerCreatorTarget);
        }
    }
    if (!atLeastOneEntryInserted) {
        tableViewerCreatorTarget.getTableViewer().refresh();
    } else {
        updateExpressionsOfInsertedEntries(currentLanguage, metadataEditorView, currentIndex, sourceEntriesOfEntriesBeingAdded, targetTableIsFiltersTable, tableViewerCreatorTarget, // , metadataEditorEvent
        metadataColumnsBeingAdded);
        for (int i = currentIndex; i < currentIndex + sourceEntriesOfEntriesBeingAdded.size(); i++) {
            columnIndicesToSelect.add(i);
        }
    }
    dataMapTableViewTarget.resizeAtExpandedSize();
    uiManager.unselectAllEntriesOfAllTables();
    uiManager.refreshBackground(true, false);
    if (metadataEditorView != null && !targetTableIsFiltersTable) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh();
    }
    int[] selection = ArrayUtils.toPrimitive(columnIndicesToSelect.toArray(new Integer[0]));
    tableViewerCreatorTarget.getSelectionHelper().setSelection(selection);
    ISelection iselection = tableViewerCreatorTarget.getTableViewer().getSelection();
    List<ITableEntry> selectedEntries = uiManager.extractSelectedTableEntries(iselection);
    uiManager.unselectAllOutputMetaDataEntries();
    uiManager.unselectAllInputMetaDataEntries();
    uiManager.parseAllExpressionsForAllTables();
    getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    getUiManager().refreshSqlExpression();
    uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, targetTableIsFiltersTable, true);
    tableViewerCreatorTarget.getTable().setFocus();
    uiManager.setDragging(false);
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IDbLanguage(org.talend.designer.dbmap.language.IDbLanguage) ArrayList(java.util.ArrayList) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.dbmap.managers.UIManager) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) ISelection(org.eclipse.jface.viewers.ISelection) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) TransferableEntry(org.talend.designer.abstractmap.ui.dnd.TransferableEntry) Zone(org.talend.designer.dbmap.ui.visualmap.zone.Zone) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) DraggedData(org.talend.designer.abstractmap.ui.dnd.DraggedData) Point(org.eclipse.swt.graphics.Point) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Point(org.eclipse.swt.graphics.Point)

Example 5 with MetadataTableEditorView

use of org.talend.core.ui.metadata.editor.MetadataTableEditorView in project tdi-studio-se by Talend.

the class UIManager method selectDataMapTableView.

/**
     * Select a table view.
     * 
     * @param dataMapTableView
     * @param useNewCommand
     * @param selectAllEntries TODO
     */
public void selectDataMapTableView(final DataMapTableView dataMapTableView, boolean useNewCommand, boolean selectAllEntries) {
    // reject table readonly
    IDataMapTable dataMapTable = dataMapTableView.getDataMapTable();
    if (dataMapTable instanceof OutputTable && ((OutputTable) dataMapTable).isErrorRejectTable()) {
        OutputTable table = (OutputTable) dataMapTable;
        if (table.getMetadataTable() != null) {
            for (IMetadataColumn column : table.getMetadataTable().getListColumns()) {
                if (mapperManager.ERROR_REJECT_MESSAGE.equals(column.getLabel()) || mapperManager.ERROR_REJECT_STACK_TRACE.equals(column.getLabel())) {
                    column.setCustom(true);
                }
            }
        }
        CustomTableManager.addCustomManagementToTable(getOutputMetaEditorView(), true);
    }
    TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
    // tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
    MetadataTableEditorView metadataTableEditorView = null;
    MetadataTableEditorView otherMetadataTableEditorView = null;
    final Zone currentZone = dataMapTableView.getZone();
    List<? extends AbstractDataMapTable> tables = null;
    DataMapTableView previousSelectedTableView = null;
    if (currentZone == Zone.INPUTS) {
        metadataTableEditorView = tabFolderEditors.getInputMetaEditorView();
        otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditorView();
        tables = mapperManager.getInputTables();
        previousSelectedTableView = this.currentSelectedInputTableView;
        this.currentSelectedInputTableView = (InputDataMapTableView) dataMapTableView;
        metadataTableEditorView.setReadOnly(this.currentSelectedInputTableView.getInputTable().hasReadOnlyMetadataColumns() || mapperManager.componentIsReadOnly() || this.currentSelectedInputTableView.getInputTable().isReadOnly());
    } else if (currentZone == Zone.OUTPUTS) {
        metadataTableEditorView = tabFolderEditors.getOutputMetaEditorView();
        otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditorView();
        tables = mapperManager.getOutputTables();
        previousSelectedTableView = this.currentSelectedOutputTableView;
        this.currentSelectedOutputTableView = (OutputDataMapTableView) dataMapTableView;
        metadataTableEditorView.setReadOnly(this.currentSelectedOutputTableView.getOutputTable().hasReadOnlyMetadataColumns() || mapperManager.componentIsReadOnly());
    } else {
        this.currentSelectedVarsTableView = (VarsDataMapTableView) dataMapTableView;
    }
    if (currentZone != Zone.VARS) {
        updateToolbarButtonsStates(currentZone);
        final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveAbstractDataMapTable(dataMapTableView);
        MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
        final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
        final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
        if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && oldSelectedView != dataMapTableView) {
            oldSelectedView = dataMapTableView;
            if (useNewCommand) {
                DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
                mapperManager.executeCommand(command);
            }
            currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getName());
            currentMetadataTableEditor.setModifiedBeanListenable(metadataTableEditorView.getTableViewerCreator());
            final MetadataTableEditorView metadataTableEditorViewFinal = metadataTableEditorView;
            final TableViewerCreator metadataTVCreator = metadataTableEditorViewFinal.getTableViewerCreator();
            final MetadataTableEditor metadataTableEditor = currentMetadataTableEditor;
            modifySelectionChangedListener(currentZone, metadataTableEditorViewFinal, metadataTVCreator, metadataTableEditor, dataMapTableView, previousSelectedTableView);
            // init actions listeners for list which contains metadata
            metadataTableEditor.addAfterOperationListListener(new IListenableListListener() {

                /**
                     * DOC acer Comment method "handleEvent".
                     * 
                     * @param event
                     */
                public void handleEvent(ListenableListEvent event) {
                    DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(abstractDataMapTable);
                    List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
                    if (event.type == TYPE.ADDED) {
                        // metadataEditorTableViewer.refresh();
                        List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.addedObjects;
                        lastCreatedInOutColumnEntries.clear();
                        if (event.index != null) {
                            int index = event.index;
                            for (IMetadataColumn metadataColumn : metadataColumns) {
                                lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, index));
                                // handle related table view
                                for (DataMapTableView tableView : relatedOutputsTableView) {
                                    // changed for bug TDI-26551 in July 2,2013 by fwang, should use original
                                    // expression for related table.
                                    IMetadataColumn relatedMetadata = metadataColumn;
                                    if (!oldMappingMap.isEmpty()) {
                                        IDataMapTable retrieveAbstractDataMapTable = mapperManager.retrieveAbstractDataMapTable(tableView);
                                        relatedMetadata = metadataColumn.clone();
                                        String label = relatedMetadata.getLabel();
                                        String expression = oldMappingMap.get(retrieveAbstractDataMapTable.getName() + "_" + label);
                                        relatedMetadata.setExpression(expression == null ? "" : expression);
                                    }
                                    mapperManager.addNewColumnEntry(tableView, relatedMetadata, index);
                                }
                                index = index + 1;
                            }
                        } else if (event.indicesTarget != null) {
                            List<Integer> indicesTarget = event.indicesTarget;
                            int lstSize = indicesTarget.size();
                            for (int i = 0; i < lstSize; i++) {
                                Integer indice = indicesTarget.get(i);
                                IMetadataColumn metadataColumn = metadataColumns.get(i);
                                lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, indice));
                                // handle related table view
                                for (DataMapTableView tableView : relatedOutputsTableView) {
                                    mapperManager.addNewColumnEntry(tableView, metadataColumn, indice);
                                }
                            }
                        } else {
                            //$NON-NLS-1$
                            throw new IllegalStateException(Messages.getString("UIManager.1"));
                        }
                        refreshBackground(false, false);
                        if (event.index != null) {
                            dataMapTableViewer.refresh();
                            dataMapTVCreator.getSelectionHelper().setSelection(event.index);
                            if (dataMapTableView.canBeResizedAtPreferedSize()) {
                                dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
                            }
                            // resize ralated table
                            for (DataMapTableView tableView : relatedOutputsTableView) {
                                if (tableView.canBeResizedAtPreferedSize()) {
                                    tableView.changeSize(tableView.getPreferredSize(true, false, false), true, true);
                                }
                            }
                        } else if (event.indicesTarget != null) {
                            dataMapTableViewer.refresh();
                            dataMapTableView.changeSize(view.getPreferredSize(false, true, false), true, true);
                            int[] selection = ArrayUtils.toPrimitive((Integer[]) event.indicesTarget.toArray(new Integer[0]));
                            dataMapTVCreator.getSelectionHelper().setSelection(selection);
                            for (DataMapTableView tableView : relatedOutputsTableView) {
                                tableView.changeSize(tableView.getPreferredSize(false, true, false), true, true);
                            }
                        }
                    }
                    if (event.type == TYPE.REMOVED) {
                        // metadataEditorTableViewer.refresh();
                        List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.removedObjects;
                        for (IMetadataColumn metadataColumn : metadataColumns) {
                            ITableEntry metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(abstractDataMapTable.getName(), metadataColumn.getLabel()));
                            mapperManager.removeTableEntry(metadataTableEntry);
                            for (DataMapTableView tableView : relatedOutputsTableView) {
                                IDataMapTable retrieveAbstractDataMapTable = mapperManager.retrieveAbstractDataMapTable(tableView);
                                metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(retrieveAbstractDataMapTable.getName(), metadataColumn.getLabel()));
                                mapperManager.removeTableEntry(metadataTableEntry);
                                if (tableView.canBeResizedAtPreferedSize()) {
                                    tableView.resizeAtExpandedSize();
                                }
                            }
                        }
                        dataMapTableViewer.refresh();
                        if (dataMapTableView.canBeResizedAtPreferedSize()) {
                            dataMapTableView.resizeAtExpandedSize();
                        }
                        resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
                        moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
                        refreshBackground(true, false);
                    }
                    if (event.type == TYPE.SWAPED) {
                        List<Integer> listIndexTarget = event.indicesTarget;
                        abstractDataMapTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
                        // handle related table view
                        for (DataMapTableView tableView : relatedOutputsTableView) {
                            AbstractDataMapTable relatedTable = (AbstractDataMapTable) tableView.getDataMapTable();
                            relatedTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
                        }
                        // dataMapTableViewer.refresh();
                        refreshBackground(true, false);
                    }
                }
            });
            metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
            metadataTableEditorView.setMetadataTableEditor(metadataTableEditor);
            metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
            metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
            dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(false);
            metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setSelection(dataMapTableViewer.getTable().getSelectionIndices());
            dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(true);
            // disable highlight for other DataMapTableView and highlight selected DataMapTableView
            for (IDataMapTable table : tables) {
                DataMapTableView otherDataMapTableView = mapperManager.retrieveAbstractDataMapTableView(table);
                otherDataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
            }
            dataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
        }
        if (selectAllEntries) {
            dataMapTVCreator.getTable().selectAll();
            selectAllLinks(dataMapTableView);
            if (currentZone != Zone.VARS) {
                metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
                metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
            }
            if (currentZone == Zone.OUTPUTS) {
                dataMapTableView.getTableViewerCreatorForFilters().getTable().selectAll();
            }
        }
        boolean isMainSchemaRepository = false;
        if (abstractDataMapTable instanceof OutputTable) {
            OutputTable outputTable = (OutputTable) abstractDataMapTable;
            if (outputTable.getIsJoinTableOf() != null || !"".equals(outputTable.getIsJoinTableOf())) {
                final OutputTable outputTableByName = mapperManager.getOutputTableByName(outputTable.getIsJoinTableOf());
                if (outputTableByName != null && outputTableByName.getId() != null) {
                    isMainSchemaRepository = true;
                }
            }
        }
        dataMapTableView.enableDiaplayViewer(abstractDataMapTable.isRepository() || isMainSchemaRepository);
    }
    if (selectAllEntries && currentZone == Zone.VARS) {
        selectAllLinks(dataMapTableView);
        mapperManager.getUiManager().getVarsTablesView().get(0).getTableViewerCreatorForColumns().getTable().selectAll();
    }
    if (otherMetadataTableEditorView != null) {
        otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : TabFolderEditors(org.talend.designer.mapper.ui.tabs.TabFolderEditors) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) AbstractDataMapTable(org.talend.designer.mapper.model.table.AbstractDataMapTable) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) ArrayList(java.util.ArrayList) List(java.util.List) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) InputsZone(org.talend.designer.mapper.ui.visualmap.zone.InputsZone) ToolbarOutputZone(org.talend.designer.mapper.ui.visualmap.zone.toolbar.ToolbarOutputZone) ToolbarZone(org.talend.designer.mapper.ui.visualmap.zone.toolbar.ToolbarZone) OutputsZone(org.talend.designer.mapper.ui.visualmap.zone.OutputsZone) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) Point(org.eclipse.swt.graphics.Point) DataMapTableViewSelectedCommand(org.talend.designer.mapper.ui.commands.DataMapTableViewSelectedCommand) TableViewer(org.eclipse.jface.viewers.TableViewer) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)

Aggregations

MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)25 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)12 ArrayList (java.util.ArrayList)7 Point (org.eclipse.swt.graphics.Point)7 Table (org.eclipse.swt.widgets.Table)6 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)6 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)6 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 IListenableListListener (org.talend.commons.utils.data.list.IListenableListListener)5 ListenableListEvent (org.talend.commons.utils.data.list.ListenableListEvent)5 MetadataTableEditor (org.talend.core.ui.metadata.editor.MetadataTableEditor)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)5 List (java.util.List)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4 MetadataTable (org.talend.core.model.metadata.MetadataTable)4 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)4