Search in sources :

Example 11 with EditPart

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

the class NodesPasteCommand 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 (jobletNodeToExpand.contains(((Node) nodePart.getModel()).getNodeContainer())) {
                                    PropertyChangeCommand ppc = new PropertyChangeCommand(((Node) nodePart.getModel()).getNodeContainer(), EParameterName.COLLAPSED.getName(), false);
                                    ppc.execute();
                                    for (EditPart jobletChildren : (List<EditPart>) subjobChildsPart.getChildren()) {
                                        if (jobletChildren instanceof NodePart) {
                                            sel.add(jobletChildren);
                                        }
                                    }
                                } else if (nodePart != null) {
                                    sel.add(nodePart);
                                }
                            }
                        }
                    }
                }
                if (editPart instanceof NodePart) {
                    Node currentNode = (Node) editPart.getModel();
                    if (nodeContainerList.contains(currentNode.getNodeContainer())) {
                        sel.add(editPart);
                    }
                }
            }
            if (!isJunitCreate() && !isJobletRefactor()) {
                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)

Example 12 with EditPart

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

the class MoveNodeCommand method initializeCurrentSelection.

private void initializeCurrentSelection() {
    currentSelection = new ArrayList<Node>();
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
        if (editPart.getModel() instanceof Node) {
            currentSelection.add((Node) editPart.getModel());
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with EditPart

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

the class MultiplePasteCommand method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.commands.CompoundCommand#execute()
     */
@Override
public void execute() {
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    oldSelection = new ArrayList<EditPart>();
    for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
        oldSelection.add(editPart);
    }
    // remove the old selection
    viewer.deselectAll();
    super.execute();
    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 NodePart) {
                Node currentNode = (Node) editPart.getModel();
                if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
                    sel.add(editPart);
                }
            } else if (editPart instanceof NoteEditPart) {
                Note currentNode = (Note) editPart.getModel();
                if (noteCmd.getNoteList().contains(currentNode)) {
                    sel.add(editPart);
                }
            } else if (editPart instanceof SubjobContainerPart) {
                // add for the bug TDI-7706
                for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
                    if (subjobChildsPart instanceof NodeContainerPart) {
                        if (nodeCmd.getNodeContainerList().contains(((NodeContainerPart) subjobChildsPart).getModel())) {
                            NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
                            if (nodePart != null) {
                                sel.add(nodePart);
                            }
                        }
                    }
                }
            }
        }
        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) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) Note(org.talend.designer.core.ui.editor.notes.Note) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 14 with EditPart

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

the class TalendEditorComponentCreationAssist method highlightOveredConnection.

private void highlightOveredConnection(org.eclipse.swt.graphics.Point cursorRelativePosition) {
    if (overedConnection != null) {
        overedConnection.setLineWidth(1);
        overedConnection = null;
    }
    EditPart findObjectAt = graphicViewer.findObjectAt(new Point(cursorRelativePosition.x, cursorRelativePosition.y));
    if (findObjectAt instanceof ConnectionPart) {
        overedConnection = (ConnectionFigure) ((ConnectionPart) findObjectAt).getFigure();
    } else if (findObjectAt instanceof ConnLabelEditPart) {
        overedConnection = (ConnectionFigure) ((ConnectionPart) ((ConnLabelEditPart) findObjectAt).getParent()).getFigure();
    }
    if (overedConnection != null) {
        overedConnection.setLineWidth(2);
    }
}
Also used : ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Point(org.eclipse.draw2d.geometry.Point) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 15 with EditPart

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

the class AbstractTalendEditor method collapsePalette.

/**
     * DOC hcw Comment method "collapsePalette".
     * 
     * @param children
     */
private void collapsePalette(List children) {
    for (Object object : children) {
        if (object instanceof TalendDrawerEditPart) {
            TalendDrawerEditPart part = (TalendDrawerEditPart) object;
            part.setExpanded(false);
            collapsePalette(part.getChildren());
        } else if (object instanceof EditPart) {
            collapsePalette(((EditPart) object).getChildren());
        }
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart)

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