001: /* Copyright (C) 2003 Finalist IT Group
002: *
003: * This file is part of JAG - the Java J2EE Application Generator
004: *
005: * JAG is free software; you can redistribute it and/or modify
006: * it under the terms of the GNU General Public License as published by
007: * the Free Software Foundation; either version 2 of the License, or
008: * (at your option) any later version.
009: * JAG is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: * You should have received a copy of the GNU General Public License
014: * along with JAG; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
016: */
017:
018: package com.finalist.jaggenerator.modules;
019:
020: import com.finalist.jaggenerator.*;
021:
022: import javax.swing.*;
023: import javax.swing.tree.*;
024:
025: import org.w3c.dom.*;
026:
027: /**
028: *
029: * @author hillie
030: */
031: public class Paths extends DefaultMutableTreeNode implements JagBean {
032:
033: /**
034: * The following paths are predefined for non-velocity sources.
035: */
036: public final static String CONF_GENERAL_DIR = "/conf/conf-general";
037: public final static String CONF_STRUTS_DIR = "/conf/conf-struts";
038: public final static String CONF_SWING_DIR = "/conf/conf-swing";
039: public final static String CONF_TAPESTRY4_DIR = "/conf/conf-tapestry4";
040:
041: public final static String JAVA_SERVICE_DIR = "/src/java-service";
042:
043: public final static String JAVA_STRUTS_DIR = "/src/java-struts";
044: public final static String JAVA_TAPESTRY4_DIR = "/src/java-tapestry4";
045: public final static String JAVA_WEB_STRUTS_DIR = "/src/web-struts";
046: public final static String JAVA_WEB_TAPESTRY4_DIR = "/src/web-tapestry4";
047:
048: public final static String JAVA_EJB2_DIR = "/src/java-ejb2";
049: public final static String JAVA_EJB3_DIR = "/src/java-ejb3";
050: public final static String JAVA_HIBERNATE2_DIR = "/src/java-hibernate2";
051: public final static String JAVA_HIBERNATE3_DIR = "/src/java-hibernate3";
052:
053: public final static String JAVA_TEST_DIR = "/src/test";
054: public final static String JAVA_MOCK_DIR = "/src/java-mock";
055: public final static String JAVA_SWING_DIR = "/src/java-swing";
056:
057: /** Creates new form BeanForm */
058: public Paths() {
059: initComponents();
060: }
061:
062: public Paths(Element el) {
063: initComponents();
064: NodeList nl = el.getElementsByTagName("module-data");
065: for (int i = 0; i < nl.getLength(); i++) {
066: Element child = (Element) nl.item(i);
067: String attName = child.getAttribute("name");
068: String value = null;
069: if (child.getFirstChild() == null)
070: value = null;
071: else
072: value = child.getFirstChild().getNodeValue();
073: if (value != null) {
074: if (attName.equalsIgnoreCase("service_output")) {
075: serviceOutText.setText(value);
076: continue;
077: }
078: if (attName.equalsIgnoreCase("hibernate_output")) {
079: hibernateOutText.setText(value);
080: continue;
081: }
082: if (attName.equalsIgnoreCase("ejb_output")) {
083: ejbOutText.setText(value);
084: continue;
085: }
086: if (attName.equalsIgnoreCase("web_output")) {
087: webOutText.setText(value);
088: continue;
089: }
090: if (attName.equalsIgnoreCase("jsp_output")) {
091: jspOutText.setText(value);
092: continue;
093: }
094: if (attName.equalsIgnoreCase("config_output")) {
095: configText.setText(value);
096: continue;
097: }
098: if (attName.equalsIgnoreCase("test_output")) {
099: testOutText.setText(value);
100: continue;
101: }
102: if (attName.equalsIgnoreCase("mock_output")) {
103: mockOutText.setText(value);
104: continue;
105: }
106: if (attName.equalsIgnoreCase("swing_output")) {
107: swingOutText.setText(value);
108: continue;
109: }
110: }
111: }
112: }
113:
114: public String toString() {
115: return "Paths";
116: }
117:
118: public JPanel getPanel() {
119: return panel;
120: }
121:
122: public void getXML(Element el) {
123: Document doc = el.getOwnerDocument();
124: Element module = doc.createElement("module");
125: module.setAttribute("name", "paths");
126:
127: Element serviceOut = doc.createElement("module-data");
128: serviceOut.setAttribute("name", "service_output");
129: if (serviceOutText.getText() != null) {
130: serviceOut.appendChild(doc.createTextNode(serviceOutText
131: .getText()));
132: }
133: module.appendChild(serviceOut);
134:
135: Element hibernateOut = doc.createElement("module-data");
136: hibernateOut.setAttribute("name", "hibernate_output");
137: if (hibernateOutText.getText() != null) {
138: hibernateOut.appendChild(doc
139: .createTextNode(hibernateOutText.getText()));
140: }
141: module.appendChild(hibernateOut);
142:
143: Element ejbOut = doc.createElement("module-data");
144: ejbOut.setAttribute("name", "ejb_output");
145: if (ejbOutText.getText() != null) {
146: ejbOut
147: .appendChild(doc.createTextNode(ejbOutText
148: .getText()));
149: }
150: module.appendChild(ejbOut);
151:
152: Element webOut = doc.createElement("module-data");
153: webOut.setAttribute("name", "web_output");
154: if (webOutText.getText() != null) {
155: webOut
156: .appendChild(doc.createTextNode(webOutText
157: .getText()));
158: }
159: module.appendChild(webOut);
160:
161: Element testOut = doc.createElement("module-data");
162: testOut.setAttribute("name", "test_output");
163: if (testOutText.getText() != null) {
164: testOut.appendChild(doc.createTextNode(testOutText
165: .getText()));
166: }
167: module.appendChild(testOut);
168:
169: Element jspOut = doc.createElement("module-data");
170: jspOut.setAttribute("name", "jsp_output");
171: if (jspOutText.getText() != null) {
172: jspOut
173: .appendChild(doc.createTextNode(jspOutText
174: .getText()));
175: }
176: module.appendChild(jspOut);
177:
178: Element configXml = doc.createElement("module-data");
179: configXml.setAttribute("name", "config_output");
180: if (configText.getText() != null) {
181: configXml.appendChild(doc.createTextNode(configText
182: .getText()));
183: }
184: module.appendChild(configXml);
185:
186: Element mockXml = doc.createElement("module-data");
187: mockXml.setAttribute("name", "mock_output");
188: if (mockOutText.getText() != null) {
189: mockXml.appendChild(doc.createTextNode(mockOutText
190: .getText()));
191: }
192: module.appendChild(mockXml);
193:
194: Element swingXml = doc.createElement("module-data");
195: swingXml.setAttribute("name", "swing_output");
196: if (swingOutText.getText() != null) {
197: swingXml.appendChild(doc.createTextNode(swingOutText
198: .getText()));
199: }
200: module.appendChild(swingXml);
201: el.appendChild(module);
202: }
203:
204: public String getSwingOutput() {
205: return swingOutText.getText();
206: }
207:
208: public String getMockOutput() {
209: return mockOutText.getText();
210: }
211:
212: public String getServiceOutput() {
213: return serviceOutText.getText();
214: }
215:
216: public String getHibernateOutput() {
217: return hibernateOutText.getText();
218: }
219:
220: public String getConfigOutput() {
221: return configText.getText();
222: }
223:
224: public String getJspOutput() {
225: return jspOutText.getText();
226: }
227:
228: public String getTestOutput() {
229: return testOutText.getText();
230: }
231:
232: public String getWebOutput() {
233: return webOutText.getText();
234: }
235:
236: public String getEjbOutput() {
237: return ejbOutText.getText();
238: }
239:
240: public void setSwingOutput(String text) {
241: swingOutText.setText(text);
242: }
243:
244: public void setMockOutput(String text) {
245: mockOutText.setText(text);
246: }
247:
248: public void setServiceOutput(String text) {
249: serviceOutText.setText(text);
250: }
251:
252: public void setHibernateOutput(String text) {
253: hibernateOutText.setText(text);
254: }
255:
256: public void setConfigOutput(String text) {
257: configText.setText(text);
258: }
259:
260: public void setJspOutput(String text) {
261: jspOutText.setText(text);
262: }
263:
264: public void setTestOutput(String text) {
265: testOutText.setText(text);
266: }
267:
268: public void setWebOutput(String text) {
269: webOutText.setText(text);
270: }
271:
272: public void setEjbOutput(String text) {
273: ejbOutText.setText(text);
274: }
275:
276: public String getRefName() {
277: return "paths";
278: }
279:
280: /** This method is called from within the constructor to
281: * initialize the form.
282: * WARNING: Do NOT modify this code. The content of this method is
283: * always regenerated by the Form Editor.
284: */
285: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
286: private void initComponents() {
287: panel = new javax.swing.JPanel();
288: ejbOutLabel = new javax.swing.JLabel();
289: webOutLabel = new javax.swing.JLabel();
290: jspOutLabel = new javax.swing.JLabel();
291: testNameLabel = new javax.swing.JLabel();
292: configOutLabel = new javax.swing.JLabel();
293: ejbOutText = new javax.swing.JTextField();
294: webOutText = new javax.swing.JTextField();
295: jspOutText = new javax.swing.JTextField();
296: testOutText = new javax.swing.JTextField();
297: configText = new javax.swing.JTextField();
298: serviceOutLabel = new javax.swing.JLabel();
299: serviceOutText = new javax.swing.JTextField();
300: hibernateOutLabel = new javax.swing.JLabel();
301: hibernateOutText = new javax.swing.JTextField();
302: mockOutLabel = new javax.swing.JLabel();
303: mockOutText = new javax.swing.JTextField();
304: swingOutLabel = new javax.swing.JLabel();
305: swingOutText = new javax.swing.JTextField();
306:
307: panel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
308:
309: ejbOutLabel
310: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
311: ejbOutLabel.setText("EJB dir:");
312: panel.add(ejbOutLabel,
313: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
314: 20, 100, -1));
315:
316: webOutLabel
317: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
318: webOutLabel.setText("Web dir:");
319: panel.add(webOutLabel,
320: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
321: 110, 100, -1));
322:
323: jspOutLabel
324: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
325: jspOutLabel.setText("JSP dir:");
326: panel.add(jspOutLabel,
327: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
328: 140, 100, -1));
329:
330: testNameLabel
331: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
332: testNameLabel.setText("Test dir:");
333: panel.add(testNameLabel,
334: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
335: 170, 100, -1));
336:
337: configOutLabel
338: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
339: configOutLabel.setText("Config dir:");
340: panel.add(configOutLabel,
341: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
342: 200, 100, -1));
343:
344: ejbOutText.setText("./src/java-ejb/");
345: ejbOutText.setToolTipText("Target directory for ejb sources");
346: ejbOutText.addFocusListener(new java.awt.event.FocusAdapter() {
347: public void focusLost(java.awt.event.FocusEvent evt) {
348: ejbOutTextFocusLost(evt);
349: }
350: });
351:
352: panel.add(ejbOutText,
353: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
354: 20, 260, -1));
355:
356: webOutText.setText("./src/java-web/");
357: webOutText
358: .setToolTipText("Target directory for web based source");
359: webOutText.addFocusListener(new java.awt.event.FocusAdapter() {
360: public void focusLost(java.awt.event.FocusEvent evt) {
361: webOutTextFocusLost(evt);
362: }
363: });
364:
365: panel.add(webOutText,
366: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
367: 110, 260, -1));
368:
369: jspOutText.setText("./src/web/");
370: jspOutText
371: .setToolTipText("Target directory for JSPs, HTML, images etc.");
372: jspOutText.addFocusListener(new java.awt.event.FocusAdapter() {
373: public void focusLost(java.awt.event.FocusEvent evt) {
374: jspOutTextFocusLost(evt);
375: }
376: });
377:
378: panel.add(jspOutText,
379: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
380: 140, 260, -1));
381:
382: testOutText.setText("./src/java-test/");
383: testOutText.setToolTipText("Target directory for JUnit tests");
384: testOutText.addFocusListener(new java.awt.event.FocusAdapter() {
385: public void focusLost(java.awt.event.FocusEvent evt) {
386: testOutTextFocusLost(evt);
387: }
388: });
389:
390: panel.add(testOutText,
391: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
392: 170, 260, -1));
393:
394: configText.setText("./conf/");
395: configText
396: .setToolTipText("Target directory for configuration files");
397: configText.addFocusListener(new java.awt.event.FocusAdapter() {
398: public void focusLost(java.awt.event.FocusEvent evt) {
399: configTextFocusLost(evt);
400: }
401: });
402:
403: panel.add(configText,
404: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
405: 200, 260, -1));
406:
407: serviceOutLabel
408: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
409: serviceOutLabel.setText("Service dir:");
410: panel.add(serviceOutLabel,
411: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
412: 80, 100, -1));
413:
414: serviceOutText.setText("./src/java-service/");
415: serviceOutText
416: .setToolTipText("Target directory for service interfaces and related sources");
417: serviceOutText
418: .addActionListener(new java.awt.event.ActionListener() {
419: public void actionPerformed(
420: java.awt.event.ActionEvent evt) {
421: serviceOutTextActionPerformed(evt);
422: }
423: });
424:
425: panel.add(serviceOutText,
426: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
427: 80, 260, -1));
428:
429: hibernateOutLabel
430: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
431: hibernateOutLabel.setText("Hibernate dir:");
432: panel.add(hibernateOutLabel,
433: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
434: 50, 100, -1));
435:
436: hibernateOutText.setText("./src/java-hibernate/");
437: hibernateOutText
438: .setToolTipText("Target directory for hibernate sources");
439: hibernateOutText
440: .addActionListener(new java.awt.event.ActionListener() {
441: public void actionPerformed(
442: java.awt.event.ActionEvent evt) {
443: hibernateOutTextActionPerformed(evt);
444: }
445: });
446:
447: panel.add(hibernateOutText,
448: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
449: 50, 260, -1));
450:
451: /*
452: mockOutLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
453: mockOutLabel.setText("Mock dir:");
454: panel.add(mockOutLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 260, 100, -1));
455:
456: mockOutText.setText("./src/java-mock/");
457: mockOutText.setToolTipText("Target directory for mock implementation sources");
458: panel.add(mockOutText, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 260, 260, -1));
459: */
460:
461: swingOutLabel
462: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
463: swingOutLabel.setText("Swing dir:");
464: panel.add(swingOutLabel,
465: new org.netbeans.lib.awtextra.AbsoluteConstraints(10,
466: 230, 100, -1));
467:
468: swingOutText.setText("./src/java-swing/");
469: swingOutText
470: .setToolTipText("Target directory for java swing client sources");
471: panel.add(swingOutText,
472: new org.netbeans.lib.awtextra.AbsoluteConstraints(120,
473: 230, 260, -1));
474:
475: }
476:
477: // </editor-fold>//GEN-END:initComponents
478:
479: private void hibernateOutTextActionPerformed(
480: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hibernateOutTextActionPerformed
481: // TODO add your handling code here:
482: }//GEN-LAST:event_hibernateOutTextActionPerformed
483:
484: private void serviceOutTextActionPerformed(
485: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serviceOutTextActionPerformed
486: // TODO add your handling code here:
487: }//GEN-LAST:event_serviceOutTextActionPerformed
488:
489: private void configTextFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_configTextFocusLost
490: JagGenerator.stateChanged(false);
491: }//GEN-LAST:event_configTextFocusLost
492:
493: private void testOutTextFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_testOutTextFocusLost
494: JagGenerator.stateChanged(false);
495: }//GEN-LAST:event_testOutTextFocusLost
496:
497: private void jspOutTextFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jspOutTextFocusLost
498: JagGenerator.stateChanged(false);
499: }//GEN-LAST:event_jspOutTextFocusLost
500:
501: private void webOutTextFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_webOutTextFocusLost
502: JagGenerator.stateChanged(false);
503: }//GEN-LAST:event_webOutTextFocusLost
504:
505: private void ejbOutTextFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ejbOutTextFocusLost
506: JagGenerator.stateChanged(false);
507: }//GEN-LAST:event_ejbOutTextFocusLost
508:
509: // Variables declaration - do not modify//GEN-BEGIN:variables
510: private javax.swing.JLabel configOutLabel;
511: private javax.swing.JTextField configText;
512: private javax.swing.JLabel ejbOutLabel;
513: private javax.swing.JTextField ejbOutText;
514: private javax.swing.JLabel hibernateOutLabel;
515: public javax.swing.JTextField hibernateOutText;
516: private javax.swing.JLabel jspOutLabel;
517: private javax.swing.JTextField jspOutText;
518: private javax.swing.JLabel mockOutLabel;
519: public javax.swing.JTextField mockOutText;
520: private javax.swing.JPanel panel;
521: private javax.swing.JLabel serviceOutLabel;
522: private javax.swing.JTextField serviceOutText;
523: private javax.swing.JLabel swingOutLabel;
524: private javax.swing.JTextField swingOutText;
525: private javax.swing.JLabel testNameLabel;
526: private javax.swing.JTextField testOutText;
527: private javax.swing.JLabel webOutLabel;
528: private javax.swing.JTextField webOutText;
529: // End of variables declaration//GEN-END:variables
530: }
|