/* Get selection */
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
// Get selection from the window
final ISelection selection = window.getSelectionService().getSelection();
Diagram diagramView = null;
// get the editing domain
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
// Walk selection
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
// Try to adapt the selection to a view
Object selectedObject = i.next();
if (selectedObject instanceof IAdaptable) {
// Try to get a View (new notation)
Object object = ((IAdaptable) selectedObject)
.getAdapter(View.class);
diagramView = ((View)object).getDiagram();
}
}
}
if (diagramView != null) {
final Diagram diag = diagramView;
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(diagramView);
AbstractEMFOperation operation = new AbstractEMFOperation(