Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableUtil.java')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableUtil.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableUtil.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableUtil.java
index d5a4bbeee92..c99b0e60fba 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableUtil.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/utils/TableUtil.java
@@ -11,15 +11,17 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.common.utils;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
@@ -34,18 +36,27 @@ public class TableUtil {
* @return the list of diagrams associated with the given element
*/
public static List<Table> getAssociatedTables(EObject element, ResourceSet resourceSet) {
+ List<Table> result;
+
if (resourceSet == null) {
- if (element != null && element.eResource() != null) {
- resourceSet = element.eResource().getResourceSet();
- }
+ resourceSet = EMFHelper.getResourceSet(element);
}
- if (resourceSet instanceof ModelSet) {
- Resource notationResource = NotationUtils.getNotationResource((ModelSet) resourceSet);
- return getAssociatedTablesFromNotationResource(element, notationResource);
+ if (resourceSet == null) {
+ // Deny
+ result = Collections.emptyList();
+ } else {
+ result = new ArrayList<Table>(3); // Don't anticipate many
+ for (EStructuralFeature.Setting setting : EMFHelper.getUsages(element)) {
+ if (setting.getEStructuralFeature() == NattablePackage.Literals.TABLE__OWNER) {
+ if (EMFHelper.getResourceSet(setting.getEObject()) == resourceSet) {
+ result.add((Table) setting.getEObject());
+ }
+ }
+ }
}
- return Collections.emptyList();
+ return result;
}
/**

Back to the top