1 2 24 package org.enhydra.tool.codegen.internal; 25 26 import org.enhydra.tool.codegen.GeneratorException; 28 import org.enhydra.tool.common.PathHandle; 29 import org.enhydra.tool.common.Replacement; 30 import org.enhydra.tool.common.ToolException; 31 32 import java.io.File ; 34 import java.util.ArrayList ; 35 import java.util.Arrays ; 36 import java.util.ResourceBundle ; 37 38 41 public class WebAppGenerator extends AppGenerator { 42 43 46 public static final String COMMAND_NAME = "webapp"; 48 51 public static final String displayName = res.getString("Web_Application"); 52 public static final String wizardTitle = 53 res.getString("Web_Application1"); 54 55 58 public WebAppGenerator() { 59 super(); 60 } 61 62 65 public String [] getOutputExcludes() { 66 String [] ex = new String [0]; 67 ArrayList list = null; 68 69 list = new ArrayList (Arrays.asList(super.getOutputExcludes())); 70 71 if (getClient().equalsIgnoreCase("chtml") || getClient().equalsIgnoreCase("wml")) { list.add("index.jsp"); list.add("RedirectServlet.java"); list.add("options.xmlc"); list.add("media" + File.separator + "makefile"); list.add(".gif"); } 80 list.trimToSize(); 81 ex = new String [list.size()]; 82 ex = (String []) list.toArray(ex); 83 list.clear(); 84 return ex; 85 } 86 87 90 public Replacement[] createReplacementsForDirectory(PathHandle path) 91 throws GeneratorException { 92 Replacement[] reps = new Replacement[0]; 93 94 reps = super.createReplacementsForDirectory(path); 95 if (path.endsWith("/presentation")) { ArrayList list = null; 97 String [] targets = new String [1]; 98 String [] rules = new String [1]; 99 Replacement targetRep = null; 100 Replacement ruleRep = null; 101 102 targets[0] = new String (); 103 rules[0] = new String (); 104 list = new ArrayList (Arrays.asList(reps)); 105 if (getClient().equalsIgnoreCase("chtml")) { 107 } else if (getClient().equalsIgnoreCase("wml")) { targets = new String [2]; 110 rules = new String [1]; 111 targets[0] = new String (); 112 targets[1] = "XMLC_" + getClient().toUpperCase() + "_OPTS_FILE = options.xmlc"; rules[0] = new String (); 115 } else { 116 117 targets = new String [5]; 119 rules = new String [4]; 120 targets[0] = "RedirectServlet"; targets[1] = new String (); 122 targets[2] = "SUBDIRS = media"; targets[3] = "XMLC_" + getClient().toUpperCase() + "_OPTS_FILE = options.xmlc"; targets[4] = "MISC_BUILD = content"; rules[0] = new String (); 127 rules[1] = "content::"; rules[2] = "\t" + "cp ../resources/index.jsp ${ROOT}/output/content/index.jsp"; rules[3] = new String (); 131 } 132 try { 133 targetRep = new Replacement("@PRESENTATION_TARGETS@", targets); 135 ruleRep = new Replacement("@PRESENTATION_RULES@", 136 rules); list.add(targetRep); 138 list.add(ruleRep); 139 } catch (ToolException e) { 140 throw new GeneratorException(e, 141 res.getString("Unable_to_create1")); 142 } 143 reps = new Replacement[list.size()]; 144 reps = (Replacement[]) list.toArray(reps); 145 list.clear(); 146 } 147 return reps; 148 } 149 150 157 public String getCommandName() { 158 return COMMAND_NAME; 159 } 160 161 167 public String getDisplayName() { 168 return WebAppGenerator.displayName; 169 } 170 171 public String getWizardTitle() { 172 return WebAppGenerator.wizardTitle; 173 } 174 175 183 public String getDescription() { 184 return res.getString("WebDescript"); 185 } 186 187 } 188 | Popular Tags |