6117
|
1 |
"{ Package: 'stx:libbasic' }"
|
5996
|
2 |
|
|
3 |
Object subclass:#UserMessage
|
|
4 |
instanceVariableNames:'defaultString key catalogID'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Interface-Internationalization'
|
|
8 |
!
|
|
9 |
|
6008
|
10 |
!UserMessage class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
added for vw5i compatibility, which accesses messageCatalogs
|
|
15 |
via:
|
|
16 |
(#key << #catalogID >> 'defaultMessage')
|
|
17 |
which creates an instance of UserMessage.
|
|
18 |
|
|
19 |
Currently, this is a dummy operation in ST/X, however it is mapped onto
|
|
20 |
the resource mechanism, if the given catalogID is the name of a class;
|
|
21 |
i.e.
|
|
22 |
(YesNoBox classResources string:'continue')
|
|
23 |
can now also be written as:
|
|
24 |
(#continue << #YesNoBox)
|
|
25 |
"
|
|
26 |
! !
|
5996
|
27 |
|
|
28 |
!UserMessage class methodsFor:'instance creation'!
|
|
29 |
|
|
30 |
key:aKeySymbol catalogID:aCatalogSymbol
|
|
31 |
^ self new key:aKeySymbol catalogID:aCatalogSymbol
|
|
32 |
!
|
|
33 |
|
|
34 |
key:aKeySymbol defaultString:aString
|
|
35 |
^ self new key:aKeySymbol defaultString:aString
|
|
36 |
! !
|
|
37 |
|
|
38 |
!UserMessage methodsFor:'accessing'!
|
|
39 |
|
|
40 |
catalogID
|
|
41 |
^ catalogID
|
|
42 |
!
|
|
43 |
|
|
44 |
catalogID:aCatalogSymbol
|
|
45 |
catalogID := aCatalogSymbol
|
|
46 |
!
|
|
47 |
|
|
48 |
defaultString
|
|
49 |
^ defaultString
|
|
50 |
!
|
|
51 |
|
|
52 |
defaultString:aString
|
|
53 |
defaultString := aString
|
|
54 |
!
|
|
55 |
|
|
56 |
key
|
|
57 |
^ key
|
|
58 |
!
|
|
59 |
|
|
60 |
key:aKeySymbol
|
|
61 |
key := aKeySymbol.
|
|
62 |
!
|
|
63 |
|
|
64 |
key:aKeySymbol catalogID:aCatalogSymbol
|
|
65 |
key := aKeySymbol.
|
|
66 |
catalogID := aCatalogSymbol
|
|
67 |
!
|
|
68 |
|
|
69 |
key:aKeySymbol defaultString:aString
|
|
70 |
key := aKeySymbol.
|
|
71 |
defaultString := aString
|
|
72 |
! !
|
|
73 |
|
|
74 |
!UserMessage methodsFor:'converting'!
|
|
75 |
|
|
76 |
asString
|
|
77 |
"for now: return the defaultString, ignoring the catalogID."
|
|
78 |
|
|
79 |
|str|
|
|
80 |
|
|
81 |
str := self lookupInMessageCatalog.
|
|
82 |
str notNil ifTrue:[ ^ str ].
|
|
83 |
defaultString notNil ifTrue:[
|
|
84 |
^ defaultString
|
|
85 |
].
|
|
86 |
^ key asString
|
6117
|
87 |
!
|
|
88 |
|
|
89 |
expandMacros
|
|
90 |
^ self asString expandMacros
|
|
91 |
|
|
92 |
!
|
|
93 |
|
|
94 |
expandMacrosWith:arg1
|
|
95 |
^ self asString expandMacrosWith:arg1
|
|
96 |
|
5996
|
97 |
! !
|
|
98 |
|
6591
|
99 |
!UserMessage methodsFor:'printing & storing'!
|
|
100 |
|
|
101 |
displayString
|
|
102 |
|
|
103 |
|stream|
|
|
104 |
|
|
105 |
stream := '' writeStream.
|
|
106 |
|
|
107 |
key storeOn:stream.
|
|
108 |
stream nextPutAll:' << '.
|
|
109 |
catalogID storeOn:stream.
|
6887
|
110 |
defaultString notNil ifTrue:[
|
|
111 |
stream nextPutAll:' >> '.
|
|
112 |
defaultString storeOn:stream.
|
|
113 |
].
|
6591
|
114 |
^ stream contents.
|
|
115 |
! !
|
|
116 |
|
5996
|
117 |
!UserMessage methodsFor:'utilities'!
|
|
118 |
|
|
119 |
<< aSymbol
|
|
120 |
"set the catalogID"
|
|
121 |
|
|
122 |
self catalogID:aSymbol
|
|
123 |
!
|
|
124 |
|
|
125 |
>> aString
|
|
126 |
"set the default string"
|
|
127 |
|
|
128 |
self defaultString:aString
|
|
129 |
|
|
130 |
"
|
|
131 |
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass')
|
|
132 |
"
|
|
133 |
!
|
|
134 |
|
|
135 |
lookupInMessageCatalog
|
6887
|
136 |
|messageCatalog|
|
5996
|
137 |
|
6887
|
138 |
"/ for now - handle the case that the catalogID is
|
5996
|
139 |
"/ a classes name; in that case, ask its resourcePack.
|
|
140 |
|
6887
|
141 |
catalogID isSymbol ifTrue:[
|
|
142 |
messageCatalog := Smalltalk at:catalogID.
|
|
143 |
] ifFalse:[
|
|
144 |
messageCatalog := catalogID.
|
|
145 |
].
|
|
146 |
messageCatalog isBehavior ifTrue:[
|
|
147 |
messageCatalog := messageCatalog classResources.
|
5996
|
148 |
].
|
6887
|
149 |
messageCatalog isNil ifTrue:[
|
|
150 |
defaultString isNil ifTrue:[
|
|
151 |
^ 'Non-existant message (%1<<%2)' bindWith:key with:catalogID printString.
|
|
152 |
].
|
|
153 |
^ defaultString.
|
|
154 |
].
|
|
155 |
|
|
156 |
^ messageCatalog at:key ifAbsent:defaultString.
|
5996
|
157 |
|
|
158 |
"
|
|
159 |
(#'WARN_RENAME' << #BrowserView >> 'A class named %1 already exists (in ''%2'')\\that class will no longer be visible (i.e. removed) if you continue.\\Continue ?' )
|
6887
|
160 |
(#'WARN_RENAME' << #BrowserView)
|
|
161 |
(#'WARN_RENAME' << BrowserView classResources)
|
|
162 |
(#dontKnow << #nonExistantMessageCatalog) asString
|
5996
|
163 |
"
|
|
164 |
! !
|
|
165 |
|
|
166 |
!UserMessage class methodsFor:'documentation'!
|
|
167 |
|
|
168 |
version
|
17711
|
169 |
^ '$Id: UserMessage.st 10447 2009-06-14 13:09:55Z vranyj1 $'
|
5996
|
170 |
! !
|