1 15 16 30 package ixenon.free.nodes; 31 32 import java.io.*; 33 import java.util.*; 34 import java.awt.*; 35 import java.awt.event.*; 36 37 import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; 41 import ixenon.free.install.*; import ixenon.free.swing.*; 44 48 public class CreateDefaultPropertyFile extends AbstractInstallable 49 implements Installable 50 { 51 public final static int SLEEP_TIME=125; 53 54 protected File targetDirectory; 55 56 protected String propFilename; 57 58 protected String prefixDir; 59 60 protected String execPrefixDir; 61 62 protected String imagesDir; 63 64 protected String audioDir; 65 66 protected String url; 67 68 79 public CreateDefaultPropertyFile ( String nodeName, 80 String propFilename, 81 String prefixDir, 82 String execPrefixDir, 83 String imagesDir, 84 String audioDir, 85 String url ) 86 { 87 super( nodeName, null, true ); 88 if ( propFilename == null || prefixDir == null) 89 throw new IllegalArgumentException ( 90 "illegal number arguments supplied." ); 91 92 this.propFilename = propFilename; 93 this.prefixDir = prefixDir; 94 this.execPrefixDir = execPrefixDir != null ? execPrefixDir : prefixDir; 95 this.imagesDir = imagesDir != null ? imagesDir : ""; 96 this.audioDir = audioDir != null? audioDir : ""; 97 this.url = url != null ? url : ""; 98 } 99 100 104 public Component getVisualComponent() 105 { 106 return (null); 107 } 108 109 113 public Component getConfigurableComponent() 114 { 115 return (null); 116 } 117 118 125 public void install() throws InstallException 126 { 127 FreeInstallerApplication theApp = 128 FreeInstallerApplication.getInstance(); 129 130 targetDirectory = new File( new File(propFilename).getParent() ); 131 if ( !targetDirectory.exists() ) 132 targetDirectory.mkdirs(); 133 134 if ( !targetDirectory.isDirectory() ) 135 throw new InstallException( 136 "no such target directory:`"+targetDirectory.getAbsolutePath()+"'" ); 137 138 theApp.getProgressFrame().setStatusText( getNodeName() ); 140 141 JProgressBar pbar = theApp.getProgressFrame().getProgressBarNode(); 142 int index = 0; 143 SwingUtilities.invokeLater( new ResetProgressBar( pbar, 0, 1, 0 ) ); 144 145 try { Thread.sleep(SLEEP_TIME); } catch (InterruptedException ie) { ; } 147 148 File dstFile = new File( propFilename ); 149 150 if (dstFile.exists() ) 152 dstFile.delete(); 153 154 PrintWriter pwriter=null; 155 FileWriter fwriter=null; 156 157 String fileSep = System.getProperty("file.separator"); 158 String pathSep = System.getProperty("path.separator"); 159 160 theApp.printInfo( "Creating default property file: `" + dstFile.getPath()+"'" ); 161 uninstallable.addFile( dstFile ); 163 164 try { 165 fwriter = new FileWriter( dstFile ); 166 pwriter = new PrintWriter( fwriter ); 167 168 pwriter.println( "# Filename:`"+dstFile.getPath()+"'" ); 169 pwriter.println( "#\n# DESCRIPTION:\n#\tA default application Java property file for:" ); 170 pwriter.println( "#\t"); 171 pwriter.println( "#\t " +theApp.getProductName() + " by " + theApp.getCompanyName() +" [c]" ); 172 pwriter.println( "#\t"); 173 pwriter.println( "#\tAutomagically generated by FreeInstaller V"+ApplicationVersion.getVersionString() ); 174 pwriter.println( "#"); 175 pwriter.println( "# WARNING: On Windows and OS/2 pathnames must be backslashified to protect"); 176 pwriter.println( "# the file separator character (\\)."); 177 pwriter.println( "#"); 178 pwriter.println(); 179 pwriter.println( "env.PREFIX="+InstallUtilities.getBackslashifiedPath(prefixDir) ); 180 pwriter.println( "env.EXEC_PREFIX="+InstallUtilities.getBackslashifiedPath(execPrefixDir) ); 181 pwriter.println( "env.AUDIO_DIR="+InstallUtilities.getBackslashifiedPath(audioDir) ); 182 pwriter.println( "env.IMAGES_DIR="+InstallUtilities.getBackslashifiedPath(imagesDir) ); 183 pwriter.println( "env.WEB_ROOT_URL="+InstallUtilities.getBackslashifiedPath(url) ); 184 pwriter.println( "# UNCOMMENT the next line to get debug on application resources"); 185 pwriter.println( "## env.DEBUG_RESOURCES=doit "); 186 pwriter.println(); 187 188 pwriter.println( "# Modify the next line to alter the java file Search Path" ); 189 pwriter.println( "# For example on a UNIX type operating system:" ); 190 pwriter.println( "## env.JAVAFILESEARCHPATH=%N%S ; %T/%N%S ; %H/%T/%N%S ; %H/%N%S ; %P/%T/%N%S ; /usr/local/%T/%N%S ; /usr/local/%N%S ; %Z/%T/%N" ); 191 pwriter.println(); 192 193 String javaFileSearchPath = 203 "%T/%L/%N%S;" + "%T/%N%S;" + "%N%S;" + 204 "%H/%T/%L/%N%S;" + "%H/%T/%N%S;" + "%H/%N%S;" + 205 "%P/%L/%T/%N%S;" + "%P/%T/%N%S;" + "%P/%N%S;" + 206 prefixDir+"/%L/%T/%N%S;" + 207 prefixDir+"/%T/%N%S;" + 208 prefixDir+"/%N%S" ; 209 210 pwriter.println( "env.JAVAFILESEARCHPATH="+InstallUtilities.getBackslashifiedPath(javaFileSearchPath) ); 211 212 pwriter.println(); 213 pwriter.println( "# END"); 214 pwriter.flush(); 215 InstallUtilities.setFilePermissions( dstFile, InstallConstants.INST_RDWR_PERMS ); 216 } 217 catch (IOException ioe) { 218 throw new InstallException( 219 "I/O exception occurred writing file:"+ targetDirectory.getPath()+ 220 "\ndetails:"+ioe.getMessage() ); 221 } 222 finally { 223 if (fwriter != null) try { fwriter.close(); } catch (Exception e) { ; } 224 if (pwriter != null) try { pwriter.close(); } catch (Exception e) { ; } 225 } 226 227 SwingUtilities.invokeLater( new UpdateProgressBar( pbar, ++index ) ); 228 } 229 230 231 protected void createUnixShellScript() throws InstallException 232 { 233 } 234 235 238 public void cleanup() throws InstallException 239 { 240 } 242 243 } 244 245 | Popular Tags |