ResourceRetriever.st
changeset 399 0822ecf56bf2
parent 378 9057ea063eca
child 476 05adf036c0ac
equal deleted inserted replaced
398:155310ec83aa 399:0822ecf56bf2
    16 Object subclass:#ResourceRetriever
    16 Object subclass:#ResourceRetriever
    17 	instanceVariableNames:'className resourceOwner selector labelText'
    17 	instanceVariableNames:'className resourceOwner selector labelText'
    18 	classVariableNames:''
    18 	classVariableNames:''
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-Support-UI'
    20 	category:'Interface-Support-UI'
       
    21 !
       
    22 
       
    23 ResourceRetriever class instanceVariableNames:'LabelResources'
       
    24 
       
    25 "
       
    26  The following class instance variables are inherited by this class:
       
    27 
       
    28 	Object - 
       
    29 "
    21 !
    30 !
    22 
    31 
    23 !ResourceRetriever class methodsFor:'documentation'!
    32 !ResourceRetriever class methodsFor:'documentation'!
    24 
    33 
    25 copyright
    34 copyright
    65 
    74 
    66 
    75 
    67 
    76 
    68 ! !
    77 ! !
    69 
    78 
       
    79 !ResourceRetriever class methodsFor:'accessing resource'!
       
    80 
       
    81 findResourceLabel: label in: aResourceOwner
       
    82     "look for a string 
       
    83         in aResourceOwner, 
       
    84         in class of aResourceOwner,
       
    85         in resources of class of aResourceOwner,
       
    86         and finally in my label resources
       
    87     "
       
    88 
       
    89     aResourceOwner isNil ifTrue: [^label].
       
    90 
       
    91     label isSymbol
       
    92     ifTrue:
       
    93     [
       
    94         (aResourceOwner respondsTo: label)
       
    95         ifTrue:
       
    96         [           
       
    97             ^aResourceOwner perform: label
       
    98         ].
       
    99 
       
   100         (aResourceOwner isClass not and: [aResourceOwner class respondsTo: label])
       
   101         ifTrue:
       
   102         [            
       
   103             ^aResourceOwner perform: label
       
   104         ].
       
   105     ].
       
   106 
       
   107     ((aResourceOwner isKindOf: ApplicationModel) or: 
       
   108     [aResourceOwner isKindOf: SimpleView]) 
       
   109     ifTrue:
       
   110     [
       
   111         ^aResourceOwner resources string: label
       
   112     ].
       
   113 
       
   114     ^self labelResources string:label
       
   115   
       
   116 !
       
   117 
       
   118 labelResources
       
   119     "if not already loaded, get the common label resourcePack
       
   120      and return it"
       
   121 
       
   122     LabelResources isNil ifTrue:[
       
   123         LabelResources := ResourcePack for:self.
       
   124     ].
       
   125     ^ LabelResources
       
   126 ! !
       
   127 
    70 !ResourceRetriever methodsFor:'accessing'!
   128 !ResourceRetriever methodsFor:'accessing'!
    71 
   129 
    72 className
   130 className
    73     "return the value of the instance variable 'className' (automatically generated)"
   131     "return the value of the instance variable 'className' (automatically generated)"
    74 
   132