Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-04-19 12:49:17 +0000
committervlorenzo2012-04-19 12:49:17 +0000
commitaa1877eaae507b5db79f373d1b977082f77686ca (patch)
tree19b8ed406db365559963bc504aeadcd5525d20ab /incoming
parent5aa93bb552106db6b9b40a8f45bf0b8d20499647 (diff)
downloadorg.eclipse.papyrus-aa1877eaae507b5db79f373d1b977082f77686ca.tar.gz
org.eclipse.papyrus-aa1877eaae507b5db79f373d1b977082f77686ca.tar.xz
org.eclipse.papyrus-aa1877eaae507b5db79f373d1b977082f77686ca.zip
371606: [UML Compare] Papyrus should provide a nested editor to compare 2 elements included in the same resource
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371606
Diffstat (limited to 'incoming')
-rw-r--r--incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java30
-rw-r--r--incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java74
-rw-r--r--incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java2
-rw-r--r--incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties1
4 files changed, 68 insertions, 39 deletions
diff --git a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java
index 129abc25f26..95b91cf2895 100644
--- a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java
+++ b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/EMFCompareEditor.java
@@ -83,7 +83,7 @@ public class EMFCompareEditor extends CompareEditor implements IReusableEditor,
}
}
-
+
/**
* @param servicesRegistry
* the service registry
@@ -100,8 +100,8 @@ public class EMFCompareEditor extends CompareEditor implements IReusableEditor,
addListeners();
}
-
- protected EMFCompareEditor(){
+
+ protected EMFCompareEditor() {
//FIXME, used by the compare UMl File Editor, try to merge code
super();
}
@@ -134,17 +134,21 @@ public class EMFCompareEditor extends CompareEditor implements IReusableEditor,
}
}
+ /**
+ * Remove the listener
+ */
protected void removeListeners() {
- if(EMFCompareEditor.this.servicesRegistry != null) {//we are in papyrus
- TransactionalEditingDomain domain = null;
- try {
- domain = EMFCompareEditor.this.servicesRegistry.getService(TransactionalEditingDomain.class);
- } catch (ServiceException e) {
- Activator.log.error(e);
- }
-
- domain.removeResourceSetListener(closeListener);
- }
+ //done by the CloseTriggerlistener. Here, it is too early to remove it
+ // if(EMFCompareEditor.this.servicesRegistry != null) {//we are in papyrus
+ // TransactionalEditingDomain domain = null;
+ // try {
+ // domain = EMFCompareEditor.this.servicesRegistry.getService(TransactionalEditingDomain.class);
+ // } catch (ServiceException e) {
+ // Activator.log.error(e);
+ // }
+ //
+ // domain.removeResourceSetListener(closeListener);
+ // }
}
protected ISashWindowsContainer getISashWindowsContainer() {
diff --git a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java
index 6473c5be345..97d5dd13269 100644
--- a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java
+++ b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/editor/listener/CloseEditorTriggerListener.java
@@ -34,39 +34,68 @@ import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.compare.common.Activator;
+import org.eclipse.papyrus.infra.emf.compare.common.editor.EMFCompareEditor;
+import org.eclipse.papyrus.infra.emf.compare.common.messages.Messages;
-
+/**
+ *
+ * This class listen the close of the nested Compare Editor.
+ * When it is closed,
+ * - it removed it from the model (notation and di files are concerned)
+ * - it remove itself from the list of listener on the editing domain
+ *
+ */
public class CloseEditorTriggerListener extends TriggerListener {
+ /**
+ * The listened model of the editor
+ */
private EObject rawModel;
+ /** the service registry */
private ServicesRegistry registry;
+ /**
+ *
+ * Constructor.
+ *
+ * @param rawModel
+ * the model for the editor to listen
+ * @param registry
+ * the service registry
+ */
public CloseEditorTriggerListener(final EObject rawModel, final ServicesRegistry registry) {
this.rawModel = rawModel;
this.registry = registry;
}
+ /**
+ *
+ * @see org.eclipse.emf.transaction.TriggerListener#trigger(org.eclipse.emf.transaction.TransactionalEditingDomain,
+ * org.eclipse.emf.common.notify.Notification)
+ *
+ * @param domain
+ * @param notification
+ * @return
+ */
@Override
- protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
- int type = notification.getEventType();
- Object feature = notification.getFeature();
+ protected Command trigger(final TransactionalEditingDomain domain, final Notification notification) {
final Object notifier = notification.getNotifier();
IPageMngr mngr = null;
try {
mngr = ServiceUtils.getInstance().getIPageMngr(registry);
} catch (ServiceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Activator.log.error(Messages.CloseEditorTriggerListener_ICantFoundTheIPageManager, e);
}
final IPageMngr mngr2 = mngr;
if(notifier instanceof PageRef) {
- PageRef ref = (PageRef)notifier;
- EObject pageId = ref.getEmfPageIdentifier();
+ final PageRef ref = (PageRef)notifier;
+ final EObject pageId = ref.getEmfPageIdentifier();
if(pageId == rawModel) {
- CompoundCommand command = new CompoundCommand();
- Command sashRemoveComd = new RecordingCommand(domain) {
+ final CompoundCommand command = new CompoundCommand();
+ final Command sashRemoveComd = new RecordingCommand(domain) {
@Override
protected void doExecute() {
@@ -76,26 +105,19 @@ public class CloseEditorTriggerListener extends TriggerListener {
EList<EObject> tabls = rawModel.eResource().getContents();
command.append(sashRemoveComd);
command.append(new RemoveCommand(domain, tabls, rawModel));
+ final Command removeListener = new RecordingCommand(domain) {
- //
- // return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Delete Compare Editor", null) {
- //
- // @Override
- // protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- //
- //// mngr2.removePage(rawModel);
- //// int index = ((PageRef)notifier).getParent().getChildren().indexOf(notifier);
- //// ((PageRef)notifier).getParent().removePage(index);
- //
- // //we remove the rawModel of its resource
- // rawModel.eResource().getContents().remove(rawModel);
- // return null;
- // }
- // });
+ @Override
+ protected void doExecute() {
+ //we remove this listener from the editingdomain
+ //it can't be done in the class which set it, because it would be removed too early
+ domain.removeResourceSetListener(CloseEditorTriggerListener.this);
+ }
+ };
+ command.append(removeListener);
return command;
}
}
return null;
}
-
}
diff --git a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java
index 2ddea62ba56..db86b67cfdd 100644
--- a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java
+++ b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/Messages.java
@@ -6,6 +6,8 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.emf.compare.common.messages.messages"; //$NON-NLS-1$
+ public static String CloseEditorTriggerListener_ICantFoundTheIPageManager;
+
public static String EMFCompareUtils_CompareTitle;
public static String PapyrusModelCompareEditorInput_CompareTitle;
diff --git a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties
index 32b13c26995..3362eb23ae1 100644
--- a/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties
+++ b/incoming/org.eclipse.papyrus.infra.emf.compare.common/src/org/eclipse/papyrus/infra/emf/compare/common/messages/messages.properties
@@ -1,2 +1,3 @@
+CloseEditorTriggerListener_ICantFoundTheIPageManager=I can't find the IPageManager
EMFCompareUtils_CompareTitle=Compare (''{0}'' - ''{1}'')
PapyrusModelCompareEditorInput_CompareTitle=Compare (''{0}'' - ''{1}'')

Back to the top