SemaphoreMonitor.st
changeset 19056 9bb181a447f7
parent 17443 e4ab616db8de
equal deleted inserted replaced
19055:1a6b9983e637 19056:9bb181a447f7
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1997 by Claus Gittinger
     4  COPYRIGHT (c) 1997 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   104 !
   106 !
   105 
   107 
   106 updateStatus:newSemaphoreList
   108 updateStatus:newSemaphoreList
   107     "update status display of semaphores"
   109     "update status display of semaphores"
   108 
   110 
   109     |oldList list oldSelection newSelection|
   111     |numberOfHeadlines oldList list oldSelection newSelection|
   110 
   112 
   111     shown ifTrue:[
   113     shown ifTrue:[
       
   114         numberOfHeadlines := self numberOfHeadlines.    
   112         oldList := listView list.
   115         oldList := listView list.
   113         oldSelection := listView selectionValue.
   116         oldSelection := listView selectionValue.
   114         oldSelection notNil ifTrue:[
   117         oldSelection notNil ifTrue:[
   115             oldSelection := oldSelection collect:[:line | line asCollectionOfWords first asNumber].
   118             oldSelection := oldSelection 
       
   119                                 collect:[:line | line asCollectionOfWords first asNumber].
   116             newSelection := OrderedCollection new.
   120             newSelection := OrderedCollection new.
   117         ].
   121         ].
   118 
   122 
   119         newSemaphoreList notNil ifTrue:[
   123         newSemaphoreList notNil ifTrue:[
   120             semaphores := WeakArray withAll:newSemaphoreList.
   124             semaphores := WeakArray withAll:newSemaphoreList.
   121         ].
   125         ].
   122         semaphores notNil ifTrue:[
   126         semaphores notNil ifTrue:[
   123             list := OrderedCollection new:(semaphores size + self numberOfHeadlines).
   127             list := OrderedCollection new:(semaphores size + numberOfHeadlines).
   124             list add:self titleLine.
   128             list add:self titleLine.
   125             list add:(String new:self titleLine size withAll:$-).
   129             list add:(String new:self titleLine size withAll:$-).
   126 
   130 
   127             semaphores validElementsDo:[:aSemaphore |
   131             semaphores validElementsDo:[:aSemaphore |
   128                 |waiters waitersNames nm id str owner color line count|
   132                 |waiters waitersNames nm id str owner color line count|
   210                     listView at:idx put:entry
   214                     listView at:idx put:entry
   211                 ]
   215                 ]
   212             ]
   216             ]
   213         ] ifFalse:[
   217         ] ifFalse:[
   214             listView setList:list.
   218             listView setList:list.
   215             "the first two entries cannot be selected"
   219             "the first few entries cannot be selected"
   216             listView attributeAt:1 put:#disabled.
   220             1 to:numberOfHeadlines do:[:lNr | listView attributeAt:lNr put:#disabled].
   217             listView attributeAt:2 put:#disabled.
       
   218         ].
   221         ].
   219         newSelection notNil ifTrue:[
   222         newSelection notNil ifTrue:[
   220             listView selectWithoutScroll:newSelection
   223             listView selectWithoutScroll:newSelection
   221         ].
   224         ].
   222         listView flush
   225         listView flush