Search in sources :

Example 11 with DataMapTableView

use of org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView 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) {
    TableEntryProperties tableEntryProperties = mapperManager.getTableEntryProperties(tableEntry);
    Point returnedPoint = tableEntryProperties.position;
    if (forceRecalculate || returnedPoint == null) {
        TableItem tableItem = mapperManager.retrieveTableItem(tableEntry);
        DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
        Rectangle tableViewBounds = dataMapTableView.getBounds();
        Table table = tableItem.getParent();
        // FIX for issue 1225 ("1" parameter added)
        Rectangle boundsTableItem = tableItem.getBounds(1);
        int x = 0;
        int y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
        if (y < 0) {
            y = 0;
        }
        Point point = new Point(x, y);
        Display display = dataMapTableView.getDisplay();
        Point pointFromTableViewOrigin = display.map(tableItem.getParent(), dataMapTableView, point);
        if (pointFromTableViewOrigin.y > tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION) {
            pointFromTableViewOrigin.y = tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION;
        }
        returnedPoint = convertPointToReferenceOrigin(getReferenceComposite(), pointFromTableViewOrigin, dataMapTableView);
        tableEntryProperties.position = returnedPoint;
    }
    return returnedPoint;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) Table(org.eclipse.swt.widgets.Table) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) 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) TableEntryProperties(org.talend.designer.dbmap.ui.visualmap.TableEntryProperties) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 12 with DataMapTableView

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

the class TableEntriesManager method retrieveTableItem.

TableItem retrieveTableItem(ITableEntry dataMapTableEntry) {
    DataMapTableView dataMapTableView = this.mapperManager.retrieveIDataMapTableView(dataMapTableEntry.getParent());
    TableItem[] tableItems = new TableItem[0];
    if (dataMapTableEntry instanceof IColumnEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
    } else if (dataMapTableEntry instanceof FilterTableEntry) {
        if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
            tableItems = dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().getItems();
        } else {
            tableItems = dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().getItems();
        }
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("TableEntriesManager.exceptionMessage.caseNotFound"));
    }
    TableItem tableItem = null;
    for (TableItem tableItem2 : tableItems) {
        if (tableItem2.getData() == dataMapTableEntry) {
            tableItem = tableItem2;
            break;
        }
    }
    getTableEntryProperties(dataMapTableEntry).setTableItem(tableItem);
    return tableItem;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) 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)

Example 13 with DataMapTableView

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

the class UIManager method minimizeAllTables.

public void minimizeAllTables(Zone zone, boolean minimize, ToolItem minimizeButton) {
    List<DataMapTableView> tablesView = null;
    TablesZoneView tablesZoneView = null;
    if (zone == Zone.INPUTS) {
        tablesView = getInputsTablesView();
        tablesZoneView = getTablesZoneViewInputs();
    } else if (zone == Zone.OUTPUTS) {
        tablesZoneView = getTablesZoneViewOutputs();
        tablesView = getOutputsTablesView();
    } else {
        //$NON-NLS-1$
        throw new RuntimeException("Case not found:" + zone);
    }
    Layout layout = tablesZoneView.getLayout();
    try {
        tablesZoneView.setLayout(null);
        for (DataMapTableView view : tablesView) {
            view.minimizeTable(minimize);
        }
    } catch (RuntimeException e) {
        ExceptionHandler.process(e);
    } finally {
        tablesZoneView.setLayout(layout);
    }
    tablesZoneView.layout();
    for (DataMapTableView view : tablesView) {
        view.layout();
    }
    resizeTablesZoneViewAtComputedSize(zone);
    moveScrollBarZoneAtSelectedTable(zone);
}
Also used : Layout(org.eclipse.swt.widgets.Layout) 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 14 with DataMapTableView

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

the class UIManager method parseExpression.

/**
     * 
     * 
     * @param expression
     * @param currentModifiedITableEntry
     * @param linkMustHaveSelectedState
     * @param checkInputKeyAutomatically TODO
     * @param inputExpressionAppliedOrCanceled TODO
     * @param newSelectedDataMapTableView
     * @return true if a link has been added or removed, false else
     */
public ParseExpressionResult parseExpression(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
    boolean linkHasBeenAdded = false;
    boolean linkHasBeenRemoved = false;
    DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(mapperManager.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;
    for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
        TableEntryLocation location = tableEntriesLocationsSource;
        if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry)) {
            ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
            sourcesForTargetToDelete.remove(sourceTableEntry);
            if (sourceTableEntry != null && !sourcesForTarget.contains(sourceTableEntry)) {
                DataMapTableView sourceDataMapTableView = mapperManager.retrieveDataMapTableView(sourceTableEntry);
                IMapperLink link = new Link(new PointLinkDescriptor(sourceTableEntry, sourceDataMapTableView.getZone()), new PointLinkDescriptor(currentModifiedITableEntry, dataMapTableView.getZone()), mapperManager);
                link.setState(linkMustHaveSelectedState ? LinkState.SELECTED : LinkState.UNSELECTED);
                mapperManager.addLink(link);
                linkHasBeenAdded = true;
            }
            alreadyProcessed.add(location);
        }
    }
    Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
    Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
    for (IMapperLink link : linksFromTarget) {
        if (sourcesForTargetToDelete.contains(link.getPointLinkDescriptor1().getTableEntry())) {
            mapperManager.removeLink(link, link.getPointLinkDescriptor2().getTableEntry());
            linkHasBeenRemoved = true;
        }
    }
    mapperManager.orderLinks();
    return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
Also used : PointLinkDescriptor(org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) 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) ParseExpressionResult(org.talend.designer.dbmap.utils.ParseExpressionResult) DataMapExpressionParser(org.talend.designer.dbmap.utils.DataMapExpressionParser) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry) Link(org.talend.designer.dbmap.ui.visualmap.link.Link) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) HashSet(java.util.HashSet)

Example 15 with DataMapTableView

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

the class UIManager method unselectAllEntriesOfAllTables.

public void unselectAllEntriesOfAllTables() {
    List<DataMapTableView> tablesView = getOutputsTablesView();
    tablesView.addAll(getInputsTablesView());
    tablesView.addAll(getVarsTablesView());
    for (DataMapTableView view : tablesView) {
        view.unselectAllEntries();
    }
}
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)

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