[430263] Remove the ModelingProjectManagerStartup startup extension

This extension implies that if Sirius is installed, a large part of
Sirius plugins are getting loaded and started even if your are not using
it.

The sessionManagerListener of ModelingProjectManagerImpl, previously
added by this extension point, is now added during the loading of the
first session.
The initialization of a modeling project (detect if the modeling project
is valid, ie with one and only one representations file) is now done at
the first access of this project and not at the Eclipse start.

Warning: If the Sirius Content Management is active (for example in
"Project Explorer"), Sirius plugins are getting loaded and started even
with this fix.

Change-Id: I3c3c3891bca0f2531935931b8ad97abaef01b320
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
index 5357677..c231804 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
@@ -367,6 +367,9 @@
 				<code>Map&lt;String, Collection&lt;String&gt;&gt;</code> instead of Guava&#8217;s 
 				<code>Multimap</code>.
 			</li>
+			<li>
+				<code>org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.initializeAfterLoad()</code> method has been removed. There is no replacement for this method documented as &#171;Not intended to be used by client&#187;.
+			</li>
 		</ul>
 		<h4 id="Changesinorg.eclipse.sirius.ext.base">Changes in 
 			<code>org.eclipse.sirius.ext.base</code>
@@ -1318,4 +1321,4 @@
 			</li>
 		</ul>
 	</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
index ed6cfa7..5d1acfd 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
@@ -106,6 +106,7 @@
 
 * @org.eclipse.sirius.ui.business.api.preferences.DesignerUIPreferencesKeys@ has been renamed into @org.eclipse.sirius.ui.business.api.preferences.SiriusUIPreferencesKeys@
 * Methods @getMissingDependencies()@ and @getMissingDependenciesErrorMessage()@ from @org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelection@ now use @Map<String, Collection<String>>@ instead of Guava's @Multimap@.
+* @org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.initializeAfterLoad()@ method has been removed. There is no replacement for this method documented as "Not intended to be used by client".
 
 h4. Changes in @org.eclipse.sirius.ext.base@
 
diff --git a/plugins/org.eclipse.sirius.ui/plugin.xml b/plugins/org.eclipse.sirius.ui/plugin.xml
index 1a86148..3d86177 100644
--- a/plugins/org.eclipse.sirius.ui/plugin.xml
+++ b/plugins/org.eclipse.sirius.ui/plugin.xml
@@ -662,11 +662,6 @@
       </objectContribution>
    </extension>
   -->
-  <extension point="org.eclipse.ui.startup">
-    <startup
-      class="org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.manager.ModelingProjectManagerStartup">
-    </startup>
-  </extension>  
 
   <extension
          point="org.eclipse.ui.commands">
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java
index ed91ab3..3b85f67 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/api/project/ModelingProjectManager.java
@@ -31,15 +31,6 @@
     ModelingProjectManager INSTANCE = ModelingProjectManagerImpl.init();
 
     /**
-     * Initialize the modeling project manager. This method should be called
-     * only once by the
-     * {@link org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.manager.ui.tools.internal.views.common.modelingproject.manager.ModelingProjectManagerStartup}
-     * .<BR>
-     * Not intended to be used by client.
-     */
-    void initializeAfterLoad();
-
-    /**
      * Load and open a representations file.
      * 
      * @param representationsFileURI
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
index e4bbd83..2c5e0fc 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerImpl.java
@@ -13,6 +13,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
@@ -41,7 +42,6 @@
 import org.eclipse.sirius.business.api.session.SessionListener;
 import org.eclipse.sirius.business.api.session.SessionManager;
 import org.eclipse.sirius.business.api.session.SessionManagerListener;
-import org.eclipse.sirius.business.internal.modelingproject.manager.InitializeModelingProjectJob;
 import org.eclipse.sirius.business.internal.modelingproject.marker.ModelingMarker;
 import org.eclipse.sirius.business.internal.query.ModelingProjectQuery;
 import org.eclipse.sirius.common.tools.api.resource.ResourceSetFactory;
@@ -56,6 +56,7 @@
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 /**
  * A manager for modeling projects.
@@ -92,11 +93,11 @@
     };
 
     /**
-     * List of representations files that are currently loading. There can be
+     * Set of representations files that are currently loading. There can be
      * only one representations file in loading at same time. However there may
      * be many waiting to be loaded.
      */
-    private List<URI> sessionFileLoading = Lists.newArrayList();
+    private Set<URI> sessionFileLoading = Sets.newHashSet();
 
     /**
      * Avoid instantiation.
@@ -116,20 +117,6 @@
     /**
      * {@inheritDoc}
      * 
-     * @see org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager#initializeAfterLoad()
-     */
-    public void initializeAfterLoad() {
-        SessionManager.INSTANCE.addSessionsListener(sessionManagerListener);
-        // Look over all projects to determine the main representations file of
-        // each modeling project.
-        Job job = new InitializeModelingProjectJob();
-        job.setPriority(Job.SHORT);
-        job.schedule();
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
      * @see org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager#loadAndOpenRepresentationsFile(org.eclipse.emf.common.util.URI)
      */
     public void loadAndOpenRepresentationsFile(final URI representationsFileURI) {
@@ -142,6 +129,9 @@
      * @see org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager#loadAndOpenRepresentationsFiles(java.util.List)
      */
     public void loadAndOpenRepresentationsFiles(final List<URI> representationsFilesURIs) {
+        // Add the specific sessions listener (if not already added).
+        SessionManager.INSTANCE.addSessionsListener(sessionManagerListener);
+
         // List only the representations files that are not already loaded or
         // that are not currently in loading.
         Iterator<URI> representationsFilesURIsToLoadIterator = Iterators.filter(representationsFilesURIs.iterator(),
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerStartup.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerStartup.java
deleted file mode 100644
index 855244f..0000000
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/modelingproject/manager/ModelingProjectManagerStartup.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.manager;
-
-import org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager;
-import org.eclipse.ui.IStartup;
-
-/**
- * A startup to initialize the ModelingProjectManager.
- * 
- * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
- */
-public class ModelingProjectManagerStartup implements IStartup {
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IStartup#earlyStartup()
-     */
-    public void earlyStartup() {
-        ModelingProjectManager.INSTANCE.initializeAfterLoad();
-    }
-}