#FEATURE by stefan
authorStefan Vogel <sv@exept.de>
Wed, 27 Nov 2019 12:30:32 +0100
changeset 6188 16ec62661cb4
parent 6187 285169601f27
child 6189 bc3a4ceccc3f
#FEATURE by stefan class: ProgressIndicator class comment/format in: #displayProgressNotifications:abortable:at:during: #displayProgressNotifications:message:abortable:at:during: changed: #inBoxWithLabel:icon:text:abortable:view:closeWhenDone: Can change message label via a ProgressNotification
ProgressIndicator.st
--- a/ProgressIndicator.st	Wed Nov 27 12:22:13 2019 +0100
+++ b/ProgressIndicator.st	Wed Nov 27 12:30:32 2019 +0100
@@ -439,7 +439,7 @@
     "create a topView containing an instance of myself,
      return the new instance, for later use with #showProgressOf:"
 
-    |top p l y y2|
+    |top p label y y2|
 
     top := Dialog new.
     top label:aLabel.
@@ -448,32 +448,35 @@
     y2 := 0.
     anIcon notNil ifTrue:[
         y := top yPosition.
-        l := top addTextLabel:anIcon.
-        l borderWidth:0.
-        l adjust:#left.
-        l cursor:(Cursor wait).
+        label := top addTextLabel:anIcon.
+        label borderWidth:0.
+        label adjust:#left.
+        label cursor:(Cursor wait).
         y2 := top yPosition.
         top yPosition:y.
     ].
 
-    l := top addTextLabel:text.
-    l borderWidth:0.
-    l adjust:#left.
-    l cursor:(Cursor wait).
-    anIcon notNil ifTrue: [l leftInset:(anIcon width + 10)].
+    label := top addTextLabel:text.
+    label sizeFixed:false.
+    label borderWidth:0.
+    label adjust:#left.
+    label cursor:(Cursor wait).
+    anIcon notNil ifTrue: [label leftInset:(anIcon width + 10)].
 
-    top yPosition:(top yPosition max:y2).
-
-    top addVerticalSpace.
+    top 
+        yPosition:(top yPosition max:y2);
+        addVerticalSpace.
 
     p := ProgressIndicator new.
-    p extent:(1.0 @ p preferredHeight).
-    p level:-1.
-    p leftInset:5;
-      rightInset:5.
-    p cursor:(Cursor wait).
-    p closeTopWhenDone:closeWhenDoneBoolean.
-    p connectToTop:top label:l.
+    p
+        extent:(1.0 @ p preferredHeight);
+        level:-1;
+        leftInset:5;
+        rightInset:5;
+        cursor:(Cursor wait);
+        closeTopWhenDone:closeWhenDoneBoolean;
+        connectToTop:top label:label;
+        yourself.
 
     top addComponent:p.
 
@@ -483,10 +486,8 @@
     ].
 
     abortable ifTrue:[
-        top addVerticalSpace.
-        top addAbortButton
-    ].
-    abortable ifFalse:[
+        top addVerticalSpace; addAbortButton.
+    ] ifFalse:[
         "/ top beUndecorated.  -- buggy for now; sets wrong height (caption not included ?)
         "/ would need the following kludge:
         "/ top preferredExtent:(top preferredExtent + (0@30)).
@@ -494,8 +495,8 @@
 
     ^ p
 
-    "Created: 17.7.1996 / 15:14:33 / cg"
-    "Modified: 17.7.1996 / 15:16:58 / cg"
+    "Created: / 17-07-1996 / 15:14:33 / cg"
+    "Modified: / 25-11-2019 / 15:44:52 / Stefan Vogel"
 !
 
 inBoxWithLabel:aLabel text:text abortable:abortable
@@ -839,13 +840,13 @@
 
     "
      ProgressIndicator
-        displayProgressNotifications:'doobidoobidoo...'
+        displayProgressNotifications:'...'
         abortable:true
         at:nil
         during:[
             200 to:400 by:5 do:[:i |
                 Delay waitForSeconds:0.1.
-                ProgressNotification progressPercentage:(i / 4).
+                ProgressNotification progressPercentage:(i / 4) messageText:'Now ', i printString.
             ]
         ].
     "
@@ -860,6 +861,7 @@
     "
 
     "Modified: / 12-11-2010 / 19:03:09 / cg"
+    "Modified (comment): / 27-11-2019 / 12:17:49 / Stefan Vogel"
 !
 
 displayProgressNotifications:aLabel message:messageString abortable:abortable at:aPointOrNil during:aBlock
@@ -868,12 +870,13 @@
      The block is passed the progressIndicator as optional argument,
      however, progressNotifications are handled and update the percentage."
 
-    |p|
+    |p textHolder|
 
+    textHolder := messageString asValue.
     p := self
             inBoxWithLabel:aLabel 
             icon:nil
-            text:messageString
+            text:textHolder
             abortable:abortable
             view:nil
             closeWhenDone:true.
@@ -882,6 +885,9 @@
         CannotReturnError catch:[
             ProgressNotification handle:[:ex |
                 p percentage:ex progressValue.
+                ex messageText notNil ifTrue:[
+                    textHolder value:ex messageText.
+                ].
                 ex proceed.
             ] do:[
                 aBlock valueWithOptionalArgument:p.    
@@ -892,6 +898,7 @@
     "
      ProgressIndicator
         displayProgressNotifications:'doobidoobidoo...'
+        message:'loooooooooooooooooooooooooooooooooooooooong Message'
         abortable:true
         at:nil
         during:[
@@ -904,6 +911,7 @@
     "
      ProgressIndicator
         displayProgressNotifications:'doobidoobidoo...'
+        message:'Message'
         abortable:true
         at:nil
         during:[
@@ -912,6 +920,8 @@
     "
 
     "Created: / 12-11-2010 / 19:02:43 / cg"
+    "Modified: / 25-11-2019 / 15:30:11 / Stefan Vogel"
+    "Modified (comment): / 27-11-2019 / 12:23:59 / Stefan Vogel"
 ! !
 
 !ProgressIndicator methodsFor:'accessing'!