/// class PD.Commands.CommandGroup

PD.Commands.CommandGroup =
Class.extend({

    //===================================
    // FIELDS
    //===================================

    _id: null,
    _commands: null,
    _executor: null,
    
    //===================================
    // CONSTRUCTOR
    //===================================

    init: function (options) {
        this._id = options.id;
        this._commands = new PD.Commands.CommandCollection();
        this._executor = new PD.Commands.CommandExecutor();
        this.registerCommands({
            commands: this.get_commands()
        });
    },

    //===================================
    // PROPERTIES
    //===================================

    get_id: function () {
        return this._id;
    },

    get_commands: function () {
        return this._commands;
    },

    //===================================
    // PUBLIC METHODS
    //===================================

    setState: function (state, overwrite) {
        if (state != null) {
            this._commands.each(function (key, command) {
                command.setState(state, overwrite);
            });
        }
    },

    execute: function (commandPath, args) {
        var command = this.get_commands().getByPath(commandPath);
        if (command != null) {
            this._executor.execute(command, args);
        }
    },

    //===================================
    // PROTECTED METHODS
    //===================================

    registerCommands: function (e) {
        // overridable
    }

});