Added #installEntries:expand:
authorvrany
Sat, 15 Oct 2011 15:13:04 +0200
changeset 10824 b27d09ac800b
parent 10823 d2b998ed529e
child 10825 dac388560714
Added #installEntries:expand:
SettingsDialog.st
--- a/SettingsDialog.st	Sat Oct 15 12:46:19 2011 +0200
+++ b/SettingsDialog.st	Sat Oct 15 15:13:04 2011 +0200
@@ -565,7 +565,13 @@
 !
 
 showRoot:aBoolean
-    self applicationList showRoot:aBoolean
+
+    self applicationList showRoot:aBoolean.
+    aBoolean ifFalse:[
+        self applicationList root children do:[:e|e expand].
+    ]
+
+    "Modified: / 15-10-2011 / 12:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SettingsDialog methodsFor:'actions'!
@@ -844,6 +850,18 @@
     ].
 !
 
+installSettingsEntries: entries expand: expand
+
+    "Installs given settings list. If expand is true,
+     dynamic settings list is expanded"
+    
+    entries do:[ :entry| 
+        self installSettingsEntry:entry expand: expand
+    ].
+
+    "Created: / 15-10-2011 / 11:45:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 installSettingsEntry:entry
     |applName applClassOrNil iconHolderOrNil|
 
@@ -853,6 +871,77 @@
     self addApplClass:applClassOrNil withName:applName icon:iconHolderOrNil value
 !
 
+installSettingsEntry:entry expand: expand
+
+    | applName applClassOrNil iconHolderOrNil cookedList className code classList name nameCode nameBlock nameList|
+
+    expand ifFalse:[
+        applName := entry at:1.
+        applClassOrNil := entry at:2.
+        iconHolderOrNil := entry at:3 ifAbsent:nil.
+        self addApplClass:applClassOrNil withName:applName icon:iconHolderOrNil value.
+        ^self
+    ].
+
+    cookedList := OrderedCollection new.
+
+    className := entry at:2 ifAbsent:nil.
+    (className notNil and:[className startsWith:'[']) ifTrue:[
+        code := className copyFrom:2 to:(className size - 1).
+        classList := (Parser evaluate:code) select:[:clsOrNil | clsOrNil notNil].
+        name := entry at:1.
+        self assert:(name includesString:'[').
+
+        nameCode := name copyFrom:(name indexOf:$[)+1 to:(name indexOf:$])-1.
+        nameCode := '^ [:each | ' , (nameCode copyReplaceString:'%' withString:'each') ,']'.
+        nameBlock := Parser evaluate:nameCode.
+
+        nameList := classList collect:nameBlock.
+        nameList sortWith:classList.
+        nameList with:classList do:[:eachName :eachClass |
+            |newEntry|
+
+            newEntry := entry copy.
+            newEntry at:1 put:(name copyTo:(name indexOf:$[)-1),eachName.
+            newEntry at:2 put:eachClass name.
+            cookedList add:newEntry.
+        ].
+    ] ifFalse:[
+        (className isNil "a directory entry"
+        or:[ (Smalltalk at:className) notNil "a valid entry"]) ifTrue:[
+            cookedList add:entry.
+        ].
+    ].
+
+    cookedList do:[:eachEntry |
+        |iconCodeOrSelector iconCode iconBlock newEntry|
+
+        iconCodeOrSelector := eachEntry at:3 ifAbsent:nil.
+        iconCodeOrSelector isNil ifTrue:[
+            newEntry := eachEntry
+        ] ifFalse:[
+            newEntry := eachEntry copy.
+            (iconCodeOrSelector startsWith:'[') ifTrue:[
+                iconCode := iconCodeOrSelector copyFrom:(iconCodeOrSelector indexOf:$[)+1 to:(iconCodeOrSelector indexOf:$])-1.
+                iconCode := '^ [:each | ' , (iconCode copyReplaceString:'%' withString:'each') ,']'.
+                iconBlock := Parser evaluate:iconCode.
+                newEntry at:3 put:(iconBlock value:(Smalltalk classNamed:(eachEntry at:2))).
+            ] ifFalse:[
+                newEntry at:3 put:(self perform:iconCodeOrSelector).
+            ].
+        ].
+        self installSettingsEntry:newEntry expand: false.
+    ].
+
+    "
+     self withAllSubclassesDo:[:cls | cls initializeSettingsList ]
+    "
+
+    "Modified: / 16-12-2002 / 18:12:50 / penk"
+    "Modified: / 20-04-2011 / 17:03:33 / cg"
+    "Created: / 15-10-2011 / 11:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 parentApplicationFor:aApplication
     |item parent|
 
@@ -1480,11 +1569,11 @@
 !SettingsDialog class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.95 2011-10-03 15:30:14 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.96 2011-10-15 13:13:04 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.95 2011-10-03 15:30:14 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.96 2011-10-15 13:13:04 vrany Exp $'
 !
 
 version_SVN