001: package org.enhydra.kelp.ant.deployer;
002:
003: /**
004: * <p>Title: </p>
005: * <p>Description: </p>
006: * <p>Copyright: Copyright (c) 2003</p>
007: * <p>Company: </p>
008: * @author unascribed
009: * @version 1.0
010: */
011:
012: //AddInCore
013: import org.enhydra.kelp.common.AbstractTool;
014: import org.enhydra.kelp.common.node.OtterProject;
015: import org.enhydra.kelp.common.swing.AddinInnerPanel;
016:
017: //AddInAnt
018: import org.enhydra.kelp.ant.node.AntProject;
019: import org.enhydra.kelp.ant.swing.HTMLViewer; //import org.enhydra.kelp.ant.xmlc.AntXMLCBuilder;
020:
021: //ToolBox
022: import org.enhydra.tool.common.InnerPanel;
023: import org.enhydra.tool.common.SwingUtil;
024: import org.enhydra.tool.common.ButtonPanel;
025: import org.enhydra.tool.common.event.FirstFocusEvent;
026: import org.enhydra.tool.common.event.FirstFocusListener;
027:
028: // Standard imports
029: import java.io.File;
030: import java.awt.Dialog;
031: import java.awt.Frame;
032: import java.awt.event.ActionListener;
033: import java.lang.ref.WeakReference;
034: import java.net.URL;
035: import java.util.ResourceBundle;
036:
037: /**
038: * <p>Title: </p>
039: * <p>Description: Deploy tool use AntProject for read,write properties and
040: * AntDeployBuilder for running Deployer. </p>
041: * <p>Copyright: Copyright (c) 2003</p>
042: * <p>Company: </p>
043: * @author Damir Milovic
044: * @version 1.0
045: */
046:
047: public class AntDeployTool extends AbstractTool implements
048: FirstFocusListener {
049:
050: static ResourceBundle addinRes = ResourceBundle
051: .getBundle("org.enhydra.kelp.common.Res");
052: private AntDeployInnerPanel innerPanel = null;
053: // private XMLCButtonPanel buttonPanel = null;
054: private AntDeployButtonPanel buttonPanel = null;
055: private WeakReference compileRef = null;
056:
057: public AntDeployTool() {
058: super ();
059: innerPanel = new AntDeployInnerPanel();
060: buttonPanel = new AntDeployButtonPanel();
061: innerPanel.addFirstFocusListener(this );
062: }
063:
064: public static void main(String[] args) {
065: SwingUtil.setLookAndFeelToSystem();
066: AntDeployTool tool = null;
067: AntProject project = null;
068: if (args.length > 0) {
069: // check path
070: File root = new File(args[0]);
071: if (!root.exists()) {
072: System.err.println("ERROR: directory'" + args[0]
073: + "' don't exist!");
074: return;
075: }
076: try {
077: project = new AntProject(args[0]);
078: } catch (Exception ex) {
079: ex.printStackTrace();
080: return;
081: }
082:
083: } else {
084: return;
085: //FIXME TODO get current directory
086: }
087:
088: tool = new AntDeployTool();
089: tool.setProject(project); //DACHA
090: tool.showDialog(new Frame());
091: return;
092: }
093:
094: /**
095: * Override
096: */
097: public void build() {
098: ((AntDeployInnerPanel) getInnerPanel()).selectOutputTab();
099: ((AntDeployInnerPanel) getInnerPanel()).save();
100: ((AntDeployInnerPanel) getInnerPanel()).clearOutput();
101: buildImpl();
102: }
103:
104: private void buildImpl() {
105: AntDeployBuilder builder = new AntDeployBuilder(
106: ((AntDeployInnerPanel) getInnerPanel())
107: .getWriteListeners());
108: builder.setProject(getProject());
109: builder.build();
110: }
111:
112: public static final String getDefaultTitle() {
113: return "Deployer";
114: }
115:
116: // implements AbstractTool
117: public String getTitle() {
118: return AntDeployTool.getDefaultTitle();
119: }
120:
121: // implements AbstractTool
122: public InnerPanel getInnerPanel() {
123: return innerPanel;
124: }
125:
126: // implements AbstractTool
127: public ButtonPanel getButtonPanel() {
128: return buttonPanel;
129: }
130:
131: public ActionListener createButtonListener() {
132: return (new AntDeployButtonListener(this ));
133: }
134:
135: // overrides AbstractTool
136: public void setProject(OtterProject project) {
137: super .setProject(project);
138: // setNodes(project.getAllDocuments());
139: }
140:
141: // overrides AbstractTool
142: public void clearAll() {
143: super .clearAll();
144: innerPanel.removeFirstFocusListener(this );
145: if (compileRef != null) {
146: compileRef.clear();
147: }
148: innerPanel = null;
149: buttonPanel = null;
150: compileRef = null;
151: }
152:
153: // implements FirstFocusListener
154: public void onFirstFocus(FirstFocusEvent event) {
155: /** @todo */
156: }
157:
158: public void showHelp(Dialog parent) {
159: URL helpURL = this .getClass().getClassLoader().getResource(
160: "using_ant_kelp.html");
161: HTMLViewer.createAndShow(parent, "Kelp Help", helpURL);
162:
163: }
164:
165: // implements org.enhydra.kelp.common.tool.AbstractTool
166: protected String getProgressTitle() {
167: return addinRes.getString("Deployment_Progress");
168: }
169:
170: // implements org.enhydra.kelp.common.tool.AbstractTool
171: protected AddinInnerPanel getPropertyPanel() {
172: return innerPanel;
173: }
174:
175: protected void back() {
176: innerPanel.back();
177: }
178:
179: protected void next() {
180: innerPanel.next();
181: }
182: }
|