KickJava   Java API By Example, From Geeks To Geeks.

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


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 DeployDataLoader 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_DEPLOY_EXTENSIONS = "deploy.extensions";
50
51     public DeployDataLoader ()
52 {
53     this (DeployDataObject.class);
54     }
55
56     public DeployDataLoader (Class JavaDoc recognizedObject)
57 {
58         super (recognizedObject);
59     }
60
61     protected void initialize () {
62
63         setDisplayName (NbBundle.getMessage (DeployDataLoader.class, "LBL_Deployloader"));
64
65         setActions (new SystemAction[] {
66                         SystemAction.get (OpenAction.class),
67                         SystemAction.get (FileSystemAction.class),
68                         null,
69                         /*
70                         SystemAction.get (CompileAction.class),
71                         null,
72                         SystemAction.get (ExecuteAction.class),
73                         null,
74                         */

75                         SystemAction.get (CutAction.class),
76                         SystemAction.get (CopyAction.class),
77                         SystemAction.get (PasteAction.class),
78                         null,
79                         SystemAction.get (DeleteAction.class),
80                         SystemAction.get (RenameAction.class),
81                         null,
82                         SystemAction.get (SaveAsTemplateAction.class),
83 // null,
84
// SystemAction.get (ToolsAction.class),
85
SystemAction.get (PropertiesAction.class),
86                     });
87
88         super.initialize();
89
90     }
91
92     protected FileObject findPrimaryFile (FileObject fo) {
93         // This can of course be much more sophisticated.
94
Enumeration JavaDoc extSet = getExtensions().extensions();
95         while (extSet.hasMoreElements())
96         {
97             String JavaDoc ext = (String JavaDoc)extSet.nextElement();
98             if (fo.hasExt (ext))
99                 return fo;
100         }
101         return null;
102     }
103
104     protected MultiDataObject createMultiObject (FileObject primaryFile)
105     throws DataObjectExistsException, IOException JavaDoc {
106         return new DeployDataObject (primaryFile, this);
107     }
108
109     protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) {
110         // Entry for the important file: by default, is preserved during all operations.
111
return new FileEntry (obj, primaryFile);
112         // return new DeployFormat (obj, primaryFile);
113
}
114
115     protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) {
116         secondaryFile.setImportant (false);
117         return new FileEntry.Numb (obj, secondaryFile); // discard whenever needed
118
}
119
120     /** @return The list of extensions this loader recognizes
121     * (the default contains only java)
122     */

123     public ExtensionList getExtensions () {
124     ExtensionList extensions = (ExtensionList)getProperty(PROP_DEPLOY_EXTENSIONS);
125     if (extensions == null) {
126             extensions = new ExtensionList();
127      //these should be read from global props instead of hard coded ?
128
extensions.addExtension(TEMP_EXT);
129 // extensions.addExtension(CONF_EXT);
130

131         putProperty(PROP_DEPLOY_EXTENSIONS, extensions, false);
132         }
133         return extensions;
134     }
135
136     /** Sets the extension list for this data loader.
137     * @param ext new list of extensions.
138     */

139     public void setExtensions(ExtensionList ext) {
140         putProperty(PROP_DEPLOY_EXTENSIONS, ext, true);
141     }
142
143 }
144
Popular Tags