KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.kelp.jbuilder.actions;
2
3 import com.borland.primetime.ide.Browser;
4 import com.borland.primetime.ide.BrowserAction;
5 import javax.swing.AbstractAction JavaDoc;
6 import org.enhydra.kelp.ant.dods.KelpDODSGenerator;
7 import com.borland.primetime.node.Project;
8 import com.borland.primetime.vfs.Url;
9 import com.borland.jbuilder.node.JBProject;
10 import java.io.File JavaDoc;
11 import org.enhydra.kelp.ant.node.AntProject;
12
13 public class DODSAction extends BrowserAction
14 {
15
16   public DODSAction(String JavaDoc s, char c) {
17     super(s, c);
18   }
19
20   public void actionPerformed(Browser browser) {
21     String JavaDoc prjPath = null;
22     JBProject project = (JBProject)browser.getActiveUserProject();
23     if (project != null) {
24       try {
25         prjPath = project.getProjectPath().getFullName();
26         AntProject antProject = new AntProject(prjPath);
27         String JavaDoc enhydraDir = antProject.getProperty(AntProject.ENHYDRA_DIR);
28         File JavaDoc dodsDirFile = new File JavaDoc(enhydraDir, "dods");
29         System.setProperty("DODS_HOME", dodsDirFile.getAbsolutePath());
30         KelpDODSGenerator.main(new String JavaDoc[] {prjPath});
31       }
32       catch (Exception JavaDoc ex) {
33         ex.printStackTrace();
34       }
35       project.refresh();
36     }
37   }
38
39   /**
40    * Enables deploy action if current project exists and if it is JBProject type
41    * and if exist builder.xml file in the project
42    *
43    * @param browser
44    */

45   public void update(Browser browser) {
46     JBProject project;
47     if (browser.getActiveProject() != null) {
48       project = (JBProject)browser.getActiveProject();
49       setEnabled( (project instanceof JBProject) &&
50                   (project.getProperty("enhydra.project", "false")
51                     .equalsIgnoreCase("true")) );
52     } else {
53       setEnabled(false);
54     }
55   }
56
57 }
Popular Tags