1 15 16 18 36 package ixenon.free.install; 37 38 import java.awt.*; 39 import java.awt.event.*; 40 import java.beans.*; 41 import java.util.*; 42 import java.io.*; 43 44 import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; 48 import sun.audio.*; 50 import ixenon.free.util.*; 51 52 53 57 public class FreeInstallerApplication 58 implements PropertyChangeListener { 59 60 61 public final static String APPLICATION_NAME="FreeInstaller"; 62 63 64 public final static String COMPANY_NAME="Xenonsoft"; 65 66 67 public final static String CREDITS = 68 "Designed and implemented by Peter Pilgrim.\n"+ 69 "XeNoNSoFT Limited, South London, England [c] January 1999.\n"+ 70 "FreeInstaller is distributed as free software under a license\n"+ 71 "compatible with the open source model.\n"; 72 73 74 protected static SingleAudioPlayer audioPlayer = new SingleAudioPlayer(); 75 76 protected ResourceBundle globalBundle; 77 78 79 protected InstallerFrame mainFrame; 80 81 82 protected ProgressFrame progressFrame; 83 84 85 private Class packageInstallerClass; 86 87 private PackageInstallable packageInstaller; 89 90 private LogFile logFile; 92 93 98 private static FreeInstallerApplication singleton=null; 99 100 101 102 108 private FreeInstallerApplication( String packageInstallerName, String [] args ) 109 { 110 System.out.println( "**** "+APPLICATION_NAME+" V" + ApplicationVersion.getVersionString() + " ****"); 112 System.out.println( CREDITS ); 113 System.out.println( "Please read the license file. `LICENSE-XPeL.txt'\n" ); 114 115 globalBundle = ResourceBundle.getBundle( "InstallerBundle" ); 119 ApplicationResources appres = 120 ApplicationResources.createInstance( globalBundle, "FreeInstaller" ); 121 122 ApplicationResources.getDefaultApplicationSearchPath(); 124 String filename = "freeinst.log"; 128 try { 129 System.out.println("Creating a log file:`"+filename+"'"); 130 System.out.println("os.version = "+System.getProperty("os.version")); 131 System.out.println("os.arch = "+System.getProperty("os.arch")); 132 System.out.println("os.name = "+System.getProperty("os.name")); 133 System.out.println("user.name = "+System.getProperty("user.name")); 134 System.out.println("user.home = "+System.getProperty("user.home")); 135 System.out.println("java.home = "+System.getProperty("java.home")); 136 System.out.println("java.version = "+System.getProperty("java.version")); 137 logFile = new LogFile( filename ); 138 logFile.dtprintln(); 139 logFile.println( "**** "+APPLICATION_NAME+" V" + ApplicationVersion.getVersionString() + " ****"); 140 logFile.println( CREDITS ); 141 logFile.println( "Please read the license file, \"Available as free software\".\n" ); 142 logFile.println("os.version = "+System.getProperty("os.version")); 143 logFile.println("os.arch = "+System.getProperty("os.arch")); 144 logFile.println("os.name = "+System.getProperty("os.name")); 145 logFile.println("user.name = "+System.getProperty("user.name")); 146 logFile.println("user.home = "+System.getProperty("user.home")); 147 logFile.println("java.home = "+System.getProperty("java.home")); 148 logFile.println("java.version = "+System.getProperty("java.version")); 149 } 150 catch (IOException ioe) { 151 System.err.println("failured to create log filename:"+filename); 152 System.err.println("I/O Exception:"+ioe.getMessage() ); 153 System.exit(3); 154 } 155 156 try { 162 packageInstallerClass = Class.forName(packageInstallerName); 163 } 164 catch ( ClassNotFoundException ce ) { 165 writeErrorLog( APPLICATION_NAME+" cannot load class:`"+packageInstallerName+"'" ); 166 System.exit(1); 167 } 168 169 try { 170 packageInstaller = (PackageInstallable)packageInstallerClass.newInstance(); 172 } 173 catch (InstantiationException ie ) { 174 writeErrorLog( APPLICATION_NAME+" cannot instantiate the class:`"+packageInstallerName+"'" ); 175 System.exit(1); 176 177 } 178 catch (IllegalAccessException iae ) { 179 writeErrorLog( APPLICATION_NAME+" illegal access during instantiation of class:`"+packageInstallerName+"'" ); 180 System.exit(1); 181 } 182 catch (ClassCastException cce) { 183 writeErrorLog( APPLICATION_NAME+" class cast exception for a class:`"+packageInstallerName+"'" ); 184 System.exit(1); 185 } 186 187 System.out.println( "Successfully loaded package installer:`"+packageInstallerName+"'" ); 191 System.out.println( "Company Name: " + getCompanyName() ); 192 System.out.println( "Product Name: " + getProductName() ); 193 logFile.dtprintln( "Successfully loaded package installer:`"+packageInstallerName+"'" ); 194 logFile.dtprintln( " + Company Name: " + getCompanyLongName() ); 195 logFile.dtprintln( " + Product Name: " + getProductLongName() ); 196 197 String mainTitle = appres.getResourceString( "mainFrame.title", "FreeInstaller from XeNoN" ); 201 mainTitle += " V" + ApplicationVersion.getVersionString()+" ( "+getProductName() + " )"; 202 203 String welcomeAudioClip = appres.getResourceString( "welcome.audioClip", "appres/audio/welcome-reverb.au" ); 204 String temp = appres.resolvePathname( "audio", welcomeAudioClip, null ); 205 if (temp != null) welcomeAudioClip=temp; 206 207 SplashScreen2.showSplash( 9950, "default.splashImage", "appres/docs/images/FreeInstaller.jpg" ); 212 213 try { 214 AudioStream audioStream = 215 new AudioStream( new FileInputStream( welcomeAudioClip )); 216 AudioData audioData = audioStream.getData(); 217 if (audioData != null) 218 getAudioPlayer().play( audioData ); 219 Thread.sleep(1000); 220 } 221 catch (IOException ioe) { 222 } 223 catch (InterruptedException ie) { 224 } 225 226 mainFrame = 231 new InstallerFrame( 232 mainTitle, "appres/images/M16Crop.jpg", 233 getCompanyName(), getProductName() ); 234 235 mainFrame.addPropertyChangeListener(this); 236 mainFrame.pack(); 237 mainFrame.setVisible(true); 238 239 String progressTitle = 240 appres.getResourceString( "progessFrame.title", "Installation Progress" ); 241 progressFrame = new ProgressFrame( progressTitle ); 242 progressFrame.pack(); 243 progressFrame.setVisible(false); 244 245 } 246 247 255 public static FreeInstallerApplication createInstance( 256 String pkgInstName, 257 String [] args ) 258 { 259 if (singleton == null) 261 singleton = new FreeInstallerApplication( pkgInstName, args ); 262 return (singleton); 263 } 264 265 270 public static FreeInstallerApplication getInstance() 271 { 272 if (singleton == null) 274 throw new NullPointerException ( "no singleton was ever created!" ); 275 return (singleton); 276 } 277 278 279 public InstallerFrame getMainFrame() 280 { 281 return (mainFrame); 282 } 283 284 285 public ProgressFrame getProgressFrame() 286 { 287 return (progressFrame); 288 } 289 290 291 public void printInfo( String msg ) 292 { 293 getProgressFrame().printInfo(msg); 294 logFile.dtprintln( msg ); 295 } 296 297 298 public void printWarning( String msg ) 299 { 300 getProgressFrame().printWarning(msg); 301 logFile.dtprintln( msg ); 302 } 303 304 305 public void printError( String msg ) 306 { 307 getProgressFrame().printError(msg); 308 logFile.dtprintln( msg ); 309 } 310 311 312 public ResourceBundle getResourceBundle() 313 { 314 return (globalBundle); 315 } 316 317 318 public void propertyChange( PropertyChangeEvent e ) 319 { 320 String propertyName = e.getPropertyName(); 321 323 if (propertyName.equals(InstallerFrame.QUIT_BUTTON_PRESSED_PROPERTY )) { 324 System.out.println( APPLICATION_NAME+" goodbye." ); 325 System.exit(0); 326 } 327 else if (propertyName.equals(InstallerFrame.INSTALL_BUTTON_PRESSED_PROPERTY )) { 328 mainFrame.setVisible(false); 337 338 packageInstaller.installPackage(); 339 } 340 } 341 342 343 public String getCompanyName() 344 { 345 return packageInstaller.getCompanyName(); 346 } 347 348 349 public String getProductName() 350 { 351 return packageInstaller.getProductName(); 352 } 353 354 356 public String getCompanyLongName() 357 { 358 return packageInstaller.getCompanyLongName(); 359 } 360 361 363 public String getProductLongName() 364 { 365 return packageInstaller.getProductLongName(); 366 } 367 368 369 public LogFile getLogFile() 370 { 371 return (logFile); 372 } 373 374 375 public void writeLog( String text ) 376 { 377 logFile.dtprintln( text ); 378 } 379 380 381 public SingleAudioPlayer getAudioPlayer() 382 { 383 return audioPlayer; 384 } 385 386 387 public void writeErrorLog( String text ) 388 { 389 System.err.println( text ); 390 logFile.dtprintln( text ); 391 } 392 } 393 394 | Popular Tags |