package com.uvigo.mhp.ui;

import java.beans.*;
import org.havi.ui.*;

public class PlayModeEditor extends PropertyEditorSupport
{
    private int mode;
    
    public void setValue(Object o)
    {
        mode = ((Integer)o).intValue();
        firePropertyChange();
    }
    
    public Object getValue()
    {
        return new Integer(mode);
    }
    
    public String getAsText()
    {
        switch (mode)
        {
            case HAnimation.PLAY_REPEATING:
                return "PLAY_REPEATING";
            default: //HAnimation.PLAY_ALTERNATING:
                return "PLAY_ALTERNATING";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("PLAY_REPEATING"))
            mode = HAnimation.PLAY_REPEATING;
        else
            mode = HAnimation.PLAY_ALTERNATING;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"PLAY_REPEATING", "PLAY_ALTERNATING"};
    }
    
    public String getJavaInitializationString()
    {
        return "org.havi.ui.HAnimation."+getAsText();
    }
}
