[539949] Activity Explorer is not closed after Eclipse is restarted and
the session is closed

Bug: 539949

Change-Id: I508a4bf629d740f8559420ce803c6ab76c64686e
Signed-off-by: Tu Ton <minhtutonthat@gmail.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 13e25bf..27d924f 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
@@ -88,7 +88,6 @@
 
     public ActivityExplorerEditor() {
         ActivityExplorerManager.INSTANCE.setEditor(this);
-        ActivityExplorerManager.INSTANCE.addActivityExplorerEditorListener(this);
         _partListener = new ActivityExplorerEditorPartListener(this);
     }
 
@@ -513,15 +512,20 @@
      * @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 {
-    	IEditorInput usedInput = input;
-    	if (usedInput instanceof FileEditorInput && !(usedInput instanceof ActivityExplorerEditorInput) ) {
-    		usedInput = new ActivityExplorerEditorInput(((FileEditorInput)input).getFile());
-    	}
-    	
-        super.init(site, usedInput);
-        getEditorSite().getPage().addPartListener(_partListener);
-    }
+	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+		IEditorInput usedInput = input;
+		if (usedInput instanceof FileEditorInput && !(usedInput instanceof ActivityExplorerEditorInput)) {
+			usedInput = new ActivityExplorerEditorInput(((FileEditorInput) input).getFile());
+		}
+
+		super.init(site, usedInput);
+		getEditorSite().getPage().addPartListener(_partListener);
+		
+		// Bug 539949: Activity Explorer session listener should be added here after the
+		// initialization of ActivityExplorerEditorInput. Otherwise, it can be removed
+		// by the method executeRequest() and the Editor is left without any listener.
+		ActivityExplorerManager.INSTANCE.addActivityExplorerEditorListener(this);
+	}
 
     /**
      * {@inheritDoc}