package com.uvigo.mhp.ui;

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

public class BackgroundModeEditor 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 HVisible.NO_BACKGROUND_FILL:
                return "NO_BACKGROUND_FILL";
            default: //HVisible.BACKGROUND_FILL
                return "BACKGROUND_FILL";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("NO_BACKGROUND_FILL"))
            mode = HVisible.NO_BACKGROUND_FILL;
        else
            mode = HVisible.BACKGROUND_FILL;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"NO_BACKGROUND_FILL", "BACKGROUND_FILL"};
    }
    
    public String getJavaInitializationString()
    {
        return "org.havi.ui.HVisible."+getAsText();
    }
}
