KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > ant > deployer > AntDeployTool


1 package org.enhydra.kelp.ant.deployer;
2
3 /**
4  * <p>Title: </p>
5  * <p>Description: </p>
6  * <p>Copyright: Copyright (c) 2003</p>
7  * <p>Company: </p>
8  * @author unascribed
9  * @version 1.0
10  */

11
12 //AddInCore
13
import org.enhydra.kelp.common.AbstractTool;
14 import org.enhydra.kelp.common.event.SelectionPanelEvent;
15 import org.enhydra.kelp.common.event.SelectionPanelListener;
16 import org.enhydra.kelp.common.event.WriteListener;
17 import org.enhydra.kelp.common.node.OtterProject;
18 import org.enhydra.kelp.common.node.OtterFileNode;
19 import org.enhydra.kelp.common.swing.AddinInnerPanel;
20 //import org.enhydra.kelp.common.properties.XMLCProjectPropertyPanel;
21
//import org.enhydra.kelp.common.xmlc.XMLCButtonPanel;
22
//import org.enhydra.kelp.common.xmlc.XMLCButtonListener;
23

24
25 //AddInAnt
26
import org.enhydra.kelp.ant.node.AntProject;
27 import org.enhydra.kelp.ant.swing.HTMLViewer;
28 //import org.enhydra.kelp.ant.xmlc.AntXMLCBuilder;
29

30
31 //ToolBox
32
import org.enhydra.tool.common.PathHandle;
33 import org.enhydra.tool.common.InnerPanel;
34 import org.enhydra.tool.common.SwingUtil;
35 import org.enhydra.tool.common.ButtonPanel;
36 import org.enhydra.tool.common.event.FirstFocusEvent;
37 import org.enhydra.tool.common.event.FirstFocusListener;
38
39 // Standard imports
40
import java.io.File JavaDoc;
41 import java.awt.Component JavaDoc;
42 import java.awt.Dialog JavaDoc;
43 import java.awt.Frame JavaDoc;
44 import java.awt.event.ActionListener JavaDoc;
45 import java.lang.ref.WeakReference JavaDoc;
46 import java.net.URL JavaDoc;
47 import java.util.ResourceBundle JavaDoc;
48 /**
49  * <p>Title: </p>
50  * <p>Description: Deploy tool use AntProject for read,write properties and
51  * AntDeployBuilder for running Deployer. </p>
52  * <p>Copyright: Copyright (c) 2003</p>
53  * <p>Company: </p>
54  * @author Damir Milovic
55  * @version 1.0
56  */

57
58 public class AntDeployTool extends AbstractTool
59                          implements FirstFocusListener {
60
61     static ResourceBundle JavaDoc addinRes =
62         ResourceBundle.getBundle("org.enhydra.kelp.common.Res");
63     private AntDeployInnerPanel innerPanel = null;
64 // private XMLCButtonPanel buttonPanel = null;
65
private AntDeployButtonPanel buttonPanel = null;
66     private WeakReference JavaDoc compileRef = null;
67
68   public AntDeployTool() {
69     super();
70     innerPanel = new AntDeployInnerPanel();
71     buttonPanel = new AntDeployButtonPanel();
72     innerPanel.addFirstFocusListener(this);
73   }
74   public static void main(String JavaDoc[] args) {
75         SwingUtil.setLookAndFeelToSystem();
76         AntDeployTool tool = null;
77         AntProject project = null;
78         if(args.length > 0){
79           // check path
80
File JavaDoc root = new File JavaDoc(args[0]);
81             if(!root.exists()){
82               System.err.println("ERROR: directory'"+args[0]+"' don't exist!");
83               return;
84             }
85             try {
86                 project = new AntProject(args[0]);
87             }
88             catch (Exception JavaDoc ex) {
89                 ex.printStackTrace();
90                 return;
91             }
92
93         }else{
94             return;
95           //FIXME TODO get current directory
96
}
97
98         tool = new AntDeployTool();
99         tool.setProject(project); //DACHA
100
tool.showDialog(new Frame JavaDoc());
101         return;
102   }
103   /**
104    * Override
105    */

106   public void build() {
107     ((AntDeployInnerPanel)getInnerPanel()).selectOutputTab();
108     ((AntDeployInnerPanel)getInnerPanel()).save();
109     ((AntDeployInnerPanel)getInnerPanel()).clearOutput();
110     buildImpl();
111   }
112
113   private void buildImpl() {
114     AntDeployBuilder builder = new AntDeployBuilder(((AntDeployInnerPanel)getInnerPanel()).getWriteListeners());
115     builder.setProject(getProject());
116     builder.build();
117   }
118
119     public static final String JavaDoc getDefaultTitle() {
120         return "Deployer";
121     }
122
123     // implements AbstractTool
124
public String JavaDoc getTitle() {
125         return AntDeployTool.getDefaultTitle();
126     }
127
128     // implements AbstractTool
129
public InnerPanel getInnerPanel() {
130         return innerPanel;
131     }
132
133     // implements AbstractTool
134
public ButtonPanel getButtonPanel() {
135         return buttonPanel;
136     }
137
138     public ActionListener JavaDoc createButtonListener() {
139         return (new AntDeployButtonListener(this));
140     }
141
142     // overrides AbstractTool
143
public void setProject(OtterProject project) {
144         super.setProject(project);
145 // setNodes(project.getAllDocuments());
146
}
147
148     // overrides AbstractTool
149
public void clearAll() {
150         super.clearAll();
151        innerPanel.removeFirstFocusListener(this);
152         if (compileRef != null) {
153             compileRef.clear();
154         }
155         innerPanel = null;
156         buttonPanel = null;
157         compileRef = null;
158     }
159
160     // implements FirstFocusListener
161
public void onFirstFocus(FirstFocusEvent event) {
162         /** @todo */
163     }
164     
165     public void showHelp(Dialog JavaDoc parent){
166         URL JavaDoc helpURL = this.getClass().getClassLoader().getResource("using_ant_kelp.html");
167         HTMLViewer.createAndShow(parent, "Kelp Help", helpURL);
168
169     }
170     // implements org.enhydra.kelp.common.tool.AbstractTool
171
protected String JavaDoc getProgressTitle() {
172         return addinRes.getString("Deployment_Progress");
173     }
174
175     // implements org.enhydra.kelp.common.tool.AbstractTool
176
protected AddinInnerPanel getPropertyPanel() {
177         return innerPanel;
178     }
179
180     protected void back() {
181       innerPanel.back();
182     }
183
184     protected void next() {
185       innerPanel.next();
186     }
187 }
188
Popular Tags