package uk.ac.reload.editor.style;


import java.io.File;
import java.io.IOException;
import java.util.Hashtable;

import javax.swing.Icon;

import org.jdom.JDOMException;
import org.jdom.Namespace;

import uk.ac.reload.dweezil.util.DweezilUIManager;
import uk.ac.reload.editor.EditorHandler;
import uk.ac.reload.editor.EditorInternalFrame;
import uk.ac.reload.editor.IEditorHandler;
import uk.ac.reload.editor.IIcons;
import uk.ac.reload.moonunit.SchemaController;
import uk.ac.reload.moonunit.schema.SchemaException;

//M: The editor implementation for style preferences
public class Style_EditorHandler implements IEditorHandler, IIcons{
    public static final String IDTV_STYLE_1_0 = "Style Preferences 1.0";

	// Namespace prefix
    public static String IDTVA_NAMESPACE_PREFIX = "idtv";
    
    // SS Version 1.0
    public static Namespace IDTVA_NAMESPACE_10 = Namespace.getNamespace("http://idtv.det.uvigo.es");

    static Hashtable SUPPORTED_NAMESPACES = new Hashtable();
    
    static {
		// Add to table of Supported Namespaces mapped to Version names
		SUPPORTED_NAMESPACES.put(IDTVA_NAMESPACE_10, IDTV_STYLE_1_0);
    }
    
    public static final File HELPER_FOLDER = new File(EditorHandler.HELPERFOLDER, "style");
    public static final File PROFILE_FOLDER = new File(HELPER_FOLDER, "profile");
    public static final File SCHEMAHELPER_FOLDER = new File(HELPER_FOLDER, "schemahelper");
    public static final File VOCAB_FOLDER = new File(HELPER_FOLDER, "vocab");

    /**
	 * Constructor
	 */
	public Style_EditorHandler() {

	}
	
    public boolean canCreateDocuments() {
        return false;
    }

    public boolean canEditFile(File file) {
	    return false;
	}

    public EditorInternalFrame editFile(File file) {
        return null;
    }

	public EditorInternalFrame newDocument() {
		return null;
	}
	
	public String getName() {
	    return "Style Preferences";
	}
	
	public Icon getIcon() {
	    return DweezilUIManager.getIcon(ICON_EDITSTYLEPREFERENCES);
	}

	public String[] getSupportedVersions() {
	    return new String[] {
	            IDTV_STYLE_1_0
	    };
	}

	public String getDefaultVersion() {
	    return IDTV_STYLE_1_0;
	}

	/**
     * Get a new instance implementation of the appropriate SchemaController
     * for a given version key.<br>
	 * @throws JDOMException
	 * @throws IOException
	 * @throws SchemaException
    */
    public SchemaController getSchemaControllerInstance(String version) throws JDOMException, SchemaException, IOException {
        SchemaController schemaController = null;
        
        if(IDTV_STYLE_1_0.equals(version)) {
            schemaController = new Style_SchemaController();
        }
        
        return schemaController;
    }
}
