Search in sources :

Example 21 with NoteEditPart

use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.

the class NotesPasteCommand method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() {
    // create the note list to paste
    createNoteList();
    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 notes
    for (Note note : noteList) {
        process.addNote(note);
    }
    // set the new note 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 NoteEditPart) {
                    Note currentNode = (Note) editPart.getModel();
                    if (noteList.contains(currentNode)) {
                        sel.add(editPart);
                    }
                }
            }
            StructuredSelection s = new StructuredSelection(sel);
            viewer.setSelection(s);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Note(org.talend.designer.core.ui.editor.notes.Note) 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) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart)

Aggregations

NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)21 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)14 List (java.util.List)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 ArrayList (java.util.ArrayList)11 Node (org.talend.designer.core.ui.editor.nodes.Node)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)9 Note (org.talend.designer.core.ui.editor.notes.Note)9 EditPart (org.eclipse.gef.EditPart)8 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)7 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)6 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)5 Clipboard (org.eclipse.gef.ui.actions.Clipboard)4 JobletContainerPart (org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart)4 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)4 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)4 Point (org.eclipse.draw2d.geometry.Point)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3