[531477] [Activity Explorer] Activity Explorer becomes "Process Map"
after a restart with null session 

Bug 531477

Conflicts:
	plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java

Change-Id: I3d3f2737373bbbd73f8f09b9344f3eeb7f605719
Signed-off-by: Ali AKAR <ali.akar82@gmail.com>
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
index da05ca8..36b896b 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/ActivityExplorerEditor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2017 THALES GLOBAL SERVICES.
+ * Copyright (c) 2006, 2018 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
@@ -19,6 +19,7 @@
 import org.eclipse.amalgam.explorer.activity.ui.api.editor.input.ActivityExplorerEditorInput;
 import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.CommonActivityExplorerPage;
 import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.DocumentationActivityExplorerPage;
+import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.MessagePage;
 import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.OverviewActivityExplorerPage;
 import org.eclipse.amalgam.explorer.activity.ui.api.manager.ActivityExplorerManager;
 import org.eclipse.amalgam.explorer.activity.ui.internal.extension.point.manager.ActivityExplorerExtensionManager;
@@ -32,9 +33,10 @@
 import org.eclipse.jface.viewers.ILabelDecorator;
 import org.eclipse.sirius.business.api.session.Session;
 import org.eclipse.sirius.business.api.session.SessionListener;
-import org.eclipse.sirius.business.api.session.SessionStatus;
 import org.eclipse.sirius.ui.business.api.session.IEditingSession;
 import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
 import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.events.ControlListener;
 import org.eclipse.swt.graphics.Image;
@@ -81,6 +83,8 @@
      */
     private int backToActivePage = 0;
 
+    protected IFormPage messagePage;
+
     public ActivityExplorerEditor() {
         ActivityExplorerManager.INSTANCE.setEditor(this);
         ActivityExplorerManager.INSTANCE.addActivityExplorerEditorListener(this);
@@ -118,14 +122,12 @@
             loggerMessage.append(exception.getMessage());
 
             ActivityExplorerLoggerService.getInstance().log(IStatus.WARNING, loggerMessage.toString(), exception);
-
         }
 
         // Add a control listener to force reflow
         getContainer().addControlListener(new ControlListener() {
             public void controlMoved(ControlEvent cevent) {
                 // Do nothing.
-
             }
 
             public void controlResized(ControlEvent cevent) {
@@ -133,7 +135,6 @@
                 IManagedForm managedForm = activePageInstance.getManagedForm();
                 managedForm.reflow(true);
             }
-
         });
         // Refresh dirty state when the part is activated : open time for
         // instance.
@@ -150,7 +151,6 @@
      * 
      * @return Vector<AbstractActivityExplorerPage>
      */
-    @SuppressWarnings("unchecked")
     public Vector<CommonActivityExplorerPage> getPages() {
         Vector<CommonActivityExplorerPage> result = new Vector<CommonActivityExplorerPage>(pages.size());
         for (Object obj : pages) {
@@ -166,10 +166,10 @@
      */
     public void removeAllPages() {
         /*
-		 * Removing first active page leads to reactivate (i.e, create the content if it wasn't) the next active one
-		 * The next will be deleted. For performance reasons we don't allow recreating page content
-		 * that will be deleted just after. see the behavior of the editor in org.eclipse.ui.forms.editor.FormEditor.pageChange(int) when the current page change:
-		 * That fixe bug: 487226
+         * Removing first active page leads to reactivate (i.e, create the content if it wasn't) the next active one The
+         * next will be deleted. For performance reasons we don't allow recreating page content that will be deleted
+         * just after. see the behavior of the editor in org.eclipse.ui.forms.editor.FormEditor.pageChange(int) when the
+         * current page change: That fixe bug: 487226
          */
         backToActivePage = getActivePage();
         int count = super.getPageCount();
@@ -179,8 +179,7 @@
             }
         }
         /*
-		 * As all page are removed before, the remaining is the first page
-		 * which it index is 0
+         * As all page are removed before, the remaining is the first page which it index is 0
          */
         this.removePage(0);
     }
@@ -197,17 +196,15 @@
 
     private void addContributedPages(List<CommonActivityExplorerPage> contributedPages) {
         for (CommonActivityExplorerPage page : contributedPages) {
-            if ((page instanceof IVisibility) && !(page.getPosition() == 0)) {
+            if ((page instanceof IVisibility) && page.getPosition() != 0) {
                 try {
                     if (page.isVisible()) {
                         addNewPage(page);
                     }
-                } catch (Throwable e) {
+                } catch (Exception e) {
 
-					StringBuilder loggerMessage = new StringBuilder(
-							"ActivityExplorerEditor.addContributedPages(..) _ "); //$NON-NLS-1$
-					loggerMessage
-							.append("An error was occured at the evaluation of the predicat or the adding of page ") //$NON-NLS-1$
+                    StringBuilder loggerMessage = new StringBuilder("ActivityExplorerEditor.addContributedPages(..) _ "); //$NON-NLS-1$
+                    loggerMessage.append("An error was occured at the evaluation of the predicat or the adding of page ") //$NON-NLS-1$
                             .append(page.getId());
                     loggerMessage.append(". Refer to the exception stack for more details"); //$NON-NLS-1$
 
@@ -240,14 +237,11 @@
                         // Log visibile pages with index 0 which are not
                         // Overview pages
                         if (page.isVisible()) {
-							StringBuilder loggerMessage = new StringBuilder(
-									"ActivityExplorerEditor.addOverviewPage(..) _ "); //$NON-NLS-1$
+                            StringBuilder loggerMessage = new StringBuilder("ActivityExplorerEditor.addOverviewPage(..) _ "); //$NON-NLS-1$
                             loggerMessage.append("Page ").append(page.getId()); //$NON-NLS-1$
-							loggerMessage
-									.append(" is not an overview page. Only overview pages are allowed to index 0"); //$NON-NLS-1$
+                            loggerMessage.append(" is not an overview page. Only overview pages are allowed to index 0"); //$NON-NLS-1$
 
-							ActivityExplorerLoggerService.getInstance().log(IStatus.WARNING, loggerMessage.toString(),
-									null);
+                            ActivityExplorerLoggerService.getInstance().log(IStatus.WARNING, loggerMessage.toString(), null);
                         }
                     }
                 } else {
@@ -256,26 +250,92 @@
                     // different from 0, we stop.
                     break;
                 }
-            } catch (Throwable e) {
+            } catch (Exception e) {
                 // Unknown errors from contributions
                 StringBuilder loggerMessage = new StringBuilder("ActivityExplorerEditor.addOverviewPage(..) _ "); //$NON-NLS-1$
                 loggerMessage.append("An error was occured at the evaluation of the predicat of page ") //$NON-NLS-1$
                         .append(page.getId());
                 loggerMessage.append(". Refer to the exception stack for more details"); //$NON-NLS-1$
-
                 ActivityExplorerLoggerService.getInstance().log(IStatus.ERROR, loggerMessage.toString(), e);
             }
         }
 
-        // Add the overview page
-        if (overviewPage != null) {
-            overviewPage.initialize(this);
-        } else {
-            // default page
-            overviewPage = new OverviewActivityExplorerPage(this);
+        if (overviewPage == null) {
+            Session session = getEditorInput().getSession();
+            if (session != null) {
+                overviewPage = new OverviewActivityExplorerPage(this);
+            } else {
+                setMessagePage(createNullSessionPage());
+            }
         }
 
-        addPage(overviewPage);
+        // Initialize and add the overview page
+        if (overviewPage != null) {
+            overviewPage.initialize(this);
+            addPage(overviewPage);
+        }
+    }
+
+    protected IFormPage createNullSessionPage() {
+        return new MessagePage(this, "Authentication failed!\nContent access has failed at session opening, you can try to open session.", "Message");
+    }
+
+    protected IFormPage getMessagePage() {
+        return messagePage;
+    }
+
+    protected void setMessagePage(IFormPage messagePage) {
+        if (!isDisposed()) {
+            // Remove old message page if present
+            if (this.messagePage != null) {
+                int pageIndex = this.messagePage.getIndex();
+                /*
+                 * !! Important Note !! Before removing the page, get it's selectable user interface and set page
+                 * control to null. The page control will not be disposed in MultiPageEditorPart#removePage(int).
+                 */
+                if (pageIndex >= 0 && pageIndex < pages.size()) {
+                    CTabItem item = ((CTabFolder) getContainer()).getItem(pageIndex);
+                    if (item != null) {
+                        item.setControl(null);
+                    }
+                }
+                // Call remove page
+                removePage(pageIndex);
+            }
+
+            // Add new message page if not null
+            if (messagePage != null) {
+                try {
+                    addPage(messagePage);
+                    if (getActivePage() == -1) {
+                        setActivePage(0);
+                    }
+                } catch (PartInitException ex) {
+                    ActivityExplorerLoggerService.getInstance().log(IStatus.ERROR, ex.getMessage(), ex);
+                }
+            }
+        }
+        this.messagePage = messagePage;
+    }
+
+    protected synchronized void finishCreatePages() {
+        if (!isDisposed() && getMessagePage() != null) {
+            // Remove previously displayed message page
+            setMessagePage(null);
+
+            // Try to create actual pages
+            createPages();
+
+            // Activate first page if no other page is already active
+            if (getActivePage() == -1) {
+                setActivePage(0);
+            }
+        }
+
+    }
+
+    protected boolean isDisposed() {
+        return pages == null;
     }
 
     /**
@@ -327,8 +387,7 @@
                 _propertySheetPage.dispose();
                 _propertySheetPage = null;
             }
-            // Unregister Sirius session listener.
-            unregisterSession();
+
             // Remove part listener.
             if (null != _partListener) {
                 editorSite.getPage().removePartListener(_partListener);
@@ -343,7 +402,6 @@
         if (null != getEditorInput()) {
             getEditorInput().dispose();
         }
-
     }
 
     /**
@@ -351,8 +409,8 @@
      */
     @Override
     public void doSave(IProgressMonitor monitor) {
-    	// Ignore. This method is not called because ActivityExplorerEditor implements ISaveablesSource.
-    	// All saves will go through the ISaveablesSource / Saveable protocol.
+        // Ignore. This method is not called because ActivityExplorerEditor implements ISaveablesSource.
+        // All saves will go through the ISaveablesSource / Saveable protocol.
     }
 
     /**
@@ -361,8 +419,7 @@
      */
     private String getBundleId(Object obj) {
         Bundle bundle = FrameworkUtil.getBundle(obj.getClass());
-    if (bundle != null)
-    {
+        if (bundle != null) {
             return bundle.getSymbolicName();
         }
         return obj.getClass().getCanonicalName();
@@ -394,7 +451,7 @@
      * {@inheritDoc}
      */
     public String getContributorId() {
-        return getSite().getId();// PROPERTIES_CONTRIBUTOR;
+        return getSite().getId();
     }
 
     /**
@@ -452,25 +509,12 @@
     }
 
     /**
-	 * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite,
-	 *      org.eclipse.ui.IEditorInput)
+     * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
      */
     @Override
     public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-
-        /*
-		 * TODO Delete
-		 *
-		IStatus status = ((ActivityExplorerEditorInput) input).getStatus();
-		if (!status.isOK()) {
-			throw new PartInitException(status);
-		}
-         */
-
         super.init(site, input);
-
         getEditorSite().getPage().addPartListener(_partListener);
-
     }
 
     /**
@@ -478,13 +522,13 @@
      */
     @Override
     public boolean isDirty() {
-    	Saveable[] saveables = getSaveables();
-		for (Saveable saveable : saveables) {
-			if (saveable.isDirty()) {
-				return true;
-			}
-		}
-		return false;
+        Saveable[] saveables = getSaveables();
+        for (Saveable saveable : saveables) {
+            if (saveable.isDirty()) {
+                return true;
+            }
+        }
+        return false;
     }
 
     /**
@@ -497,35 +541,12 @@
     }
 
     /**
-     * Unregister the session listener and set the session to <code>null</code>.
-     */
-    private void unregisterSession() {
-        ActivityExplorerEditorInput editorInput = getEditorInput();
-        if (null != editorInput) {
-            Session session = editorInput.getSession();
-            if (null != session) {
-                session = null;
-            }
-        }
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
     public Image getTitleImage() {
         ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
-        Image decoratedImage = decorator.decorateImage(super.getTitleImage(), getEditorInput().getSession());
-
-        return decoratedImage;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void setTitleImage(Image titleImage) {
-        super.setTitleImage(titleImage);
+        return decorator.decorateImage(super.getTitleImage(), getEditorInput().getSession());
     }
 
     private int addNewPage(IFormPage page) {
@@ -550,7 +571,6 @@
      * @param current
      * @return the previous page or null
      */
-    @SuppressWarnings("unchecked")
     public IFormPage getPreviousPage(IFormPage current) {
         IFormPage previousPage = null;
         int i = pages.indexOf(current);
@@ -572,7 +592,6 @@
      * @param current
      * @return the next page or null
      */
-    @SuppressWarnings("unchecked")
     public IFormPage getNextPage(IFormPage current) {
         IFormPage nextPage = null;
         int i = pages.indexOf(current);
@@ -630,36 +649,33 @@
     public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
         String property = event.getProperty();
         boolean value = (Boolean.valueOf(event.getNewValue().toString()));
-        if (doPropertyChange(event, value, property)) {
-            if (ActivityExplorerManager.INSTANCE.getEditor() != null) {
-                ActivityExplorerManager.INSTANCE.getEditor().getActivePageInstance().getManagedForm().reflow(true);
-            }
+        if (doPropertyChange(event, value, property) && ActivityExplorerManager.INSTANCE.getEditor() != null) {
+            ActivityExplorerManager.INSTANCE.getEditor().getActivePageInstance().getManagedForm().reflow(true);
         }
 
     }
 
     @Override
-    public void executeRequest(int request, Session session) {
+    public void executeRequest(int request, Session newSession) {
 
         ActivityExplorerEditorInput editorInput = getEditorInput();
 
         if (editorInput != null) {
-            Session session2 = editorInput.getSession();
+            Session session = editorInput.getSession();
             switch (request) {
             case SessionListener.CLOSING:
-                if (session2 != null && session2.equals(session)) {
+                if (session != null && session.equals(newSession)) {
                     Runnable runnable = new Runnable() {
                         public void run() {
                             close(false);
-							ActivityExplorerManager.INSTANCE
-									.removeActivityExplorerEditorListener(ActivityExplorerEditor.this);
+                            ActivityExplorerManager.INSTANCE.removeActivityExplorerEditorListener(ActivityExplorerEditor.this);
                         }
                     };
                     run(runnable);
                 }
                 break;
             case SessionListener.SELECTED_VIEWS_CHANGE_KIND:
-                if (session2 != null && session2.equals(session) && session.isOpen()) {
+                if (session != null && session.equals(newSession) && newSession.isOpen()) {
                     Runnable runnable = new Runnable() {
                         public void run() {
                             updateEditorPages();
@@ -669,22 +685,31 @@
                 }
                 break;
             case SessionListener.REPRESENTATION_CHANGE:
-                if (session2 != null && session2.equals(session) && session.isOpen()) {
+                if (session != null && session.equals(newSession) && newSession.isOpen()) {
                     _editorDirtyStateChanged();
                 }
                 break;
             case SessionListener.OPENED:
+                if (newSession != null && newSession.equals(session)) {
+                    Runnable runnable = new Runnable() {
+                        public void run() {
+                            setPartName(getPartName());
+                            finishCreatePages();
+                        }
+                    };
+                    run(runnable);
+                }
                 break;
             case SessionListener.DIRTY:
             case SessionListener.SYNC:
             case SessionListener.SEMANTIC_CHANGE: // Listening to changes to
                                                   // mark
-                if (session2 != null && session2.equals(session) && session.isOpen()) {
+                if (session != null && session.equals(newSession) && newSession.isOpen()) {
                     _editorDirtyStateChanged();
                 }
                 break;
             case SessionListener.REPLACED:
-                if (session2 != null && session2.equals(session) && session.isOpen()) {
+                if (session != null && session.equals(newSession) && newSession.isOpen()) {
                     _editorDirtyStateChanged();
                 }
                 break;
@@ -736,11 +761,10 @@
             IEditingSession uiSession = SessionUIManager.INSTANCE.getOrCreateUISession(session);
             if (uiSession instanceof ISaveablesSource) {
                 return (ISaveablesSource) uiSession;
-            } else {
-                // IEditingSession instance does not implement ISaveablesSource.
-                throw new ClassCastException(String.format(Messages.ActivityExplorerEditor_IEditingSessionRetrieval_ShouldAlsoImplementISaveablesSource, IEditingSession.class.getSimpleName(),
-                        ISaveablesSource.class.getSimpleName()));
             }
+            // IEditingSession instance does not implement ISaveablesSource.
+            throw new ClassCastException(String.format(Messages.ActivityExplorerEditor_IEditingSessionRetrieval_ShouldAlsoImplementISaveablesSource, IEditingSession.class.getSimpleName(),
+                    ISaveablesSource.class.getSimpleName()));
         }
         return null;
     }
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 2dd5519..2287063 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c)  2006, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c)  2006, 2018 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
@@ -41,203 +41,202 @@
  */
 public class ActivityExplorerEditorInput extends FileEditorInput implements IEditorInput, IPersistableElement {
 
-	/**
-	 * File linked to this activity explorer.
-	 */
-	private static final String ACTIVITY_EXPLORER_FILE = "activityExplorerFile"; //$NON-NLS-1$
-	
+    /**
+     * 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());
-	}
+    /**
+     * status of the input FIXME why this is added here?
+     */
+    @Deprecated
+    private IStatus _status;
 
-	@Deprecated
-	public ActivityExplorerEditorInput(Session session, EObject eObject) {
-		this(SessionHelper.getFirstAnalysisFile((DAnalysisSession) session));
-	}
-	
+    public ActivityExplorerEditorInput(IFile file) {
+        super(file);
+        loadState(getFile());
+    }
 
-	/**
-	 * Dispose.
-	 */
-	public void dispose() {
-		// Nothing to do
-	}
+    @Deprecated
+    public ActivityExplorerEditorInput(Session session, EObject eObject) {
+        this(SessionHelper.getFirstAnalysisFile((DAnalysisSession) session));
+    }
 
-	/**
-	 * @see org.eclipse.ui.IEditorInput#exists()
-	 */
-	@Override
-	public boolean exists() {
-		Session session = this.getSession();
-		return super.exists() && (session != null) && (session.isOpen());
-	}
+    /**
+     * Dispose.
+     */
+    public void dispose() {
+        // Nothing to do
+    }
 
-	/**
-	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
-	 */
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public Object getAdapter(Class adapter_p) {
-		if (adapter_p == Session.class) {
-			IPath path = getFile().getFullPath();
-			URI uri = URI.createPlatformResourceURI(path.toString(), true);
-			Session session = SessionManager.INSTANCE.getExistingSession(uri);
-			return session;
-		}
-		if ((null != _status) && (adapter_p == IStatus.class)) {
-			return _status;
-		}
-		return super.getAdapter(adapter_p);
-	}
+    /**
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    @Override
+    public boolean exists() {
+        Session session = this.getSession();
+        return super.exists() && (session != null) && (session.isOpen());
+    }
 
-	/**
-	 * @see org.eclipse.ui.IPersistableElement#getFactoryId()
-	 */
-	public String getFactoryId() {
-		return ActivityExplorerEditorInputFactory.ID;
-	}
+    /**
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    public Object getAdapter(Class adapter_p) {
+        if (adapter_p == Session.class) {
+            IPath path = getFile().getFullPath();
+            URI uri = URI.createPlatformResourceURI(path.toString(), true);
+            Session session = SessionManager.INSTANCE.getExistingSession(uri);
+            return session;
+        }
+        if ((null != _status) && (adapter_p == IStatus.class)) {
+            return _status;
+        }
+        return super.getAdapter(adapter_p);
+    }
 
-	/**
-	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
-	 */
-	public ImageDescriptor getImageDescriptor() {
-		return null;
-	}
+    /**
+     * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+     */
+    public String getFactoryId() {
+        return ActivityExplorerEditorInputFactory.ID;
+    }
 
-	/**
-	 * Return the UI representation of current handled model.
-	 * 
-	 * @return
-	 */
-	@Deprecated
-	public String getModelUiName() {
-		String result = ""; //$NON-NLS-1$
-		EObject project = getRootSemanticElement();
-		if (null != project) {
-			result = EObjectLabelProviderHelper.getText(project);
-		}
-		return result;
-	}
+    /**
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    public ImageDescriptor getImageDescriptor() {
+        return null;
+    }
 
-	/**
-	 * Get the underlying project.
-	 * 
-	 * @return the project
-	 */
-	@Deprecated
-	public EObject getRootSemanticElement() {
-		EObject result = null;
-		String path = null;
-		try {
-			IFile file = getFile();
-			path = file.getFullPath().toString();
-			String defaultCharset = null;
-			defaultCharset = System.getProperty("file.encoding"); //$NON-NLS-1$
-			defaultCharset = defaultCharset != null && defaultCharset.isEmpty()? defaultCharset:"UTF-8"; //$NON-NLS-1$
-			path = URLDecoder.decode(path, defaultCharset);
-			URI uri = URI.createPlatformResourceURI(path, true);
-			Session session = SessionManager.INSTANCE.getExistingSession(uri);
-			result = getRootSemanticElement(session);
-		} catch (UnsupportedEncodingException e) {
-			ActivityExplorerLoggerService.getInstance().log(new Status(IStatus.ERROR, ActivityExplorerActivator.ID, 
-					"Could not find the resource " + path + ". See the error log for more details", e)); //$NON-NLS-1$
-		}
-		return result;
-	}
+    /**
+     * Return the UI representation of current handled model.
+     * 
+     * @return
+     */
+    @Deprecated
+    public String getModelUiName() {
+        String result = ""; //$NON-NLS-1$
+        EObject project = getRootSemanticElement();
+        if (null != project) {
+            result = EObjectLabelProviderHelper.getText(project);
+        } else if (getFile() != null) {
+            String fileExtension = getFile().getFileExtension();
+            String fileName = getFile().getName();
+            result = fileName.substring(0, fileName.indexOf(fileExtension) - 1);
+        }
+        return result;
+    }
 
-	/**
-	 * @see org.eclipse.ui.IEditorInput#getName()
-	 */
-	public String getName() {
-		return getModelUiName();
-	}
+    /**
+     * Get the underlying project.
+     * 
+     * @return the project
+     */
+    @Deprecated
+    public EObject getRootSemanticElement() {
+        EObject result = null;
+        String path = null;
+        try {
+            IFile file = getFile();
+            path = file.getFullPath().toString();
+            String defaultCharset = null;
+            defaultCharset = System.getProperty("file.encoding"); //$NON-NLS-1$
+            defaultCharset = defaultCharset != null && defaultCharset.isEmpty() ? defaultCharset : "UTF-8"; //$NON-NLS-1$
+            path = URLDecoder.decode(path, defaultCharset);
+            URI uri = URI.createPlatformResourceURI(path, true);
+            Session session = SessionManager.INSTANCE.getExistingSession(uri);
+            result = getRootSemanticElement(session);
+        } catch (UnsupportedEncodingException e) {
+            ActivityExplorerLoggerService.getInstance().log(new Status(IStatus.ERROR, ActivityExplorerActivator.ID, "Could not find the resource " + path + ". See the error log for more details", e)); //$NON-NLS-1$
+        }
+        return result;
+    }
 
-	/**
-	 * @see org.eclipse.ui.IEditorInput#getPersistable()
-	 */
-	public IPersistableElement getPersistable() {
-		return this;
-	}
+    /**
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    public String getName() {
+        return getModelUiName();
+    }
 
-	/**
-	 * Get the underlying session.
-	 * 
-	 * @return a not <code>null</code> instance.
-	 */
-	// TODO
-	@Deprecated
-	public Session getSession() {
-		return (Session) getAdapter(Session.class);
-	}
+    /**
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    public IPersistableElement getPersistable() {
+        return this;
+    }
 
-	@Deprecated
-	public IStatus getStatus() {
-		return (IStatus) getAdapter(IStatus.class);
-	}
+    /**
+     * Get the underlying session.
+     * 
+     * @return a not <code>null</code> instance.
+     */
+    // TODO
+    @Deprecated
+    public Session getSession() {
+        return (Session) getAdapter(Session.class);
+    }
 
-	/**
-	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
-	 */
-	public String getToolTipText() {
-		return getModelUiName();
-	}
+    @Deprecated
+    public IStatus getStatus() {
+        return (IStatus) getAdapter(IStatus.class);
+    }
 
-	// FIXME be contributive
-	private void loadState(IFile file) {
-		try {
-			Session session = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.SessionHelper
-					.getSession(file);
+    /**
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    public String getToolTipText() {
+        return getModelUiName();
+    }
 
-			// don't open session if already opened (bad performance)
-			if (null == session) {
-				// Instantiate the action responsible for opening a session.
-				org.eclipse.amalgam.explorer.activity.ui.api.actions.OpenSessionAction openSessionAction = new org.eclipse.amalgam.explorer.activity.ui.api.actions.OpenSessionAction();
-				openSessionAction.setRunInProgressService(false);
-				openSessionAction.selectionChanged(new StructuredSelection(file));
+    // FIXME be contributive
+    private void loadState(IFile file) {
+        try {
+            Session session = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.SessionHelper.getSession(file);
 
-				// Open the session.
-				openSessionAction.run();
-				_status = openSessionAction.getStatus();
-				if (_status == null) {
-					_status = Status.OK_STATUS;
-				}
+            // don't open session if already opened (bad performance)
+            if (null == session) {
+                // Instantiate the action responsible for opening a session.
+                org.eclipse.amalgam.explorer.activity.ui.api.actions.OpenSessionAction openSessionAction = new org.eclipse.amalgam.explorer.activity.ui.api.actions.OpenSessionAction();
+                openSessionAction.setRunInProgressService(false);
+                openSessionAction.selectionChanged(new StructuredSelection(file));
 
-				if (_status.isOK()) {
-					session = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.SessionHelper
-							.getSession(file);
-				}
-			}
-			if (null == getRootSemanticElement()) {
-				_status = new Status(IStatus.WARNING, ActivityExplorerActivator.ID, Messages.ActivityExplorerEditor_1);
-			}
-		} catch (Exception e) {
-			_status = new Status(IStatus.ERROR, ActivityExplorerActivator.ID, e.getMessage(), e);
-		}
-	}
+                // Open the session.
+                openSessionAction.run();
+                _status = openSessionAction.getStatus();
+                if (_status == null) {
+                    _status = Status.OK_STATUS;
+                }
 
-	/**
-	 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
-	 */
-	public void saveState(IMemento memento_p) {
-		memento_p.putString(ACTIVITY_EXPLORER_FILE, getFile().getFullPath().toString());
-	}
+                if (_status.isOK()) {
+                    session = org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.SessionHelper.getSession(file);
+                }
+            }
+            if (null == getRootSemanticElement()) {
+                _status = new Status(IStatus.WARNING, ActivityExplorerActivator.ID, Messages.ActivityExplorerEditor_1);
+            }
+        } catch (Exception e) {
+            _status = new Status(IStatus.ERROR, ActivityExplorerActivator.ID, e.getMessage(), e);
+        }
+    }
 
-	/**
-	 * 
-	 * @param session_p
-	 * @return model root of the first semantic resource managed by session_p or null
-	 * 
-	 * @deprecated will be deteled
-	 */
-	@Deprecated
-	public EObject getRootSemanticElement(Session session_p) {
-		return SessionHelper.getRootSemanticModel(session_p);
-	}
+    /**
+     * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+     */
+    public void saveState(IMemento memento_p) {
+        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 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/MessagePage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/MessagePage.java
new file mode 100644
index 0000000..e74b255
--- /dev/null
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/MessagePage.java
@@ -0,0 +1,82 @@
+/*******************************************************************************

+ * Copyright (c)  2006, 2018 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:

+ *    Thales - initial API and implementation

+ *******************************************************************************/

+package org.eclipse.amalgam.explorer.activity.ui.api.editor.pages;

+

+import org.eclipse.swt.layout.GridData;

+import org.eclipse.swt.layout.GridLayout;

+import org.eclipse.swt.widgets.Composite;

+import org.eclipse.swt.widgets.Label;

+import org.eclipse.ui.forms.IManagedForm;

+import org.eclipse.ui.forms.editor.FormEditor;

+import org.eclipse.ui.forms.editor.FormPage;

+import org.eclipse.ui.forms.widgets.FormToolkit;

+

+public class MessagePage extends FormPage {

+

+    private static final int FORM_BODY_MARGIN_HEIGHT = 0;

+

+    private static final int FORM_BODY_MARGIN_WIDTH = 0;

+

+    private static final int FORM_BODY_MARGIN_TOP = 12;

+

+    private static final int FORM_BODY_MARGIN_BOTTOM = 12;

+

+    private static final int FORM_BODY_MARGIN_LEFT = 6;

+

+    private static final int FORM_BODY_MARGIN_RIGHT = 6;

+

+    private static final int FORM_BODY_HORIZONTAL_SPACING = 20;

+

+    private static final int FORM_BODY_VERTICAL_SPACING = 17;

+

+    protected String message;

+

+    public MessagePage(FormEditor formEditor, String message) {

+        this(formEditor, message, ""); //$NON-NLS-1$ //$NON-NLS-2$

+    }

+

+    public MessagePage(FormEditor formEditor, String message, String title) {

+        super(formEditor, "007", title); //$NON-NLS-1$ //$NON-NLS-2$

+        this.message = message;

+    }

+

+    @Override

+    protected void createFormContent(final IManagedForm managedForm) {

+        // Create single columned page layout

+        Composite body = managedForm.getForm().getBody();

+        body.setLayout(createFormBodyGridLayout(false, 1));

+

+        // Display message indicating that editor input is being loaded

+        FormToolkit toolkit = managedForm.getToolkit();

+        Label label = toolkit.createLabel(body, message);

+        label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

+    }

+

+    private GridLayout createFormBodyGridLayout(boolean makeColumnsEqualWidth, int numColumns) {

+        GridLayout layout = new GridLayout();

+

+        layout.marginHeight = FORM_BODY_MARGIN_HEIGHT;

+        layout.marginWidth = FORM_BODY_MARGIN_WIDTH;

+

+        layout.marginTop = FORM_BODY_MARGIN_TOP;

+        layout.marginBottom = FORM_BODY_MARGIN_BOTTOM;

+        layout.marginLeft = FORM_BODY_MARGIN_LEFT;

+        layout.marginRight = FORM_BODY_MARGIN_RIGHT;

+

+        layout.horizontalSpacing = FORM_BODY_HORIZONTAL_SPACING;

+        layout.verticalSpacing = FORM_BODY_VERTICAL_SPACING;

+

+        layout.makeColumnsEqualWidth = makeColumnsEqualWidth;

+        layout.numColumns = numColumns;

+

+        return layout;

+    }

+}

diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java
index 6bdad18..7c540f8 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/session/listeners/ActivityExplorerSessionListener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c)  2006, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c)  2006, 2018 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
@@ -10,11 +10,8 @@
  *******************************************************************************/
 package org.eclipse.amalgam.explorer.activity.ui.internal.session.listeners;
 
-import java.lang.ref.WeakReference;
-
 import org.eclipse.amalgam.explorer.activity.ui.api.manager.ActivityExplorerManager;
 import org.eclipse.sirius.business.api.session.Session;
-import org.eclipse.sirius.business.api.session.SessionListener;
 import org.eclipse.sirius.business.api.session.SessionManagerListener;
 import org.eclipse.sirius.viewpoint.description.Viewpoint;
 
@@ -23,55 +20,28 @@
  */
 public class ActivityExplorerSessionListener implements SessionManagerListener {
 
-	@Override
-	public void notify(Session sessionp, int notification) {
+    @Override
+    public void notify(Session session, int notification) {
+        ActivityExplorerManager.INSTANCE.dispatchEvent(notification, session);
+    }
 
-		WeakReference<Session> session = new WeakReference<Session>(sessionp);
+    @Override
+    public void notifyAddSession(Session newSession) {
+        // Do Nothing
+    }
 
-		switch (notification) {
-		case SessionListener.CLOSING:
-			ActivityExplorerManager.INSTANCE.dispatchEvent(notification, session.get());
-			break;
-		case SessionListener.SELECTED_VIEWS_CHANGE_KIND:
-			ActivityExplorerManager.INSTANCE.dispatchEvent(notification, session.get());
-			break;
-		case SessionListener.REPRESENTATION_CHANGE:
-			ActivityExplorerManager.INSTANCE.dispatchEvent(notification, session.get());
-			break;
-		case SessionListener.OPENED:
-			break;
-		case SessionListener.DIRTY:
-		case SessionListener.SYNC:
-		case SessionListener.SEMANTIC_CHANGE: // Listening to changes to mark
-			ActivityExplorerManager.INSTANCE.dispatchEvent(notification, session.get());
-			break;
-		case SessionListener.REPLACED:
-			ActivityExplorerManager.INSTANCE.dispatchEvent(notification, session.get());
-			break;
-		}
-	}
+    @Override
+    public void notifyRemoveSession(Session removedSession) {
+        // Do Nothing
+    }
 
-	@Override
-	public void notifyAddSession(Session newSession) {
-		// TODO Auto-generated method stub
+    @Override
+    public void viewpointSelected(Viewpoint selectedSirius) {
+        // Do Nothing
+    }
 
-	}
-
-	@Override
-	public void notifyRemoveSession(Session removedSession) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void viewpointSelected(Viewpoint selectedSirius) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void viewpointDeselected(Viewpoint deselectedSirius) {
-		// TODO Auto-generated method stub
-
-	}
+    @Override
+    public void viewpointDeselected(Viewpoint deselectedSirius) {
+        // Do Nothing
+    }
 }