Cleanup of (former) `VDBModelPresenter`
* renamed `VDBModelPresenter` to `VDBAbstractPresenter` to follow
naming conventions
* improved support for presenter-defined menu items by using
per-menu-item receiver feature recently added to `stx:libview2` /
`stx:libwidh2`.
* As a demonstration, added "Enable" / "Disable" menu items to
breakpoint menu.
"
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 }"
VDBAbstractApplication subclass:#VDBAbstractListApplication
instanceVariableNames:'internalListHolder internalListView internalSelectionHolder'
classVariableNames:''
poolDictionaries:''
category:'VDB-UI-Abstract'
!
!VDBAbstractListApplication 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/
"
! !
!VDBAbstractListApplication class methodsFor:'interface specs'!
columnsSpec
^ #()
"Created: / 02-06-2017 / 07:26:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
windowSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:VDBAbstractListApplication andSelector:#windowSpec
VDBAbstractListApplication new openInterface:#windowSpec
VDBAbstractListApplication open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'VDBAbstractListApplication'
name: 'VDBAbstractListApplication'
min: (Point 10 10)
bounds: (Rectangle 0 0 300 300)
)
component:
(SpecCollection
collection: (
(SelectionInListModelViewSpec
name: 'SelectionInListModelView1'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
model: internalSelectionHolder
menu: contextMenu
hasHorizontalScrollBar: true
hasVerticalScrollBar: true
listModel: internalListHolder
useIndex: false
highlightMode: line
doubleClickSelector: doDoubleClick
postBuildCallback: postBuildInternalListView:
)
)
)
)
"Modified: / 11-07-2017 / 15:19:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication class methodsFor:'menu specs'!
contextMenu
"This resource specification was automatically generated
by the MenuEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the MenuEditor may not be able to read the specification."
"
MenuEditor new openOnClass:VDBAbstractListApplication andSelector:#contextMenu
(Menu new fromLiteralArrayEncoding:(VDBAbstractListApplication contextMenu)) startUp
"
<resource: #menu>
^
#(Menu
(
(MenuItem
label: 'Item Menu Slice'
submenuChannel: contextMenuItemSlice
isMenuSlice: true
)
(MenuItem
label: 'Inspect Menu Slice'
submenuChannel: contextMenuInspectSlice
isMenuSlice: true
)
)
nil
nil
)
!
contextMenuInspectSlice
"This resource specification was automatically generated
by the MenuEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the MenuEditor may not be able to read the specification."
"
MenuEditor new openOnClass:VDBAbstractListApplication andSelector:#contextMenuInspectSlice
(Menu new fromLiteralArrayEncoding:(VDBAbstractListApplication contextMenuInspectSlice)) startUp
"
<resource: #menu>
^
#(Menu
(
(MenuItem
enabled: hasSelection
label: 'Inspect Model'
itemValue: doInspectModel
)
(MenuItem
label: 'Inspect Presenter'
itemValue: doInspectPresenter
)
(MenuItem
label: '-'
)
(MenuItem
label: 'Update'
itemValue: duUpdateList
)
)
nil
nil
)
! !
!VDBAbstractListApplication class methodsFor:'plugIn spec'!
aspectSelectors
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this. If it is corrupted,
the UIPainter may not be able to read the specification."
"Return a description of exported aspects;
these can be connected to aspects of an embedding application
(if this app is embedded in a subCanvas)."
^ #(
#debuggerHolder
).
! !
!VDBAbstractListApplication class methodsFor:'queries'!
isAbstract
"Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine again."
^ self == VDBAbstractListApplication.
! !
!VDBAbstractListApplication methodsFor:'actions'!
postBuildInternalListView: aView
<resource: #uiCallback>
| columns |
internalListView := aView.
internalListView font: CodeView defaultFont.
columns := self class columnsSpec.
columns notEmptyOrNil ifTrue:[
| renderer |
renderer := aView setupTableRenderer.
renderer columnDescriptors: columns
].
"Modified: / 11-06-2017 / 22:16:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication methodsFor:'aspects'!
backgroundColorFor: aVDBPresenter
"Returns an backgdound color for second and the rest of columns (not for the first one).
If `nil` returned, a default is used"
^ nil
"Created: / 01-02-2018 / 09:06:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication methodsFor:'aspects-private'!
internalListHolder
"return/create the 'listHolder' value holder (automatically generated)"
internalListHolder isNil ifTrue:[
internalListHolder := ValueHolder new.
].
^ internalListHolder
"Created: / 27-02-2015 / 15:55:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
internalSelectionHolder
"return/create the 'internalSelectionHolder' value holder (automatically generated)"
internalSelectionHolder isNil ifTrue:[
internalSelectionHolder := ValueHolder new.
internalSelectionHolder addDependent:self.
].
^ internalSelectionHolder
! !
!VDBAbstractListApplication methodsFor:'change & update'!
enqueueDelayedInvalidateInternalList
internalListView notNil ifTrue:[
internalListView scrolledView invalidate
]
"Created: / 01-02-2018 / 23:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
enqueueDelayedUpdateInternalList
self enqueueDelayedUpdate: #delayedUpdateInternalList
"Created: / 20-09-2014 / 23:05:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 17-01-2018 / 06:51:55 / jv"
!
enqueueDelayedUpdateSelection
self enqueueDelayedUpdate: #delayedUpdateSelection
"Created: / 27-02-2015 / 15:35:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 17-01-2018 / 06:52:09 / jv"
!
update:aspect with:param from:sender
"Invoked when an object that I depend upon sends a change notification."
sender == internalSelectionHolder ifTrue:[
self enqueueDelayedUpdateSelection.
^ self
].
super update:aspect with:param from:sender
"Created: / 27-02-2015 / 15:44:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication methodsFor:'change & update-delayed'!
delayedUpdateInternalList
"raise an error: must be redefined in concrete subclass(es)"
^ self subclassResponsibility
!
delayedUpdateSelection
"raise an error: must be redefined in concrete subclass(es)"
^ self subclassResponsibility
! !
!VDBAbstractListApplication methodsFor:'hooks'!
commonPostOpen
"a common hook for postOpenWith:, postOpenAsSubcanvasWith: and postOpenAsDialogWith:."
self enqueueDelayedUpdateInternalList
"Created: / 18-09-2014 / 00:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 20-09-2014 / 23:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication methodsFor:'menu'!
contextMenu
^ [
(Menu decodeFromLiteralArray: self class contextMenu)
receiver:self;
findGuiResourcesIn:self;
yourself
]
"Created: / 16-01-2018 / 14:29:05 / jv"
"Modified: / 16-01-2018 / 22:02:37 / jv"
"Modified (comment): / 16-01-2018 / 23:26:46 / jv"
!
contextMenuItemSlice
| item menu |
item := self internalSelectionHolder value.
item isNil ifTrue:[
menu := Menu new.
] ifFalse:[
menu := item contextMenu.
].
^ menu.
"Created: / 16-01-2018 / 13:37:08 / jv"
"Modified: / 16-01-2018 / 22:03:45 / jv"
! !
!VDBAbstractListApplication methodsFor:'menu actions'!
doDoubleClick
"Invoked when user double-clicks to list item."
| selectedVarObjPresenter |
selectedVarObjPresenter := self internalSelectionHolder value.
selectedVarObjPresenter notNil ifTrue:[
selectedVarObjPresenter doDoubleClick
].
"Created: / 13-06-2017 / 17:09:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 16-01-2018 / 23:33:12 / jv"
"Modified: / 05-02-2018 / 13:02:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doInspectModel
| selection |
selection := self internalSelectionHolder value.
selection notEmptyOrNil ifTrue:[
selection subject inspect
].
"Modified: / 05-02-2018 / 13:07:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doInspectPresenter
self internalSelectionHolder value inspect
"Modified: / 22-09-2014 / 01:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
duUpdateList
<resource: #uiCallback>
self enqueueDelayedUpdateInternalList
"Modified: / 12-06-2017 / 12:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication methodsFor:'queries'!
hasSelection
^ self internalSelectionHolder value notEmptyOrNil
"Modified: / 22-09-2014 / 01:13:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !