Search in sources :

Example 6 with MetadataTableEditorView

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

the class UIManager method refreshInOutTableAndMetaTable.

/**
     * DOC amaumont Comment method "refreshInOutTableAndMetaTable".
     * 
     * @param currentModifiedTableEntry can be null
     */
private void refreshInOutTableAndMetaTable(AbstractInOutTableEntry currentModifiedTableEntry) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedTableEntry);
    IMetadataTable metadataTableTarget = ((AbstractInOutTable) dataMapTableView.getDataMapTable()).getMetadataTable();
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedTableEntry);
    MetadataTableEditorView metadataEditorView = getMetadataEditorView(dataMapTableView.getZone());
    if (metadataEditorView != null && metadataEditorView.getMetadataTableEditor() != null && metadataEditorView.getMetadataTableEditor().getMetadataTable() == metadataTableTarget) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh(currentModifiedTableEntry.getMetadataColumn());
        metadataEditorView.getTableViewerCreator().refreshTableEditorControls();
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) 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) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 7 with MetadataTableEditorView

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

the class MapperManager method onEntitySelection.

private void onEntitySelection(IStructuredSelection selection, AbstractInOutTree selectedTree) {
    // do selection in metadata schema editor
    EList<? extends TreeNode> nodes = null;
    if (selectedTree instanceof InputXmlTree) {
        nodes = ((InputXmlTree) selectedTree).getNodes();
    } else {
        nodes = ((OutputXmlTree) selectedTree).getNodes();
    }
    List<Integer> selectionIndices = new ArrayList<Integer>();
    List<TreeNode> selectedDocChild = new ArrayList<TreeNode>();
    Iterator iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof TreeNodeEditPart) {
            TreeNode model = (TreeNode) ((TreeNodeEditPart) obj).getModel();
            if (model.eContainer() == selectedTree) {
                selectionIndices.add(nodes.indexOf(model));
            } else {
                AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(model);
                if (abstractInOutTree == selectedTree) {
                    selectedDocChild.add(model);
                }
            }
        }
    }
    int[] selections = new int[selectionIndices.size()];
    for (int i = 0; i < selectionIndices.size(); i++) {
        selections[i] = selectionIndices.get(i);
    }
    MetadataTableEditorView metaEditorView = null;
    XmlTreeSchemaTableView treeEditorView = null;
    if (selectedTree instanceof InputXmlTree) {
        metaEditorView = mapperUI.getTabFolderEditors().getInputMetaEditorView();
        treeEditorView = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
    } else {
        metaEditorView = mapperUI.getTabFolderEditors().getOutputMetaEditorView();
        treeEditorView = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
    }
    metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
    metaEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
    metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
    metaEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    // if no, change page
    if (!selectedDocChild.isEmpty()) {
        treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        TreeNode firstSelection = null;
        if (selectedDocChild.size() > 1) {
            selectionIndices = new ArrayList<Integer>();
            List<TreeNode> allList = new ArrayList<TreeNode>();
            for (TreeNode schemaNodes : nodes) {
                if (XmlMapUtil.DOCUMENT.equals(schemaNodes.getType())) {
                    allList.addAll(SchemaTableUtils.getTreeSchemaEnties(schemaNodes));
                }
            }
            int minIndex = allList.size();
            for (TreeNode selected : selectedDocChild) {
                int indexOf = allList.indexOf(selected);
                if (indexOf != -1 && indexOf < minIndex) {
                    firstSelection = selected;
                }
            }
        } else {
            firstSelection = selectedDocChild.get(0);
        }
        treeEditorView.getExtendedTableModel().changePageIfNeeded(firstSelection);
        // update selection
        selectionIndices = new ArrayList<Integer>();
        for (TreeNode selected : selectedDocChild) {
            int indexOf = treeEditorView.getExtendedTableModel().getBeansList().indexOf(selected);
            if (indexOf != -1) {
                selectionIndices.add(indexOf);
            }
        }
        selections = new int[selectionIndices.size()];
        for (int i = 0; i < selectionIndices.size(); i++) {
            selections[i] = selectionIndices.get(i);
        }
        treeEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
        treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        treeEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) XmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Iterator(java.util.Iterator) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 8 with MetadataTableEditorView

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

the class MapperManager method isTableOfOutputMetadataEditor.

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

Example 9 with MetadataTableEditorView

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

the class UIManager method selectLinkedMetadataEditorEntries.

/**
     * DOC amaumont Comment method "selectTableEntries".
     * 
     * @param view
     * @param selectedTableEntries
     * @param selectionIndices
     */
public void selectLinkedMetadataEditorEntries(DataMapTableView view, int[] selectionIndices) {
    MetadataTableEditorView metadataTableEditorView = null;
    MetadataTableEditorView otherMetadataTableEditorView = null;
    if (view.getZone() == Zone.INPUTS) {
        metadataTableEditorView = getInputMetaEditorView();
        otherMetadataTableEditorView = getOutputMetaEditorView();
    } else if (view.getZone() == Zone.OUTPUTS) {
        metadataTableEditorView = getOutputMetaEditorView();
        otherMetadataTableEditorView = getInputMetaEditorView();
    }
    if (metadataTableEditorView != null) {
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        metadataTableEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selectionIndices);
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
    if (otherMetadataTableEditorView != null) {
        otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 10 with MetadataTableEditorView

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

the class CompleteDropTargetTableListener 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(draggableTargetControl, cursorPosition);
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    DataMapTableView dataMapTableViewTarget = getMapperManager().retrieveDataMapTableView(draggableTargetControl);
    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();
    draggableTargetControl.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 targetTableIsGlobalMapTable = analyzer.targetTableIsGlobalMapTable();
    boolean atLeastOneEntryInserted = false;
    boolean insertionEntryMode = analyzer.isInsertionEntryMode();
    boolean mapEachSourceToNextTargets = analyzer.isMapOneToOneMode();
    TableViewerCreator tableViewerCreatorTarget = null;
    if (!analyzer.targetIsExpressionFilterText()) {
        if (targetTableIsFiltersTable) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForFilters();
        } else if (targetTableIsGlobalMapTable) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForGlobalMap();
        } else {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForColumns();
        }
    }
    uiManager.applyActivatedCellEditors(tableViewerCreatorTarget);
    // 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) {
            // set the default operator.
            if (currentEntryTarget instanceof InputColumnTableEntry) {
                ((InputColumnTableEntry) currentEntryTarget).setOperator(Operator.EQUALS.getLiteral());
            }
            boolean overwrite = (lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
            modifyExistingExpression(currentLanguage, currentEntryTarget, tableEntrySource, overwrite, zoneSourceEntry);
            uiManager.parseExpression(currentEntryTarget.getExpression(), currentEntryTarget, false, true, true);
            int indexOfEntry = tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
            columnIndicesToSelect.add(indexOfEntry);
        } 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.VARS || zoneSourceEntry == Zone.VARS && zoneTarget == Zone.VARS) {
                columnIndicesToSelect.add(currentIndex);
                currentIndex = insertNewVarEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.VARS && zoneTarget == Zone.OUTPUTS) {
                insertNewOutputEntryFromVarEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.INPUTS && targetTableIsGlobalMapTable) {
                insertNewGlobalMapEntryFromInputEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.INPUTS && zoneTarget != Zone.VARS) {
                insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
            // nothing
            } 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);
        }
    }
    if (zoneTarget == Zone.VARS) {
        dataMapTableViewTarget.resizeAtExpandedSize();
    }
    if (targetTableIsGlobalMapTable) {
        dataMapTableViewTarget.updateGridDataHeightForTableGlobalMap();
        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);
    tableViewerCreatorTarget.getTable().deselectAll();
    uiManager.unselectAllOutputMetaDataEntries();
    uiManager.unselectAllInputMetaDataEntries();
    uiManager.parseAllExpressionsForAllTables();
    getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    getMapperManager().getProblemsManager().checkLookupExpressionProblem();
    uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, true, false);
    dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
    tableViewerCreatorTarget.getTable().setFocus();
    uiManager.setDragging(false);
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.mapper.managers.UIManager) TableEntryLocation(org.talend.designer.mapper.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.mapper.ui.visualmap.zone.Zone) DataMapTableView(org.talend.designer.mapper.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) ILanguage(org.talend.designer.mapper.language.ILanguage) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

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