home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / chapm20.zip / ChapInst.cls < prev    next >
Text File  |  1995-06-22  |  10KB  |  292 lines

  1. "Initialization code"
  2.  !
  3.  
  4. "define class"
  5. WindowDialog subclass: #ChChapManInstallDialog
  6.   instanceVariableNames: ''
  7.   classVariableNames: ''
  8.   poolDictionaries: ''!
  9.  
  10.  
  11.  
  12. !ChChapManInstallDialog methods !
  13.  
  14. applicationTargetDirectory: aPane
  15.         "Private - Set the default application target directory."
  16.         "@16.06.95 ch: Creation"
  17.  
  18.     aPane contents: Disk fullDirName, 'ChapApp'
  19. !
  20.    
  21. cancel: aTopPane
  22.         "Private - Cancel the dialog box."
  23.         "@22.05.95 ch: Creation" 
  24.  
  25.     Transcript cr; nextPutAll: 'Installation aborted.'; cr.
  26.     self close.!
  27.   
  28. copyFile: aString fromDirectory: fromDir toDirectory: toDir
  29.         "Copy a the with name <aString> from the directory 
  30.         <fromDir> to the directory <toDir>. Check if the copy is 
  31.         ok."  
  32.         "@18.06.95 ch: Creation"
  33.  
  34.     (File copy: fromDir fullDirName, aString to: toDir fullDirName, aString) ifFalse: [
  35.         self error: 'Error copying file ', aString]
  36. !
  37.  
  38. createView
  39.         "Private - Create the view."
  40.         "@16.06.95 ch: Creation"
  41.  
  42.     | charSize realCharSize aPane |
  43.     realCharSize := WindowDialog unitMultiplier.
  44.     charSize := realCharSize * (1 @ (3/2)).
  45.  
  46.     self
  47.         label: 'ChapMan Installation';
  48.         addSubpane: (StaticText new
  49.             contents: 'Source directory of distribution files:';
  50.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ (1/4+1)) * charSize) 
  51.                 extentFromLeftTop: (40 @ 1) * realCharSize]);
  52.         addSubpane: ((aPane := EntryField new)
  53.             setName: #sourceDirectory:;
  54.             when: #needsContents send: #sourceDirectory: to: self with: aPane;
  55.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ 2) * charSize) 
  56.                 extentFromLeftTop: (40 @ 1) * charSize]);
  57.  
  58.         addSubpane: (StaticText new
  59.             contents: 'Target directory for application files:';
  60.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ (1/4+3)) * charSize) 
  61.                 extentFromLeftTop: (40 @ 1) * realCharSize]);
  62.         addSubpane: ((aPane := EntryField new)
  63.             setName: #applicationTargetDirectory:;
  64.             when: #needsContents send: #applicationTargetDirectory: to: self with: aPane;
  65.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ 4) * charSize) 
  66.                 extentFromLeftTop: (40 @ 1) * charSize]);
  67.  
  68.         addSubpane: (StaticText new
  69.             contents: 'Target directory for help files:';
  70.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ (1/4+5)) * charSize) 
  71.                 extentFromLeftTop: (40 @ 1) * realCharSize]);
  72.         addSubpane: ((aPane := EntryField new)
  73.             setName: #helpTargetDirectory:;
  74.             when: #needsContents send: #helpTargetDirectory: to: self with: aPane;
  75.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ 6) * charSize) 
  76.                 extentFromLeftTop: (40 @ 1) * charSize]);
  77.  
  78.         addSubpane: (GroupBox new
  79.             contents: 'Installation format';
  80.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ (1/6+7)) * charSize)
  81.                 extentFromLeftTop: (40 @ 3) * charSize]);
  82.         addSubpane: (RadioButton new
  83.             setName: 'installSLLVersion';
  84.             contents: 'SLL';
  85.             selection: true;
  86.             framingBlock: [:box | (box leftTop rightAndDown: (3 @ 8) * charSize)
  87.                 extentFromLeftTop: (38 @ 1) * charSize]);
  88.         addSubpane: (RadioButton new
  89.             contents: 'File-In (not available in the test version)';
  90.             selection: false;
  91.             framingBlock: [:box | (box leftTop rightAndDown: (3 @ 9) * charSize)
  92.                 extentFromLeftTop: (38 @ 1) * charSize]);
  93.  
  94.         "Now, the install, cancel buttons."
  95.         addSubpane: (Button new
  96.             defaultPushButton;
  97.             contents: 'Install' replaceEscapeCharacters;
  98.             when: #clicked send: #install to: self;
  99.             framingBlock: [:box | (box leftTop rightAndDown: (2 @ 11) * charSize) 
  100.                 extentFromLeftTop: (8 @ 1) * charSize]);
  101.  
  102.         addSubpane: (Button new
  103.             contents: 'Cancel' replaceEscapeCharacters;
  104.             when: #clicked send: #cancel: to: self with: nil;
  105.             framingBlock: [:box | (box leftTop rightAndDown: (12 @ 11) * charSize) 
  106.                 extentFromLeftTop: (8 @ 1) * charSize]).
  107.  
  108.     self mainView alignRelativeToScreen
  109.  
  110.  
  111. !
  112.   
  113. helpTargetDirectory: aPane
  114.         "Private - Set the default application target directory."
  115.         "@16.06.95 ch: Creation"
  116.  
  117.     aPane contents: Disk fullDirName, 'Help'
  118. !
  119.  
  120. initWindowSize
  121.         "Private - Answer the initial window size."
  122.  
  123.     | aPoint | 
  124.     aPoint := WindowDialog unitMultiplier * (44 @ 19). 
  125.     "^(Display extent / 2 leftAndUp: (aPoint / 2)) extentFromLeftTop: aPoint."
  126.     ^aPoint
  127. !
  128.    
  129. install
  130.         "Private - Install ChapMan."
  131.         "@21.06.95 ch" 
  132.         "@18.06.95 ch: fix"
  133.         "@16.06.95 ch: Creation"
  134.  
  135.     | answer sourceDir applicationTargetDir helpTargetDir bugfixFile
  136.     platformLetter installSLLVersion programVersion file fullVersion 
  137.     apps app aDirectory |
  138.     programVersion := '20'.
  139.     Transcript cr.
  140.     sourceDir := Directory pathName: 
  141.         (self paneAt: #sourceDirectory:) contents.
  142.     sourceDir exists ifFalse: [
  143.         ^MessageBox message: 'Source directory doesn''t exist.'].
  144.  
  145.     helpTargetDir := Directory pathName: 
  146.         (self paneAt: #helpTargetDirectory:) contents.
  147.     helpTargetDir exists ifFalse: [
  148.         ^MessageBox message: 'Help target directory doesn''t exist.'].
  149.  
  150.     applicationTargetDir := Directory pathName: 
  151.         (self paneAt: #applicationTargetDirectory:) contents.
  152.     applicationTargetDir exists ifFalse: [
  153.         answer := MessageBox confirm: 'Application target directory doesn''t exist. Create it?'.
  154.         answer 
  155.             ifTrue: [applicationTargetDir create]
  156.             ifFalse: [^self].
  157.         ].
  158.     installSLLVersion := (self paneAt: 'installSLLVersion') selection.
  159.     platformLetter := String with: SmalltalkLibrary platformLetter.
  160.     fullVersion := (sourceDir existingFileNamed: 
  161.         'Chap', platformLetter, programVersion, '.sml') notNil.
  162.     installSLLVersion not & fullVersion not ifTrue: [
  163.         ^MessageBox message: 'File in version not available.'].
  164.  
  165.     "Copy the help files."
  166.     Transcript cr; nextPutAll: 'Copying help files...'.
  167.     file := 'Chap', platformLetter, programVersion, '.hlp'.
  168.     self copyFile: file fromDirectory: sourceDir toDirectory: helpTargetDir.
  169.  
  170.     "Copy the resource DLL."
  171.     Transcript cr; nextPutAll: 'Copying DLLs...'.
  172.     file := 'Chap', platformLetter, programVersion, '.dll'.
  173.     self copyFile: file fromDirectory: sourceDir toDirectory: Disk.
  174.  
  175.     "Copy the application files."
  176.     Transcript cr; nextPutAll: 'Copying application files...'.
  177.     (sourceDir filesNamed: '*.cha'),
  178.     (sourceDir filesNamed: '*.cls'),
  179.     (sourceDir filesNamed: '*.st') do: [:each |
  180.         self copyFile: each fromDirectory: sourceDir toDirectory: applicationTargetDir].
  181.  
  182.     "Install the bug fixes."
  183.     Smalltalk platformIsOS2 ifTrue: [
  184.         Smalltalk versionNumberString = '3.0.0' 
  185.             ifTrue: [bugfixFile := 'fixo30']
  186.             ifFalse: [bugfixFile := 'fixo301']
  187.         ].
  188.     Smalltalk platformIsWin32 ifTrue: [
  189.         bugfixFile := 'fixw30'].
  190.     Transcript cr; nextPutAll: 'Installing bug fixes ', bugfixFile, '...'.
  191.     (applicationTargetDir file: bugfixFile, '.cls') fileIn; close.
  192.         
  193.     "Install the registration SLL."
  194.     (Smalltalk includesKey: #ChRegisterDialog) ifFalse: [
  195.         Transcript cr; nextPutAll: 'Installing the registration SLL...'.
  196.         file := 'ChapR', platformLetter, programVersion, '.sll'.
  197.         self copyFile: file fromDirectory: sourceDir toDirectory: Disk.
  198.         SmalltalkLibraryBinder bindTo: file.
  199.         Transcript nextPutAll: ' Installed.'.
  200.         ].
  201.  
  202.     "Install the ChapMan System."
  203.     installSLLVersion ifTrue: [
  204.         Transcript cr; nextPutAll: 'Installing the ChapMan SLL...'.
  205.         file := 'Chap', platformLetter, programVersion.
  206.         self copyFile: file, '.sll' fromDirectory: sourceDir toDirectory: Disk.
  207.         fullVersion ifTrue: [
  208.             self copyFile: file, '.sml' fromDirectory: sourceDir toDirectory: Disk].
  209.         SmalltalkLibraryBinder bindTo: file, '.sll'.
  210.         Transcript nextPutAll: ' Installed.'.
  211.         ]
  212.     ifFalse: [
  213.         Smalltalk at: #ChapManInstallationDirectory put: applicationTargetDir fullDirName.
  214.         file := (applicationTargetDir file: 'ChapBas.st').
  215.         file fileIn; close.
  216.         Smalltalk removeKey: #ChapManInstallationDirectory.
  217.         ].
  218.     (Smalltalk at: #ChApplicationBrowser) installChapMan.
  219.  
  220.     "Install the Library Builder SLLs."
  221.     (Smalltalk includesKey: #SmalltalkLibraryBuilder) ifFalse: [
  222.         aDirectory := 'extras\slbuild'.
  223.         [aDirectory := Directory pathName: aDirectory. aDirectory exists] whileFalse: [
  224.             aDirectory := Prompter 
  225.                 prompt: 'Enter directory of the Smalltalk Library Builder SLLs'
  226.                 default: aDirectory pathName.
  227.             aDirectory isNil ifTrue: [
  228.                 ^self cancel: nil].
  229.             ].
  230.         (aDirectory filesNamed: '*.sll') do: [:each |
  231.             self copyFile: each fromDirectory: aDirectory toDirectory: Disk.
  232.             SmalltalkLibraryBinder bindTo: each.
  233.             Transcript cr; nextPutAll: each, ' installed.'.
  234.             ].
  235.         ].
  236.  
  237.     "File In all available application definitions."
  238.     (Smalltalk at: #ChApplication) configVariables 
  239.         at: 'DirectoryCHA' put: applicationTargetDir.
  240.     apps := Array
  241.         with: 'ChapMan'
  242.         with: bugfixFile.
  243.     apps := apps, #('CompIntf' 'Events' 'FileSys' 'StLibMan' 'WinPolic' 'WinSys').
  244.     Transcript cr; nextPutAll: 'Installing Application definitions...'.
  245.     apps do: [:appName |
  246.         Transcript cr; nextPutAll: '  ', appName.
  247.         app := (Smalltalk at: #ChApplication)
  248.             newFromFile: appName subApplications: true
  249.             installSource: false
  250.             useExisting: false.
  251.         app notNil ifTrue: [
  252.             app addToMainApplications]
  253.         ifFalse: [
  254.             MessageBox message: 'Couldn''t file in application ', appName.
  255.             self cancel: nil].
  256.         ].
  257.  
  258.     Transcript cr; nextPutAll: 'ChapMan System installed.'; cr.
  259.  
  260.     [
  261.     Cursor reset.
  262.     (MessageBox confirm: 'Confirm the reinitialization of the window system.') ifTrue: [
  263.         Notifier reinitialize]
  264.     ] forkAt: Processor lowUserPriority.
  265.     self close.
  266. !
  267.   
  268. open
  269.         "Open the settings dialog."
  270.         "@22.04.95 ch: Creation"
  271.     self 
  272.         createView;
  273.         openWindow
  274. !
  275.  
  276. sourceDirectory: aPane
  277.         "Private - Set the default source directory."
  278.         "@16.06.95 ch: Creation"
  279.  
  280.     aPane contents: ''
  281. ! !
  282.  
  283.  
  284.  
  285. !ChChapManInstallDialog class methods ! !
  286. "Finalization code"
  287.    
  288. [ChChapManInstallDialog new open] fork!
  289.  
  290.    
  291. Transcript cr; nextPutAll: 'ChapMan Installation installed.'!
  292.