Search in sources :

Example 6 with FilterTableEntry

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

the class UIManager method selectLinks.

/**
     * Highlight links and linked cells which have are referenced by the selected items.
     * 
     * @param dataMapTableView
     * @param forceResetHighlightLinksForOtherTables TODO
     * @param selectAllTableLinks TODO
     * @param selectedMetadataTableEntries, source or targets entries which must be highlighted, can be null to select
     * all links of a same DataMapTableView
     */
@SuppressWarnings("unchecked")
public void selectLinks(DataMapTableView dataMapTableView, List<ITableEntry> selectedTableEntries, boolean forceResetHighlightLinksForOtherTables, boolean selectAllTableLinks) {
    if (!selectAllTableLinks && selectedTableEntries == null || selectedTableEntries != null && selectedTableEntries.size() == 0) {
        return;
    }
    UIManager uiManager = mapperManager.getUiManager();
    TableViewerCreator<ITableEntry> currentTableViewer = null;
    boolean isFilterTableSelected = false;
    boolean isGlobalMapTableSelected = false;
    if (!selectAllTableLinks) {
        ITableEntry firstEntry = selectedTableEntries.get(0);
        if (firstEntry.isTableEntry()) {
            if (firstEntry instanceof FilterTableEntry) {
                isFilterTableSelected = true;
                currentTableViewer = dataMapTableView.getTableViewerCreatorForFilters();
            } else if (firstEntry instanceof GlobalMapEntry) {
                isGlobalMapTableSelected = true;
                currentTableViewer = dataMapTableView.getTableViewerCreatorForGlobalMap();
            } else {
                currentTableViewer = dataMapTableView.getTableViewerCreatorForColumns();
            }
        }
    }
    // Color selectedColor = dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW);
    Color unselectedColor = dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WHITE);
    Zone currentZone = dataMapTableView.getZone();
    Set<ITableEntry> hashSelectedMetadataTableEntries = new HashSet<ITableEntry>();
    if (selectAllTableLinks) {
        if (currentZone == Zone.INPUTS || currentZone == Zone.OUTPUTS) {
            hashSelectedMetadataTableEntries.add(((AbstractInOutTable) dataMapTableView.getDataMapTable()).getExpressionFilter());
        }
        hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForColumns().getInputList());
        if (currentZone == Zone.INPUTS) {
            hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForGlobalMap().getInputList());
        }
        if (currentZone == Zone.OUTPUTS) {
            hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForFilters().getInputList());
        }
    } else {
        hashSelectedMetadataTableEntries.addAll(selectedTableEntries);
    }
    // ////////////////////////////////////////////////////////////////////////
    // Unselect all links and tableEntries if Ctrl or Shift keys are not pressed or if zone different of last
    // selection
    boolean zoneHasChanged = (previousSelectedZone == Zone.INPUTS || previousSelectedZone == Zone.VARS) && currentZone == Zone.OUTPUTS || (currentZone == Zone.INPUTS || currentZone == Zone.VARS) && previousSelectedZone == Zone.OUTPUTS;
    boolean tableTypeHasChanged = previousSelectedTableIsConstraint != isFilterTableSelected && currentZone == Zone.OUTPUTS || previousSelectedTableIsGlobalMap != isGlobalMapTableSelected && currentZone == Zone.INPUTS;
    boolean resetHighlightObjectsForOtherTables = !uiManager.isDragging() && (!uiManager.isCtrlPressed() && !uiManager.isShiftPressed() || zoneHasChanged);
    if (resetHighlightObjectsForOtherTables || forceResetHighlightLinksForOtherTables) {
        for (IMapperLink link : mapperManager.getLinks()) {
            if (!hashSelectedMetadataTableEntries.contains(link.getPointLinkDescriptor1().getTableEntry()) && !hashSelectedMetadataTableEntries.contains(link.getPointLinkDescriptor2().getTableEntry())) {
                link.setState(LinkState.UNSELECTED);
                ITableEntry sourceITableEntry = link.getPointLinkDescriptor1().getTableEntry();
                TableItem tableItem = mapperManager.retrieveTableItem(sourceITableEntry);
                if (tableItem != null) {
                    tableItem.setBackground(unselectedColor);
                }
                ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
                if (tableItem != null) {
                    tableItem = mapperManager.retrieveTableItem(targetITableEntry);
                }
                if (tableItem != null) {
                    tableItem.setBackground(unselectedColor);
                }
            }
        }
        if (currentZone == Zone.INPUTS || currentZone == Zone.VARS) {
            unselectAllOutputMetaDataEntries();
        } else if (currentZone == Zone.OUTPUTS) {
            unselectAllInputMetaDataEntries();
        }
        Collection<DataMapTableView> tablesToDeselectEntries = mapperManager.getTablesView();
        for (DataMapTableView viewToDeselectEntries : tablesToDeselectEntries) {
            if (viewToDeselectEntries != dataMapTableView) {
                viewToDeselectEntries.unselectAllEntries();
            } else if (viewToDeselectEntries == dataMapTableView && tableTypeHasChanged) {
                if (isFilterTableSelected) {
                    viewToDeselectEntries.unselectAllColumnEntries();
                    viewToDeselectEntries.unselectAllGlobalMapEntries();
                } else if (isGlobalMapTableSelected) {
                    viewToDeselectEntries.unselectAllColumnEntries();
                    viewToDeselectEntries.unselectAllConstraintEntries();
                } else {
                    viewToDeselectEntries.unselectAllGlobalMapEntries();
                    viewToDeselectEntries.unselectAllConstraintEntries();
                }
            }
        }
    }
    // ////////////////////////////////////////////////////////////////////////
    // ////////////////////////////////////////////////////////////////////////
    // Select or unselect links and tableEntries
    List<ITableEntry> allEntriesOfCurrentTableView = new ArrayList<ITableEntry>();
    if (currentZone == Zone.INPUTS || currentZone == Zone.OUTPUTS) {
        allEntriesOfCurrentTableView.add(((AbstractInOutTable) dataMapTableView.getDataMapTable()).getExpressionFilter());
    }
    if (selectAllTableLinks || currentTableViewer != null) {
        allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForColumns().getInputList());
        if (selectAllTableLinks && currentZone == Zone.OUTPUTS) {
            allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForFilters().getInputList());
        }
        // if (selectAllTableLinks && currentZone == Zone.INPUTS) {
        if (currentZone == Zone.INPUTS) {
            allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForGlobalMap().getInputList());
        }
    }
    int lstSize = allEntriesOfCurrentTableView.size();
    Set<IMapperLink> linksAlreadySelected = new HashSet<IMapperLink>();
    for (int i = 0; i < lstSize; i++) {
        ITableEntry entry = allEntriesOfCurrentTableView.get(i);
        Set<IMapperLink> linksFromSource = mapperManager.getGraphicalLinksFromSource(entry);
        Set<IMapperLink> linksFromTarget = mapperManager.getGraphicalLinksFromTarget(entry);
        LinkState linkState = null;
        if (hashSelectedMetadataTableEntries.contains(entry)) {
            linkState = LinkState.SELECTED;
        } else {
            linkState = LinkState.UNSELECTED;
        }
        for (IMapperLink link : linksFromSource) {
            ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
            if (linkState == LinkState.SELECTED || !linksAlreadySelected.contains(link) && linkState == LinkState.UNSELECTED) {
                link.setState(linkState);
                if (linkState == LinkState.SELECTED) {
                    linksAlreadySelected.add(link);
                }
            }
            EntryState entryState = (link.getState() == LinkState.SELECTED ? EntryState.HIGHLIGHT : EntryState.NONE);
            setEntryState(mapperManager, entryState, targetITableEntry);
        }
        for (IMapperLink link : linksFromTarget) {
            ITableEntry sourceITableEntry = link.getPointLinkDescriptor1().getTableEntry();
            if (linkState == LinkState.SELECTED || !linksAlreadySelected.contains(link) && linkState == LinkState.UNSELECTED) {
                link.setState(linkState);
                if (linkState == LinkState.SELECTED) {
                    linksAlreadySelected.add(link);
                }
            }
            EntryState entryState = (link.getState() == LinkState.SELECTED ? EntryState.HIGHLIGHT : EntryState.NONE);
            setEntryState(mapperManager, entryState, sourceITableEntry);
        }
    }
    // ////////////////////////////////////////////////////////////////////////
    // order links to place selected links at last position (last drawn)
    mapperManager.orderLinks();
    uiManager.refreshBackground(false, false);
    previousSelectedZone = dataMapTableView.getZone();
    previousSelectedTableIsConstraint = isFilterTableSelected;
    previousSelectedTableIsGlobalMap = isGlobalMapTableSelected;
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) 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) Color(org.eclipse.swt.graphics.Color) TableItem(org.eclipse.swt.widgets.TableItem) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) ArrayList(java.util.ArrayList) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) 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) Point(org.eclipse.swt.graphics.Point) LinkState(org.talend.designer.abstractmap.ui.visualmap.link.LinkState) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) EntryState(org.talend.designer.mapper.ui.visualmap.table.EntryState) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) HashSet(java.util.HashSet)

Example 7 with FilterTableEntry

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

the class TableEntriesManager method retrieveTableItem.

TableItem retrieveTableItem(ITableEntry dataMapTableEntry) {
    DataMapTableView dataMapTableView = this.mapperManager.retrieveAbstractDataMapTableView(dataMapTableEntry.getParent());
    TableItem[] tableItems = new TableItem[0];
    if (dataMapTableEntry instanceof IColumnEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
    } else if (dataMapTableEntry instanceof FilterTableEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForFilters().getTable().getItems();
    } else if (dataMapTableEntry instanceof GlobalMapEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForGlobalMap().getTable().getItems();
    } else if (dataMapTableEntry instanceof ExpressionFilterEntry) {
        return null;
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("TableEntriesManager.exceptionMessage.caseNotFound"));
    }
    TableItem tableItem = null;
    for (int i = 0; i < tableItems.length; i++) {
        if (tableItems[i].getData() == dataMapTableEntry) {
            tableItem = tableItems[i];
            break;
        }
    }
    getTableEntryProperties(dataMapTableEntry).setTableItem(tableItem);
    return tableItem;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)

Example 8 with FilterTableEntry

use of org.talend.designer.mapper.model.tableentry.FilterTableEntry 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)

Example 9 with FilterTableEntry

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

the class MapperManager method removeTablePair.

/**
     * 
     * Remove the <code>DataMapTableView</code>-<code>DataMapTable</code> pair.
     * 
     * @param view
     */
public void removeTablePair(DataMapTableView view) {
    IDataMapTable dataTable = tableManager.getData(view);
    List<IColumnEntry> dataMapTableEntries = dataTable.getColumnEntries();
    if (isAdvancedMap() && dataTable instanceof AbstractInOutTable) {
        tableEntriesManager.removeAll(Arrays.asList(((AbstractInOutTable) dataTable).getExpressionFilter()));
    }
    tableEntriesManager.removeAll(dataMapTableEntries);
    if (dataTable instanceof OutputTable) {
        List<FilterTableEntry> constraintEntries = ((OutputTable) dataTable).getFilterEntries();
        tableEntriesManager.removeAll(constraintEntries);
    }
    tableManager.removeTable(view);
}
Also used : AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 10 with FilterTableEntry

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

the class MapperManager method addNewFilterEntry.

public FilterTableEntry addNewFilterEntry(DataMapTableView dataMapTableView, String name, Integer index) {
    IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
    FilterTableEntry constraintEntry = new FilterTableEntry(abstractDataMapTable, name, null);
    tableEntriesManager.addTableEntry(constraintEntry, index);
    return constraintEntry;
}
Also used : FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable)

Aggregations

FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)17 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)7 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)7 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)7 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 TableItem (org.eclipse.swt.widgets.TableItem)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 ArrayList (java.util.ArrayList)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Color (org.eclipse.swt.graphics.Color)2 Point (org.eclipse.swt.graphics.Point)2 Table (org.eclipse.swt.widgets.Table)2 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)2 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)2 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1