only ask once for resources (remember locally)
authorClaus Gittinger <cg@exept.de>
Fri, 01 Sep 2000 12:17:27 +0200
changeset 1401 0fda9891ba4a
parent 1400 8a7b55b08bf3
child 1402 bc51abc1c7fd
only ask once for resources (remember locally)
Menu.st
MenuItem.st
ResourceRetriever.st
--- a/Menu.st	Thu Aug 31 12:04:08 2000 +0200
+++ b/Menu.st	Fri Sep 01 12:17:27 2000 +0200
@@ -412,12 +412,23 @@
 findGuiResourcesIn:aResourceContainerOrApplication
     "setup a resource owner
     "
+    ^ self 
+        findGuiResourcesIn:aResourceContainerOrApplication 
+        rememberResourcesIn:(ValueHolder new)
+!
+
+findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
+    "setup a resource owner
+    "
     aResourceContainerOrApplication notNil ifTrue:[
-	items notNil ifTrue:[
-	    items do:[:anItem| anItem findGuiResourcesIn:aResourceContainerOrApplication ]
-	]
+        items notNil ifTrue:[
+            items do:[:anItem | 
+                anItem 
+                    findGuiResourcesIn:aResourceContainerOrApplication 
+                    rememberResourcesIn:aValueHolderOrNil
+            ]
+        ]
     ]
-
 ! !
 
 !Menu methodsFor:'adding & removing'!
@@ -949,5 +960,5 @@
 !Menu class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.45 2000-08-21 22:44:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.46 2000-09-01 10:16:54 cg Exp $'
 ! !
--- a/MenuItem.st	Thu Aug 31 12:04:08 2000 +0200
+++ b/MenuItem.st	Fri Sep 01 12:17:27 2000 +0200
@@ -550,6 +550,34 @@
     ]
 
     "Modified: / 18.6.1998 / 16:54:25 / cg"
+!
+
+findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
+    "setup a resource container
+    "
+    |lblImg m|
+
+    self translateLabel ifTrue:[
+        label := ResourceRetriever 
+                        findResourceLabel:label 
+                        in:aResourceContainerOrApplication
+                        rememberResourcesIn:aValueHolderOrNil
+    ].
+
+    adornment notNil ifTrue:[
+        (lblImg := adornment labelImage) notNil ifTrue:[   
+            lblImg findGuiResourcesIn:aResourceContainerOrApplication.
+            lblImg labelText notNil ifTrue: [lblImg labelText: label].
+        ].   
+        (m := adornment submenu) notNil ifTrue:[
+            m := m value.
+            m notNil ifTrue:[
+                m findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
+            ]
+        ].
+    ]
+
+    "Modified: / 18.6.1998 / 16:54:25 / cg"
 ! !
 
 !MenuItem methodsFor:'converting'!
@@ -1030,5 +1058,5 @@
 !MenuItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.40 2000-05-05 09:27:41 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.41 2000-09-01 10:17:13 cg Exp $'
 ! !
--- a/ResourceRetriever.st	Thu Aug 31 12:04:08 2000 +0200
+++ b/ResourceRetriever.st	Fri Sep 01 12:17:27 2000 +0200
@@ -111,6 +111,47 @@
   
 !
 
+findResourceLabel:label in:aResourceOwner rememberResourcesIn:aValueHolderOrNil
+    "look for a string 
+        in aResourceOwner, 
+        in class of aResourceOwner,
+        in resources of class of aResourceOwner,
+        and finally in my label resources
+    "
+
+    |resources|
+
+    aResourceOwner isNil ifTrue: [^label].
+
+    label isSymbol ifTrue:[
+        (aResourceOwner respondsTo: label) ifTrue:[           
+            ^ aResourceOwner perform:label
+        ].
+
+        (aResourceOwner isClass not 
+        and: [aResourceOwner class respondsTo: label])
+        ifTrue:[            
+            ^ aResourceOwner perform:label
+        ].
+    ].
+
+    resources := aValueHolderOrNil value.
+    resources isNil ifTrue:[
+        resources := aResourceOwner perform:#resources ifNotUnderstood:nil.
+        resources notNil ifTrue:[
+            aValueHolderOrNil notNil ifTrue:[
+                aValueHolderOrNil value:resources
+            ]
+        ]
+    ].
+    resources notNil ifTrue:[
+        ^ resources string:label
+    ].
+
+    ^ self labelResources string:label
+  
+!
+
 labelResources
     "if not already loaded, get the common label resourcePack
      and return it"
@@ -276,5 +317,5 @@
 !ResourceRetriever class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ResourceRetriever.st,v 1.3 2000-08-21 22:45:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ResourceRetriever.st,v 1.4 2000-09-01 10:17:27 cg Exp $'
 ! !