diff options
| author | Laurent Fasani | 2017-05-11 13:02:34 +0000 |
|---|---|---|
| committer | Laurent Fasani | 2017-07-07 15:55:10 +0000 |
| commit | 366d87a710b88df8aefaa2625d8674747817ddbf (patch) | |
| tree | e21b7daba4aff384adcc05f175d68df09804b21a | |
| parent | 96e11b09c677a39b4d68feff1a558784b39e0686 (diff) | |
| download | org.eclipse.sirius-366d87a710b88df8aefaa2625d8674747817ddbf.tar.gz org.eclipse.sirius-366d87a710b88df8aefaa2625d8674747817ddbf.tar.xz org.eclipse.sirius-366d87a710b88df8aefaa2625d8674747817ddbf.zip | |
[516669] Prevent srm resources loading at Session.open
* That commit starts the phase to have the representation lazy loading
effective.
* Load only srm resource for representation that should be opened at
startup
Bug: 516669
Change-Id: I856c578ca21abb20d93ba81f2b2e9f71c9372c46
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
2 files changed, 22 insertions, 43 deletions
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionHelper.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionHelper.java index 6719cad553..578ee4de2c 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionHelper.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionHelper.java @@ -14,6 +14,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import java.util.stream.Collectors; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; @@ -25,6 +26,7 @@ import org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil; import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager; import org.eclipse.sirius.ui.tools.internal.dialogs.RepresentationsSelectionDialog; import org.eclipse.sirius.viewpoint.DRepresentation; +import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; import org.eclipse.sirius.viewpoint.description.RepresentationDescription; import org.eclipse.sirius.viewpoint.description.Viewpoint; import org.eclipse.sirius.viewpoint.provider.Messages; @@ -45,15 +47,12 @@ public final class SessionHelper { } /** - * Open existing representations whose description has the - * <code>showOnStartup</code> flag. + * Open existing representations whose description has the <code>showOnStartup</code> flag. * <p> - * If there is only one such representation, it is opened automatically. If - * there are several, a dialog box opens allowing the user to select which - * ones to open (including none). + * If there is only one such representation, it is opened automatically. If there are several, a dialog box opens + * allowing the user to select which ones to open (including none). * <p> - * No new representations are created. Only the existing ones are - * candidates. + * No new representations are created. Only the existing ones are candidates. * * @param session * the session for which to open the startup representations. @@ -86,15 +85,13 @@ public final class SessionHelper { } /** - * Finds all the existing representations in the session which are marked as - * <code>showOnStartup</code> and hence candidates for being automatically - * opened. + * Finds all the existing representations in the session which are marked as <code>showOnStartup</code> and hence + * candidates for being automatically opened. * * @param session * the session in which to look for representations. - * @return all the existing representations in the session which are marked - * as <code>showOnStartup</code>, in no particular order. May be - * empty, but not <code>null</code>. + * @return all the existing representations in the session which are marked as <code>showOnStartup</code>, in no + * particular order. May be empty, but not <code>null</code>. */ public static Collection<DRepresentation> findAllStartupCandidates(final Session session) { Collection<DRepresentation> candidates = new ArrayList<DRepresentation>(); @@ -102,13 +99,10 @@ public final class SessionHelper { if (!selectedViewpoints.isEmpty()) { Map<RepresentationDescription, Boolean> alreadyCheckedDescriptions = Maps.newHashMap(); - Collection<DRepresentation> allRepresentations = DialectManager.INSTANCE.getAllRepresentations(session); - for (DRepresentation repr : allRepresentations) { - RepresentationDescription description = DialectManager.INSTANCE.getDescription(repr); - if (description != null && SessionHelper.checkStartupDescInSelectedVps(description, alreadyCheckedDescriptions, selectedViewpoints)) { - candidates.add(repr); - } - } + candidates = DialectManager.INSTANCE.getAllRepresentationDescriptors(session).stream().filter(repDesc -> { + RepresentationDescription description = repDesc.getDescription(); + return description != null && SessionHelper.checkStartupDescInSelectedVps(description, alreadyCheckedDescriptions, selectedViewpoints); + }).map(DRepresentationDescriptor::getRepresentation).collect(Collectors.toList()); } return candidates; } @@ -126,18 +120,14 @@ public final class SessionHelper { } /** - * Select which of the specified representations should really be - * automatically opened. If there is only one candidate, it is automatically - * selected. If there are more than one, the user is asked to select the - * ones he wants (including none) through a modal dialog box. + * Select which of the specified representations should really be automatically opened. If there is only one + * candidate, it is automatically selected. If there are more than one, the user is asked to select the ones he + * wants (including none) through a modal dialog box. * * @param representationsOrigin - * A String representing the origin of the candidates (for - * example "from projectName", or - * "from representations file fileName"), or null if no precision - * is needed. This information is displayed in the message of the - * dialog, at the end of the message - * "Select the startup representations to open" + * A String representing the origin of the candidates (for example "from projectName", or "from + * representations file fileName"), or null if no precision is needed. This information is displayed in + * the message of the dialog, at the end of the message "Select the startup representations to open" * @param candidates * the candidate representation to select from. * @return the subset of candidates which are selected for opening. diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesTracker.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesTracker.java index 066752b2c1..875e281b5a 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesTracker.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesTracker.java @@ -29,7 +29,6 @@ import org.eclipse.emf.transaction.RunnableWithResult; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.emf.transaction.util.TransactionUtil; import org.eclipse.sirius.business.api.query.URIQuery; -import org.eclipse.sirius.business.internal.representation.DRepresentationDescriptorToDRepresentationLinkManager; import org.eclipse.sirius.common.tools.DslCommonPlugin; import org.eclipse.sirius.ecore.extender.tool.api.ModelUtils; import org.eclipse.sirius.ext.emf.EReferencePredicate; @@ -38,7 +37,6 @@ import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DView; import org.eclipse.sirius.viewpoint.Messages; import org.eclipse.sirius.viewpoint.SiriusPlugin; -import org.eclipse.sirius.viewpoint.ViewpointPackage; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; @@ -84,7 +82,6 @@ class SessionResourcesTracker { void initialize(IProgressMonitor monitor) { DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.RESOLVE_ALL_KEY); Collection<DAnalysis> analyses = session.allAnalyses(); - resolveAllDRepresentations(analyses); // First resolve all VSM resources used for Sirius to ignore VSM // resources and VSM linked resources (as viewpoint:/environment // resource) as new semantic element @@ -121,13 +118,6 @@ class SessionResourcesTracker { dAnalysisRefresher.initialize(); } - private void resolveAllDRepresentations(Collection<DAnalysis> analyses) { - analyses.stream().flatMap(analysis -> analysis.getOwnedViews().stream()).flatMap(view -> view.getOwnedRepresentationDescriptors().stream()).forEach(repDesc -> { - // get the representation with loadOnDemand=true to force loading the resource - new DRepresentationDescriptorToDRepresentationLinkManager(repDesc).getRepresentation(true); - }); - } - void addAdaptersOnAnalysis(final DAnalysis analysis) { if (semanticResourcesUpdater != null && !analysis.eAdapters().contains(semanticResourcesUpdater)) { analysis.eAdapters().add(semanticResourcesUpdater); @@ -180,11 +170,10 @@ class SessionResourcesTracker { ModelUtils.resolveAll(session.getTransactionalEditingDomain().getResourceSet(), new EReferencePredicate() { @Override public boolean apply(EReference input) { - // Do not resolve derived features except DRepresentationDescriptor#Representation since we force the - // loading of all representation for now. + // Do not resolve derived features // Do not resolve containment/container references : they are // already resolved by the model structural analysis course. - return (!input.isDerived() || ViewpointPackage.eINSTANCE.getDRepresentationDescriptor_Representation().equals(input)) && !input.isContainer() && !input.isContainment(); + return !input.isDerived() && !input.isContainer() && !input.isContainment(); } }); } |
