Search in sources :

Example 6 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
@SuppressWarnings("unchecked")
public void selectNode(Node node) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        // ProcessPart < SubjobContainerPart < NodeContainerPart < NodePart
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof SubjobContainerPart) {
                SubjobContainerPart subjobPart = (SubjobContainerPart) editPart;
                for (EditPart part : (List<EditPart>) subjobPart.getChildren()) {
                    if (part instanceof NodeContainerPart) {
                        EditPart nodePart = (EditPart) part.getChildren().get(0);
                        if (nodePart instanceof NodePart) {
                            if (((NodePart) nodePart).getModel().equals(node)) {
                                viewer.select(nodePart);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 7 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class NodePartKeyHander method getNavigationSiblings.

@Override
protected List getNavigationSiblings() {
    EditPart focusPart = getFocusEditPart();
    boolean displayVa = true;
    if (focusPart.getParent() != null) {
        if (focusPart instanceof SubjobContainerPart) {
            // return getNodePart((SubjobContainerPart) focusPart);
            SubjobContainerPart subConPart = (SubjobContainerPart) focusPart;
            List subList = focusPart.getParent().getChildren();
            for (int j = 0; j < subList.size(); j++) {
                if (subList.get(j) instanceof SubjobContainerPart) {
                    subConPart = (SubjobContainerPart) subList.get(j);
                    SubjobContainer subContainer = (SubjobContainer) subConPart.getModel();
                    if (subContainer.isDisplayed() == false) {
                        displayVa = false;
                    }
                } else if (subList.get(j) instanceof NoteEditPart) {
                    NoteEditPart notePart = (NoteEditPart) subList.get(j);
                    return getNodePart((ProcessPart) notePart.getParent());
                } else if (subList.get(j) instanceof NodePart) {
                    NodePart node = (NodePart) subList.get(j);
                    return getNodePart((ProcessPart) node.getParent().getParent().getParent());
                }
            }
            if (displayVa == false) {
                return getNodePart((ProcessPart) focusPart.getParent());
            }
        } else if (focusPart instanceof NodePart) {
            // get all node part for a job.
            return getNodePart((ProcessPart) focusPart.getParent().getParent().getParent());
        // return getNodePart((SubjobContainerPart) focusPart.getParent().getParent());
        } else if (focusPart instanceof NoteEditPart) {
            return getNodePart((ProcessPart) focusPart.getParent());
        }
        return focusPart.getParent().getChildren();
    }
    List list = new ArrayList();
    list.add(focusPart);
    return list;
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) EditPart(org.eclipse.gef.EditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) ArrayList(java.util.ArrayList) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) List(java.util.List) ArrayList(java.util.ArrayList) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 8 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class ConnectionPart method getModelChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
     */
@Override
protected List getModelChildren() {
    List<Element> elements;
    elements = new ArrayList<Element>();
    elements.add(((Connection) getModel()).getConnectionLabel());
    elements.add(((Connection) getModel()).getPerformance());
    if (((Connection) getModel()).getResuming() != null) {
        elements.add(((Connection) getModel()).getResuming());
    }
    boolean monitorSupport = true;
    if (getParent() != null && getRoot() != null) {
        EditPart contents = getRoot().getContents();
        if (contents.getModel() instanceof IProcess) {
            IProcess currentProcess = (IProcess) contents.getModel();
            if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().endsWith(currentProcess.getComponentsType())) {
                monitorSupport = false;
            }
        }
    } else {
        IProcess currentProcess = ((Connection) getModel()).getSource().getProcess();
        if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().endsWith(currentProcess.getComponentsType())) {
            monitorSupport = false;
        }
    }
    if (monitorSupport) {
        if (((Connection) getModel()).getConnectionTrace() != null) {
            elements.add(((Connection) getModel()).getConnectionTrace());
        }
        // Add monitor label
        if (((Connection) getModel()).isMonitorConnection()) {
            elements.add(((Connection) getModel()).getMonitorLabel());
        }
    }
    return elements;
}
Also used : Element(org.talend.core.model.process.Element) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) IConnection(org.talend.core.model.process.IConnection) IProcess(org.talend.core.model.process.IProcess)

Example 9 with EditPart

use of org.eclipse.gef.EditPart 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 10 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class NodesMoveCommond method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() {
    // create the node container list to paste
    createNodeContainerList();
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    // save old selection
    if (!multipleCommand) {
        oldSelection = new ArrayList<EditPart>();
        for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
            oldSelection.add(editPart);
        }
        // remove the old selection
        viewer.deselectAll();
    }
    // creates the different nodes
    for (NodeContainer nodeContainer : nodeContainerList) {
        ((Process) process).addNodeContainer(nodeContainer);
    }
    // check that the created connections exists now, or create them if needed
    for (String newConnectionName : createdNames) {
        if (process.checkValidConnectionName(newConnectionName, true)) {
            process.addUniqueConnectionName(newConnectionName);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
    // set the new node as the current selection
    if (!multipleCommand) {
        EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
        if (processPart instanceof ProcessPart) {
            // can only be
            // ProcessPart but still
            // test
            List<EditPart> sel = new ArrayList<EditPart>();
            for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
                if (editPart instanceof SubjobContainerPart) {
                    for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
                        if (subjobChildsPart instanceof NodeContainerPart) {
                            if (nodeContainerList.contains(((NodeContainerPart) subjobChildsPart).getModel())) {
                                NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
                                if (nodePart != null) {
                                    sel.add(nodePart);
                                }
                            }
                        }
                    }
                }
                if (editPart instanceof NodePart) {
                    Node currentNode = (Node) editPart.getModel();
                    if (nodeContainerList.contains(currentNode.getNodeContainer())) {
                        sel.add(editPart);
                    }
                }
            }
            StructuredSelection s = new StructuredSelection(sel);
            viewer.setSelection(s);
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) List(java.util.List) ArrayList(java.util.ArrayList) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

EditPart (org.eclipse.gef.EditPart)291 List (java.util.List)58 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)55 ArrayList (java.util.ArrayList)51 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)27 Point (org.eclipse.draw2d.geometry.Point)26 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)26 Test (org.junit.Test)26 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)21 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)21 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 Iterator (java.util.Iterator)18 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)13