diff --git a/plugins/org.polarsys.chess.validator/src/org/polarsys/chess/validator/libs/ActionsLib.java b/plugins/org.polarsys.chess.validator/src/org/polarsys/chess/validator/libs/ActionsLib.java
index 44fa5e7a0f8ba1664bb06f5c2131566fd633daae..bc5aa161f2a253a1babaa6b778b03831ca1b61d2 100755
--- a/plugins/org.polarsys.chess.validator/src/org/polarsys/chess/validator/libs/ActionsLib.java
+++ b/plugins/org.polarsys.chess.validator/src/org/polarsys/chess/validator/libs/ActionsLib.java
@@ -32,6 +32,7 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.emf.ecore.impl.EReferenceImpl;
+import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.edit.command.DeleteCommand;
 import org.eclipse.emf.edit.command.SetCommand;
 import org.eclipse.emf.transaction.RollbackException;
@@ -51,9 +52,18 @@ import org.eclipse.papyrus.MARTE.MARTE_Foundations.NFPs.NfpConstraint;
 import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
 import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
 import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
 import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
 import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForActionHandlers;
 import org.eclipse.papyrus.uml.tools.listeners.PapyrusStereotypeListener;
+import org.eclipse.papyrus.uml.tools.model.ExtendedUmlModel;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.uml2.uml.Behavior;
 import org.eclipse.uml2.uml.Classifier;
 import org.eclipse.uml2.uml.Comment;
@@ -74,8 +84,15 @@ import org.eclipse.uml2.uml.Property;
 import org.eclipse.uml2.uml.Realization;
 import org.eclipse.uml2.uml.Stereotype;
 import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.internal.impl.ClassImpl;
+import org.eclipse.uml2.uml.resource.UMLResource;
 import org.polarsys.chess.chessmlprofile.ComponentModel.FunctionalPartition;
+import org.polarsys.chess.chessmlprofile.Core.CHESS;
 import org.polarsys.chess.chessmlprofile.Core.PSMPackage;
+import org.polarsys.chess.chessmlprofile.Core.CHESSViews.AnalysisView;
+import org.polarsys.chess.chessmlprofile.Core.CHESSViews.ComponentView;
+import org.polarsys.chess.chessmlprofile.Core.CHESSViews.DeploymentView;
+import org.polarsys.chess.chessmlprofile.Core.CHESSViews.PSMView;
 import org.polarsys.chess.chessmlprofile.Core.CHESSViews.RTAnalysisView;
 import org.polarsys.chess.chessmlprofile.Predictability.DeploymentConfiguration.HardwareBaseline.CH_HwProcessor;
 import org.polarsys.chess.chessmlprofile.Predictability.RTComponentModel.CHRtSpecification;
@@ -84,6 +101,7 @@ import org.polarsys.chess.validator.automatedActions.IAutomatedAction;
 import org.polarsys.chess.core.profiles.CHESSProfileManager;
 import org.polarsys.chess.core.util.CHESSProjectSupport;
 import org.polarsys.chess.core.util.uml.ModelError;
+import org.polarsys.chess.core.util.uml.ResourceUtils;
 import org.polarsys.chess.core.util.uml.UMLUtils;
 import org.polarsys.chess.core.views.ViewUtils;
 import org.polarsys.chess.service.gui.utils.CHESSEditorUtils;
@@ -160,6 +178,7 @@ public class ActionsLib {
 			}
 			return null;
 		}
+		
 	};
 
 	/** The port removal action. */
@@ -260,7 +279,6 @@ public class ActionsLib {
 			}
 			return null;
 		}
-
 	};
 
 	/** The remove realization operations action. */
@@ -466,6 +484,7 @@ public class ActionsLib {
 				}
 			}
 		}
+		
 	};
 
 
@@ -1146,89 +1165,107 @@ public class ActionsLib {
 	public static IAutomatedAction saAnalysisContextDeletionAction = new IAutomatedAction() {
 		private IStatus operationAborted = new Status(IStatus.ERROR,
 				Activator.PLUGIN_ID, Messages.operationAborted);
-		private Package psm = null;
-		private PSMPackage psmPackage = null;
 
 		@Override
 		public Command compile(Notification notification,
 				List<Notification> notificationList,
 				TransactionalEditingDomain domain) throws RollbackException {
+			
+			PSMPackage psmPackageStereoToDelete = null;
+			
 			Object notifier = notification.getNotifier();
 			
-			if (notifier instanceof Package && 
-					notification.getEventType() == 22 && 		// MODIFIED_STEREOTYPE
-					notification.getNewValue() instanceof PSMPackage) {
-				psm = (Package)notifier;
-				Stereotype psmPackageStereo = psm.getAppliedStereotype(Constants.CH_PsmPackage);				
-				if (psmPackageStereo != null) {
-					psmPackage = (PSMPackage)psm.getStereotypeApplication(psmPackageStereo);
-				}				
-				return null;
-			}
-
-			if ((notifier instanceof Package 
-					&& notification.getEventType() == Notification.REMOVE) &&
-					notification.getFeature() instanceof EReference	&&
-					((EReference) notification.getFeature()).getName().equals("packagedElement")) {
+			Package psmPackageToDelete = null;
+			org.eclipse.uml2.uml.Class oldAnalysisContextClass = null;
+			
+			Object feature = notification.getFeature();
+			
+			if (notifier instanceof SaAnalysisContext && notification.getNewValue()== null &&
+						notification.getOldValue() instanceof org.eclipse.uml2.uml.Class && notification.getEventType() == Notification.SET
+					&& (feature instanceof EReferenceImpl)	&& ((EReferenceImpl) feature).getName().equals("base_StructuredClassifier")
+					
+					){
+				//check if there is a PSMPackage which refer this SaAnalysisContext 
+				oldAnalysisContextClass = (org.eclipse.uml2.uml.Class) notification.getOldValue();
 				
-				// check the package is stereotyped as RTAnalysisView
-				if (((Package)notifier).getAppliedStereotype(Constants.RT_ANALYSIS_VIEW) == null) {
-					return null;
-				}
+				PapyrusMultiDiagramEditor editor = (PapyrusMultiDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+						.getActivePage().getActiveEditor();
 				
-				// If the PSM Package related to this SaAnalysisContext does not exist (e.g. has been purged)
-				if (psmPackage == null) {
+				Resource res = null;
+				try {
+					res = ResourceUtils.getUMLResource(editor.getServicesRegistry());
+				} catch (ServiceException e) {
+					CHESSProjectSupport.CHESS_CONSOLE.println("Unable to retrieve the UML resource via the Service Registry");
+					e.printStackTrace();
 					return null;
 				}
+				Model model =  ResourceUtils.getModel(res);
 				
-				org.eclipse.uml2.uml.Class cl= (org.eclipse.uml2.uml.Class) notification.getOldValue();
-				String saAnalysisContextName = "";
-				if(cl.getName() != null) {
-					saAnalysisContextName = cl.getName();
-				}
-				String psmPackageName = "";
-				if (psm!= null && psm.getName() != null) {
-					psmPackageName = psm.getName();
-				}
-		
-				// Ask user if he is sure he wants to delete this saAnalysisContext
-				// warning that the related PSM Package will be deleted
-				PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();																		
-
-				if (editor == null) {							
-					return null;
-				}
-
-				MessageDialog md = CHESSEditorUtils.showConfirmDialog(editor, "Confirm", 
-						"Do you want to remove also the PSM Package: "+psmPackageName+" related to the SaAnalysisContext: "+saAnalysisContextName+" ?");
-
-				int result = md.open();
 				
-				// OK
-				if (result == 0) {
-					Model umlModel = cl.getModel();
-					if (psmPackage != null) {
-						Command cmd = deletePackage(umlModel, psm);
-						psm = null;
-						return cmd;
+				CHESS chess =  (CHESS) model.getStereotypeApplication(model.getAppliedStereotype("CHESS::Core::CHESS"));
+				
+				PSMView psmView = chess.getPsmView();
+				Package psmViewPkg = psmView.getBase_Package();
+				
+				for (Package p : psmViewPkg.getNestedPackages()){
+					if (p.getAppliedStereotype("CHESS::Core::PSMPackage") != null){
+						PSMPackage psmPackageStero = (PSMPackage) p.getStereotypeApplication(p.getAppliedStereotype("CHESS::Core::PSMPackage"));
+						if (notifier.equals(psmPackageStero.getAnalysisContext())){
+							psmPackageStereoToDelete = psmPackageStero;
+							psmPackageToDelete = psmPackageStero.getBase_Package();
+						}
 					}
-					return null;
-				}
-				// CANCEL
-				if (result == 2) {
-					CHESSProjectSupport.CHESS_CONSOLE.println(operationAborted.getMessage());
-					psm = null;
-					throw new RollbackException(operationAborted);
 				}
-				// NO
-				if (result == 1) {
-					psm = null;
-					return null;		
+			}
+			
+			// If the PSM Package related to this SaAnalysisContext does not exist (e.g. has been purged)
+			if (psmPackageStereoToDelete == null) {
+				return null;
+			}
+			
+			String saAnalysisContextName = "";
+			if(oldAnalysisContextClass.getName() != null) {
+				saAnalysisContextName = oldAnalysisContextClass.getName();
+			}
+			String psmPackageName = "";
+			if (psmPackageToDelete!= null && psmPackageToDelete.getName() != null) {
+				psmPackageName = psmPackageToDelete.getName();
+			}
+	
+			// Ask user if he is sure he wants to delete this saAnalysisContext
+			// warning that the related PSM Package will be deleted
+			PapyrusMultiDiagramEditor editor = CHESSEditorUtils.getCHESSEditor();																		
+
+			if (editor == null) {							
+				return null;
+			}
+			
+			MessageDialog md = CHESSEditorUtils.showConfirmDialog(editor, "Confirm", 
+					"Do you want to remove also the PSM Package: "+psmPackageName+" related to the SaAnalysisContext: "+saAnalysisContextName+" ?");
+
+			int result = md.open();
+			
+			// OK
+			if (result == 0) {
+				Model umlModel = oldAnalysisContextClass.getModel();
+				if (psmPackageToDelete != null) {
+					Command cmd = deletePackage(umlModel, psmPackageToDelete);
+					
+					return cmd;
 				}
-				
-				return null;					
+				return null;
 			}
-			return null;
+			// CANCEL
+			if (result == 2) {
+				CHESSProjectSupport.CHESS_CONSOLE.println(operationAborted.getMessage());
+				throw new RollbackException(operationAborted);
+			}
+			// NO
+			if (result == 1) {
+				return null;		
+			}
+			return null;					
+		
 		}