Search in sources :

Example 46 with ITableEntry

use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.

the class SearchZoneMapper method hightlightAll.

public void hightlightAll(Map<Integer, Map<Integer, ITableEntry>> searchMaps, boolean isHightlight) {
    Iterator iter = searchMaps.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
        Map<Integer, ITableEntry> map = (Map<Integer, ITableEntry>) entry.getValue();
        Iterator it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            if (isHightlight) {
                setEntryState(mapperManager, EntryState.HIGHLIGHTALL, (ITableEntry) e.getValue());
            } else {
                setEntryState(mapperManager, EntryState.NONE, (ITableEntry) e.getValue());
            }
        }
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 47 with ITableEntry

use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.

the class SearchZoneMapper method getSelectedKeyAtSelectedTableItem.

public Integer getSelectedKeyAtSelectedTableItem(Map<Integer, Map<Integer, ITableEntry>> searchMaps) {
    Integer selectKey = 0;
    TableViewerCreator tableViewerCreator = null;
    if (uiManager.getCurrentSelectedInputTableView() != null) {
        tableViewerCreator = uiManager.getCurrentSelectedInputTableView().getTableViewerCreatorForColumns();
        if (tableViewerCreator != null && tableViewerCreator.getTableViewer() != null) {
            ISelection selection = tableViewerCreator.getTableViewer().getSelection();
            if (selection == null || selection.isEmpty()) {
                if (uiManager.getCurrentSelectedOutputTableView() != null) {
                    tableViewerCreator = uiManager.getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
                }
            }
        }
    } else if (uiManager.getCurrentSelectedOutputTableView() != null) {
        tableViewerCreator = uiManager.getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
    }
    if (tableViewerCreator != null && tableViewerCreator.getTableViewer() != null) {
        ISelection selection = tableViewerCreator.getTableViewer().getSelection();
        if (selection != null && !selection.isEmpty()) {
            List<ITableEntry> list = uiManager.extractSelectedTableEntries(selection);
            if (list != null && !list.isEmpty()) {
                ITableEntry tableEntry = list.get(0);
                if (tableEntry != null) {
                    Iterator iter = searchMaps.entrySet().iterator();
                    while (iter.hasNext()) {
                        Map.Entry entry = (Map.Entry) iter.next();
                        Map<Integer, ITableEntry> map = (Map<Integer, ITableEntry>) entry.getValue();
                        if (map.containsValue(tableEntry)) {
                            Iterator it = map.entrySet().iterator();
                            while (it.hasNext()) {
                                Map.Entry e = (Map.Entry) it.next();
                                if (e.getValue() != null && e.getValue() instanceof ITableEntry) {
                                    ITableEntry tableEntryTemp = (ITableEntry) e.getValue();
                                    if (tableEntry.equals(tableEntryTemp)) {
                                        tableViewerCreator.getTableViewer().getTable().deselectAll();
                                        return (Integer) entry.getKey();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return selectKey;
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 48 with ITableEntry

use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.

the class UIManager method parseFilterColumn.

public ParseExpressionResult parseFilterColumn(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
    if (currentModifiedITableEntry instanceof InputColumnTableEntry) {
        InputColumnTableEntry entry = (InputColumnTableEntry) currentModifiedITableEntry;
        if (StringUtils.trimToNull(expression) == null) {
            entry.setOperator(null);
        }
    }
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
    boolean linkHasBeenAdded = false;
    boolean linkHasBeenRemoved = false;
    DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
    TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
    Set<TableEntryLocation> alreadyProcessed = new HashSet<TableEntryLocation>();
    Set<ITableEntry> sourcesForTarget = mapperManager.getSourcesForTarget(currentModifiedITableEntry);
    Set<ITableEntry> sourcesForTargetToDelete = new HashSet<ITableEntry>(sourcesForTarget);
    boolean isInputEntry = currentModifiedITableEntry instanceof InputColumnTableEntry;
    ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
    for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
        TableEntryLocation location = tableEntriesLocationsSource;
        // tests to know if link must be removed if key is unchecked
        boolean dontRemoveLink = (!isInputEntry || isInputEntry && (inputExpressionAppliedOrCanceled || !inputExpressionAppliedOrCanceled && !mapperManager.checkEntryHasInvalidUncheckedKey((InputColumnTableEntry) currentModifiedITableEntry)));
        if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry) && (mapperManager.isAdvancedMap() || !mapperManager.isAdvancedMap() && dontRemoveLink)) {
            ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
            if (sourceTableEntry != null && sourcesForTarget.contains(sourceTableEntry)) {
                Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
                Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
                for (IMapperLink link : linksFromTarget) {
                    link.calculate();
                }
            }
        }
    }
    mapperManager.orderLinks();
    if (!mapperManager.isAdvancedMap()) {
        if (dataMapTableView.getZone() == Zone.INPUTS) {
            if (linkHasBeenAdded || linkHasBeenRemoved) {
                checkTargetInputKey(currentModifiedITableEntry, checkInputKeyAutomatically, inputExpressionAppliedOrCanceled);
            }
            if (inputExpressionAppliedOrCanceled) {
                openChangeKeysDialog((InputDataMapTableView) dataMapTableView);
            }
        }
    }
    return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) 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) ParseExpressionResult(org.talend.designer.mapper.utils.ParseExpressionResult) DataMapExpressionParser(org.talend.designer.mapper.utils.DataMapExpressionParser) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) HashSet(java.util.HashSet) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 49 with ITableEntry

use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.

the class UIManager method selectLinkedTableEntries.

/**
     * DOC amaumont Comment method "selectTableEntries".
     * 
     * @param metadataTable
     * @param selectedTableEntries
     * @param selectionIndices
     */
public void selectLinkedTableEntries(IMetadataTable metadataTable, int[] selectionIndices) {
    DataMapTableView dataMapTableView = tableManager.getView(metadataTable);
    if (dataMapTableView == null) {
        return;
    }
    dataMapTableView.setTableSelection(selectionIndices);
    List<ITableEntry> list = extractSelectedTableEntries(dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().getSelection());
    selectLinks(dataMapTableView, list, false, false);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) 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)

Example 50 with ITableEntry

use of org.talend.designer.abstractmap.model.tableentry.ITableEntry 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();
    }
    TableViewerCreator tableViewerCreatorForColumns = view.getTableViewerCreatorForColumns();
    if (tableViewerCreatorForColumns != null) {
        final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
        if (tableViewerForEntries.getSelection() != null) {
            List<ITableEntry> extractSelectedTableEntries = extractSelectedTableEntries(tableViewerForEntries.getSelection());
            for (ITableEntry entry : extractSelectedTableEntries) {
                if (entry instanceof OutputColumnTableEntry) {
                    if (((OutputColumnTableEntry) entry).getMetadataColumn().isCustom() && view.getZone() == Zone.OUTPUTS) {
                        metadataTableEditorView.getExtendedToolbar().getRemoveButton().getButton().setEnabled(false);
                        break;
                    }
                }
            }
        }
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)59 ArrayList (java.util.ArrayList)14 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)14 Point (org.eclipse.swt.graphics.Point)12 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)11 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)11 List (java.util.List)9 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)9 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)9 TableViewer (org.eclipse.jface.viewers.TableViewer)7 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)7 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)7 HashMap (java.util.HashMap)6 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)6 AbstractUIManager (org.talend.designer.abstractmap.managers.AbstractUIManager)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)6 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)6 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)6 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)4