1 /**
  2  * Object that is used to undo actions when a figure is connected to a connector
  3  * @this {ConnectCommand} 
  4  * @constructor
  5  * 
  6  * @param objectId {Object} the object/number to identify the object upon the connect will act.
  7  * In this case is an array for the composite key of a glue [id1, id2] 
  8  * @param typeOfObject {Number} - the type of Command, usually History.OBJECT_GLUE. For more see History.OBJECT_etc.
  9  * @param property {String} - the property that changed
 10  * @param previousValue {Object} - previous object value
 11  * @param currentValue {Object} - current object value
 12  * @author Zack Newsham zack_newsham@yahoo.co.uk
 13  * @author Alex <alex@scriptoid.com>
 14  */
 15 function ConnectCommand(objectId, typeOfObject, property, previousValue, currentValue){
 16     this.objectId = objectId;
 17     this.typeOfObject = typeOfObject;
 18     this.property = property;
 19     this.previousValue = previousValue;
 20     this.currentValue = currentValue;
 21     this.oType = "Connect Action";
 22 }
 23 
 24 ConnectCommand.prototype = {
 25     
 26     /**This method should be called every time an Undo is requested.
 27      * Redo means to recreate the Glue
 28      **/
 29     undo : function(){
 30         //delete the glue
 31         CONNECTOR_MANAGER.glueRemoveByIds(this.objectId[0], this.objectId[1]);
 32         
 33         //remove previous create :p
 34         History.CURRENT_POINTER--;
 35         History.undo();
 36         
 37         //move back up as the Hostory.undo() will decrease pointer again
 38         History.CURRENT_POINTER++;
 39     },    
 40     
 41     
 42     /**This method got called every time the Redo is requested.
 43      *Undo for Connecting means that we need to delete the glue
 44      **/
 45     redo : function(){
 46         //try to recreate the glue
 47         var glues = CONNECTOR_MANAGER.glueGetAllByIds(this.objectId[0], this.objectId[1]);
 48         
 49         if(glues.length == 0){ //avoid recreating it if already exists :p
 50             CONNECTOR_MANAGER.glueCreate(this.objectId[0], this.objectId[1]);        
 51         }
 52     }
 53     
 54 }
 55 
 56