Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2016-05-17 12:06:34 +0000
committerGerrit Code Review @ Eclipse.org2016-05-17 12:46:20 +0000
commit618a24a09304f3444f90d9c06213599dabb54ea2 (patch)
treeb6fabf9728056fd22a9d421907c337f72a071b81 /plugins/customization
parent99bae43e9ed401e6df981282d41326cd42641dce (diff)
downloadorg.eclipse.papyrus-618a24a09304f3444f90d9c06213599dabb54ea2.tar.gz
org.eclipse.papyrus-618a24a09304f3444f90d9c06213599dabb54ea2.tar.xz
org.eclipse.papyrus-618a24a09304f3444f90d9c06213599dabb54ea2.zip
Bug 493623: [Properties View - Performances] Properties view editor is
very slow (> 2 minutes for opening UML) https://bugs.eclipse.org/bugs/show_bug.cgi?id=493623 - Workaround: Use a dedicated CustomizationManager for the Properties View editor Change-Id: I00c29bb5e121fe789108e81e1c08f6779b7a97ae Signed-off-by: Camille Letavernier <camille.letavernier@cea.fr>
Diffstat (limited to 'plugins/customization')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/Activator.java89
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java8
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/messages/messages.properties2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/AbstractContextualContentProvider.java8
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java10
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextLabelProvider.java5
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java7
7 files changed, 73 insertions, 56 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/Activator.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/Activator.java
index 89c0c48ad26..e9c08f16029 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/Activator.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/Activator.java
@@ -11,13 +11,28 @@
*****************************************************************************/
package org.eclipse.papyrus.customization.properties;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.papyrus.infra.emf.CustomizationComparator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import com.google.common.collect.Sets;
+
/** The activator class controls the plug-in life cycle */
public class Activator extends AbstractUIPlugin {
@@ -66,47 +81,47 @@ public class Activator extends AbstractUIPlugin {
return Activator.plugin;
}
- // private ICustomizationManager fCustomizationManager;
+ private ICustomizationManager fCustomizationManager;
/**
*
* @return the customization manager in charge to adapt element in modisco
*/
- // public ICustomizationManager getCustomizationManager() {
- // if(this.fCustomizationManager == null) {
- // this.fCustomizationManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(new ResourceSetImpl());
- // init(this.fCustomizationManager);
- // }
- // return this.fCustomizationManager;
- //
- // return org.eclipse.papyrus.infra.emf.Activator.getDefault().getCustomizationManager();
- // }
-
- // private void init(final ICustomizationManager customizationManager) {
- // customizationManager.setShowContainer(false);
- // customizationManager.setShowDerivedLinks(true);
- // customizationManager.setShowEmptyLinks(true);
- //
- // try {
- // List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
- // for(MetamodelView metamodelView : registryDefaultCustomizations) {
- // //FIXME: One of the default uiCustom files in Papyrus has a side effect to call resolveAll on the resource set. While this is generally not a problem in Papyrus,
- // //it becomes critical with the properties view customization, as the resource set contains hundreds of proxies to xwt files (Which are really expensive to load)
- // //It seems that this uiCustom query cannot be easily fixed, so we disable it in this context.
- // //The query which tries to (indirectly) resolve all: org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries.IsDiagramContainer
- // //Used by: PapyrusNotationFacet.querySet -> PapyrusNotationFacet.uiCustom
- // if("PapyrusNotationFacet".equals(metamodelView.getName())) {
- // continue; //Disable this specific uiCustom
- // }
- //
- // customizationManager.registerCustomization(metamodelView);
- // }
- //
- // customizationManager.loadCustomizations();
- // } catch (Throwable e) {
- // Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error initializing customizations", e)); //$NON-NLS-1$
- // }
- // }
+ public ICustomizationManager getCustomizationManager() {
+ if (this.fCustomizationManager == null) {
+ this.fCustomizationManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(new ResourceSetImpl());
+ init(this.fCustomizationManager);
+ }
+ return this.fCustomizationManager;
+ }
+
+ private void init(final ICustomizationManager customizationManager) {
+ // the appearance can be customized here:
+
+ // FIXME: One of the default custom files in Papyrus has a side effect to call resolveAll on the resource set. While this is generally not a problem in Papyrus,
+ // it becomes critical with the properties view customization, as the resource set contains hundreds of proxies to xwt files (Which are really expensive to load)
+ // The query which tries to (indirectly) resolve all: org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries.IsDiagramContainer, by using EMFHelper.getUsages()
+ // Find more details in Bug 493623
+ Set<String> enabledCustomizations = Sets.newHashSet("Properties Context", "Properties UI");
+
+ try {
+
+ // load customizations defined as default through the customization
+ // extension
+ ICustomizationCatalogManager customCatalog = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(customizationManager.getResourceSet());
+
+ List<Customization> registryAllCustomizations = customCatalog.getRegisteredCustomizations();
+ List<Customization> orderedCustomizationList = registryAllCustomizations.stream()
+ .filter((c) -> enabledCustomizations.contains(c.getName()))
+ .sorted(new CustomizationComparator())
+ .collect(Collectors.toList());
+
+ customizationManager.getManagedCustomizations().addAll(orderedCustomizationList);
+
+ } catch (Throwable e) {
+ log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error initializing customizations", e)); //$NON-NLS-1$
+ }
+ }
/**
* @return The IPath representing the plugin's preferences folder location
@@ -134,7 +149,7 @@ public class Activator extends AbstractUIPlugin {
* @param path
* The path to the image from the plugin
* @return
- * The Image at the given location, or null if it couldn't be found
+ * The Image at the given location, or null if it couldn't be found
*/
public Image getImage(String pluginId, String path) {
final ImageRegistry registry = getImageRegistry();
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java
index 61109c42ac8..52654c13bbe 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/UIEditor.java
@@ -39,6 +39,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.URIHandler;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
@@ -100,7 +101,7 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
*/
public class UIEditor extends EcoreEditor implements ITabbedPropertySheetPageContributor, CommandStackListener {
- private Set<Preview> previews = new HashSet<Preview>();
+ private Set<Preview> previews = new HashSet<>();
private TreeViewer selectionViewer;
@@ -287,7 +288,7 @@ public class UIEditor extends EcoreEditor implements ITabbedPropertySheetPageCon
}
URIHandler handler = resourceSet.getURIConverter().getURIHandler(resource.getURI());
- Map<String, Object> options = new HashMap<String, Object>();
+ Map<String, Object> options = new HashMap<>();
options.put(URIConverter.OPTION_URI_CONVERTER, resourceSet.getURIConverter());
try {
OutputStream os = handler.createOutputStream(resource.getURI(), options);
@@ -474,6 +475,9 @@ public class UIEditor extends EcoreEditor implements ITabbedPropertySheetPageCon
}
}
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ resourceSet.getLoadOptions().put(XMLResource.OPTION_USE_PACKAGE_NS_URI_AS_LOCATION, false);
+
super.createModel();
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/messages/messages.properties b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/messages/messages.properties
index 6df562915d7..42177f86668 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/messages/messages.properties
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/messages/messages.properties
@@ -51,4 +51,4 @@ UIEditor_FilterViews=Filter views :
WorkspaceContextDeleteAction_0=Delete context model from the local workspace
WorkspaceContextDeleteAction_1=Deleting the property view configuration:
WorkspaceContextEditAction_0=Open editor on context model in the local workspace
-WorkspaceContextEditAction_1=Opening the property view configuration:
+WorkspaceContextEditAction_1=Opening the properties view configuration:
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/AbstractContextualContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/AbstractContextualContentProvider.java
index 5e90766cbfa..97969594261 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/AbstractContextualContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/AbstractContextualContentProvider.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus - bug 485220
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.providers;
@@ -19,11 +19,11 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.customization.properties.Activator;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.ui.util.PropertiesUtil;
import org.eclipse.papyrus.infra.tools.util.ListHelper;
import org.eclipse.papyrus.infra.ui.emf.providers.strategy.SemanticEMFContentProvider;
-import org.eclipse.papyrus.infra.ui.emf.utils.ProviderHelper;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
/**
@@ -49,12 +49,12 @@ public abstract class AbstractContextualContentProvider extends SemanticEMFConte
* The EObject used to retrieve the available contexts
*/
protected AbstractContextualContentProvider(EObject source) {
- super(findContexts(source).toArray(new Context[0]), ProviderHelper.getCustomizationManager());
+ super(findContexts(source).toArray(new Context[0]), Activator.getDefault().getCustomizationManager());
contexts = ListHelper.asList((Context[]) roots);
}
private static List<Context> findContexts(EObject source) {
- List<Context> contexts = new LinkedList<Context>();
+ List<Context> contexts = new LinkedList<>();
Context rootContext = null;
if (source.eResource() != null) {
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java
index 9eeacc4fcf7..81b2a3e1d52 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus - bug 485220
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.providers;
@@ -18,10 +18,10 @@ import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.customization.properties.Activator;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedTreeContentProvider;
import org.eclipse.papyrus.infra.properties.contexts.Context;
import org.eclipse.papyrus.infra.properties.ui.util.PropertiesUtil;
-import org.eclipse.papyrus.infra.ui.emf.utils.ProviderHelper;
/**
* The customization editor's content provider. Based on the EMF Facet
@@ -35,7 +35,7 @@ public class ContextContentProvider extends CustomizedTreeContentProvider {
* Constructor.
*/
public ContextContentProvider() {
- super(ProviderHelper.getCustomizationManager());
+ super(Activator.getDefault().getCustomizationManager());
}
/**
@@ -52,10 +52,10 @@ public class ContextContentProvider extends CustomizedTreeContentProvider {
return null;
}
- Set<EObject> elements = new LinkedHashSet<EObject>();
+ Set<EObject> elements = new LinkedHashSet<>();
elements.addAll(resourceSet.getResources().get(0).getContents());
- Set<Context> allContexts = new LinkedHashSet<Context>();
+ Set<Context> allContexts = new LinkedHashSet<>();
for (EObject element : elements) {
if (element instanceof Context) {
allContexts.addAll(PropertiesUtil.getDependencies((Context) element));
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextLabelProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextLabelProvider.java
index 54270175f5c..3f530445f0c 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextLabelProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextLabelProvider.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus - bug 485220
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.providers;
@@ -18,7 +18,6 @@ import org.eclipse.papyrus.customization.properties.Activator;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.DecoratingCustomizedLabelProvider;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.ResolvingCustomizedLabelProvider;
-import org.eclipse.papyrus.infra.ui.emf.utils.ProviderHelper;
import org.eclipse.swt.graphics.Image;
/**
@@ -33,7 +32,7 @@ public class ContextLabelProvider extends ResolvingCustomizedLabelProvider {
* Constructor.
*/
public ContextLabelProvider() {
- super(new DecoratingCustomizedLabelProvider(ProviderHelper.getCustomizationManager()));
+ super(new DecoratingCustomizedLabelProvider(Activator.getDefault().getCustomizationManager()));
}
@Override
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java
index ab5c49940a4..ec0c5c19b1e 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus - bug 485220
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.providers;
@@ -22,7 +22,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.papyrus.customization.properties.Activator;
import org.eclipse.papyrus.infra.properties.environment.Environment;
import org.eclipse.papyrus.infra.ui.emf.providers.strategy.SemanticEMFContentProvider;
-import org.eclipse.papyrus.infra.ui.emf.utils.ProviderHelper;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
@@ -41,7 +40,7 @@ public class EnvironmentContentProvider extends SemanticEMFContentProvider imple
* different environments.
*/
public EnvironmentContentProvider(EStructuralFeature feature) {
- super(null, feature, getRoots(feature), ProviderHelper.getCustomizationManager());
+ super(null, feature, getRoots(feature), Activator.getDefault().getCustomizationManager());
}
private static EObject[] getRoots(EStructuralFeature feature) {
@@ -50,7 +49,7 @@ public class EnvironmentContentProvider extends SemanticEMFContentProvider imple
return new EObject[0];
}
- List<Object> allObjects = new LinkedList<Object>();
+ List<Object> allObjects = new LinkedList<>();
for (Environment environment : ConfigurationManager.getInstance().getPropertiesRoot().getEnvironments()) {
allObjects.addAll((List<?>) environment.eGet(feature));
}

Back to the top