Source:
protected Command getCommand() { final CompoundCommand doStoreLayoutsCmd = new CompoundCommand("Store layouts"); doStoreLayoutsCmd.add(new Command("Clear previous layout data") { @Override public boolean canUndo() { return false; } @Override public boolean canExecute() { return super.canExecute(); } @Override public void execute() { for (SiriusLayoutDataManager layoutDataManager : LayoutDataManagerRegistry.getAllSiriusLayoutDataManagers()) { layoutDataManager.clearLayoutData(); } } }); DiagramEditPart diagramEditPart = getDiagramEditPart(); if (diagramEditPart instanceof IDDiagramEditPart) { final Option<DDiagram> diagram = ((IDDiagramEditPart) diagramEditPart).resolveDDiagram(); if (diagram.some()) { List<IGraphicalEditPart> selectedEditParts = cleanSelectedObjects(getSelectedObjects()); for (Iterator<IGraphicalEditPart> iter = selectedEditParts.iterator(); iter.hasNext(); ) { final IGraphicalEditPart toStore = iter.next(); doStoreLayoutsCmd.add(new ICommandProxy(new AbstractTransactionalCommand(toStore.getEditingDomain(), "Copy layout data", null) { @Override protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { for (SiriusLayoutDataManager layoutDataManager : LayoutDataManagerRegistry.getSiriusLayoutDataManagers(diagram.get())) { layoutDataManager.storeLayoutData(toStore); } return CommandResult.newOKCommandResult(); } @Override protected IStatus doUndo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { for (SiriusLayoutDataManager layoutDataManager : LayoutDataManagerRegistry.getSiriusLayoutDataManagers(diagram.get())) { layoutDataManager.clearLayoutData(); } return super.doUndo(monitor, info); } })); } } } return doStoreLayoutsCmd.unwrap(); }

Target:
protected Command getCommand() { final CompoundCommand doStoreLayoutsCmd = new CompoundCommand("Store layouts"); doStoreLayoutsCmd.add(new Command("Clear previous layout data") { @Override public boolean canUndo() { return false; } @Override public boolean canExecute() { return super.canExecute(); } @Override public void execute() { for (SiriusLayoutDataManager layoutDataManager : LayoutDataManagerRegistry.getAllSiriusLayoutDataManagers()) { layoutDataManager.clearLayoutData(); } } }); DiagramEditPart diagramEditPart = getDiagramEditPart(); if (diagramEditPart instanceof IDDiagramEditPart) { final Option<DDiagram> diagram = ((IDDiagramEditPart) diagramEditPart).resolveDDiagram(); if (diagram.some()) { List<IGraphicalEditPart> selectedEditParts = cleanSelectedObjects(getSelectedObjects()); for (final IGraphicalEditPart toStore : selectedEditParts) { doStoreLayoutsCmd.add(new ICommandProxy(new AbstractTransactionalCommand(toStore.getEditingDomain(), "Copy layout data", null) { @Override protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { for (SiriusLayoutDataManager layoutDataManager : LayoutDataManagerRegistry.getSiriusLayoutDataManagers(diagram.get())) { layoutDataManager.storeLayoutData(toStore); } return CommandResult.newOKCommandResult(); } @Override protected IStatus doUndo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { for (SiriusLayoutDataManager layoutDataManager : LayoutDataManagerRegistry.getSiriusLayoutDataManagers(diagram.get())) { layoutDataManager.clearLayoutData(); } return super.doUndo(monitor, info); } })); } } } return doStoreLayoutsCmd.unwrap(); }