KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.openide.actions.*;
27 import org.openide.cookies.*;
28 import org.openide.loaders.*;
29 import org.openide.nodes.*;
30 import org.openide.util.HelpCtx;
31 import org.openide.filesystems.FileObject;
32 import org.openide.filesystems.FileSystem;
33 import org.openide.filesystems.FileStateInvalidException;
34 import org.enhydra.kelp.forte.node.DodsDataLoader;
35
36 import org.enhydra.kelp.forte.DodsSettings;
37
38 import org.enhydra.kelp.common.PathUtil;
39
40 import java.io.File JavaDoc;
41
42 /** Represents a Deploy object in the Repository.
43  *
44  * @author rees0234
45  */

46 public class DodsDataObject extends MultiDataObject {
47
48     static final long serialVersionUID = -1461825550268566994L;
49
50     protected DodsSettings settings = null;
51
52     public DodsDataObject (FileObject pf, DodsDataLoader loader) throws DataObjectExistsException
53     {
54         super (pf, loader);
55         init ();
56     }
57
58     private void init () {
59         settings = DodsSettings.getDefault();
60         CookieSet cookies = getCookieSet ();
61         // Add whatever capabilities you need, e.g.:
62
/*
63         cookies.add (new ExecSupport (getPrimaryEntry ()));
64         cookies.add (new EditorSupport (getPrimaryEntry ()));
65         cookies.add (new CompilerSupport.Compile (getPrimaryEntry ()));
66         cookies.add (new CompilerSupport.Build (getPrimaryEntry ()));
67         cookies.add (new CompilerSupport.Clean (getPrimaryEntry ()));
68         cookies.add (new OpenCookie () {
69         public void open () {
70             // do something...but usually you want to use OpenSupport instead
71         }
72         });
73         */

74         cookies.add(new XMLCEditorSupport(this));
75     }
76
77     public HelpCtx getHelpCtx () {
78         return HelpCtx.DEFAULT_HELP;
79         // If you add context help, change to:
80
// return new HelpCtx (DeployDataObject.class);
81
}
82
83     protected Node createNodeDelegate () {
84         return new DodsDataNode (this);
85     }
86
87     public String JavaDoc getPath()
88     {
89         FileObject file = getPrimaryFile();
90         StringBuffer JavaDoc res = new StringBuffer JavaDoc();
91         FileSystem fs = null;
92         try
93         {
94            fs = file.getFileSystem();
95         } catch (FileStateInvalidException e)
96         {
97            System.err.println(e);
98            return "invalid";
99         }
100
101         res.append(fs.getSystemName());
102         String JavaDoc pack = file.getPackageNameExt(File.separatorChar, '.');
103         res.append(File.separatorChar);
104         res.append(pack);
105
106         return res.toString();
107     }
108
109     public String JavaDoc getProperty(String JavaDoc key)
110     {
111        String JavaDoc path = PathUtil.compressPathRelativeToProject(new ForteProject(), getPath());
112        return (String JavaDoc)settings.getNodeProperty(path + key);
113     }
114
115     public void setProperty(String JavaDoc key, String JavaDoc value)
116     {
117         String JavaDoc path = PathUtil.compressPathRelativeToProject(new ForteProject(), getPath());
118         settings.setNodeProperty(path + key, value);
119     }
120 }
121
Popular Tags