/*
 * HtmlEditorManager.java
 *
 * Created on October 18, 2000, 2:34 PM
 */

package ovt.servlet;

import ovt.*;
import ovt.beans.*;
import ovt.util.*;

/**
 *
 * @author  ko
 * @version 
 */
public class HtmlEditorManager extends Object {
    
    
    /** Creates new HtmlEditorManager */
    public HtmlEditorManager() {
    }
    
    public static HtmlPropertyEditor getEditor(OVTCore core, String propPath)
            throws IllegalArgumentException {
        return getEditor(core.getPD(propPath));
    }
    
    public static HtmlPropertyEditor getEditor(BasicPropertyDescriptor desc) {
        Log.log("HtmlEditorManager :: getEditor for " + desc.getDisplayName(), 7);
        BasicPropertyEditor ed = desc.getPropertyEditor();
        if (ed instanceof MenuPropertyEditor) {
            MenuPropertyEditor mpe = (MenuPropertyEditor)ed;
            switch (mpe.getType()) {
                case MenuPropertyEditor.CHECKBOX : return new HtmlComboBoxEditor(desc);
                // to be implemented later
                case MenuPropertyEditor.RADIOBUTTON : return new HtmlComboBoxEditor(desc);
                // in swith case - make ComboBox editor
                case MenuPropertyEditor.SWITCH : return new HtmlComboBoxEditor(desc);
            }
        } else if (ed instanceof ComboBoxPropertyEditor) {
            return new HtmlComboBoxEditor(desc);
        }
        // else 
        return new HtmlTextEditor(desc);
    }

}