diff options
Diffstat (limited to 'tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java')
-rw-r--r-- | tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java index 8753f5f3de8..d0f96b18492 100644 --- a/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java +++ b/tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java @@ -61,7 +61,6 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.RootEditPart; import org.eclipse.gef.ui.palette.PaletteViewer; -import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand; @@ -74,6 +73,7 @@ import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette; import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory; +import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; import org.eclipse.gmf.runtime.notation.Diagram; @@ -95,8 +95,6 @@ import org.eclipse.papyrus.infra.nattable.common.editor.AbstractEMFNattableEdito import org.eclipse.papyrus.infra.nattable.common.modelresource.PapyrusNattableModel; import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.infra.tools.util.PlatformHelper; import org.eclipse.papyrus.infra.tools.util.TypeUtils; import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor; @@ -1539,21 +1537,23 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit } /** - * Delete an edit-part from the diagram. + * Delete one or more edit-parts from the diagram. * * @param editPart - * the edit-part to delete + * the edit-parts to delete * * @since 2.2 + * + * @throws IllegalArgumentException + * if no edit-parts are specified */ - public void delete(EditPart editPart) { - EObject toDestroy = editPart.getAdapter(EObject.class); - EObject container = toDestroy.eContainer(); - DestroyElementRequest request = new DestroyElementRequest(toDestroy, false); - IElementEditService edit = ElementEditServiceUtils.getCommandProvider(container); - ICommand delete = edit.getEditCommand(request); - - assertThat("No delete command obtained", delete, notNullValue()); + public void delete(EditPart... editPart) { + // In the diagram, deletion of a multiple selection is accomplished with separate + // requests to each edit-part, so do the same here + org.eclipse.gef.commands.Command delete = Stream.of(editPart).map(ep -> ep.getCommand(new EditCommandRequestWrapper(new DestroyElementRequest(false)))) + .reduce(org.eclipse.gef.commands.Command::chain) + .orElseThrow(IllegalArgumentException::new); + execute(delete); } } |