Ext.define('VisibilityStackItemClass', {
    constructor: function(o, newIsVisible, oldIsVisible, visibleActionID){
        this.OrderOfChange = o;
        this.NewIsVisible = newIsVisible;
        this.OldIsVisible = oldIsVisible;
        this.VisibleActionID = visibleActionID;
    },
    toString: function(){
        return Ext.String.format("IsVisible changed from {0} to {1} by VisibleAction: {2}", this.OldIsVisible, this.NewIsVisible, this.VisibleActionID);
    }
});
Ext.define('VisibilityChangeClass', {
    constructor: function(cfgXML, visibleActionID){
        this.VisibleActionID = visibleActionID;
        this.TargetActionID = XmlHelper.getString(cfgXML, "targetActionID");
        this.TargetIsVisible = XmlHelper.getBoolean(cfgXML, "targetIsVisible");
        this.Effect = XmlHelper.getInteger(cfgXML, "effect");
        this.Duration = XmlHelper.getFloat(cfgXML, "duration");
    },
    toString: function(){
        return Ext.String.format("VisiblieAction: {2}, Change {0} to {1}", this.TargetActionID, (this.TargetIsVisible ? "Show" : "Hide"), this.VisibleActionID);
    }
});
Ext.define('VisibleClass15', {
    extend: 'GeneralAction',
    constructor: function(cfgXML, o, actionSequence){
        this.ChangeList = null;
        this.callParent([ cfgXML, o, actionSequence]);
        this.ChangeList = new Ext.util.MixedCollection();
        var changeNodes = cfgXML.getElementsByTagName("change");
        for (var i = 0; i < changeNodes.length; i++) {
            var changeObject = new VisibilityChangeClass(changeNodes[i], this.id);
            this.ChangeList.add(changeObject.TargetActionID, changeObject);
        }
    },
    processAction: function(){
        this.ChangeList.each(function(vcObject, index, length){
           // Author.log("Trying to show/hide:"+vcObject.toString());
            if (Author.CurrentStateManager.hasAction(vcObject.TargetActionID)) {
                var targetAction = Author.CurrentStateManager.getActionByID(vcObject.TargetActionID);
                if (targetAction.IsDisplayable) {
                    //Here targetAction is the orginal Action
                    targetAction.applyVisibilityChange(this.LogicalOrder, vcObject);
                }
                else {
                    Author.log("VisibleClass trying to set visibility on a not displayable action.")
                }
            }
            else {
                Author.log("VisibleClass: Can't find action [" + vcObject.TargetActionID + "].");
              // Author.showCurrentListActions();
            }
        }, this);
        return {MoveOn: true, Interval: 0};
    }
});
