KickJava   Java API By Example, From Geeks To Geeks.

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


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.deployer.AntDeployTool;
7 import com.borland.jbuilder.node.JBProject;
8 import com.borland.primetime.vfs.Filesystem;
9 import com.borland.primetime.vfs.VFS;
10 import com.borland.primetime.vfs.Url;
11 import com.borland.primetime.node.FileNode;
12 import java.io.File JavaDoc;
13 import com.borland.primetime.node.FolderNode;
14 import com.borland.primetime.node.Node;
15 import com.borland.primetime.node.LightweightNode;
16 import org.enhydra.kelp.ant.node.AntProject;
17 import org.enhydra.kelp.jbuilder.node.NodeUtil;
18
19 public class DeployerAction extends BrowserAction
20 {
21
22   private JBProject project;
23
24   public DeployerAction(String JavaDoc s, char c) {
25     super(s, c);
26   }
27
28   public void actionPerformed(Browser browser) {
29     String JavaDoc prjPath = null;
30     Url url;
31     project = (JBProject) browser.getActiveProject();
32     prjPath = project.getProjectPath().getFullName();
33     AntProject antProject = null;
34     try {
35       antProject = new AntProject(prjPath);
36     }
37     catch (Exception JavaDoc e) {
38       e.printStackTrace();
39     }
40
41     AntDeployTool.main(new String JavaDoc[] {prjPath});
42
43     url = new Url(new File JavaDoc(antProject.getProperty(AntProject.OUTPUT_DIR)));
44     if (url.getFileObject().exists()) {
45       try {
46         NodeUtil.doAddFolders(project, project, url);
47       }
48       catch (Exception JavaDoc ex) {
49         ex.printStackTrace();
50       }
51       browser.getActiveProject().refresh();
52     }
53   }
54
55   /**
56    * Enables deploy action if current project exists and if it is JBProject type
57    * and if exist builder.xml file in the project
58    *
59    * @param browser
60    */

61   public void update(Browser browser) {
62     if (browser.getActiveProject() != null) {
63       project = (JBProject)browser.getActiveProject();
64       setEnabled( (project instanceof JBProject) &&
65                   (project.getProperty("enhydra.project", "false")
66                     .equalsIgnoreCase("true")) );
67     } else {
68       setEnabled(false);
69     }
70   }
71 }
Popular Tags