KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > actions > DODSAction


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 package org.enhydra.kelp.forte.actions;
24
25 // OpenIDE
26
import org.openide.nodes.Node;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29 import org.openide.util.actions.CallableSystemAction;
30 import org.openide.TopManager;
31 import org.openide.loaders.DataFolder;
32 import org.openide.loaders.DataObject;
33 import org.openide.src.ClassElement;
34 import org.openide.DialogDescriptor;
35 import org.openide.filesystems.FileSystem;
36 import org.openide.filesystems.FileObject;
37
38 // ToolBox
39
import org.enhydra.tool.common.SwingUtil;
40 import org.enhydra.tool.common.event.HelpEvent;
41 import org.enhydra.tool.common.event.HelpListener;
42
43 // AddinCore
44
import org.enhydra.kelp.KelpInfo;
45 import org.enhydra.kelp.common.dods.CoreDodsTool;
46 import org.enhydra.kelp.common.dods.DodsButtonPanel;
47 import org.enhydra.kelp.common.dods.DodsButtonListener;
48 import org.enhydra.kelp.common.node.OtterFileNode;
49
50 // AddinForte
51
import org.enhydra.kelp.forte.node.ForteProject;
52
53 // JDK
54
import java.awt.Dialog JavaDoc;
55 import java.awt.event.ActionListener JavaDoc;
56 import java.awt.event.ActionEvent JavaDoc;
57 import java.net.URL JavaDoc;
58 import java.net.MalformedURLException JavaDoc;
59
60 // mn 08.06.2002
61
import java.io.File JavaDoc;
62 import java.io.FileInputStream JavaDoc;
63 import java.io.FileOutputStream JavaDoc;
64 /**
65  * Action sensitive to some cookie that does something useful.
66  *
67  * @author rees0234
68  */

69 public class DODSAction extends CallableSystemAction implements HelpListener {
70     private static String JavaDoc anchor = "dodswizard";
71
72     // implements HelpListener
73
public void onHelp(HelpEvent event) {
74         URL JavaDoc url = null;
75         String JavaDoc[] home = new String JavaDoc[2];
76         home[0] = System.getProperty("netbeans.home");
77         home[1] = System.getProperty("netbeans.user");
78         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
79         buf.append(KelpInfo.getAddinHelpURL(home));
80         buf.append('#').append(anchor);
81         try {
82           url = new URL JavaDoc(buf.toString());
83           TopManager.getDefault().showUrl(url);
84         } catch (MalformedURLException JavaDoc e) {
85           e.printStackTrace(System.err);
86         }
87     }
88
89     public void performAction() {
90         // do work based on the current node selection, e.g.:
91
// SourceCookie cookie = (SourceCookie) nodes[0].getCookie (SourceCookie.class);
92
// etc.
93
ForteProject project = new ForteProject();
94         project.setEnhydraPath();
95
96         System.setProperty("DODS_HOME", project.getEnhydraPath()+
97           File.separator+"dods");
98
99         String JavaDoc[] options = DodsButtonPanel.getOptions();
100
101         CoreDodsTool tool = new CoreDodsTool();
102         DodsButtonListener listener = new DodsButtonListener(tool);
103         tool.getInnerPanel().initPreferredSize();
104
105         tool.setProject(project);
106         DialogDescriptor dscr = new DialogDescriptor(tool.getInnerPanel(),
107                 tool.getTitle(), true, options, options[1],
108                 DialogDescriptor.BOTTOM_ALIGN, HelpCtx.DEFAULT_HELP,
109                 listener);
110         Dialog JavaDoc dlg = TopManager.getDefault().createDialog(dscr);
111         tool.addHelpListener(this);
112         dlg.show();
113
114     }
115
116     public String JavaDoc getName() {
117         return CoreDodsTool.getDefaultTitle();
118     }
119
120     public boolean isEnabled()
121     {
122         return (new ForteProject().getRootFolder() != null);
123     }
124
125
126     protected String JavaDoc iconResource() {
127         return "smallicon.gif";
128     }
129
130     public HelpCtx getHelpCtx() {
131         return HelpCtx.DEFAULT_HELP;
132
133         // If you will provide context help then use:
134
// return new HelpCtx (DeployementAction.class);
135
}
136
137     /**
138      * Perform extra initialization of this action's singleton.
139      * PLEASE do not use constructors for this purpose!
140      */

141     protected void initialize() {
142         // mn 08.06.2002
143
super.initialize();
144         putProperty(javax.swing.Action.SHORT_DESCRIPTION,
145                     NbBundle.getMessage(DeploymentAction.class,
146                                         "HINT_DODS_Action"));
147     }
148
149 }
150
Popular Tags