Search in sources :

Example 26 with DataMapTableView

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

the class UIManager method refreshInOutTableAndMetaTable.

/**
     * DOC amaumont Comment method "refreshInOutTableAndMetaTable".
     * 
     * @param currentModifiedTableEntry can be null
     */
private void refreshInOutTableAndMetaTable(AbstractInOutTableEntry currentModifiedTableEntry) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedTableEntry);
    IMetadataTable metadataTableTarget = ((AbstractInOutTable) dataMapTableView.getDataMapTable()).getMetadataTable();
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedTableEntry);
    MetadataTableEditorView metadataEditorView = getMetadataEditorView(dataMapTableView.getZone());
    if (metadataEditorView != null && metadataEditorView.getMetadataTableEditor() != null && metadataEditorView.getMetadataTableEditor().getMetadataTable() == metadataTableTarget) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh(currentModifiedTableEntry.getMetadataColumn());
        metadataEditorView.getTableViewerCreator().refreshTableEditorControls();
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 27 with DataMapTableView

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

the class UIManager method removeInputTableView.

/**
     * Call mapperManager.removeSelectedOutput() to remove a table view.
     * 
     * @param dataMapTableViewToRemove
     */
public void removeInputTableView(InputDataMapTableView dataMapTableViewToRemove) {
    List<DataMapTableView> outputsTablesView = getInputsTablesView();
    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 = getInputMetaEditorView();
    if (outputMetaEditorView.getMetadataTableEditor().getMetadataTable() == ((InputTable) dataMapTableViewToRemove.getDataMapTable()).getMetadataTable()) {
        getInputMetaEditorView().setMetadataTableEditor(null);
    }
    dataMapTableViewToRemove.dispose();
    dataMapTableViewToRemove = null;
    getTablesZoneViewInputs().layout();
    refreshBackground(true, false);
    setCurrentSelectedInputTableView(null);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Control(org.eclipse.swt.widgets.Control) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 28 with DataMapTableView

use of org.talend.designer.dbmap.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 renamingDependentEntries TODO
     * @param text
     * @param entry
     */
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry, boolean renamingDependentEntries) {
    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;
            }
        }
        if (dataMapTable instanceof OutputTable) {
            List<FilterTableEntry> constraintWhereEntries = ((OutputTable) dataMapTable).getWhereFilterEntries();
            for (FilterTableEntry entry : constraintWhereEntries) {
                if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
            List<FilterTableEntry> constraintOtherEntries = ((OutputTable) dataMapTable).getOtherFilterEntries();
            for (FilterTableEntry entry : constraintOtherEntries) {
                if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
        }
    }
    mapperManager.getUiManager().refreshBackground(false, false);
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
    TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
    TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
    mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
    refreshSqlExpression();
    if (!renamingDependentEntries) {
        AbstractInOutTable currentTable = (AbstractInOutTable) currentModifiedITableEntry.getParent();
        if (currentTable instanceof InputTable) {
            InputTable currentInputTable = (InputTable) currentTable;
            String physicalTableName = currentInputTable.getTableName();
            String alias = currentInputTable.getAlias();
            InputTable physicalInputTable = null;
            List<InputTable> inputTables = mapperManager.getInputTables();
            if (alias != null) {
                for (InputTable table : inputTables) {
                    if (table.equals(physicalTableName)) {
                        physicalInputTable = table;
                    }
                }
            } else {
                physicalInputTable = currentInputTable;
            }
            if (physicalInputTable == null) {
                List<IOConnection> incomingConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
                IOConnection connectionFound = null;
                for (IOConnection connection : incomingConnections) {
                    if (connection.getName().equals(physicalTableName)) {
                        connectionFound = connection;
                    }
                }
                IMetadataColumn metadataColumn = connectionFound.getTable().getColumn(previousColumnName);
                if (metadataColumn != null) {
                    metadataColumn.setLabel(newColumnName);
                }
            }
            for (InputTable table : inputTables) {
                if ((// Physical table parent
                alias != null && table.getAlias() == null && table.getName().equals(physicalTableName) || // Alias table
                alias == null && table.getAlias() != null && table.getTableName().equals(physicalTableName))) {
                    TableEntryLocation location = new TableEntryLocation(table.getName(), previousColumnName);
                    DataMapTableView aliasTableView = mapperManager.retrieveDataMapTableView(location);
                    ITableEntry aliasTableEntry = mapperManager.retrieveTableEntry(location);
                    if (aliasTableEntry != null) {
                        processColumnNameChanged(previousColumnName, newColumnName, aliasTableView, aliasTableEntry, true);
                    }
                }
            }
        }
    }
// if (atLeastOneLinkHasBeenRemoved) {
// new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
//
// public void run() {
// TableViewerCreator tableViewerCreatorForColumns = dataMapTableView
// .getTableViewerCreatorForColumns();
// boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(),
// Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
// Messages.getString("UIManager.propagateMessage")); //$NON-NLS-1$
// if (propagate) {
// TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), previousColumnName);
// TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), newColumnName);
// mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
// refreshSqlExpression();
// }
// }
// }).start();
// }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation)

Example 29 with DataMapTableView

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

the class TableManager method removeTable.

/**
     * DOC amaumont Comment method "removeTable".
     * 
     * @param dataTable
     */
Object removeTable(IDataMapTable dataTable) {
    List<IColumnEntry> dataMapTableEntries = dataTable.getColumnEntries();
    TableEntriesManager tableEntriesManager = mapperManager.getTableEntriesManager();
    tableEntriesManager.removeAll(dataMapTableEntries, isPhysicalInputTable(dataTable.getName()));
    if (dataTable instanceof OutputTable) {
        List<FilterTableEntry> whereConstraintEntries = ((OutputTable) dataTable).getWhereFilterEntries();
        tableEntriesManager.removeAll(whereConstraintEntries, false);
        List<FilterTableEntry> otherConstraintEntries = ((OutputTable) dataTable).getOtherFilterEntries();
        tableEntriesManager.removeAll(otherConstraintEntries, false);
    }
    getMatchedList(dataTable).remove(dataTable);
    DataMapTableView view = abstractDataMapTableToView.remove(dataTable);
    swtTableToView.remove(view.getTableViewerCreatorForColumns().getTable());
    if (view.getTableViewerCreatorForWhereFilters() != null) {
        swtTableToView.remove(view.getTableViewerCreatorForWhereFilters().getTable());
    }
    if (view.getTableViewerCreatorForOtherFilters() != null) {
        swtTableToView.remove(view.getTableViewerCreatorForOtherFilters().getTable());
    }
    return view;
}
Also used : FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 30 with DataMapTableView

use of org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView 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 selectedMetadataTableEntries, source or targets entries which must be highlighted, can be null to select
     * all links of a same DataMapTableView
     * @param isFilterTableSelected TODO
     * @param forceResetHighlightLinksForOtherTables TODO
     */
@SuppressWarnings("unchecked")
public void selectLinks(DataMapTableView dataMapTableView, List<ITableEntry> selectedMetadataTableEntries, boolean isFilterTableSelected, boolean forceResetHighlightLinksForOtherTables) {
    boolean selectColumnAndFiltersLinks = (selectedMetadataTableEntries == null);
    UIManager uiManager = mapperManager.getUiManager();
    TableViewerCreator<ITableEntry> currentTableViewer = null;
    TableViewerCreator<ITableEntry> whereFilterCreator = null;
    TableViewerCreator<ITableEntry> otherFilterCreator = null;
    if (isFilterTableSelected) {
        currentTableViewer = dataMapTableView.getTableViewerCreatorForWhereFilters();
    } 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 (selectColumnAndFiltersLinks) {
        hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForColumns().getInputList());
        if (currentZone == Zone.OUTPUTS) {
            hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForWhereFilters().getInputList());
            hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForOtherFilters().getInputList());
        }
    } else {
        hashSelectedMetadataTableEntries.addAll(selectedMetadataTableEntries);
    }
    // ////////////////////////////////////////////////////////////////////////
    // 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 && currentZone == Zone.OUTPUTS || currentZone == Zone.INPUTS && previousSelectedZone == Zone.OUTPUTS;
    boolean tableTypeHasChanged = previousSelectedTableIsConstraint != isFilterTableSelected && currentZone == Zone.OUTPUTS;
    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);
                tableItem.setBackground(unselectedColor);
                ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
                tableItem = mapperManager.retrieveTableItem(targetITableEntry);
                tableItem.setBackground(unselectedColor);
            }
        }
        if (currentZone == Zone.INPUTS) {
            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();
                } else {
                    viewToDeselectEntries.unselectAllConstraintEntries();
                }
            }
        }
    }
    // ////////////////////////////////////////////////////////////////////////
    // ////////////////////////////////////////////////////////////////////////
    // Select or unselect links and tableEntries
    List<ITableEntry> allEntriesOfCurrentTableView = new ArrayList<ITableEntry>();
    if (currentTableViewer != null) {
        allEntriesOfCurrentTableView.addAll(currentTableViewer.getInputList());
        if (selectColumnAndFiltersLinks && currentZone == Zone.OUTPUTS) {
            allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForWhereFilters().getInputList());
            allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForOtherFilters().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;
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) OutputsZone(org.talend.designer.dbmap.ui.visualmap.zone.OutputsZone) InputsZone(org.talend.designer.dbmap.ui.visualmap.zone.InputsZone) Zone(org.talend.designer.dbmap.ui.visualmap.zone.Zone) ToolbarInputZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarInputZone) ToolbarOutputZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarOutputZone) ToolbarZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarZone) Color(org.eclipse.swt.graphics.Color) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.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.dbmap.ui.visualmap.table.EntryState) HashSet(java.util.HashSet)

Aggregations

DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)35 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)24 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)24 Point (org.eclipse.swt.graphics.Point)12 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)7 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)7 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)7 InputTable (org.talend.designer.dbmap.model.table.InputTable)6 FormData (org.eclipse.swt.layout.FormData)5 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)5 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 UIManager (org.talend.designer.dbmap.managers.UIManager)5 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)5 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)5 TablesZoneView (org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView)5 ArrayList (java.util.ArrayList)4 Control (org.eclipse.swt.widgets.Control)4 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)4 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)4