1 15 16 30 package ixenon.free.install; 31 32 import java.awt.*; 33 import java.awt.event.*; 34 import java.beans.*; 35 import java.util.*; 36 import java.io.*; 37 38 import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; 42 import sun.audio.*; 44 import ixenon.free.util.*; import ixenon.free.swing.*; import ixenon.free.nodes.*; import ixenon.free.uninstall.*; 49 52 80 public class BasicInstaller 81 implements PackageInstallable, Runnable 82 { 83 protected FreeInstallerApplication theApp; 84 protected ApplicationResources appres; 85 86 protected PrefixRoot prefixRoot; 87 protected File prefix; 88 protected Locale locale; 89 protected int installMode; 90 protected String endMessage; 91 protected DefaultUninstaller uninstaller; 92 93 protected File currentDir; 94 protected File sourceDir; 95 protected File sourceImagesDir; 96 protected File sourceAudioDir; 97 protected File targetBinDir; 98 protected File targetLibDir; 99 protected File targetDataDir; 100 protected File targetClassesDir; 101 protected File targetImagesDir; 102 protected File targetAudioDir; 103 104 105 109 public BasicInstaller() 110 { 111 } 112 113 116 public String getCompanyName() 117 { 118 return "Xenonsoft"; 119 } 120 121 124 public String getProductName() 125 { 126 return "FreeInstaller"; 127 } 128 129 130 public String getCompanyLongName() 131 { 132 return "Xenonsoft, South London, England"; 133 } 134 135 136 public String getProductLongName() 137 { 138 return "FreeInstaller (Example BasicInstaller) 1999"; 139 } 140 141 142 public void installPackage() 143 { 144 theApp = FreeInstallerApplication.getInstance(); 145 appres = ApplicationResources.getInstance(); 146 147 String dlgRes = "packageInstaller.basicDialog"; 148 149 String cancelButtonText = 150 appres.getResourceString( dlgRes+".cancelButton.label", "Cancel" ); 151 String approveButtonText = 152 appres.getResourceString( dlgRes+".approveButton.label", "Install" ); 153 String prevButtonText = 154 appres.getResourceString( dlgRes+".prevButton.label", "<Back" ); 155 String nextButtonText = 156 appres.getResourceString( dlgRes+".nextButton.label", "Next>" ); 157 158 String exampleHtml = 159 appres.getResourceString( dlgRes+".exampleDocURL", "appres/docs/Example.html" ); 160 161 PagerDialog dialog = 162 new PagerDialog( theApp.getMainFrame(), 163 "Pre-Installation Sheet Dialog" ); 164 dialog.setCancelButtonText(cancelButtonText); 165 dialog.setApproveButtonText(approveButtonText); 166 167 Pager pager = dialog.getPagerPane(); 168 pager.setPrevButtonText(prevButtonText); 169 pager.setNextButtonText(nextButtonText); 170 171 HTMLViewerPane htmlPane = new HTMLViewerPane(); 172 String urlPath = appres.resolvePathname( "docs", exampleHtml, null ); 173 File file = new File(urlPath); 174 if ( file.exists() ) 175 urlPath = "file:"+file.getAbsolutePath(); 176 try { 177 htmlPane.setPage( urlPath ); 178 } 179 catch (IOException ioe ) { 180 System.err.println(ioe); 181 } 182 183 createInstallationSheet(); 185 186 Image image = appres.getImage( "images", "appres/images/biz-logo.gif", null ); 190 JLabel label = new JLabel( new ImageIcon( image )); 191 label.setPreferredSize( new Dimension( 250, 375 )); 192 label.setBorder( new EmptyBorder( 10,30,10,30 )); 193 dialog.getPagerPane().addCenterSideComponent( label, BorderLayout.WEST ); 195 196 dialog.addPage(htmlPane); 197 dialog.pack(); Dimension size = new Dimension(dialog.getSize()); 199 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 200 201 if (screen.width > 1100 ) { 202 size.width = 950; 204 size.height = 850; 205 } 206 int x = (screen.width-size.width)/2; 207 int y = (screen.height-size.height)/2; 208 dialog.setBounds(x, y, size.width, size.height); 209 int answer = dialog.showDialog(); 210 if (answer == PagerDialog.APPROVE_BUTTON ) { 211 Thread t1 = new Thread (this); 216 t1.start(); 217 theApp.getProgressFrame().setVisible(true); 218 } 219 else { 220 theApp.getMainFrame().setVisible(true); 224 theApp.getProgressFrame().setVisible(false); 225 } 226 } 227 228 229 230 protected void createInstallationSheet() 231 { 232 String osname = System.getProperty("os.name"); 233 String fileSep = System.getProperty("file.separator"); 234 String pathSep = System.getProperty("path.separator"); 235 String userHome = System.getProperty("user.home"); 236 237 final InstallerFrame mainFrame = theApp.getMainFrame(); 238 239 prefix = mainFrame.getPrefix(); 240 locale = mainFrame.getLocale(); 241 installMode = mainFrame.getInstallMode(); 242 243 uninstaller = new DefaultUninstaller( prefix, "Uninstall-FreeInstaller" ); 248 249 currentDir = new File( System.getProperty("user.dir") ); 251 sourceImagesDir = 252 InstallUtilities.createNormalizedFile( currentDir, "appres/images" ); 253 sourceAudioDir = 254 InstallUtilities.createNormalizedFile( currentDir, "appres/audio" ); 255 256 targetBinDir = 267 InstallUtilities.createNormalizedFile( prefix, "bin" ); 268 targetLibDir = 269 InstallUtilities.createNormalizedFile( prefix, "lib" ); 270 targetClassesDir = 271 InstallUtilities.createNormalizedFile( prefix, "lib/classes" ); 272 targetDataDir = 273 InstallUtilities.createNormalizedFile( prefix, "lib/FreeInstaller" ); 274 targetImagesDir = 275 InstallUtilities.createNormalizedFile( prefix, "appres/images" ); 276 targetAudioDir = 277 InstallUtilities.createNormalizedFile( prefix, "appres/audio" ); 278 279 prefixRoot = new PrefixRoot( "top directory", prefix ); 280 281 289 InstallMultipleFile installLauncher = new InstallMultipleFile( 293 "FreeInstaller launcher (shell script) ", 294 InstallConstants.INST_EXE_PERMS, 295 currentDir, prefix, "FreeInstaller" ); 296 prefixRoot.add(installLauncher); 297 298 InstallMultipleFile installBase = new InstallMultipleFile( 302 "FreeInstaller (basic) ", 303 InstallConstants.INST_RDONLY_PERMS, 304 currentDir, prefix, 305 new String [] { "README", "TODO", "CHANGES", "Makefile", "LICENSE-XPeL.txt" } ); 306 prefixRoot.add(installBase); 307 308 SimpleCopyFile simple1 = new SimpleCopyFile( 312 "Exercise the simple file copier", 313 InstallConstants.INST_RDONLY_PERMS, 314 InstallUtilities.createNormalizedFile( currentDir, "README"), 315 InstallUtilities.createNormalizedFile( prefix, "copy_of_README" ) ); 316 prefixRoot.add(simple1); 317 318 InstallFilterFile installProperties = new InstallFilterFile( 322 "Install Properties Files", 323 InstallConstants.INST_RDONLY_PERMS, 324 currentDir, prefix, 325 new SimpleFilenameFilter(".properties") ); 326 prefixRoot.add(installProperties); 327 328 InstallMultipleFile installJars = new InstallMultipleFile( 332 "FreeInstaller (Java Archive) ", 333 InstallConstants.INST_RDWR_PERMS, 334 currentDir, prefix, 335 new String [] { "freeinst.jar" } ); 336 installJars.setPedantic(false); 337 prefixRoot.add(installJars); 338 339 InstallFilterFile installScripts = new InstallFilterFile( 343 "Shell scripts", 344 InstallConstants.INST_RDONLY_PERMS, 345 currentDir, prefix, 346 new SimpleFilenameFilter(".sh") ); 347 prefixRoot.add(installScripts); 348 349 InstallFilterFile installImages1 = new InstallFilterFile( 353 "GIF / JPEG images (*.gif, *.jpg, *.jpeg)", 354 InstallConstants.INST_RDONLY_PERMS, 355 sourceImagesDir, targetImagesDir, 356 new SimpleFilenameFilter( 357 new String [] { ".gif", ".jpg", ".jpeg" } )); 358 prefixRoot.add(installImages1); 359 360 361 InstallFilterFile installAudio1 = new InstallFilterFile( 362 "Audio files (*.au, *.wav, *.aiff)", 363 InstallConstants.INST_RDONLY_PERMS, 364 sourceAudioDir, targetAudioDir, 365 new SimpleFilenameFilter( 366 new String [] { ".au", ".raw", "*.wav", "*.aiff" } )); 367 prefixRoot.add(installAudio1); 368 369 InstallFilterFile installDoc1 = new InstallFilterFile( 371 "Documentation (*.html, *.html, *.txt)", 372 InstallConstants.INST_RDONLY_PERMS, 373 InstallUtilities.createNormalizedFile( currentDir, "appres/docs"), 374 InstallUtilities.createNormalizedFile( prefix, "appres/docs" ), 375 new SimpleFilenameFilter( 376 new String [] { ".html", ".htm", ".txt", ".doc" } )); 377 prefixRoot.add(installDoc1); 378 379 InstallFilterFile installImages2 = new InstallFilterFile( 380 "Doc GIF/JPEG images (*.gif, *.jpg, *.jpeg)", 381 InstallConstants.INST_RDONLY_PERMS, 382 InstallUtilities.createNormalizedFile( currentDir, "appres/docs/images"), 383 InstallUtilities.createNormalizedFile( prefix, "appres/docs/images" ), 384 new SimpleFilenameFilter( 385 new String [] { ".gif", ".jpg", ".jpeg" } )); 386 prefixRoot.add(installImages2); 387 388 InstallFilterFile installJava1 = new InstallFilterFile( 392 "Java Source Files #1", 393 InstallConstants.INST_RDONLY_PERMS, 394 InstallUtilities.createNormalizedFile( currentDir, "ixenon/free/install"), 395 InstallUtilities.createNormalizedFile( prefix, "ixenon/free/install" ), 396 new SimpleFilenameFilter(".java")); 397 prefixRoot.add(installJava1); 398 399 InstallFilterFile installJava2 = new InstallFilterFile( 400 "Java Source Files #2", 401 InstallConstants.INST_RDONLY_PERMS, 402 InstallUtilities.createNormalizedFile( currentDir, "ixenon/free/util"), 403 InstallUtilities.createNormalizedFile( prefix, "ixenon/free/util" ), 404 new SimpleFilenameFilter(".java")); 405 prefixRoot.add(installJava2); 406 407 InstallFilterFile installJava3 = new InstallFilterFile( 408 "Java Source Files #3", 409 InstallConstants.INST_RDONLY_PERMS, 410 InstallUtilities.createNormalizedFile( currentDir,"ixenon/free/swing"), 411 InstallUtilities.createNormalizedFile( prefix, "ixenon/free/swing" ), 412 new SimpleFilenameFilter(".java")); 413 prefixRoot.add(installJava3); 414 415 InstallFilterFile installJava4 = new InstallFilterFile( 416 "Java Source Files #4", 417 InstallConstants.INST_RDONLY_PERMS, 418 InstallUtilities.createNormalizedFile( currentDir, "ixenon/free/uninstall"), 419 InstallUtilities.createNormalizedFile( prefix, "ixenon/free/uninstall" ), 420 new SimpleFilenameFilter(".java")); 421 prefixRoot.add(installJava4); 422 423 InstallFilterFile installJava5 = new InstallFilterFile( 424 "Java Source Files #5", 425 InstallConstants.INST_RDONLY_PERMS, 426 InstallUtilities.createNormalizedFile( currentDir, "ixenon/free/nodes"), 427 InstallUtilities.createNormalizedFile( prefix, "ixenon/free/nodes" ), 428 new SimpleFilenameFilter(".java")); 429 prefixRoot.add(installJava5); 430 431 String [] jarFiles1 = new String [3]; 435 436 jarFiles1[0] = prefix.getAbsolutePath(); jarFiles1[1] = prefix.getAbsolutePath() + fileSep + "freeinst.jar"; 438 CreateRuntimeBatch createBatch1 = new CreateRuntimeBatch( 439 "Creating Batch Launcher Scripts", 440 prefix, prefix , 441 "FREE_INSTALLER_HOME", "FreeInstaller", 442 "ixenon.free.install.FreeInstaller" , 443 jarFiles1 ); 444 prefixRoot.add(createBatch1); 445 446 String [] jarFiles2 = new String [3]; 450 jarFiles2[0] = currentDir.getAbsolutePath(); jarFiles2[1] = currentDir.getAbsolutePath() + fileSep + "freeinst.jar"; 452 CreateRuntimeBatch createBatch2 = new CreateRuntimeBatch( 453 "Creating Batch Launcher Scripts for the binary distribution", 454 currentDir, currentDir, 455 "FREE_INSTALLER_HOME", "FreeInstaller", 456 "ixenon.free.install.FreeInstaller" , 457 jarFiles2 ); 458 459 createBatch2.setGenerateUninstall(false); 461 462 prefixRoot.add(createBatch2); 463 464 String propFilename; 469 String appClassName="FreeInstaller"; 470 if ( osname.startsWith("Windows 95") || 471 osname.startsWith("Windows 98") || 472 osname.startsWith("Windows NT") || 473 osname.startsWith("Windows 2000") || 474 osname.startsWith("OS/2") ) 475 propFilename = "_"+appClassName+fileSep+appClassName+".properties"; 477 else 478 propFilename = "."+appClassName+fileSep+appClassName+".properties"; 480 481 CreateDefaultPropertyFile createProperty1 = 482 new CreateDefaultPropertyFile( 483 "Creating default properties file (#1)", 484 userHome+fileSep+propFilename, 485 prefix.getPath(), null, 486 targetImagesDir.getPath(), 487 targetAudioDir.getPath(), 488 null ); 489 prefixRoot.add(createProperty1); 490 491 CreateDefaultPropertyFile createProperty2 = 492 new CreateDefaultPropertyFile( 493 "Creating default properties file (#2)", 494 new File( targetLibDir, appClassName+".properties" ).getPath(), 495 prefix.getPath(), null, 496 targetImagesDir.getPath(), 497 targetAudioDir.getPath(), 498 null ); 499 prefixRoot.add(createProperty2); 500 501 endMessage = 502 "Just a message to let you know that the installation has now completed.\n"+ 503 "\nVENDOR: "+ getCompanyName() + 504 "\nPRODUCT: "+ getProductName() + 505 "\n\nThe software has been installed in `"+prefix.getPath()+"'.\n"+ 506 "The source distribution has been copied successfully.\n"+ 507 "To uninstall the software, simply run `"+ 508 uninstaller.getTargetFilename()+"'\n"; 509 510 endMessage += 511 "Be sure to read the log file:`"+ 512 theApp.getLogFile().getFilename()+"'\n"+ 513 "\n*** NOTE: Please ignore the rest of this text ***\n"+ 514 "You will find executables stored in `"+targetBinDir.getPath()+"'.\n"+ 515 "You will find libraries stored in `"+targetLibDir.getPath()+"'.\n"+ 516 "You will also find properties stored in `"+propFilename+"'.\n"+ 517 "and you will also find text files in `"+targetDataDir.getPath()+"'.\n"+ 518 "\n\tEnjoy\n"; 519 } 520 521 522 public synchronized void run() 523 { 524 527 final InstallerFrame mainFrame = theApp.getMainFrame(); 528 529 theApp.printInfo( "Beginning installation ..." ); 530 theApp.printInfo( "COMPANY:"+getCompanyName() ); 531 theApp.printInfo( "PRODUCT:"+getProductName() ); 532 533 theApp.printWarning( "This package installer currently ignores any installation type setting."); 534 theApp.printWarning( "This package installer currently ignores any locale setting."); 535 536 try { Thread.sleep(3000); } catch (InterruptedException ie) { ; } 537 538 Enumeration etor = prefixRoot.preorderEnumeration(); 543 Installable installable; 544 545 while ( etor.hasMoreElements() ) { 546 installable = (Installable)etor.nextElement(); 550 installable.setLocale(locale); 551 installable.setInstallMode(installMode); 552 installable.setUninstaller(uninstaller); 553 554 try { 556 theApp.printInfo( "" ); 557 theApp.printInfo( "INSTALLING: "+installable.getNodeName() ); 558 installable.install(); 559 } 560 catch (InstallException ie ) { 561 theApp.printError( "installation exception message: "+ie.getMessage() ); 562 uninstaller.generateScript(); 563 564 final String message = "**** INSTALL EXCEPTION ****\n\n" + ie.getMessage(); 565 SwingUtilities.invokeLater( new Runnable () { 566 public void run() { 567 InstallerFrame.popupErrorDialog( 568 mainFrame, "installExceptionDialog", 569 "Install Exception Dialog", message ); 570 System.exit(1); 571 } 572 }); 573 574 return; 578 } 579 } 580 581 uninstaller.generateScript(); 584 585 theApp.printInfo( "" ); 586 theApp.printInfo( "Installation completed." ); 587 588 SwingUtilities.invokeLater( new Runnable () { 589 public void run() { 590 InstallerFrame.popupInfoDialog( 591 theApp.getProgressFrame(), 592 "informationDialog", "Information Dialog", endMessage ); 593 System.exit(0); 595 } 596 }); 597 598 String temp; 611 String audioClip1 = appres.getResourceString( "BasicInstaller.audioClip1", "rock-fill.au" ); 612 String audioClip2 = appres.getResourceString( "BasicInstaller.audioClip2", "rock-verse.au" ); 613 String audioClip3 = appres.getResourceString( "BasicInstaller.audioClip3", "rock-frettap7.au" ); 614 615 temp = appres.resolvePathname( "appres/audio", audioClip1, null ); 616 if (temp != null) audioClip1=temp; 617 temp = appres.resolvePathname( "appres/audio", audioClip2, null ); 618 if (temp != null) audioClip2=temp; 619 temp = appres.resolvePathname( "appres/audio", audioClip3, null ); 620 if (temp != null) audioClip3=temp; 621 622 try { 623 AudioStream [] audioStream = new AudioStream[16]; 627 int n=0; 628 audioStream[n++] = new AudioStream( new FileInputStream( audioClip1 )); 629 audioStream[n++] = new AudioStream( new FileInputStream( audioClip2 )); 630 audioStream[n++] = new AudioStream( new FileInputStream( audioClip2 )); 631 audioStream[n++] = new AudioStream( new FileInputStream( audioClip3 )); 632 audioStream[n++] = new AudioStream( new FileInputStream( audioClip1 )); 633 audioStream[n++] = new AudioStream( new FileInputStream( audioClip2 )); 634 audioStream[n++] = new AudioStream( new FileInputStream( audioClip2 )); 635 audioStream[n++] = new AudioStream( new FileInputStream( audioClip2 )); 636 audioStream[n++] = new AudioStream( new FileInputStream( audioClip1 )); 637 audioStream[n++] = new AudioStream( new FileInputStream( audioClip1 )); 638 audioStream[n++] = new AudioStream( new FileInputStream( audioClip2 )); 639 audioStream[n++] = new AudioStream( new FileInputStream( audioClip3 )); 640 641 System.gc(); 643 644 Vector v = new Vector(); 646 for (int q=0; q<audioStream.length; ++q ) 647 if ( audioStream[q] != null ) 648 v.addElement(audioStream[q]); 649 650 AudioStreamSequence audiostream = new AudioStreamSequence(v.elements()); 651 try { Thread.sleep(2500); } catch (InterruptedException ie) { ; } 652 theApp.getAudioPlayer().play( audiostream ); 653 } 654 catch (IOException ioe) { 655 } 656 657 } 658 } 659 660 | Popular Tags |