KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > node > DodsDataLoader


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Lisa Reese
21  *
22  */

23
24 package org.enhydra.kelp.forte.node;
25
26 import java.io.IOException JavaDoc;
27
28 import org.openide.actions.*;
29 import org.openide.filesystems.FileObject;
30 import org.openide.filesystems.FileUtil;
31 import org.openide.loaders.*;
32 import org.openide.util.NbBundle;
33 import org.openide.util.actions.SystemAction;
34
35 import java.util.Enumeration JavaDoc;
36 import java.io.*;
37
38 /** Recognizes some set of files in the Repository as belonging together.
39  *
40  * @author rees0234
41  */

42 public class DodsDataLoader extends MultiFileLoader {
43
44     static final long serialVersionUID = 7377840573359349120L;
45
46     private static final String JavaDoc TEMP_EXT = "in";
47 // private static final String CONF_EXT = "conf";
48

49     public static final String JavaDoc PROP_DODS_EXTENSIONS = "dods.extensions";
50
51     public DodsDataLoader ()
52 {
53     this (DodsDataObject.class);
54     }
55
56     public DodsDataLoader (Class JavaDoc recognizedObject)
57 {
58         super (recognizedObject);
59     }
60
61     protected void initialize () {
62
63         setDisplayName (NbBundle.getMessage(DodsDataLoader.class, "LBL_Dodsloader"));
64
65         setActions (new SystemAction[] {
66 // SystemAction.get (OpenAction.class),
67
null,
68 // SystemAction.get (FileSystemAction.class),
69
null,
70                         null,
71                         /*
72                         SystemAction.get (CompileAction.class),
73                         null,
74                         SystemAction.get (ExecuteAction.class),
75                         null,
76                         */

77 // SystemAction.get (CutAction.class),
78
null,
79 // SystemAction.get (CopyAction.class),
80
null,
81 // SystemAction.get (PasteAction.class),
82
null,
83                         null,
84 // SystemAction.get (DeleteAction.class),
85
null,
86 // SystemAction.get (RenameAction.class),
87
null,
88                         null,
89 // SystemAction.get (SaveAsTemplateAction.class),
90
null,
91 // SystemAction.get (ToolsAction.class),
92
// SystemAction.get (PropertiesAction.class),
93
null
94                     });
95
96 // super.initialize();
97

98     }
99
100     protected FileObject findPrimaryFile (FileObject fo) {
101         // This can of course be much more sophisticated.
102
Enumeration JavaDoc extSet = getExtensions().extensions();
103         while (extSet.hasMoreElements())
104         {
105             String JavaDoc ext = (String JavaDoc)extSet.nextElement();
106             if (fo.hasExt (ext))
107                 return fo;
108         }
109         return null;
110     }
111
112     protected MultiDataObject createMultiObject (FileObject primaryFile)
113     throws DataObjectExistsException, IOException JavaDoc {
114         return new DodsDataObject (primaryFile, this);
115     }
116
117     protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) {
118         // Entry for the important file: by default, is preserved during all operations.
119
return new FileEntry (obj, primaryFile);
120         // return new DodsFormat (obj, primaryFile);
121
}
122
123     protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) {
124         secondaryFile.setImportant (false);
125         return new FileEntry.Numb (obj, secondaryFile); // discard whenever needed
126
}
127
128     /** @return The list of extensions this loader recognizes
129     * (the default contains only java)
130     */

131     public ExtensionList getExtensions () {
132     ExtensionList extensions = (ExtensionList)getProperty(PROP_DODS_EXTENSIONS);
133     if (extensions == null) {
134             extensions = new ExtensionList();
135      //these should be read from global props instead of hard coded ?
136
extensions.addExtension(TEMP_EXT);
137 // extensions.addExtension(CONF_EXT);
138

139         putProperty(PROP_DODS_EXTENSIONS, extensions, false);
140         }
141         return extensions;
142     }
143
144     /** Sets the extension list for this data loader.
145     * @param ext new list of extensions.
146     */

147     public void setExtensions(ExtensionList ext) {
148         putProperty(PROP_DODS_EXTENSIONS, ext, true);
149     }
150
151 }
152
Popular Tags