KickJava   Java API By Example, From Geeks To Geeks.

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


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
35 import org.enhydra.kelp.forte.DeploySettings;
36
37 import org.enhydra.kelp.common.PathUtil;
38
39 import java.io.File JavaDoc;
40
41 /** Represents a Deploy object in the Repository.
42  *
43  * @author rees0234
44  */

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

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