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();
}
Aggregations