author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 20 Dec 2010 07:13:27 +0000 | |
branch | jv |
changeset 17814 | b75a7f0c346b |
parent 17807 | 06cc6c49e291 |
child 17834 | 04ff72c5039a |
permissions | -rw-r--r-- |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
1 |
" |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
3 |
All Rights Reserved |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
4 |
|
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
5 |
This software is furnished under a license and may be used |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
10 |
hereby transferred. |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
11 |
" |
6117 | 12 |
"{ Package: 'stx:libbasic' }" |
5996 | 13 |
|
14 |
Object subclass:#UserMessage |
|
15 |
instanceVariableNames:'defaultString key catalogID' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Internationalization' |
|
19 |
! |
|
20 |
||
6008 | 21 |
!UserMessage class methodsFor:'documentation'! |
22 |
||
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
23 |
copyright |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
24 |
" |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
26 |
All Rights Reserved |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
27 |
|
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
28 |
This software is furnished under a license and may be used |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
29 |
only in accordance with the terms of that license and with the |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
30 |
inclusion of the above copyright notice. This software may not |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
31 |
be provided or otherwise made available to, or used by, any |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
32 |
other person. No title to or ownership of the software is |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
33 |
hereby transferred. |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
34 |
" |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
35 |
! |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
36 |
|
6008 | 37 |
documentation |
38 |
" |
|
39 |
added for vw5i compatibility, which accesses messageCatalogs |
|
40 |
via: |
|
41 |
(#key << #catalogID >> 'defaultMessage') |
|
42 |
which creates an instance of UserMessage. |
|
43 |
||
44 |
Currently, this is a dummy operation in ST/X, however it is mapped onto |
|
45 |
the resource mechanism, if the given catalogID is the name of a class; |
|
46 |
i.e. |
|
47 |
(YesNoBox classResources string:'continue') |
|
48 |
can now also be written as: |
|
49 |
(#continue << #YesNoBox) |
|
50 |
" |
|
51 |
! ! |
|
5996 | 52 |
|
53 |
!UserMessage class methodsFor:'instance creation'! |
|
54 |
||
55 |
key:aKeySymbol catalogID:aCatalogSymbol |
|
56 |
^ self new key:aKeySymbol catalogID:aCatalogSymbol |
|
57 |
! |
|
58 |
||
59 |
key:aKeySymbol defaultString:aString |
|
60 |
^ self new key:aKeySymbol defaultString:aString |
|
61 |
! ! |
|
62 |
||
63 |
!UserMessage methodsFor:'accessing'! |
|
64 |
||
65 |
catalogID |
|
66 |
^ catalogID |
|
67 |
! |
|
68 |
||
69 |
catalogID:aCatalogSymbol |
|
70 |
catalogID := aCatalogSymbol |
|
71 |
! |
|
72 |
||
73 |
defaultString |
|
74 |
^ defaultString |
|
75 |
! |
|
76 |
||
77 |
defaultString:aString |
|
78 |
defaultString := aString |
|
79 |
! |
|
80 |
||
81 |
key |
|
82 |
^ key |
|
83 |
! |
|
84 |
||
85 |
key:aKeySymbol |
|
86 |
key := aKeySymbol. |
|
87 |
! |
|
88 |
||
89 |
key:aKeySymbol catalogID:aCatalogSymbol |
|
90 |
key := aKeySymbol. |
|
91 |
catalogID := aCatalogSymbol |
|
92 |
! |
|
93 |
||
94 |
key:aKeySymbol defaultString:aString |
|
95 |
key := aKeySymbol. |
|
96 |
defaultString := aString |
|
97 |
! ! |
|
98 |
||
99 |
!UserMessage methodsFor:'converting'! |
|
100 |
||
101 |
asString |
|
102 |
"for now: return the defaultString, ignoring the catalogID." |
|
103 |
||
104 |
|str| |
|
105 |
||
106 |
str := self lookupInMessageCatalog. |
|
107 |
str notNil ifTrue:[ ^ str ]. |
|
108 |
defaultString notNil ifTrue:[ |
|
109 |
^ defaultString |
|
110 |
]. |
|
111 |
^ key asString |
|
6117 | 112 |
! |
113 |
||
114 |
expandMacros |
|
115 |
^ self asString expandMacros |
|
116 |
||
117 |
! |
|
118 |
||
119 |
expandMacrosWith:arg1 |
|
120 |
^ self asString expandMacrosWith:arg1 |
|
121 |
||
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
122 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
123 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
124 |
string |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
125 |
^ self asString |
5996 | 126 |
! ! |
127 |
||
6591 | 128 |
!UserMessage methodsFor:'printing & storing'! |
129 |
||
130 |
displayString |
|
131 |
||
132 |
|stream| |
|
133 |
||
134 |
stream := '' writeStream. |
|
135 |
||
136 |
key storeOn:stream. |
|
137 |
stream nextPutAll:' << '. |
|
138 |
catalogID storeOn:stream. |
|
6887 | 139 |
defaultString notNil ifTrue:[ |
140 |
stream nextPutAll:' >> '. |
|
141 |
defaultString storeOn:stream. |
|
142 |
]. |
|
6591 | 143 |
^ stream contents. |
144 |
! ! |
|
145 |
||
5996 | 146 |
!UserMessage methodsFor:'utilities'! |
147 |
||
148 |
<< aSymbol |
|
149 |
"set the catalogID" |
|
150 |
||
151 |
self catalogID:aSymbol |
|
152 |
! |
|
153 |
||
154 |
>> aString |
|
155 |
"set the default string" |
|
156 |
||
157 |
self defaultString:aString |
|
158 |
||
159 |
" |
|
160 |
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass') |
|
161 |
" |
|
162 |
! |
|
163 |
||
164 |
lookupInMessageCatalog |
|
6887 | 165 |
|messageCatalog| |
5996 | 166 |
|
6887 | 167 |
"/ for now - handle the case that the catalogID is |
5996 | 168 |
"/ a classes name; in that case, ask its resourcePack. |
169 |
||
6887 | 170 |
catalogID isSymbol ifTrue:[ |
171 |
messageCatalog := Smalltalk at:catalogID. |
|
172 |
] ifFalse:[ |
|
173 |
messageCatalog := catalogID. |
|
174 |
]. |
|
175 |
messageCatalog isBehavior ifTrue:[ |
|
176 |
messageCatalog := messageCatalog classResources. |
|
5996 | 177 |
]. |
6887 | 178 |
messageCatalog isNil ifTrue:[ |
179 |
defaultString isNil ifTrue:[ |
|
180 |
^ 'Non-existant message (%1<<%2)' bindWith:key with:catalogID printString. |
|
181 |
]. |
|
182 |
^ defaultString. |
|
183 |
]. |
|
184 |
||
185 |
^ messageCatalog at:key ifAbsent:defaultString. |
|
5996 | 186 |
|
187 |
" |
|
188 |
(#'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 | 189 |
(#'WARN_RENAME' << #BrowserView) |
190 |
(#'WARN_RENAME' << BrowserView classResources) |
|
191 |
(#dontKnow << #nonExistantMessageCatalog) asString |
|
5996 | 192 |
" |
193 |
! ! |
|
194 |
||
195 |
!UserMessage class methodsFor:'documentation'! |
|
196 |
||
197 |
version |
|
17814 | 198 |
^ '$Id: UserMessage.st 10602 2010-12-20 07:13:27Z vranyj1 $' |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
199 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
200 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
201 |
version_CVS |
17814 | 202 |
^ 'Header: /cvs/stx/stx/libbasic/UserMessage.st,v 1.6 2009/10/02 00:08:10 cg Exp ' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
203 |
! |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
204 |
|
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
205 |
version_SVN |
17814 | 206 |
^ '$Id: UserMessage.st 10602 2010-12-20 07:13:27Z vranyj1 $' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17735
diff
changeset
|
207 |
! ! |
17767 | 208 |
|
17772
6e0b3c06c364
Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17767
diff
changeset
|
209 |
|
17780 | 210 |
|
17807 | 211 |
|
17814 | 212 |