AbstractLauncherApplication.st
branchjv
changeset 17134 c4cce8b7a95d
parent 17133 f9f20407fbf9
parent 16974 0159bd547729
child 17136 cb908d2ba02e
equal deleted inserted replaced
17133:f9f20407fbf9 17134:c4cce8b7a95d
    34 		packageIcon greyPackageIcon folderIcon greyFolderIcon
    34 		packageIcon greyPackageIcon folderIcon greyFolderIcon
    35 		alreadyLoadedString applicationIcon greyApplicationIcon root
    35 		alreadyLoadedString applicationIcon greyApplicationIcon root
    36 		itemsByPath getItemByPath myHierarchicalItemWithLabelAndIcon
    36 		itemsByPath getItemByPath myHierarchicalItemWithLabelAndIcon
    37 		filterHolder masterRoot infoTextHolder loadButton
    37 		filterHolder masterRoot infoTextHolder loadButton
    38 		loadAndBrowseButton selectedPackageHolder monticelloRoot
    38 		loadAndBrowseButton selectedPackageHolder monticelloRoot
    39 		backgroundPackageFindProcess'
    39 		backgroundPackageFindProcess itemsMatchingFilter'
    40 	classVariableNames:'PreviousPackageDialogItems PreviousPackageDialogExtent'
    40 	classVariableNames:'PreviousPackageDialogItems PreviousPackageDialogExtent'
    41 	poolDictionaries:''
    41 	poolDictionaries:''
    42 	privateIn:AbstractLauncherApplication
    42 	privateIn:AbstractLauncherApplication
       
    43 !
       
    44 
       
    45 HierarchicalItemWithLabelAndIcon subclass:#MyHierarchicalItem
       
    46 	instanceVariableNames:'type info'
       
    47 	classVariableNames:''
       
    48 	poolDictionaries:''
       
    49 	privateIn:AbstractLauncherApplication::PackageLoadDialog
    43 !
    50 !
    44 
    51 
    45 !AbstractLauncherApplication class methodsFor:'documentation'!
    52 !AbstractLauncherApplication class methodsFor:'documentation'!
    46 
    53 
    47 copyright
    54 copyright
   419         ].
   426         ].
   420         OpenSettingsDialog := nil.
   427         OpenSettingsDialog := nil.
   421     ].
   428     ].
   422 
   429 
   423     settingsApp := SettingsDialog new.
   430     settingsApp := SettingsDialog new.
       
   431     settingsApp resources:(AbstractLauncherApplication resources).
   424     settingsApp requestor:requestor.
   432     settingsApp requestor:requestor.
   425     settingsApp installSettingsEntries:(self allSettingsList).
   433     settingsApp installSettingsEntries:(self allSettingsList).
   426     "/ settingsApp requestor:self.
   434     "/ settingsApp requestor:self.
   427     OpenSettingsDialog := settingsApp.
   435     OpenSettingsDialog := settingsApp.
   428     settingsApp allButOpen.
   436     settingsApp allButOpen.
  1282 !
  1290 !
  1283 
  1291 
  1284 requestForWindowClose
  1292 requestForWindowClose
  1285     "close request from windowing system (window close);
  1293     "close request from windowing system (window close);
  1286      confirm and ask if closing of launcher only or
  1294      confirm and ask if closing of launcher only or
  1287      a smalltalk-exit is wanted"
  1295      a Smalltalk-exit is wanted"
  1288 
  1296 
  1289     |answer|
  1297     |answer|
  1290 
  1298 
  1291     answer := Dialog
  1299     answer := Dialog
  1292                 confirmWithCancel:(resources string:'Close %1 only or Exit Smalltalk (Close all) ?' with:self class name)
  1300                 confirmWithCancel:(resources string:'Close %1 only or Exit Smalltalk (Close all) ?' with:self class name)
  1299 
  1307 
  1300     answer ifFalse:[
  1308     answer ifFalse:[
  1301         ^ true
  1309         ^ true
  1302     ].
  1310     ].
  1303 
  1311 
  1304     self exit
  1312     self exit.
       
  1313     "/ not reached
       
  1314     ^ false
  1305 
  1315 
  1306     "Modified: / 20.5.1999 / 17:24:47 / cg"
  1316     "Modified: / 20.5.1999 / 17:24:47 / cg"
  1307 !
  1317 !
  1308 
  1318 
  1309 saveAndTerminateRequest
  1319 saveAndTerminateRequest
  2556     WindowTreeView openOnAll
  2566     WindowTreeView openOnAll
  2557 !
  2567 !
  2558 
  2568 
  2559 viewBrowse
  2569 viewBrowse
  2560     "let user pick a view and browse its Application class. 
  2570     "let user pick a view and browse its Application class. 
  2561      Of course, only smalltalk views are allowed"
  2571      Of course, only Smalltalk views are allowed"
  2562 
  2572 
  2563     |v app appClass browser|
  2573     |v app appClass browser|
  2564 
  2574 
  2565     (v := self pickAView) notNil ifTrue:[
  2575     (v := self pickAView) notNil ifTrue:[
  2566         browser := UserPreferences browserClass.
  2576         browser := UserPreferences browserClass.
  2577     "Created: / 30-06-2011 / 22:59:03 / cg"
  2587     "Created: / 30-06-2011 / 22:59:03 / cg"
  2578 !
  2588 !
  2579 
  2589 
  2580 viewDestroy
  2590 viewDestroy
  2581     "let user pick a view and destroy it.
  2591     "let user pick a view and destroy it.
  2582      Even allow destroying non-smalltalk views
  2592      Even allow destroying non-Smalltalk views
  2583      (also for views which I forgot due to some error)"
  2593      (also for views which I forgot due to some error)"
  2584 
  2594 
  2585     |screen v id i c|
  2595     |screen v id i c|
  2586 
  2596 
  2587     Delay waitForSeconds:1.
  2597     Delay waitForSeconds:1.
  2624     "Modified: / 27-04-2012 / 13:24:23 / cg"
  2634     "Modified: / 27-04-2012 / 13:24:23 / cg"
  2625 !
  2635 !
  2626 
  2636 
  2627 viewInspect
  2637 viewInspect
  2628     "let user pick a view and inspect it. 
  2638     "let user pick a view and inspect it. 
  2629      Of course, only smalltalk views are allowed"
  2639      Of course, only Smalltalk views are allowed"
  2630 
  2640 
  2631     |v|
  2641     |v|
  2632 
  2642 
  2633     (v := self pickAView) notNil ifTrue:[
  2643     (v := self pickAView) notNil ifTrue:[
  2634         v inspect
  2644         v inspect
  2635     ]
  2645     ]
  2636 !
  2646 !
  2637 
  2647 
  2638 viewMigrate
  2648 viewMigrate
  2639     "let user pick a view and migrate it to some other display.
  2649     "let user pick a view and migrate it to some other display.
  2640      Only smalltalk views are allowed"
  2650      Only Smalltalk views are allowed"
  2641 
  2651 
  2642     |v|
  2652     |v|
  2643 
  2653 
  2644     (v := self pickAView) notNil ifTrue:[
  2654     (v := self pickAView) notNil ifTrue:[
  2645         self migrateWindow:v topView
  2655         self migrateWindow:v topView
  7240     filterHolder := ValueHolder with:nil.
  7250     filterHolder := ValueHolder with:nil.
  7241     itemsByPath := Dictionary new.
  7251     itemsByPath := Dictionary new.
  7242     packageIdByItem := IdentityDictionary new.
  7252     packageIdByItem := IdentityDictionary new.
  7243     pathByItem := IdentityDictionary new.  
  7253     pathByItem := IdentityDictionary new.  
  7244 
  7254 
  7245     Class withoutUpdatingChangesDo:[
       
  7246         myHierarchicalItemWithLabelAndIcon := 
       
  7247             HierarchicalItemWithLabelAndIcon 
       
  7248                 subclass:#myHierarchicalItemWithLabelAndIcon
       
  7249                 instanceVariableNames:'type info'
       
  7250                 classVariableNames:''
       
  7251                 poolDictionaries:''
       
  7252                 category:nil
       
  7253                 inEnvironment:nil.
       
  7254             myHierarchicalItemWithLabelAndIcon compile:'type ^ type'.
       
  7255             myHierarchicalItemWithLabelAndIcon compile:'type:aSymbol type := aSymbol'.
       
  7256             myHierarchicalItemWithLabelAndIcon compile:'info ^ info'.
       
  7257             myHierarchicalItemWithLabelAndIcon compile:'info:anObject info := anObject'.
       
  7258     ].
       
  7259 
       
  7260     list := HierarchicalList new.
  7255     list := HierarchicalList new.
  7261 
  7256 
  7262     masterRoot := myHierarchicalItemWithLabelAndIcon new.
  7257     masterRoot := MyHierarchicalItem new.
  7263     masterRoot icon:(ToolbarIconLibrary stxHomeIcon).
  7258     masterRoot icon:(ToolbarIconLibrary stxHomeIcon).
  7264     masterRoot label:(resources string:'local ').
  7259     masterRoot label:(resources string:'local ').
  7265     masterRoot type:#localRoot.
  7260     masterRoot type:#localRoot.
  7266 
  7261 
  7267     root := myHierarchicalItemWithLabelAndIcon new.
  7262     root := MyHierarchicalItem new.
  7268     root icon:folderIcon.
  7263     root icon:folderIcon.
  7269     root label:((resources string:'[Compiled Packages]') asText allItalic withColor:Color grey).
  7264     root label:((resources string:'[Compiled Packages]') asText allItalic withColor:Color grey).
  7270     root type:#compiledPackagesRoot.
  7265     root type:#compiledPackagesRoot.
  7271     masterRoot add:root.
  7266     masterRoot add:root.
  7272 
  7267 
  7273     monticelloRoot := myHierarchicalItemWithLabelAndIcon new.
  7268     monticelloRoot := MyHierarchicalItem new.
  7274     monticelloLabel := ((resources string:'[Monticello Packages]') asText allItalic withColor:Color grey).
  7269     monticelloLabel := ((resources string:'[Monticello Packages]') asText allItalic withColor:Color grey).
  7275     monticelloRoot type:#monticelloRoot.
  7270     monticelloRoot type:#monticelloRoot.
  7276 
  7271 
  7277     (MCRepositoryGroup isNil or:[MCRepositoryGroup isLoaded not]) ifTrue:[
  7272     (MCRepositoryGroup isNil or:[MCRepositoryGroup isLoaded not]) ifTrue:[
  7278         monticelloRoot icon:greyFolderIcon.
  7273         monticelloRoot icon:greyFolderIcon.
  7415         ]
  7410         ]
  7416     ].
  7411     ].
  7417 !
  7412 !
  7418 
  7413 
  7419 filterChangedAction
  7414 filterChangedAction
  7420     |matchingItems filterPattern isMatch firstMatchingItem|
  7415     |newMatchingItems filterPattern isMatch firstMatchingItem|
  7421 
  7416 
  7422     filterPattern := filterHolder value.
  7417     filterPattern := filterHolder value.
  7423     filterPattern isEmptyOrNil ifTrue:[
  7418     filterPattern isEmptyOrNil ifTrue:[
  7424         "/ nothing
  7419         itemsMatchingFilter notEmptyOrNil ifTrue:[ 
  7425         root recursiveDo:[:item |
  7420             "/ nothing
  7426             item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
       
  7427         ].
       
  7428     ] ifFalse:[
       
  7429         filterPattern := filterPattern asLowercase.
       
  7430         isMatch := filterPattern includesMatchCharacters.
       
  7431 
       
  7432         matchingItems := OrderedCollection new.
       
  7433         masterRoot recursiveDo:[:item |
       
  7434             |itemLabel itemPackage|
       
  7435 
       
  7436             itemLabel := item label.
       
  7437             itemPackage := packageIdByItem at:item ifAbsent:''.
       
  7438 
       
  7439             ((isMatch and:[itemLabel matches:filterPattern caseSensitive:false])
       
  7440                 or:[ (isMatch not and:[ itemLabel asLowercase includesString:filterPattern ])
       
  7441                 or:[ (isMatch and:[itemPackage matches:filterPattern caseSensitive:false])
       
  7442                 or:[ isMatch not and:[ itemPackage asLowercase includesString:filterPattern ]]]])
       
  7443             ifTrue:[ 
       
  7444                 matchingItems add:item.
       
  7445             ]
       
  7446         ].
       
  7447         matchingItems isEmpty ifTrue:[
       
  7448             "/ nothing found
       
  7449             root recursiveDo:[:item |
  7421             root recursiveDo:[:item |
  7450                 item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
  7422                 item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
  7451             ].
  7423             ].
  7452             Screen current beep.
  7424         ].
  7453         ] ifFalse:[
  7425         itemsMatchingFilter := #().
  7454             "/ collapse all and fully expand all matching items
  7426         ^ self.
  7455             masterRoot recursiveDo:[:item |
  7427     ].
  7456                 item collapse.
  7428     
  7457                 item label:(item label copy asText allNonBold withColor:Color grey).
  7429     filterPattern := filterPattern asLowercase.
  7458             ].
  7430     isMatch := filterPattern includesMatchCharacters.
  7459             firstMatchingItem := nil.
  7431 
  7460             matchingItems do:[:item |
  7432     newMatchingItems := OrderedCollection new.
  7461                 item label:(item label copy asText allBold withoutAnyColorEmphasis).
  7433     masterRoot recursiveDo:[:item |
  7462                 item makeVisible.
  7434         |itemLabel itemPackage|
  7463                 firstMatchingItem := firstMatchingItem ? item.
  7435 
  7464             ].
  7436         itemLabel := item label.
  7465             hierarchicalListView makeLineVisible:firstMatchingItem listIndex.
  7437         itemPackage := packageIdByItem at:item ifAbsent:''.
  7466         ].
  7438 
  7467     ].
  7439         ((isMatch and:[itemLabel matches:filterPattern caseSensitive:false])
       
  7440             or:[ (isMatch not and:[ itemLabel asLowercase includesString:filterPattern ])
       
  7441             or:[ (isMatch and:[itemPackage matches:filterPattern caseSensitive:false])
       
  7442             or:[ isMatch not and:[ itemPackage asLowercase includesString:filterPattern ]]]])
       
  7443         ifTrue:[ 
       
  7444             newMatchingItems add:item.
       
  7445         ]
       
  7446     ].
       
  7447     (newMatchingItems sameContentsAs:itemsMatchingFilter) ifTrue:[
       
  7448         ^ self
       
  7449     ].    
       
  7450     
       
  7451     newMatchingItems isEmpty ifTrue:[
       
  7452         "/ nothing found
       
  7453         root recursiveDo:[:item |
       
  7454             item label:(item label copy asText allNonBold withoutAnyColorEmphasis).
       
  7455         ].
       
  7456         Screen current beep.
       
  7457     ] ifFalse:[
       
  7458         "/ collapse all and fully expand all matching items
       
  7459         masterRoot recursiveDo:[:item |
       
  7460             item collapse.
       
  7461             item label:(item label copy asText allNonBold withColor:Color grey).
       
  7462         ].
       
  7463         firstMatchingItem := nil.
       
  7464         newMatchingItems do:[:item |
       
  7465             item label:(item label copy asText allBold withoutAnyColorEmphasis).
       
  7466             item makeVisible.
       
  7467             firstMatchingItem := firstMatchingItem ? item.
       
  7468         ].
       
  7469         hierarchicalListView makeLineVisible:firstMatchingItem listIndex.
       
  7470     ].
       
  7471     itemsMatchingFilter := newMatchingItems.
  7468 !
  7472 !
  7469 
  7473 
  7470 getItemByPath:path packageID:packageID under:aRoot
  7474 getItemByPath:path packageID:packageID under:aRoot
  7471     "/ ensures an item for a path and returns it.
  7475     "/ ensures an item for a path and returns it.
  7472     "/ if not already present, the item is created as a folder
  7476     "/ if not already present, the item is created as a folder
  7476     item := path isEmpty   
  7480     item := path isEmpty   
  7477             ifTrue:[aRoot]
  7481             ifTrue:[aRoot]
  7478             ifFalse:[ itemsByPath at:( {aRoot label},path) ifAbsent:nil ].
  7482             ifFalse:[ itemsByPath at:( {aRoot label},path) ifAbsent:nil ].
  7479     item isNil ifTrue:[
  7483     item isNil ifTrue:[
  7480         parent := self getItemByPath:(path copyButLast) packageID:packageID under:aRoot.
  7484         parent := self getItemByPath:(path copyButLast) packageID:packageID under:aRoot.
  7481         item := myHierarchicalItemWithLabelAndIcon new
  7485         item := MyHierarchicalItem new
  7482                 children:#();
  7486                 children:#();
  7483                 icon:greyFolderIcon; 
  7487                 icon:greyFolderIcon; 
  7484                 label:path last.
  7488                 label:path last.
  7485         parent add:item.
  7489         parent add:item.
  7486         itemsByPath at:( {aRoot label},path) put:item.
  7490         itemsByPath at:( {aRoot label},path) put:item.
  7496     (MCRepositoryGroup default repositories 
  7500     (MCRepositoryGroup default repositories 
  7497         asSortedCollection:[:a :b |a displayString < b displayString])
  7501         asSortedCollection:[:a :b |a displayString < b displayString])
  7498             do:[:each |
  7502             do:[:each |
  7499                 |reposItem|
  7503                 |reposItem|
  7500 
  7504 
  7501                 reposItem := myHierarchicalItemWithLabelAndIcon new.
  7505                 reposItem := MyHierarchicalItem new.
  7502                 reposItem icon:folderIcon.
  7506                 reposItem icon:folderIcon.
  7503                 reposItem label:each displayString , ((resources string:' [MC Repository]') asText allItalic withColor:Color grey).
  7507                 reposItem label:each displayString , ((resources string:' [MC Repository]') asText allItalic withColor:Color grey).
  7504                 reposItem type:#monticelloRepository.
  7508                 reposItem type:#monticelloRepository.
  7505                 reposItem info:each.
  7509                 reposItem info:each.
  7506                 monticelloRoot add:reposItem.
  7510                 monticelloRoot add:reposItem.
  7507 
  7511 
  7508                 each allPackageNames asSortedCollection do:[:eachPackage |
  7512                 each allPackageNames asSortedCollection do:[:eachPackage |
  7509                     |packageItem|
  7513                     |packageItem|
  7510 
  7514 
  7511                     packageItem := myHierarchicalItemWithLabelAndIcon new.
  7515                     packageItem := MyHierarchicalItem new.
  7512                     packageItem icon:packageIcon.
  7516                     packageItem icon:packageIcon.
  7513                     packageItem label:eachPackage.
  7517                     packageItem label:eachPackage.
  7514                     packageItem type:#monticelloPackage.
  7518                     packageItem type:#monticelloPackage.
  7515                     reposItem add:packageItem.
  7519                     reposItem add:packageItem.
  7516                 ]
  7520                 ]
  7726                         |path|
  7730                         |path|
  7727                         
  7731                         
  7728                         path := subDir asFilename components.
  7732                         path := subDir asFilename components.
  7729                         (itemsByPath at:( {root label},path) ifAbsent:nil) isNil ifTrue:[
  7733                         (itemsByPath at:( {root label},path) ifAbsent:nil) isNil ifTrue:[
  7730                             folderRoot isNil ifTrue:[
  7734                             folderRoot isNil ifTrue:[
  7731                                 folderRoot := myHierarchicalItemWithLabelAndIcon new.
  7735                                 folderRoot := MyHierarchicalItem new.
  7732                                 folderRoot icon:folderIcon.
  7736                                 folderRoot icon:folderIcon.
  7733                                 folderRoot label:((resources string:'[%1]' with:eachDirName) asText allItalic withColor:Color grey).
  7737                                 folderRoot label:((resources string:'[%1]' with:eachDirName) asText allItalic withColor:Color grey).
  7734                                 folderRoot type:#compiledPackagesRoot.
  7738                                 folderRoot type:#compiledPackagesRoot.
  7735                             ].    
  7739                             ].    
  7736                             self 
  7740                             self 
  8065             ].
  8069             ].
  8066         ].
  8070         ].
  8067     ].
  8071     ].
  8068 ! !
  8072 ! !
  8069 
  8073 
       
  8074 !AbstractLauncherApplication::PackageLoadDialog::MyHierarchicalItem methodsFor:'accessing'!
       
  8075 
       
  8076 info
       
  8077     ^ info
       
  8078 !
       
  8079 
       
  8080 info:something
       
  8081     info := something.
       
  8082 !
       
  8083 
       
  8084 type
       
  8085     ^ type
       
  8086 !
       
  8087 
       
  8088 type:something
       
  8089     type := something.
       
  8090 ! !
       
  8091 
  8070 !AbstractLauncherApplication class methodsFor:'documentation'!
  8092 !AbstractLauncherApplication class methodsFor:'documentation'!
  8071 
  8093 
  8072 version
  8094 version
  8073     ^ '$Header$'
  8095     ^ '$Header$'
  8074 !
  8096 !