package com.uvigo.mhp.ui;

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

public class NOUSADODelayedTimeEditor extends PropertyEditorSupport
{
    private int mode;
    
    public void setValue(Object o)
    {
        mode = ((Integer)o).intValue();
        System.out.println("cuando me llaman en el delayedTimeEditor valego "+mode);
        firePropertyChange();
    }
    
    public Object getValue()
    {
        return new Integer(mode);
    }
    
    public String getAsText()
    {
        switch (mode)
        {
            case HPanel.TIME_ALWAYS:
                return "ALWAYS";
            case HPanel.TIME_OK:
                return "OK";
            case HPanel.TIME_WRONG:
                return "WRONG";
                case HPanel.TIME_DELAYED:
                return "DELAYED";
            default: //HPanel.BACKGROUND_FILL
                return "LIMITED";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("ALWAYS"))
            mode = HPanel.TIME_ALWAYS;
        else if (s.equalsIgnoreCase("OK"))
            mode = HPanel.TIME_OK;
        else if (s.equalsIgnoreCase("WRONG"))
            mode = HPanel.TIME_WRONG;
         else if (s.equalsIgnoreCase("DELAYED"))
            mode = HPanel.TIME_DELAYED;
        else
            mode = HPanel.TIME_LIMITED;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"ALWAYS", "OK", "WRONG", "DELAYED", "LIMITED"};
    }
    
    public String getJavaInitializationString()
    {
        return "com.uvigo.mhp.ui.HPanel.TIME_"+getAsText();
    }
}
