"
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
Copyright (c) 2009-2010 eXept Software AG
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"
"{ Package: 'stx:libtool' }"
"{ NameSpace: Tools }"
ApplicationModel subclass:#InlineMessageDialog
instanceVariableNames:'messageHolder progressHolder progressView specHolder
panelShownHolder panelHiddenHolder worker layout customAction
customActionVisibleHolder customActionLabelHolder'
classVariableNames:''
poolDictionaries:''
category:'Interface-Tools'
!
!InlineMessageDialog class methodsFor:'documentation'!
copyright
"
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
Copyright (c) 2009-2010 eXept Software AG
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"
! !
!InlineMessageDialog class methodsFor:'interface specs'!
messageInfoSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::NewSystemBrowser andSelector:#messageInfoSpec
Tools::NewSystemBrowser new openInterface:#messageInfoSpec
"
<resource: #canvas>
^
#(FullSpec
name: messageInfoSpec
window:
(WindowSpec
label: 'MessageInfo'
name: 'MessageInfo'
min: (Point 10 10)
bounds: (Rectangle 0 0 800 40)
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
forceRecursiveBackgroundOfDefaultBackground: true
)
component:
(SpecCollection
collection: (
(LabelSpec
label: 'Label'
name: 'Message'
layout: (LayoutFrame 10 0 -10 0.5 -90 1 10 0.5)
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
translateLabel: true
labelChannel: messageHolder
adjust: left
)
(ActionButtonSpec
label: 'OK'
name: 'OK'
layout: (LayoutFrame -80 1 -12 0.5 -12 1 12 0.5)
translateLabel: true
model: doOK
)
)
)
)
"Modified: / 28-10-2010 / 18:30:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
progressInfoSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#progressInfoSpec
Tools::InlineMessageDialog new openInterface:#progressInfoSpec
"
<resource: #canvas>
^
#(FullSpec
name: progressInfoSpec
window:
(WindowSpec
label: 'ProgressInfo'
name: 'ProgressInfo'
min: (Point 10 10)
bounds: (Rectangle 0 0 800 40)
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
forceRecursiveBackgroundOfDefaultBackground: true
)
component:
(SpecCollection
collection: (
(LabelSpec
label: 'Label'
name: 'Message'
layout: (LayoutFrame 10 0 0 0 -90 1 20 0)
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
translateLabel: true
labelChannel: messageHolder
adjust: left
)
(ProgressIndicatorSpec
name: 'ProgressIndicator'
layout: (LayoutFrame 10 0 -20 1 -133 1 -3 1)
model: progressHolder
foregroundColor: (Color 52.156862745098 37.2549019607843 0.0)
backgroundColor: (Color 100.0 91.3725490196078 70.1960784313726)
postBuildCallback: postBuildProgressView:
)
(ActionButtonSpec
label: 'Abort'
name: 'Abort'
layout: (AlignmentOrigin -12 1 0 0.5 1 0.5)
translateLabel: true
resizeForLabel: true
model: doAbort
)
)
)
)
!
warningInfoSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#warningInfoSpec
Tools::InlineMessageDialog new openInterface:#warningInfoSpec
"
<resource: #canvas>
^
#(FullSpec
name: warningInfoSpec
window:
(WindowSpec
label: 'MessageInfo'
name: 'MessageInfo'
min: (Point 10 10)
bounds: (Rectangle 0 0 800 40)
backgroundColor: (Color 76.078431372549 43.1372549019608 43.1372549019608)
forceRecursiveBackgroundOfDefaultBackground: true
)
component:
(SpecCollection
collection: (
(LabelSpec
label: 'Label'
name: 'Message'
layout: (LayoutFrame 10 0 -10 0.5 -160 1 10 0.5)
backgroundColor: (Color 76.078431372549 43.1372549019608 43.1372549019608)
translateLabel: true
labelChannel: messageHolder
adjust: left
)
(ActionButtonSpec
label: 'OK'
name: 'OK'
layout: (LayoutFrame -80 1 -12 0.5 -12 1 12 0.5)
translateLabel: true
model: doOK
)
(ActionButtonSpec
label: 'Details'
name: 'Button1'
layout: (LayoutFrame -160 1 -12 0.5 -92 1 12 0.5)
visibilityChannel: customActionVisibleHolder
translateLabel: true
labelChannel: customActionLabelHolder
model: doCustomAction
)
)
)
)
!
windowSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#windowSpec
Tools::InlineMessageDialog new openInterface:#windowSpec
Tools::InlineMessageDialog open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'Tools::InlineMessageDialog'
name: 'Tools::InlineMessageDialog'
min: (Point 10 10)
bounds: (Rectangle 0 0 800 40)
backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
forceRecursiveBackgroundOfDefaultBackground: true
)
component:
(SpecCollection
collection: (
(SubCanvasSpec
name: 'InfoSpec'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
hasHorizontalScrollBar: false
hasVerticalScrollBar: false
miniScrollerHorizontal: false
specHolder: specHolder
createNewBuilder: false
)
)
)
)
! !
!InlineMessageDialog methodsFor:'accessing'!
customAction
^ customAction
!
customAction:aBlock
customAction := aBlock.
self customActionVisibleHolder value: true.
"Modified: / 13-02-2012 / 18:45:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
message: aString
self messageHolder value: aString
"Created: / 28-10-2010 / 18:23:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
progress: aNumberOrNil
aNumberOrNil isNumber ifTrue:[
progressView notNil ifTrue:[
progressView showBusyIndication: false.
].
self progressHolder value: aNumberOrNil
] ifFalse:[
progressView notNil ifTrue:[
progressView showBusyIndication: true.
]
]
"Created: / 28-10-2010 / 18:24:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!InlineMessageDialog methodsFor:'actions'!
doAbort
worker isNil ifTrue:[ self hide. ^ self ].
worker interruptWith:[
NoHandlerError handle:[:ex |
ex parameter signal == AbortOperationRequest ifTrue:[
ex return.
].
ex reject.
] do:[
AbortOperationRequest raise.
].
].
(worker notNil and:[worker isDead]) ifTrue:[
worker := nil.
worker terminate.
"/ raise its prio to make it terminate quickly
worker priority:(Processor userSchedulingPriority + 1)
].
"Modified: / 10-02-2012 / 10:49:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doCustomAction
customAction value
"Created: / 13-02-2012 / 18:46:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doOK
<resource: #uiCallback>
self hide.
"Modified: / 28-10-2010 / 18:21:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!InlineMessageDialog methodsFor:'aspects'!
customActionLabelHolder
<resource: #uiAspect>
"automatically generated by UIPainter ..."
"*** the code below creates a default model when invoked."
"*** (which may not be the one you wanted)"
"*** Please change as required and accept it in the browser."
"*** (and replace this comment by something more useful ;-)"
customActionLabelHolder isNil ifTrue:[
customActionLabelHolder := 'buttonLabel' asValue.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/ customActionLabelHolder addDependent:self.
"/ customActionLabelHolder onChangeSend:#customActionLabelHolderChanged to:self.
].
^ customActionLabelHolder.
!
customActionVisibleHolder
<resource: #uiAspect>
"automatically generated by UIPainter ..."
"*** the code below creates a default model when invoked."
"*** (which may not be the one you wanted)"
"*** Please change as required and accept it in the browser."
"*** (and replace this comment by something more useful ;-)"
customActionVisibleHolder isNil ifTrue:[
customActionVisibleHolder := false asValue.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/ customActionVisibleHolder addDependent:self.
"/ customActionVisibleHolder onChangeSend:#customActionVisibleHolderChanged to:self.
].
^ customActionVisibleHolder.
"Modified: / 13-02-2012 / 16:56:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
messageHolder
<resource: #uiAspect>
"automatically generated by UIPainter ..."
"*** the code below creates a default model when invoked."
"*** (which may not be the one you wanted)"
"*** Please change as required and accept it in the browser."
"*** (and replace this comment by something more useful ;-)"
messageHolder isNil ifTrue:[
messageHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/ messageHolder addDependent:self.
"/ messageHolder onChangeSend:#messageHolderChanged to:self.
].
^ messageHolder.
!
panelHiddenHolder
"return/create the 'panelHiddenHolder' value holder (automatically generated)"
panelHiddenHolder isNil ifTrue:[
panelHiddenHolder := ValueHolder new.
].
^ panelHiddenHolder
!
panelHiddenHolder:aValueModel
"set the 'panelHiddenHolder' value holder (automatically generated)"
panelHiddenHolder := aValueModel.
!
panelShownHolder
"return/create the 'panelShownHolder' value holder (automatically generated)"
panelShownHolder isNil ifTrue:[
panelShownHolder := ValueHolder new.
].
^ panelShownHolder
!
panelShownHolder:aValueModel
"set the 'panelShownHolder' value holder (automatically generated)"
panelShownHolder := aValueModel.
!
progressHolder
<resource: #uiAspect>
"automatically generated by UIPainter ..."
"*** the code below creates a default model when invoked."
"*** (which may not be the one you wanted)"
"*** Please change as required and accept it in the browser."
"*** (and replace this comment by something more useful ;-)"
progressHolder isNil ifTrue:[
progressHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/ progressHolder addDependent:self.
"/ progressHolder onChangeSend:#progressHolderChanged to:self.
].
^ progressHolder.
!
specHolder
"return/create the 'specHolder' value holder (automatically generated)"
specHolder isNil ifTrue:[
specHolder := ValueHolder with: #messageInfoSpec.
].
^ specHolder
"Modified: / 28-10-2010 / 18:29:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!InlineMessageDialog methodsFor:'hooks'!
postBuildProgressView: aProgressIndicator
progressView := aProgressIndicator
"Created: / 10-02-2012 / 10:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!InlineMessageDialog methodsFor:'informing'!
information: message
self information: message timeout: nil
"Created: / 11-02-2012 / 23:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
information: message timeout: timeoutOrNil
self message: message.
self show: #messageInfoSpec.
timeoutOrNil isInteger ifTrue:[
[
Delay waitForSeconds: timeoutOrNil.
self hide.
] fork.
]
"Created: / 11-02-2012 / 23:14:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
progress: label while: block
worker := [
self message: label.
self progress: nil.
self show: #progressInfoSpec.
[
block value.
] on: ProgressNotification , ActivityNotification do:[:ex|
self progress: ex parameter.
ex messageText notNil ifTrue:[
self message: ex messageText.
].
ex proceed.
].
] newProcess.
worker addExitAction:[
self specHolder value == #progressInfoSpec ifTrue:[
self hide.
].
worker := nil.
].
worker resume.
"Created: / 10-02-2012 / 10:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
warning: message action: block labeled: label
self message: message.
self customActionLabelHolder value: label.
self customAction: block.
self show: #warningInfoSpec.
"Created: / 13-02-2012 / 16:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!InlineMessageDialog methodsFor:'private'!
getMyView
| v |
v := builder window.
^(v superView isKindOf: SubCanvas)
ifTrue:[v superView]
ifFalse:[v]
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
getOtherView
| myView |
myView := self getMyView.
^ myView superView isNil ifTrue:[
nil.
] ifFalse: [
myView superView subViews after: myView
].
"Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
hide
| myView otherView |
myView := self getMyView.
otherView := self getOtherView.
customAction := nil.
self customActionVisibleHolder value: false.
myView isVisible ifFalse:[^self]."/already hidden"
myView isVisible: false.
panelShownHolder notNil ifTrue:[
panelShownHolder value: false
].
panelHiddenHolder notNil ifTrue:[
panelHiddenHolder value: true
].
otherView layout: layout
"Created: / 29-10-2010 / 11:55:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
show: spec
| myView otherView |
myView := self getMyView.
otherView := self getOtherView.
myView isVisible ifTrue:[
self specHolder value: spec.
^self.
].
layout := otherView layout copy.
myView isVisible: true.
panelShownHolder notNil ifTrue:[
panelShownHolder value: true
].
panelHiddenHolder notNil ifTrue:[
panelHiddenHolder value: false
].
otherView layout:
(layout copy topOffset: layout topOffset + 40; yourself).
self specHolder value: spec.
"Created: / 29-10-2010 / 11:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!InlineMessageDialog class methodsFor:'documentation'!
version
^ '$Id: Tools__InlineMessageDialog.st 7887 2012-02-13 19:19:58Z vranyj1 $'
!
version_CVS
^ 'Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.4 2012-02-11 23:35:59 +0000 vrany Exp '
!
version_SVN
^ '$Id: Tools__InlineMessageDialog.st 7887 2012-02-13 19:19:58Z vranyj1 $'
! !