AbstractLauncherApplication.st
changeset 15355 442c5e018df2
parent 15352 f62436b30ab8
child 15367 2391b2f27591
equal deleted inserted replaced
15354:5d0ff32c0807 15355:442c5e018df2
   246     ^ SettingsDialog defaultSettingsApplicationList
   246     ^ SettingsDialog defaultSettingsApplicationList
   247 !
   247 !
   248 
   248 
   249 expandSettingsList:rawList
   249 expandSettingsList:rawList
   250     "this expands a raw settings list,
   250     "this expands a raw settings list,
   251      by looking for entries with '[...]' in their class name.
   251      by looking for entries with a block in their class name.
   252      If any such is present, it is evaluated as a block, returning
   252      If any such is present, it is evaluated, returning
   253      a collection of actual entries to use.
   253      a collection of actual entries to use. Then, also % entries in
       
   254      the name and icon are evaluated by sending corresponding messages
       
   255      to the collected classes.
   254      This allows for easy dynamic construction of more complicated
   256      This allows for easy dynamic construction of more complicated
   255      lists, for example to adapt to the set of loaded classes dynamically."
   257      lists, for example to adapt to the set of loaded classes dynamically."
   256 
   258 
   257     "I am not sure. if this is is a good idea; although it makes heavy use of
   259     "I am not sure. if this is is a good idea; although it makes heavy use of
   258      Smalltalk's dynamic features, it is probably better done differently
   260      Smalltalk's dynamic features, it is probably better done differently
   259      (using a brace construct, to generate the entries).
   261      (letting the caller do this).
   260      use of a string which is evaluated makes it harder to debug, and also
   262      The code here is harder to debug, and understand"
   261      harder to find using the browser's sender/implementor search functions"
       
   262     
   263     
   263     |cookedList settingsList|
   264     |cookedList settingsList|
   264 
   265 
   265     cookedList := OrderedCollection new.
   266     cookedList := OrderedCollection new.
   266 
   267 
   267     rawList do:[:eachEntry|
   268     rawList do:[:eachEntry|
   268         |treeName className newEntry code classList name nameCode nameBlock nameList iconCode iconBlock|
   269         |treeName classNameOrBlock newEntry code classList name nameCode nameBlock nameList iconCode iconBlock|
   269 
   270 
   270         className := eachEntry at:2 ifAbsent:nil.
   271         classNameOrBlock := eachEntry at:2 ifAbsent:nil.
   271         (className notNil and:[className startsWith:'[']) ifTrue:[
   272         classNameOrBlock isBlock ifTrue:[
   272             code := className copyFrom:2 to:(className size - 1).
   273             classList := classNameOrBlock value select:[:clsOrNil | clsOrNil notNil].
   273             classList := (Parser evaluate:code) select:[:clsOrNil | clsOrNil notNil].
       
   274             name := eachEntry at:1.
   274             name := eachEntry at:1.
   275             self assert:(name includesString:'[').
   275             self assert:(name includesString:'[').
   276 
   276 
   277             nameCode := name copyFrom:(name indexOf:$[)+1 to:(name indexOf:$])-1.
   277             nameCode := name copyFrom:(name indexOf:$[)+1 to:(name indexOf:$])-1.
   278             nameCode := '^ [:each | ' , (nameCode copyReplaceString:'%' withString:'each') ,']'.
   278             nameCode := '^ [:each | ' , (nameCode copyReplaceString:'%' withString:'each') ,']'.
   287                 newEntry at:1 put:(name copyTo:(name indexOf:$[)-1),eachName.
   287                 newEntry at:1 put:(name copyTo:(name indexOf:$[)-1),eachName.
   288                 newEntry at:2 put:eachClass name.
   288                 newEntry at:2 put:eachClass name.
   289                 cookedList add:newEntry.
   289                 cookedList add:newEntry.
   290             ].
   290             ].
   291         ] ifFalse:[
   291         ] ifFalse:[
   292             (className isNil "a directory entry"
   292             (classNameOrBlock isNil "a directory entry"
   293             or:[ (Smalltalk at:className) notNil "a valid entry"]) ifTrue:[
   293             or:[ (Smalltalk at:classNameOrBlock) notNil "a valid entry"]) ifTrue:[
   294                 cookedList add:eachEntry.
   294                 cookedList add:eachEntry.
   295             ] ifFalse:[
   295             ] ifFalse:[
   296                 className notNil ifTrue:[
   296                 classNameOrBlock notNil ifTrue:[
   297                     Transcript showCR:'Launcher: missing settings class: ',className.
   297                     Transcript showCR:'Launcher: missing settings class: ',classNameOrBlock.
   298                 ].
   298                 ].
   299             ].
   299             ].
   300         ].
   300         ].
   301     ].
   301     ].
   302 
   302 
  7052 ! !
  7052 ! !
  7053 
  7053 
  7054 !AbstractLauncherApplication class methodsFor:'documentation'!
  7054 !AbstractLauncherApplication class methodsFor:'documentation'!
  7055 
  7055 
  7056 version
  7056 version
  7057     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.471 2015-02-21 13:42:56 cg Exp $'
  7057     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.472 2015-02-21 14:15:37 cg Exp $'
  7058 !
  7058 !
  7059 
  7059 
  7060 version_CVS
  7060 version_CVS
  7061     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.471 2015-02-21 13:42:56 cg Exp $'
  7061     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.472 2015-02-21 14:15:37 cg Exp $'
  7062 !
  7062 !
  7063 
  7063 
  7064 version_SVN
  7064 version_SVN
  7065     ^ '$Id: AbstractLauncherApplication.st,v 1.471 2015-02-21 13:42:56 cg Exp $'
  7065     ^ '$Id: AbstractLauncherApplication.st,v 1.472 2015-02-21 14:15:37 cg Exp $'
  7066 ! !
  7066 ! !
  7067 
  7067