author | Claus Gittinger <cg@exept.de> |
Wed, 05 Feb 2014 19:59:44 +0100 | |
changeset 13853 | 002e319d4027 |
parent 12686 | 0920976ce7ef |
child 14525 | bd238db12086 |
permissions | -rw-r--r-- |
9987 | 1 |
" |
10099 | 2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
9987 | 4 |
|
10099 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9987 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
ApplicationModel subclass:#InlineMessageDialog |
|
12686
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
31 |
instanceVariableNames:'messageHolder progressHolder backgroundColorHolder |
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
32 |
backgroundColorOrDefaultHolder progressView panelView |
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
33 |
panelViewComponents specHolder panelShownHolder panelHiddenHolder |
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
34 |
worker layout changeLayoutUponShowHide' |
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
35 |
classVariableNames:'' |
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
36 |
poolDictionaries:'' |
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
37 |
category:'Interface-Tools' |
9987 | 38 |
! |
39 |
||
40 |
!InlineMessageDialog class methodsFor:'documentation'! |
|
41 |
||
42 |
copyright |
|
43 |
" |
|
10099 | 44 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
45 |
Copyright (c) 2009-2010 eXept Software AG |
|
46 |
||
47 |
Permission is hereby granted, free of charge, to any person |
|
48 |
obtaining a copy of this software and associated documentation |
|
49 |
files (the 'Software'), to deal in the Software without |
|
50 |
restriction, including without limitation the rights to use, |
|
51 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
52 |
copies of the Software, and to permit persons to whom the |
|
53 |
Software is furnished to do so, subject to the following |
|
54 |
conditions: |
|
9987 | 55 |
|
10099 | 56 |
The above copyright notice and this permission notice shall be |
57 |
included in all copies or substantial portions of the Software. |
|
58 |
||
59 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
60 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
61 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
62 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
63 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
64 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
65 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
66 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9987 | 67 |
" |
11518 | 68 |
! |
69 |
||
70 |
documentation |
|
71 |
" |
|
72 |
A simple info/warning dialog to embed into application window - |
|
73 |
much like information panel in Firefox or other applications. |
|
74 |
Use it when a modal dialog might be too disturbing. |
|
75 |
||
76 |
||
77 |
[author:] |
|
78 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
79 |
||
80 |
[instance variables:] |
|
81 |
||
82 |
[class variables:] |
|
83 |
||
84 |
[see also:] |
|
85 |
||
86 |
" |
|
87 |
! |
|
88 |
||
89 |
examples |
|
90 |
" |
|
91 |
Starting the application: |
|
92 |
[exBegin] |
|
93 |
Tools::InlineMessageDialog new |
|
94 |
open; |
|
95 |
message: 'Hello World'; |
|
96 |
show: #messageInfoSpec. |
|
97 |
||
98 |
||
99 |
[exEnd] |
|
100 |
||
101 |
more examples to be added: |
|
102 |
[exBegin] |
|
103 |
... add code fragment for |
|
104 |
... executable example here ... |
|
105 |
[exEnd] |
|
106 |
" |
|
107 |
! ! |
|
108 |
||
109 |
!InlineMessageDialog class methodsFor:'accessing-colors'! |
|
110 |
||
111 |
defaultInformationBackground |
|
112 |
||
113 |
^(Color red:100.0 green:78.0392156862745 blue:22.7450980392157) |
|
114 |
||
115 |
"Created: / 10-04-2012 / 19:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
116 |
! |
|
117 |
||
118 |
defaultWarningBackground |
|
119 |
||
120 |
^(Color red:76.078431372549 green:43.1372549019608 blue:43.1372549019608) |
|
121 |
||
122 |
"Created: / 10-04-2012 / 19:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9987 | 123 |
! ! |
124 |
||
125 |
!InlineMessageDialog class methodsFor:'interface specs'! |
|
126 |
||
127 |
messageInfoSpec |
|
128 |
"This resource specification was automatically generated |
|
129 |
by the UIPainter of ST/X." |
|
130 |
||
131 |
"Do not manually edit this!! If it is corrupted, |
|
132 |
the UIPainter may not be able to read the specification." |
|
133 |
||
134 |
" |
|
11518 | 135 |
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#messageInfoSpec |
136 |
Tools::InlineMessageDialog new openInterface:#messageInfoSpec |
|
9987 | 137 |
" |
138 |
||
139 |
<resource: #canvas> |
|
140 |
||
141 |
^ |
|
142 |
#(FullSpec |
|
143 |
name: messageInfoSpec |
|
144 |
window: |
|
145 |
(WindowSpec |
|
146 |
label: 'MessageInfo' |
|
147 |
name: 'MessageInfo' |
|
148 |
min: (Point 10 10) |
|
149 |
bounds: (Rectangle 0 0 800 40) |
|
150 |
) |
|
151 |
component: |
|
152 |
(SpecCollection |
|
153 |
collection: ( |
|
154 |
(LabelSpec |
|
155 |
label: 'Label' |
|
156 |
name: 'Message' |
|
11518 | 157 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
158 |
backgroundChannel: backgroundColorOrDefaultHolder |
|
9987 | 159 |
translateLabel: true |
160 |
labelChannel: messageHolder |
|
161 |
adjust: left |
|
162 |
) |
|
163 |
) |
|
164 |
||
165 |
) |
|
166 |
) |
|
167 |
! |
|
168 |
||
169 |
progressInfoSpec |
|
170 |
"This resource specification was automatically generated |
|
171 |
by the UIPainter of ST/X." |
|
172 |
||
173 |
"Do not manually edit this!! If it is corrupted, |
|
174 |
the UIPainter may not be able to read the specification." |
|
175 |
||
176 |
" |
|
177 |
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#progressInfoSpec |
|
178 |
Tools::InlineMessageDialog new openInterface:#progressInfoSpec |
|
179 |
" |
|
180 |
||
181 |
<resource: #canvas> |
|
182 |
||
183 |
^ |
|
184 |
#(FullSpec |
|
185 |
name: progressInfoSpec |
|
186 |
window: |
|
187 |
(WindowSpec |
|
188 |
label: 'ProgressInfo' |
|
189 |
name: 'ProgressInfo' |
|
190 |
min: (Point 10 10) |
|
191 |
bounds: (Rectangle 0 0 800 40) |
|
192 |
forceRecursiveBackgroundOfDefaultBackground: true |
|
193 |
) |
|
194 |
component: |
|
195 |
(SpecCollection |
|
196 |
collection: ( |
|
11518 | 197 |
(ViewSpec |
198 |
name: 'Box1' |
|
199 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
200 |
level: 0 |
|
201 |
backgroundChannel: backgroundColorOrDefaultHolder |
|
202 |
component: |
|
203 |
(SpecCollection |
|
204 |
collection: ( |
|
205 |
(LabelSpec |
|
206 |
label: 'Label' |
|
207 |
name: 'Message' |
|
208 |
layout: (LayoutFrame 0 0 0 0 -20 1 20 0) |
|
209 |
backgroundChannel: backgroundColorOrDefaultHolder |
|
210 |
translateLabel: true |
|
211 |
labelChannel: messageHolder |
|
212 |
adjust: left |
|
213 |
) |
|
214 |
(ProgressIndicatorSpec |
|
215 |
name: 'ProgressIndicator' |
|
216 |
layout: (LayoutFrame 0 0 -20 1 -20 1 -3 1) |
|
217 |
level: 0 |
|
218 |
backgroundChannel: backgroundColorOrDefaultHolder |
|
219 |
model: progressHolder |
|
220 |
foregroundColor: (Color 52.156862745098 37.2549019607843 0.0) |
|
221 |
postBuildCallback: postBuildProgressView: |
|
222 |
) |
|
223 |
) |
|
224 |
||
225 |
) |
|
9987 | 226 |
) |
227 |
) |
|
228 |
||
229 |
) |
|
230 |
) |
|
231 |
! |
|
232 |
||
11518 | 233 |
warningInfoSpec |
234 |
||
235 |
<resource: #canvas> |
|
236 |
||
237 |
^self messageInfoSpec |
|
238 |
||
239 |
"Modified: / 10-04-2012 / 19:40:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
240 |
! |
|
241 |
||
9987 | 242 |
windowSpec |
243 |
"This resource specification was automatically generated |
|
244 |
by the UIPainter of ST/X." |
|
245 |
||
246 |
"Do not manually edit this!! If it is corrupted, |
|
247 |
the UIPainter may not be able to read the specification." |
|
248 |
||
249 |
" |
|
250 |
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#windowSpec |
|
251 |
Tools::InlineMessageDialog new openInterface:#windowSpec |
|
252 |
Tools::InlineMessageDialog open |
|
253 |
" |
|
254 |
||
255 |
<resource: #canvas> |
|
256 |
||
257 |
^ |
|
258 |
#(FullSpec |
|
259 |
name: windowSpec |
|
260 |
window: |
|
261 |
(WindowSpec |
|
262 |
label: 'Tools::InlineMessageDialog' |
|
263 |
name: 'Tools::InlineMessageDialog' |
|
264 |
min: (Point 10 10) |
|
265 |
bounds: (Rectangle 0 0 800 40) |
|
266 |
) |
|
267 |
component: |
|
268 |
(SpecCollection |
|
269 |
collection: ( |
|
11518 | 270 |
(ViewSpec |
271 |
name: 'Layout' |
|
9987 | 272 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
11518 | 273 |
backgroundChannel: backgroundColorOrDefaultHolder |
274 |
component: |
|
275 |
(SpecCollection |
|
276 |
collection: ( |
|
277 |
(HorizontalPanelViewSpec |
|
278 |
name: 'ComponentPanel' |
|
279 |
layout: (LayoutFrame 12 0 0 0 -10 1 0 1) |
|
280 |
backgroundChannel: backgroundColorOrDefaultHolder |
|
281 |
horizontalLayout: rightSpaceFit |
|
282 |
verticalLayout: fit |
|
283 |
horizontalSpace: 0 |
|
284 |
verticalSpace: 3 |
|
285 |
elementsChangeSize: true |
|
286 |
component: |
|
287 |
(SpecCollection |
|
288 |
collection: ( |
|
289 |
(SubCanvasSpec |
|
290 |
name: 'InfoSpec' |
|
291 |
level: 0 |
|
292 |
hasHorizontalScrollBar: false |
|
293 |
hasVerticalScrollBar: false |
|
294 |
miniScrollerHorizontal: false |
|
295 |
specHolder: specHolder |
|
296 |
createNewBuilder: false |
|
297 |
usePreferredHeight: true |
|
298 |
useDynamicPreferredWidth: true |
|
299 |
useDynamicPreferredHeight: true |
|
300 |
useDefaultExtent: true |
|
301 |
usePreferredWidth: true |
|
302 |
) |
|
303 |
) |
|
304 |
||
305 |
) |
|
306 |
postBuildCallback: postBuildPanelView: |
|
307 |
) |
|
308 |
) |
|
309 |
||
310 |
) |
|
9987 | 311 |
) |
312 |
) |
|
313 |
||
314 |
) |
|
315 |
) |
|
316 |
! ! |
|
317 |
||
11518 | 318 |
!InlineMessageDialog class methodsFor:'others'! |
319 |
||
320 |
version_CVS |
|
13853 | 321 |
^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.13 2014-02-05 18:59:44 cg Exp $' |
11518 | 322 |
! ! |
323 |
||
9987 | 324 |
!InlineMessageDialog methodsFor:'accessing'! |
325 |
||
11518 | 326 |
backgroundColor: aColor |
327 |
"Sets the background color, but only iff backgroundColorHolder is |
|
328 |
not set" |
|
329 |
||
330 |
backgroundColorHolder isNil ifTrue:[ |
|
331 |
self backgroundColorOrDefaultHolder value: aColor |
|
332 |
] |
|
333 |
||
334 |
"Created: / 10-04-2012 / 19:38:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
335 |
! |
|
336 |
||
9987 | 337 |
message: aString |
338 |
||
339 |
self messageHolder value: aString |
|
340 |
||
341 |
"Created: / 28-10-2010 / 18:23:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
342 |
! |
|
343 |
||
344 |
progress: aNumberOrNil |
|
345 |
||
11249 | 346 |
aNumberOrNil isNumber ifTrue:[ |
347 |
progressView notNil ifTrue:[ |
|
348 |
progressView showBusyIndication: false. |
|
349 |
]. |
|
350 |
self progressHolder value: aNumberOrNil |
|
351 |
] ifFalse:[ |
|
352 |
progressView notNil ifTrue:[ |
|
353 |
progressView showBusyIndication: true. |
|
354 |
] |
|
355 |
||
356 |
] |
|
9987 | 357 |
|
358 |
"Created: / 28-10-2010 / 18:24:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
359 |
! ! |
|
360 |
||
11518 | 361 |
!InlineMessageDialog methodsFor:'accessing-presentation'! |
362 |
||
363 |
changeLayoutUponShowHide: aBoolean |
|
364 |
"If set to false, no changes to compokent layout is done |
|
365 |
when panel is shown/hidden. This effectively means, that |
|
366 |
that panel is shown over the normal content. |
|
367 |
||
368 |
Default value is true (i.e., relayout components)" |
|
369 |
||
370 |
changeLayoutUponShowHide := aBoolean |
|
371 |
||
372 |
"Modified (comment): / 17-05-2012 / 13:56:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
373 |
! ! |
|
374 |
||
9987 | 375 |
!InlineMessageDialog methodsFor:'actions'! |
376 |
||
377 |
doAbort |
|
378 |
||
11248 | 379 |
worker isNil ifTrue:[ self hide. ^ self ]. |
380 |
worker interruptWith:[ |
|
381 |
NoHandlerError handle:[:ex | |
|
12686
0920976ce7ef
class: Tools::InlineMessageDialog
Claus Gittinger <cg@exept.de>
parents:
12603
diff
changeset
|
382 |
ex exception creator == AbortOperationRequest ifTrue:[ |
11248 | 383 |
ex return. |
384 |
]. |
|
385 |
ex reject. |
|
386 |
] do:[ |
|
387 |
AbortOperationRequest raise. |
|
388 |
]. |
|
13853 | 389 |
]. |
390 |
(worker notNil and:[worker isDead not]) ifTrue:[ |
|
391 |
worker terminate. |
|
392 |
"/ raise its prio to make it terminate quickly |
|
12462
7466535c9b47
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12416
diff
changeset
|
393 |
worker priority:(Processor userSchedulingPriority + 1). |
11518 | 394 |
worker := nil. |
395 |
]. |
|
396 |
||
13853 | 397 |
"Modified: / 11-04-2012 / 16:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11518 | 398 |
! |
399 |
||
12416
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
400 |
doAbortIfWorking |
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
401 |
worker notNil ifTrue:[ self doAbort ]. |
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
402 |
|
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
403 |
"Created: / 04-10-2012 / 19:20:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
404 |
! |
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
405 |
|
11518 | 406 |
doOK |
407 |
<resource: #uiCallback> |
|
408 |
||
409 |
(worker notNil and:[worker isDead not]) ifTrue:[ |
|
13853 | 410 |
worker terminate. |
12416
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
411 |
"/ raise its prio to make it terminate quickly |
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
412 |
worker priority:(Processor userSchedulingPriority + 1). |
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
413 |
worker := nil. |
11248 | 414 |
]. |
11518 | 415 |
self hide. |
9987 | 416 |
|
13853 | 417 |
"Modified: / 31-03-2013 / 18:02:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11518 | 418 |
! ! |
419 |
||
420 |
!InlineMessageDialog methodsFor:'adding & removing components'! |
|
421 |
||
422 |
addButton: aButton |
|
423 |
| layoutView | |
|
424 |
||
425 |
aButton preferredExtent: ((aButton width + 20) max: 70"px") @ 24. |
|
426 |
layoutView := View new. |
|
427 |
layoutView backgroundChannel: self backgroundColorOrDefaultHolder. |
|
428 |
layoutView addComponent: aButton. |
|
429 |
aButton layout: |
|
430 |
( LayoutFrame fractions:(0 @ 0.5 corner:1.0 @ 0.5) offsets:(3 @ -12 corner:-3 @ 12) ). |
|
431 |
layoutView preferredExtent: (aButton preferredExtent x + 12) @ 24. |
|
432 |
||
433 |
^self addComponent: layoutView |
|
434 |
||
435 |
"Created: / 10-04-2012 / 20:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
436 |
! |
|
437 |
||
438 |
addButtonAbort |
|
439 |
||
440 |
^self addButtonWithLabel: (self resources string:'Abort') action: [ self doAbort ] |
|
441 |
||
442 |
"Created: / 10-04-2012 / 21:45:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
443 |
! |
|
444 |
||
445 |
addButtonOK |
|
446 |
||
447 |
^self addButtonWithLabel: (self resources string:'OK') action: [ self doOK ] |
|
448 |
||
449 |
"Created: / 10-04-2012 / 21:44:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
450 |
! |
|
451 |
||
452 |
addButtonWithLabel: label action: action |
|
453 |
^self addButton: (Button label: label action: action) |
|
454 |
||
455 |
"Created: / 10-04-2012 / 20:50:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9987 | 456 |
! |
457 |
||
11518 | 458 |
addComponent: aView |
459 |
panelView isNil ifTrue:[ |
|
460 |
panelViewComponents isNil ifTrue:[ |
|
461 |
panelViewComponents := OrderedCollection new |
|
462 |
]. |
|
463 |
panelViewComponents add: aView |
|
464 |
] ifFalse:[ |
|
465 |
panelView addSubView: aView. |
|
466 |
aView isVisible: true. |
|
467 |
]. |
|
468 |
^aView. |
|
469 |
||
470 |
"Created: / 10-04-2012 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
471 |
! |
|
472 |
||
473 |
beInformation |
|
474 |
||
475 |
self backgroundColor: self class defaultInformationBackground. |
|
476 |
self specHolder value: #messageInfoSpec |
|
477 |
||
478 |
"Created: / 11-04-2012 / 11:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
479 |
! |
|
480 |
||
481 |
beProgress |
|
482 |
||
483 |
self backgroundColor: self class defaultInformationBackground. |
|
484 |
self specHolder value: #progressInfoSpec |
|
485 |
||
486 |
"Created: / 11-04-2012 / 11:41:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
487 |
! |
|
9987 | 488 |
|
11518 | 489 |
beWarning |
490 |
||
491 |
self backgroundColor: self class defaultWarningBackground. |
|
492 |
self specHolder value: #messageInfoSpec |
|
493 |
||
494 |
"Created: / 11-04-2012 / 11:41:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
495 |
! |
|
9987 | 496 |
|
11518 | 497 |
removeComponent: aView |
498 |
panelView notNil ifTrue:[ |
|
499 |
panelView removeComponent: aView. |
|
500 |
]. |
|
501 |
panelViewComponents notNil ifTrue:[ |
|
502 |
panelViewComponents remove: aView ifAbsent:[]. |
|
503 |
] |
|
504 |
||
505 |
"Created: / 11-04-2012 / 00:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
506 |
! |
|
507 |
||
508 |
removeComponents |
|
509 |
"Removes all components except subcanvas" |
|
510 |
panelViewComponents := nil. |
|
511 |
panelView notNil ifTrue:[ |
|
512 |
panelView subViews copyWithoutFirst do:[:component| |
|
513 |
component destroy |
|
514 |
] |
|
515 |
||
516 |
]. |
|
517 |
||
518 |
"Created: / 11-04-2012 / 00:51:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9987 | 519 |
! ! |
520 |
||
521 |
!InlineMessageDialog methodsFor:'aspects'! |
|
522 |
||
11518 | 523 |
backgroundColorHolder |
524 |
"return/create the 'backgroundColorHolder' value holder (automatically generated)" |
|
525 |
||
526 |
backgroundColorHolder isNil ifTrue:[ |
|
527 |
backgroundColorHolder := ValueHolder new. |
|
528 |
]. |
|
529 |
^ backgroundColorHolder |
|
530 |
! |
|
531 |
||
532 |
backgroundColorHolder:something |
|
533 |
"set the 'backgroundColorHolder' value holder (automatically generated)" |
|
534 |
||
535 |
|oldValue newValue| |
|
536 |
||
537 |
backgroundColorHolder notNil ifTrue:[ |
|
538 |
oldValue := backgroundColorHolder value. |
|
539 |
backgroundColorHolder removeDependent:self. |
|
540 |
]. |
|
541 |
backgroundColorHolder := something. |
|
542 |
backgroundColorHolder notNil ifTrue:[ |
|
543 |
backgroundColorHolder addDependent:self. |
|
544 |
]. |
|
545 |
newValue := backgroundColorHolder value. |
|
546 |
oldValue ~~ newValue ifTrue:[ |
|
547 |
self update:#value with:newValue from:backgroundColorHolder. |
|
548 |
]. |
|
549 |
! |
|
550 |
||
551 |
backgroundColorOrDefaultHolder |
|
552 |
"return/create the 'backgroundColorOrDefaultHolder' value holder (automatically generated)" |
|
553 |
||
554 |
backgroundColorOrDefaultHolder isNil ifTrue:[ |
|
555 |
backgroundColorOrDefaultHolder := ValueHolder new. |
|
556 |
backgroundColorOrDefaultHolder addDependent:self. |
|
557 |
]. |
|
558 |
^ backgroundColorOrDefaultHolder |
|
559 |
! |
|
560 |
||
9987 | 561 |
messageHolder |
562 |
<resource: #uiAspect> |
|
563 |
||
564 |
messageHolder isNil ifTrue:[ |
|
565 |
messageHolder := ValueHolder new. |
|
566 |
]. |
|
567 |
^ messageHolder. |
|
11509 | 568 |
|
569 |
"Modified (comment): / 15-05-2012 / 11:08:35 / cg" |
|
9987 | 570 |
! |
571 |
||
11248 | 572 |
panelHiddenHolder |
573 |
"return/create the 'panelHiddenHolder' value holder (automatically generated)" |
|
574 |
||
575 |
panelHiddenHolder isNil ifTrue:[ |
|
576 |
panelHiddenHolder := ValueHolder new. |
|
577 |
]. |
|
578 |
^ panelHiddenHolder |
|
579 |
! |
|
580 |
||
581 |
panelHiddenHolder:aValueModel |
|
582 |
"set the 'panelHiddenHolder' value holder (automatically generated)" |
|
583 |
||
584 |
panelHiddenHolder := aValueModel. |
|
585 |
! |
|
586 |
||
587 |
panelShownHolder |
|
588 |
"return/create the 'panelShownHolder' value holder (automatically generated)" |
|
589 |
||
590 |
panelShownHolder isNil ifTrue:[ |
|
591 |
panelShownHolder := ValueHolder new. |
|
592 |
]. |
|
593 |
^ panelShownHolder |
|
594 |
! |
|
595 |
||
596 |
panelShownHolder:aValueModel |
|
597 |
"set the 'panelShownHolder' value holder (automatically generated)" |
|
598 |
||
599 |
panelShownHolder := aValueModel. |
|
600 |
! |
|
601 |
||
9987 | 602 |
progressHolder |
603 |
<resource: #uiAspect> |
|
604 |
||
605 |
"automatically generated by UIPainter ..." |
|
606 |
||
607 |
"*** the code below creates a default model when invoked." |
|
608 |
"*** (which may not be the one you wanted)" |
|
609 |
"*** Please change as required and accept it in the browser." |
|
610 |
"*** (and replace this comment by something more useful ;-)" |
|
611 |
||
612 |
progressHolder isNil ifTrue:[ |
|
613 |
progressHolder := ValueHolder new. |
|
614 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
615 |
"/ progressHolder addDependent:self. |
|
616 |
"/ progressHolder onChangeSend:#progressHolderChanged to:self. |
|
617 |
]. |
|
618 |
^ progressHolder. |
|
619 |
! |
|
620 |
||
621 |
specHolder |
|
622 |
"return/create the 'specHolder' value holder (automatically generated)" |
|
623 |
||
624 |
specHolder isNil ifTrue:[ |
|
625 |
specHolder := ValueHolder with: #messageInfoSpec. |
|
626 |
]. |
|
627 |
^ specHolder |
|
628 |
||
629 |
"Modified: / 28-10-2010 / 18:29:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
630 |
! ! |
|
631 |
||
11518 | 632 |
!InlineMessageDialog methodsFor:'change & update'! |
633 |
||
634 |
update:aspect with:parameter from:changedObject |
|
635 |
"Invoked when an object that I depend upon sends a change notification." |
|
636 |
||
637 |
changedObject == backgroundColorHolder ifTrue:[ |
|
638 |
self backgroundColorOrDefaultHolder value: backgroundColorHolder value. |
|
639 |
^ self. |
|
640 |
]. |
|
641 |
super update:aspect with:parameter from:changedObject |
|
642 |
||
643 |
"Modified: / 10-04-2012 / 19:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
644 |
! ! |
|
645 |
||
11249 | 646 |
!InlineMessageDialog methodsFor:'hooks'! |
647 |
||
11518 | 648 |
commonPostBuild |
649 |
panelViewComponents notEmptyOrNil ifTrue:[ |
|
650 |
| correctionView | |
|
651 |
panelViewComponents do:[:each|panelView addSubView: each]. |
|
652 |
"/ "/Correction view, dunno why the layout is bad without it... |
|
653 |
"/ correctionView := View new. |
|
654 |
"/ correctionView extent: (panelView subViews size * 3)@24. |
|
655 |
"/ correctionView backgroundChannel: self backgroundColorOrDefaultHolder. |
|
656 |
"/ panelView addComponent: correctionView |
|
657 |
] |
|
658 |
||
659 |
"Created: / 10-04-2012 / 21:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
660 |
! |
|
661 |
||
662 |
postBuildPanelView: aPanelView |
|
663 |
panelView := aPanelView. |
|
664 |
||
665 |
"Created: / 10-04-2012 / 20:47:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
666 |
! |
|
667 |
||
11249 | 668 |
postBuildProgressView: aProgressIndicator |
669 |
progressView := aProgressIndicator |
|
670 |
||
671 |
"Created: / 10-02-2012 / 10:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
672 |
! ! |
|
673 |
||
9987 | 674 |
!InlineMessageDialog methodsFor:'private'! |
675 |
||
676 |
getMyView |
|
677 |
||
678 |
| v | |
|
679 |
||
11518 | 680 |
builder isNil ifTrue:[ ^ nil ]. |
9987 | 681 |
v := builder window. |
682 |
^(v superView isKindOf: SubCanvas) |
|
683 |
ifTrue:[v superView] |
|
684 |
ifFalse:[v] |
|
685 |
||
686 |
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
687 |
! |
|
688 |
||
689 |
getOtherView |
|
690 |
||
691 |
| myView | |
|
692 |
||
693 |
myView := self getMyView. |
|
11518 | 694 |
^ (myView isNil or:[myView superView isNil]) ifTrue:[ |
11248 | 695 |
nil. |
696 |
] ifFalse: [ |
|
697 |
myView superView subViews after: myView |
|
698 |
]. |
|
9987 | 699 |
|
700 |
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
701 |
! |
|
702 |
||
703 |
hide |
|
704 |
||
705 |
| myView otherView | |
|
12416
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
706 |
builder isNil ifTrue:[ ^ self ]. |
9987 | 707 |
myView := self getMyView. |
708 |
otherView := self getOtherView. |
|
709 |
||
11518 | 710 |
myView isVisible ifFalse:[ "/already hidden" |
711 |
self reset. |
|
712 |
^self |
|
713 |
]. |
|
9987 | 714 |
myView isVisible: false. |
11248 | 715 |
panelShownHolder notNil ifTrue:[ |
716 |
panelShownHolder value: false |
|
717 |
]. |
|
718 |
panelHiddenHolder notNil ifTrue:[ |
|
719 |
panelHiddenHolder value: true |
|
720 |
]. |
|
11518 | 721 |
changeLayoutUponShowHide ~~ false ifTrue:[ |
12416
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
722 |
otherView layout: layout. |
11518 | 723 |
]. |
11248 | 724 |
|
11518 | 725 |
self reset. |
9987 | 726 |
|
727 |
"Created: / 29-10-2010 / 11:55:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12416
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
728 |
"Modified (format): / 17-01-2013 / 23:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9987 | 729 |
! |
730 |
||
11518 | 731 |
show |
9987 | 732 |
|
733 |
| myView otherView | |
|
734 |
myView := self getMyView. |
|
735 |
otherView := self getOtherView. |
|
11518 | 736 |
(myView isNil or:[myView isVisible]) ifTrue:[ |
737 |
^self. |
|
738 |
]. |
|
9987 | 739 |
myView isVisible: true. |
11248 | 740 |
panelShownHolder notNil ifTrue:[ |
741 |
panelShownHolder value: true |
|
742 |
]. |
|
743 |
panelHiddenHolder notNil ifTrue:[ |
|
744 |
panelHiddenHolder value: false |
|
745 |
]. |
|
746 |
||
11518 | 747 |
changeLayoutUponShowHide ~~ false ifTrue:[ |
748 |
otherView notNil ifTrue:[ |
|
749 |
layout := otherView layout copy. |
|
750 |
otherView layout: |
|
751 |
(layout copy topOffset: layout topOffset + 40; yourself). |
|
752 |
]. |
|
753 |
]. |
|
754 |
||
755 |
"Created: / 11-04-2012 / 11:43:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
756 |
! |
|
757 |
||
758 |
show: spec |
|
759 |
<resource: #obsolete> |
|
760 |
||
761 |
self obsoleteMethodWarning. |
|
762 |
self breakPoint: #jv. |
|
763 |
||
764 |
spec == #warningInfoSpec ifTrue:[ self beWarning ]. |
|
765 |
spec == #messageInfoSpec ifTrue:[ self beInformation ]. |
|
766 |
spec == #progressInfoSpec ifTrue:[ self beProgress ]. |
|
767 |
self show. |
|
9987 | 768 |
|
769 |
"Created: / 29-10-2010 / 11:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
770 |
! ! |
|
771 |
||
11518 | 772 |
!InlineMessageDialog methodsFor:'utilities'! |
773 |
||
774 |
reset |
|
775 |
"Resets the dialog to initial state, removes all |
|
776 |
user supplied components." |
|
777 |
||
778 |
self removeComponents. |
|
779 |
||
780 |
"Created: / 11-04-2012 / 00:51:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
781 |
! |
|
782 |
||
783 |
showMessage: aString |
|
784 |
"Shows given message and OK button (which closes the dialog |
|
785 |
when clicked" |
|
786 |
||
787 |
self showMessage: aString closeAfter: nil |
|
788 |
||
789 |
"Created: / 11-04-2012 / 13:11:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
790 |
! |
|
791 |
||
792 |
showMessage: aString closeAfter: aTimeDurationOrIntegerOrNil |
|
793 |
"Shows given message and OK button (which closes the dialog |
|
794 |
when clicked). The dialog closes automaticaly after |
|
795 |
aTimeDurationOrIntegerOrNil (integer value means secons, nil |
|
796 |
means do not close automatically)" |
|
797 |
||
798 |
||
799 |
self reset. |
|
800 |
self beInformation. |
|
801 |
self message: aString. |
|
802 |
self addButtonOK. |
|
803 |
self show. |
|
804 |
aTimeDurationOrIntegerOrNil notNil ifTrue:[ |
|
805 |
worker := |
|
806 |
[ |
|
807 |
aTimeDurationOrIntegerOrNil isInteger ifTrue:[ |
|
808 |
Delay waitForSeconds: aTimeDurationOrIntegerOrNil. |
|
809 |
] ifFalse:[ |
|
810 |
Delay waitForMilliseconds: aTimeDurationOrIntegerOrNil milliseconds |
|
811 |
]. |
|
812 |
self hide. |
|
813 |
] newProcess. |
|
814 |
worker addExitAction:[ worker := nil ]. |
|
815 |
worker resume. |
|
816 |
]. |
|
817 |
||
818 |
"Created: / 11-04-2012 / 13:13:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
819 |
! |
|
820 |
||
821 |
showProgressLabeled: aString while: aBlock |
|
822 |
"During an execution of aBlock, show a label with given |
|
823 |
string, a progressbar showing the progress and an 'Abort' button. |
|
824 |
||
825 |
If the block raises a ProgressNotification, then the percentage |
|
826 |
progress is updated accordingly. If it raises an ActivityNotification, |
|
827 |
then the label is updated and progress bar is changed to be an |
|
828 |
activity notificator. |
|
829 |
||
830 |
When an 'Abort' button is pressed, the block is interrupted by |
|
831 |
AbortOperationRequest. |
|
832 |
||
833 |
When a block terminates (either normally or abruptly, dialog is closed. |
|
834 |
" |
|
835 |
||
836 |
worker := [ |
|
837 |
self reset. |
|
838 |
self beProgress. |
|
839 |
self message: aString. |
|
840 |
self addButtonAbort. |
|
841 |
self progress: nil. |
|
842 |
self show. |
|
843 |
[ |
|
844 |
aBlock value. |
|
845 |
] on: ProgressNotification , ActivityNotification do:[:ex| |
|
846 |
self progress: ex parameter. |
|
847 |
ex messageText notNil ifTrue:[ |
|
848 |
self message: ex messageText. |
|
849 |
]. |
|
850 |
ex proceed. |
|
851 |
]. |
|
852 |
] newProcess. |
|
853 |
worker addExitAction:[ |
|
854 |
"This check is required, since somebody may want to show |
|
855 |
info/warning from within the action block" |
|
856 |
self specHolder value == #progressInfoSpec ifTrue:[ |
|
857 |
self hide. |
|
858 |
]. |
|
859 |
worker := nil. |
|
860 |
]. |
|
861 |
worker resume. |
|
862 |
||
863 |
"Created: / 11-04-2012 / 13:38:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
864 |
! ! |
|
865 |
||
866 |
!InlineMessageDialog methodsFor:'utilities-obsolete'! |
|
867 |
||
868 |
information: message |
|
869 |
||
870 |
self information: message timeout: nil |
|
871 |
||
872 |
"Created: / 11-02-2012 / 23:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
873 |
! |
|
874 |
||
875 |
information: message timeout: timeoutOrNil |
|
876 |
||
877 |
self reset. |
|
878 |
self beInformation. |
|
879 |
self message: message. |
|
880 |
self addButtonOK. |
|
881 |
self show. |
|
882 |
timeoutOrNil isInteger ifTrue:[ |
|
883 |
[ |
|
884 |
Delay waitForSeconds: timeoutOrNil. |
|
885 |
self hide. |
|
886 |
] fork. |
|
887 |
] |
|
888 |
||
889 |
"Created: / 11-02-2012 / 23:14:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
890 |
! |
|
891 |
||
892 |
progress: label while: block |
|
893 |
||
894 |
worker := [ |
|
895 |
self reset. |
|
896 |
self beProgress. |
|
897 |
self message: label. |
|
898 |
self addButtonAbort. |
|
899 |
self progress: nil. |
|
900 |
self show. |
|
901 |
[ |
|
902 |
block value. |
|
903 |
] on: ProgressNotification , ActivityNotification do:[:ex| |
|
904 |
self progress: ex parameter. |
|
905 |
ex messageText notNil ifTrue:[ |
|
906 |
self message: ex messageText. |
|
907 |
]. |
|
908 |
ex proceed. |
|
909 |
]. |
|
910 |
] newProcess. |
|
911 |
worker addExitAction:[ |
|
912 |
self specHolder value == #progressInfoSpec ifTrue:[ |
|
913 |
self hide. |
|
914 |
]. |
|
915 |
worker := nil. |
|
916 |
]. |
|
917 |
worker resume. |
|
918 |
||
919 |
"Created: / 10-02-2012 / 10:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
920 |
! |
|
921 |
||
922 |
warning: message action: block labeled: label |
|
923 |
||
924 |
self reset. |
|
925 |
self beWarning. |
|
926 |
self message: message. |
|
927 |
self addButtonWithLabel: label action: block. |
|
928 |
self addButtonOK. |
|
929 |
self show |
|
930 |
||
931 |
"Created: / 13-02-2012 / 16:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
932 |
! ! |
|
933 |
||
9987 | 934 |
!InlineMessageDialog class methodsFor:'documentation'! |
935 |
||
11249 | 936 |
version |
13853 | 937 |
^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.13 2014-02-05 18:59:44 cg Exp $' |
12462
7466535c9b47
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12416
diff
changeset
|
938 |
! |
7466535c9b47
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12416
diff
changeset
|
939 |
|
7466535c9b47
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12416
diff
changeset
|
940 |
version_HG |
7466535c9b47
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12416
diff
changeset
|
941 |
|
13853 | 942 |
^ '$Changeset: <not expanded> $' |
11249 | 943 |
! |
944 |
||
9987 | 945 |
version_SVN |
13853 | 946 |
^ '$Id: Tools__InlineMessageDialog.st,v 1.13 2014-02-05 18:59:44 cg Exp $' |
9987 | 947 |
! ! |
12416
1171d0e7a363
class: Tools::InlineMessageDialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
11518
diff
changeset
|
948 |