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
|
11518
|
31 |
instanceVariableNames:'messageHolder progressHolder backgroundColorHolder
|
|
32 |
backgroundColorOrDefaultHolder progressView panelView
|
|
33 |
panelViewComponents specHolder panelShownHolder panelHiddenHolder
|
|
34 |
worker layout changeLayoutUponShowHide'
|
9987
|
35 |
classVariableNames:''
|
|
36 |
poolDictionaries:''
|
|
37 |
category:'Interface-Tools'
|
|
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
|
|
321 |
^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.7 2012-05-17 15:31:22 vrany Exp $'
|
|
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 |
|
|
382 |
ex parameter signal == AbortOperationRequest ifTrue:[
|
|
383 |
ex return.
|
|
384 |
].
|
|
385 |
ex reject.
|
|
386 |
] do:[
|
|
387 |
AbortOperationRequest raise.
|
|
388 |
].
|
|
389 |
].
|
11518
|
390 |
(worker notNil and:[worker isDead not]) ifTrue:[
|
|
391 |
worker terminate.
|
|
392 |
"/ raise its prio to make it terminate quickly
|
|
393 |
worker priority:(Processor userSchedulingPriority + 1).
|
|
394 |
worker := nil.
|
|
395 |
].
|
|
396 |
|
|
397 |
"Modified: / 11-04-2012 / 16:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
398 |
!
|
|
399 |
|
|
400 |
doOK
|
|
401 |
<resource: #uiCallback>
|
|
402 |
|
|
403 |
(worker notNil and:[worker isDead not]) ifTrue:[
|
11248
|
404 |
worker := nil.
|
|
405 |
worker terminate.
|
|
406 |
"/ raise its prio to make it terminate quickly
|
|
407 |
worker priority:(Processor userSchedulingPriority + 1)
|
|
408 |
].
|
11518
|
409 |
self hide.
|
9987
|
410 |
|
11518
|
411 |
"Modified: / 11-04-2012 / 13:18:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
412 |
! !
|
|
413 |
|
|
414 |
!InlineMessageDialog methodsFor:'adding & removing components'!
|
|
415 |
|
|
416 |
addButton: aButton
|
|
417 |
| layoutView |
|
|
418 |
|
|
419 |
aButton preferredExtent: ((aButton width + 20) max: 70"px") @ 24.
|
|
420 |
layoutView := View new.
|
|
421 |
layoutView backgroundChannel: self backgroundColorOrDefaultHolder.
|
|
422 |
layoutView addComponent: aButton.
|
|
423 |
aButton layout:
|
|
424 |
( LayoutFrame fractions:(0 @ 0.5 corner:1.0 @ 0.5) offsets:(3 @ -12 corner:-3 @ 12) ).
|
|
425 |
layoutView preferredExtent: (aButton preferredExtent x + 12) @ 24.
|
|
426 |
|
|
427 |
^self addComponent: layoutView
|
|
428 |
|
|
429 |
"Created: / 10-04-2012 / 20:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
430 |
!
|
|
431 |
|
|
432 |
addButtonAbort
|
|
433 |
|
|
434 |
^self addButtonWithLabel: (self resources string:'Abort') action: [ self doAbort ]
|
|
435 |
|
|
436 |
"Created: / 10-04-2012 / 21:45:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
437 |
!
|
|
438 |
|
|
439 |
addButtonOK
|
|
440 |
|
|
441 |
^self addButtonWithLabel: (self resources string:'OK') action: [ self doOK ]
|
|
442 |
|
|
443 |
"Created: / 10-04-2012 / 21:44:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
444 |
!
|
|
445 |
|
|
446 |
addButtonWithLabel: label action: action
|
|
447 |
^self addButton: (Button label: label action: action)
|
|
448 |
|
|
449 |
"Created: / 10-04-2012 / 20:50:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9987
|
450 |
!
|
|
451 |
|
11518
|
452 |
addComponent: aView
|
|
453 |
panelView isNil ifTrue:[
|
|
454 |
panelViewComponents isNil ifTrue:[
|
|
455 |
panelViewComponents := OrderedCollection new
|
|
456 |
].
|
|
457 |
panelViewComponents add: aView
|
|
458 |
] ifFalse:[
|
|
459 |
panelView addSubView: aView.
|
|
460 |
aView isVisible: true.
|
|
461 |
].
|
|
462 |
^aView.
|
|
463 |
|
|
464 |
"Created: / 10-04-2012 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
465 |
!
|
|
466 |
|
|
467 |
beInformation
|
|
468 |
|
|
469 |
self backgroundColor: self class defaultInformationBackground.
|
|
470 |
self specHolder value: #messageInfoSpec
|
|
471 |
|
|
472 |
"Created: / 11-04-2012 / 11:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
473 |
!
|
|
474 |
|
|
475 |
beProgress
|
|
476 |
|
|
477 |
self backgroundColor: self class defaultInformationBackground.
|
|
478 |
self specHolder value: #progressInfoSpec
|
|
479 |
|
|
480 |
"Created: / 11-04-2012 / 11:41:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
481 |
!
|
9987
|
482 |
|
11518
|
483 |
beWarning
|
|
484 |
|
|
485 |
self backgroundColor: self class defaultWarningBackground.
|
|
486 |
self specHolder value: #messageInfoSpec
|
|
487 |
|
|
488 |
"Created: / 11-04-2012 / 11:41:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
489 |
!
|
9987
|
490 |
|
11518
|
491 |
removeComponent: aView
|
|
492 |
panelView notNil ifTrue:[
|
|
493 |
panelView removeComponent: aView.
|
|
494 |
].
|
|
495 |
panelViewComponents notNil ifTrue:[
|
|
496 |
panelViewComponents remove: aView ifAbsent:[].
|
|
497 |
]
|
|
498 |
|
|
499 |
"Created: / 11-04-2012 / 00:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
500 |
!
|
|
501 |
|
|
502 |
removeComponents
|
|
503 |
"Removes all components except subcanvas"
|
|
504 |
panelViewComponents := nil.
|
|
505 |
panelView notNil ifTrue:[
|
|
506 |
panelView subViews copyWithoutFirst do:[:component|
|
|
507 |
component destroy
|
|
508 |
]
|
|
509 |
|
|
510 |
].
|
|
511 |
|
|
512 |
"Created: / 11-04-2012 / 00:51:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9987
|
513 |
! !
|
|
514 |
|
|
515 |
!InlineMessageDialog methodsFor:'aspects'!
|
|
516 |
|
11518
|
517 |
backgroundColorHolder
|
|
518 |
"return/create the 'backgroundColorHolder' value holder (automatically generated)"
|
|
519 |
|
|
520 |
backgroundColorHolder isNil ifTrue:[
|
|
521 |
backgroundColorHolder := ValueHolder new.
|
|
522 |
].
|
|
523 |
^ backgroundColorHolder
|
|
524 |
!
|
|
525 |
|
|
526 |
backgroundColorHolder:something
|
|
527 |
"set the 'backgroundColorHolder' value holder (automatically generated)"
|
|
528 |
|
|
529 |
|oldValue newValue|
|
|
530 |
|
|
531 |
backgroundColorHolder notNil ifTrue:[
|
|
532 |
oldValue := backgroundColorHolder value.
|
|
533 |
backgroundColorHolder removeDependent:self.
|
|
534 |
].
|
|
535 |
backgroundColorHolder := something.
|
|
536 |
backgroundColorHolder notNil ifTrue:[
|
|
537 |
backgroundColorHolder addDependent:self.
|
|
538 |
].
|
|
539 |
newValue := backgroundColorHolder value.
|
|
540 |
oldValue ~~ newValue ifTrue:[
|
|
541 |
self update:#value with:newValue from:backgroundColorHolder.
|
|
542 |
].
|
|
543 |
!
|
|
544 |
|
|
545 |
backgroundColorOrDefaultHolder
|
|
546 |
"return/create the 'backgroundColorOrDefaultHolder' value holder (automatically generated)"
|
|
547 |
|
|
548 |
backgroundColorOrDefaultHolder isNil ifTrue:[
|
|
549 |
backgroundColorOrDefaultHolder := ValueHolder new.
|
|
550 |
backgroundColorOrDefaultHolder addDependent:self.
|
|
551 |
].
|
|
552 |
^ backgroundColorOrDefaultHolder
|
|
553 |
!
|
|
554 |
|
9987
|
555 |
messageHolder
|
|
556 |
<resource: #uiAspect>
|
|
557 |
|
|
558 |
messageHolder isNil ifTrue:[
|
|
559 |
messageHolder := ValueHolder new.
|
|
560 |
].
|
|
561 |
^ messageHolder.
|
11509
|
562 |
|
|
563 |
"Modified (comment): / 15-05-2012 / 11:08:35 / cg"
|
9987
|
564 |
!
|
|
565 |
|
11248
|
566 |
panelHiddenHolder
|
|
567 |
"return/create the 'panelHiddenHolder' value holder (automatically generated)"
|
|
568 |
|
|
569 |
panelHiddenHolder isNil ifTrue:[
|
|
570 |
panelHiddenHolder := ValueHolder new.
|
|
571 |
].
|
|
572 |
^ panelHiddenHolder
|
|
573 |
!
|
|
574 |
|
|
575 |
panelHiddenHolder:aValueModel
|
|
576 |
"set the 'panelHiddenHolder' value holder (automatically generated)"
|
|
577 |
|
|
578 |
panelHiddenHolder := aValueModel.
|
|
579 |
!
|
|
580 |
|
|
581 |
panelShownHolder
|
|
582 |
"return/create the 'panelShownHolder' value holder (automatically generated)"
|
|
583 |
|
|
584 |
panelShownHolder isNil ifTrue:[
|
|
585 |
panelShownHolder := ValueHolder new.
|
|
586 |
].
|
|
587 |
^ panelShownHolder
|
|
588 |
!
|
|
589 |
|
|
590 |
panelShownHolder:aValueModel
|
|
591 |
"set the 'panelShownHolder' value holder (automatically generated)"
|
|
592 |
|
|
593 |
panelShownHolder := aValueModel.
|
|
594 |
!
|
|
595 |
|
9987
|
596 |
progressHolder
|
|
597 |
<resource: #uiAspect>
|
|
598 |
|
|
599 |
"automatically generated by UIPainter ..."
|
|
600 |
|
|
601 |
"*** the code below creates a default model when invoked."
|
|
602 |
"*** (which may not be the one you wanted)"
|
|
603 |
"*** Please change as required and accept it in the browser."
|
|
604 |
"*** (and replace this comment by something more useful ;-)"
|
|
605 |
|
|
606 |
progressHolder isNil ifTrue:[
|
|
607 |
progressHolder := ValueHolder new.
|
|
608 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
609 |
"/ progressHolder addDependent:self.
|
|
610 |
"/ progressHolder onChangeSend:#progressHolderChanged to:self.
|
|
611 |
].
|
|
612 |
^ progressHolder.
|
|
613 |
!
|
|
614 |
|
|
615 |
specHolder
|
|
616 |
"return/create the 'specHolder' value holder (automatically generated)"
|
|
617 |
|
|
618 |
specHolder isNil ifTrue:[
|
|
619 |
specHolder := ValueHolder with: #messageInfoSpec.
|
|
620 |
].
|
|
621 |
^ specHolder
|
|
622 |
|
|
623 |
"Modified: / 28-10-2010 / 18:29:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
624 |
! !
|
|
625 |
|
11518
|
626 |
!InlineMessageDialog methodsFor:'change & update'!
|
|
627 |
|
|
628 |
update:aspect with:parameter from:changedObject
|
|
629 |
"Invoked when an object that I depend upon sends a change notification."
|
|
630 |
|
|
631 |
changedObject == backgroundColorHolder ifTrue:[
|
|
632 |
self backgroundColorOrDefaultHolder value: backgroundColorHolder value.
|
|
633 |
^ self.
|
|
634 |
].
|
|
635 |
super update:aspect with:parameter from:changedObject
|
|
636 |
|
|
637 |
"Modified: / 10-04-2012 / 19:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
638 |
! !
|
|
639 |
|
11249
|
640 |
!InlineMessageDialog methodsFor:'hooks'!
|
|
641 |
|
11518
|
642 |
commonPostBuild
|
|
643 |
panelViewComponents notEmptyOrNil ifTrue:[
|
|
644 |
| correctionView |
|
|
645 |
panelViewComponents do:[:each|panelView addSubView: each].
|
|
646 |
"/ "/Correction view, dunno why the layout is bad without it...
|
|
647 |
"/ correctionView := View new.
|
|
648 |
"/ correctionView extent: (panelView subViews size * 3)@24.
|
|
649 |
"/ correctionView backgroundChannel: self backgroundColorOrDefaultHolder.
|
|
650 |
"/ panelView addComponent: correctionView
|
|
651 |
]
|
|
652 |
|
|
653 |
"Created: / 10-04-2012 / 21:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
654 |
!
|
|
655 |
|
|
656 |
postBuildPanelView: aPanelView
|
|
657 |
panelView := aPanelView.
|
|
658 |
|
|
659 |
"Created: / 10-04-2012 / 20:47:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
660 |
!
|
|
661 |
|
11249
|
662 |
postBuildProgressView: aProgressIndicator
|
|
663 |
progressView := aProgressIndicator
|
|
664 |
|
|
665 |
"Created: / 10-02-2012 / 10:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
666 |
! !
|
|
667 |
|
9987
|
668 |
!InlineMessageDialog methodsFor:'private'!
|
|
669 |
|
|
670 |
getMyView
|
|
671 |
|
|
672 |
| v |
|
|
673 |
|
11518
|
674 |
builder isNil ifTrue:[ ^ nil ].
|
9987
|
675 |
v := builder window.
|
|
676 |
^(v superView isKindOf: SubCanvas)
|
|
677 |
ifTrue:[v superView]
|
|
678 |
ifFalse:[v]
|
|
679 |
|
|
680 |
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
681 |
!
|
|
682 |
|
|
683 |
getOtherView
|
|
684 |
|
|
685 |
| myView |
|
|
686 |
|
|
687 |
myView := self getMyView.
|
11518
|
688 |
^ (myView isNil or:[myView superView isNil]) ifTrue:[
|
11248
|
689 |
nil.
|
|
690 |
] ifFalse: [
|
|
691 |
myView superView subViews after: myView
|
|
692 |
].
|
9987
|
693 |
|
|
694 |
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
695 |
!
|
|
696 |
|
|
697 |
hide
|
|
698 |
|
|
699 |
| myView otherView |
|
|
700 |
myView := self getMyView.
|
|
701 |
otherView := self getOtherView.
|
|
702 |
|
11518
|
703 |
myView isVisible ifFalse:[ "/already hidden"
|
|
704 |
self reset.
|
|
705 |
^self
|
|
706 |
].
|
9987
|
707 |
myView isVisible: false.
|
11248
|
708 |
panelShownHolder notNil ifTrue:[
|
|
709 |
panelShownHolder value: false
|
|
710 |
].
|
|
711 |
panelHiddenHolder notNil ifTrue:[
|
|
712 |
panelHiddenHolder value: true
|
|
713 |
].
|
11518
|
714 |
changeLayoutUponShowHide ~~ false ifTrue:[
|
|
715 |
otherView layout: layout.
|
|
716 |
].
|
11248
|
717 |
|
11518
|
718 |
self reset.
|
9987
|
719 |
|
|
720 |
"Created: / 29-10-2010 / 11:55:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
721 |
!
|
|
722 |
|
11518
|
723 |
show
|
9987
|
724 |
|
|
725 |
| myView otherView |
|
|
726 |
myView := self getMyView.
|
|
727 |
otherView := self getOtherView.
|
11518
|
728 |
(myView isNil or:[myView isVisible]) ifTrue:[
|
|
729 |
^self.
|
|
730 |
].
|
9987
|
731 |
myView isVisible: true.
|
11248
|
732 |
panelShownHolder notNil ifTrue:[
|
|
733 |
panelShownHolder value: true
|
|
734 |
].
|
|
735 |
panelHiddenHolder notNil ifTrue:[
|
|
736 |
panelHiddenHolder value: false
|
|
737 |
].
|
|
738 |
|
11518
|
739 |
changeLayoutUponShowHide ~~ false ifTrue:[
|
|
740 |
otherView notNil ifTrue:[
|
|
741 |
layout := otherView layout copy.
|
|
742 |
otherView layout:
|
|
743 |
(layout copy topOffset: layout topOffset + 40; yourself).
|
|
744 |
].
|
|
745 |
].
|
|
746 |
|
|
747 |
"Created: / 11-04-2012 / 11:43:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
748 |
!
|
|
749 |
|
|
750 |
show: spec
|
|
751 |
<resource: #obsolete>
|
|
752 |
|
|
753 |
self obsoleteMethodWarning.
|
|
754 |
self breakPoint: #jv.
|
|
755 |
|
|
756 |
spec == #warningInfoSpec ifTrue:[ self beWarning ].
|
|
757 |
spec == #messageInfoSpec ifTrue:[ self beInformation ].
|
|
758 |
spec == #progressInfoSpec ifTrue:[ self beProgress ].
|
|
759 |
self show.
|
9987
|
760 |
|
|
761 |
"Created: / 29-10-2010 / 11:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
762 |
! !
|
|
763 |
|
11518
|
764 |
!InlineMessageDialog methodsFor:'utilities'!
|
|
765 |
|
|
766 |
reset
|
|
767 |
"Resets the dialog to initial state, removes all
|
|
768 |
user supplied components."
|
|
769 |
|
|
770 |
self removeComponents.
|
|
771 |
|
|
772 |
"Created: / 11-04-2012 / 00:51:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
773 |
!
|
|
774 |
|
|
775 |
showMessage: aString
|
|
776 |
"Shows given message and OK button (which closes the dialog
|
|
777 |
when clicked"
|
|
778 |
|
|
779 |
self showMessage: aString closeAfter: nil
|
|
780 |
|
|
781 |
"Created: / 11-04-2012 / 13:11:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
782 |
!
|
|
783 |
|
|
784 |
showMessage: aString closeAfter: aTimeDurationOrIntegerOrNil
|
|
785 |
"Shows given message and OK button (which closes the dialog
|
|
786 |
when clicked). The dialog closes automaticaly after
|
|
787 |
aTimeDurationOrIntegerOrNil (integer value means secons, nil
|
|
788 |
means do not close automatically)"
|
|
789 |
|
|
790 |
|
|
791 |
self reset.
|
|
792 |
self beInformation.
|
|
793 |
self message: aString.
|
|
794 |
self addButtonOK.
|
|
795 |
self show.
|
|
796 |
aTimeDurationOrIntegerOrNil notNil ifTrue:[
|
|
797 |
worker :=
|
|
798 |
[
|
|
799 |
aTimeDurationOrIntegerOrNil isInteger ifTrue:[
|
|
800 |
Delay waitForSeconds: aTimeDurationOrIntegerOrNil.
|
|
801 |
] ifFalse:[
|
|
802 |
Delay waitForMilliseconds: aTimeDurationOrIntegerOrNil milliseconds
|
|
803 |
].
|
|
804 |
self hide.
|
|
805 |
] newProcess.
|
|
806 |
worker addExitAction:[ worker := nil ].
|
|
807 |
worker resume.
|
|
808 |
].
|
|
809 |
|
|
810 |
"Created: / 11-04-2012 / 13:13:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
811 |
!
|
|
812 |
|
|
813 |
showProgressLabeled: aString while: aBlock
|
|
814 |
"During an execution of aBlock, show a label with given
|
|
815 |
string, a progressbar showing the progress and an 'Abort' button.
|
|
816 |
|
|
817 |
If the block raises a ProgressNotification, then the percentage
|
|
818 |
progress is updated accordingly. If it raises an ActivityNotification,
|
|
819 |
then the label is updated and progress bar is changed to be an
|
|
820 |
activity notificator.
|
|
821 |
|
|
822 |
When an 'Abort' button is pressed, the block is interrupted by
|
|
823 |
AbortOperationRequest.
|
|
824 |
|
|
825 |
When a block terminates (either normally or abruptly, dialog is closed.
|
|
826 |
"
|
|
827 |
|
|
828 |
worker := [
|
|
829 |
self reset.
|
|
830 |
self beProgress.
|
|
831 |
self message: aString.
|
|
832 |
self addButtonAbort.
|
|
833 |
self progress: nil.
|
|
834 |
self show.
|
|
835 |
[
|
|
836 |
aBlock value.
|
|
837 |
] on: ProgressNotification , ActivityNotification do:[:ex|
|
|
838 |
self progress: ex parameter.
|
|
839 |
ex messageText notNil ifTrue:[
|
|
840 |
self message: ex messageText.
|
|
841 |
].
|
|
842 |
ex proceed.
|
|
843 |
].
|
|
844 |
] newProcess.
|
|
845 |
worker addExitAction:[
|
|
846 |
"This check is required, since somebody may want to show
|
|
847 |
info/warning from within the action block"
|
|
848 |
self specHolder value == #progressInfoSpec ifTrue:[
|
|
849 |
self hide.
|
|
850 |
].
|
|
851 |
worker := nil.
|
|
852 |
].
|
|
853 |
worker resume.
|
|
854 |
|
|
855 |
"Created: / 11-04-2012 / 13:38:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
856 |
! !
|
|
857 |
|
|
858 |
!InlineMessageDialog methodsFor:'utilities-obsolete'!
|
|
859 |
|
|
860 |
information: message
|
|
861 |
|
|
862 |
self information: message timeout: nil
|
|
863 |
|
|
864 |
"Created: / 11-02-2012 / 23:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
865 |
!
|
|
866 |
|
|
867 |
information: message timeout: timeoutOrNil
|
|
868 |
|
|
869 |
self reset.
|
|
870 |
self beInformation.
|
|
871 |
self message: message.
|
|
872 |
self addButtonOK.
|
|
873 |
self show.
|
|
874 |
timeoutOrNil isInteger ifTrue:[
|
|
875 |
[
|
|
876 |
Delay waitForSeconds: timeoutOrNil.
|
|
877 |
self hide.
|
|
878 |
] fork.
|
|
879 |
]
|
|
880 |
|
|
881 |
"Created: / 11-02-2012 / 23:14:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
882 |
!
|
|
883 |
|
|
884 |
progress: label while: block
|
|
885 |
|
|
886 |
worker := [
|
|
887 |
self reset.
|
|
888 |
self beProgress.
|
|
889 |
self message: label.
|
|
890 |
self addButtonAbort.
|
|
891 |
self progress: nil.
|
|
892 |
self show.
|
|
893 |
[
|
|
894 |
block value.
|
|
895 |
] on: ProgressNotification , ActivityNotification do:[:ex|
|
|
896 |
self progress: ex parameter.
|
|
897 |
ex messageText notNil ifTrue:[
|
|
898 |
self message: ex messageText.
|
|
899 |
].
|
|
900 |
ex proceed.
|
|
901 |
].
|
|
902 |
] newProcess.
|
|
903 |
worker addExitAction:[
|
|
904 |
self specHolder value == #progressInfoSpec ifTrue:[
|
|
905 |
self hide.
|
|
906 |
].
|
|
907 |
worker := nil.
|
|
908 |
].
|
|
909 |
worker resume.
|
|
910 |
|
|
911 |
"Created: / 10-02-2012 / 10:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
912 |
!
|
|
913 |
|
|
914 |
warning: message action: block labeled: label
|
|
915 |
|
|
916 |
self reset.
|
|
917 |
self beWarning.
|
|
918 |
self message: message.
|
|
919 |
self addButtonWithLabel: label action: block.
|
|
920 |
self addButtonOK.
|
|
921 |
self show
|
|
922 |
|
|
923 |
"Created: / 13-02-2012 / 16:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
924 |
! !
|
|
925 |
|
9987
|
926 |
!InlineMessageDialog class methodsFor:'documentation'!
|
|
927 |
|
11249
|
928 |
version
|
11518
|
929 |
^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.7 2012-05-17 15:31:22 vrany Exp $'
|
11249
|
930 |
!
|
|
931 |
|
9987
|
932 |
version_SVN
|
11518
|
933 |
^ '§Id: Tools__InlineMessageDialog.st 7976 2012-04-11 16:14:22Z vranyj1 §'
|
9987
|
934 |
! !
|