Search in sources :

Example 1 with InputTablePart

use of org.talend.designer.gefabstractmap.part.InputTablePart in project tdi-studio-se by Talend.

the class FiguresManager method onTreeSelected.

protected void onTreeSelected(List nodes, MapperTablePart selectedTreePart) {
    // selectedTreePart.setTreeOrChildSelected(true);
    /*
         * clean colors for other trees in the same zone must be executed before highlight the selected tree ,or the
         * color for LookupConnection won't be changed
         */
    List children = mapDataEditPart.getChildren();
    for (Object obj : children) {
        MapperTablePart abstractPart = null;
        if (selectedTreePart instanceof InputTablePart && obj instanceof InputTablePart) {
            abstractPart = (InputTablePart) obj;
        } else if (selectedTreePart instanceof OutputTablePart && obj instanceof OutputTablePart) {
            abstractPart = (OutputTablePart) obj;
        }
        if (abstractPart != null) {
            if (abstractPart != selectedTreePart) {
                abstractPart.highLightHeader(false);
            }
            abstractPart.updateChildrenConnections(abstractPart.getChildren(), false);
        }
    }
    selectedTreePart.highLightHeader(true);
    selectedTreePart.updateChildrenConnections(nodes, true);
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) ArrayList(java.util.ArrayList) List(java.util.List) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart)

Example 2 with InputTablePart

use of org.talend.designer.gefabstractmap.part.InputTablePart in project tdi-studio-se by Talend.

the class FiguresManager method selectionChanged.

@Override
public void selectionChanged(SelectionChangedEvent event) {
    mapDataEditPart = (MapperRootEditPart) graphicViewer.getContents();
    if (getRootEditPart() == null) {
        return;
    }
    List selectedEditParts = graphicViewer.getSelectedEditParts();
    if (selectedEditParts.isEmpty()) {
        return;
    }
    boolean outputRemoveEnable = false;
    boolean outputMoveUp = false;
    boolean outputMoveDown = false;
    boolean inputMoveUp = false;
    boolean inputMoveDown = false;
    List<MapperTable> outputTrees = getOutputTables();
    List<MapperTable> inputTrees = getInputTables();
    OutputZoneToolBar outputToolBar = mapDataEditPart.getOutputZoneToolBar();
    InputZoneToolBar inputToolBar = mapDataEditPart.getInputZoneToolBar();
    boolean selectNode = false;
    Object lastSelection = selectedEditParts.get(selectedEditParts.size() - 1);
    if (lastSelection instanceof TableEntityPart) {
        selectNode = true;
        MapperTablePart findTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
        if (findTreePart instanceof InputTablePart) {
            currentSelectedInputTable = (InputTablePart) findTreePart;
        } else if (findTreePart instanceof OutputTablePart) {
            currentSelectedOutputTable = (OutputTablePart) findTreePart;
        }
        // only change connection figures for nodes in the same tree as the lastSelection
        List<TableEntityPart> nodes = new ArrayList<TableEntityPart>();
        for (int i = 0; i < selectedEditParts.size() - 1; i++) {
            Object obj = selectedEditParts.get(i);
            if (obj instanceof TableEntityPart) {
                MapperTablePart findOtherTreePart = MapperUtils.getMapperTablePart((TableEntityPart) obj);
                if (findOtherTreePart == findTreePart) {
                    nodes.add((TableEntityPart) obj);
                }
            }
        }
        nodes.add((TableEntityPart) lastSelection);
        onTreeSelected(nodes, findTreePart);
    // change color for other unselected node in the tree;
    } else if (lastSelection instanceof OutputTablePart) {
        currentSelectedOutputTable = (OutputTablePart) lastSelection;
        onTreeSelected(currentSelectedOutputTable.getChildren(), currentSelectedOutputTable);
    } else if (lastSelection instanceof InputTablePart) {
        currentSelectedInputTable = (InputTablePart) lastSelection;
        onTreeSelected(currentSelectedInputTable.getChildren(), currentSelectedInputTable);
    }
    if (currentSelectedOutputTable != null) {
        MapperTable model = (MapperTable) currentSelectedOutputTable.getModel();
        if (!isErrorRejectTable(model)) {
            outputRemoveEnable = true;
        }
        int index = outputTrees.indexOf(model);
        if (index != -1 && index != 0) {
            if (index != 1 || !isErrorRejectTable(outputTrees.get(0))) {
                outputMoveUp = true;
            }
        }
        if (index != -1 && index != outputTrees.size() - 1) {
            if (!isErrorRejectTable(model)) {
                outputMoveDown = true;
            }
        }
    }
    outputToolBar.setRemoveButtonEnable(outputRemoveEnable);
    outputToolBar.setMoveUpEnable(outputMoveUp);
    outputToolBar.setMoveDownEnable(outputMoveDown);
    if (currentSelectedInputTable != null) {
        MapperTable tree = (MapperTable) currentSelectedInputTable.getModel();
        if (!isLookup(tree)) {
            inputMoveUp = false;
            inputMoveDown = false;
        } else {
            int indexOf = inputTrees.indexOf(tree);
            if (indexOf != -1 && indexOf > 1) {
                inputMoveUp = true;
            }
            if (indexOf > 0 && indexOf != inputTrees.size() - 1) {
                inputMoveDown = true;
            }
        }
    }
    inputToolBar.setMoveDownEnable(inputMoveDown);
    inputToolBar.setMoveUpEnable(inputMoveUp);
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) OutputZoneToolBar(org.talend.designer.gefabstractmap.figures.treetools.zone.OutputZoneToolBar) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) ArrayList(java.util.ArrayList) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) InputZoneToolBar(org.talend.designer.gefabstractmap.figures.treetools.zone.InputZoneToolBar) MapperTable(org.talend.designer.gefabstractmap.model.abstractmap.MapperTable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with InputTablePart

use of org.talend.designer.gefabstractmap.part.InputTablePart in project tdi-studio-se by Talend.

the class MapperGraphicalEditor method makeDefaultSelection.

public void makeDefaultSelection() {
    EditPart contents = getGraphicalViewer().getContents();
    if (contents instanceof MapperRootEditPart) {
        MapperRootEditPart mapdataPart = (MapperRootEditPart) contents;
        List children = mapdataPart.getChildren();
        InputTablePart firstInputPart = null;
        OutputTablePart firstOutputPart = null;
        if (children != null) {
            for (int i = 0; i < children.size(); i++) {
                Object object = children.get(i);
                if (object instanceof InputTablePart && firstInputPart == null) {
                    firstInputPart = (InputTablePart) object;
                }
                if (object instanceof OutputTablePart && firstOutputPart == null) {
                    firstOutputPart = (OutputTablePart) object;
                }
                if (firstInputPart != null && firstOutputPart != null) {
                    break;
                }
            }
            if (firstInputPart != null) {
                getGraphicalViewer().appendSelection(firstInputPart);
            }
            if (firstOutputPart != null) {
                getGraphicalViewer().appendSelection(firstOutputPart);
            }
        }
    }
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) EventObject(java.util.EventObject) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart)

Example 4 with InputTablePart

use of org.talend.designer.gefabstractmap.part.InputTablePart in project tdi-studio-se by Talend.

the class MapperGraphicalViewer method primDeselectAll.

/*
     * if partToAppend is inputTree , don't clean all outputTree in selection list , leave the first one by default . if
     * partToAppend is outputTree , do the same for inputTree selections
     */
private void primDeselectAll(EditPart eidtPart) {
    EditPart partToAppend = eidtPart;
    List list = primGetSelectedEditParts();
    if (partToAppend instanceof TableEntityPart) {
        partToAppend = MapperUtils.getMapperTablePart((TableEntityPart) partToAppend);
    }
    EditPart part;
    MapperTablePart abstractTreePart = null;
    for (int i = 0; i < list.size(); i++) {
        part = (EditPart) list.get(i);
        if (partToAppend instanceof InputTablePart) {
            if (abstractTreePart == null && part instanceof OutputTablePart) {
                abstractTreePart = (MapperTablePart) part;
                continue;
            }
        } else if (partToAppend instanceof OutputTablePart) {
            if (abstractTreePart == null && part instanceof InputTablePart) {
                abstractTreePart = (MapperTablePart) part;
                continue;
            }
        }
        part.setSelected(EditPart.SELECTED_NONE);
    }
    list.clear();
    if (abstractTreePart != null) {
        list.add(abstractTreePart);
    }
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart)

Example 5 with InputTablePart

use of org.talend.designer.gefabstractmap.part.InputTablePart in project tdi-studio-se by Talend.

the class ConnectionColumnAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    if (connectionPart == null) {
        return getOwner().getBounds().getLeft();
    }
    MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
    boolean loctionRight = false;
    if (mapperTablePart instanceof InputTablePart) {
        loctionRight = true;
    }
    Point ref = null;
    if (mapperTablePart != null && entityManager.isTableMinimized()) {
        if (loctionRight) {
            ref = mapperTablePart.getFigure().getBounds().getRight();
        } else {
            ref = mapperTablePart.getFigure().getBounds().getLeft();
        }
    } else {
        if (getOwner() == null) {
            return null;
        } else if (getOwner() instanceof TableTreeEntityFigure) {
            TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
            if (nodeFigure.getElement() != null) {
                if (loctionRight) {
                    ref = nodeFigure.getElement().getBounds().getRight();
                } else {
                    ref = nodeFigure.getElement().getBounds().getLeft();
                }
                getOwner().translateToAbsolute(ref);
            }
        } else {
            ref = getOwner().getBounds().getCenter();
            getOwner().translateToAbsolute(ref);
        }
    }
    if (mapperTablePart != null && ref != null) {
        IFigure treeFigure = mapperTablePart.getFigure();
        if (loctionRight) {
            int avialableX = treeFigure.getBounds().getRight().x;
            if (ref.x > avialableX) {
                ref.x = avialableX;
            }
        } else {
            int avialableX = treeFigure.getBounds().x;
            if (ref.x < avialableX) {
                ref.x = avialableX;
            }
        }
    }
    if (connectionPart instanceof BaseConnectionEditPart && connectionPart.getFigure() instanceof PolylineConnection) {
        BaseConnectionEditPart baseConnectionPart = (BaseConnectionEditPart) connectionPart;
        PolylineConnection connFigure = (PolylineConnection) connectionPart.getFigure();
        org.eclipse.swt.graphics.Point avilableSize = entityManager.getGraphicalViewer().getControl().getSize();
        if (forceDarshDot) {
            connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
        } else if (ref != null) {
            if (ref.y < 0) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = 0;
                }
                if (loctionRight) {
                    baseConnectionPart.setSourceConcained(false);
                } else {
                    baseConnectionPart.setTargetContained(false);
                }
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else if (ref.y > avilableSize.y) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = avilableSize.y;
                }
                if (loctionRight) {
                    baseConnectionPart.setSourceConcained(false);
                } else {
                    baseConnectionPart.setTargetContained(false);
                }
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else {
                if (loctionRight) {
                    baseConnectionPart.setSourceConcained(true);
                } else {
                    baseConnectionPart.setTargetContained(true);
                }
                if (!baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            }
        }
    }
    return ref;
}
Also used : TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) Point(org.eclipse.draw2d.geometry.Point) PolylineConnection(org.eclipse.draw2d.PolylineConnection) LookupConnectionPart(org.talend.designer.gefabstractmap.part.LookupConnectionPart) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)

Aggregations

InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)6 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)5 List (java.util.List)4 OutputTablePart (org.talend.designer.gefabstractmap.part.OutputTablePart)4 ArrayList (java.util.ArrayList)2 IFigure (org.eclipse.draw2d.IFigure)2 PolylineConnection (org.eclipse.draw2d.PolylineConnection)2 Point (org.eclipse.draw2d.geometry.Point)2 EditPart (org.eclipse.gef.EditPart)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)2 MapperRootEditPart (org.talend.designer.gefabstractmap.part.MapperRootEditPart)2 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)2 EventObject (java.util.EventObject)1 InputZoneToolBar (org.talend.designer.gefabstractmap.figures.treetools.zone.InputZoneToolBar)1 OutputZoneToolBar (org.talend.designer.gefabstractmap.figures.treetools.zone.OutputZoneToolBar)1 MapperTable (org.talend.designer.gefabstractmap.model.abstractmap.MapperTable)1 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)1