Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Fasani2017-07-12 12:39:32 +0000
committerLaurent Fasani2017-07-12 12:39:32 +0000
commit66c1e400a1943e2a83d1df0a330dba2ddb87926c (patch)
treebee91cb26d1dad0c285df2d01c28f343a9eab179
parentda225241d978bd0c99d8cf527b355848f6d97f43 (diff)
downloadorg.eclipse.sirius-66c1e400a1943e2a83d1df0a330dba2ddb87926c.tar.gz
org.eclipse.sirius-66c1e400a1943e2a83d1df0a330dba2ddb87926c.tar.xz
org.eclipse.sirius-66c1e400a1943e2a83d1df0a330dba2ddb87926c.zip
[516669] Fix DViewQuery.getLoadedRepresentations
* Avoid loading representation if ot loaded. Bug: 516669 Change-Id: I56442fbcb0327a0a1307918e87a9778cacec0b73 Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DViewQuery.java24
1 files changed, 8 insertions, 16 deletions
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DViewQuery.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DViewQuery.java
index 23db3fecb9..8cae91a9ba 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DViewQuery.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/query/DViewQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2016, 2017 THALES GLOBAL SERVICES.
* 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
@@ -14,6 +14,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.viewpoint.DRepresentation;
@@ -21,12 +22,10 @@ import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DView;
import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
import com.google.common.collect.UnmodifiableIterator;
/**
- * A class aggregating all the queries (read-only!) having a {@link DView} as a
- * starting point.
+ * A class aggregating all the queries (read-only!) having a {@link DView} as a starting point.
*
* @author lfasani
*/
@@ -49,8 +48,7 @@ public final class DViewQuery {
}
/**
- * Get the {@link DRepresentation}s which are already loaded in the dView
- * resourceSet.
+ * Get the {@link DRepresentation}s which are already loaded in the dView resourceSet.
*
* @return an unmodifiable list with the loaded {@link DRepresentation}s
*/
@@ -58,20 +56,14 @@ public final class DViewQuery {
if (activateTrace) {
Thread.dumpStack();
}
- List<DRepresentation> representations = Lists.newArrayList();
- for (DRepresentationDescriptor repDescriptor : dView.getOwnedRepresentationDescriptors()) {
- DRepresentation representation = repDescriptor.getRepresentation();
- if (representation != null) {
- representations.add(representation);
- }
- }
+ List<DRepresentation> representations = dView.getOwnedRepresentationDescriptors().stream().filter(DRepresentationDescriptor::isLoadedRepresentation)
+ .map(DRepresentationDescriptor::getRepresentation).collect(Collectors.toList());
return Collections.unmodifiableList(representations);
}
/**
- * Get all the EObject following a predicate from all the
- * {@link DRepresentation} inside the {@link DView} ({@link DRepresentation}
- * s are not owned by the {@link DView}).
+ * Get all the EObject following a predicate from all the {@link DRepresentation} inside the {@link DView}
+ * ({@link DRepresentation} s are not owned by the {@link DView}).
*
* @param predicate
* predicate used to filter the result

Back to the top