Search in sources :

Example 31 with DataMapTableView

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

the class UIManager method moveSelectedTableDown.

private void moveSelectedTableDown(DataMapTableView currentSelectedTableView, List<DataMapTableView> tablesView, int indexStartMovedAuthorized) {
    int indexCurrentTable = tablesView.indexOf(currentSelectedTableView);
    if (indexCurrentTable < indexStartMovedAuthorized || indexCurrentTable == tablesView.size() - 1) {
        return;
    }
    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);
    mapperManager.getProblemsManager().checkProblemsForAllEntries(currentSelectedTableView, true);
    mapperManager.getProblemsManager().checkProblemsForAllEntries(nextTableView, true);
}
Also used : FormData(org.eclipse.swt.layout.FormData) 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)

Example 32 with DataMapTableView

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

the class MapperManager method addInputAliasTable.

/**
     * DOC amaumont Comment method "addAlias".
     */
public void addInputAliasTable() {
    AliasDialog aliasDialog = new AliasDialog(this, tableManager.getPhysicalInputTableNames(), tableManager.getAliases(), tableManager.getVisibleTables());
    if (!aliasDialog.open()) {
        return;
    }
    List<IOConnection> incomingConnections = getComponent().getMapperMain().getIoInputConnections();
    IOConnection connectionFound = null;
    for (IOConnection connection : incomingConnections) {
        if (connection.getName().equalsIgnoreCase(aliasDialog.getTableName())) {
            connectionFound = connection;
            break;
        }
    }
    List<DataMapTableView> inputsTablesView = getUiManager().getInputsTablesView();
    int sizeOutputsView = inputsTablesView.size();
    Control lastChild = null;
    if (sizeOutputsView - 1 >= 0) {
        lastChild = inputsTablesView.get(sizeOutputsView - 1);
    }
    String alias = aliasDialog.getAlias();
    //$NON-NLS-1$
    boolean isPhysicalTable = alias.equals("") || alias.equalsIgnoreCase(aliasDialog.getTableName());
    String aliasOrTableName = isPhysicalTable ? aliasDialog.getTableName() : alias;
    IMetadataTable metadataTable = isPhysicalTable ? connectionFound.getTable() : connectionFound.getTable().clone();
    boolean isInvisiblePhysicalTable = aliasDialog.isSameAsPhysicalTable(aliasOrTableName) && !aliasDialog.isSameAsVisibleTableName(aliasOrTableName);
    InputTable inputTable = new InputTable(this, metadataTable, aliasOrTableName);
    if (isInvisiblePhysicalTable) {
        inputTable.setAlias(null);
    } else {
        inputTable.setAlias(aliasOrTableName);
    }
    inputTable.setTableName(aliasDialog.getTableName());
    inputTable.initFromExternalData(null);
    TablesZoneView tablesZoneViewInputs = uiManager.getTablesZoneViewInputs();
    DataMapTableView dataMapTableView = uiManager.createNewInputTableView(lastChild, inputTable, tablesZoneViewInputs);
    tablesZoneViewInputs.setSize(tablesZoneViewInputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewInputs.layout(true, true);
    uiManager.moveInputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    tablesZoneViewInputs.layout();
    uiManager.selectDataMapTableView(dataMapTableView, true, false);
    uiManager.updateDropDownJoinTypeForInputs();
    uiManager.parseAllExpressionsForAllTables();
    uiManager.refreshSqlExpression();
    getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) Control(org.eclipse.swt.widgets.Control) AliasDialog(org.talend.designer.dbmap.ui.dialog.AliasDialog) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) 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) TablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView)

Example 33 with DataMapTableView

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

the class MapperManager method replaceLocation.

/**
     * 
     * DOC amaumont Comment method "replaceLocation".
     * 
     * @param previousLocation
     * @param newLocation
     * @param dataMapExpressionParser
     * @param table
     * @param entry
     * @return true if expression of entry has changed
     */
private boolean replaceLocation(final TableEntryLocation previousLocation, final TableEntryLocation newLocation, DataMapExpressionParser dataMapExpressionParser, IDataMapTable table, ITableEntry entry) {
    boolean expressionHasChanged = false;
    String currentExpression = entry.getExpression();
    TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(currentExpression);
    // loop on all locations of current expression
    for (TableEntryLocation currentLocation : tableEntryLocations) {
        if (currentLocation.equals(previousLocation)) {
            currentExpression = dataMapExpressionParser.replaceLocation(currentExpression, previousLocation, newLocation);
            expressionHasChanged = true;
        }
    }
    if (expressionHasChanged) {
        entry.setExpression(currentExpression);
        DataMapTableView dataMapTableView = retrieveIDataMapTableView(table);
        TableViewerCreator tableViewerCreator = null;
        if (entry instanceof IColumnEntry) {
            tableViewerCreator = dataMapTableView.getTableViewerCreatorForColumns();
        } else if (entry instanceof FilterTableEntry) {
            if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) entry).getFilterKind())) {
                tableViewerCreator = dataMapTableView.getTableViewerCreatorForOtherFilters();
            } else {
                tableViewerCreator = dataMapTableView.getTableViewerCreatorForWhereFilters();
            }
        }
        tableViewerCreator.getTableViewer().refresh(entry);
        uiManager.parseExpression(currentExpression, entry, false, true, false);
        return true;
    }
    return false;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) 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) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry)

Example 34 with DataMapTableView

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

the class UIManager method unregisterCustomPaint.

public void unregisterCustomPaint() {
    List<DataMapTableView> tablesView = getOutputsTablesView();
    tablesView.addAll(getInputsTablesView());
    for (DataMapTableView view : tablesView) {
        view.getTableViewerCreatorForColumns().setUseCustomItemColoring(false);
    }
}
Also used : 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)

Example 35 with DataMapTableView

use of org.talend.designer.dbmap.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 = getInputsTablesView();
        int indexCurrentTable = tablesView.indexOf(currentSelectedInputTableView);
        if (moveUp) {
            if (indexCurrentTable > 0) {
                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 = getOutputsTablesView();
        int indexCurrentTable = tablesView.indexOf(currentSelectedOutputTableView);
        if (moveUp) {
            if (indexCurrentTable > 0) {
                return true;
            }
            return false;
        } else {
            if (indexCurrentTable < tablesView.size() - 1) {
                return true;
            }
            return false;
        }
    }
    return false;
}
Also used : 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) List(java.util.List) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point)

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