VDBThreadGroupPresenter.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 23 Nov 2017 22:45:57 +0000
changeset 49 2ec7f7ed9242
parent 44 41cc5a7840fe
child 53 738e2f6626bf
permissions -rw-r--r--
License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

VDBModelPresenter subclass:#VDBThreadGroupPresenter
	instanceVariableNames:'threadGroup'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Presentation'
!

!VDBThreadGroupPresenter class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
! !

!VDBThreadGroupPresenter methodsFor:'accessing'!

icon
    threadGroup isRunning ifTrue:[ ^ VDBIconLibrary threadGroupRunning16x16 ].
    threadGroup isStopped ifTrue:[ ^ VDBIconLibrary threadGroupStopped16x16 ].
    threadGroup isDead    ifTrue:[ ^ VDBIconLibrary threadGroupTerminated16x16 ].
    ^ nil

    "Created: / 22-09-2014 / 22:13:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 30-09-2014 / 00:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

label
    | executableOrThreadGrouppId pidOrEmpty state |

    threadGroup executable notNil ifTrue:[ 
        executableOrThreadGrouppId := threadGroup executable contractTo: 30 
    ] ifFalse:[ 
        executableOrThreadGrouppId := 'thread group ', threadGroup id.
    ].

    (threadGroup type = 'process' and:[ threadGroup pid notNil ]) ifTrue:[
        pidOrEmpty := 'pid ', threadGroup pid printString , ', '.
    ].
    threadGroup isStopped ifTrue:[ 
        state := 'stopped'
    ] ifFalse:[ 
    threadGroup isRunning ifTrue:[ 
        state := 'running'
    ] ifFalse:[ 
    threadGroup isFinished ifTrue:[ 
        state := 'finished'
    ] ifFalse:[ 
    threadGroup isTerminated ifTrue:[ 
        state := 'terminated'
    ] ifFalse:[ 
        state := 'not run'
    ]]]].

    ^ '%1 [%2%3]' bindWith: executableOrThreadGrouppId 
                      with: pidOrEmpty ? ''
                      with: state

    "Created: / 22-09-2014 / 00:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 07-06-2017 / 07:47:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

threadGroup
    ^ threadGroup
! !

!VDBThreadGroupPresenter methodsFor:'initialization'!

setThreadGroup: aGDBThreadGroup
    threadGroup := aGDBThreadGroup

    "Created: / 21-09-2014 / 23:38:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBThreadGroupPresenter methodsFor:'protocol-accessing'!

fetchChildren
    "should compute the list of children via the model.
     Be aware, that the somewhat stupid 'optimization' of how the model is fetched may lead to
     a O(n*log n) or even O(n^2) behavior here.
     *** to optimize: redefine by subClass"

    ^ threadGroup threads collect:[ :t | VDBThreadPresenter new setThread: t; parent: self ]

    "Created: / 21-09-2014 / 23:41:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBThreadGroupPresenter methodsFor:'testing'!

isThreadGroupPresenter
    ^ true

    "Created: / 21-09-2014 / 23:54:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBThreadGroupPresenter class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !