Search in sources :

Example 11 with GlobalMapEntry

use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry 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 12 with GlobalMapEntry

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

the class ExternalDataConverter method fillExternalTable.

/**
     * 
     * DOC amaumont Comment method "fillExternalTable".
     * 
     * @param table
     * @param externalMapperTable
     */
private void fillExternalTable(InputTable table, ExternalMapperTable externalMapperTable) {
    externalMapperTable.setInnerJoin(table.isInnerJoin());
    externalMapperTable.setPersistent(table.isPersistent());
    externalMapperTable.setActivateExpressionFilter(table.isActivateExpressionFilter());
    externalMapperTable.setActivateCondensedTool(table.isActivateCondensedTool());
    externalMapperTable.setActivateColumnNameFilter(table.isActivateColumnNameFilter());
    externalMapperTable.setId(table.getId());
    String expressionFilter = null;
    if (table.getExpressionFilter() != null && table.getExpressionFilter().getExpression() != null) {
        expressionFilter = table.getExpressionFilter().getExpression();
    }
    externalMapperTable.setExpressionFilter(expressionFilter);
    String matchingMode = null;
    if (table.getMatchingMode() != null) {
        matchingMode = table.getMatchingMode().toString();
    }
    externalMapperTable.setMatchingMode(matchingMode);
    String lookupMode = null;
    if (table.getLookupMode() != null) {
        lookupMode = table.getLookupMode().toString();
    }
    externalMapperTable.setLookupMode(lookupMode);
    ArrayList<ExternalMapperTableEntry> globalMapEntries = new ArrayList<ExternalMapperTableEntry>();
    for (GlobalMapEntry constraintTableEntry : table.getGlobalMapEntries()) {
        ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
        externalMapperTableEntry.setExpression(constraintTableEntry.getExpression());
        externalMapperTableEntry.setName(constraintTableEntry.getName());
        globalMapEntries.add(externalMapperTableEntry);
    }
    externalMapperTable.setGlobalMapKeysValues(globalMapEntries);
    fillExternalTableWithCommonsData(table, externalMapperTable);
    inputTables.add(externalMapperTable);
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 13 with GlobalMapEntry

use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry 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 14 with GlobalMapEntry

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

the class MapperManager method addNewGlobalMapEntry.

/**
     * 
     * @param dataMapTableView
     * @param index
     * @param type TODO
     * @param metadataColumn, can be null if added in VarsTable
     */
public GlobalMapEntry addNewGlobalMapEntry(DataMapTableView dataMapTableView, ITableEntry tableEntrySource, Integer index) {
    IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
    GlobalMapEntry dataMapTableEntry = null;
    if (dataMapTableView.getZone() == Zone.INPUTS) {
        dataMapTableEntry = new GlobalMapEntry(abstractDataMapTable, "\"" + dataMapTableView.findUniqueName("myKey") + "\"", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        null);
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
    }
    AddGlobalMapEntryCommand command = new AddGlobalMapEntryCommand(tableEntriesManager, dataMapTableEntry, index);
    executeCommand(command);
    return dataMapTableEntry;
}
Also used : AddGlobalMapEntryCommand(org.talend.designer.mapper.ui.commands.AddGlobalMapEntryCommand) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 15 with GlobalMapEntry

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

the class InputDataMapTableView method createGlobalMapTable.

protected void createGlobalMapTable() {
    this.extendedTableViewerForGlobalMap = new AbstractExtendedTableViewer<GlobalMapEntry>(((InputTable) abstractDataMapTable).getTableGlobalMapEntriesModel(), centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
            createGlobalMapColumns(tableViewerCreator);
        }

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
             * (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
             */
        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setColumnsResizableByDefault(true);
            newTableViewerCreator.setShowLineSelection(SHOW_ROW_SELECTION.FULL);
            newTableViewerCreator.setBorderVisible(false);
            newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
            newTableViewerCreator.setKeyboardManagementForCellEdition(true);
            newTableViewerCreator.setHorizontalScroll(false);
            newTableViewerCreator.setVerticalScroll(false);
            // tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
            // instanceof
            // AbstractInOutTable);
            newTableViewerCreator.setFirstColumnMasked(true);
        }
    };
    tableViewerCreatorForGlobalMap = this.extendedTableViewerForGlobalMap.getTableViewerCreator();
    if (mapperManager.componentIsReadOnly()) {
        tableViewerCreatorForGlobalMap.setReadOnly(true);
    }
    this.extendedTableViewerForGlobalMap.setCommandStack(mapperManager.getCommandStack());
    tableForGlobalMap = tableViewerCreatorForGlobalMap.getTable();
    tableForGlobalMapGridData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    tableForGlobalMap.setLayoutData(tableForGlobalMapGridData);
    boolean tableGlobalMapVisible = false;
    if (abstractDataMapTable instanceof InputTable) {
        IUILookupMode lookupMode = ((InputTable) abstractDataMapTable).getLookupMode();
        tableGlobalMapVisible = lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD;
    }
    tableForGlobalMapGridData.exclude = !tableGlobalMapVisible;
    tableForGlobalMap.setVisible(tableGlobalMapVisible);
    if (!mapperManager.componentIsReadOnly()) {
        new DragNDrop(mapperManager, tableForGlobalMap, false, true);
    }
    tableViewerCreatorForGlobalMap.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    final TableViewer tableViewer = tableViewerCreatorForGlobalMap.getTableViewer();
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            selectThisDataMapTableView();
            UIManager uiManager = mapperManager.getUiManager();
            uiManager.selectLinks(InputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
        }
    });
    tableForGlobalMap.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForGlobalMap, event);
        }
    });
    tableViewerCreatorForGlobalMap.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForGlobalMap) {

        @Override
        public Color getBackground(Object element, int columnIndex) {
            return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
        }

        @Override
        public Color getForeground(Object element, int columnIndex) {
            return getForegroundCellColor(tableViewerCreator, element, columnIndex);
        }
    });
    initShowMessageErrorListener(tableForGlobalMap);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) DefaultHeaderColumnSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultHeaderColumnSelectionListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArmListener(org.eclipse.swt.events.ArmListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) IUILookupMode(org.talend.designer.mapper.model.table.IUILookupMode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Color(org.eclipse.swt.graphics.Color) UIManager(org.talend.designer.mapper.managers.UIManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) Point(org.eclipse.swt.graphics.Point) InputTable(org.talend.designer.mapper.model.table.InputTable) DragNDrop(org.talend.designer.mapper.ui.dnd.DragNDrop) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) DefaultTableLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider) FocusEvent(org.eclipse.swt.events.FocusEvent) ArmEvent(org.eclipse.swt.events.ArmEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Aggregations

GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)20 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)10 ArrayList (java.util.ArrayList)8 InputTable (org.talend.designer.mapper.model.table.InputTable)8 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)7 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)6 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)6 List (java.util.List)4 Table (org.eclipse.swt.widgets.Table)4 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)4 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)4 OutputTable (org.talend.designer.mapper.model.table.OutputTable)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 FocusEvent (org.eclipse.swt.events.FocusEvent)3 FocusListener (org.eclipse.swt.events.FocusListener)3 Point (org.eclipse.swt.graphics.Point)3 GridData (org.eclipse.swt.layout.GridData)3 TableItem (org.eclipse.swt.widgets.TableItem)3