[501355] Use deprecated constructor to get a root semantic model from
session

Change-Id: I4b7018166b94a2714df1eada5278bf57978dfdbb
Signed-off-by: Faycal Abka <faycal.abka@altran.com>
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/actions/OpenSessionAction.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/actions/OpenSessionAction.java
index 88468ce..6f60d17 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/actions/OpenSessionAction.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/actions/OpenSessionAction.java
@@ -208,9 +208,6 @@
 				} catch (PartInitException exception) {

 					StringBuilder loggerMessage = new StringBuilder(".run(..) _ Activity Explorer not Found."); //$NON-NLS-1$

 					loggerMessage.append(exception.getMessage());

-					// __logger.warn(new

-					// EmbeddedMessage(loggerMessage.toString(),

-					// IReportManagerDefaultComponents.UI), exception);

 				}

 			}

 		};

diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/input/ActivityExplorerEditorInput.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/input/ActivityExplorerEditorInput.java
index 639bc86..2e61f5c 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/input/ActivityExplorerEditorInput.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/input/ActivityExplorerEditorInput.java
@@ -12,7 +12,6 @@
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
-import java.util.Iterator;
 
 import org.eclipse.amalgam.explorer.activity.ui.ActivityExplorerActivator;
 import org.eclipse.amalgam.explorer.activity.ui.api.editor.Messages;
@@ -26,7 +25,6 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.sirius.business.api.session.Session;
@@ -47,13 +45,14 @@
 	 * File linked to this activity explorer.
 	 */
 	private static final String ACTIVITY_EXPLORER_FILE = "activityExplorerFile"; //$NON-NLS-1$
+	
 
 	/**
 	 * status of the input FIXME why this is added here?
 	 */
 	@Deprecated
 	private IStatus _status;
-
+	
 	public ActivityExplorerEditorInput(IFile file) {
 		super(file);
 		loadState(getFile());
@@ -63,6 +62,7 @@
 	public ActivityExplorerEditorInput(Session session, EObject eObject) {
 		this(SessionHelper.getFirstAnalysisFile((DAnalysisSession) session));
 	}
+	
 
 	/**
 	 * Dispose.
@@ -229,21 +229,15 @@
 		memento_p.putString(ACTIVITY_EXPLORER_FILE, getFile().getFullPath().toString());
 	}
 
+	/**
+	 * 
+	 * @param session_p
+	 * @return model root of the first semantic resource managed by session_p or null
+	 * 
+	 * @deprecated will be deteled
+	 */
 	@Deprecated
-	public static EObject getRootSemanticElement(Session session_p) {
-		EObject result = null;
-		if (session_p != null) {
-			Iterator<Resource> semanticResources = session_p.getSemanticResources().iterator();
-			// Iterate over semantic resources to search for a project.
-			while (semanticResources.hasNext()) {
-				Resource semanticResource = semanticResources.next();
-				EObject object = semanticResource.getContents().get(0);
-				if (object instanceof EObject) {
-					result = object;
-					break;
-				}
-			}
-		}
-		return result;
+	public EObject getRootSemanticElement(Session session_p) {
+		return SessionHelper.getRootSemanticModel(session_p);
 	}
 }
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/SessionHelper.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/SessionHelper.java
index c586bca..9b523c1 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/SessionHelper.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/helper/SessionHelper.java
@@ -24,6 +24,13 @@
 import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession;
 
 public class SessionHelper {
+	
+	/**
+	 * @deprecated never use this. It is introduced for technical reason and will be removed
+	 */
+	@Deprecated
+	private static final String AFM_EXTENSION = "afm";
+	
 	public static IFile getFirstAnalysisFile(DAnalysisSession session_p) {
 		IFile result = null;
 		Resource resource = session_p.getSessionResource();
@@ -40,8 +47,13 @@
 	 * Get the project (only one instance) for given session.
 	 * 
 	 * @param session_p
-	 * @return must be not <code>null</code>.
+	 * @return model root of the first semantic resource managed by session_p or null
+	 * 
+	 * @deprecated will be removed. Do not base client code by calling this method
+	 * or calling {@link org.eclipse.amalgam.explorer.activity.ui.api.manager.ActivityExplorerManager.getRootSemanticModel()}
+	 * 
 	 */
+	@Deprecated
 	public static EObject getRootSemanticModel(Session session_p) {
 
 		EObject result = null;
@@ -49,6 +61,10 @@
 		// Iterate over semantic resources to search for a project.
 		while (semanticResources.hasNext()) {
 			Resource semanticResource = semanticResources.next();
+			String fileExtension = semanticResource.getURI().fileExtension();
+			if (fileExtension == null || fileExtension.isEmpty() || AFM_EXTENSION.equals(fileExtension)){
+				continue;
+			}
 			result = semanticResource.getContents().get(0);
 			break;
 		}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/manager/ActivityExplorerManager.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/manager/ActivityExplorerManager.java
index 77c6f79..aaea62c 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/manager/ActivityExplorerManager.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/manager/ActivityExplorerManager.java
@@ -86,7 +86,11 @@
 	 * session.
 	 * 
 	 * @return EObject
+	 * 
+	 * @deprecated will be remove. Client must not call this method
+	 * 
 	 */
+	@Deprecated
 	public EObject getRootSemanticModel() {
 		ActivityExplorerEditor editor = getEditor();
 		if (editor != null) {
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/ActivityExplorerEditorInputFactory.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/ActivityExplorerEditorInputFactory.java
index ebc5562..10f6c8d 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/ActivityExplorerEditorInputFactory.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/ActivityExplorerEditorInputFactory.java
@@ -40,14 +40,17 @@
 	 */
 	public IAdaptable createElement(IMemento memento_p) {
 		String path = memento_p.getString(ACTIVITY_EXPLORER_FILE);
+		
 		if (path == null || path.isEmpty()) {
 			IStatus status = new Status(IStatus.ERROR, ActivityExplorerActivator.ID,
 					"Activity Explorer cannot find the path of file to restaure"); //$NON-NLS-1$
 			ActivityExplorerLoggerService.getInstance().log(status);
 			return null;
 		}
+		
 
 		IResource file = getPlatformResource(new Path(path));
+		
 		if (file != null && file instanceof IFile) {
 			ActivityExplorerEditorInput input = new ActivityExplorerEditorInput((IFile) file);
 			return input;