ProgressIndicator.st
author Claus Gittinger <cg@exept.de>
Wed, 14 Sep 2011 18:44:14 +0200
changeset 4079 29b468da8728
parent 4078 91d764cf9cbd
child 4088 e0f9cfd1cdb4
permissions -rw-r--r--
added: #new_showBusyIndicatorDuring: #old_showBusyIndicatorDuring: run block in current thread (for queries and handlers to work)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62
claus
parents: 50
diff changeset
     1
"
claus
parents: 50
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 50
diff changeset
     3
	      All Rights Reserved
claus
parents: 50
diff changeset
     4
claus
parents: 50
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 50
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 50
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 50
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 50
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 50
diff changeset
    10
 hereby transferred.
claus
parents: 50
diff changeset
    11
"
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
1789
99a33f0b2164 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1740
diff changeset
    13
50
claus
parents:
diff changeset
    14
View subclass:#ProgressIndicator
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
    15
	instanceVariableNames:'percentage showPercentage fgColor bgColor connectedTop
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    16
		connectedLabel collector finishAction closeTopWhenDone showBusy
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    17
		busyPosition busyDelta busyIndicationProcess'
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    18
	classVariableNames:''
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    19
	poolDictionaries:''
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    20
	category:'Views-Misc'
50
claus
parents:
diff changeset
    21
!
claus
parents:
diff changeset
    22
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    23
!ProgressIndicator class methodsFor:'documentation'!
50
claus
parents:
diff changeset
    24
62
claus
parents: 50
diff changeset
    25
copyright
claus
parents: 50
diff changeset
    26
"
claus
parents: 50
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 50
diff changeset
    28
	      All Rights Reserved
claus
parents: 50
diff changeset
    29
claus
parents: 50
diff changeset
    30
 This software is furnished under a license and may be used
claus
parents: 50
diff changeset
    31
 only in accordance with the terms of that license and with the
claus
parents: 50
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
claus
parents: 50
diff changeset
    33
 be provided or otherwise made available to, or used by, any
claus
parents: 50
diff changeset
    34
 other person.  No title to or ownership of the software is
claus
parents: 50
diff changeset
    35
 hereby transferred.
claus
parents: 50
diff changeset
    36
"
claus
parents: 50
diff changeset
    37
!
claus
parents: 50
diff changeset
    38
50
claus
parents:
diff changeset
    39
documentation
claus
parents:
diff changeset
    40
"
claus
parents:
diff changeset
    41
    a view showing a rectangle filled according the percentage value.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    42
    Can be used as a progress indicator a la MSwindows;
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    43
    it can also be configured as a non-percentage busy indication
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    44
    via the showBusyIndication flag (a la netscape).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    45
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    46
    Can be used as a widget within an application, or
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    47
    via the convenient #inBox: instance creation messages,
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    48
    which shows a progressDisplay in a modalBox, while some
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    49
    action is performed.
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
    50
    See examples.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    51
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    52
    [author:]
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    53
	Claus Gittinger
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    54
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    55
    [see also:]
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    56
	ActionWaitBox AnimatedLabel
50
claus
parents:
diff changeset
    57
"
claus
parents:
diff changeset
    58
!
claus
parents:
diff changeset
    59
claus
parents:
diff changeset
    60
examples
claus
parents:
diff changeset
    61
"
62
claus
parents: 50
diff changeset
    62
    basic (internal) interface
claus
parents: 50
diff changeset
    63
    (if progress indicator is to be used in a complex box ...):
50
claus
parents:
diff changeset
    64
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    65
    Before you get frustrated - see the convenient-interface examples
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    66
    at the end ;-)
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    67
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    68
									[exBegin]
50
claus
parents:
diff changeset
    69
      |top p h|
claus
parents:
diff changeset
    70
62
claus
parents: 50
diff changeset
    71
      top := ModalBox new.
50
claus
parents:
diff changeset
    72
      top extent:300@100.
claus
parents:
diff changeset
    73
      top label:'Progress'.
claus
parents:
diff changeset
    74
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
    75
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
    76
      p level:-1.
62
claus
parents: 50
diff changeset
    77
      h := p preferredExtent y.
50
claus
parents:
diff changeset
    78
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    79
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    80
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    81
	rightInset:5.
50
claus
parents:
diff changeset
    82
claus
parents:
diff changeset
    83
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    84
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    85
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    86
	      p percentage:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    87
	  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    88
	  top hide.
62
claus
parents: 50
diff changeset
    89
      ] fork.
claus
parents: 50
diff changeset
    90
      top open.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    91
									[exEnd]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    92
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    93
    as a busy indicator
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
    94
									[exBegin]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    95
      |top p h|
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    96
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    97
      top := ModalBox new.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    98
      top extent:300@100.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
    99
      top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   100
      p := ProgressIndicator in:top.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   101
      p origin:(0.0@0.5) corner:(1.0@0.5).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   102
      p level:-1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   103
      h := p preferredExtent y.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   104
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   105
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   106
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   107
	rightInset:5.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   108
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   109
      p showBusyIndication:true.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   110
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   111
	  'do something here ....'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   112
	  (Delay forSeconds:5) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   113
	  top hide.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   114
      ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   115
      top open.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   116
									[exEnd]
50
claus
parents:
diff changeset
   117
claus
parents:
diff changeset
   118
    changing colors, turning percentage display off:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   119
									[exBegin]
50
claus
parents:
diff changeset
   120
      |top p h|
claus
parents:
diff changeset
   121
claus
parents:
diff changeset
   122
      top := StandardSystemView new.
claus
parents:
diff changeset
   123
      top extent:300@100.
claus
parents:
diff changeset
   124
      top label:'Progress'.
claus
parents:
diff changeset
   125
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   126
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   127
      p level:-1.
claus
parents:
diff changeset
   128
      p showPercentage:false.
claus
parents:
diff changeset
   129
      p foregroundColor:(Color red).
claus
parents:
diff changeset
   130
      h := 10.
claus
parents:
diff changeset
   131
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   132
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   133
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   134
	rightInset:5.
50
claus
parents:
diff changeset
   135
      top open.
claus
parents:
diff changeset
   136
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   137
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   138
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   139
	      p percentage:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   140
	  ]
50
claus
parents:
diff changeset
   141
      ] fork
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   142
									[exEnd]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   143
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   144
    as a busy indicator and percentage display (as in netscape)
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   145
									[exBegin]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   146
      |top p h|
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   147
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   148
      top := ModalBox new.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   149
      top extent:300@60.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   150
      top label:'Busy'.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   151
      p := ProgressIndicator in:top.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   152
      p origin:(0.0@0.5) corner:(1.0@0.5).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   153
      p level:-1.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   154
      p showPercentage:false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   155
      p backgroundColor:(Color cyan).
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   156
      h := p preferredExtent y.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   157
      p topInset:(h // 3) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   158
	bottomInset:(h // 3) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   159
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   160
	rightInset:5.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   161
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   162
      p showBusyIndication:true.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   163
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   164
	  top label:'Busy'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   165
	  1 to:100 do:[:i |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   166
	    (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   167
	  ].
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   168
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   169
	  top label:'Percentage'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   170
	  p showBusyIndication:false.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   171
	  1 to:100 do:[:i |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   172
	    (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   173
	    p percentage:i. 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   174
	  ].
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   175
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   176
	  top hide.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   177
      ] fork.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   178
      top open.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   179
									[exEnd]
50
claus
parents:
diff changeset
   180
claus
parents:
diff changeset
   181
    with border (2D look):
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   182
									[exBegin]
50
claus
parents:
diff changeset
   183
      |top p h|
claus
parents:
diff changeset
   184
claus
parents:
diff changeset
   185
      top := StandardSystemView new.
claus
parents:
diff changeset
   186
      top extent:300@100.
claus
parents:
diff changeset
   187
      top label:'Progress'.
claus
parents:
diff changeset
   188
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   189
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   190
      p borderWidth:1.
62
claus
parents: 50
diff changeset
   191
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   192
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   193
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   194
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   195
	rightInset:5.
50
claus
parents:
diff changeset
   196
      top open.
claus
parents:
diff changeset
   197
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   198
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   199
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   200
	      p percentage:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   201
	  ]
50
claus
parents:
diff changeset
   202
      ] fork
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   203
									[exEnd]
50
claus
parents:
diff changeset
   204
claus
parents:
diff changeset
   205
claus
parents:
diff changeset
   206
    getting progress from a model:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   207
									[exBegin]
50
claus
parents:
diff changeset
   208
      |model top p h|
claus
parents:
diff changeset
   209
claus
parents:
diff changeset
   210
      model := 0 asValue.
claus
parents:
diff changeset
   211
claus
parents:
diff changeset
   212
      top := StandardSystemView new.
claus
parents:
diff changeset
   213
      top extent:300@100.
claus
parents:
diff changeset
   214
      top label:'Progress'.
claus
parents:
diff changeset
   215
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   216
      p model:model.
claus
parents:
diff changeset
   217
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   218
      p level:-1.
62
claus
parents: 50
diff changeset
   219
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   220
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   221
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   222
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   223
	rightInset:5.
50
claus
parents:
diff changeset
   224
      top open.
claus
parents:
diff changeset
   225
claus
parents:
diff changeset
   226
      [
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   227
	  1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   228
	      (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   229
	      model value:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   230
	  ]
50
claus
parents:
diff changeset
   231
      ] fork
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   232
									[exEnd]
50
claus
parents:
diff changeset
   233
62
claus
parents: 50
diff changeset
   234
50
claus
parents:
diff changeset
   235
    concrete example:
claus
parents:
diff changeset
   236
      search all files in the source directory for a string
claus
parents:
diff changeset
   237
      using grep. Show progress while doing so.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   238
									[exBegin]
50
claus
parents:
diff changeset
   239
      |top p h names done|
claus
parents:
diff changeset
   240
claus
parents:
diff changeset
   241
      top := StandardSystemView new.
claus
parents:
diff changeset
   242
      top extent:300@100.
claus
parents:
diff changeset
   243
      top label:'Searching ...'.
claus
parents:
diff changeset
   244
      p := ProgressIndicator in:top.
claus
parents:
diff changeset
   245
      p origin:(0.0@0.5) corner:(1.0@0.5).
claus
parents:
diff changeset
   246
      p level:-1.
62
claus
parents: 50
diff changeset
   247
      h := p preferredExtent y.
50
claus
parents:
diff changeset
   248
      p topInset:(h // 2) negated; 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   249
	bottomInset:(h // 2) negated;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   250
	leftInset:5;
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   251
	rightInset:5.
50
claus
parents:
diff changeset
   252
      top openWithPriority:(Processor activePriority + 1).
claus
parents:
diff changeset
   253
claus
parents:
diff changeset
   254
      names := 'source' asFilename directoryContents.
claus
parents:
diff changeset
   255
      done := 0.
claus
parents:
diff changeset
   256
      names do:[:aName |
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   257
	|fn stream line|
50
claus
parents:
diff changeset
   258
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   259
	p percentage:(done / names size * 100).
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   260
	fn := ('source/' , aName) asFilename.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   261
	fn isDirectory ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   262
	    stream := fn readStream.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   263
	    [stream atEnd] whileFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   264
		line := stream nextLine.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   265
		(line findString:'subclass:') ~~ 0 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   266
		    Transcript showCR:line
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   267
		].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   268
	    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   269
	    stream close.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   270
	].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   271
	done := done + 1
50
claus
parents:
diff changeset
   272
      ].
claus
parents:
diff changeset
   273
claus
parents:
diff changeset
   274
      top destroy
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   275
									[exEnd]
62
claus
parents: 50
diff changeset
   276
claus
parents: 50
diff changeset
   277
claus
parents: 50
diff changeset
   278
   using the convenient inBox-interface
claus
parents: 50
diff changeset
   279
claus
parents: 50
diff changeset
   280
   (this creates a box and an activity label and evaluates a block
claus
parents: 50
diff changeset
   281
    to indicate ...)
claus
parents: 50
diff changeset
   282
claus
parents: 50
diff changeset
   283
    basic interface demonstration:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   284
									[exBegin]
62
claus
parents: 50
diff changeset
   285
      |p|
claus
parents: 50
diff changeset
   286
claus
parents: 50
diff changeset
   287
      p := ProgressIndicator 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   288
		inBoxWithLabel:'doing something  ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   289
		abortable:true.
62
claus
parents: 50
diff changeset
   290
      p showProgressOf:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   291
	    [:progressValue :currentAction |
62
claus
parents: 50
diff changeset
   292
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   293
	      1 to:100 do:[:val |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   294
		  (Delay forSeconds:0.05) wait.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   295
		  val == 25 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   296
		      currentAction value:'still going ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   297
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   298
		  val == 50 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   299
		      currentAction value:'halfway through ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   300
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   301
		  val == 75 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   302
		      currentAction value:'almost finished ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   303
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   304
		  progressValue value:val 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   305
	      ]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   306
	    ]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   307
									[exEnd]
62
claus
parents: 50
diff changeset
   308
claus
parents: 50
diff changeset
   309
claus
parents: 50
diff changeset
   310
    above search example using this convenient interface:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   311
									[exBegin]
62
claus
parents: 50
diff changeset
   312
      |p|
claus
parents: 50
diff changeset
   313
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   314
      p := ProgressIndicator 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   315
		inBoxWithLabel:'searching files ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   316
		abortable:false.
62
claus
parents: 50
diff changeset
   317
      p showProgressOf:
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   318
	    [:progressValue :currentAction |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   319
		|names nDone|
62
claus
parents: 50
diff changeset
   320
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   321
		names := 'source' asFilename directoryContents.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   322
		nDone := 0.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   323
		names do:[:aName |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   324
		  |fn stream line|
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   325
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   326
		  progressValue value:(nDone / names size * 100).
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   327
		  currentAction value:'searching ' , 'source/' , aName , ' ...'.
62
claus
parents: 50
diff changeset
   328
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   329
		  fn := ('source/' , aName) asFilename.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   330
		  fn isDirectory ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   331
		      stream := fn readStream.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   332
		      [stream atEnd] whileFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   333
			  line := stream nextLine.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   334
			  (line findString:'subclass:') ~~ 0 ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   335
			      Transcript showCR:line
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   336
			  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   337
		      ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   338
		      stream close.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   339
		  ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   340
		  nDone := nDone + 1
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   341
		].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   342
	    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   343
									[exEnd]
62
claus
parents: 50
diff changeset
   344
claus
parents: 50
diff changeset
   345
claus
parents: 50
diff changeset
   346
    a nice example: copying files a la windows ...
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   347
    the following copies all files to /dev/null.
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   348
									[exBegin]
62
claus
parents: 50
diff changeset
   349
      |p|
claus
parents: 50
diff changeset
   350
claus
parents: 50
diff changeset
   351
      (ProgressIndicator 
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   352
		inBoxWithLabel:'copy files to /dev/null ...'
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   353
		abortable:true)
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   354
	 showProgressOf:
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   355
	    [:progressValue :currentAction |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   356
		|files nFiles nDone|
62
claus
parents: 50
diff changeset
   357
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   358
		files := '.' asFilename directoryContents.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   359
		nFiles := files size.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   360
		nDone := 0.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   361
		files do:[:aFileName |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   362
		    |percent|
50
claus
parents:
diff changeset
   363
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   364
		    nDone := nDone + 1.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   365
		    percent := nDone / nFiles * 100.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   366
		    progressValue value:percent. 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   367
		    aFileName asFilename isDirectory ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   368
			Transcript showCR:('skipping ' , aFileName , ' ...'). 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   369
			currentAction value:('skipping ' , aFileName , ' ...'). 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   370
		    ] ifFalse:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   371
			Transcript showCR:('copying ' , aFileName , ' ...').
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   372
			currentAction value:('copying ' , aFileName , ' ...').
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   373
			Object errorSignal handle:[:ex |
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   374
			    self warn:'an error occurred while copying ' , aFileName.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   375
			    ex return
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   376
			] do:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   377
			    aFileName asFilename copyTo:'/dev/null'.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   378
			]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   379
		    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   380
		].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   381
	    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   382
									[exEnd]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   383
"
50
claus
parents:
diff changeset
   384
! !
claus
parents:
diff changeset
   385
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   386
!ProgressIndicator class methodsFor:'instance creation'!
62
claus
parents: 50
diff changeset
   387
claus
parents: 50
diff changeset
   388
inBox
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   389
    "create a topView containing an instance of myself,
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   390
     for later use with #showProgressOf:"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   391
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   392
    ^ self inBoxWithLabel:'executing ...' abortable:false
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   393
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   394
    "Modified: 22.10.1997 / 21:08:37 / cg"
62
claus
parents: 50
diff changeset
   395
!
claus
parents: 50
diff changeset
   396
claus
parents: 50
diff changeset
   397
inBoxWithLabel:aLabel
claus
parents: 50
diff changeset
   398
    "create a topView containing an instance of myself,
claus
parents: 50
diff changeset
   399
     for later use with #showProgressOf:"
claus
parents: 50
diff changeset
   400
claus
parents: 50
diff changeset
   401
    ^ self inBoxWithLabel:aLabel abortable:false 
claus
parents: 50
diff changeset
   402
!
claus
parents: 50
diff changeset
   403
claus
parents: 50
diff changeset
   404
inBoxWithLabel:aLabel abortable:abortable
claus
parents: 50
diff changeset
   405
    "create a topView containing an instance of myself,
claus
parents: 50
diff changeset
   406
     for later use with #showProgressOf:"
claus
parents: 50
diff changeset
   407
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   408
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   409
	inBoxWithLabel:aLabel   
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   410
	text:''
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   411
	abortable:abortable
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   412
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   413
    "Modified: 17.7.1996 / 15:14:58 / cg"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   414
!
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   415
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   416
inBoxWithLabel:aLabel icon:anIcon text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   417
    "create a topView containing an instance of myself,
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   418
     return the new instance, for later use with #showProgressOf:"
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   419
2436
6c0df331b7b1 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 2435
diff changeset
   420
    |top p l y y2|
62
claus
parents: 50
diff changeset
   421
claus
parents: 50
diff changeset
   422
    top := Dialog new.
claus
parents: 50
diff changeset
   423
    top label:aLabel.
claus
parents: 50
diff changeset
   424
    top cursor:(Cursor wait).
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   425
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   426
    y2 := 0.
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   427
    anIcon notNil ifTrue:[
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   428
        y := top yPosition.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   429
        l := top addTextLabel:anIcon.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   430
        l borderWidth:0.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   431
        l adjust:#left.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   432
        l cursor:(Cursor wait).
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   433
        y2 := top yPosition.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   434
        top yPosition:y.
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   435
    ].
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   436
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   437
    l := top addTextLabel:text.
62
claus
parents: 50
diff changeset
   438
    l borderWidth:0.
74
claus
parents: 62
diff changeset
   439
    l adjust:#left.
62
claus
parents: 50
diff changeset
   440
    l cursor:(Cursor wait).
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   441
    anIcon notNil ifTrue: [l leftInset:(anIcon width + 10)].
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   442
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   443
    top yPosition:(top yPosition max:y2).
62
claus
parents: 50
diff changeset
   444
claus
parents: 50
diff changeset
   445
    top addVerticalSpace.
claus
parents: 50
diff changeset
   446
claus
parents: 50
diff changeset
   447
    p := ProgressIndicator new.
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   448
    p extent:(1.0 @ p preferredHeight).
62
claus
parents: 50
diff changeset
   449
    p level:-1.
claus
parents: 50
diff changeset
   450
    p leftInset:5;
claus
parents: 50
diff changeset
   451
      rightInset:5.
claus
parents: 50
diff changeset
   452
    p cursor:(Cursor wait).
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   453
    p closeTopWhenDone:closeWhenDoneBoolean.
62
claus
parents: 50
diff changeset
   454
    p connectToTop:top label:l.
claus
parents: 50
diff changeset
   455
claus
parents: 50
diff changeset
   456
    top addComponent:p.
claus
parents: 50
diff changeset
   457
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   458
    additionalView notNil ifTrue:[
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   459
        top addComponent:additionalView.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   460
        additionalView extent:(1.0 @ additionalView preferredHeight).
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   461
    ].
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   462
62
claus
parents: 50
diff changeset
   463
    abortable ifTrue:[
3425
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   464
        top addVerticalSpace.
20459e327062 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
   465
        top addAbortButton
62
claus
parents: 50
diff changeset
   466
    ].
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   467
    abortable ifFalse:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   468
        "/ top beUndecorated.  -- buggy for now; sets wrong height (caption not included ?)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   469
        "/ would need the following kludge:
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   470
        "/ top preferredExtent:(top preferredExtent + (0@30)).
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   471
    ].
62
claus
parents: 50
diff changeset
   472
claus
parents: 50
diff changeset
   473
    ^ p
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   474
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   475
    "Created: 17.7.1996 / 15:14:33 / cg"
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   476
    "Modified: 17.7.1996 / 15:16:58 / cg"
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   477
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   478
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   479
inBoxWithLabel:aLabel text:text abortable:abortable
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   480
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   481
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   482
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   483
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   484
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   485
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   486
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   487
	view:nil
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   488
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   489
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   490
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   491
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   492
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   493
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   494
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   495
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   496
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   497
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   498
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   499
	view:additionalView 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   500
	closeWhenDone:true
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   501
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   502
!
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   503
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   504
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   505
    "create a topView containing an instance of myself,
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   506
     for later use with #showProgressOf:"
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   507
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   508
    ^ self
634
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   509
	inBoxWithLabel:aLabel 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   510
	icon:nil
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   511
	text:text 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   512
	abortable:abortable 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   513
	view:additionalView 
cee0d1f706e1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 575
diff changeset
   514
	closeWhenDone:closeWhenDoneBoolean
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   515
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   516
!
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   517
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   518
progressOpenOn:progressModel label:aLabel
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   519
    "create and open a progressIndicator dialog window,
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   520
     bit do not open it modal; instead, it is opened modeless
1834
ba170c21ed76 defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   521
     and control returns to the caller.
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   522
     The models value is assumed to be 0..1 
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   523
     (which is for compatibility and different from ST/X's percentage use)
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   524
     Added for VW compatibility (RB)."
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   525
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   526
    |p ra|
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   527
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   528
    p := self
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   529
	    inBoxWithLabel:aLabel 
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   530
	    icon:nil
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   531
	    text:aLabel
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   532
	    abortable:false
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   533
	    view:nil
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
   534
	    closeWhenDone:false.
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   535
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   536
    ra := RangeAdaptor on:progressModel start:0 stop:0.01 grid:nil.
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   537
    p model:ra.
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   538
2132
fd5b29a20fe1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2082
diff changeset
   539
    p topView openModeless; waitUntilVisible.
1681
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   540
    ^ p.
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   541
9ef9e8ec0f43 progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
   542
    "Modified: / 4.2.2000 / 01:25:55 / cg"
62
claus
parents: 50
diff changeset
   543
! !
claus
parents: 50
diff changeset
   544
3999
434665aedfea category of:8 methods
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
   545
!ProgressIndicator class methodsFor:'simple public API'!
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   546
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   547
displayBusyIndicator:aLabel abortable:abortable at:aPoint during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   548
    "easy interface - show progress while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   549
     The block is passed the progressIndicator as argument
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   550
     so the block can change the label and/or change the progress value."
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   551
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   552
    ^ self
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   553
        displayBusyIndicator:aLabel 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   554
        message:aLabel
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   555
        abortable:abortable 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   556
        at:aPoint 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   557
        during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   558
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   559
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   560
     ProgressIndicator
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   561
        displayBusyIndicator:'doobidoobidoo...'
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   562
        abortable:true
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   563
        at:(Screen default center)
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   564
        during:[
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   565
            200 to:400 by:5 do:[:i |
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   566
                Delay waitForSeconds:0.1.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   567
            ]
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   568
        ].
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   569
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   570
     ProgressIndicator
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   571
        displayBusyIndicator:'doobidoobidoo...'
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   572
        abortable:true
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   573
        at:(Screen default center)
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   574
        during:[
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   575
            Delay waitForSeconds:3.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   576
        ].
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   577
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   578
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   579
    "Modified: / 12-11-2010 / 18:59:45 / cg"
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   580
!
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   581
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   582
displayBusyIndicator:aLabel at:aPoint during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   583
    "easy interface - show progress while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   584
     The block is passed a valueHolder, which is to be set to values from
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   585
     startValue to endValue during the blocks evaluation.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   586
     This is scaled to 0..100% completion.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   587
     Set the valueHolder to nil, to get a busy-indicator"
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   588
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   589
    self
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   590
        displayBusyIndicator:aLabel 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   591
        abortable:false 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   592
        at:aPoint 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   593
        during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   594
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   595
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   596
     ProgressIndicator
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   597
        displayBusyIndicator:'doobidoobidoo...'
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   598
        at:(Screen default center)
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   599
        during:[
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   600
            200 to:400 by:5 do:[:i |
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   601
                Delay waitForSeconds:0.1.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   602
            ]
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   603
        ].
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   604
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   605
!
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   606
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   607
displayBusyIndicator:aLabel message:messageString abortable:abortable at:aPoint during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   608
    "easy interface - show progress while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   609
     The block is passed the progressIndicator as argument
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   610
     so the block can change the label and/or change the progress value."
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   611
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   612
    |p|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   613
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   614
    p := self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   615
            inBoxWithLabel:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   616
            icon:nil
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   617
            text:messageString
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   618
            abortable:abortable
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   619
            view:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   620
            closeWhenDone:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   621
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   622
    p showBusyIndication:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   623
    p showBusyIndicatorDuring:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   624
        CannotReturnError catch:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   625
            aBlock valueWithOptionalArgument:p.    
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   626
        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   627
    ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   628
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   629
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   630
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   631
        displayBusyIndicator:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   632
        abortable:true
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   633
        at:(Screen default center)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   634
        during:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   635
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   636
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   637
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   638
        ].
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   639
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   640
     ProgressIndicator
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   641
        displayBusyIndicator:'doobidoobidoo...'
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   642
        abortable:true
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   643
        at:(Screen default center)
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   644
        during:[
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   645
            Delay waitForSeconds:3.
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   646
        ].
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   647
    "
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   648
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   649
    "Created: / 12-11-2010 / 18:59:13 / cg"
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   650
!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   651
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   652
displayBusyIndicator:aLabel message:messageString at:aPoint during:aBlock
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   653
    "easy interface - show progress while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   654
     The block is passed a valueHolder, which is to be set to values from
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   655
     startValue to endValue during the blocks evaluation.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   656
     This is scaled to 0..100% completion.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   657
     Set the valueHolder to nil, to get a busy-indicator"
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   658
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   659
    self
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   660
        displayBusyIndicator:aLabel
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   661
        message:messageString
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   662
        abortable:false 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   663
        at:aPoint 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   664
        during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   665
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   666
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   667
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   668
        displayBusyIndicator:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   669
        at:(Screen default center)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   670
        during:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   671
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   672
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   673
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   674
        ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   675
    "
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   676
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   677
    "Created: / 12-11-2010 / 19:01:12 / cg"
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   678
!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   679
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   680
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   681
    "easy interface - show progress while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   682
     The block is passed a valueHolder, which is to be set to values from
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   683
     startValue to endValue during the blocks evaluation.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   684
     This is scaled to 0..100% completion.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   685
     Set the valueHolder to nil, to get a busy-indicator"
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   686
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   687
    ^ self
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   688
        displayProgress:aLabel 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   689
        message:aLabel
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   690
        at:aPoint 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   691
        from:startValue 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   692
        to:endValue 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   693
        during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   694
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   695
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   696
     ProgressIndicator
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   697
        displayProgress:'doobidoobidoo...'
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   698
        at:(Screen default center)
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   699
        from:200 to:400
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   700
        during:[:val |
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   701
            200 to:400 by:5 do:[:i |
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   702
                val value:i.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   703
                Delay waitForSeconds:0.1.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   704
            ]
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   705
        ].
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   706
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   707
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   708
    "Modified: / 12-11-2010 / 19:02:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   709
!
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   710
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   711
displayProgress:aLabel message:messageString at:aPoint from:startValue to:endValue during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   712
    "easy interface - show progress while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   713
     The block is passed a valueHolder, which is to be set to values from
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   714
     startValue to endValue during the blocks evaluation.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   715
     This is scaled to 0..100% completion.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   716
     Set the valueHolder to nil, to get a busy-indicator"
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   717
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   718
    |p|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   719
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   720
    p := self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   721
            inBoxWithLabel:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   722
            icon:nil
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   723
            text:messageString
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   724
            abortable:false
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   725
            view:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   726
            closeWhenDone:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   727
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   728
    p showProgressOf:[:progressValue :currentAction |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   729
        |scaler|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   730
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   731
        scaler := [:scaledValue | 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   732
                        |newPercentage oldPercentage oldLabel|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   733
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   734
                        scaledValue isNil ifTrue:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   735
                            p showBusyIndication:true
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   736
                        ] ifFalse:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   737
                            p showBusyIndication:false.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   738
                            oldPercentage := progressValue value.
3827
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
   739
                            endValue = startValue ifTrue:[
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
   740
                                newPercentage := 0.
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
   741
                            ] ifFalse:[
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
   742
                                newPercentage := (scaledValue - startValue) / (endValue-startValue) * 100.
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
   743
                            ].
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   744
                            newPercentage ~= oldPercentage ifTrue:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   745
                                progressValue value:newPercentage.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   746
                            ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   747
                            oldLabel := currentAction value.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   748
                            oldLabel ~= aLabel ifTrue:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   749
                                currentAction value:aLabel.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   750
                            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   751
                        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   752
                  ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   753
        CannotReturnError catch:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   754
            aBlock valueWithOptionalArgument:scaler and:p.    
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   755
        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   756
    ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   757
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   758
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   759
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   760
        displayProgress:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   761
        at:(Screen default center)
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   762
        from:200 to:400
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   763
        during:[:val |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   764
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   765
                val value:i.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   766
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   767
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   768
        ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   769
    "
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   770
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   771
    "Created: / 12-11-2010 / 19:01:38 / cg"
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   772
!
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   773
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   774
displayProgressNotifications:aLabel abortable:abortable at:aPointOrNil during:aBlock
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   775
    "easy interface - show progress as provided by progressNotifications
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   776
     while evaluating aBlock.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   777
     The block is passed the progressIndicator as optional argument,
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   778
     however, progressNotifications are handled and update the percentage."
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   779
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   780
    ^ self
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   781
        displayProgressNotifications:aLabel 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   782
        message:aLabel 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   783
        abortable:abortable 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   784
        at:aPointOrNil 
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   785
        during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   786
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   787
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   788
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   789
     ProgressIndicator
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   790
        displayProgressNotifications:'doobidoobidoo...'
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   791
        abortable:true
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   792
        at:nil
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   793
        during:[
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   794
            200 to:400 by:5 do:[:i |
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   795
                Delay waitForSeconds:0.1.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   796
                ProgressNotification progressPercentage:(i / 4).
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   797
            ]
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   798
        ].
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   799
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   800
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   801
     ProgressIndicator
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   802
        displayProgressNotifications:'doobidoobidoo...'
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   803
        abortable:true
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   804
        at:nil
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   805
        during:[
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   806
            Delay waitForSeconds:3.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   807
        ].
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   808
    "
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   809
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   810
    "Modified: / 12-11-2010 / 19:03:09 / cg"
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   811
!
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   812
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   813
displayProgressNotifications:aLabel message:messageString abortable:abortable at:aPointOrNil during:aBlock
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   814
    "easy interface - show progress as provided by progressNotifications
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   815
     while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   816
     The block is passed the progressIndicator as optional argument,
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   817
     however, progressNotifications are handled and update the percentage."
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   818
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   819
    |p|
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   820
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   821
    p := self
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   822
            inBoxWithLabel:aLabel 
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   823
            icon:nil
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   824
            text:messageString
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   825
            abortable:abortable
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   826
            view:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   827
            closeWhenDone:true.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   828
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   829
    p showBusyIndicatorDuring:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   830
        CannotReturnError catch:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   831
            ProgressNotification handle:[:ex |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   832
                p percentage:ex progressValue.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   833
                ex proceed.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   834
            ] do:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   835
                aBlock valueWithOptionalArgument:p.    
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   836
            ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   837
        ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   838
    ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   839
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   840
    "
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   841
     ProgressIndicator
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   842
        displayProgressNotifications:'doobidoobidoo...'
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   843
        abortable:true
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   844
        at:nil
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   845
        during:[
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   846
            200 to:400 by:5 do:[:i |
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   847
                Delay waitForSeconds:0.1.
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   848
                ProgressNotification progressPercentage:(i / 4).
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   849
            ]
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   850
        ].
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   851
    "
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   852
    "
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   853
     ProgressIndicator
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   854
        displayProgressNotifications:'doobidoobidoo...'
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   855
        abortable:true
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   856
        at:nil
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   857
        during:[
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   858
            Delay waitForSeconds:3.
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   859
        ].
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
   860
    "
3967
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   861
Claus Gittinger <cg@exept.de>
parents: 3827
diff changeset
   862
    "Created: / 12-11-2010 / 19:02:43 / cg"
3542
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   863
! !
3e9b8a2186da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3442
diff changeset
   864
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   865
!ProgressIndicator methodsFor:'accessing'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   866
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   867
percentage:aNumber
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   868
    "set the percentage"
237
ecea4b3a34ce more interfaces
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   869
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   870
    |newPercentage|
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   871
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   872
    aNumber < 0 ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   873
        newPercentage := -1.
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   874
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   875
        newPercentage := ((aNumber max:0) min:100) rounded.
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
   876
    ].
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   877
    newPercentage ~= percentage ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   878
        percentage := newPercentage.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   879
        self invalidateRepairNow:true.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   880
    ]
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   881
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   882
    "Modified: / 6.6.1998 / 19:43:56 / cg"
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   883
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   884
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   885
showBusyIndication:aBooleanHolder
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   886
    "switch between percentage mode (if false) and busy indication (if true)"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   887
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   888
    aBooleanHolder ~~ showBusy ifTrue:[
3969
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   889
        showBusy notNil ifTrue:[        
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   890
            showBusy removeDependent:self.
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   891
        ].
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   892
        showBusy := aBooleanHolder.
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   893
        showBusy isValueModel ifTrue:[showBusy addDependent:self].
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   894
        (showBusy value) ifTrue:[
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   895
            self startBusyIndicationProcess.
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   896
        ] ifFalse:[
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   897
            self stopBusyIndicationProcess
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   898
        ].
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   899
        shown ifTrue:[self redraw]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   900
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   901
3969
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   902
    "Created: / 21-10-1998 / 17:35:16 / cg"
fa06bc0686ed changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents: 3967
diff changeset
   903
    "Modified: / 17-11-2010 / 13:43:51 / cg"
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   904
! !
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   905
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   906
!ProgressIndicator methodsFor:'accessing-behavior'!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   907
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   908
closeTopWhenDone:aBoolean
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   909
    "set/clear the close-topView-when-done flag"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   910
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   911
    closeTopWhenDone := aBoolean
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   912
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   913
    "Created: 3.9.1996 / 14:22:03 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   914
    "Modified: 29.3.1997 / 16:08:19 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   915
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   916
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   917
finishAction:aBlock 
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   918
    "define an action to be performed when finished"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   919
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   920
    finishAction := aBlock
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   921
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   922
    "Created: 3.9.1996 / 14:15:15 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   923
    "Modified: 29.3.1997 / 16:08:35 / cg"
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   924
! !
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   925
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
   926
!ProgressIndicator methodsFor:'accessing-look'!
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   927
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   928
backgroundColor 
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   929
    "return the percentage displays background color"
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   930
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   931
    ^ bgColor
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   932
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   933
!
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   934
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   935
backgroundColor:aColor 
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   936
    "set the percentage displays background color"
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   937
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   938
    aColor ~= bgColor ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   939
        bgColor := aColor.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   940
        self invalidateRepairNow:true
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   941
    ].
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   942
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   943
    "Modified: / 20.7.1998 / 23:32:48 / cg"
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   944
!
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
   945
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   946
foregroundColor 
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   947
    "return the percentage displays foreground color"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   948
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   949
    ^ fgColor
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   950
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   951
    "Created: 29.3.1997 / 16:12:28 / cg"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   952
!
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   953
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   954
foregroundColor:aColor 
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   955
    "set the percentage displays foreground color"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   956
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   957
    aColor ~= fgColor ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   958
        fgColor := aColor.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   959
        self invalidateRepairNow:true
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   960
    ].
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   961
993
6274668e8262 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   962
    "Modified: / 20.7.1998 / 23:27:47 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   963
!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   964
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   965
showPercentage
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   966
    "return the flag controlling if the percentage is to be shown numerically"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   967
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   968
    ^ showPercentage
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   969
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   970
    "Created: 29.3.1997 / 16:12:39 / cg"
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   971
!
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   972
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   973
showPercentage:aBoolean
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   974
    "set/clear the flag controlling if the percentage is to be shown numerically"
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   975
336
5199e2058981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   976
    showPercentage := aBoolean.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   977
    self invalidateRepairNow:true
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   978
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
   979
    "Modified: / 6.6.1998 / 19:28:44 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   980
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   981
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   982
!ProgressIndicator methodsFor:'change & update'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   983
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   984
update:aspect with:aParameter from:changedObject
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   985
    "react upon value changes of my model"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
   986
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   987
    (aspect == aspectMsg
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   988
    and:[changedObject == model]) ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   989
        self percentage:(model perform:aspectMsg).
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   990
        ^ self
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   991
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   992
    changedObject == showBusy ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   993
        showBusy value 
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   994
            ifTrue:[self startBusyIndicationProcess]
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   995
            ifFalse:[self stopBusyIndicationProcess].
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   996
        self redraw.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
   997
        ^ self
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   998
    ].
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   999
    ^ super update:aspect with:aParameter from:changedObject
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1000
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1001
    "Modified: / 21-10-1998 / 18:01:52 / cg"
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1002
    "Modified: / 01-11-2006 / 08:40:50 / janfrog"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1003
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1004
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1005
!ProgressIndicator methodsFor:'drawing'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1006
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1007
redraw
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1008
    "redraw the percentage bar and optional percentage string"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1009
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1010
    |s lx rx sx sy sw m2 m w h doBusy|
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1011
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1012
    self shown ifFalse:[^self].
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1013
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1014
    m := margin + 1.
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1015
    m2 := m*2.
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1016
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1017
    w := width - m2.
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1018
    h := height - m2.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1019
910
5c9592e782fd always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  1020
"/    self clear.
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1021
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1022
    doBusy := showBusy value.
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1023
    doBusy ifFalse:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1024
        percentage value < 0 ifTrue:[
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1025
            self startBusyIndicationProcess.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1026
            doBusy := true.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1027
        ].        
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1028
    ].
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1029
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1030
    doBusy ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1031
        self paint:bgColor.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1032
        self fillRectangleX:m y:m width:w height:h.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1033
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1034
        lx := (w * busyPosition / 100) rounded.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1035
        rx := (w * (busyPosition + 20) / 100) rounded.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1036
        rx := rx min:w.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1037
        lx := lx max:m.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1038
        self paint:fgColor.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1039
        self fillRectangleX:lx y:m width:(rx - lx) height:h.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1040
        ^ self
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1041
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1042
2040
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1043
    self stopBusyIndicationProcess.
702df7addef9 busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents: 1935
diff changeset
  1044
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1045
    rx := (w * percentage / 100) rounded.
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
  1046
    self paint:bgColor.
843
34de7f6bea2d do only draw what to draw
tz
parents: 826
diff changeset
  1047
    self fillRectangleX:m+rx y:m width:w-rx height:h.
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1048
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1049
    showPercentage ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1050
        s := percentage printString , ' %'.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1051
        font := font onDevice:device.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1052
        sw := font widthOf:s .
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1053
        sx := (width - sw) // 2.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1054
        sy := height // 2 + font descent + 2.
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1055
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1056
        rx <= (sx+sw) ifTrue:[
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1057
            self paint:Color black.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1058
            self displayString:s x:sx y:sy.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1059
        ]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1060
    ].
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1061
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1062
    self paint:fgColor.
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1063
    self fillRectangleX:m y:m width:rx height:h.
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1064
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1065
    showPercentage ifTrue:[
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1066
        rx >= sx ifTrue:[
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1067
            self clippingRectangle:(m@m corner:rx+1 @ h).
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1068
            self paint:Color white.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1069
            self displayString:s x:sx y:sy.
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1070
            self clippingRectangle:nil
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1071
        ]
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1072
    ]
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1073
3748
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1074
    "Modified: / 21-10-1998 / 18:01:58 / cg"
4d72710a919e care for being not shown
Claus Gittinger <cg@exept.de>
parents: 3626
diff changeset
  1075
    "Modified: / 12-12-2006 / 18:26:02 / janfrog"
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1076
!
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1077
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1078
sizeChanged:how
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1079
    super sizeChanged:how.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1080
    self invalidate
863
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1081
a401ecea61a3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1082
    "Created: / 18.4.1998 / 02:34:37 / cg"
865
5c15ad847ad2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
  1083
    "Modified: / 18.4.1998 / 14:09:40 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1084
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1085
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
  1086
!ProgressIndicator methodsFor:'initialization & release'!
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1087
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1088
destroy
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1089
    busyIndicationProcess notNil ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1090
	self stopBusyIndicationProcess
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1091
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1092
    super destroy.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1093
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1094
    "Created: / 21.10.1998 / 17:29:58 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1095
    "Modified: / 21.10.1998 / 17:30:36 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1096
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1097
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1098
initStyle
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1099
    "initialize styleSheet values"
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1100
575
9279151db8f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
  1101
    <resource: #style (#'progressIndicator.viewBackground'
2921
1e8c394e895e resource directive
Claus Gittinger <cg@exept.de>
parents: 2878
diff changeset
  1102
                       #'progressIndicator.foregroundColor')>
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1103
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1104
    super initStyle.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1105
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1106
    self is3D ifTrue:[
2921
1e8c394e895e resource directive
Claus Gittinger <cg@exept.de>
parents: 2878
diff changeset
  1107
        self level:-1
347
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1108
    ].
3264e5caa799 fixed #fgColor;
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1109
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
  1110
    bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white.
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1111
    fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue.
335
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1112
    fgColor := fgColor onDevice:device.
6f007bdeae94 resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1113
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1114
    showPercentage := true.
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1115
!
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1116
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1117
initialize
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
  1118
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1119
    super initialize.
826
d8470e26754d revised for the docu (step 4)
tz
parents: 634
diff changeset
  1120
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1121
    percentage := 0.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1122
    showBusy := false.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1123
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1124
    "Modified: / 21.10.1998 / 17:33:02 / cg"
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1125
!
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1126
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1127
mapped
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1128
    super mapped.
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1129
    (showBusy value) ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1130
	self startBusyIndicationProcess.
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1131
    ].
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1132
!
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1133
3970
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1134
release
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1135
    super release.
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1136
    showBusy notNil ifTrue:[showBusy removeDependent:self].
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1137
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1138
    "Created: / 17-11-2010 / 13:44:45 / cg"
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1139
!
fd8dd1403069 added: #release
Claus Gittinger <cg@exept.de>
parents: 3969
diff changeset
  1140
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1141
unmapped
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1142
    super unmapped.
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1143
    (showBusy value) ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1144
	self stopBusyIndicationProcess.
1935
a2338e64cf2f terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents: 1852
diff changeset
  1145
    ].
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1146
! !
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1147
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1148
!ProgressIndicator methodsFor:'private'!
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1149
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1150
connectToTop:top label:label
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1151
    connectedTop := top.
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1152
    connectedLabel := label
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1153
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1154
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1155
startBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1156
    busyIndicationProcess isNil ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1157
	busyPosition := 0.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1158
	busyDelta := 5.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1159
	busyIndicationProcess := [
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1160
				    [self realized] whileTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1161
					Delay waitForSeconds:0.2.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1162
					self shown ifTrue:[
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1163
					    self updateBusyIndicatorPosition.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1164
					]
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1165
				    ].
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1166
				    busyIndicationProcess := nil.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1167
				 ] fork.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1168
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1169
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1170
    "Created: / 21.10.1998 / 18:02:35 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1171
    "Modified: / 21.10.1998 / 18:03:49 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1172
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1173
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1174
stopBusyIndicationProcess
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1175
    busyIndicationProcess notNil ifTrue:[
2563
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1176
	busyIndicationProcess terminate.
b04147223487 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2509
diff changeset
  1177
	busyIndicationProcess := nil
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1178
    ].
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1179
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1180
    "Created: / 21.10.1998 / 17:30:19 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1181
!
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1182
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1183
updateBusyIndicatorPosition
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1184
    busyPosition := busyPosition + busyDelta.
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1185
    busyPosition >= 80 ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1186
        busyDelta > 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1187
            busyDelta := busyDelta negated.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1188
        ]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1189
    ] ifFalse:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1190
        busyPosition <= 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1191
            busyDelta < 0 ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1192
                busyDelta := busyDelta negated.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1193
            ]
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1194
        ]
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1195
    ].
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
  1196
    self invalidate
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1197
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1198
    "Created: / 21.10.1998 / 17:33:28 / cg"
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1199
    "Modified: / 21.10.1998 / 17:58:58 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1200
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1201
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1202
!ProgressIndicator methodsFor:'queries'!
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1203
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1204
preferredExtent
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1205
    "return my preferred extent"
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1206
3581
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1207
    "/ If I have an explicit preferredExtent..
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1208
    explicitExtent notNil ifTrue:[
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1209
        ^ explicitExtent
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1210
    ].
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1211
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1212
    "/ If I have a cached preferredExtent value..
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1213
    preferredExtent notNil ifTrue:[
3581
3a61a4e2a631 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3542
diff changeset
  1214
        ^ preferredExtent
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1215
    ].
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1216
    ^ 100 @ (font height + font descent + ((margin + 1) * 2))
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1217
574
be7f980eb6dc commentary
Claus Gittinger <cg@exept.de>
parents: 347
diff changeset
  1218
    "Modified: 22.10.1997 / 21:07:17 / cg"
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1219
! !
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1220
62
claus
parents: 50
diff changeset
  1221
!ProgressIndicator methodsFor:'showing progress'!
claus
parents: 50
diff changeset
  1222
4079
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1223
new_showBusyIndicatorDuring:aBlock
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1224
    "show progress, while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1225
     If the receiver has been created with inBox, show the
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1226
     box centered on the screen. If not, the view is assumed to
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1227
     be contained in another view, and no special startup actions
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1228
     are performed.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1229
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1230
     Caveat: cannot (currently) suppress close of the box ..."
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1231
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1232
    |labelValue p|
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1233
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1234
    connectedLabel notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1235
        labelValue := (connectedLabel label ? '') asValue.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1236
        connectedLabel 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1237
            model:labelValue;
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1238
            aspect:#value;
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1239
            labelMessage:#value.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1240
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1241
        labelValue := '' asValue.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1242
    ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1243
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1244
    "/ the display process
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1245
    p := [
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1246
            self topView show.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1247
         ] fork.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1248
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1249
    "/ the worker process
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1250
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1251
    [
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1252
        aBlock value
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1253
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1254
        p terminate.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1255
        p := nil.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1256
        self stopBusyIndicationProcess.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1257
        closeTopWhenDone ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1258
            connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop).
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1259
            connectedTop hide
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1260
        ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1261
        self topView hide.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1262
        finishAction value
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1263
    ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1264
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1265
    "
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1266
      |p|
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1267
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1268
      p := ProgressIndicator inBox.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1269
      p showBusyIndication:true.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1270
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1271
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1272
                1 to:200 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1273
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1274
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1275
                ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1276
            ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1277
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1278
      'it can be reused ...'.  
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1279
      p showBusyIndication:false.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1280
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1281
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1282
                1 to:100 by:5 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1283
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1284
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1285
                ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1286
            ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1287
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1288
    "
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1289
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1290
    "Created: / 14-09-2011 / 18:41:44 / cg"
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1291
!
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1292
4078
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1293
new_showProgressOf:aBlock
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1294
    "show progress, while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1295
     If the receiver has been created with inBox, show the
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1296
     box centered on the screen. If not, the view is assumed to
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1297
     be contained in another view, and no special startup actions
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1298
     are performed.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1299
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1300
     The block is passed two arguments, the progressValue,
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1301
     which should be set to the percentage from time-to-time
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1302
     within the block and an action value, which should be set to
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1303
     the currently performed action (a string) from time to time.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1304
     The second valueHolder can be left unchanged.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1305
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1306
     Caveat: cannot (currently) suppress close of the box ..."
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1307
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1308
    |progressValue labelValue p aborted|
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1309
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1310
    progressValue := 0 asValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1311
    aborted := false.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1312
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1313
    connectedLabel notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1314
        labelValue := (connectedLabel label ? '') asValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1315
        connectedLabel 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1316
            model:labelValue;
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1317
            aspect:#value;
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1318
            labelMessage:#value.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1319
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1320
        labelValue := '' asValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1321
    ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1322
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1323
    self model:progressValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1324
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1325
    "/ the display process
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1326
    p := [
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1327
            self topView show.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1328
         ] fork.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1329
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1330
"/    WindowGroup windowGroupQuerySignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1331
"/        ex proceedWith:self topView windowGroup
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1332
"/    ] do:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1333
        [
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1334
            aBlock value:progressValue value:labelValue
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1335
        ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1336
            p terminate.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1337
            p := nil.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1338
            closeTopWhenDone ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1339
                connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop).
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1340
                connectedTop hide
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1341
            ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1342
            self topView hide.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1343
            finishAction value
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1344
        ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1345
"/    ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1346
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1347
    "
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1348
      |p|
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1349
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1350
      p := ProgressIndicator inBox.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1351
      p showBusyIndication:true.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1352
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1353
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1354
                1 to:200 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1355
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1356
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1357
                ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1358
            ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1359
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1360
      'it can be reused ...'.  
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1361
      p showBusyIndication:false.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1362
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1363
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1364
                1 to:100 by:5 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1365
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1366
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1367
                ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1368
            ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1369
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1370
    "
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1371
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1372
    "Created: / 14-09-2011 / 11:02:21 / cg"
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1373
!
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1374
4079
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1375
old_showBusyIndicatorDuring:aBlock
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1376
    "show progress, while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1377
     If the receiver has been created with inBox, show the
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1378
     box centered on the screen. If not, the view is assumed to
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1379
     be contained in another view, and no special startup actions
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1380
     are performed.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1381
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1382
     Caveat: cannot (currently) suppress close of the box ..."
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1383
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1384
    |labelValue p|
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1385
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1386
    connectedLabel notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1387
        labelValue := (connectedLabel label ? '') asValue.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1388
        connectedLabel 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1389
            model:labelValue;
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1390
            aspect:#value;
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1391
            labelMessage:#value.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1392
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1393
        labelValue := '' asValue.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1394
    ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1395
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1396
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1397
    "/ the worker process
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1398
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1399
    p := [
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1400
        [
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1401
            WindowGroup windowGroupQuerySignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1402
                ex proceedWith:self topView windowGroup
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1403
            ] do:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1404
                aBlock value
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1405
            ]
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1406
        ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1407
            p := nil.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1408
            self stopBusyIndicationProcess.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1409
            closeTopWhenDone ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1410
                connectedTop hide
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1411
            ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1412
            finishAction value.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1413
            
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1414
        ]
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1415
    ] newProcess.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1416
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1417
    Processor activeProcess 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1418
        withHigherPriorityDo:
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1419
            [
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1420
                p resume.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1421
                self topView show.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1422
            ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1423
    p notNil ifTrue:[p terminate].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1424
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1425
    "
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1426
      |p|
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1427
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1428
      p := ProgressIndicator inBox.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1429
      p showBusyIndication:true.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1430
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1431
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1432
                1 to:200 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1433
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1434
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1435
                ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1436
            ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1437
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1438
      'it can be reused ...'.  
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1439
      p showBusyIndication:false.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1440
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1441
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1442
                1 to:100 by:5 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1443
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1444
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1445
                ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1446
            ].
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1447
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1448
    "
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1449
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1450
    "Modified: / 21-10-1998 / 17:37:00 / cg"
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1451
    "Created: / 14-09-2011 / 18:41:34 / cg"
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1452
!
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1453
4078
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1454
old_showProgressOf:aBlock
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1455
    "show progress, while evaluating aBlock.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1456
     If the receiver has been created with inBox, show the
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1457
     box centered on the screen. If not, the view is assumed to
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1458
     be contained in another view, and no special startup actions
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1459
     are performed.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1460
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1461
     The block is passed two arguments, the progressValue,
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1462
     which should be set to the percentage from time-to-time
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1463
     within the block and an action value, which should be set to
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1464
     the currently performed action (a string) from time to time.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1465
     The second valueHolder can be left unchanged.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1466
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1467
     Caveat: cannot (currently) suppress close of the box ..."
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1468
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1469
    |progressValue labelValue p aborted|
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1470
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1471
    progressValue := 0 asValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1472
    aborted := false.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1473
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1474
    connectedLabel notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1475
        labelValue := (connectedLabel label ? '') asValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1476
        connectedLabel 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1477
            model:labelValue;
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1478
            aspect:#value;
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1479
            labelMessage:#value.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1480
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1481
        labelValue := '' asValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1482
    ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1483
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1484
    self model:progressValue.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1485
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1486
    "/ the worker process
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1487
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1488
    p := [
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1489
        [
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1490
            WindowGroup windowGroupQuerySignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1491
                ex proceedWith:self topView windowGroup
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1492
            ] do:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1493
                AbortSignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1494
                    aborted := true
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1495
                ] do:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1496
                    aBlock value:progressValue value:labelValue
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1497
                ]
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1498
            ]
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1499
        ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1500
            p := nil.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1501
            closeTopWhenDone ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1502
                connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop).
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1503
                connectedTop hide
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1504
            ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1505
            finishAction value
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1506
        ]
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1507
    ] newProcess.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1508
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1509
    Processor activeProcess 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1510
        withHigherPriorityDo:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1511
            p resume.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1512
            self topView show.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1513
        ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1514
    p notNil ifTrue:[p terminate].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1515
    aborted ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1516
        AbortSignal raiseRequest
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1517
    ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1518
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1519
    "
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1520
      |p|
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1521
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1522
      p := ProgressIndicator inBox.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1523
      p showBusyIndication:true.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1524
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1525
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1526
                1 to:200 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1527
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1528
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1529
                ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1530
            ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1531
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1532
      'it can be reused ...'.  
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1533
      p showBusyIndication:false.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1534
      p showProgressOf:
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1535
            [:progressValue :currentAction |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1536
                1 to:100 by:5 do:[:percent |
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1537
                    (Delay forSeconds:0.05) wait.
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1538
                    progressValue value:percent 
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1539
                ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1540
            ].
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1541
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1542
    "
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1543
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1544
    "Modified: / 12-09-2011 / 09:57:03 / cg"
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1545
    "Created: / 14-09-2011 / 11:00:12 / cg"
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1546
!
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1547
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1548
showBusyIndicatorDuring:aBlock
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1549
    "show progress, while evaluating aBlock.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1550
     If the receiver has been created with inBox, show the
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1551
     box centered on the screen. If not, the view is assumed to
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1552
     be contained in another view, and no special startup actions
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1553
     are performed.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1554
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1555
     Caveat: cannot (currently) suppress close of the box ..."
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1556
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1557
    |labelValue p|
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1558
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1559
    connectedLabel notNil ifTrue:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1560
        labelValue := (connectedLabel label ? '') asValue.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1561
        connectedLabel 
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1562
            model:labelValue;
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1563
            aspect:#value;
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1564
            labelMessage:#value.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1565
    ] ifFalse:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1566
        labelValue := '' asValue.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1567
    ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1568
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1569
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1570
    "/ the worker process
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1571
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1572
    p := [
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1573
        [
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1574
            WindowGroup windowGroupQuerySignal handle:[:ex |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1575
                ex proceedWith:self topView windowGroup
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1576
            ] do:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1577
                aBlock value
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1578
            ]
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1579
        ] ensure:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1580
            p := nil.
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1581
            self stopBusyIndicationProcess.
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1582
            closeTopWhenDone ifTrue:[
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1583
                connectedTop hide
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1584
            ].
3626
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1585
            finishAction value.
b2087f53346e ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1586
            
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1587
        ]
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1588
    ] newProcess.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1589
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1590
    Processor activeProcess 
2878
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1591
        withHigherPriorityDo:
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1592
            [
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1593
                p resume.
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1594
                self topView show.
6a88c8ffeb14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2850
diff changeset
  1595
            ].
2850
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1596
    p notNil ifTrue:[p terminate].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1597
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1598
    "
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1599
      |p|
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1600
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1601
      p := ProgressIndicator inBox.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1602
      p showBusyIndication:true.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1603
      p showProgressOf:
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1604
            [:progressValue :currentAction |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1605
                1 to:200 do:[:percent |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1606
                    (Delay forSeconds:0.05) wait.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1607
                    progressValue value:percent 
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1608
                ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1609
            ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1610
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1611
      'it can be reused ...'.  
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1612
      p showBusyIndication:false.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1613
      p showProgressOf:
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1614
            [:progressValue :currentAction |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1615
                1 to:100 by:5 do:[:percent |
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1616
                    (Delay forSeconds:0.05) wait.
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1617
                    progressValue value:percent 
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1618
                ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1619
            ].
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1620
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1621
    "
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1622
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1623
    "Modified: / 21.10.1998 / 17:37:00 / cg"
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1624
!
4e58a7e9c323 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2837
diff changeset
  1625
62
claus
parents: 50
diff changeset
  1626
showProgressOf:aBlock
claus
parents: 50
diff changeset
  1627
    "show progress, while evaluating aBlock.
claus
parents: 50
diff changeset
  1628
     If the receiver has been created with inBox, show the
claus
parents: 50
diff changeset
  1629
     box centered on the screen. If not, the view is assumed to
claus
parents: 50
diff changeset
  1630
     be contained in another view, and no special startup actions
claus
parents: 50
diff changeset
  1631
     are performed.
claus
parents: 50
diff changeset
  1632
claus
parents: 50
diff changeset
  1633
     The block is passed two arguments, the progressValue,
claus
parents: 50
diff changeset
  1634
     which should be set to the percentage from time-to-time
claus
parents: 50
diff changeset
  1635
     within the block and an action value, which should be set to
claus
parents: 50
diff changeset
  1636
     the currently performed action (a string) from time to time.
claus
parents: 50
diff changeset
  1637
     The second valueHolder can be left unchanged.
claus
parents: 50
diff changeset
  1638
claus
parents: 50
diff changeset
  1639
     Caveat: cannot (currently) suppress close of the box ..."
claus
parents: 50
diff changeset
  1640
4078
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1641
    "/ ^ self old_showProgressOf:aBlock
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1642
    ^ self new_showProgressOf:aBlock
62
claus
parents: 50
diff changeset
  1643
claus
parents: 50
diff changeset
  1644
    "
claus
parents: 50
diff changeset
  1645
      |p|
claus
parents: 50
diff changeset
  1646
claus
parents: 50
diff changeset
  1647
      p := ProgressIndicator inBox.
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1648
      p showBusyIndication:true.
62
claus
parents: 50
diff changeset
  1649
      p showProgressOf:
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1650
            [:progressValue :currentAction |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1651
                1 to:200 do:[:percent |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1652
                    (Delay forSeconds:0.05) wait.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1653
                    progressValue value:percent 
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1654
                ].
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1655
            ].
62
claus
parents: 50
diff changeset
  1656
claus
parents: 50
diff changeset
  1657
      'it can be reused ...'.  
1168
35e46761842f added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
  1658
      p showBusyIndication:false.
62
claus
parents: 50
diff changeset
  1659
      p showProgressOf:
2837
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1660
            [:progressValue :currentAction |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1661
                1 to:100 by:5 do:[:percent |
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1662
                    (Delay forSeconds:0.05) wait.
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1663
                    progressValue value:percent 
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1664
                ].
d788335f2010 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
  1665
            ].
62
claus
parents: 50
diff changeset
  1666
claus
parents: 50
diff changeset
  1667
    "
219
44246b9b4288 use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
  1668
4078
Claus Gittinger <cg@exept.de>
parents: 4077
diff changeset
  1669
    "Modified: / 14-09-2011 / 17:03:08 / cg"
62
claus
parents: 50
diff changeset
  1670
! !
claus
parents: 50
diff changeset
  1671
334
8af14110efdb comments & category changes
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
  1672
!ProgressIndicator class methodsFor:'documentation'!
50
claus
parents:
diff changeset
  1673
183
c63a4f284a6d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1674
version
4079
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1675
    ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.68 2011-09-14 16:44:14 cg Exp $'
3827
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
  1676
!
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
  1677
ec0aed04e61f changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents: 3748
diff changeset
  1678
version_CVS
4079
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
  1679
    ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.68 2011-09-14 16:44:14 cg Exp $'
50
claus
parents:
diff changeset
  1680
! !