diff options
author | Camille Letavernier | 2016-01-13 14:57:07 +0000 |
---|---|---|
committer | Camille Letavernier | 2016-01-18 12:41:09 +0000 |
commit | e470aff3493a4d9c00ecaa22cae442625a50e2c5 (patch) | |
tree | bc5003fe2aa9d339a68fcfd535c45248c95bb42e /plugins/facet | |
parent | 1305645a73413c2c73c3e2dad8e99c409279a342 (diff) | |
download | org.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')
22 files changed, 414 insertions, 65 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.classpath index 2d1a4302f04..b862a296d38 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.classpath +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.settings/org.eclipse.jdt.core.prefs index 4759947300a..62a08f4494d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,10 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF index 3c02f96adb6..a8d56779409 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/META-INF/MANIFEST.MF @@ -22,4 +22,4 @@ Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.emf.facet.custom.core.internal.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.custom.core;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java index 297243fe9aa..332ae9dc16e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java @@ -59,7 +59,7 @@ public interface ICustomizationManager { */
<T> T getCustomValueOf(EObject eObject,
FacetOperation customProperty, Class<T> classs)
- throws CustomizationException;
+ throws CustomizationException;
/**
* This method is used to get the value of a customization property for a
@@ -78,7 +78,7 @@ public interface ICustomizationManager { <T> T getCustomValueOf(EObject eObject,
ETypedElement structuralFeature,
FacetOperation customProperty, Class<T> classs)
- throws CustomizationException;
+ throws CustomizationException;
/**
* This method returns the resourceSet used to manage the customization
@@ -88,4 +88,14 @@ public interface ICustomizationManager { IFacetManager getFacetManager();
+ /**
+ * Multi-valued version of {@link #getCustomValueOf(EObject, FacetOperation, Class)}
+ *
+ * @param eObject
+ * @param visibleReferences
+ * @param class1
+ * @return
+ */
+ <T> List<T> getCustomValuesOf(EObject eObject, FacetOperation customProperty, Class<T> class1) throws CustomizationException;;
+
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java index bf12983c637..02816817be2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java @@ -55,14 +55,16 @@ public class CustomizationManager implements ICustomizationManager { this.facetManager.getManagedFacetSets().remove(customization);
}
+ @Override
public List<Customization> getManagedCustomizations() {
return new CustomizationsDelegatingList(this.facetManager.getManagedFacetSets());
}
+ @Override
public <T> T getCustomValueOf(final EObject eObject,
final FacetOperation customizationProperty,
final Class<T> classs)
- throws CustomizationException {
+ throws CustomizationException {
// Begin precondition checking section
/*
* The scope of a customization property is not available yet in new customization meta-model
@@ -86,11 +88,12 @@ public class CustomizationManager implements ICustomizationManager { return result;
}
+ @Override
public <T> T getCustomValueOf(final EObject eObject,
final ETypedElement eTypedElement,
final FacetOperation customizationProperty,
final Class<T> classs)
- throws CustomizationException {
+ throws CustomizationException {
// Begin precondition checking section
if (eObject == null) {
throw new IllegalArgumentException("The parameter 'eObject' must not be null."); //$NON-NLS-1$
@@ -157,6 +160,7 @@ public class CustomizationManager implements ICustomizationManager { }
}
+ @Override
public ResourceSet getResourceSet() {
return this.facetManager.getResourceSet();
}
@@ -174,7 +178,28 @@ public class CustomizationManager implements ICustomizationManager { }
}
+ @Override
public IFacetManager getFacetManager() {
return this.facetManager;
}
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager#getCustomValuesOf(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation, java.lang.Class)
+ *
+ * @param eObject
+ * @param customProperty
+ * @param class1
+ * @return
+ * @throws CustomizationException
+ */
+ @Override
+ public <T> List<T> getCustomValuesOf(EObject eObject, FacetOperation customizationProperty, Class<T> classs) throws CustomizationException {
+ List<T> result = null;
+ try {
+ result = this.facetManager.getOrInvokeMultiValued(eObject, customizationProperty, classs);
+ } catch (final Exception e) {
+ throw new CustomizationException(e);
+ }
+ return result;
+ }
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.classpath index 2d1a4302f04..b862a296d38 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.classpath +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.settings/org.eclipse.jdt.core.prefs index 4759947300a..62a08f4494d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,10 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF index 40375517a3a..e895e11360e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF @@ -25,4 +25,4 @@ Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.emf.facet.custom.ui.internal.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.custom.ui;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet index 0399612b056..93197289336 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet @@ -307,6 +307,26 @@ <query
xsi:type="query:FalseLiteralQuery"/>
</facetOperations>
+ <facetOperations
+ name="visibleReferences"
+ upperBound="-1">
+ <eType
+ xsi:type="ecore:EClass"
+ href="http://www.eclipse.org/emf/2002/Ecore#//EReference"/>
+ <query
+ xsi:type="javaQuery:JavaQuery"
+ implementationClassName="org.eclipse.papyrus.emf.facet.custom.ui.internal.query.DefaultVisibleReferencesQuery"/>
+ </facetOperations>
+ <facetOperations
+ name="visibleAttributes"
+ upperBound="-1">
+ <eType
+ xsi:type="ecore:EClass"
+ href="http://www.eclipse.org/emf/2002/Ecore#//EAttribute"/>
+ <query
+ xsi:type="javaQuery:JavaQuery"
+ implementationClassName="org.eclipse.papyrus.emf.facet.custom.ui.internal.query.DefaultVisibleAttributesQuery"/>
+ </facetOperations>
</eClassifiers>
<eClassifiers
xsi:type="efacet:Facet"
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java index 1215c4bbfd7..6ae256b8abf 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java @@ -21,7 +21,34 @@ import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperati * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IContentPropertiesHandler {
+
+ /**
+ * The isVisible customization operation
+ *
+ * Since Papyrus 1.2.0, this operation is only used for Objects (Not Features)
+ *
+ * @return
+ */
FacetOperation getIsVisible();
+ /**
+ * Return the collapseLink customization operation
+ *
+ * @return
+ */
public FacetOperation getCollapseLink();
+
+ /**
+ * Return the getVisibleAttributes customization operation
+ *
+ * @return
+ */
+ public FacetOperation getVisibleAttributes();
+
+ /**
+ * Return the getVisibleReferences customization operation
+ *
+ * @return
+ */
+ public FacetOperation getVisibleReferences();
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java index c6e86d7115a..73052bca244 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java @@ -30,7 +30,6 @@ import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.ETypedElement; import org.eclipse.jface.viewers.Viewer; import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; @@ -140,6 +139,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv return result; } + @Override public Object[] getElements(final Object inputElement) { // Reconcile the (possibly changed) list of root elements with our tree element proxies @@ -161,7 +161,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv } for (final Object element : elements) { - if (!isVisible(element, null)) { + if (!isVisible(element)) { continue; } @@ -189,6 +189,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv return eObjectProxy; } + @Override public Object[] getChildren(final Object parentElement) { Object[] result; if (parentElement == null) { @@ -320,6 +321,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv return children; } + @Override public Object getParent(final Object element) { Object result = null; if (element instanceof TreeElement) { @@ -329,28 +331,31 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv return result; } + @Override public boolean hasChildren(final Object element) { return getChildren(element).length > 0; } + @Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { if (oldInput != newInput) { cache.clear(); } } + @Override public ICustomizationManager getCustomizationManager() { return this.customManager; } - public boolean isVisible(final Object object, final ETypedElement eTypedElement) { + public boolean isVisible(final Object object) { Boolean result = Boolean.TRUE; if (object instanceof EObject) { final EObject eObject = (EObject) object; try { - result = this.customManager.getCustomValueOf(eObject, eTypedElement, this.contentHandler.getIsVisible(), Boolean.class); + result = this.customManager.getCustomValueOf(eObject, this.contentHandler.getIsVisible(), Boolean.class); } catch (final CustomizationException e) { Logger.logError(e, Activator.getDefault()); } @@ -376,7 +381,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv private void createReferences(final EObjectTreeElement treeElement, Collection<EStructuralFeature> facetFeatures, Collection<Object> children) { final EObject eObject = treeElement.getEObject(); - for (EReference next : eObject.eClass().getEAllReferences()) { + for (EReference next : getVisibleReferences(eObject)) { createReference(treeElement, eObject, next, children); } for (EStructuralFeature next : facetFeatures) { @@ -387,26 +392,24 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv } private void createReference(EObjectTreeElement treeElement, EObject eObject, EReference eReference, Collection<Object> children) { - if (isVisible(eObject, eReference)) { - if (collapseLink(eObject, eReference)) { - if (eReference.getUpperBound() != 1) { - collectMultiValuedReferenceChildren(eReference, eObject, treeElement, children); - } else { - Object child = getSingleValuedReferenceChild(eReference, eObject, treeElement); - if (child != null) { - children.add(child); - } - } + if (collapseLink(eObject, eReference)) { + if (eReference.getUpperBound() != 1) { + collectMultiValuedReferenceChildren(eReference, eObject, treeElement, children); } else { - children.add(getEReferenceProxy(eReference, treeElement)); + Object child = getSingleValuedReferenceChild(eReference, eObject, treeElement); + if (child != null) { + children.add(child); + } } + } else { + children.add(getEReferenceProxy(eReference, treeElement)); } } private void createAttributes(final EObjectTreeElement treeElement, Collection<EStructuralFeature> facetFeatures, Collection<? super TreeElement> children) { final EObject eObject = treeElement.getEObject(); - for (EAttribute next : eObject.eClass().getEAllAttributes()) { + for (EAttribute next : getVisibleAttributes(eObject)) { createAttribute(treeElement, eObject, next, children); } for (EStructuralFeature next : facetFeatures) { @@ -416,36 +419,48 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv } } + private List<EAttribute> getVisibleAttributes(EObject eObject) { + List<EAttribute> result = null; + try { + result = this.customManager.getCustomValuesOf(eObject, this.contentHandler.getVisibleAttributes(), EAttribute.class); + } catch (final CustomizationException e) { + Logger.logError(e, Activator.getDefault()); + } + + return result == null ? Collections.emptyList() : result; + } + + private List<EReference> getVisibleReferences(EObject eObject) { + List<EReference> result = null; + try { + result = this.customManager.getCustomValuesOf(eObject, this.contentHandler.getVisibleReferences(), EReference.class); + } catch (final CustomizationException e) { + Logger.logError(e, Activator.getDefault()); + } + + return result == null ? Collections.emptyList() : result; + } + private void createAttribute(EObjectTreeElement treeElement, EObject eObject, EAttribute eAttribute, Collection<? super TreeElement> children) { - if (isVisible(eObject, eAttribute)) { - TreeElement eAttributeTreeElement = getEAttributeProxy(eAttribute, treeElement); - if (eAttributeTreeElement != null) { - children.add(eAttributeTreeElement); - } + TreeElement eAttributeTreeElement = getEAttributeProxy(eAttribute, treeElement); + if (eAttributeTreeElement != null) { + children.add(eAttributeTreeElement); } } private EReferenceTreeElement createReferenceProxy(final EReference reference, final EObjectTreeElement parent) { - final EObject eObject = parent.getEObject(); - if (isVisible(eObject, reference)) { - final EReferenceTreeElement referenceProxy = TreeproxyFactory.eINSTANCE.createEReferenceTreeElement(); - referenceProxy.setEReference(reference); - referenceProxy.setParent(parent); - return referenceProxy; - } - return null; + final EReferenceTreeElement referenceProxy = TreeproxyFactory.eINSTANCE.createEReferenceTreeElement(); + referenceProxy.setEReference(reference); + referenceProxy.setParent(parent); + return referenceProxy; } private EAttributeTreeElement createAttributeProxy(final EAttribute attribute, final EObjectTreeElement parent) { - final EObject eObject = parent.getEObject(); - if (isVisible(eObject, attribute)) { - final EAttributeTreeElement attributeProxy = TreeproxyFactory.eINSTANCE.createEAttributeTreeElement(); - attributeProxy.setEAttribute(attribute); - attributeProxy.setParent(parent); - return attributeProxy; - } - return null; + final EAttributeTreeElement attributeProxy = TreeproxyFactory.eINSTANCE.createEAttributeTreeElement(); + attributeProxy.setEAttribute(attribute); + attributeProxy.setParent(parent); + return attributeProxy; } private Object getSingleValuedReferenceChild(final EReference eReference, final EObject eObject, final TreeElement parent) { @@ -502,6 +517,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv return (EReferenceTreeElement) cache.get(cacheElement); } + @Override public void dispose() { cache.clear(); rootElements = null; diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java index 482e8939219..a33fef2cef2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java @@ -52,6 +52,8 @@ public class PropertiesHandler implements IContentPropertiesHandler, private static final String IS_ITALIC = "isItalic"; //$NON-NLS-1$
private static final String COLLAPSE_LINK = "collapseLink"; //$NON-NLS-1$
private static final String IS_VISIBLE = "isVisible"; //$NON-NLS-1$
+ private static final String VISIBLE_REFERENCES = "visibleReferences"; //$NON-NLS-1$
+ private static final String VISIBLE_ATTRIBUTES = "visibleAttributes"; //$NON-NLS-1$
private static final String IS_UNDERLINED = "isUnderlined"; //$NON-NLS-1$
private static final String IS_STRUCKTHROUGH = "isStruckthrough"; //$NON-NLS-1$
private static final String TOP_L_OVERLAY = "topLeftOverlay"; //$NON-NLS-1$
@@ -126,56 +128,67 @@ public class PropertiesHandler implements IContentPropertiesHandler, }
+ @Override
public FacetOperation getCollapseLink() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.COLLAPSE_LINK);
}
+ @Override
public FacetOperation getLabelProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.LABEL);
}
+ @Override
public FacetOperation getBackgroundProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.BACKGROUND);
}
+ @Override
public FacetOperation getForegroundProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.FOREGROUND);
}
+ @Override
public FacetOperation getFontNameProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.FONT);
}
+ @Override
public FacetOperation getFontSizeProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.FONT_SIZE);
}
+ @Override
public FacetOperation getIsBoldProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.IS_BOLD);
}
+ @Override
public FacetOperation getIsItalicProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.IS_ITALIC);
}
+ @Override
public FacetOperation getIsVisible() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.IS_VISIBLE);
}
+ @Override
public FacetOperation getIsUnderlinedProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.IS_UNDERLINED);
}
+ @Override
public FacetOperation getIsStruckthroughProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.IS_STRUCKTHROUGH);
@@ -211,6 +224,7 @@ public class PropertiesHandler implements IContentPropertiesHandler, PropertiesHandler.BOTTOM_R_OVERLAY);
}
+ @Override
public FacetOperation getSelectionProperty() {
return getPropertyByName(PropertiesHandler.CUSTOM,
PropertiesHandler.SELECTION);
@@ -306,4 +320,26 @@ public class PropertiesHandler implements IContentPropertiesHandler, return getPropertyByName(PropertiesHandler.TT_CUSTOM,
PropertiesHandler.SHADOW);
}
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler#getVisibleAttributes()
+ *
+ * @return
+ */
+ @Override
+ public FacetOperation getVisibleAttributes() {
+ return getPropertyByName(PropertiesHandler.CUSTOM,
+ PropertiesHandler.VISIBLE_ATTRIBUTES);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler#getVisibleReferences()
+ *
+ * @return
+ */
+ @Override
+ public FacetOperation getVisibleReferences() {
+ return getPropertyByName(PropertiesHandler.CUSTOM,
+ PropertiesHandler.VISIBLE_REFERENCES);
+ }
}
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleAttributesQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleAttributesQuery.java new file mode 100644 index 00000000000..68912cf4308 --- /dev/null +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleAttributesQuery.java @@ -0,0 +1,46 @@ +/***************************************************************************** + * 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.custom.ui.internal.query; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * @author Camille Letavernier + * + */ +public class DefaultVisibleAttributesQuery implements IJavaQuery2<EObject, List<EAttribute>> { + + /** + * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager) + * + * @param source + * @param parameterValues + * @param facetManager + * @return + * @throws DerivedTypedElementException + */ + @Override + public List<EAttribute> evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException { + return Collections.emptyList(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleReferencesQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleReferencesQuery.java new file mode 100644 index 00000000000..c224ee07c8e --- /dev/null +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleReferencesQuery.java @@ -0,0 +1,60 @@ +/***************************************************************************** + * 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.custom.ui.internal.query; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * @author Camille Letavernier + * + */ +public class DefaultVisibleReferencesQuery implements IJavaQuery2<EObject, List<EReference>> { + + /** + * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager) + * + * @param source + * @param parameterValues + * @param facetManager + * @return + * @throws DerivedTypedElementException + */ + @Override + public List<EReference> evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException { + return source.eClass().getEAllReferences().stream().filter( + ref -> !isEmpty(ref, source) // + ).collect(Collectors.toList()); + } + + private boolean isEmpty(EReference reference, EObject source) { + Object value = source.eGet(reference); + if (value == null) { + return true; + } + if (value instanceof Collection) { + return ((Collection<?>) value).isEmpty(); + } + return false; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath index 45f024e850e..b862a296d38 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs index 73da3815343..a0d51c8b4db 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs @@ -1,14 +1,14 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF index dd68c13fe81..dc10e6b24d9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF @@ -23,4 +23,4 @@ Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.efacet.core;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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);
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.classpath index 2d1a4302f04..b862a296d38 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.classpath +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.settings/org.eclipse.jdt.core.prefs index 4759947300a..62a08f4494d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,10 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/META-INF/MANIFEST.MF index 620bacf0b36..a1cd783babc 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.query.java.core/META-INF/MANIFEST.MF @@ -18,4 +18,4 @@ Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.emf.facet.query.java.core.internal.plugin.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.query.java.core;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|