1 19 20 package org.netbeans.modules.web.wizards; 21 22 import java.io.IOException ; 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.modules.web.api.webmodule.WebModule; 33 34 39 40 abstract class DeployData { 41 42 WebApp webApp = null; 43 String className = null; 44 boolean makeEntry = true; 45 FileObject ddObject = null; 46 47 final static boolean debug = false; 48 49 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 ioex) { 65 if(debug) { 66 log("Couldn't get the web app!"); 67 ioex.printStackTrace(); } 69 } 70 catch(Exception ex) { 71 if(debug) { 72 log("Couldn't get the web app!"); 73 ex.printStackTrace(); } 75 } 76 } 77 78 String getClassName() { 79 if(className == null) return ""; 80 return className; 81 } 82 83 void setClassName(String 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 { 96 97 if(debug) log("::writeChanges()"); if(webApp == null) return; 99 if(debug) log("now writing..."); webApp.write(ddObject); 101 } 102 103 abstract boolean isValid(); 104 abstract void createDDEntries(); 106 abstract String getErrorMessage(); 107 abstract void log(String 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 |