ProgressNotification.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 13:15:17 +0200
changeset 6243 949681aaf3e4
parent 6187 285169601f27
permissions -rw-r--r--
#BUGFIX by cg class: TerminalView changed: #processInput:n:

"{ Encoding: utf8 }"

"
 COPYRIGHT (c) 2008 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libwidg2' }"

"{ NameSpace: Smalltalk }"

ActivityNotification subclass:#ProgressNotification
	instanceVariableNames:'statusInfo'
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Exceptions-Notifications'
!

!ProgressNotification class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2008 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    This should be used in long-going activities to tell the caller about any
    progress (percentage).
    Being a notification, it will be ignored if no one is interested.
    If someone is interested, the caller may present this information as a progress-bar,
    percentage display or whatever is useful in the UI.
    Examples are:
        http-requests, ftp requests, long lint checks etc.

    See examples (look for references to this class) on how this is used.

     ProgressNotification handle:[:ex |
        Transcript showCR:(ex progressValue rounded).
        ex proceed.
     ] do:[
         #(0 1 2 3 4 5 6 6 7 8 9)
             do:[:i| Delay waitForMilliseconds: 50]
             displayingProgress: 'Progress'
     ].

"
! !

!ProgressNotification class methodsFor:'notification'!

notify:message progress:aPercentageNumber
    ^ self raiseRequestWith:aPercentageNumber errorString:message

    "Created: / 31-07-2012 / 16:13:54 / cg"
    "Modified: / 25-11-2019 / 15:35:05 / Stefan Vogel"
!

progressPercentage:aPercentageNumber
    ^ self raiseRequestWith:aPercentageNumber in:thisContext sender

    "Modified: / 23-02-2017 / 16:51:52 / cg"
    "Modified (format): / 25-11-2019 / 15:36:17 / Stefan Vogel"
!

progressPercentage:aPercentageNumber messageText:messageText 
    ^ self raiseRequestWith:aPercentageNumber errorString:messageText in:thisContext sender

    "Created: / 25-11-2019 / 11:20:11 / Stefan Vogel"
    "Modified: / 25-11-2019 / 15:35:38 / Stefan Vogel"
!

progressPercentage:aPercentageNumber statusInfo:statusInfo
    ^ self newException
        statusInfo:statusInfo;
        raiseRequestWith:aPercentageNumber in:thisContext sender

    "Created: / 23-02-2017 / 16:52:11 / cg"
    "Modified (format): / 25-11-2019 / 15:35:55 / Stefan Vogel"
! !

!ProgressNotification methodsFor:'accessing'!

progressValue
    "answer the parameter that was passed to the notification request
     as percentage parameter"

    ^ parameter

    "Modified (comment): / 25-11-2019 / 11:18:31 / Stefan Vogel"
!

statusInfo
    "any additional info (opaque to me)"
    
    ^ statusInfo
!

statusInfo:something
    "any additional info (opaque to me)"

    statusInfo := something.
! !

!ProgressNotification class methodsFor:'documentation'!

version
    ^ '$Header$'
! !