Search in sources :

Example 26 with DataMapTableView

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

the class Link method calculate.

public void calculate() {
    point1 = this.uiManager.getTableEntryPosition(pointLinkDescriptor1.getTableEntry(), true);
    point2 = this.uiManager.getTableEntryPosition(pointLinkDescriptor2.getTableEntry(), true);
    DataMapTableView viewTable1 = this.mapperManager.retrieveDataMapTableView(pointLinkDescriptor1.getTableEntry());
    DataMapTableView viewTable2 = this.mapperManager.retrieveDataMapTableView(pointLinkDescriptor2.getTableEntry());
    widthTable1 = viewTable1.getBounds().width + 2 * viewTable1.getBorderWidth();
    widthTable2 = viewTable2.getBounds().width + 2 * viewTable2.getBorderWidth();
}
Also used : DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)

Example 27 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView 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 28 with DataMapTableView

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

the class UIManager method processColumnNameChanged.

/**
     * DOC amaumont Comment method "processNewProcessColumnName".
     * 
     * @param previousColumnName TODO
     * @param dataMapTableView
     * @param text
     * @param entry
     */
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry) {
    mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
    Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
    boolean atLeastOneLinkHasBeenRemoved = false;
    for (DataMapTableView view : tableViews) {
        IDataMapTable dataMapTable = view.getDataMapTable();
        List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
        for (IColumnEntry entry : metadataTableEntries) {
            if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                atLeastOneLinkHasBeenRemoved = true;
            }
        }
        // for the input/output table expression filter
        if (dataMapTable instanceof AbstractInOutTable) {
            ExpressionFilterEntry expressionFilterEntry = ((AbstractInOutTable) dataMapTable).getExpressionFilter();
            if (expressionFilterEntry != null && expressionFilterEntry.getExpression() != null) {
                if (parseExpression(expressionFilterEntry.getExpression(), expressionFilterEntry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
        }
    }
    mapperManager.getUiManager().refreshBackground(false, false);
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
    if (atLeastOneLinkHasBeenRemoved) {
        new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {

            public void run() {
                TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
                boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(), //$NON-NLS-1$
                Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
                Messages.getString("UIManager.propagateMessage"));
                if (propagate) {
                    TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
                    TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
                    mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
                }
            }
        }).start();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) 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) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Example 29 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView 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 30 with DataMapTableView

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

the class UIManager method removeOutputTableView.

/**
     * Call mapperManager.removeSelectedOutput() to remove a table view.
     * 
     * @param dataMapTableViewToRemove
     */
public void removeOutputTableView(DataMapTableView dataMapTableViewToRemove) {
    List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        Control control = outputsTablesView.get(i);
        if (control == dataMapTableViewToRemove && i < sizeList - 1 && i > 0) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i - 1));
            break;
        }
    }
    mapperManager.removeTablePair(dataMapTableViewToRemove);
    MetadataTableEditorView outputMetaEditorView = getOutputMetaEditorView();
    if (outputMetaEditorView.getMetadataTableEditor() != null && outputMetaEditorView.getMetadataTableEditor().getMetadataTable() == ((OutputTable) dataMapTableViewToRemove.getDataMapTable()).getMetadataTable()) {
        getOutputMetaEditorView().setMetadataTableEditor(null);
    }
    dataMapTableViewToRemove.dispose();
    dataMapTableViewToRemove = null;
    getTablesZoneViewOutputs().layout();
    refreshBackground(true, false);
    this.currentSelectedOutputTableView = null;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Control(org.eclipse.swt.widgets.Control) 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) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

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