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
|
11248
|
31 |
instanceVariableNames:'messageHolder progressHolder progressView specHolder
|
|
32 |
panelShownHolder panelHiddenHolder worker layout'
|
9987
|
33 |
classVariableNames:''
|
|
34 |
poolDictionaries:''
|
|
35 |
category:'Interface-Tools'
|
|
36 |
!
|
|
37 |
|
|
38 |
!InlineMessageDialog class methodsFor:'documentation'!
|
|
39 |
|
|
40 |
copyright
|
|
41 |
"
|
10099
|
42 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
|
|
43 |
Copyright (c) 2009-2010 eXept Software AG
|
|
44 |
|
|
45 |
Permission is hereby granted, free of charge, to any person
|
|
46 |
obtaining a copy of this software and associated documentation
|
|
47 |
files (the 'Software'), to deal in the Software without
|
|
48 |
restriction, including without limitation the rights to use,
|
|
49 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
50 |
copies of the Software, and to permit persons to whom the
|
|
51 |
Software is furnished to do so, subject to the following
|
|
52 |
conditions:
|
9987
|
53 |
|
10099
|
54 |
The above copyright notice and this permission notice shall be
|
|
55 |
included in all copies or substantial portions of the Software.
|
|
56 |
|
|
57 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
58 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
59 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
60 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
61 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
62 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
63 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
64 |
OTHER DEALINGS IN THE SOFTWARE.
|
9987
|
65 |
"
|
|
66 |
! !
|
|
67 |
|
|
68 |
!InlineMessageDialog class methodsFor:'interface specs'!
|
|
69 |
|
|
70 |
messageInfoSpec
|
|
71 |
"This resource specification was automatically generated
|
|
72 |
by the UIPainter of ST/X."
|
|
73 |
|
|
74 |
"Do not manually edit this!! If it is corrupted,
|
|
75 |
the UIPainter may not be able to read the specification."
|
|
76 |
|
|
77 |
"
|
|
78 |
UIPainter new openOnClass:Tools::NewSystemBrowser andSelector:#messageInfoSpec
|
|
79 |
Tools::NewSystemBrowser new openInterface:#messageInfoSpec
|
|
80 |
"
|
|
81 |
|
|
82 |
<resource: #canvas>
|
|
83 |
|
|
84 |
^
|
|
85 |
#(FullSpec
|
|
86 |
name: messageInfoSpec
|
|
87 |
window:
|
|
88 |
(WindowSpec
|
|
89 |
label: 'MessageInfo'
|
|
90 |
name: 'MessageInfo'
|
|
91 |
min: (Point 10 10)
|
|
92 |
bounds: (Rectangle 0 0 800 40)
|
|
93 |
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
|
|
94 |
forceRecursiveBackgroundOfDefaultBackground: true
|
|
95 |
)
|
|
96 |
component:
|
|
97 |
(SpecCollection
|
|
98 |
collection: (
|
|
99 |
(LabelSpec
|
|
100 |
label: 'Label'
|
|
101 |
name: 'Message'
|
|
102 |
layout: (LayoutFrame 10 0 -10 0.5 -90 1 10 0.5)
|
|
103 |
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
|
|
104 |
translateLabel: true
|
|
105 |
labelChannel: messageHolder
|
|
106 |
adjust: left
|
|
107 |
)
|
|
108 |
(ActionButtonSpec
|
|
109 |
label: 'OK'
|
|
110 |
name: 'OK'
|
|
111 |
layout: (LayoutFrame -80 1 -12 0.5 -12 1 12 0.5)
|
|
112 |
translateLabel: true
|
|
113 |
model: doOK
|
|
114 |
)
|
|
115 |
)
|
|
116 |
|
|
117 |
)
|
|
118 |
)
|
|
119 |
|
|
120 |
"Modified: / 28-10-2010 / 18:30:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
121 |
!
|
|
122 |
|
|
123 |
progressInfoSpec
|
|
124 |
"This resource specification was automatically generated
|
|
125 |
by the UIPainter of ST/X."
|
|
126 |
|
|
127 |
"Do not manually edit this!! If it is corrupted,
|
|
128 |
the UIPainter may not be able to read the specification."
|
|
129 |
|
|
130 |
"
|
|
131 |
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#progressInfoSpec
|
|
132 |
Tools::InlineMessageDialog new openInterface:#progressInfoSpec
|
|
133 |
"
|
|
134 |
|
|
135 |
<resource: #canvas>
|
|
136 |
|
|
137 |
^
|
|
138 |
#(FullSpec
|
|
139 |
name: progressInfoSpec
|
|
140 |
window:
|
|
141 |
(WindowSpec
|
|
142 |
label: 'ProgressInfo'
|
|
143 |
name: 'ProgressInfo'
|
|
144 |
min: (Point 10 10)
|
|
145 |
bounds: (Rectangle 0 0 800 40)
|
|
146 |
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
|
|
147 |
forceRecursiveBackgroundOfDefaultBackground: true
|
|
148 |
)
|
|
149 |
component:
|
|
150 |
(SpecCollection
|
|
151 |
collection: (
|
|
152 |
(LabelSpec
|
|
153 |
label: 'Label'
|
|
154 |
name: 'Message'
|
|
155 |
layout: (LayoutFrame 10 0 0 0 -90 1 20 0)
|
|
156 |
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
|
|
157 |
translateLabel: true
|
|
158 |
labelChannel: messageHolder
|
|
159 |
adjust: left
|
|
160 |
)
|
|
161 |
(ProgressIndicatorSpec
|
|
162 |
name: 'ProgressIndicator'
|
10470
|
163 |
layout: (LayoutFrame 10 0 -20 1 -133 1 -3 1)
|
9987
|
164 |
model: progressHolder
|
|
165 |
foregroundColor: (Color 52.156862745098 37.2549019607843 0.0)
|
|
166 |
backgroundColor: (Color 100.0 91.3725490196078 70.1960784313726)
|
11248
|
167 |
postBuildCallback: postBuildProgressView:
|
9987
|
168 |
)
|
|
169 |
(ActionButtonSpec
|
|
170 |
label: 'Abort'
|
|
171 |
name: 'Abort'
|
10470
|
172 |
layout: (AlignmentOrigin -12 1 0 0.5 1 0.5)
|
9987
|
173 |
translateLabel: true
|
10470
|
174 |
resizeForLabel: true
|
9987
|
175 |
model: doAbort
|
|
176 |
)
|
|
177 |
)
|
|
178 |
|
|
179 |
)
|
|
180 |
)
|
|
181 |
!
|
|
182 |
|
|
183 |
windowSpec
|
|
184 |
"This resource specification was automatically generated
|
|
185 |
by the UIPainter of ST/X."
|
|
186 |
|
|
187 |
"Do not manually edit this!! If it is corrupted,
|
|
188 |
the UIPainter may not be able to read the specification."
|
|
189 |
|
|
190 |
"
|
|
191 |
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#windowSpec
|
|
192 |
Tools::InlineMessageDialog new openInterface:#windowSpec
|
|
193 |
Tools::InlineMessageDialog open
|
|
194 |
"
|
|
195 |
|
|
196 |
<resource: #canvas>
|
|
197 |
|
|
198 |
^
|
|
199 |
#(FullSpec
|
|
200 |
name: windowSpec
|
|
201 |
window:
|
|
202 |
(WindowSpec
|
|
203 |
label: 'Tools::InlineMessageDialog'
|
|
204 |
name: 'Tools::InlineMessageDialog'
|
|
205 |
min: (Point 10 10)
|
|
206 |
bounds: (Rectangle 0 0 800 40)
|
|
207 |
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
|
|
208 |
forceRecursiveBackgroundOfDefaultBackground: true
|
|
209 |
)
|
|
210 |
component:
|
|
211 |
(SpecCollection
|
|
212 |
collection: (
|
|
213 |
(SubCanvasSpec
|
|
214 |
name: 'InfoSpec'
|
|
215 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
|
|
216 |
hasHorizontalScrollBar: false
|
|
217 |
hasVerticalScrollBar: false
|
|
218 |
miniScrollerHorizontal: false
|
|
219 |
specHolder: specHolder
|
|
220 |
createNewBuilder: false
|
|
221 |
)
|
|
222 |
)
|
|
223 |
|
|
224 |
)
|
|
225 |
)
|
|
226 |
! !
|
|
227 |
|
11248
|
228 |
!InlineMessageDialog class methodsFor:'others'!
|
|
229 |
|
|
230 |
version_CVS
|
|
231 |
^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.4 2012-02-11 23:35:59 vrany Exp $'
|
|
232 |
! !
|
|
233 |
|
9987
|
234 |
!InlineMessageDialog methodsFor:'accessing'!
|
|
235 |
|
|
236 |
message: aString
|
|
237 |
|
|
238 |
self messageHolder value: aString
|
|
239 |
|
|
240 |
"Created: / 28-10-2010 / 18:23:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
241 |
!
|
|
242 |
|
|
243 |
progress: aNumberOrNil
|
|
244 |
|
|
245 |
self progressHolder value: aNumberOrNil
|
|
246 |
|
|
247 |
"Created: / 28-10-2010 / 18:24:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
248 |
! !
|
|
249 |
|
|
250 |
!InlineMessageDialog methodsFor:'actions'!
|
|
251 |
|
|
252 |
doAbort
|
|
253 |
|
11248
|
254 |
worker isNil ifTrue:[ self hide. ^ self ].
|
|
255 |
worker interruptWith:[
|
|
256 |
NoHandlerError handle:[:ex |
|
|
257 |
ex parameter signal == AbortOperationRequest ifTrue:[
|
|
258 |
ex return.
|
|
259 |
].
|
|
260 |
ex reject.
|
|
261 |
] do:[
|
|
262 |
AbortOperationRequest raise.
|
|
263 |
].
|
|
264 |
].
|
|
265 |
(worker notNil and:[worker isDead]) ifTrue:[
|
|
266 |
worker := nil.
|
|
267 |
worker terminate.
|
|
268 |
"/ raise its prio to make it terminate quickly
|
|
269 |
worker priority:(Processor userSchedulingPriority + 1)
|
|
270 |
].
|
9987
|
271 |
|
11248
|
272 |
"Modified: / 10-02-2012 / 10:49:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9987
|
273 |
!
|
|
274 |
|
|
275 |
doOK
|
|
276 |
<resource: #uiCallback>
|
|
277 |
|
|
278 |
self hide.
|
|
279 |
|
|
280 |
"Modified: / 28-10-2010 / 18:21:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
281 |
! !
|
|
282 |
|
|
283 |
!InlineMessageDialog methodsFor:'aspects'!
|
|
284 |
|
|
285 |
messageHolder
|
|
286 |
<resource: #uiAspect>
|
|
287 |
|
|
288 |
"automatically generated by UIPainter ..."
|
|
289 |
|
|
290 |
"*** the code below creates a default model when invoked."
|
|
291 |
"*** (which may not be the one you wanted)"
|
|
292 |
"*** Please change as required and accept it in the browser."
|
|
293 |
"*** (and replace this comment by something more useful ;-)"
|
|
294 |
|
|
295 |
messageHolder isNil ifTrue:[
|
|
296 |
messageHolder := ValueHolder new.
|
|
297 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
298 |
"/ messageHolder addDependent:self.
|
|
299 |
"/ messageHolder onChangeSend:#messageHolderChanged to:self.
|
|
300 |
].
|
|
301 |
^ messageHolder.
|
|
302 |
!
|
|
303 |
|
11248
|
304 |
panelHiddenHolder
|
|
305 |
"return/create the 'panelHiddenHolder' value holder (automatically generated)"
|
|
306 |
|
|
307 |
panelHiddenHolder isNil ifTrue:[
|
|
308 |
panelHiddenHolder := ValueHolder new.
|
|
309 |
].
|
|
310 |
^ panelHiddenHolder
|
|
311 |
!
|
|
312 |
|
|
313 |
panelHiddenHolder:aValueModel
|
|
314 |
"set the 'panelHiddenHolder' value holder (automatically generated)"
|
|
315 |
|
|
316 |
panelHiddenHolder := aValueModel.
|
|
317 |
!
|
|
318 |
|
|
319 |
panelShownHolder
|
|
320 |
"return/create the 'panelShownHolder' value holder (automatically generated)"
|
|
321 |
|
|
322 |
panelShownHolder isNil ifTrue:[
|
|
323 |
panelShownHolder := ValueHolder new.
|
|
324 |
].
|
|
325 |
^ panelShownHolder
|
|
326 |
!
|
|
327 |
|
|
328 |
panelShownHolder:aValueModel
|
|
329 |
"set the 'panelShownHolder' value holder (automatically generated)"
|
|
330 |
|
|
331 |
panelShownHolder := aValueModel.
|
|
332 |
!
|
|
333 |
|
9987
|
334 |
progressHolder
|
|
335 |
<resource: #uiAspect>
|
|
336 |
|
|
337 |
"automatically generated by UIPainter ..."
|
|
338 |
|
|
339 |
"*** the code below creates a default model when invoked."
|
|
340 |
"*** (which may not be the one you wanted)"
|
|
341 |
"*** Please change as required and accept it in the browser."
|
|
342 |
"*** (and replace this comment by something more useful ;-)"
|
|
343 |
|
|
344 |
progressHolder isNil ifTrue:[
|
|
345 |
progressHolder := ValueHolder new.
|
|
346 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
347 |
"/ progressHolder addDependent:self.
|
|
348 |
"/ progressHolder onChangeSend:#progressHolderChanged to:self.
|
|
349 |
].
|
|
350 |
^ progressHolder.
|
|
351 |
!
|
|
352 |
|
|
353 |
specHolder
|
|
354 |
"return/create the 'specHolder' value holder (automatically generated)"
|
|
355 |
|
|
356 |
specHolder isNil ifTrue:[
|
|
357 |
specHolder := ValueHolder with: #messageInfoSpec.
|
|
358 |
].
|
|
359 |
^ specHolder
|
|
360 |
|
|
361 |
"Modified: / 28-10-2010 / 18:29:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
362 |
! !
|
|
363 |
|
11248
|
364 |
!InlineMessageDialog methodsFor:'informing'!
|
|
365 |
|
|
366 |
information: message
|
|
367 |
|
|
368 |
self information: message timeout: nil
|
|
369 |
|
|
370 |
"Created: / 11-02-2012 / 23:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
371 |
!
|
|
372 |
|
|
373 |
information: message timeout: timeoutOrNil
|
|
374 |
|
|
375 |
self message: message.
|
|
376 |
self show: #messageInfoSpec.
|
|
377 |
timeoutOrNil isInteger ifTrue:[
|
|
378 |
[
|
|
379 |
Delay waitForSeconds: timeoutOrNil.
|
|
380 |
self hide.
|
|
381 |
] fork.
|
|
382 |
]
|
|
383 |
|
|
384 |
"Created: / 11-02-2012 / 23:14:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
385 |
!
|
|
386 |
|
|
387 |
progress: label while: block
|
|
388 |
|
|
389 |
worker := [
|
|
390 |
self message: label.
|
|
391 |
self progress: nil.
|
|
392 |
self show: #progressInfoSpec.
|
|
393 |
[
|
|
394 |
block value.
|
|
395 |
] on: ProgressNotification do:[:ex|
|
|
396 |
self progress: ex progressValue.
|
|
397 |
ex messageText notNil ifTrue:[
|
|
398 |
self message: ex messageText.
|
|
399 |
].
|
|
400 |
ex proceed.
|
|
401 |
].
|
|
402 |
] newProcess.
|
|
403 |
worker addExitAction:[
|
|
404 |
self hide.
|
|
405 |
worker := nil.
|
|
406 |
].
|
|
407 |
worker resume.
|
|
408 |
|
|
409 |
"Created: / 10-02-2012 / 10:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
410 |
! !
|
|
411 |
|
|
412 |
!InlineMessageDialog methodsFor:'initializing'!
|
|
413 |
|
|
414 |
postBuildProgressView: aView
|
|
415 |
|
|
416 |
aView showBusyIndication:
|
|
417 |
(BlockValue
|
|
418 |
with: [:p|p value isNil]
|
|
419 |
argument: self progressHolder)
|
|
420 |
|
|
421 |
"Created: / 10-02-2012 / 10:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
422 |
! !
|
|
423 |
|
9987
|
424 |
!InlineMessageDialog methodsFor:'private'!
|
|
425 |
|
|
426 |
getMyView
|
|
427 |
|
|
428 |
| v |
|
|
429 |
|
|
430 |
v := builder window.
|
|
431 |
^(v superView isKindOf: SubCanvas)
|
|
432 |
ifTrue:[v superView]
|
|
433 |
ifFalse:[v]
|
|
434 |
|
|
435 |
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
436 |
!
|
|
437 |
|
|
438 |
getOtherView
|
|
439 |
|
|
440 |
| myView |
|
|
441 |
|
|
442 |
myView := self getMyView.
|
11248
|
443 |
^ myView superView isNil ifTrue:[
|
|
444 |
nil.
|
|
445 |
] ifFalse: [
|
|
446 |
myView superView subViews after: myView
|
|
447 |
].
|
9987
|
448 |
|
|
449 |
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
450 |
!
|
|
451 |
|
|
452 |
hide
|
|
453 |
|
|
454 |
| myView otherView |
|
|
455 |
myView := self getMyView.
|
|
456 |
otherView := self getOtherView.
|
|
457 |
|
|
458 |
myView isVisible ifFalse:[^self]."/already hidden"
|
|
459 |
myView isVisible: false.
|
11248
|
460 |
panelShownHolder notNil ifTrue:[
|
|
461 |
panelShownHolder value: false
|
|
462 |
].
|
|
463 |
panelHiddenHolder notNil ifTrue:[
|
|
464 |
panelHiddenHolder value: true
|
|
465 |
].
|
|
466 |
|
|
467 |
otherView layout: layout
|
9987
|
468 |
|
|
469 |
"Created: / 29-10-2010 / 11:55:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
470 |
!
|
|
471 |
|
|
472 |
show: spec
|
|
473 |
|
|
474 |
| myView otherView |
|
|
475 |
myView := self getMyView.
|
|
476 |
otherView := self getOtherView.
|
|
477 |
myView isVisible ifTrue:[^self]."/already shown"
|
11248
|
478 |
layout := otherView layout copy.
|
9987
|
479 |
myView isVisible: true.
|
11248
|
480 |
panelShownHolder notNil ifTrue:[
|
|
481 |
panelShownHolder value: true
|
|
482 |
].
|
|
483 |
panelHiddenHolder notNil ifTrue:[
|
|
484 |
panelHiddenHolder value: false
|
|
485 |
].
|
|
486 |
|
9987
|
487 |
otherView layout:
|
11248
|
488 |
(layout copy topOffset: layout topOffset + 40; yourself).
|
9987
|
489 |
self specHolder value: spec.
|
|
490 |
|
|
491 |
"Created: / 29-10-2010 / 11:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
492 |
! !
|
|
493 |
|
|
494 |
!InlineMessageDialog class methodsFor:'documentation'!
|
|
495 |
|
|
496 |
version_SVN
|
11248
|
497 |
^ '§Id: Tools__InlineMessageDialog.st 7881 2012-02-11 22:16:34Z vranyj1 §'
|
9987
|
498 |
! !
|