Search in sources :

Example 31 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class UIManager method isTableViewMoveable.

public boolean isTableViewMoveable(Zone zone, boolean moveUp) {
    if (zone == Zone.INPUTS) {
        if (currentSelectedInputTableView == null) {
            return false;
        }
        List<DataMapTableView> tablesView = mapperManager.getUiManager().getInputsTablesView();
        int indexCurrentTable = tablesView.indexOf(currentSelectedInputTableView);
        if (moveUp) {
            if (indexCurrentTable > 1) {
                return true;
            }
            return false;
        } else {
            if (indexCurrentTable < tablesView.size() - 1 && indexCurrentTable > 0) {
                return true;
            }
            return false;
        }
    } else if (zone == Zone.OUTPUTS) {
        if (currentSelectedOutputTableView == null) {
            return false;
        }
        List<DataMapTableView> tablesView = mapperManager.getUiManager().getOutputsTablesView();
        int indexCurrentTable = tablesView.indexOf(currentSelectedOutputTableView);
        if (moveUp) {
            if (indexCurrentTable > 0) {
                // TDI-28187:join table should always under its host table
                OutputDataMapTableView previousOutTable = (OutputDataMapTableView) tablesView.get(indexCurrentTable - 1);
                String joinTableName = currentSelectedOutputTableView.getOutputTable().getIsJoinTableOf();
                if (joinTableName != null && joinTableName.equals(previousOutTable.getOutputTable().getName())) {
                    return false;
                }
                return true;
            }
            return false;
        } else {
            if (indexCurrentTable < tablesView.size() - 1) {
                OutputDataMapTableView nextOutTable = (OutputDataMapTableView) tablesView.get(indexCurrentTable + 1);
                String joinTableName = nextOutTable.getOutputTable().getIsJoinTableOf();
                if (joinTableName != null && joinTableName.equals(currentSelectedOutputTableView.getOutputTable().getName())) {
                    return false;
                }
                return true;
            }
            return false;
        }
    }
    return false;
}
Also used : 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) ArrayList(java.util.ArrayList) List(java.util.List) Point(org.eclipse.swt.graphics.Point) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)

Example 32 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class UIManager method moveSelectedTableDown.

private void moveSelectedTableDown(final DataMapTableView currentSelectedTableView, List<DataMapTableView> tablesView, int indexStartMovedAuthorized) {
    int indexCurrentTable = tablesView.indexOf(currentSelectedTableView);
    if (indexCurrentTable < indexStartMovedAuthorized || indexCurrentTable == tablesView.size() - 1) {
        return;
    }
    final DataMapTableView nextTableView = tablesView.get(indexCurrentTable + 1);
    FormData formDataCurrent = (FormData) currentSelectedTableView.getLayoutData();
    formDataCurrent.top.control = nextTableView;
    if (indexCurrentTable + 2 <= tablesView.size() - 1) {
        DataMapTableView afterNextTableView = tablesView.get(indexCurrentTable + 2);
        FormData formDataAfterNext = (FormData) afterNextTableView.getLayoutData();
        formDataAfterNext.top.control = currentSelectedTableView;
    }
    FormData formDataNext = (FormData) nextTableView.getLayoutData();
    if (indexCurrentTable - 1 >= 0) {
        formDataNext.top.control = tablesView.get(indexCurrentTable - 1);
    } else {
        formDataNext.top.control = null;
    }
    tableManager.swapWithNextTable(currentSelectedTableView.getDataMapTable());
    currentSelectedTableView.getParent().layout();
    parseAllExpressions(currentSelectedTableView, false);
    parseAllExpressions(nextTableView, false);
    checkProblemsForMovedTables(currentSelectedTableView, nextTableView);
}
Also used : FormData(org.eclipse.swt.layout.FormData) 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)

Example 33 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class UIManager method unselectAllEntriesOfAllTables.

public void unselectAllEntriesOfAllTables() {
    List<DataMapTableView> tablesView = mapperManager.getUiManager().getOutputsTablesView();
    tablesView.addAll(mapperManager.getUiManager().getInputsTablesView());
    tablesView.addAll(mapperManager.getUiManager().getVarsTablesView());
    for (DataMapTableView view : tablesView) {
        view.unselectAllEntries();
    }
}
Also used : 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 34 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class UIManager method parseExpression.

/**
     * 
     * 
     * @param expression
     * @param currentModifiedITableEntry
     * @param linkMustHaveSelectedState
     * @param checkInputKeyAutomatically TODO
     * @param inputExpressionAppliedOrCanceled TODO
     * @param newSelectedDataMapTableView
     * @return true if a link has been added or removed, false else
     */
public ParseExpressionResult parseExpression(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);
            sourcesForTargetToDelete.remove(sourceTableEntry);
            if (sourceTableEntry != null && !sourcesForTarget.contains(sourceTableEntry)) {
                DataMapTableView sourceDataMapTableView = mapperManager.retrieveDataMapTableView(sourceTableEntry);
                IMapperLink link = new Link(new PointLinkDescriptor(sourceTableEntry, sourceDataMapTableView.getZone()), new PointLinkDescriptor(currentModifiedITableEntry, dataMapTableView.getZone()), mapperManager);
                link.setState(linkMustHaveSelectedState ? LinkState.SELECTED : LinkState.UNSELECTED);
                mapperManager.addLink(link);
                linkHasBeenAdded = true;
            }
            alreadyProcessed.add(location);
        }
    }
    Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
    Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
    for (IMapperLink link : linksFromTarget) {
        if (sourcesForTargetToDelete.contains(link.getPointLinkDescriptor1().getTableEntry())) {
            mapperManager.removeLink(link, link.getPointLinkDescriptor2().getTableEntry());
            linkHasBeenRemoved = true;
        }
    }
    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 : PointLinkDescriptor(org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor) 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) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) Link(org.talend.designer.mapper.ui.visualmap.link.Link) HashSet(java.util.HashSet) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 35 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class UIManager method applyActivatedCellEditorsForAllTables.

/**
     * 
     * "applyActivatedCellEditorsForAllTables".
     * 
     * @param exceptThisTableViewerCreator
     */
public void applyActivatedCellEditorsForAllTables(TableViewerCreator exceptThisTableViewerCreator) {
    Collection<DataMapTableView> tablesView = mapperManager.getTablesView();
    for (DataMapTableView dataMapTableView : tablesView) {
        TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
        if (tableViewerCreatorForColumns != exceptThisTableViewerCreator) {
            applyActivatedCellEditors(tableViewerCreatorForColumns);
        }
        TableViewerCreator tableViewerCreatorForGlobalMap = dataMapTableView.getTableViewerCreatorForGlobalMap();
        if (tableViewerCreatorForGlobalMap != null && tableViewerCreatorForGlobalMap != exceptThisTableViewerCreator) {
            applyActivatedCellEditors(tableViewerCreatorForGlobalMap);
        }
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) 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)

Aggregations

DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)47 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)24 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)24 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)24 Point (org.eclipse.swt.graphics.Point)11 OutputTable (org.talend.designer.mapper.model.table.OutputTable)10 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)9 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)7 ArrayList (java.util.ArrayList)6 FormData (org.eclipse.swt.layout.FormData)6 UIManager (org.talend.designer.mapper.managers.UIManager)6 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)5 List (java.util.List)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4