KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > loader > CssFileLoader


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * CssFileLoader.java
22  *
23  * Created on December 8, 2004, 10:06 PM
24  */

25
26 package org.netbeans.modules.css.loader;
27
28 import org.openide.filesystems.FileObject;
29 import org.openide.loaders.DataObjectExistsException;
30 import org.openide.loaders.MultiDataObject;
31 import org.openide.loaders.UniFileLoader;
32 import org.openide.util.NbBundle;
33
34 /**
35  * Data loader that recognizes and loads the CSS files
36  * @author Winston Prakash
37  * @version 1.0
38  */

39 public class CssFileLoader extends UniFileLoader{
40
41     public static final String JavaDoc CSS_MIME_TYPE = "text/x-css"; //NOI18N
42

43     /** Creates a new instance of CssFileLoader */
44     public CssFileLoader() {
45         super(org.netbeans.modules.css.loader.CssDataObject.class.getName());
46     }
47
48     /** Get the default display name of this loader.
49      * @return default display name
50      */

51     protected String JavaDoc defaultDisplayName() {
52         return NbBundle.getMessage(CssFileLoader.class, "CssLoaderName"); // NOI18N
53
}
54
55     /**
56      * Initialize shared state of this shared class (SharedClassObject)
57      */

58     protected void initialize() {
59         super.initialize();
60         getExtensions().addMimeType(CSS_MIME_TYPE);
61     }
62
63     protected FileObject findPrimaryFile(FileObject fo) {
64         if (fo.isFolder()) {
65             return null;
66         }
67
68         FileObject primaryFile = super.findPrimaryFile(fo);
69         if (primaryFile == null) {
70             return null;
71         }
72         return primaryFile;
73     }
74
75     /**
76      * Create the data object for a given primary file.
77      * @return data object for the file
78      */

79     protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, java.io.IOException JavaDoc {
80         return new CssDataObject(primaryFile, this);
81     }
82
83     protected String JavaDoc actionsContext() {
84         return "Loaders/" + CSS_MIME_TYPE + "/Actions";
85     }
86 }
87
Popular Tags