KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > SchemaLoader


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.schema;
20
21
22 import org.openide.filesystems.*;
23 import org.openide.loaders.*;
24
25 import org.netbeans.modules.xml.core.XMLDataLoader;
26
27 /**
28  * XML Schema loader. It is mime type based.
29  *
30  * @author Petr Kuzel
31  */

32 public class SchemaLoader extends UniFileLoader {
33
34     private static final long serialVersionUID = 54841328367L;
35
36     static final String JavaDoc MIME_TYPE = "application/x-schema+xml"; // NOI18N
37

38     /** Creates a new instance of SchemaLoader */
39     public SchemaLoader() {
40         super("org.netbeans.modules.xml.schema.SchemaObject"); // NOI18N
41
}
42     
43     /** Does initialization. Initializes display name,
44      * extension list and the actions. */

45     protected void initialize () {
46         super.initialize();
47         
48         ExtensionList ext = getExtensions();
49         ext.addMimeType (MIME_TYPE);
50         setExtensions (ext);
51     }
52     
53     protected String JavaDoc actionsContext() {
54         return "Loaders/text/x-schema+xml/Actions/";
55     }
56     
57     /**
58      * Lazy init name.
59      */

60     protected String JavaDoc defaultDisplayName () {
61         return Util.THIS.getString ("SchemaLoader_name");
62     }
63     
64     /** Creates the right primary entry for given primary file.
65      *
66      * @param primaryFile primary file recognized by this loader
67      * @return primary entry for that file
68      */

69     protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) {
70         return new XMLDataLoader.XMLFileEntry (obj, primaryFile); //adds smart templating
71
}
72
73     /** Creates the right data object for given primary file.
74      * It is guaranteed that the provided file is realy primary file
75      * returned from the method findPrimaryFile.
76      *
77      * @param primaryFile the primary file
78      * @return the data object for this file
79      * @exception DataObjectExistsException if the primary file already has data object
80      */

81     protected MultiDataObject createMultiObject (FileObject primaryFile)
82             throws DataObjectExistsException, java.io.IOException JavaDoc {
83         return new SchemaObject (primaryFile, this);
84     }
85     
86 }
87
Popular Tags