diff options
| author | Florian Barbin | 2016-05-27 13:19:36 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2016-05-27 15:27:20 +0000 |
| commit | 6dfbad649980487be4656ccd45c3b3ed6ae3f17d (patch) | |
| tree | 2343af2a91297ccc9213ae7224a74f48b2bbcab5 | |
| parent | 56c4346d342b5a5673ead39428ba4547fab55b0a (diff) | |
| download | org.eclipse.sirius-6dfbad649980487be4656ccd45c3b3ed6ae3f17d.tar.gz org.eclipse.sirius-6dfbad649980487be4656ccd45c3b3ed6ae3f17d.tar.xz org.eclipse.sirius-6dfbad649980487be4656ccd45c3b3ed6ae3f17d.zip | |
[482831] Use the EditingDomain to create the command
* Objects cannot be adapted in ItemProviderAdapter.
* The AdapterFactoryEditingDomain#createCommand implementation delegates
the command creation to IEditingDomainItemProvider if the object can
be adapt to that type. Most of the time, generated ItemProviders
implement IEditingDomainItemProvider. The default createCommand
implementation is inherited from ItemProviderAdapter.
Bug: 482831
Change-Id: I47af0f5a98d2efbc8363417ecd61e8999234788a
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius.ext.emf.edit/src/org/eclipse/sirius/ext/emf/edit/EditingDomainServices.java | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/plugins/org.eclipse.sirius.ext.emf.edit/src/org/eclipse/sirius/ext/emf/edit/EditingDomainServices.java b/plugins/org.eclipse.sirius.ext.emf.edit/src/org/eclipse/sirius/ext/emf/edit/EditingDomainServices.java index caf648d644..5314ad2186 100644 --- a/plugins/org.eclipse.sirius.ext.emf.edit/src/org/eclipse/sirius/ext/emf/edit/EditingDomainServices.java +++ b/plugins/org.eclipse.sirius.ext.emf.edit/src/org/eclipse/sirius/ext/emf/edit/EditingDomainServices.java @@ -38,7 +38,6 @@ import org.eclipse.emf.edit.provider.ITableItemFontProvider; import org.eclipse.emf.edit.provider.ITableItemLabelProvider; import org.eclipse.emf.edit.provider.ITreeItemContentProvider; import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; -import org.eclipse.emf.edit.provider.ItemProviderAdapter; /** * Provides access to common {@link EditingDomain} and @@ -74,7 +73,7 @@ import org.eclipse.emf.edit.provider.ItemProviderAdapter; * In all cases, a {@code getXXXProvider()} service method is also made * available (for example {@link #getLabelProvider(EObject)}, which returns the * item provider itself (or <code>null</code>). The item provider is located - * using the {@link ItemProviderAdapter} returned by the {@link AdapterFactory} + * using the {@code ItemProviderAdapter} returned by the {@link AdapterFactory} * associated to the element's editing domain. This assumes said domain is an * {@link AdapterFactoryEditingDomain} (which is true in practice in Sirius, * which uses a <code>TransactionalEditingDomain</code> that inherits from @@ -125,7 +124,7 @@ import org.eclipse.emf.edit.provider.ItemProviderAdapter; * <h4>Command-related Services</h4> * <p> * A series of service methods can be used to invoke the standard EMF Commands - * available from {@link ItemProviderAdapter}'s various + * available from {@code ItemProviderAdapter}'s various * {@code createXXXCommand()} methods. Note that contrary to the * {@code createXXXCommand()} methods which simply returns a {@link Command} * instance, the service methods exposed in this class will directly @@ -145,9 +144,11 @@ import org.eclipse.emf.edit.provider.ItemProviderAdapter; * </ul> * <p> * The implementation of these services delegate to the - * {@link ItemProviderAdapter#createCommand(Object, EditingDomain, Class, CommandParameter)} - * method, so any customization made in the {@link ItemProviderAdapter}'s - * implementation will be taken into account. + * {@link EditingDomain#createCommand(Class, CommandParameter)} which delegates + * to the IEditingDomainItemProvider#createCommand(Object, EditingDomain, Class, + * CommandParameter) method, so any customization made in the + * {@code IEditingDomainItemProvider}'s implementation will be taken into + * account. * * @author pcdavid */ @@ -188,10 +189,6 @@ public class EditingDomainServices { return null; } - public ItemProviderAdapter getItemProviderAdapter(EObject self) { - return getAdapter(self, ItemProviderAdapter.class); - } - // Services from IItemLabelProvider public IItemLabelProvider getLabelProvider(EObject self) { @@ -567,17 +564,14 @@ public class EditingDomainServices { } } - // Commands: createXXXCommand from ItemProviderAdapter + // Commands: createXXXCommand from EditingDomain.createCommand private void performCommand(EObject self, Class<? extends Command> cmdClass, CommandParameter param) { - ItemProviderAdapter ipa = getItemProviderAdapter(self); - if (ipa != null) { - EditingDomain domain = getEditingDomain(self); - if (domain != null) { - Command cmd = ipa.createCommand(self, domain, cmdClass, param); - CommandStack stack = domain.getCommandStack(); - stack.execute(cmd); - } + EditingDomain domain = getEditingDomain(self); + if (domain != null) { + Command cmd = domain.createCommand(cmdClass, param); + CommandStack stack = domain.getCommandStack(); + stack.execute(cmd); } } |
