1 2 24 package org.enhydra.tool.codegen; 25 26 28 import org.enhydra.tool.ToolBoxInfo; 29 30 32 import java.io.File ; 33 import java.util.StringTokenizer ; 34 import java.util.ResourceBundle ; 35 36 41 abstract public class ProjectOptionSet extends OptionSet implements Constants { 42 43 46 public static final String PROJECT = "project"; 48 51 public static final String ROOT = "root"; 53 56 public static final String PACKAGE = "package"; 58 61 public static final String COPYRIGHT = "copyright"; 63 66 public static final String COPYRIGHTFILE = "copyrightfile"; 68 71 public static final String NOCLI = "nocli"; 73 76 public static final String OVERWRITE = "overwrite"; 78 79 81 private final String DEF_PROJECT = "untitled1"; private final String DEF_PACKAGE = "untitled"; 84 89 public ProjectOptionSet() { 90 91 92 try { 93 add (new GeneratorOption (PROJECT, DEF_PROJECT, 94 res.getString ("PROJECT"), 95 res.getString ("PROJECT_Instruct"), 96 true, true)); 97 add (new GeneratorOption (PACKAGE, DEF_PACKAGE, 98 res.getString ("PACKAGE"), 99 res.getString ("PACKAGE_Instruct"), 100 true, true)); 101 add (new GeneratorOption (ROOT, getDefaultRoot (), 102 res.getString ("ROOT"), 103 res.getString ("ROOT_Instruct"), 104 true, true)); 105 add (new GeneratorOption (COPYRIGHT, new String (), 106 res.getString ("STRING"), 107 res.getString ("STRING instruct"), 108 false, true)); 109 add (new GeneratorOption (COPYRIGHTFILE, new String (), 110 res.getString ("FILE"), 111 res.getString ("FILE_instruct"), 112 false, true)); 113 add (new GeneratorOption (NOCLI, false, 114 res.getString ("Suppress_CLI"), 115 true)); 116 add (new GeneratorOption (OVERWRITE, false, 117 res.getString ("OK_to_overwrite"), 118 false)); 119 } catch (GeneratorException e) { 120 e.printStackTrace (); 121 } 122 } 123 124 130 private String getDefaultRoot () { 131 final String DIR_ENHYDRA_APPS = "myProjects"; StringBuffer buf = new StringBuffer (); 133 String userHome = new String (); 134 File file = null; 135 136 userHome = System.getProperties ().getProperty (SYS_USER_HOME); 137 138 buf.append (userHome); 139 buf.append (File.separator); 140 buf.append (DIR_ENHYDRA_APPS); 141 142 file = new File (buf.toString ()); 143 144 if (!file.exists ()) { 145 file.mkdirs (); 146 } 147 148 if (!file.isDirectory ()) { 149 buf.setLength (0); 150 buf.append (userHome); 151 } 152 153 return buf.toString (); 154 } 155 156 } 157 158 | Popular Tags |