package vis.beans.editors;
import java.beans.*;
/**
 * Property editor for displaying viewing modes.
 */
import java.lang.reflect.*;
import java.util.*;
import vis.util.*;
 public class EnumEditor extends java.beans.PropertyEditorSupport {
    Enum oldVal = null;
    Enum newVal=null;
    Field fl[];
    String stringValue = Integer.toString(1);
    int intValue;
    String[] tags;
    /** @return tags the tags.
      */
    public String[] getTags() {
       return tags;
    } 
    /** @return val value of the property as an Object
      */                             
    public void setValue(Object val){
       tags = ((Enum)val).getMembers();
       oldVal = newVal;
       newVal = (Enum)val;
    }
    /** @param txt the text value of the property.
      */
    public void setAsText(String txt){
       if(tags== null) return;
       try {
          for(int i=0;i<tags.length;i++){
              if(txt.equals(tags[i])){
                 newVal.setCurrentValue(newVal.getValue(txt));
                 System.out.println("fire");
                 firePropertyChange();
                 break;
              }
           }
        }
       catch(Exception e){e.printStackTrace();}
       return;
    }
    /** @return stringValue the text value of the property.
      */
    public String getAsText(){
       return stringValue;
    }
    /** @return newValue the value of the property as an Object.
      */
    public Object getValue(){
       return newVal;
    }
 }

