
     function Parameter_EventListenerNotify(object){
       this.object = object;
       this.listeners = new Array();
       this.addListener = function(listener){
         this.listeners[this.listeners.length] = listener;
       }
       this.notify = function(event){
         if(this.listeners.length==0) return;
         for(var i=0;i<this.listeners.length;i++){
          this.listeners[i].doChange(event);
         }
      }

     }



     Parameter_EventListenerNotify.prototype.doChange = function(value){
      if(this.object!=null)
        this.object.value = value;
       //该对象的数值已经变化，通知其它对象
     }

     function Parameter_Parameter(id,name,code,filter) {
        this.id = id;
        this.code = code==null?this.id:code;
        this.filter = filter == null?this.code:filter;
        this.name = name;
     };

     //根据选择的值完全匹配进行缩水
     function Parameter_OptionGenerator(select,style,styleClass,defaultValue){
      this.Parameter_EventListenerNotify = Parameter_EventListenerNotify;
      this.Parameter_EventListenerNotify(select);
      this.select = select;
      this.style = style;
      this.defaultValue = defaultValue;
      this.styleClass = styleClass;
      this.parameters = new Array();

      this.add = function(parameter){
        this.parameters[this.parameters.length] = parameter;
      };

      this.generatorSelectOptions = function(filter){
        this.select.options.length = 0;
        this.select.disabled = true;

        for(var i=0;i<this.parameters.length;i++) {
          var parameter = this.parameters[i];
          if(this.isMatch(parameter,filter)){
            if(parameter.id == this.defaultValue)
              this.generatorSelectOption(parameter,true);
            else
             this.generatorSelectOption(parameter,false);
          }
        }
        this.select.disabled = false;

      };

      this.generatorSelectOption = function(parameter,matched){
        var option = this.select.options[this.select.options.length++];
        option.value = parameter.id;
        option.text = parameter.name;
        option.selected = matched;
        if(this.style != null) {
            option.style = this.style;
       }
        if(this.styleClass != null) {
        //  option.styple.class = this.styleClass;
       }
      }
     };
     Parameter_OptionGenerator.prototype =  new Parameter_EventListenerNotify;

     Parameter_OptionGenerator.prototype.doChange = function(filter){
        this.generatorSelectOptions(filter);
        this.notify(this.select.value);
        //该对象的数值已经变化，通知其它对象
     };

     Parameter_OptionGenerator.prototype.isMatch = function(parameter,filter){
        if(filter == null||"" == filter||"" == parameter.id)
          return true;
        if(parameter.filter == filter)
         return true;
        return false;
     };


     /**
      * 根据选择的值部分匹配进行缩水
      */

     function Parameter_ShrinkOptionGenerator(select,style,styleClass,defaultValue){
       this.Parameter_OptionGenerator = Parameter_OptionGenerator;
       this.Parameter_OptionGenerator(select,style,styleClass,defaultValue);
     };
     Parameter_ShrinkOptionGenerator.prototype = new Parameter_OptionGenerator;



     Parameter_ShrinkOptionGenerator.prototype.isMatch = function(parameter,filter){

       if(filter==null||"" == filter||"" == parameter.id||parameter.filter.indexOf(filter)==0){
        return true;
       }
       return false;
     };


      /**
      * 根据用户的输入，定位选择框内对应的值
      */

     function Parameter_FocusOptionGenerator(select,style,styleClass,defaultValue){
       this.Parameter_OptionGenerator = Parameter_OptionGenerator;
       this.Parameter_OptionGenerator(select,style,styleClass,defaultValue);

       this.focusOption = function(filter) {
        for(var i=0;i<this.parameters.length;i++) {
         var parameter = this.parameters[i];
         select.options[i].selected = false;
          if(this.isMatch(parameter,filter)){
            select.options[i].selected = true;
            break;
          }
        }
       }
      };
     Parameter_FocusOptionGenerator.prototype = new Parameter_OptionGenerator;
     Parameter_FocusOptionGenerator.prototype.doChange = function(filter){
        this.focusOption(filter);
        this.notify(this.select.value);
     };
     Parameter_FocusOptionGenerator.prototype.isMatch = function(parameter,filter){
       if(filter==null||"" == filter||"" == parameter.id||parameter.filter.indexOf(filter)==0){
        return true;
       }
       return false;
     };
