Search in sources :

Example 1 with CreateNodeConnectionRequest

use of org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest 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 2 with CreateNodeConnectionRequest

use of org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest in project tdi-studio-se by Talend.

the class DragAndDropEditPolicy method eraseTargetFeedback.

@Override
public void eraseTargetFeedback(Request request) {
    if (indicator != null) {
        if (request instanceof CreateNodeConnectionRequest) {
            CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
            AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
            if (targetEditPart != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
                try {
                    getFeedbackLayer().remove(indicator);
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
}
Also used : CreateNodeConnectionRequest(org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart)

Example 3 with CreateNodeConnectionRequest

use of org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest in project tdi-studio-se by Talend.

the class DragAndDropEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request instanceof CreateNodeConnectionRequest) {
        CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
        AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
        // show feedback when insert new column
        if (rq.getNewObjectType() != null && targetEditPart != null) {
            Object model = targetEditPart.getModel();
            switch(rq.getNewObjectType()) {
                case DROP_INSERT_OUTPUT:
                case DROP_INSERT_VAR:
                    if (model instanceof OutputTreeNode || model instanceof VarNode) {
                        IFigure targetFigure = targetEditPart.getFigure();
                        if (targetFigure != null) {
                            if (indicator == null) {
                                indicator = new InsertionIndicator();
                            }
                            Rectangle copy = targetFigure.getBounds().getCopy();
                            Rectangle bounds = new Rectangle();
                            bounds.x = copy.x - 5;
                            bounds.y = copy.y - 5;
                            bounds.width = copy.width + 10;
                            bounds.height = 10;
                            indicator.setBounds(bounds);
                            getFeedbackLayer().add(indicator);
                        }
                    } else {
                        if (indicator != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
                            getFeedbackLayer().remove(indicator);
                        }
                    }
                    break;
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CreateNodeConnectionRequest(org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)3 CreateNodeConnectionRequest (org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest)3 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)2 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)2 IFigure (org.eclipse.draw2d.IFigure)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 EditPart (org.eclipse.gef.EditPart)1 Command (org.eclipse.gef.commands.Command)1 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)1 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)1 CreateDocChildrenCommand (org.talend.designer.xmlmap.commands.CreateDocChildrenCommand)1 InsertNewColumnCommand (org.talend.designer.xmlmap.commands.InsertNewColumnCommand)1 UpdateExpressionCommand (org.talend.designer.xmlmap.commands.UpdateExpressionCommand)1 UpdateFilterExpressionCommand (org.talend.designer.xmlmap.commands.UpdateFilterExpressionCommand)1 DropType (org.talend.designer.xmlmap.dnd.DropType)1 XmlMapGraphicViewer (org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)1 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)1 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)1 MapperManager (org.talend.designer.xmlmap.ui.tabs.MapperManager)1