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.custom.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.custom.ui')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.classpath2
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet20
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java27
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java92
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java36
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleAttributesQuery.java46
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibleReferencesQuery.java60
9 files changed, 248 insertions, 43 deletions
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;
+ }
+
+}

Back to the top