NewLauncher.st
changeset 15238 9bd14234e90e
parent 15235 aa33f7381cf0
child 15239 33e62506afb2
--- a/NewLauncher.st	Sun Feb 08 10:51:57 2015 +0100
+++ b/NewLauncher.st	Mon Feb 09 14:56:55 2015 +0100
@@ -3400,13 +3400,14 @@
      add remote packages (central goody repository?),
      add a description text view, showing more info about the package (from where?)"    
 
-    |l masterRoot root monticelloRoot dialog filter filterHolder v itemsByPath getItemByPath packageIdByItem packageID
+    |l masterRoot root dialog filter filterHolder v itemsByPath getItemByPath packageIdByItem packageID
      packageIcon greyPackageIcon applicationIcon greyApplicationIcon 
      folderIcon greyFolderIcon
      browse packageDirPath 
      loadAction updateAction filterChangedAction selectionChangeAction showPackageInfoAction
      hierarchicalListView itemMenuGenerator
-     resources selectedPackageLabel selectedPackageHolder infoView infoTextHolder|
+     resources selectedPackageLabel selectedPackageHolder infoView infoTextHolder
+     monticelloRoot monticelloLabel myHierarchicalItemWithLabelAndIcon|
 
     resources := self resources.
 
@@ -3423,6 +3424,21 @@
     itemsByPath := Dictionary new.
     packageIdByItem := IdentityDictionary new.
 
+    Class withoutUpdatingChangesDo:[
+        myHierarchicalItemWithLabelAndIcon := 
+            HierarchicalItemWithLabelAndIcon 
+                subclass:#myHierarchicalItemWithLabelAndIcon
+                instanceVariableNames:'type info'
+                classVariableNames:''
+                poolDictionaries:''
+                category:nil
+                inEnvironment:nil.
+            myHierarchicalItemWithLabelAndIcon compile:'type ^ type'.
+            myHierarchicalItemWithLabelAndIcon compile:'type:aSymbol type := aSymbol'.
+            myHierarchicalItemWithLabelAndIcon compile:'info ^ info'.
+            myHierarchicalItemWithLabelAndIcon compile:'info:anObject info := anObject'.
+    ].
+
     "/ ensures an item for a path and returns it.
     "/ if not already present, the item is created as a folder
     getItemByPath := 
@@ -3434,7 +3450,7 @@
                     ifFalse:[ itemsByPath at:path ifAbsent:nil ].
             item isNil ifTrue:[
                 parent := getItemByPath value:(path copyButLast).
-                item := HierarchicalItemWithLabelAndIcon new
+                item := myHierarchicalItemWithLabelAndIcon new
                         children:#();
                         icon:greyFolderIcon; 
                         label:path last.
@@ -3448,43 +3464,51 @@
 
     l := HierarchicalList new.
 
-    masterRoot := HierarchicalItemWithLabelAndIcon new.
+    masterRoot := myHierarchicalItemWithLabelAndIcon new.
     masterRoot icon:(ToolbarIconLibrary stxHomeIcon).
     masterRoot label:(resources string:'local ').
 
-    root := HierarchicalItemWithLabelAndIcon new.
+    root := myHierarchicalItemWithLabelAndIcon new.
     root icon:folderIcon.
     root label:((resources string:'[Compiled Packages]') asText allItalic colorizeAllWith:Color grey).
+    root type:#compiledPackagesRoot.
     masterRoot add:root.
 
-"/ as yet unfinished - to give you an idea where we are going to...
-false ifTrue:[
-    monticelloRoot := HierarchicalItemWithLabelAndIcon new.
-    monticelloRoot icon:folderIcon.
-    monticelloRoot label:((resources string:'[Monticello Packages]') asText allItalic colorizeAllWith:Color grey).
+    monticelloRoot := myHierarchicalItemWithLabelAndIcon new.
+    monticelloLabel := ((resources string:'[Monticello Packages]') asText allItalic colorizeAllWith:Color grey).
+    monticelloRoot type:#monticelloRoot.
+
+    MCRepositoryGroup isNil ifTrue:[
+        monticelloRoot icon:greyFolderIcon.
+        monticelloRoot label:monticelloLabel, (' (Monticello Support not Loaded)' asText colorizeAllWith:Color grey).
+    ] ifFalse:[
+        monticelloRoot icon:folderIcon.
+        monticelloRoot label:monticelloLabel.
+        (MCRepositoryGroup default repositories 
+            asSortedCollection:[:a :b |a displayString < b displayString])
+                do:[:each |
+                    |reposItem|
+
+                    reposItem := myHierarchicalItemWithLabelAndIcon new.
+                    reposItem icon:folderIcon.
+                    reposItem label:each displayString , ((resources string:' [MC Repository]') asText allItalic colorizeAllWith:Color grey).
+                    reposItem type:#monticelloRepository.
+                    reposItem info:each.
+                    monticelloRoot add:reposItem.
+
+                    each allPackageNames asSortedCollection do:[:eachPackage |
+                        |packageItem|
+
+                        packageItem := myHierarchicalItemWithLabelAndIcon new.
+                        packageItem icon:packageIcon.
+                        packageItem label:eachPackage.
+                        packageItem type:#monticelloPackage.
+                        reposItem add:packageItem.
+                    ]
+                ].
+    ].
     masterRoot add:monticelloRoot.
 
-    MCRepositoryGroup notNil ifTrue:[
-        MCRepositoryGroup default repositories do:[:each |
-            |reposItem|
-
-            reposItem := HierarchicalItemWithLabelAndIcon new.
-            reposItem icon:folderIcon.
-            reposItem label:each displayString , ((resources string:' [MC Repository]') asText allItalic colorizeAllWith:Color grey).
-            monticelloRoot add:reposItem.
-
-            each allPackageNames asSortedCollection do:[:eachPackage |
-                |packageItem|
-
-                packageItem := HierarchicalItemWithLabelAndIcon new.
-                packageItem icon:packageIcon.
-                packageItem label:eachPackage.
-                reposItem add:packageItem.
-            ]
-        ].
-    ].
-].
-
     packageDirPath := Smalltalk getSystemFileName:'packages'.
     packageDirPath isNil ifTrue:[
         root label:root label,((resources string:' (no "packages" folder found)') colorizeAllWith:Color red).
@@ -3596,7 +3620,7 @@
                 isMatch := filterPattern includesMatchCharacters.
 
                 matchingItems := OrderedCollection new.
-                root recursiveDo:[:item |
+                masterRoot recursiveDo:[:item |
                     ((isMatch and:[item label matches:filterPattern caseSensitive:false])
                         or:[ isMatch not and:[ item label asLowercase includesString:filterPattern ]])
                     ifTrue:[ 
@@ -3611,7 +3635,7 @@
                     Screen current beep.
                 ] ifFalse:[
                     "/ collapse all and fully expand all matching items
-                    root recursiveDo:[:item |
+                    masterRoot recursiveDo:[:item |
                         item collapse.
                         item label:(item label copy asText allNonBold colorizeAllWith:Color grey).
                     ].
@@ -3629,28 +3653,35 @@
     loadAction :=
         [:doBrowse |
             (v scrolledView selectionValue) do:[:eachSelectedItem |
-                |package|
-
-                package := packageIdByItem at:eachSelectedItem ifAbsent:nil.
-                package notNil ifTrue:[
-                    dialog withWaitCursorDo:[
-                        Smalltalk onChangeSend:#value:value: to:updateAction.
-                        [
-                            Smalltalk loadPackage:package
-                        ] ensure:[
-                            Smalltalk retractInterestsFor:updateAction.
-                        ]
-                    ].
-                    doBrowse ifTrue:[
-                        Tools::NewSystemBrowser openOnPackage:package
-                    ].
-                    eachSelectedItem icon == packageIcon ifTrue:[
-                        eachSelectedItem icon:greyPackageIcon.
-                        eachSelectedItem label:(eachSelectedItem label , ' (already loaded)' asText allItalic).
-                    ] ifFalse:[
-                        eachSelectedItem icon == applicationIcon ifTrue:[
-                            eachSelectedItem icon:greyApplicationIcon.
-                            eachSelectedItem label:(eachSelectedItem label , (resources string:' (already loaded)') asText allItalic).
+                |package repos|
+
+                eachSelectedItem type == #monticelloPackage ifTrue:[
+                    |repos|
+
+                    repos := eachSelectedItem parent info.                    
+                    MCRepositoryBrowser openOnRepository:repos forPackage:eachSelectedItem label.
+                ] ifFalse:[
+                    package := packageIdByItem at:eachSelectedItem ifAbsent:nil.
+                    package notNil ifTrue:[
+                        dialog withWaitCursorDo:[
+                            Smalltalk onChangeSend:#value:value: to:updateAction.
+                            [
+                                Smalltalk loadPackage:package
+                            ] ensure:[
+                                Smalltalk retractInterestsFor:updateAction.
+                            ]
+                        ].
+                        doBrowse ifTrue:[
+                            Tools::NewSystemBrowser openOnPackage:package
+                        ].
+                        eachSelectedItem icon == packageIcon ifTrue:[
+                            eachSelectedItem icon:greyPackageIcon.
+                            eachSelectedItem label:(eachSelectedItem label , ' (already loaded)' asText allItalic).
+                        ] ifFalse:[
+                            eachSelectedItem icon == applicationIcon ifTrue:[
+                                eachSelectedItem icon:greyApplicationIcon.
+                                eachSelectedItem label:(eachSelectedItem label , (resources string:' (already loaded)') asText allItalic).
+                            ].
                         ].
                     ].
                 ].
@@ -3730,16 +3761,20 @@
 
             selectionIndices size == 1 ifTrue:[
                 selectedItem := hierarchicalListView selectionValue first.
-                p := packageIdByItem at:selectedItem ifAbsent:nil.
-                p notNil ifTrue:[
-                    selectedPackageHolder value:(resources string:'Selected Package: "%1"' with:p allBold).
-                    showPackageInfoAction value:p.
+                selectedItem type == #monticelloRepository ifTrue:[
+                    infoTextHolder value:'Monticello repository.'.
                 ] ifFalse:[
-                    selectedItem == masterRoot ifTrue:[
-                        infoTextHolder value:'Packages found on the local machine.'
-                    ].
-                    selectedItem == root ifTrue:[
-                        infoTextHolder value:'Local packages as found in the "packages" folder.'
+                    p := packageIdByItem at:selectedItem ifAbsent:nil.
+                    p notNil ifTrue:[
+                        selectedPackageHolder value:(resources string:'Selected Package: "%1"' with:p allBold).
+                        showPackageInfoAction value:p.
+                    ] ifFalse:[
+                        selectedItem == masterRoot ifTrue:[
+                            infoTextHolder value:'Packages found on the local machine.'
+                        ].
+                        selectedItem == root ifTrue:[
+                            infoTextHolder value:'Local packages as found in the "packages" folder.'
+                        ].
                     ].
                 ].
             ] ifFalse:[
@@ -3749,23 +3784,34 @@
 
     itemMenuGenerator :=
         [
-            |m|
-
+            |item m|
+
+            item := hierarchicalListView selectionValue first.
             m := Menu new.
             m addItem:(MenuItem 
                         label: (resources string:'Open File Browser on Project''s Folder')
                         itemValue: [
-                            |i package dir|
-
-                            i := hierarchicalListView selectionValue first.
-                            package := packageIdByItem at:i ifAbsent:nil.
+                            |package dir|
+
+                            package := packageIdByItem at:item ifAbsent:nil.
                             package notNil ifTrue:[
                                 dir := Smalltalk packageDirectoryForPackageId:package.
                                 dir notNil ifTrue:[
                                     UserPreferences current fileBrowserClass openOn:dir.
                                 ]
-                            ]
+                            ].
                         ]).
+
+            item type == #monticelloPackage ifTrue:[
+                m addItem:(MenuItem 
+                            label: (resources string:'Browse Monticello Package')
+                            itemValue: [
+                                |repos|
+
+                                repos := item parent info.                    
+                                MCRepositoryBrowser openOnRepository:repos forPackage:item label.
+                            ]).
+            ].
             m
         ].
 
@@ -5607,14 +5653,14 @@
 !NewLauncher class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.525 2015-02-08 09:39:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.526 2015-02-09 13:56:55 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.525 2015-02-08 09:39:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.526 2015-02-09 13:56:55 cg Exp $'
 !
 
 version_SVN
-    ^ '$Id: NewLauncher.st,v 1.525 2015-02-08 09:39:38 cg Exp $'
+    ^ '$Id: NewLauncher.st,v 1.526 2015-02-09 13:56:55 cg Exp $'
 ! !