package com.uvigo.mhp.ui;

import java.beans.*;
import javax.swing.*;

public class HMenuLayoutOrientationEditor extends PropertyEditorSupport
{
    private int orientation;
    
    public void setValue(Object o)
    {
        orientation = ((Integer)o).intValue();
        firePropertyChange();
    }
    
    public Object getValue()
    {
        return new Integer(orientation);
    }
    
    public String getAsText()
    {
        switch (orientation)
        {
            case JList.VERTICAL:
                return "VERTICAL";
            case JList.VERTICAL_WRAP:
                return "VERTICAL_WRAP";
            default: // HORIZONTAL_WRAP
                return "HORIZONTAL_WRAP";
        }
    }
    
    public void setAsText(String s) throws IllegalArgumentException
    {
        if (s.equalsIgnoreCase("VERTICAL"))
            orientation = JList.VERTICAL;
        else if (s.equalsIgnoreCase("VERTICAL_WRAP"))
            orientation = JList.VERTICAL_WRAP;
        else
            orientation = JList.HORIZONTAL_WRAP;
        firePropertyChange();
    }
    
    public String[] getTags()
    {
        return new String[]
        {"VERTICAL", "VERTICAL_WRAP", "HORIZONTAL_WRAP"};
    }
    
    public String getJavaInitializationString()
    {
        return "javax.swing.JList."+getAsText();
    }
}
