diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyModelElementsAction.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyModelElementsAction.java index c3b1a7b78dc43637946a49ce49ad6d17ebbae075..592e9c39dd4c682b018c01a6c329a5534cc5ccb1 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyModelElementsAction.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyModelElementsAction.java @@ -61,7 +61,7 @@ public class CopyModelElementsAction extends ModelElementsActionBase { CopyPasteUtils.copyToClipboard(selection); } catch (IOException e) { LoggingUtils.error(ToolingBaseUIActivator.getDefault(), - "Had problems during copy", e); + "Had problems during copy operation", e); } } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyPasteUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyPasteUtils.java index bed9dd92be65a117c3ecec6e9c4577e9d47ccf06..c88e03fa1eaadab767beb9aa7411368846646ba8 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyPasteUtils.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CopyPasteUtils.java @@ -35,7 +35,7 @@ import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.widgets.Display; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.util.EMFResourceUtils; /** @@ -97,14 +97,14 @@ final class CopyPasteUtils { } for (EObject insertObj : contents) { - if (!ICompositorService.INSTANCE + if (!IElementCompositorService.INSTANCE .canCompose(target, insertObj, null)) { return; } } for (EObject insertObj : contents) { - ICompositorService.INSTANCE.compose(target, insertObj, null); + IElementCompositorService.INSTANCE.compose(target, insertObj, null); // LibrarySupport.activateAllElements(insertObj); } } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CutModelElementsAction.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CutModelElementsAction.java index 7ff197e0d53f5d942a93fb4dc7cd1ad186e9c686..8575e66a00fd456268c5559fc4a86f1758a9ae47 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CutModelElementsAction.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/CutModelElementsAction.java @@ -27,7 +27,7 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; import org.fortiss.tooling.base.ui.ToolingBaseUIActivator; -import org.fortiss.tooling.kernel.model.IRemovable; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.util.LoggingUtils; /** @@ -60,11 +60,12 @@ public class CutModelElementsAction extends ModelElementsActionBase { try { CopyPasteUtils.copyToClipboard(selection); for (EObject o : selection) { - ((IRemovable) o).remove(); + IElementCompositorService.INSTANCE.decompose( + o.eContainer(), o, null); } } catch (IOException e) { LoggingUtils.error(ToolingBaseUIActivator.getDefault(), - "Had problems during copy", e); + "Had problems during cut operation", e); } } @@ -77,10 +78,8 @@ public class CutModelElementsAction extends ModelElementsActionBase { @Override public boolean canExecute() { for (EObject o : selection) { - if (!(o instanceof IRemovable)) { - return false; - } - if (!((IRemovable) o).canRemove()) { + if (!IElementCompositorService.INSTANCE.canDecompose( + o.eContainer(), o, null)) { return false; } } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/PasteModelElementAction.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/PasteModelElementAction.java index 7a1a01bcb628d9fdf8a1f4363cddf6a2624064a1..2f85e86897b5f5d93a854d4d1231af352df7575a 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/PasteModelElementAction.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/action/PasteModelElementAction.java @@ -50,7 +50,7 @@ public class PasteModelElementAction extends ModelElementsActionBase { /** {@inheritDoc} */ @Override protected Command createCommand(final Collection<EObject> selection) { - return new AbstractCommand("Copy") { + return new AbstractCommand("Paste") { @Override public void execute() { diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java index d13947521d12123c74dd8edc185426f7d1291bc1..c29d0efe9fd250eb41e8b57d58baa1ccced8b936 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/compose/HierarchicElementConnectionCompositorBase.java @@ -27,7 +27,7 @@ import org.fortiss.tooling.base.ui.dnd.DropContext; import org.fortiss.tooling.base.ui.editpart.RootEditPartBase; import org.fortiss.tooling.kernel.interfaces.IConnectionCompositionContext; import org.fortiss.tooling.kernel.interfaces.IConnectionCompositor; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.services.IElementCompositorService; /** * Base implementation for supporting direct connection of two @@ -124,13 +124,13 @@ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHier // drop source connector DropContext sourceDrop = context instanceof DragContext ? ((DragContext) context) .getSourceDropContext() : null; - ICompositorService.INSTANCE + IElementCompositorService.INSTANCE .compose(source, sourceConnector, sourceDrop); // drop target target connector DropContext targetDrop = context instanceof DragContext ? ((DragContext) context) .getTargetDropContext() : null; - ICompositorService.INSTANCE + IElementCompositorService.INSTANCE .compose(target, targetConnector, targetDrop); // link connection to connectors diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DropContext.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DropContext.java index 123d4083e939840aaf1c3bb1d9cc9f47cae8a426..c9d21b1c4303b26270cdaa68677bba3760081da1 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DropContext.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/dnd/DropContext.java @@ -20,7 +20,7 @@ package org.fortiss.tooling.base.ui.dnd; import org.eclipse.draw2d.geometry.Point; import org.eclipse.gef.EditPart; import org.fortiss.tooling.base.ui.editpart.RootEditPartBase; -import org.fortiss.tooling.kernel.interfaces.ICompositionContext; +import org.fortiss.tooling.kernel.interfaces.IElementCompositionContext; /** * Composition context for GEF edit parts initiated by a drop gesture. The @@ -35,7 +35,7 @@ import org.fortiss.tooling.kernel.interfaces.ICompositionContext; * @version $Rev$ * @ConQAT.Rating YELLOW Hash: F41CA022ECFE85D93C254EFB2BE6D7BE */ -public class DropContext implements ICompositionContext { +public class DropContext implements IElementCompositionContext { /** Drop target edit part */ private final EditPart dropTarget; diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java index 42e2924a0be535e429c333bd15ff8705f4dfe465..be65a5100d92d40c68e2fafb52e346f5de8bd4ab 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editor/TreeViewerEditorBase.java @@ -37,7 +37,7 @@ import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.dnd.TransferData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.ui.base.EditorBase; import org.fortiss.tooling.kernel.ui.util.DragAndDropUtils; import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils; @@ -174,7 +174,7 @@ public abstract class TreeViewerEditorBase<T extends EObject> extends .extractDroppedEObject(LocalSelectionTransfer .getTransfer().getSelection()); - return ICompositorService.INSTANCE.canCompose( + return IElementCompositorService.INSTANCE.canCompose( (EObject) lastTarget, dropped, null); } return false; @@ -186,12 +186,12 @@ public abstract class TreeViewerEditorBase<T extends EObject> extends if (lastTarget instanceof EObject) { final EObject dropped = DragAndDropUtils .extractDroppedEObject(data); - if (ICompositorService.INSTANCE.canCompose( + if (IElementCompositorService.INSTANCE.canCompose( (EObject) lastTarget, dropped, null)) { TreeViewerEditorBase.this.executeCommand(new Runnable() { @Override public void run() { - ICompositorService.INSTANCE.compose( + IElementCompositorService.INSTANCE.compose( (EObject) lastTarget, dropped, null); } }); diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/LayoutEditPolicyBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/LayoutEditPolicyBase.java index 2064056506a88ca9a78d54f553ba73cffa999149..8f583273ee32c245cc015abeea85de757b18511c 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/LayoutEditPolicyBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/LayoutEditPolicyBase.java @@ -24,8 +24,8 @@ import org.eclipse.gef.commands.Command; import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.requests.CreateRequest; import org.fortiss.tooling.base.ui.dnd.DropContext; -import org.fortiss.tooling.kernel.interfaces.ICompositionContext; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.interfaces.IElementCompositionContext; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.ui.util.DragAndDropUtils; /** @@ -64,20 +64,20 @@ public abstract class LayoutEditPolicyBase extends LayoutEditPolicy { } final EObject model = (EObject) getHost().getModel(); - final ICompositionContext context = new DropContext(getHost(), location); + final IElementCompositionContext context = new DropContext(getHost(), location); final EObject dropped = DragAndDropUtils.extractDroppedEObject(request .getNewObject()); return new Command() { @Override public boolean canExecute() { - return ICompositorService.INSTANCE.canCompose(model, dropped, + return IElementCompositorService.INSTANCE.canCompose(model, dropped, context); } @Override public void execute() { - ICompositorService.INSTANCE.compose(model, dropped, context); + IElementCompositorService.INSTANCE.compose(model, dropped, context); } }; } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/RemoveEditPolicy.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/RemoveEditPolicy.java index 239c69335707c3cf198a94dcae8e646ba1c03740..3106bcb52e71ff88fa25172ecc474593fe9f63fa 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/RemoveEditPolicy.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/policy/RemoveEditPolicy.java @@ -19,17 +19,18 @@ package org.fortiss.tooling.base.ui.editpart.policy; import java.util.List; +import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.EditPart; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.commands.UnexecutableCommand; import org.eclipse.gef.editpolicies.ComponentEditPolicy; import org.eclipse.gef.requests.GroupRequest; -import org.fortiss.tooling.kernel.model.IRemovable; +import org.fortiss.tooling.kernel.services.IElementCompositorService; /** - * An edit policy for {@link IRemovable}. This is not a singleton, as the - * editpart will call various setters on its instance. + * An edit policy for removing model elements. Delete commands are redirected to + * {@link IElementCompositorService} to determine the model change. * * @author hoelzl * @author $Author$ @@ -44,10 +45,14 @@ public final class RemoveEditPolicy extends ComponentEditPolicy { public Command createDeleteCommand(GroupRequest request) { CompoundCommand compound = new CompoundCommand(); for (EditPart ep : (List<EditPart>) request.getEditParts()) { - if (!(ep.getModel() instanceof IRemovable)) { + EObject model = (EObject) ep.getModel(); + boolean canDelete = IElementCompositorService.INSTANCE + .canDecompose(model.eContainer(), model, null); + if (canDelete) { + compound.add(new RemoveCommand(model)); + } else { return UnexecutableCommand.INSTANCE; } - compound.add(new RemoveCommand((IRemovable) ep.getModel())); } return compound; } @@ -56,23 +61,25 @@ public final class RemoveEditPolicy extends ComponentEditPolicy { public static class RemoveCommand extends Command { /** The entity to be removed. */ - private final IRemovable toRemove; + private final EObject toRemove; - /** Creates a command to remove a subcomponent. */ - public RemoveCommand(IRemovable toRemove) { + /** Creates a command to remove an element. */ + public RemoveCommand(EObject toRemove) { this.toRemove = toRemove; } /** {@inheritDoc} */ @Override public void execute() { - toRemove.remove(); + IElementCompositorService.INSTANCE.decompose(toRemove.eContainer(), + toRemove, null); } /** {@inheritDoc} */ @Override public boolean canExecute() { - return toRemove.canRemove(); + return IElementCompositorService.INSTANCE.canDecompose( + toRemove.eContainer(), toRemove, null); } } } diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ActionService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ActionService.java index 0580ef230962f28d2eaef4407a13e066a169128f..bc911d6ba912d8f7f672560a7f261adbf1481fd8 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ActionService.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ActionService.java @@ -21,7 +21,6 @@ import java.util.EventObject; import org.eclipse.emf.common.command.CommandStackListener; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.action.IMenuManager; import org.eclipse.ui.IActionBars; import org.eclipse.ui.ISharedImages; @@ -29,8 +28,8 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; import org.fortiss.tooling.kernel.interfaces.ITopLevelElementChangeListener; import org.fortiss.tooling.kernel.interfaces.ITopLevelElementContext; -import org.fortiss.tooling.kernel.model.IRemovable; import org.fortiss.tooling.kernel.services.ICommandStackService; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.services.IPersistencyService; import org.fortiss.tooling.kernel.ui.base.EObjectActionBase; import org.fortiss.tooling.kernel.ui.services.IActionService; @@ -90,11 +89,9 @@ public class ActionService implements IActionService, new Runnable() { @Override public void run() { - if (selectedObject instanceof IRemovable) { - ((IRemovable) selectedObject).remove(); - } else { - EcoreUtil.delete(selectedObject, true); - } + IElementCompositorService.INSTANCE.decompose( + selectedObject.eContainer(), + selectedObject, null); } }); } @@ -158,10 +155,10 @@ public class ActionService implements IActionService, globalRedoAction.setEnabled(ICommandStackService.INSTANCE .canRedo(target)); - boolean canDelete = (target instanceof IRemovable) - && ((IRemovable) target).canRemove(); + boolean canDelete = IElementCompositorService.INSTANCE.canDecompose( + target.eContainer(), target, null); canDelete = canDelete - || !IPersistencyService.INSTANCE.isTopLevelElement(target); + && !IPersistencyService.INSTANCE.isTopLevelElement(target); globalDeleteAction.setTarget(target); globalDeleteAction.setEnabled(canDelete); } diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NewMenu.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NewMenu.java index 44615b738170d6f045650153c4fa374b43f587ef..66b1f956a2742a5b07dcb3eee7db30a06616aab3 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NewMenu.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/NewMenu.java @@ -24,7 +24,7 @@ import org.eclipse.jface.action.IContributionItem; import org.eclipse.ui.actions.CompoundContributionItem; import org.fortiss.tooling.kernel.interfaces.IPrototypeProvider; import org.fortiss.tooling.kernel.services.ICommandStackService; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.services.IPrototypeService; import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; import org.fortiss.tooling.kernel.ui.services.IEditorService; @@ -105,7 +105,7 @@ public class NewMenu extends CompoundContributionItem { @Override public void run() { EObject newObject = prototype.getPrototypeCopy(); - if (ICompositorService.INSTANCE.compose(container, + if (IElementCompositorService.INSTANCE.compose(container, newObject, null)) { IEditorService.INSTANCE.openInEditor(newObject); } @@ -119,7 +119,7 @@ public class NewMenu extends CompoundContributionItem { */ public boolean prepare(EObject container) { this.container = container; - return ICompositorService.INSTANCE.canCompose(container, + return IElementCompositorService.INSTANCE.canCompose(container, prototype.getPrototype(), null); } diff --git a/org.fortiss.tooling.kernel/trunk/model/kernel.ecore b/org.fortiss.tooling.kernel/trunk/model/kernel.ecore index 520d37b477ad583841483aabcaa13a63c2718fa5..d1afbf198ae4935d16217d1da288f527e92b12b8 100644 --- a/org.fortiss.tooling.kernel/trunk/model/kernel.ecore +++ b/org.fortiss.tooling.kernel/trunk/model/kernel.ecore @@ -41,21 +41,4 @@ </eAnnotations> </eStructuralFeatures> </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="IRemovable" abstract="true" interface="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Model elements implementing this interface can provide a custom remove operatoin."/> - </eAnnotations> - <eOperations name="canRemove" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns whether the current model element can be removed."/> - <details key="body" value="return IRemovableStaticImpl.canRemove(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="remove" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Removes the current model element from its parent."/> - <details key="body" value="return IRemovableStaticImpl.remove(this);"/> - </eAnnotations> - </eOperations> - </eClassifiers> </ecore:EPackage> diff --git a/org.fortiss.tooling.kernel/trunk/plugin.xml b/org.fortiss.tooling.kernel/trunk/plugin.xml index ec578c5ad5ea6473ea95e8dbbbd8d8fe609c5bfd..63eaaaa97a9bdfaff88b8f9f69fbfba97c1d5eba 100644 --- a/org.fortiss.tooling.kernel/trunk/plugin.xml +++ b/org.fortiss.tooling.kernel/trunk/plugin.xml @@ -6,7 +6,7 @@ <extension-point id="modelStorageProvider" name="Model Storage Provider" schema="schema/modelStorageProvider.exsd"/> <extension-point id="modelConstraintChecker" name="Model Constraint Checker" schema="schema/modelConstraintChecker.exsd"/> <extension-point id="eclipseResourceStorageLocationProvider" name="Eclipse Resource Storage Location Provider" schema="schema/eclipseResourceStorageLocationProvider.exsd"/> - <extension-point id="modelElementConnectionCompositor" name="Model Element Connection Compositor" schema="schema/modelElementConnectionCompositor.exsd"/> + <extension-point id="modelConnectionCompositor" name="Model Connection Compositor" schema="schema/modelConnectionCompositor.exsd"/> <extension point="org.eclipse.emf.ecore.generated_package"> <package diff --git a/org.fortiss.tooling.kernel/trunk/schema/modelElementConnectionCompositor.exsd b/org.fortiss.tooling.kernel/trunk/schema/modelConnectionCompositor.exsd similarity index 100% rename from org.fortiss.tooling.kernel/trunk/schema/modelElementConnectionCompositor.exsd rename to org.fortiss.tooling.kernel/trunk/schema/modelConnectionCompositor.exsd diff --git a/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd b/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd index eb349afe2c178c4ab573d8f330523ead8c3729a3..24e2730b800701f8e3cd1d1fe460c7abce4c7441 100644 --- a/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd +++ b/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd @@ -60,7 +60,7 @@ The model element compositor. </documentation> <appinfo> - <meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.interfaces.ICompositor"/> + <meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.interfaces.IElementCompositor"/> </appinfo> </annotation> </attribute> diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositionContext.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IElementCompositionContext.java similarity index 89% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositionContext.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IElementCompositionContext.java index 18becd197583ca304b6c39609b3f7b11bf6ea442..ae63f5ba2c22dace78f0964134ca4104c852558a 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositionContext.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IElementCompositionContext.java @@ -19,8 +19,8 @@ $Id$ package org.fortiss.tooling.kernel.interfaces; /** - * An {@link ICompositionContext} provides additional information like drop - * point positions to an {@link ICompositor}. + * An {@link IElementCompositionContext} provides additional information like drop + * point positions to an {@link IElementCompositor}. * * @FloH: what is a "drop point" position? * @@ -29,6 +29,6 @@ package org.fortiss.tooling.kernel.interfaces; * @version $Rev$ * @ConQAT.Rating RED Hash: D85BD49FE3F70C2C4AF5B5B9250C0863 */ -public interface ICompositionContext { +public interface IElementCompositionContext { // this is just a marker interface } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositor.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IElementCompositor.java similarity index 73% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositor.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IElementCompositor.java index 09000d1cf0fea937c522bb3b95e9d64af9dff852..37d4cef21f07783eb881d7083184174cd0633a7c 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositor.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IElementCompositor.java @@ -21,23 +21,30 @@ import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** - * Interface for compositors, i.e. classes which know how to compose - * {@link EObject}s. - * - * @TODO: rename to "ElementCompositor" + * Interface for compositors, i.e. classes which know how to compose and + * decompose {@link EObject}s. * * @author hoelzl * @author $Author$ * @version $Rev$ * @ConQAT.Rating YELLOW Hash: 75F650B0058B591BE903CC45C0AB9876 */ -public interface ICompositor<T extends EObject> extends IEObjectAware<T> { +public interface IElementCompositor<T extends EObject> extends IEObjectAware<T> { /** * Returns whether the given container may include the given contained * object. */ boolean canCompose(T container, EObject contained, - ICompositionContext context); + IElementCompositionContext context); + + /** + * Returns whether this compositor is able to compose the given prototype. + * While {@link #canCompose(EObject, EObject, IElementCompositionContext)} + * considers a concrete composition between the container and contained + * element, this method returns this compositor's ability to accept the + * given prototype in general. + */ + boolean canComposePrototype(Prototype prototype); /** * Asks the compositor to insert the contained object into the container. @@ -45,14 +52,21 @@ public interface ICompositor<T extends EObject> extends IEObjectAware<T> { * This method returns a boolean, since user-interaction during compose * might cancel the command. */ - boolean compose(T container, EObject contained, ICompositionContext context); + boolean compose(T container, EObject contained, + IElementCompositionContext context); /** - * Returns whether this compositor is able to compose the given prototype. - * While {@link #canCompose(EObject, EObject, ICompositionContext)} - * considers a concrete composition between the container and contained - * element, this method returns this compositor's ability to accept the - * given prototype in general. + * Returns whether the given contained element may be removed from the given + * container element. */ - boolean canComposePrototype(Prototype prototype); + boolean canDecompose(T container, EObject contained, + IElementCompositionContext context); + + /** + * Asks the compositor to remove the contained object from the container. + * This method returns a boolean, since user-interaction during compose + * might cancel the command. + */ + boolean decompose(T container, EObject contained, + IElementCompositionContext context); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ElementCompositorService.java similarity index 60% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ElementCompositorService.java index 25378ba5ba9409128bf1da60db54abfd095f590c..770e6e9c10150d1b56872d752f487906d98216ec 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ElementCompositorService.java @@ -21,22 +21,22 @@ import java.util.List; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.base.EObjectAwareServiceBase; -import org.fortiss.tooling.kernel.interfaces.ICompositionContext; -import org.fortiss.tooling.kernel.interfaces.ICompositor; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.interfaces.IElementCompositionContext; +import org.fortiss.tooling.kernel.interfaces.IElementCompositor; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** - * This class implements the {@link ICompositorService} interface. + * This class implements the {@link IElementCompositorService} interface. * * @author hoelzl * @author $Author$ * @version $Rev$ * @ConQAT.Rating YELLOW Hash: 1AB8E5D4937CE2C77649035548CA11DF */ -public final class CompositorService extends - EObjectAwareServiceBase<ICompositor<EObject>> implements - ICompositorService { +public final class ElementCompositorService extends + EObjectAwareServiceBase<IElementCompositor<EObject>> implements + IElementCompositorService { /** The compositor extension point ID. */ private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementCompositor"; @@ -50,27 +50,27 @@ public final class CompositorService extends /** {@inheritDoc} */ @Override public boolean canCompose(EObject container, EObject element, - ICompositionContext context) { - return findWorkingCompositor(container, element, context) != null; + IElementCompositionContext context) { + return findWorkingCompositor(container, element, context, false) != null; } /** {@inheritDoc} */ @Override public boolean compose(EObject container, EObject element, - ICompositionContext context) { - return findWorkingCompositor(container, element, context).compose( - container, element, context); + IElementCompositionContext context) { + return findWorkingCompositor(container, element, context, false) + .compose(container, element, context); } /** {@inheritDoc} */ @Override public boolean canComposePrototype(Class<? extends EObject> containerClass, Prototype prototype) { - List<ICompositor<EObject>> list = getRegisteredHandlers(containerClass); + List<IElementCompositor<EObject>> list = getRegisteredHandlers(containerClass); if (list == null) { return false; } - for (ICompositor<EObject> compositor : list) { + for (IElementCompositor<EObject> compositor : list) { if (compositor.canComposePrototype(prototype)) { return true; } @@ -78,19 +78,39 @@ public final class CompositorService extends return false; } + /** {@inheritDoc} */ + @Override + public boolean canDecompose(EObject container, EObject contained, + IElementCompositionContext context) { + return findWorkingCompositor(container, contained, context, true) != null; + } + + /** {@inheritDoc} */ + @Override + public boolean decompose(EObject container, EObject contained, + IElementCompositionContext context) { + return findWorkingCompositor(container, contained, context, true) + .decompose(container, contained, context); + } + /** - * Returns the first {@link ICompositor} which can compose the given element - * (or <code>null</code>). + * Returns the first {@link IElementCompositor} which can compose the given + * element (or <code>null</code>). */ - private ICompositor<EObject> findWorkingCompositor(EObject container, - EObject contained, ICompositionContext context) { - List<ICompositor<EObject>> list = getRegisteredHandlers(container + private IElementCompositor<EObject> findWorkingCompositor( + EObject container, EObject contained, + IElementCompositionContext context, boolean decompose) { + List<IElementCompositor<EObject>> list = getRegisteredHandlers(container .getClass()); if (list == null) { return null; } - for (ICompositor<EObject> compositor : list) { - if (compositor.canCompose(container, contained, context)) { + for (IElementCompositor<EObject> compositor : list) { + if (!decompose + && compositor.canCompose(container, contained, context)) { + return compositor; + } else if (decompose + && compositor.canDecompose(container, contained, context)) { return compositor; } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java index 0e7daf3e71086d0640f051d67f77c6b07791113a..1b6cba833376ade66a86e3f0579d834a4672f2cb 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java @@ -27,7 +27,7 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.interfaces.IPrototypeProvider; -import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.services.IElementCompositorService; import org.fortiss.tooling.kernel.services.IPrototypeService; import org.fortiss.tooling.kernel.util.ExtensionPointUtils; import org.fortiss.tooling.kernel.util.LoggingUtils; @@ -98,7 +98,7 @@ public class PrototypeService implements IPrototypeService { Class<? extends EObject> modelElementType) { List<Prototype> result = new LinkedList<Prototype>(); for (Prototype prototype : getAllPrototypes()) { - if (ICompositorService.INSTANCE.canComposePrototype( + if (IElementCompositorService.INSTANCE.canComposePrototype( modelElementType, prototype)) { result.add(prototype); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/model/impl/IRemovableStaticImpl.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/model/impl/IRemovableStaticImpl.java deleted file mode 100644 index e9c6962156eef9a0fcf44027c6c19ecefabc5dc1..0000000000000000000000000000000000000000 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/model/impl/IRemovableStaticImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id$ -| | -| Copyright 2011 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.tooling.kernel.model.impl; - -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.fortiss.tooling.kernel.model.IRemovable; - -/** - * Static implementations for {@link IRemovable}. - * - * @author hoelzl - * @author $Author$ - * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 5B3BFFF46645CA9E7A150552528C27B9 - */ -public final class IRemovableStaticImpl { - - /** Constructor. */ - private IRemovableStaticImpl() { - // class not intended to be instantiated. - } - - /** Returns true, if a parent exists. */ - public static boolean canRemove(IRemovable element) { - return element.eContainer() != null; - } - - /** - * Removes element from its parent container and deletes all references to - * it and its children. - */ - public static boolean remove(IRemovable element) { - EcoreUtil.delete(element, true); - return true; - } -} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/model/impl/package.html b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/model/impl/package.html deleted file mode 100644 index 3b352be40c84242e9f342ee4117c5e74eb3c65af..0000000000000000000000000000000000000000 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/model/impl/package.html +++ /dev/null @@ -1,8 +0,0 @@ -<!-- - $Id$ - @version $Rev$ - @ConQAT.Rating YELLOW Hash: BB6887C456481D9CAC1639E1D772BB0F ---> -<body> -Static implementations of EMF operations defined in the <code>kernel.ecore</code> meta-model. -</body> diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IElementCompositorService.java similarity index 63% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IElementCompositorService.java index 09c0087e47b149fe3a79d8847cbfc32602b01c9c..7b69893909c8ecd93a655ce660a3747f3a97959c 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IElementCompositorService.java @@ -18,46 +18,60 @@ $Id$ package org.fortiss.tooling.kernel.services; import org.eclipse.emf.ecore.EObject; -import org.fortiss.tooling.kernel.interfaces.ICompositionContext; -import org.fortiss.tooling.kernel.interfaces.ICompositor; -import org.fortiss.tooling.kernel.internal.CompositorService; +import org.fortiss.tooling.kernel.interfaces.IElementCompositionContext; +import org.fortiss.tooling.kernel.interfaces.IElementCompositor; +import org.fortiss.tooling.kernel.internal.ElementCompositorService; import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** - * The compositor service provides registration and access to model element - * compositors. + * The element compositor service provides registration and access to model + * element compositors. * * @author hoelzl * @author $Author$ * @version $Rev$ * @ConQAT.Rating YELLOW Hash: 4F6FF89C40A2BCE2A0310068028A0567 */ -public interface ICompositorService { +public interface IElementCompositorService { /** Returns the singleton instance of the service. */ - public static final ICompositorService INSTANCE = new CompositorService(); + public static final IElementCompositorService INSTANCE = new ElementCompositorService(); /** * Determines if there is a compositor that allows the composition of the * container and the prototype {@link EObject}. */ boolean canCompose(EObject container, EObject element, - ICompositionContext context); + IElementCompositionContext context); /** * Composes the container and the element. Since this operation may be * canceled by the user, it returns a boolean value. */ boolean compose(EObject container, EObject element, - ICompositionContext context); + IElementCompositionContext context); /** * Returns whether given prototype can be composed with containers of the - * given class. This method searches for an {@link ICompositor} that is able - * to handle the composition in general. + * given class. This method searches for an {@link IElementCompositor} that + * is able to handle the composition in general. * - * @see ICompositor#canComposePrototype(org.fortiss.tooling.kernel.services.IPrototypeService.Prototype) + * @see IElementCompositor#canComposePrototype(org.fortiss.tooling.kernel.services.IPrototypeService.Prototype) */ boolean canComposePrototype(Class<? extends EObject> containerClass, Prototype prototype); + + /** + * Determines if there is a compositor that allows the decomposition of the + * container and the contained {@link EObject}. + */ + boolean canDecompose(EObject container, EObject contained, + IElementCompositionContext context); + + /** + * Decomposes the container and the element. Since this operation may be + * canceled by the user, it returns a boolean value. + */ + boolean decompose(EObject container, EObject contained, + IElementCompositionContext context); }