Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-11-21 14:11:11 +0000
committerCamille Letavernier2013-11-21 14:13:05 +0000
commit9b4af1c8024448f987e6fb93857f80e3b3767798 (patch)
treefcfa38f14c95bc2107cbb813f611349ec8133df6 /plugins
parent9c6c1b24973dd2fc905a33b3a7cd7b02660e5872 (diff)
downloadorg.eclipse.papyrus-9b4af1c8024448f987e6fb93857f80e3b3767798.tar.gz
org.eclipse.papyrus-9b4af1c8024448f987e6fb93857f80e3b3767798.tar.xz
org.eclipse.papyrus-9b4af1c8024448f987e6fb93857f80e3b3767798.zip
354845: [Performances - Model Explorer] really slow with a big model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=354845
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java35
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java24
2 files changed, 34 insertions, 25 deletions
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java
index 265ee913f9e..7354ad1f1c6 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java
@@ -12,9 +12,13 @@
*/
package org.eclipse.papyrus.uml.modelexplorer.queries;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
-import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
@@ -23,9 +27,6 @@ import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery;
import org.eclipse.uml2.uml.Element;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-
/**
* Get the collection of all contained diagrams
* FIXME : delete this class when the bug EMF-Facet 365744 will be corrected!
@@ -35,19 +36,21 @@ import com.google.common.base.Predicate;
@Deprecated
public class GetContainedDiagrams extends AbstractEditorContainerQuery implements IJavaModelQuery<Element, Collection<org.eclipse.gmf.runtime.notation.Diagram>> {
- public Collection<org.eclipse.gmf.runtime.notation.Diagram> evaluate(final Element context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
- Predicate<EStructuralFeature.Setting> p = new Predicate<EStructuralFeature.Setting>() {
- public boolean apply(EStructuralFeature.Setting arg0) {
- return arg0.getEObject() instanceof Diagram ;
- }
- };
- Function<EStructuralFeature.Setting, Diagram> f = new Function<EStructuralFeature.Setting, Diagram>() {
+ public Collection<Diagram> evaluate(final Element context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ List<Diagram> result = new ArrayList<Diagram>();
+ Iterator<EObject> roots = NavigatorUtils.getNotationRoots(context);
+ if(roots == null) {
+ return result;
+ }
- public Diagram apply(EStructuralFeature.Setting arg0) {
- return (Diagram)arg0.getEObject();
+ while(roots.hasNext()) {
+ EObject root = roots.next();
+ if(root instanceof Diagram) {
+ if(EcoreUtil.equals(((Diagram)root).getElement(), context)) {
+ result.add((Diagram)root);
+ }
}
-
- };
- return NavigatorUtils.findFilterAndApply(context, p, f);
+ }
+ return result;
}
}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java
index 547e4d8b4c7..09086c714b5 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java
@@ -12,17 +12,17 @@
*/
package org.eclipse.papyrus.uml.modelexplorer.queries;
+import java.util.Iterator;
+
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery;
-import com.google.common.base.Predicate;
-
/**
* FIXME : delete this class when the bug EMF-Facet 365744 will be corrected!
*
@@ -33,13 +33,19 @@ public class IsDiagramContainer extends AbstractEditorContainerQuery implements
public Boolean evaluate(final EObject context, ParameterValueList parameterValues) throws ModelQueryExecutionException {
- Predicate<EObject> p = new Predicate<EObject>() {
+ Iterator<EObject> roots = NavigatorUtils.getNotationRoots(context);
+ if(roots == null) {
+ return false;
+ }
- public boolean apply(EObject arg0) {
- return arg0 instanceof Diagram && ((Diagram)arg0).getElement() == context;
+ while(roots.hasNext()) {
+ EObject root = roots.next();
+ if(root instanceof Diagram) {
+ if(EcoreUtil.equals(((Diagram)root).getElement(), context)) {
+ return true;
+ }
}
- };
-
- return NavigatorUtils.any(context, NotationPackage.eINSTANCE.getDiagram(), false, p);
+ }
+ return false;
}
}

Back to the top