 package com.vistech.editors;
 import java.beans.*;


 import java.lang.reflect.*;
 import java.util.*;
 /**
   * Property editor for displaying viewing modes.
   */
 public class EnumIntEditor extends java.beans.PropertyEditorSupport {
    Field items[];
    String stringValue = Integer.toString(1);
    int intValue;
    String enumClass;
    public String[] getTags() {
        try {
          Class flClass = Class.forName(enumClass);
          items = flClass.getDeclaredFields();
          String EnumStr[] = new String[items.length];
          for(int i=0;i< items.length;i++){
              EnumStr[i] = items[i].getName();
              System.out.println(EnumStr);
          }
          return EnumStr;
        } catch (ClassNotFoundException e){
            System.out.println(enumClass + "  not found");
            return null; 
        }
    }

    public void setAsText(String txt){
       if(items == null) return;
       try {
          for(int i=0;i<items.length;i++){
              if(txt.equals(items[i].getName())){
                 intValue = items[i].getInt(null);
                 stringValue = Integer.toString(intValue); 
                 firePropertyChange();
                 break;
              }
           }
        }
       catch(Exception e){   System.out.println(" setAsText Exception");}
       return;
    }
    public String getAsText(){
       return stringValue;
    }
    public Object getValue(){
       return new Integer(intValue);
    }
    public void setEnumClass(String en){
       enumClass = en;
    }

}

