Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2016-01-13 14:57:07 +0000
committerCamille Letavernier2016-01-18 12:41:09 +0000
commite470aff3493a4d9c00ecaa22cae442625a50e2c5 (patch)
treebc5003fe2aa9d339a68fcfd535c45248c95bb42e /plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui
parent1305645a73413c2c73c3e2dad8e99c409279a342 (diff)
downloadorg.eclipse.papyrus-e470aff3493a4d9c00ecaa22cae442625a50e2c5.tar.gz
org.eclipse.papyrus-e470aff3493a4d9c00ecaa22cae442625a50e2c5.tar.xz
org.eclipse.papyrus-e470aff3493a4d9c00ecaa22cae442625a50e2c5.zip
485539: [Performances - Facet Manager] FacetManager recomputes the
Facets for a given element too many times https://bugs.eclipse.org/bugs/show_bug.cgi?id=485539 - Replace the custom property isVisible(EObject, EStructuralFeature) with getVisibleReferences(EObject) and getVisibleAttributes(EObject). This improves performances a lot, especially for complex metamodels such as UML Change-Id: I170b70774b8f6f19ded7fe1e824097b0c5cf7300 Signed-off-by: Camille Letavernier <camille.letavernier@cea.fr>
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java109
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java4
2 files changed, 111 insertions, 2 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java
new file mode 100644
index 00000000000..467b04019a3
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java
@@ -0,0 +1,109 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.ETypedElement;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
+
+/**
+ * @author Camille Letavernier
+ *
+ */
+//Moved from FacetUtils to clarify
+public class FacetUIUtils {
+
+ /**
+ * This methods returns all the known (registered) eTypedElements.
+ *
+ * @param resourceSet
+ * the eTypedElement search will be done in/using this resourceSet
+ * @return all the known (registered) eTypedElements
+ */
+ public static Set<? extends ETypedElement> getETypedElements(
+ final ResourceSet resourceSet) {
+ final Set<ETypedElement> result = new HashSet<ETypedElement>();
+ final Collection<Object> ePackages = EPackage.Registry.INSTANCE
+ .values();
+ for (Object object : ePackages) {
+ EPackage ePackage = null;
+ if (object instanceof EPackage) {
+ ePackage = (EPackage) object;
+ } else if (object instanceof EPackage.Descriptor) {
+ final EPackage.Descriptor descriptor = (EPackage.Descriptor) object;
+ ePackage = descriptor.getEPackage();
+ }
+ if (ePackage != null) {
+ result.addAll(getETypedElements(ePackage));
+ }
+ }
+ result.addAll(getFacetETypedElements(resourceSet));
+ return result;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static Set<? extends ETypedElement> getFacetETypedElements(
+ final ResourceSet resourceSet) {
+ final Set<ETypedElement> result = new HashSet<ETypedElement>();
+ final Collection<FacetSet> facetSets = IFacetSetCatalogManagerFactory.DEFAULT
+ .getOrCreateFacetSetCatalogManager(resourceSet)
+ .getRegisteredFacetSets();
+ for (FacetSet facetSet : facetSets) {
+ result.addAll(getETypedElements(facetSet));
+ }
+ return result;
+ }
+
+ public static List<ETypedElement> getETypedElements(final EPackage ePackage) {
+ final List<ETypedElement> result = new ArrayList<ETypedElement>();
+ for (EClassifier eClassifier : ePackage.getEClassifiers()) {
+ result.addAll(getETypedElements(eClassifier));
+ }
+ for (EPackage subPackage : ePackage.getESubpackages()) {
+ result.addAll(getETypedElements(subPackage));
+ }
+ return result;
+ }
+
+ /**
+ * @since 0.3
+ */
+ public static List<ETypedElement> getETypedElements(
+ final EClassifier eClassifier) {
+ final List<ETypedElement> result = new ArrayList<ETypedElement>();
+ if (eClassifier instanceof Facet) {
+ final Facet facet = (Facet) eClassifier;
+ result.addAll(facet.getFacetElements());
+ result.addAll(facet.getFacetOperations());
+ } else if (eClassifier instanceof EClass) {
+ final EClass eClass = (EClass) eClassifier;
+ result.addAll(eClass.getEAllStructuralFeatures());
+ result.addAll(eClass.getEAllOperations());
+ }
+ return result;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java
index 4704beeb09c..ddf7256cd5d 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java
@@ -252,7 +252,7 @@ public class NavigationView extends ViewPart implements INavigationView {
final GridLayout groupLayout = new GridLayout();
queryGroup.setLayout(groupLayout);
final Collection<ETypedElement> eTypedElements = new ArrayList<ETypedElement>(
- FacetUtils.getETypedElements(getResourceSet()));
+ FacetUIUtils.getETypedElements(getResourceSet()));
final Collection<? extends EObject> knownEPackages = IFacetSetCatalogManagerFactory.DEFAULT
.getOrCreateFacetSetCatalogManager(this.getResourceSet())
.getRegisteredFacetSets();
@@ -264,7 +264,7 @@ public class NavigationView extends ViewPart implements INavigationView {
getCustomizationManager(),
knownEPackages);
this.navSelection.setAvailableETypedElements(eTypedElements);
- }
+ }
private void createContextGroup(final Composite parent) {
final Group contextGroup = new Group(parent, SWT.NONE);

Back to the top