Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2016-05-30 13:38:16 +0000
committerGerrit Code Review @ Eclipse.org2016-05-30 14:49:13 +0000
commit2fd1fc2ab6e806bdd1829ab2f7f4cba327b844c2 (patch)
tree2fc48531a76d756f94c5c34f931fa0cf23bac855 /plugins/infra/gmfdiag
parenta184cf4e46d73cb7e5c820dcc81ae23ce7d6d0c2 (diff)
downloadorg.eclipse.papyrus-2fd1fc2ab6e806bdd1829ab2f7f4cba327b844c2.tar.gz
org.eclipse.papyrus-2fd1fc2ab6e806bdd1829ab2f7f4cba327b844c2.tar.xz
org.eclipse.papyrus-2fd1fc2ab6e806bdd1829ab2f7f4cba327b844c2.zip
Bug 494921 - Improve the ElementTypesConfiguration framework to provide
ClientContext dependent advice execution ordering Change-Id: I20eb9fc1fec583e94e919061acf622203e8000f4
Diffstat (limited to 'plugins/infra/gmfdiag')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DefaultEditHelper.java45
1 files changed, 31 insertions, 14 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DefaultEditHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DefaultEditHelper.java
index 62a32bb3bc2..9ea3d8d6c22 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DefaultEditHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DefaultEditHelper.java
@@ -25,6 +25,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
import org.eclipse.gmf.runtime.emf.type.core.IContainerDescriptor;
import org.eclipse.gmf.runtime.emf.type.core.IEditHelperContext;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
@@ -340,35 +341,51 @@ public class DefaultEditHelper extends AbstractNotifierEditHelper {
advices = (IEditHelperAdvice[]) contextMap.get(EditHelper_Advice);
}
}
-
}
if (advices == null) {
-
if (editHelperContext instanceof EObject) {
- // IElementType type = ElementTypeRegistry.getInstance().getElementType((EObject) editHelperContext, req.getClientContext());
- // advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), type);
advices = ElementTypeRegistry.getInstance().getEditHelperAdvice((EObject) editHelperContext, req.getClientContext());
+ IElementType type = ElementTypeRegistry.getInstance().getElementType((EObject) editHelperContext, req.getClientContext());
+ if (type != null) {
+ Arrays.sort(advices, new AdviceComparator(req.getClientContext().getId()));
+ }
} else if (editHelperContext instanceof IElementType) {
advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), ((IElementType) editHelperContext));
+ Arrays.sort(advices, new AdviceComparator(req.getClientContext().getId()));
} else if (editHelperContext instanceof IEditHelperContext) {
- IElementType type = ((IEditHelperContext) editHelperContext).getElementType();
- if (type != null) {
- advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), type);
+ IClientContext clientContext = ((IEditHelperContext) editHelperContext).getClientContext();
+ IElementType elementType = ((IEditHelperContext) editHelperContext).getElementType();
+ EObject eObject = ((IEditHelperContext) editHelperContext).getEObject();
+
+ if (clientContext != null) {
+ if (elementType != null) {
+ advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), elementType);
+ Arrays.sort(advices, new AdviceComparator(req.getClientContext().getId()));
+ } else if (eObject != null) {
+ IElementType type = ElementTypeRegistry.getInstance().getElementType(eObject, req.getClientContext());
+ if (type != null) {
+ advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), type);
+ Arrays.sort(advices, new AdviceComparator(req.getClientContext().getId()));
+ }
+ }
} else {
- advices = ElementTypeRegistry.getInstance().getEditHelperAdvice(editHelperContext);
+ if (elementType != null) {
+ advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), elementType);
+ Arrays.sort(advices, new AdviceComparator(req.getClientContext().getId()));
+ } else if (eObject != null) {
+ IElementType type = ElementTypeRegistry.getInstance().getElementType(eObject, req.getClientContext());
+ if (type != null) {
+ advices = CacheRegistry.getInstance().getEditHelperAdvice(req.getClientContext(), type);
+ Arrays.sort(advices, new AdviceComparator(req.getClientContext().getId()));
+ }
+ }
}
- } else {
- advices = ElementTypeRegistry.getInstance().getEditHelperAdvice(editHelperContext);
}
}
- if(null != advices){
- Arrays.sort(advices, new AdviceComparator());
- }
-
return advices;
}

Back to the top