Search in sources :

Example 1 with InputTable

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

the class ExternalDataConverter method prepareInputTables.

public ArrayList<InputTable> prepareInputTables(List<IOConnection> inputConnections, ExternalMapperData externalData) {
    ArrayList<InputTable> inputDataMapTables = new ArrayList<InputTable>();
    ArrayList<IOConnection> remainingConnections = new ArrayList<IOConnection>(inputConnections);
    // case externalData IS NOT initialized
    if (externalData == null || externalData.getInputTables().size() == 0) {
        for (IOConnection connection : inputConnections) {
            InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
            inputTable.initFromExternalData(null);
            if (EConnectionType.FLOW_MAIN != connection.getConnectionType()) {
                inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
            }
            if (connection.getTable() == null) {
                inputTable.setReadOnly(true);
            }
            inputDataMapTables.add(inputTable);
        }
    } else {
        // case externalData IS initialized
        Map<String, IOConnection> nameToInputConnection = new HashMap<String, IOConnection>();
        for (IOConnection connection : inputConnections) {
            nameToInputConnection.put(connection.getName(), connection);
        }
        for (ExternalMapperTable persistentTable : externalData.getInputTables()) {
            IOConnection connection = nameToInputConnection.get(persistentTable.getName());
            if (connection != null) {
                InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
                inputTable.initFromExternalData(persistentTable);
                inputDataMapTables.add(inputTable);
                remainingConnections.remove(connection);
                // remove table settings in main ,set false in case the value is true in previous version
                if (EConnectionType.FLOW_MAIN == connection.getConnectionType()) {
                    inputTable.setActivateCondensedTool(false);
                    // bug TDI-8027
                    inputTable.setPersistent(false);
                }
                if (connection.getTable() == null) {
                    inputTable.setReadOnly(true);
                }
            }
        }
        for (IOConnection connection : remainingConnections) {
            InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
            inputTable.initFromExternalData(null);
            inputDataMapTables.add(inputTable);
            // remove table settings in main ,set false in case the value is true in previous version
            if (EConnectionType.FLOW_MAIN == connection.getConnectionType()) {
                inputTable.setActivateCondensedTool(false);
                // bug TDI-8027
                inputTable.setPersistent(false);
            } else {
                inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
            }
            if (connection.getTable() == null) {
                inputTable.setReadOnly(true);
            }
        }
    }
    // sort for put table with main connection at top position of the list
    Collections.sort(inputDataMapTables, new Comparator<InputTable>() {

        public int compare(InputTable o1, InputTable o2) {
            if (o1.isMainConnection()) {
                return -1;
            } else if (o2.isMainConnection()) {
                return 1;
            }
            return 0;
        }
    });
    return inputDataMapTables;
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 2 with InputTable

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

the class LinkManager method registerLevelForNewLink.

/**
     * DOC amaumont Comment method "registerLevelForNewLink".
     * 
     * @param link
     * @param graphicalLinksFromTarget
     */
public void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
    boolean hasAlreadyInputTarget = false;
    boolean hasAlreadyVarTarget = false;
    ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = sourceEntry.getParent().getClass() == targetEntry.getParent().getClass();
    if (hasSameZone) {
        boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
        boolean isVarTarget = targetEntry instanceof VarTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInputTarget) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isVarTarget) {
            leveledLinks = getVarLinksForLevels();
        }
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
                ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
                ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
                if (targetEntry == targetTableEntry) {
                    if (sourceTableEntry instanceof InputColumnTableEntry && (targetTableEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
                        hasAlreadyInputTarget = true;
                    }
                    if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
                        hasAlreadyVarTarget = true;
                    }
                    if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
                        linksFromLevelsList.add(link);
                        link.setLevel(indexOfLeveledLink + 1);
                        break;
                    }
                }
            }
        }
        if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
            ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
            int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
            link.setLevel(firstEmptyIndex + 1);
            list.add(link);
            if (firstEmptyIndex < leveledLinks.size()) {
                leveledLinks.set(firstEmptyIndex, list);
            } else {
                leveledLinks.add(list);
            }
        }
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputTable(org.talend.designer.mapper.model.table.InputTable) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) List(java.util.List) ArrayList(java.util.ArrayList) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 3 with InputTable

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

the class DropContextAnalyzer method checkDropIsValid.

/**
     * DOC amaumont Comment method "checkDropHasValidTarget".
     */
private boolean checkDropIsValid() {
    isInputToInput = false;
    mapOneToOneAuthorized = true;
    if (targetIsExpressionFilterText() || (targetTableIsFiltersTable() || targetTableIsGlobalMapTable() || draggedData.getTransferableEntryList().size() <= 1)) {
        mapOneToOneAuthorized = false;
    }
    if (invalidKeyPressed) {
        return false;
    }
    /*
         * INPUT => INPUT
         */
    if (zoneSource == Zone.INPUTS && zoneTarget == Zone.INPUTS) {
        isInputToInput = true;
        mapOneToOneAuthorized = false;
        List<InputTable> inputTables = mapperManager.getInputTables();
        int indexTableSource = inputTables.indexOf(dataMapTableViewSource.getDataMapTable());
        int indexTableTarget = inputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
        if (currentTableTarget != null) {
            if (indexTableSource >= indexTableTarget) {
                /*
                     * INPUT => INPUT && index of table source >= index of table target
                     */
                return false;
            } else {
                return true;
            }
        } else if (currentStyledTextTarget != null) {
            if (indexTableSource > indexTableTarget) {
                /*
                     * INPUT => INPUT && index of table source > index of table target
                     */
                return false;
            } else {
                return true;
            }
        } else {
            //$NON-NLS-1$
            throw new IllegalStateException(Messages.getString("DropContextAnalyzer.notFound"));
        }
    }
    /*
         * OUTPUT => OUTPUT
         */
    if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
        isOutputToOutput = true;
        mapOneToOneAuthorized = true;
        List<OutputTable> outputTables = mapperManager.getOutputTables();
        int indexSourceOutputTable = outputTables.indexOf(dataMapTableViewSource.getDataMapTable());
        int indexTargetOutputTable = outputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
        if (indexSourceOutputTable == indexTargetOutputTable) {
            /*
                 * INPUT => INPUT && index of table source >= index of table target
                 */
            return false;
        } else {
            // OUTPUT => OUTPUT
            return checkZoonTarget();
        }
    }
    if (currentTableTarget != null) {
        TableItem tableItemTarget = getTableItemFromPosition(new Point(event.x, event.y));
        if (zoneSource == Zone.VARS && zoneTarget == Zone.VARS && tableItemTarget != null) {
            if (tableItemSource == tableItemTarget || !dropVarsEntryIsValid(tableItemTarget)) {
                /*
                     * VAR => VAR && (item source == item target || item target is invalid)
                     */
                return false;
            }
        }
    }
    if (zoneSource == Zone.VARS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
        /*
             * VAR => INPUT OUTPUT => OUTPUT OUTPUT => INPUT OUTPUT => VAR
             */
        return false;
    }
    return checkZoonTarget();
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 4 with InputTable

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

the class MapperUI method createInputZoneWithTables.

private void createInputZoneWithTables(MapperModel mapperModel, final Display display) {
    inputsZone = new InputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
    inputsZone.createHeaderZoneComponents();
    sc1 = new ScrolledComposite(inputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
    // this.dropTargetOperationListener.addControl(sc1);
    GridData sc1GridData = new GridData(GridData.FILL_BOTH);
    sc1.setLayoutData(sc1GridData);
    sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        // System.out.println("sc1 controlMoved");
        }

        public void controlResized(ControlEvent e) {
            // System.out.println("sc1 controlResized");
            onSashResized(display);
        }
    });
    // add for auto scroll
    new DragNDrop(mapperManager, sc1, true, true);
    inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
    // this.dropTargetOperationListener.addControl(inputTablesZoneView);
    inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.setExpandHorizontal(true);
    sc1.setContent(inputTablesZoneView);
    sc1MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc1);
    inputTablesZoneView.initInsertionIndicator();
    Control previousControl = null;
    List<InputTable> tables = mapperModel.getInputDataMapTables();
    Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
    if (minimizeStateOfTables != null) {
        inputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
    }
    for (InputTable inputTable : tables) {
        InputDataMapTableView dataMapTableView = new InputDataMapTableView(inputTablesZoneView, SWT.BORDER, inputTable, mapperManager);
        FormData formData = new FormData();
        formData.left = new FormAttachment(0, 0);
        formData.right = new FormAttachment(100, 0);
        formData.top = new FormAttachment(previousControl);
        dataMapTableView.setLayoutData(formData);
        previousControl = dataMapTableView;
        boolean tableIsMinimized = inputTable.isMinimized();
        dataMapTableView.minimizeTable(tableIsMinimized);
        dataMapTableView.registerStyledExpressionEditor(getTabFolderEditors().getStyledTextHandler());
        dataMapTableView.loaded();
    // dataMapTableView.fillMinimumSize(false);
    }
    inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc1MSListener.addMouseWheelListener(sc1);
}
Also used : FormData(org.eclipse.swt.layout.FormData) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) InputTable(org.talend.designer.mapper.model.table.InputTable) Control(org.eclipse.swt.widgets.Control) InputsZone(org.talend.designer.mapper.ui.visualmap.zone.InputsZone) DragNDrop(org.talend.designer.mapper.ui.dnd.DragNDrop) InputTablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.InputTablesZoneView) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 5 with InputTable

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

the class UIManager method getTableEntryPosition.

/**
     * DOC amaumont Comment method "getTableEntryPosition".
     * 
     * @param manager TODO
     * @param tableEntry
     * @param forceRecalculate TODO
     * @return
     */
public Point getTableEntryPosition(ITableEntry tableEntry, boolean forceRecalculate) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
    int entriesSize = 0;
    int minHeight = dataMapTableView.getTableViewerCreatorForColumns().getTable().getHeaderHeight() + dataMapTableView.getTableViewerCreatorForColumns().getTable().getItemHeight();
    TableItem[] tableItems = new TableItem[0];
    if (tableEntry instanceof InputColumnTableEntry || tableEntry instanceof OutputColumnTableEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
        AbstractInOutTable abstractInOutTable = (AbstractInOutTable) dataMapTableView.getDataMapTable();
        if (dataMapTableView.getZone() == Zone.OUTPUTS) {
            OutputTable outputTable = (OutputTable) abstractInOutTable;
            List<IColumnEntry> oldOuputEntries = outputTable.getDataMapTableEntries();
            entriesSize = oldOuputEntries.size();
        }
        if (dataMapTableView.getZone() == Zone.INPUTS) {
            InputTable inputTable = (InputTable) abstractInOutTable;
            List<IColumnEntry> oldOuputEntries = inputTable.getDataMapTableEntries();
            entriesSize = oldOuputEntries.size();
        }
    }
    Rectangle tableViewBounds = dataMapTableView.getBounds();
    Point pointFromTableViewOrigin = null;
    Display display = dataMapTableView.getDisplay();
    Point returnedPoint = new Point(0, 0);
    TableEntryProperties tableEntryProperties = null;
    int itemIndex = 0;
    if (tableEntry instanceof IColumnEntry || tableEntry instanceof FilterTableEntry || tableEntry instanceof GlobalMapEntry) {
        tableEntryProperties = mapperManager.getTableEntryProperties(tableEntry);
        returnedPoint = tableEntryProperties.position;
        if (forceRecalculate || returnedPoint == null) {
            int y;
            TableItem tableItem = mapperManager.retrieveTableItem(tableEntry);
            boolean isOutputEntry = tableEntry instanceof OutputColumnTableEntry;
            boolean isIntputEntry = tableEntry instanceof InputColumnTableEntry;
            boolean checked = false;
            for (int i = 0; i < tableItems.length; i++) {
                if (tableItems[i].getData() == tableEntry) {
                    itemIndex = i;
                    break;
                }
            }
            boolean allIsNull = false;
            if (tableItem == null && (isIntputEntry || isOutputEntry)) {
                if (tableItems.length > 0) {
                    tableItem = tableItems[0];
                    checked = true;
                } else {
                    allIsNull = true;
                }
            }
            if (!allIsNull) {
                Table table = tableItem.getParent();
                // FIX for issue 1225 ("1" parameter added)
                Rectangle boundsTableItem = tableItem.getBounds(1);
                y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
                if (isOutputEntry || isIntputEntry) {
                    if (entriesSize != tableItems.length) {
                        y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
                    }
                }
                if (checked) {
                    y = boundsTableItem.y + dataMapTableView.getBorderWidth();
                    checked = false;
                }
                int x = 0;
                if (y < 0) {
                    y = 0;
                }
                Point point = new Point(x, y);
                pointFromTableViewOrigin = display.map(tableItem.getParent(), dataMapTableView, point);
            } else {
                Text columnFilterText = dataMapTableView.getColumnNameFilterText();
                Point point = new Point(-dataMapTableView.getBorderWidth() - 19, minHeight);
                pointFromTableViewOrigin = display.map(columnFilterText, dataMapTableView, point);
            }
        }
    } else if (tableEntry instanceof ExpressionFilterEntry) {
        StyledText expressionFilterText = dataMapTableView.getExpressionFilterText();
        //            dataMapTableView.getex
        Point point = new Point(-dataMapTableView.getBorderWidth() - 19, 16);
        pointFromTableViewOrigin = display.map(expressionFilterText, dataMapTableView, point);
    } else {
        //$NON-NLS-1$
        throw new IllegalStateException("Case not found");
    }
    if (pointFromTableViewOrigin.y > tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION) {
        pointFromTableViewOrigin.y = tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION;
    }
    returnedPoint = convertPointToReferenceOrigin(getReferenceComposite(), pointFromTableViewOrigin, dataMapTableView);
    if (tableEntryProperties != null) {
        tableEntryProperties.position = returnedPoint;
    }
    return returnedPoint;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) Table(org.eclipse.swt.widgets.Table) AbstractDataMapTable(org.talend.designer.mapper.model.table.AbstractDataMapTable) StyledText(org.eclipse.swt.custom.StyledText) TableItem(org.eclipse.swt.widgets.TableItem) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) Rectangle(org.eclipse.swt.graphics.Rectangle) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) 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) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableEntryProperties(org.talend.designer.mapper.ui.visualmap.TableEntryProperties) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) Display(org.eclipse.swt.widgets.Display)

Aggregations

InputTable (org.talend.designer.mapper.model.table.InputTable)24 ArrayList (java.util.ArrayList)10 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)8 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)8 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)8 OutputTable (org.talend.designer.mapper.model.table.OutputTable)5 HashMap (java.util.HashMap)4 List (java.util.List)4 VarsTable (org.talend.designer.mapper.model.table.VarsTable)4 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 Point (org.eclipse.swt.graphics.Point)3 GridData (org.eclipse.swt.layout.GridData)3 Table (org.eclipse.swt.widgets.Table)3 TableItem (org.eclipse.swt.widgets.TableItem)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)3 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)3 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)3 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)3