KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > wizards > DeployData


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.n
18  */

19
20 package org.netbeans.modules.web.wizards;
21
22 import java.io.IOException JavaDoc;
23
24 import org.openide.filesystems.FileObject;
25
26 import org.netbeans.modules.j2ee.dd.api.web.DDProvider;
27 import org.netbeans.modules.j2ee.dd.api.web.WebApp;
28
29 //import org.netbeans.api.java.classpath.ClassPath;
30
//import org.netbeans.api.project.Project;
31
//import org.netbeans.api.project.FileOwnerQuery;
32
import org.netbeans.modules.web.api.webmodule.WebModule;
33
34 /**
35 * Generic methods for evaluating the input into the wizards.
36 *
37 * @author Ana von Klopp
38 */

39
40 abstract class DeployData {
41
42     WebApp webApp = null;
43     String JavaDoc className = null;
44     boolean makeEntry = true;
45     FileObject ddObject = null;
46
47     final static boolean debug = false;
48
49     // This is the web app file object
50
void setWebApp(FileObject fo) {
51     if(debug) log("::setWebApp()");
52     if(fo == null) {
53         ddObject = null;
54         webApp = null;
55         return;
56     }
57
58     ddObject = fo;
59
60     try {
61         webApp = DDProvider.getDefault().getDDRoot(fo);
62         if(debug) log(webApp.toString());
63     }
64     catch(IOException JavaDoc ioex) {
65         if(debug) {
66         log("Couldn't get the web app!");
67         ioex.printStackTrace(); // XXX this is not an exception handling
68
}
69     }
70     catch(Exception JavaDoc ex) {
71         if(debug) {
72         log("Couldn't get the web app!");
73         ex.printStackTrace(); // XXX this is not an exception handling
74
}
75     }
76     }
77
78     String JavaDoc getClassName() {
79     if(className == null) return "";
80     return className;
81     }
82
83     void setClassName(String JavaDoc name) {
84     this.className = name;
85     }
86
87     boolean makeEntry() {
88     return makeEntry;
89     }
90
91     void setMakeEntry(boolean makeEntry) {
92     this.makeEntry = makeEntry;
93     }
94
95     void writeChanges() throws IOException JavaDoc {
96
97     if(debug) log("::writeChanges()"); //NOI18N
98
if(webApp == null) return;
99     if(debug) log("now writing..."); //NOI18N
100
webApp.write(ddObject);
101     }
102
103     abstract boolean isValid();
104     // This must invoke write changes at the end
105
abstract void createDDEntries();
106     abstract String JavaDoc getErrorMessage();
107     abstract void log(String JavaDoc s);
108     abstract void setAddToDD(boolean addToDD);
109     abstract boolean isAddToDD();
110     
111     public static FileObject getWebAppFor(FileObject folder) {
112         if (folder==null) return null;
113         WebModule webModule = WebModule.getWebModule(folder);
114         if (webModule==null) return null;
115         return webModule.getDeploymentDescriptor ();
116     }
117     
118     public boolean hasDD() {
119         return webApp!=null;
120     }
121 }
122
123
Popular Tags