33 instanceVariableNames:'hierarchicalListView packageIdByItem pathByItem packageDirPath |
33 instanceVariableNames:'hierarchicalListView packageIdByItem pathByItem packageDirPath |
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 classVariableNames:'PreviousPackageDialogItems PreviousPackageDialogExtent' |
40 classVariableNames:'PreviousPackageDialogItems PreviousPackageDialogExtent' |
40 poolDictionaries:'' |
41 poolDictionaries:'' |
41 privateIn:AbstractLauncherApplication |
42 privateIn:AbstractLauncherApplication |
42 ! |
43 ! |
43 |
44 |
7154 |
7155 |
7155 openModal |
7156 openModal |
7156 self new openLoadPackageDialogModal:true |
7157 self new openLoadPackageDialogModal:true |
7157 ! ! |
7158 ! ! |
7158 |
7159 |
|
7160 !AbstractLauncherApplication::PackageLoadDialog methodsFor:'initialize & release'! |
|
7161 |
|
7162 initializeIcons |
|
7163 folderIcon := ToolbarIconLibrary directoryOpen18x18Icon. |
|
7164 "/ folderHalfGreyIcon := ToolbarIconLibrary directoryOpenHalfGrey18x18Icon. |
|
7165 packageIcon := ToolbarIconLibrary packageOpen24x24Icon. |
|
7166 applicationIcon := ToolbarIconLibrary makeYellow22x22Icon1. |
|
7167 greyFolderIcon := folderIcon asGrayImageDepth:8. |
|
7168 greyPackageIcon := packageIcon asGrayImageDepth:8. |
|
7169 greyApplicationIcon := applicationIcon asGrayImageDepth:(applicationIcon depth min:8). |
|
7170 ! |
|
7171 |
|
7172 release |
|
7173 |p| |
|
7174 |
|
7175 (p := backgroundPackageFindProcess) notNil ifTrue:[ |
|
7176 p isDead ifFalse:[ |
|
7177 p terminate |
|
7178 ] |
|
7179 ]. |
|
7180 super release |
|
7181 ! ! |
|
7182 |
7159 !AbstractLauncherApplication::PackageLoadDialog methodsFor:'opening'! |
7183 !AbstractLauncherApplication::PackageLoadDialog methodsFor:'opening'! |
7160 |
7184 |
7161 openLoadPackageDialog |
7185 openLoadPackageDialog |
7162 "open a dialog showing wellknown packages (listed in the packages directory) |
7186 "open a dialog showing wellknown packages (listed in the packages directory) |
7163 and offer to load the selected one(s). |
7187 and offer to load the selected one(s). |
7302 PreviousPackageDialogItems := itemsByPath. |
7328 PreviousPackageDialogItems := itemsByPath. |
7303 PreviousPackageDialogExtent := dialog extent. |
7329 PreviousPackageDialogExtent := dialog extent. |
7304 ! ! |
7330 ! ! |
7305 |
7331 |
7306 !AbstractLauncherApplication::PackageLoadDialog methodsFor:'private'! |
7332 !AbstractLauncherApplication::PackageLoadDialog methodsFor:'private'! |
|
7333 |
|
7334 addItemWithPackagePath:path target:target asApplication:isApplication toRoot:aRoot |
|
7335 |item isAlreadyLoaded defClass packageID| |
|
7336 |
|
7337 "/ see if already loaded |
|
7338 |
|
7339 packageID := (path size > 1) |
|
7340 ifTrue:[ path first , ':' , ((path copyFrom:2) asStringWith:$/) ] |
|
7341 ifFalse:[ path first ]. |
|
7342 |
|
7343 item := self getItemByPath:path packageID:packageID under:aRoot. |
|
7344 |
|
7345 isAlreadyLoaded := false. |
|
7346 Error handle:[:ex | |
|
7347 item label:(item label , (' ERROR - please rebuild!!' colorizeAllWith:Color red)). |
|
7348 ] do:[ |
|
7349 isAlreadyLoaded := |
|
7350 (defClass := ProjectDefinition definitionClassForPackage:packageID) notNil |
|
7351 and:[ defClass isLoaded |
|
7352 and:[ defClass isFullyLoaded ]]. |
|
7353 ]. |
|
7354 |
|
7355 target notNil ifTrue:[ |
|
7356 ((target startsWith:'lib ') or:[(target startsWith:'app ')]) ifTrue:[ |
|
7357 pathByItem at:item put:(target copyFrom:(target indexOfSeparator + 1)) withoutSeparators. |
|
7358 ]. |
|
7359 ]. |
|
7360 |
|
7361 "/ do not overwrite an app by a lib with the same name (happens in expecco/application) |
|
7362 (isApplication or:[ item icon isNil or:[item icon == folderIcon or:[item icon == greyFolderIcon]]]) ifTrue:[ |
|
7363 isAlreadyLoaded ifTrue:[ |
|
7364 item icon:(isApplication ifTrue:[greyApplicationIcon] ifFalse:[greyPackageIcon]). |
|
7365 item label:(item label , alreadyLoadedString) |
|
7366 ] ifFalse:[ |
|
7367 item icon:(isApplication ifTrue:[applicationIcon] ifFalse:[packageIcon]). |
|
7368 ]. |
|
7369 ]. |
|
7370 |
|
7371 "/ if it is not already loaded, make all parents non-grey |
|
7372 isAlreadyLoaded ifFalse:[ |
|
7373 path size-1 to:1 by:-1 do:[:n | |
|
7374 |parentPath parentItem| |
|
7375 |
|
7376 parentPath := path copyTo:n. |
|
7377 parentItem := self getItemByPath:parentPath packageID:packageID under:aRoot. |
|
7378 parentItem icon == greyFolderIcon ifTrue:[ |
|
7379 parentItem icon:folderIcon. |
|
7380 "/ ] ifFalse:[ |
|
7381 "/ parentItem icon == greyApplicationIcon ifTrue:[ |
|
7382 "/ parentItem icon:applicationIcon. |
|
7383 "/ ]. |
|
7384 ]. |
|
7385 ] |
|
7386 ]. |
|
7387 ! |
7307 |
7388 |
7308 filterChangedAction |
7389 filterChangedAction |
7309 |matchingItems filterPattern isMatch firstMatchingItem| |
7390 |matchingItems filterPattern isMatch firstMatchingItem| |
7310 |
7391 |
7311 filterPattern := filterHolder value. |
7392 filterPattern := filterHolder value. |
7354 hierarchicalListView makeLineVisible:firstMatchingItem listIndex. |
7435 hierarchicalListView makeLineVisible:firstMatchingItem listIndex. |
7355 ]. |
7436 ]. |
7356 ]. |
7437 ]. |
7357 ! |
7438 ! |
7358 |
7439 |
7359 getItemByPath:path packageID:packageID |
7440 getItemByPath:path packageID:packageID under:aRoot |
7360 "/ ensures an item for a path and returns it. |
7441 "/ ensures an item for a path and returns it. |
7361 "/ if not already present, the item is created as a folder |
7442 "/ if not already present, the item is created as a folder |
7362 |
7443 |
7363 |item parent subPackageID| |
7444 |item parent subPackageID| |
7364 |
7445 |
7365 item := path isEmpty |
7446 item := path isEmpty |
7366 ifTrue:[root] |
7447 ifTrue:[aRoot] |
7367 ifFalse:[ itemsByPath at:path ifAbsent:nil ]. |
7448 ifFalse:[ itemsByPath at:( {aRoot label},path) ifAbsent:nil ]. |
7368 item isNil ifTrue:[ |
7449 item isNil ifTrue:[ |
7369 parent := self getItemByPath:(path copyButLast) packageID:packageID. |
7450 parent := self getItemByPath:(path copyButLast) packageID:packageID under:aRoot. |
7370 item := myHierarchicalItemWithLabelAndIcon new |
7451 item := myHierarchicalItemWithLabelAndIcon new |
7371 children:#(); |
7452 children:#(); |
7372 icon:greyFolderIcon; |
7453 icon:greyFolderIcon; |
7373 label:path last. |
7454 label:path last. |
7374 parent add:item. |
7455 parent add:item. |
7375 itemsByPath at:path put:item. |
7456 itemsByPath at:( {aRoot label},path) put:item. |
7376 subPackageID := path size > 1 |
7457 subPackageID := path size > 1 |
7377 ifTrue:[ path first , ':' , ((path copyFrom:2) asStringWith:$/) ] |
7458 ifTrue:[ path first , ':' , ((path copyFrom:2) asStringWith:$/) ] |
7378 ifFalse:[ path first ]. |
7459 ifFalse:[ path first ]. |
7379 packageIdByItem at:item put:subPackageID. |
7460 packageIdByItem at:item put:subPackageID. |
7380 ]. |
7461 ]. |
7591 self loadPackageAndUpdate:subPackageID browse:false subPackages:true item:eachChild. |
7662 self loadPackageAndUpdate:subPackageID browse:false subPackages:true item:eachChild. |
7592 ]. |
7663 ]. |
7593 ]. |
7664 ]. |
7594 ! |
7665 ! |
7595 |
7666 |
|
7667 readOtherPackageTrees |
|
7668 |packagePath| |
|
7669 |
|
7670 packagePath := Smalltalk packagePath. |
|
7671 packagePath do:[:eachDirName | |
|
7672 |folderRoot eachDir| |
|
7673 |
|
7674 eachDir := eachDirName asFilename. |
|
7675 selectedPackageHolder value isNil ifTrue:[ |
|
7676 infoTextHolder value:('searching %1...' bindWith:eachDirName). |
|
7677 ]. |
|
7678 eachDir |
|
7679 recursiveDirectoryContentsWithPrefix:'' |
|
7680 filesDo:nil |
|
7681 directoriesDo:[:subDir | |
|
7682 |dfnBasename expectedDfnFilename| |
|
7683 |
|
7684 (eachDir / subDir / 'abbrev.stc') exists ifTrue:[ |
|
7685 "/ see if there is a project definition file in this dir |
|
7686 dfnBasename := subDir copyReplaceAll:(Filename separator) with:$_. |
|
7687 expectedDfnFilename := (eachDir / subDir / dfnBasename) withSuffix:'st'. |
|
7688 expectedDfnFilename exists ifTrue:[ |
|
7689 |path| |
|
7690 |
|
7691 path := subDir asFilename components. |
|
7692 (itemsByPath at:( {root label},path) ifAbsent:nil) isNil ifTrue:[ |
|
7693 folderRoot isNil ifTrue:[ |
|
7694 folderRoot := myHierarchicalItemWithLabelAndIcon new. |
|
7695 folderRoot icon:folderIcon. |
|
7696 folderRoot label:((resources string:'[%1]' with:eachDirName) asText allItalic colorizeAllWith:Color grey). |
|
7697 folderRoot type:#compiledPackagesRoot. |
|
7698 ]. |
|
7699 self |
|
7700 addItemWithPackagePath:path |
|
7701 target:nil |
|
7702 asApplication:false |
|
7703 toRoot:folderRoot. |
|
7704 ]. |
|
7705 ] |
|
7706 ]. |
|
7707 ]. |
|
7708 folderRoot notNil ifTrue:[ |
|
7709 masterRoot add:folderRoot. |
|
7710 ]. |
|
7711 ]. |
|
7712 selectedPackageHolder value isNil ifTrue:[ |
|
7713 infoTextHolder value:('done searching other package folders.'). |
|
7714 ]. |
|
7715 |
|
7716 "/ packageDirPath isNil ifTrue:[ |
|
7717 "/ root label:root label,((resources string:' (no "packages" folder found)') colorizeAllWith:Color red). |
|
7718 "/ ] ifFalse:[ |
|
7719 "/ packageDirPath asFilename directoryContentsAsFilenames sort do:[:fn | |
|
7720 "/ |item base nm path parentPath parent isLibrary isApplication isAlreadyLoaded |
|
7721 "/ defClass target packageID| |
|
7722 "/ |
|
7723 "/ ((fn suffix = 'mcz') |
|
7724 "/ or:[ fn isDirectory |
|
7725 "/ or:[ (fn baseName startsWith:'.') |
|
7726 "/ or:[ (fn baseName = 'README') ]]]) ifFalse:[ |
|
7727 "/ base := fn withoutSuffix baseName. |
|
7728 "/ (base startsWith:'lib') ifTrue:[ |
|
7729 "/ nm := (base copyFrom:4). |
|
7730 "/ fn suffix notEmptyOrNil ifTrue:[ |
|
7731 "/ isLibrary := true. |
|
7732 "/ isApplication := false. |
|
7733 "/ ] ifFalse:[ |
|
7734 "/ isLibrary := false. |
|
7735 "/ isApplication := true. |
|
7736 "/ ] |
|
7737 "/ ] ifFalse:[ |
|
7738 "/ nm := base. |
|
7739 "/ isLibrary := false. |
|
7740 "/ isApplication := true. |
|
7741 "/ ]. |
|
7742 "/ |
|
7743 "/ path := nm asCollectionOfSubstringsSeparatedBy:$_. |
|
7744 "/ "/ see if already loaded |
|
7745 "/ |
|
7746 "/ packageID := (path size > 1) |
|
7747 "/ ifTrue:[ path first , ':' , ((path copyFrom:2) asStringWith:$/) ] |
|
7748 "/ ifFalse:[ path first ]. |
|
7749 "/ |
|
7750 "/ item := self getItemByPath:path packageID:packageID. |
|
7751 "/ |
|
7752 "/ isAlreadyLoaded := false. |
|
7753 "/ Error handle:[:ex | |
|
7754 "/ item label:(item label , (' ERROR - please rebuild!!' colorizeAllWith:Color red)). |
|
7755 "/ ] do:[ |
|
7756 "/ isAlreadyLoaded := |
|
7757 "/ (defClass := ProjectDefinition definitionClassForPackage:packageID) notNil |
|
7758 "/ and:[ defClass isLoaded |
|
7759 "/ and:[ defClass isFullyLoaded ]]. |
|
7760 "/ ]. |
|
7761 "/ |
|
7762 "/ target := fn contents first. |
|
7763 "/ ((target startsWith:'lib ') or:[(target startsWith:'app ')]) ifTrue:[ |
|
7764 "/ pathByItem at:item put:(target copyFrom:(target indexOfSeparator + 1)) withoutSeparators. |
|
7765 "/ ]. |
|
7766 "/ |
|
7767 "/ "/ do not overwrite an app by a lib with the same name (happens in expecco/application) |
|
7768 "/ (isApplication or:[ item icon isNil or:[item icon == folderIcon or:[item icon == greyFolderIcon]]]) ifTrue:[ |
|
7769 "/ isAlreadyLoaded ifTrue:[ |
|
7770 "/ item icon:(isApplication ifTrue:[greyApplicationIcon] ifFalse:[greyPackageIcon]). |
|
7771 "/ item label:(item label , alreadyLoadedString) |
|
7772 "/ ] ifFalse:[ |
|
7773 "/ item icon:(isApplication ifTrue:[applicationIcon] ifFalse:[packageIcon]). |
|
7774 "/ ]. |
|
7775 "/ ]. |
|
7776 "/ |
|
7777 "/ "/ if it is not already loaded, make all parents non-grey |
|
7778 "/ isAlreadyLoaded ifFalse:[ |
|
7779 "/ path size-1 to:1 by:-1 do:[:n | |
|
7780 "/ |parentPath parentItem| |
|
7781 "/ |
|
7782 "/ parentPath := path copyTo:n. |
|
7783 "/ parentItem := self getItemByPath:parentPath packageID:packageID. |
|
7784 "/ parentItem icon == greyFolderIcon ifTrue:[ |
|
7785 "/ parentItem icon:folderIcon. |
|
7786 "/"/ ] ifFalse:[ |
|
7787 "/"/ parentItem icon == greyApplicationIcon ifTrue:[ |
|
7788 "/"/ parentItem icon:applicationIcon. |
|
7789 "/"/ ]. |
|
7790 "/ ]. |
|
7791 "/ ] |
|
7792 "/ ]. |
|
7793 "/ ]. |
|
7794 "/ ]. |
|
7795 "/ ]. |
|
7796 ! |
|
7797 |
|
7798 readOtherPackageTreesInBackground |
|
7799 backgroundPackageFindProcess := |
|
7800 [ |
|
7801 [ |
|
7802 self readOtherPackageTrees. |
|
7803 ] ensure:[ |
|
7804 backgroundPackageFindProcess := nil. |
|
7805 ]. |
|
7806 ] forkAt:(Processor userBackgroundPriority). |
|
7807 ! |
|
7808 |
7596 readPackageTree |
7809 readPackageTree |
7597 packageDirPath := Smalltalk getSystemFileName:'packages'. |
7810 packageDirPath := Smalltalk getSystemFileName:'packages'. |
7598 packageDirPath isNil ifTrue:[ |
7811 packageDirPath isNil ifTrue:[ |
7599 root label:root label,((resources string:' (no "packages" folder found)') colorizeAllWith:Color red). |
7812 root label:root label,((resources string:' (no "packages" folder found)') colorizeAllWith:Color red). |
7600 ] ifFalse:[ |
7813 ] ifFalse:[ |
7789 |
8010 |
7790 "/ update the corresponding tree item |
8011 "/ update the corresponding tree item |
7791 (whatChanged == #postPackageLoad or:[whatChanged == #postLoad]) ifTrue:[ |
8012 (whatChanged == #postPackageLoad or:[whatChanged == #postLoad]) ifTrue:[ |
7792 parameter notNil ifTrue:[ |
8013 parameter notNil ifTrue:[ |
7793 packageID := parameter asSymbol. |
8014 packageID := parameter asSymbol. |
7794 item := self getItemByPath:(packageID splitByAny:':/') packageID:packageID. |
8015 item := self getItemByPath:(packageID splitByAny:':/') packageID:packageID under:root. |
7795 item notNil ifTrue:[ |
8016 item notNil ifTrue:[ |
7796 isLoaded := (ProjectDefinition definitionClassForPackage:packageID) notNil. |
8017 isLoaded := (ProjectDefinition definitionClassForPackage:packageID) notNil. |
7797 isLoaded ifTrue:[ |
8018 isLoaded ifTrue:[ |
7798 (item icon == applicationIcon or:[item icon == packageIcon]) ifTrue:[ |
8019 (item icon == applicationIcon or:[item icon == packageIcon]) ifTrue:[ |
7799 item icon:((item icon == applicationIcon) ifTrue:[greyApplicationIcon] ifFalse:[greyPackageIcon]). |
8020 item icon:((item icon == applicationIcon) ifTrue:[greyApplicationIcon] ifFalse:[greyPackageIcon]). |