#------------------------------------------------------------------
#-----------------ON_EVENT "AfterEditAttributeValue"---------------
#------------------------------------------------------------------
 
	# SETG id_InstId:(instid)
	# SETG id_AttrId:(attrid)
	# SETG id_ModelId:(modelid)
	# SETG id_AttrTypeId:(attrtypeid)
		# 0 INTEGER, 1 DOUBLE, 2 STRING, 3 DISTRIBUTION, 4 TIME, 5 ENUMERATION,
		# 6 ENUMERATIONLIST, 7 LONGSTRING, 8 PROGRAMCALL, 9 INTERREF, 10 EXPRESSION, 
		# 11 RECORD, 12 ATTRPROFREF, 13 DATE, 14 DATETIME, 15 CLOB

# The event handler "AfterEditAttributeValue" is used for accepting the listed results in the model notebook.
# One can accept the results individually or all by one click.

#------------------------------------------------------------- 
#--------------Accept Individually the Attribute Changes------
#-------------------------------------------------------------

CC "Core"  GET_ATTR_ID classid:(id_ModelId) attrname:"Changes"
#-->RESULT ecode:intValue attrid:id
SET id_RecAttrId:(attrid)



IF (id_AttrId = id_RecAttrId) {

CC "Core" GET_REC_ATTR_ROW_COUNT objid:(id_ModelId) attrid:(id_AttrId) 
#-->RESULT ecode:intValue count:intValue
	SETL n_rec_row_count:(count)

	IF (n_rec_row_count > 1) {
		FOR i from:(n_rec_row_count) to:(1) by:(-1)
			{
				CC "Core" GET_REC_ATTR_ROW_ID objid:(id_ModelId) attrid:(id_AttrId)  index:(i) 
				#--> RESULT ecode: intValue rowid: id . 
				SETG id_RowId:(rowid)
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Accept Change"
				#-->RESULT ecode:intValue val:anyValue
				SET s_AcceptChangeBoolVal:(val)				
				
				IF (s_AcceptChangeBoolVal = "Yes") {
				CC "Core"  GET_ATTR_VAL  objid:(id_RowId) attrname:"Class"
				#-->RESULT ecode:intValue val:anyValue
				SET id_Classid:(VAL val)
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Object"
				#-->RESULT ecode:intValue val:anyValue
				SET n_ObjName:(val)
				
				CC "Core"  GET_ATTR_ID classid: (id_Classid) attrname:("ChangeGraph")	
				#-->RESULT ecode:intValue attrid:id
				CC "Core" GET_OBJ_ID modelid:(id_ModelId) classid:(id_Classid) objname:(n_ObjName)
				SET n_ObjId:(objid)
				CC "Core"  GET_ATTR_VAL objid: (n_ObjId) attrname:"ChangeGraph"
				#-->RESULT ecode:intValue val:anyValue
				CC "Core"  SET_ATTR_VAL objid: (n_ObjId) attrname:"ChangeGraph" val:((val) - 1)
				#-->RESULT ecode:intValue
				CC "Core" REMOVE_REC_ROW objid:(id_ModelId) attrid:(id_AttrId) rowid:(id_RowId)
				#--> RESULT ecode: intValue
							
				}
				
			}
	}
	ELSE {
	CC "Core"  GET_REC_ATTR_ROW_ID objid:(id_ModelId) attrid:(id_AttrId)  index:1
	#-->RESULT ecode:intValue rowid:intValue
	SET id_RowId:(rowid)
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Accept Change"
				#-->RESULT ecode:intValue val:anyValue
				SET s_AcceptChangeBoolVal:(val)
				
				IF (s_AcceptChangeBoolVal = "Yes") {
				CC "Core" REMOVE_REC_ROW objid:(id_ModelId) attrid:(id_AttrId) rowid:(id_RowId)
				#--> RESULT ecode: intValue
	
	}
}
}


#------------------------------------------------------------- 
#--------------Accept Individually the Object Changes---------
#-------------------------------------------------------------

CC "Core"  GET_ATTR_ID classid:(id_ModelId) attrname:"Object History"
#-->RESULT ecode:intValue attrid:id
SET id_RecObjId:(attrid)


IF (id_AttrId = id_RecObjId) {

CC "Core" GET_REC_ATTR_ROW_COUNT objid:(id_ModelId) attrid:(id_AttrId) 
#-->RESULT ecode:intValue count:intValue
	SETL n_rec_row_count:(count)

	IF (n_rec_row_count > 1) {
		FOR i from:(n_rec_row_count) to:(1) by:(-1)
			{
				CC "Core" GET_REC_ATTR_ROW_ID objid:(id_ModelId) attrid:(id_AttrId)  index:(i) 
				#--> RESULT ecode: intValue rowid: id . 
				SETG id_RowId:(rowid)
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Accept Change"
				#-->RESULT ecode:intValue val:anyValue
				SET s_AcceptChangeBoolVal:(val)
							
				
				IF (s_AcceptChangeBoolVal = "Yes") {
				CC "Core"  GET_ATTR_VAL  objid:(id_RowId) attrname:"Class"
				#-->RESULT ecode:intValue val:anyValue
				SET id_Classid:(VAL val)
				#-->RESULT ecode:intValue val:anyValue
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Object"
				SET n_ObjName:(val)
				
				CC "Core"  GET_ATTR_ID classid: (id_Classid) attrname:("ChangeGraph")	
				#-->RESULT ecode:intValue attrid:id
				CC "Core" GET_OBJ_ID modelid:(id_ModelId) classid:(id_Classid) objname:(n_ObjName)
				SET n_ObjId:(objid)
				CC "Core"  GET_ATTR_VAL objid: (n_ObjId) attrname:"ChangeGraph"
				#-->RESULT ecode:intValue val:anyValue
				CC "Core"  SET_ATTR_VAL objid: (n_ObjId) attrname:"ChangeGraph" val:((val) - 1)
				#-->RESULT ecode:intValue
				CC "Core" REMOVE_REC_ROW objid:(id_ModelId) attrid:(id_AttrId) rowid:(id_RowId)
				#--> RESULT ecode: intValue
							
				}
				
			}
	}
	ELSE {
	CC "Core"  GET_REC_ATTR_ROW_ID objid:(id_ModelId) attrid:(id_AttrId)  index:1
	#-->RESULT ecode:intValue rowid:intValue
	SET id_RowId:(rowid)
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Accept Change"
				#-->RESULT ecode:intValue val:anyValue
				SET s_AcceptChangeBoolVal:(val)
				
				IF (s_AcceptChangeBoolVal = "Yes") {
				CC "Core" REMOVE_REC_ROW objid:(id_ModelId) attrid:(id_AttrId) rowid:(id_RowId)
				#--> RESULT ecode: intValue
	
	}
}
}



#------------------------------------------------------------------
#--------------------Accept all Changes----------------------------
#------------------------------------------------------------------



CC "Core"  GET_ATTR_ID classid:(id_ModelId) attrname:("Accept all changes")
#-->RESULT ecode:intValue attrid:id
SET id_AacAttrId:(attrid)

IF (id_AttrId = id_AacAttrId) {

CC "Core"  GET_ATTR_VAL objid:(id_ModelId) attrname:"Accept all changes"
#-->RESULT ecode:intValue val:anyValue
		SET s_AcceptAllChangesBoolVal:(val)

	IF (s_AcceptAllChangesBoolVal = "Yes") {
	CC "AdoScript" WARNINGBOX "Do you really want to accept and delete all changes" ok-cancel
	
	IF (endbutton = "cancel") {
	CC "Core" SET_ATTR_VAL objid: (id_ModelId) attrname:"Accept all changes" val: "No"
	#-->RESULT ecode:intValue
	EXIT
	}
	
	
	IF (endbutton = "ok") {
	CC "Core" GET_REC_ATTR_ROW_COUNT objid:(id_ModelId) attrid:(id_RecAttrId)
		#-->RESULT ecode:intValue count:intValue
	SET n_rec_row_count:(count)

		FOR i from:(n_rec_row_count) to:1 by:(-1) {

		CC "Core" GET_REC_ATTR_ROW_ID objid:(id_ModelId) attrid:(id_RecAttrId) index:(i) 
				#--> RESULT ecode: intValue rowid: id . 
				SET id_RowId:(rowid)

				
				CC "Core"  GET_ATTR_VAL  objid:(id_RowId) attrname:"Class"
				#-->RESULT ecode:intValue val:anyValue
				SET id_Classid:(VAL val)
				CC "Core" GET_ATTR_VAL objid:(id_RowId) attrname:"Object"
				#-->RESULT ecode:intValue val:anyValue
				SET n_ObjName:(val)
				
				CC "Core"  GET_ATTR_ID classid: (id_Classid) attrname:("ChangeGraph")	
				#-->RESULT ecode:intValue attrid:id
				CC "Core" GET_OBJ_ID modelid:(id_ModelId) classid:(id_Classid) objname:(n_ObjName)
				SET n_ObjId:(objid)
				CC "Core"  GET_ATTR_VAL objid: (n_ObjId) attrname:"ChangeGraph"
				#-->RESULT ecode:intValue val:anyValue
				CC "Core"  SET_ATTR_VAL objid: (n_ObjId) attrname:"ChangeGraph" val:((val) - 1)
				#-->RESULT ecode:intValue
				
		CC "Core" REMOVE_REC_ROW objid:(id_ModelId) attrid:(id_RecAttrId) rowid:(id_RowId)
			#--> RESULT ecode: intValue
	
	CC "Core"  SET_ATTR_VAL objid:(id_ModelId) attrname:"Accept all changes" val:"No"
	#-->RESULT ecode:intValue
	
		
			
		}
	}
	
}

}