@script name="Freeze">
   Contains functions that identify and handle Translation/Personalization Freeze violation
   (c) SAP AG 2003-2008. All rights reserved.
#DEPENDENCIES[
   lib:Basic.js
   lib:EventsMgr.js
   lib:PopupMgr.js
   lib~skin:styles.Global.css
]
//#INCLUDE[gml:defs.inc]
//#INCLUDE[env:global_hotkeys.inc]
//////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
<@method name="canDeleteStableIDs">
   Checks if element(s)that are to be deleted have related so-called stable IDs. If yes - prompts for user approval to deleting/losing these IDs
   An arrray of elements, to be deleted
   if true check the object and its children, if false check the object only
   if true check for actual existence of tects,, if false check statucally - based on the object's Class
   
      If the method is called with "objects" that is not an array, the modeler will always be prompted with the general message
   
   ~true if the object can be safely deleted - meaning freeze is not broken or the modeler confirmed breaking it
function canDeleteStableIDs(objects, deep, dynamic) {
// Note: the method searches all objects for personalization violations. If found, search is stopped and a general msg is displayed.
// If not found, we search for translation issues. There are two reasons for this design:
// 1. The translation search is reused in other locations that do not care about personalization (e.g. reset a from to defaults)
// 2. The personalization search is very fast compared to the (recursive) translation search
	var tf = $ENV.model.isTranslationFreeze;
	var pf = $ENV.model.isPersonalizationFreeze;
	if (!tf && !pf) return(true); // no freeze situation
	
	if (pf) {
		var freezeViolation = false;
		if (ISARRAY(objects)) { // if array of objects - loop on each one
			for (var i=0; i issue a general warning about "might be lost" 
			freezeViolation = true;
		}
		
		var msg = '#TEXT[YMSG_DEL_TRANS_PERS]';
		if (freezeViolation && !$ENV.model.blockedMessages[msg]) {
			var features = {mainTxt:msg, neverShowTxt:'#TEXT[XCKL_DO_NOT_SHOW]'};
			features.buttons = '#TEXT[XBUT_OK] #TEXT[XBUT_CANCEL]';
			features.callback = function(val){if (val) $ENV.model.blockedMessages[msg]=val;};
			return(CONFIRMONCE(features));
		}
	}
	// we get here ==> no personlization freeze violation, and not a generic message due to invalid input
	if (!tf) return(true);
	return(canDeleteTextObjects(objects, deep, '#TEXT[YMSG_DELETE_TRANSLATION]', dynamic)); // if failed to find personalization violation, look for translation violation
	
}
<@method name="canDeleteTextObjects">
   Checks if element(s) that are to be deleted have related text objects. If yes - prompts for user approval to deleting/losing these IDs
   
      The method can be also called for elements that are only subject to deletion of thier text objects (but not deletino of the objects themselves - 
      e.g. reset to defaults)
   
   An arrray of elements, to be deleted
   if true check the object and its children, if false check the object only
   a message to display instead of the default message
   if true check for actual existence of tects,, if false check statucally - based on the object's Class
   
      This method can be called in situations of objects deletion or only of losing text objects.
      This ugly coding is to save $$$ and ensure consistecy, by defininig the strings only once - in core.env
   
   ~true if the object can be safely deleted - meaning freeze is not broken or the modeler confirmed breaking it
function canDeleteTextObjects(objects, deep, msgOverride, dynamic) {
	if (!$ENV.model.isTranslationFreeze) return(true); // no freeze situation
	
	var freezeViolation = false;
	if (ISARRAY(objects)) { // if array of objects - loop on each one
		for (var i=0; i issue a general warning about "might be lost" 
		freezeViolation = true;
	}
	
	var msg = msgOverride ? msgOverride : '#TEXT[XMSG_LOSE_TRANSLATION]';
	if (freezeViolation && !$ENV.model.blockedMessages[msg]) {
		var features = {mainTxt:msg, neverShowTxt:'#TEXT[XCKL_DO_NOT_SHOW]'};
		features.buttons = '#TEXT[XBUT_OK] #TEXT[XBUT_CANCEL]';
		features.callback = function(val){if (val) $ENV.model.blockedMessages[msg]=val;};
		return(CONFIRMONCE(features));
	}
	else
		return(true); // no freeze violation
}
function canResetProperty(object, propName) {
	var msg = "#TEXT[XMSG_LOSE_TRANSLATION]";
	if ($ENV.model.isTranslationFreeze && !$ENV.model.blockedMessages[msg]) {
		var cb = function(ret){
					if ("#TEXT[XBUT_OK]"==ret) {
						object.setProperty(propName);
					};
				}
		var btns = '#TEXT[XBUT_OK] #TEXT[XBUT_CANCEL]';
		PROMPT(msg,	{	buttons:btns, callback:cb, width:400, height:80} );
	} else {
		object.setProperty(propName);
	}
}