Tools__InlineMessageDialog.st
changeset 11518 0ff0a7132e35
parent 11509 7fa7922c44a0
child 12401 4714b9640528
child 12405 76f9a872362b
child 12416 1171d0e7a363
equal deleted inserted replaced
11517:bf056eb85f41 11518:0ff0a7132e35
    26 "{ Package: 'stx:libtool' }"
    26 "{ Package: 'stx:libtool' }"
    27 
    27 
    28 "{ NameSpace: Tools }"
    28 "{ NameSpace: Tools }"
    29 
    29 
    30 ApplicationModel subclass:#InlineMessageDialog
    30 ApplicationModel subclass:#InlineMessageDialog
    31 	instanceVariableNames:'messageHolder progressHolder progressView specHolder
    31 	instanceVariableNames:'messageHolder progressHolder backgroundColorHolder
    32 		panelShownHolder panelHiddenHolder worker layout'
    32 		backgroundColorOrDefaultHolder progressView panelView
       
    33 		panelViewComponents specHolder panelShownHolder panelHiddenHolder
       
    34 		worker layout changeLayoutUponShowHide'
    33 	classVariableNames:''
    35 	classVariableNames:''
    34 	poolDictionaries:''
    36 	poolDictionaries:''
    35 	category:'Interface-Tools'
    37 	category:'Interface-Tools'
    36 !
    38 !
    37 
    39 
    61  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    63  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    62  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    64  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    63  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    65  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    64  OTHER DEALINGS IN THE SOFTWARE.
    66  OTHER DEALINGS IN THE SOFTWARE.
    65 "
    67 "
       
    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>"
    66 ! !
   123 ! !
    67 
   124 
    68 !InlineMessageDialog class methodsFor:'interface specs'!
   125 !InlineMessageDialog class methodsFor:'interface specs'!
    69 
   126 
    70 messageInfoSpec
   127 messageInfoSpec
    73 
   130 
    74     "Do not manually edit this!! If it is corrupted,
   131     "Do not manually edit this!! If it is corrupted,
    75      the UIPainter may not be able to read the specification."
   132      the UIPainter may not be able to read the specification."
    76 
   133 
    77     "
   134     "
    78      UIPainter new openOnClass:Tools::NewSystemBrowser andSelector:#messageInfoSpec
   135      UIPainter new openOnClass:Tools::InlineMessageDialog andSelector:#messageInfoSpec
    79      Tools::NewSystemBrowser new openInterface:#messageInfoSpec
   136      Tools::InlineMessageDialog new openInterface:#messageInfoSpec
    80     "
   137     "
    81 
   138 
    82     <resource: #canvas>
   139     <resource: #canvas>
    83 
   140 
    84     ^ 
   141     ^ 
    88        (WindowSpec
   145        (WindowSpec
    89           label: 'MessageInfo'
   146           label: 'MessageInfo'
    90           name: 'MessageInfo'
   147           name: 'MessageInfo'
    91           min: (Point 10 10)
   148           min: (Point 10 10)
    92           bounds: (Rectangle 0 0 800 40)
   149           bounds: (Rectangle 0 0 800 40)
    93           backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
       
    94           forceRecursiveBackgroundOfDefaultBackground: true
       
    95         )
   150         )
    96         component: 
   151         component: 
    97        (SpecCollection
   152        (SpecCollection
    98           collection: (
   153           collection: (
    99            (LabelSpec
   154            (LabelSpec
   100               label: 'Label'
   155               label: 'Label'
   101               name: 'Message'
   156               name: 'Message'
   102               layout: (LayoutFrame 10 0 -10 0.5 -90 1 10 0.5)
   157               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
   103               backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
   158               backgroundChannel: backgroundColorOrDefaultHolder
   104               translateLabel: true
   159               translateLabel: true
   105               labelChannel: messageHolder
   160               labelChannel: messageHolder
   106               adjust: left
   161               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             )
   162             )
   115            )
   163            )
   116          
   164          
   117         )
   165         )
   118       )
   166       )
   119 
       
   120     "Modified: / 28-10-2010 / 18:30:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   121 !
   167 !
   122 
   168 
   123 progressInfoSpec
   169 progressInfoSpec
   124     "This resource specification was automatically generated
   170     "This resource specification was automatically generated
   125      by the UIPainter of ST/X."
   171      by the UIPainter of ST/X."
   141        (WindowSpec
   187        (WindowSpec
   142           label: 'ProgressInfo'
   188           label: 'ProgressInfo'
   143           name: 'ProgressInfo'
   189           name: 'ProgressInfo'
   144           min: (Point 10 10)
   190           min: (Point 10 10)
   145           bounds: (Rectangle 0 0 800 40)
   191           bounds: (Rectangle 0 0 800 40)
   146           backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
       
   147           forceRecursiveBackgroundOfDefaultBackground: true
   192           forceRecursiveBackgroundOfDefaultBackground: true
   148         )
   193         )
   149         component: 
   194         component: 
   150        (SpecCollection
   195        (SpecCollection
   151           collection: (
   196           collection: (
   152            (LabelSpec
   197            (ViewSpec
   153               label: 'Label'
   198               name: 'Box1'
   154               name: 'Message'
   199               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
   155               layout: (LayoutFrame 10 0 0 0 -90 1 20 0)
   200               level: 0
   156               backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
   201               backgroundChannel: backgroundColorOrDefaultHolder
   157               translateLabel: true
   202               component: 
   158               labelChannel: messageHolder
   203              (SpecCollection
   159               adjust: left
   204                 collection: (
   160             )
   205                  (LabelSpec
   161            (ProgressIndicatorSpec
   206                     label: 'Label'
   162               name: 'ProgressIndicator'
   207                     name: 'Message'
   163               layout: (LayoutFrame 10 0 -20 1 -133 1 -3 1)
   208                     layout: (LayoutFrame 0 0 0 0 -20 1 20 0)
   164               model: progressHolder
   209                     backgroundChannel: backgroundColorOrDefaultHolder
   165               foregroundColor: (Color 52.156862745098 37.2549019607843 0.0)
   210                     translateLabel: true
   166               backgroundColor: (Color 100.0 91.3725490196078 70.1960784313726)
   211                     labelChannel: messageHolder
   167               postBuildCallback: postBuildProgressView:
   212                     adjust: left
   168             )
   213                   )
   169            (ActionButtonSpec
   214                  (ProgressIndicatorSpec
   170               label: 'Abort'
   215                     name: 'ProgressIndicator'
   171               name: 'Abort'
   216                     layout: (LayoutFrame 0 0 -20 1 -20 1 -3 1)
   172               layout: (AlignmentOrigin -12 1 0 0.5 1 0.5)
   217                     level: 0
   173               translateLabel: true
   218                     backgroundChannel: backgroundColorOrDefaultHolder
   174               resizeForLabel: true
   219                     model: progressHolder
   175               model: doAbort
   220                     foregroundColor: (Color 52.156862745098 37.2549019607843 0.0)
       
   221                     postBuildCallback: postBuildProgressView:
       
   222                   )
       
   223                  )
       
   224                
       
   225               )
   176             )
   226             )
   177            )
   227            )
   178          
   228          
   179         )
   229         )
   180       )
   230       )
       
   231 !
       
   232 
       
   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>"
   181 !
   240 !
   182 
   241 
   183 windowSpec
   242 windowSpec
   184     "This resource specification was automatically generated
   243     "This resource specification was automatically generated
   185      by the UIPainter of ST/X."
   244      by the UIPainter of ST/X."
   202        (WindowSpec
   261        (WindowSpec
   203           label: 'Tools::InlineMessageDialog'
   262           label: 'Tools::InlineMessageDialog'
   204           name: 'Tools::InlineMessageDialog'
   263           name: 'Tools::InlineMessageDialog'
   205           min: (Point 10 10)
   264           min: (Point 10 10)
   206           bounds: (Rectangle 0 0 800 40)
   265           bounds: (Rectangle 0 0 800 40)
   207           backgroundColor: (Color 100.0 78.0392156862745 22.7450980392157)
       
   208           forceRecursiveBackgroundOfDefaultBackground: true
       
   209         )
   266         )
   210         component: 
   267         component: 
   211        (SpecCollection
   268        (SpecCollection
   212           collection: (
   269           collection: (
   213            (SubCanvasSpec
   270            (ViewSpec
   214               name: 'InfoSpec'
   271               name: 'Layout'
   215               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
   272               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
   216               hasHorizontalScrollBar: false
   273               backgroundChannel: backgroundColorOrDefaultHolder
   217               hasVerticalScrollBar: false
   274               component: 
   218               miniScrollerHorizontal: false
   275              (SpecCollection
   219               specHolder: specHolder
   276                 collection: (
   220               createNewBuilder: false
   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               )
   221             )
   311             )
   222            )
   312            )
   223          
   313          
   224         )
   314         )
   225       )
   315       )
   226 ! !
   316 ! !
   227 
   317 
       
   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 
   228 !InlineMessageDialog methodsFor:'accessing'!
   324 !InlineMessageDialog methodsFor:'accessing'!
       
   325 
       
   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 !
   229 
   336 
   230 message: aString
   337 message: aString
   231 
   338 
   232     self messageHolder value: aString
   339     self messageHolder value: aString
   233 
   340 
   247         ]
   354         ]
   248 
   355 
   249     ]
   356     ]
   250 
   357 
   251     "Created: / 28-10-2010 / 18:24:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   358     "Created: / 28-10-2010 / 18:24:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   359 ! !
       
   360 
       
   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>"
   252 ! !
   373 ! !
   253 
   374 
   254 !InlineMessageDialog methodsFor:'actions'!
   375 !InlineMessageDialog methodsFor:'actions'!
   255 
   376 
   256 doAbort
   377 doAbort
   264             ex reject.
   385             ex reject.
   265         ] do:[
   386         ] do:[
   266             AbortOperationRequest raise.
   387             AbortOperationRequest raise.
   267         ].
   388         ].
   268     ].
   389     ].
   269     (worker notNil and:[worker isDead]) ifTrue:[
   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:[
   270         worker := nil.
   404         worker := nil.
   271         worker terminate.
   405         worker terminate.
   272         "/ raise its prio to make it terminate quickly
   406         "/ raise its prio to make it terminate quickly
   273         worker priority:(Processor userSchedulingPriority + 1)
   407         worker priority:(Processor userSchedulingPriority + 1)
   274     ].
   408     ].
   275 
       
   276     "Modified: / 10-02-2012 / 10:49:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   277 !
       
   278 
       
   279 doOK
       
   280     <resource: #uiCallback>
       
   281 
       
   282     self hide.
   409     self hide.
   283 
   410 
   284     "Modified: / 28-10-2010 / 18:21:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   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>"
       
   450 !
       
   451 
       
   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 !
       
   482 
       
   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 !
       
   490 
       
   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>"
   285 ! !
   513 ! !
   286 
   514 
   287 !InlineMessageDialog methodsFor:'aspects'!
   515 !InlineMessageDialog methodsFor:'aspects'!
       
   516 
       
   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 !
   288 
   554 
   289 messageHolder
   555 messageHolder
   290     <resource: #uiAspect>
   556     <resource: #uiAspect>
   291 
   557 
   292     messageHolder isNil ifTrue:[
   558     messageHolder isNil ifTrue:[
   355     ^ specHolder
   621     ^ specHolder
   356 
   622 
   357     "Modified: / 28-10-2010 / 18:29:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   623     "Modified: / 28-10-2010 / 18:29:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   358 ! !
   624 ! !
   359 
   625 
       
   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 
   360 !InlineMessageDialog methodsFor:'hooks'!
   640 !InlineMessageDialog methodsFor:'hooks'!
       
   641 
       
   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 !
   361 
   661 
   362 postBuildProgressView: aProgressIndicator
   662 postBuildProgressView: aProgressIndicator
   363     progressView := aProgressIndicator
   663     progressView := aProgressIndicator
   364 
   664 
   365     "Created: / 10-02-2012 / 10:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   665     "Created: / 10-02-2012 / 10:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   366 ! !
   666 ! !
   367 
   667 
   368 !InlineMessageDialog methodsFor:'informing'!
   668 !InlineMessageDialog methodsFor:'private'!
       
   669 
       
   670 getMyView
       
   671 
       
   672     | v |
       
   673 
       
   674     builder isNil ifTrue:[ ^ nil ].
       
   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.
       
   688     ^ (myView isNil or:[myView superView isNil]) ifTrue:[
       
   689         nil.    
       
   690     ] ifFalse: [
       
   691         myView superView subViews after: myView
       
   692     ].
       
   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 
       
   703     myView isVisible ifFalse:[ "/already hidden"
       
   704         self reset.
       
   705         ^self 
       
   706     ].
       
   707     myView isVisible: false.
       
   708     panelShownHolder notNil ifTrue:[
       
   709         panelShownHolder value: false
       
   710     ].
       
   711     panelHiddenHolder notNil ifTrue:[
       
   712         panelHiddenHolder value: true
       
   713     ].
       
   714     changeLayoutUponShowHide ~~ false ifTrue:[
       
   715         otherView  layout: layout.
       
   716     ].
       
   717 
       
   718     self reset.
       
   719 
       
   720     "Created: / 29-10-2010 / 11:55:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   721 !
       
   722 
       
   723 show
       
   724 
       
   725     | myView otherView |
       
   726     myView := self getMyView.
       
   727     otherView := self getOtherView.
       
   728     (myView isNil or:[myView isVisible]) ifTrue:[
       
   729         ^self.
       
   730     ].
       
   731     myView isVisible: true.
       
   732     panelShownHolder notNil ifTrue:[
       
   733         panelShownHolder value: true
       
   734     ].
       
   735     panelHiddenHolder notNil ifTrue:[
       
   736         panelHiddenHolder value: false
       
   737     ].
       
   738 
       
   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.
       
   760 
       
   761     "Created: / 29-10-2010 / 11:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   762 ! !
       
   763 
       
   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'!
   369 
   859 
   370 information: message 
   860 information: message 
   371 
   861 
   372     self information: message timeout: nil
   862     self information: message timeout: nil
   373 
   863 
   374     "Created: / 11-02-2012 / 23:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   864     "Created: / 11-02-2012 / 23:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   375 !
   865 !
   376 
   866 
   377 information: message timeout: timeoutOrNil
   867 information: message timeout: timeoutOrNil
   378 
   868 
       
   869     self reset.
       
   870     self beInformation.
   379     self message: message.
   871     self message: message.
   380     self show: #messageInfoSpec.
   872     self addButtonOK.
       
   873     self show.
   381     timeoutOrNil isInteger ifTrue:[
   874     timeoutOrNil isInteger ifTrue:[
   382         [
   875         [
   383             Delay waitForSeconds: timeoutOrNil.
   876             Delay waitForSeconds: timeoutOrNil.
   384             self hide.
   877             self hide.
   385         ] fork.
   878         ] fork.
   389 !
   882 !
   390 
   883 
   391 progress: label while: block
   884 progress: label while: block
   392 
   885 
   393     worker := [
   886     worker := [
       
   887         self reset.
       
   888         self beProgress.
   394         self message: label.
   889         self message: label.
       
   890         self addButtonAbort.
   395         self progress: nil.
   891         self progress: nil.
   396         self show: #progressInfoSpec.
   892         self show.
   397         [
   893         [
   398             block value.    
   894             block value.    
   399         ] on: ProgressNotification , ActivityNotification do:[:ex|
   895         ] on: ProgressNotification , ActivityNotification do:[:ex|
   400             self progress: ex parameter.
   896             self progress: ex parameter.
   401             ex messageText notNil ifTrue:[
   897             ex messageText notNil ifTrue:[
   403             ].
   899             ].
   404             ex proceed.
   900             ex proceed.
   405         ].
   901         ].
   406     ] newProcess.
   902     ] newProcess.
   407     worker addExitAction:[
   903     worker addExitAction:[
   408         self hide.
   904         self specHolder value == #progressInfoSpec ifTrue:[
       
   905             self hide.
       
   906         ].
   409         worker := nil.
   907         worker := nil.
   410     ].
   908     ].
   411     worker resume.
   909     worker resume.
   412 
   910 
   413     "Created: / 10-02-2012 / 10:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   911     "Created: / 10-02-2012 / 10:34:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   414 ! !
   912 !
   415 
   913 
   416 !InlineMessageDialog methodsFor:'private'!
   914 warning: message action: block labeled: label
   417 
   915 
   418 getMyView
   916     self reset.
   419 
   917     self beWarning.
   420     | v |
   918     self message: message.
   421 
   919     self addButtonWithLabel: label action: block.
   422     v := builder window.
   920     self addButtonOK.
   423     ^(v superView isKindOf: SubCanvas)
   921     self show
   424         ifTrue:[v superView]
   922 
   425         ifFalse:[v]
   923     "Created: / 13-02-2012 / 16:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   426 
       
   427     "Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   428 !
       
   429 
       
   430 getOtherView
       
   431 
       
   432     | myView |
       
   433 
       
   434     myView := self getMyView.
       
   435     ^ myView superView isNil ifTrue:[
       
   436         nil.    
       
   437     ] ifFalse: [
       
   438         myView superView subViews after: myView
       
   439     ].
       
   440 
       
   441     "Created: / 29-10-2010 / 11:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   442 !
       
   443 
       
   444 hide
       
   445 
       
   446     | myView otherView |
       
   447     myView := self  getMyView.
       
   448     otherView := self getOtherView.
       
   449 
       
   450     myView isVisible ifFalse:[^self]."/already hidden"
       
   451     myView isVisible: false.
       
   452     panelShownHolder notNil ifTrue:[
       
   453         panelShownHolder value: false
       
   454     ].
       
   455     panelHiddenHolder notNil ifTrue:[
       
   456         panelHiddenHolder value: true
       
   457     ].
       
   458 
       
   459     otherView  layout: layout
       
   460 
       
   461     "Created: / 29-10-2010 / 11:55:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   462 !
       
   463 
       
   464 show: spec
       
   465 
       
   466     | myView otherView |
       
   467     myView := self getMyView.
       
   468     otherView := self getOtherView.
       
   469     myView isVisible ifTrue:[^self]."/already shown"
       
   470     layout := otherView layout copy.
       
   471     myView isVisible: true.
       
   472     panelShownHolder notNil ifTrue:[
       
   473         panelShownHolder value: true
       
   474     ].
       
   475     panelHiddenHolder notNil ifTrue:[
       
   476         panelHiddenHolder value: false
       
   477     ].
       
   478 
       
   479     otherView  layout: 
       
   480         (layout copy topOffset: layout topOffset + 40; yourself).
       
   481     self specHolder value: spec.
       
   482 
       
   483     "Created: / 29-10-2010 / 11:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   484 ! !
   924 ! !
   485 
   925 
   486 !InlineMessageDialog class methodsFor:'documentation'!
   926 !InlineMessageDialog class methodsFor:'documentation'!
   487 
   927 
   488 version
   928 version
   489     ^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.6 2012-05-15 09:51:40 cg Exp $'
   929     ^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.7 2012-05-17 15:31:22 vrany Exp $'
   490 !
       
   491 
       
   492 version_CVS
       
   493     ^ '$Header: /cvs/stx/stx/libtool/Tools__InlineMessageDialog.st,v 1.6 2012-05-15 09:51:40 cg Exp $'
       
   494 !
   930 !
   495 
   931 
   496 version_SVN
   932 version_SVN
   497     ^ '§Id: Tools__InlineMessageDialog.st 7881 2012-02-11 22:16:34Z vranyj1 §'
   933     ^ '§Id: Tools__InlineMessageDialog.st 7976 2012-04-11 16:14:22Z vranyj1 §'
   498 ! !
   934 ! !