1 2 24 package org.enhydra.tool.codegen.internal; 25 26 import org.enhydra.tool.ToolBoxInfo; 28 import org.enhydra.tool.codegen.Constants; 29 import org.enhydra.tool.codegen.ProjectReplacementSet; 30 import org.enhydra.tool.codegen.GeneratorException; 31 import org.enhydra.tool.common.PathHandle; 32 import org.enhydra.tool.common.Replacement; 33 import org.enhydra.tool.common.ReplacementSet; 34 import org.enhydra.tool.common.ToolException; 35 36 import java.io.File ; 38 import java.util.ArrayList ; 39 import java.util.Arrays ; 40 import java.util.ResourceBundle ; 41 42 47 public class Enhydra3AppGenerator extends AppGenerator { 48 49 52 public static final String COMMAND_NAME = "en3app"; 54 57 public static final String displayName = "Enhydra Application"; 58 public static final String wizardTitle = "Enhydra Application Wizard"; 59 60 63 public Enhydra3AppGenerator() {} 64 65 68 public String [] getOutputExcludes() { 69 String [] ex = new String [0]; 70 ArrayList list = null; 71 72 list = new ArrayList (Arrays.asList(super.getOutputExcludes())); 73 74 if (getClient().equalsIgnoreCase("chtml") || getClient().equalsIgnoreCase("wml")) { list.add("RedirectPresentation.java"); list.add("options.xmlc"); list.add("media" + File.separator + "makefile"); list.add(".gif"); } 82 list.trimToSize(); 83 ex = new String [list.size()]; 84 ex = (String []) list.toArray(ex); 85 list.clear(); 86 return ex; 87 } 88 89 92 public Replacement[] createReplacementsForDirectory(PathHandle path) 93 throws GeneratorException { 94 Replacement[] reps = new Replacement[0]; 95 ArrayList list = null; 96 97 reps = super.createReplacementsForDirectory(path); 98 try { 99 if (path.endsWith("/conf")) { Replacement rep = null; 101 ReplacementSet set = null; 102 String url = new String (); 103 104 list = new ArrayList (Arrays.asList(reps)); 105 set = new ReplacementSet(reps); 106 rep = set.lookup(AppReplacementSet.JAVA_PACKAGE); 107 url = rep.getReplaceWith()[0].replace('.', '/'); 108 rep = new Replacement("@JAVA_PACKAGE_URL@", url); list.add(rep); 110 reps = new Replacement[list.size()]; 111 reps = (Replacement[]) list.toArray(reps); 112 list.clear(); 113 } else if (path.endsWith("/presentation")) { String [] targets = new String [1]; 115 String [] rules = new String [1]; 116 Replacement targetRep = null; 117 Replacement ruleRep = null; 118 119 targets[0] = new String (); 120 rules[0] = new String (); 121 list = new ArrayList (Arrays.asList(reps)); 122 123 if (getClient().equalsIgnoreCase("chtml")) { 126 } else if (getClient().equalsIgnoreCase("wml")) { targets = new String [2]; 129 rules = new String [1]; 130 targets[0] = new String (); 131 targets[1] = "XMLC_" + getClient().toUpperCase() + "_OPTS_FILE = options.xmlc"; rules[0] = new String (); 134 } else { 135 136 targets = new String [4]; 138 rules = new String [1]; 139 targets[0] = "RedirectPresentation"; targets[1] = new String (); 141 targets[2] = "SUBDIRS = media"; targets[3] = "XMLC_" + getClient().toUpperCase() + "_OPTS_FILE = options.xmlc"; rules[0] = new String (); 145 } 146 targetRep = new Replacement("@PRESENTATION_TARGETS@", targets); 148 ruleRep = new Replacement("@PRESENTATION_RULES@", 149 rules); list.add(targetRep); 151 list.add(ruleRep); 152 reps = new Replacement[list.size()]; 153 reps = (Replacement[]) list.toArray(reps); 154 list.clear(); 155 } 156 } catch (ToolException e) { 157 throw new GeneratorException(e, 158 res.getString("Unable_to_create")); 159 } 160 return reps; 161 } 162 163 170 public String getCommandName() { 171 return COMMAND_NAME; 172 } 173 174 180 public String getDisplayName() { 181 return Enhydra3AppGenerator.displayName; 182 } 183 184 public String getWizardTitle() { 185 return Enhydra3AppGenerator.wizardTitle; 186 } 187 188 196 public String getDescription() { 197 return res.getString("En3Descript"); 198 } 199 200 } 201 | Popular Tags |