Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Fasani2017-06-19 08:55:47 +0000
committerLaurent Fasani2017-07-07 15:54:51 +0000
commitc52738d518392b43b20efcddda89cd269d4715e5 (patch)
tree46d56b6ed10fb3442cd7a7c3db4b9c431662aba9
parentac13ee639a074d0b222debb73c252e28a92a95ba (diff)
downloadorg.eclipse.sirius-c52738d518392b43b20efcddda89cd269d4715e5.tar.gz
org.eclipse.sirius-c52738d518392b43b20efcddda89cd269d4715e5.tar.xz
org.eclipse.sirius-c52738d518392b43b20efcddda89cd269d4715e5.zip
[516669] Add DialectManager methods to prepare rep lazy loading
* The following methods implementation on DialectManager load the representation - getRepresentations(EObject , Session ) - getAllRepresentations(Session ) - getRepresentations(RepresentationDescription , Session ) * Consequently, to avoid representation loading, new methods are created to be used in a the lazy representation loading context - getLoadedRepresentations(EObject , Session ) - getAllLoadedRepresentations(Session ) Bug: 516669 Change-Id: I1ae7185ce74978e449242b6d27390dff1dcaec76 Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectManager.java23
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java19
2 files changed, 42 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectManager.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectManager.java
index 8a16978078..72c209e848 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectManager.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectManager.java
@@ -103,6 +103,19 @@ public interface DialectManager extends DialectServices {
Collection<DRepresentation> getRepresentations(EObject semantic, Session session);
/**
+ * Return the representations, of the given session, whose target is the given {@code semantic}. If {@code semantic}
+ * is null, this methods acts as {@code getAllLoadedRepresentations(Session)}</br>
+ * This methods will return ONLY the representations that are loaded.
+ *
+ * @param semantic
+ * targeted semantic element.
+ * @param session
+ * the current session.
+ * @return the non null list of representations.
+ */
+ Collection<DRepresentation> getLoadedRepresentations(EObject semantic, Session session);
+
+ /**
* Return all the representations of the given session.</br>
* This methods will load all the representations.
*
@@ -113,6 +126,16 @@ public interface DialectManager extends DialectServices {
Collection<DRepresentation> getAllRepresentations(Session session);
/**
+ * Return all the representations of the given session.</br>
+ * This methods will return ONLY the representations that are loaded.
+ *
+ * @param session
+ * the current session.
+ * @return the non null list of representations.
+ */
+ Collection<DRepresentation> getAllLoadedRepresentations(Session session);
+
+ /**
* Return the representations, of the given session, from a description.
*
* @param representationDescription
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java
index ae326ac202..03f0ce4916 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java
@@ -254,6 +254,18 @@ public class DialectManagerImpl implements DialectManager {
return reps;
}
+ @Override
+ public synchronized Collection<DRepresentation> getLoadedRepresentations(final EObject semantic, final Session session) {
+ Collection<DRepresentation> reps = null;
+ if (semantic != null) {
+ reps = findAllRepresentationDescriptors(semantic, session).stream().filter(DRepresentationDescriptor::isLoadedRepresentation).map(DRepresentationDescriptor::getRepresentation)
+ .collect(Collectors.toList());
+ } else {
+ reps = getAllLoadedRepresentations(session);
+ }
+ return reps;
+ }
+
private Collection<DRepresentation> findAllRepresentations(EObject semantic, Session session) {
Collection<DRepresentation> result = Lists.newArrayList();
ECrossReferenceAdapter xref = session.getSemanticCrossReferencer();
@@ -279,6 +291,13 @@ public class DialectManagerImpl implements DialectManager {
}
@Override
+ public Collection<DRepresentation> getAllLoadedRepresentations(final Session session) {
+ Collection<DRepresentation> reps = getAllRepresentationDescriptors(session).stream().filter(DRepresentationDescriptor::isLoadedRepresentation).map(DRepresentationDescriptor::getRepresentation)
+ .collect(Collectors.toList());
+ return reps;
+ }
+
+ @Override
public Collection<DRepresentationDescriptor> getRepresentationDescriptors(EObject semantic, Session session) {
Collection<DRepresentationDescriptor> repDescriptors = null;
if (semantic != null) {

Back to the top