Search in sources :

Example 1 with MapperTablePart

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

the class LookupColumnAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    if (connectionPart == null) {
        return getOwner().getBounds().getLeft();
    }
    MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
    Point ref = null;
    if (mapperTablePart != null && entityManager.isTableMinimized()) {
        ref = mapperTablePart.getFigure().getBounds().getLeft();
    } else {
        if (getOwner() == null) {
            return null;
        } else if (getOwner() instanceof TableEntityFigure) {
            TableEntityFigure nodeFigure = (TableEntityFigure) getOwner();
            if (nodeFigure.getElement() != null) {
                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();
        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 (ref != null) {
            if (ref.y < 0) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = 0;
                }
                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;
                }
                baseConnectionPart.setTargetContained(false);
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else {
                baseConnectionPart.setTargetContained(true);
                if (!baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            }
        }
    }
    return ref;
}
Also used : Point(org.eclipse.draw2d.geometry.Point) LookupConnectionPart(org.talend.designer.gefabstractmap.part.LookupConnectionPart) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 2 with MapperTablePart

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

the class MapperSelectEditPartTracker method getShiftAffactedEditPart.

private void getShiftAffactedEditPart(List toSelect, List deSelect) {
    if (lastSelectedShiftPart == null || lastSelectedShiftPart == getSourceEditPart()) {
        toSelect.add(getSourceEditPart());
        return;
    }
    List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
    if (lastSelectedShiftPart instanceof TableEntityPart) {
        MapperTablePart treePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelectedShiftPart);
        if (treePart != null) {
            partList = MapperUtils.getFlatChildrenPartList(treePart);
        }
    }
    int index = partList.indexOf(lastSelectedShiftPart);
    int index2 = partList.indexOf(getSourceEditPart());
    if (index2 != -1) {
        for (int i = Math.min(index, index2); i < Math.max(index, index2) + 1; i++) {
            if (!toSelect.contains(partList.get(i))) {
                toSelect.add(partList.get(i));
            }
        }
        List selectedEditParts = getCurrentViewer().getSelectedEditParts();
        for (int i = 0; i < selectedEditParts.size(); i++) {
            if (partList.contains(selectedEditParts.get(i)) && !toSelect.contains(selectedEditParts.get(i))) {
                deSelect.add(selectedEditParts.get(i));
            }
        }
    }
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart)

Example 3 with MapperTablePart

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

the class DragAndDropEditPolicy method getCommand.

@Override
public Command getCommand(Request request) {
    if (request instanceof CreateNodeConnectionRequest) {
        CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
        EditPart targetEditPart = rq.getTargetEditPart();
        Command command = null;
        if (targetEditPart != null && TemplateTransfer.getInstance().getObject() instanceof TransferedObject) {
            TransferedObject toDrop = (TransferedObject) TemplateTransfer.getInstance().getObject();
            MapperManager manager = ((XmlMapGraphicViewer) targetEditPart.getViewer()).getMapperManager();
            if (manager != null && manager.getExternalData() != null) {
                DropType dropType = rq.getNewObjectType();
                if (dropType != null) {
                    switch(dropType) {
                        case DROP_FILTER:
                            if (targetEditPart instanceof MapperTablePart) {
                                command = new UpdateFilterExpressionCommand(toDrop, (MapperTablePart) targetEditPart, manager.getExternalData());
                            }
                            break;
                        case DROP_EXPRESSION:
                            if (targetEditPart instanceof TableEntityPart) {
                                command = new UpdateExpressionCommand(toDrop, (TableEntityPart) targetEditPart, manager);
                            }
                            break;
                        case DROP_OUTPUT_DOC_CHILD:
                            if (targetEditPart instanceof OutputTreeNodeEditPart && rq.getNewObject() instanceof OutputTreeNode) {
                                command = new CreateDocChildrenCommand(toDrop, (OutputTreeNodeEditPart) targetEditPart, rq, manager);
                            }
                            break;
                        case DROP_INSERT_OUTPUT:
                        case DROP_INSERT_VAR:
                        case DROP_INSERT_INPUT:
                            command = new InsertNewColumnCommand(toDrop, targetEditPart, rq, manager, dropType);
                        default:
                            break;
                    }
                }
            }
        }
        if (command != null) {
            return command;
        }
    // drop expression
    // boolean update = rq.getDropType() == CreateNodeConnectionRequest.DROP_EXPRESSION ? true : false;
    // return new CreateNodeAndConnectionCommand(rq.getNewObject(), rq.getTargetEditPart(), update);
    }
    return super.getCommand(request);
}
Also used : MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) CreateDocChildrenCommand(org.talend.designer.xmlmap.commands.CreateDocChildrenCommand) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) EditPart(org.eclipse.gef.EditPart) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) UpdateExpressionCommand(org.talend.designer.xmlmap.commands.UpdateExpressionCommand) Command(org.eclipse.gef.commands.Command) InsertNewColumnCommand(org.talend.designer.xmlmap.commands.InsertNewColumnCommand) UpdateFilterExpressionCommand(org.talend.designer.xmlmap.commands.UpdateFilterExpressionCommand) CreateDocChildrenCommand(org.talend.designer.xmlmap.commands.CreateDocChildrenCommand) UpdateExpressionCommand(org.talend.designer.xmlmap.commands.UpdateExpressionCommand) CreateNodeConnectionRequest(org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest) UpdateFilterExpressionCommand(org.talend.designer.xmlmap.commands.UpdateFilterExpressionCommand) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) DropType(org.talend.designer.xmlmap.dnd.DropType) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) InsertNewColumnCommand(org.talend.designer.xmlmap.commands.InsertNewColumnCommand) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 4 with MapperTablePart

use of org.talend.designer.gefabstractmap.part.MapperTablePart 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 5 with MapperTablePart

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

the class RowSelectionEditPolicy method getLocatorFigure.

private IFigure getLocatorFigure(GraphicalEditPart owner) {
    IFigure figure = owner.getFigure();
    if (owner instanceof TableEntityPart) {
        TableEntityFigure treeNodeFigure = (TableEntityFigure) figure;
        // table figure to restrict the width
        MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) owner);
        IFigure parentFigure = ((GraphicalEditPart) abstractInOutTreePart).getFigure();
        Rectangle treeBounds = parentFigure.getBounds();
        Rectangle rowBounds = treeNodeFigure.getElement().getBounds();
        Rectangle treeNodeBounds = figure.getBounds();
        figure = new Figure();
        if (treeBounds.x + 1 != treeNodeBounds.x || treeNodeBounds.width > treeBounds.width) {
            figure.setBounds(new Rectangle(treeBounds.x + 1, treeNodeBounds.y, treeBounds.width - 2, rowBounds.height));
            return figure;
        } else {
            figure.setBounds(owner.getFigure().getBounds().getCopy());
            figure.getBounds().height = rowBounds.height;
            return figure;
        }
    } else if (figure instanceof VarEntityFigure) {
        Rectangle copy = figure.getBounds().getCopy();
        figure = new Figure();
        figure.setBounds(copy);
        return figure;
    }
    return owner.getFigure();
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) IFigure(org.eclipse.draw2d.IFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure)

Aggregations

MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)14 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)7 List (java.util.List)6 ArrayList (java.util.ArrayList)5 IFigure (org.eclipse.draw2d.IFigure)5 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)5 Point (org.eclipse.draw2d.geometry.Point)4 EditPart (org.eclipse.gef.EditPart)4 PolylineConnection (org.eclipse.draw2d.PolylineConnection)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)3 OutputTablePart (org.talend.designer.gefabstractmap.part.OutputTablePart)3 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 Composite (org.eclipse.swt.widgets.Composite)2 Control (org.eclipse.swt.widgets.Control)2 Text (org.eclipse.swt.widgets.Text)2 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)2 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)2