Letractively / aost

Automatically exported from code.google.com/p/aost
Other
1 stars 0 forks source link

add duplicated command detection to Tellurium IDE 0.8.0 #460

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Prevent duplicated commands

Original issue reported on code.google.com by John.Jian.Fang@gmail.com on 11 Aug 2010 at 5:01

GoogleCodeExporter commented 9 years ago
function UiCommand(name, ref, value, valueType, uid, seq){
    this.name = name;
    this.value = value;
    this.ref = ref;
    this.uid = uid;
    this.seq = seq;
    this.valueType = valueType;
}

UiCommand.prototype.toString = function(){
    var sb = new StringBuffer();
    sb.append("[seq: ").append(this.seq).append(", name: ").append(this.name).append(", value").append(this.value)
            .append(", value: ").append(this.value).append(", ref:").append(this.ref).append("]");
    return sb.toString();
};

UiCommand.prototype.isEqual = function(cmd){
    return this.name == cmd.name && this.uid == cmd.uid && this.value == cmd.value && this.ref == cmd.ref;
};
Workspace.prototype.addCommand = function(name, ref, value, valueType){
    var command = new UiCommand(name, ref, value, valueType, null, null);
    if(this.commandList.length > 0){
        var prevCmd = this.commandList[this.commandList.length-1];
        if(command.isEqual(prevCmd)){
            logger.warn("Duplicated command: " + command.toString() + ", ignore it.");
            return false;
        }
    }
    this.commandList.push(command);
    return true;
};

Original comment by John.Jian.Fang@gmail.com on 11 Aug 2010 at 5:25