package com.uvigo.mhp.activeImage;

import java.beans.*;

public class mouseBehaviourEditor extends PropertyEditorSupport
{
    private int behaviour;
    
    public void setValue(Object o)
    {
        behaviour = ((Integer)o).intValue();
        firePropertyChange();
    }
    
    public Object getValue()
    {
        return new Integer(behaviour);
    }
    
    public String getAsText()
    {
        switch (behaviour)
        {
            case ActiveImage.CLICK_TO_SELECT:
                return ActiveImage.CLICK_TO_SELECT_STR;
            default:
                return ActiveImage.SELECTION_FOLLOWS_MOUSE_STR;
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase(ActiveImage.CLICK_TO_SELECT_STR))
            behaviour = ActiveImage.CLICK_TO_SELECT;
        else
            behaviour = ActiveImage.SELECTION_FOLLOWS_MOUSE;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {ActiveImage.CLICK_TO_SELECT_STR, ActiveImage.SELECTION_FOLLOWS_MOUSE_STR};
    }
    
    public String getJavaInitializationString()
    {
        return ((Integer) getValue()).toString();
    }
}
