author | Claus Gittinger <cg@exept.de> |
Mon, 16 Dec 2019 11:42:32 +0100 | |
changeset 25131 | ef5405956d85 |
parent 24096 | 98fa8c26986e |
permissions | -rw-r--r-- |
23777 | 1 |
"{ Encoding: utf8 }" |
2 |
||
4466
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
3 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
4 |
COPYRIGHT (c) 1999 by eXept Software AG |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
5 |
All Rights Reserved |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
6 |
|
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
7 |
This software is furnished under a license and may be used |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
8 |
only in accordance with the terms of that license and with the |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
9 |
inclusion of the above copyright notice. This software may not |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
10 |
be provided or otherwise made available to, or used by, any |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
11 |
other person. No title to or ownership of the software is |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
12 |
hereby transferred. |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
13 |
" |
6206 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
17307 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
7032
3c0246b4e602
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
6427
diff
changeset
|
18 |
UserNotification subclass:#Warning |
23777 | 19 |
instanceVariableNames:'optionalTitle' |
4446 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Kernel-Exceptions' |
|
23 |
! |
|
24 |
||
25 |
!Warning class methodsFor:'documentation'! |
|
26 |
||
4466
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
27 |
copyright |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
28 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
29 |
COPYRIGHT (c) 1999 by eXept Software AG |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
30 |
All Rights Reserved |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
31 |
|
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
32 |
This software is furnished under a license and may be used |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
33 |
only in accordance with the terms of that license and with the |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
34 |
inclusion of the above copyright notice. This software may not |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
35 |
be provided or otherwise made available to, or used by, any |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
36 |
other person. No title to or ownership of the software is |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
37 |
hereby transferred. |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
38 |
" |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
39 |
|
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
40 |
! |
9cba6f4ecec4
copyrights added; typo in docu
Claus Gittinger <cg@exept.de>
parents:
4446
diff
changeset
|
41 |
|
4446 | 42 |
documentation |
43 |
" |
|
12279 | 44 |
Warning is the superclass of all warning signals in the system. |
7038 | 45 |
The default beavior for an unhandled Warning is to display a warn |
46 |
box with the error decription. If no display is available, the error |
|
47 |
description is written to the Transcript. |
|
4446 | 48 |
|
49 |
[author:] |
|
50 |
Stefan Vogel |
|
51 |
||
52 |
[see also:] |
|
53 |
Signal |
|
54 |
" |
|
55 |
! |
|
56 |
||
57 |
examples |
|
58 |
" |
|
6427 | 59 |
show a warning: |
4446 | 60 |
[exBegin] |
6427 | 61 |
Transcript showCR:'1 - now raising'. |
62 |
Warning raiseRequest. |
|
63 |
Transcript showCR:'2 - after the raise'. |
|
64 |
[exEnd] |
|
65 |
||
66 |
passing an errorString: |
|
67 |
[exBegin] |
|
68 |
Warning raiseRequestErrorString:'hello world' |
|
69 |
[exEnd] |
|
70 |
||
71 |
provide a handler for warnings: |
|
72 |
[exBegin] |
|
73 |
Warning handle:[:ex | |
|
74 |
Transcript showCR:'WARNING: ' , ex description |
|
75 |
] do:[ |
|
76 |
'...'. |
|
77 |
Warning raiseRequest. |
|
78 |
'...'. |
|
79 |
]. |
|
80 |
||
81 |
Warning handle:[:ex | |
|
82 |
Transcript showCR:'WARNING: ' , ex description |
|
83 |
] do:[ |
|
84 |
'...'. |
|
85 |
Warning raiseRequestErrorString:'hello world'. |
|
86 |
'...'. |
|
87 |
] |
|
88 |
[exEnd] |
|
89 |
||
90 |
ignore warnings during some evaluation: |
|
91 |
[exBegin] |
|
92 |
Warning ignoreIn:[ |
|
93 |
'...'. |
|
94 |
Warning raiseRequest. |
|
95 |
'...'. |
|
96 |
] |
|
97 |
[exEnd] |
|
98 |
||
99 |
defer a warning to some later time: |
|
100 |
[exBegin] |
|
101 |
Warning deferAfter:[ |
|
102 |
Transcript showCR:'1 - no warning here ...'. |
|
103 |
Warning raiseRequestErrorString:'this warning is deferred'. |
|
104 |
Transcript showCR:'2 - but in a second...'. |
|
105 |
]. |
|
106 |
Transcript showCR:'3 - after warning-protected block'. |
|
4446 | 107 |
[exEnd] |
108 |
" |
|
109 |
! ! |
|
110 |
||
111 |
!Warning class methodsFor:'initialization'! |
|
112 |
||
113 |
initialize |
|
114 |
||
7032
3c0246b4e602
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
6427
diff
changeset
|
115 |
NotifierString := 'Warning:'. |
4446 | 116 |
|
117 |
" |
|
118 |
self initialize |
|
119 |
" |
|
120 |
||
121 |
"Created: / 23.7.1999 / 15:34:27 / stefan" |
|
122 |
! ! |
|
123 |
||
12083 | 124 |
|
23777 | 125 |
!Warning methodsFor:'accessing'! |
126 |
||
127 |
title:aWarnBoxWindowTitle |
|
128 |
"an optional title for the warn box" |
|
129 |
||
130 |
optionalTitle := aWarnBoxWindowTitle. |
|
131 |
||
132 |
"Created: / 26-02-2019 / 15:41:47 / Claus Gittinger" |
|
133 |
! ! |
|
134 |
||
4446 | 135 |
!Warning methodsFor:'default actions'! |
136 |
||
4525 | 137 |
defaultAction |
5295 | 138 |
"Default action for warnings: open a warn box with description" |
4446 | 139 |
|
16423 | 140 |
self showWarnDialog. |
141 |
self proceed. |
|
142 |
||
143 |
" |
|
144 |
Warning raiseRequestErrorString:' abc' |
|
145 |
" |
|
146 |
||
147 |
"Modified: / 3.8.1999 / 14:06:41 / stefan" |
|
148 |
! |
|
149 |
||
150 |
showWarnDialog |
|
151 |
"open a warn box with description" |
|
152 |
||
24096 | 153 |
|maxLineLength text collectedLines| |
4500
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
154 |
|
24096 | 155 |
maxLineLength := 150. |
156 |
||
5295 | 157 |
text := self description. |
4446 | 158 |
|
24023 | 159 |
(self suppressDialogIfUnhandled not and:[self hasDialog]) ifTrue:[ |
24096 | 160 |
text := text asStringCollection. |
161 |
(text contains:[:line | line size > maxLineLength]) ifTrue:[ |
|
162 |
collectedLines := StringCollection new. |
|
163 |
text do:[:line | |
|
164 |
|first| |
|
165 |
||
166 |
line size > maxLineLength ifTrue:[ |
|
167 |
first := true. |
|
168 |
(line splitForSize:maxLineLength) do:[:eachPart | |
|
169 |
first ifTrue:[ |
|
170 |
collectedLines add:eachPart. |
|
171 |
first := false. |
|
172 |
] ifFalse:[ |
|
173 |
collectedLines add:((' >> ' withColor:Color lightGrey),eachPart) |
|
174 |
]. |
|
175 |
]. |
|
176 |
] ifFalse:[ |
|
177 |
collectedLines add:line |
|
178 |
]. |
|
179 |
]. |
|
180 |
text := collectedLines |
|
181 |
]. |
|
23777 | 182 |
optionalTitle notNil ifTrue:[ |
183 |
Dialog warn:text title:optionalTitle |
|
184 |
] ifFalse:[ |
|
185 |
Dialog warn:text. |
|
186 |
]. |
|
4500
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
187 |
] ifFalse:[ |
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
188 |
" |
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
189 |
on systems without GUI, simply show |
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
190 |
the message on the Transcript. |
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
191 |
" |
24023 | 192 |
Transcript show:(self class name); show:': '; showCR:text. |
4500
be0fe7e7e21b
Write to transcript if Dialog is not available.
Stefan Vogel <sv@exept.de>
parents:
4466
diff
changeset
|
193 |
]. |
4446 | 194 |
|
195 |
" |
|
7032
3c0246b4e602
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
6427
diff
changeset
|
196 |
Warning raiseRequestErrorString:' abc' |
23777 | 197 |
(Warning new title:'Alert') raiseRequestErrorString:' abc' |
4446 | 198 |
" |
199 |
||
23777 | 200 |
"Modified: / 03-08-1999 / 14:06:41 / stefan" |
24096 | 201 |
"Modified: / 30-04-2019 / 12:59:53 / Claus Gittinger" |
4446 | 202 |
! ! |
203 |
||
204 |
!Warning class methodsFor:'documentation'! |
|
205 |
||
206 |
version |
|
19201
b301ed05553d
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
17307
diff
changeset
|
207 |
^ '$Header$' |
12083 | 208 |
! |
209 |
||
210 |
version_CVS |
|
19201
b301ed05553d
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
17307
diff
changeset
|
211 |
^ '$Header$' |
4446 | 212 |
! ! |
7032
3c0246b4e602
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
6427
diff
changeset
|
213 |
|
16423 | 214 |
|
4446 | 215 |
Warning initialize! |