// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) space 
// Source File Name:   ChoiceEditor.java

package lt.ktu.gmj.propertySheet;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JComboBox;
import javax.swing.JComponent;

// Referenced classes of package lt.ktu.gmj.propertySheet:
//            PropertyEditor, PropertyReader, PropertyWriter, InvalidPropertyException, 
//            PropertyNotifier, PropertyProvider

public class ChoiceEditor
    implements PropertyEditor
{

    public void refreshed()
    {
        int i = ((Integer)provider.get()).intValue();
        editor.setSelectedIndex(i);
    }

    public void fieldChanged()
    {
        try
        {
            int i = editor.getSelectedIndex();
            provider.set(new Integer(i));
        }
        catch (InvalidPropertyException invalidpropertyexception) { }
    }

    public JComponent component()
    {
        return (JComponent)editor;
    }

    public ChoiceEditor(PropertyProvider propertyprovider, String as[])
    {
        provider = null;
        editor = new JComboBox(as);
        editor.addItemListener(new _cls1());
        provider = propertyprovider;
        provider.addObserver(this);
        refreshed();
    }

    private PropertyProvider provider;
    private JComboBox editor;

    private class _cls1
        implements ItemListener
    {

        public void itemStateChanged(ItemEvent itemevent)
        {
            fieldChanged();
        }

        public void constructor$0(ChoiceEditor choiceeditor)
        {
        }

        public _cls1()
        {
            constructor$0(ChoiceEditor.this);
        }
    }

}
