Stub Button In Visual Works

Here you find an implementation of the StubButton for VisualWorks.

Make sure, that you have Envy and the RefactoringBrowser installed, than file in the follwing...

(Any help appreciated to format code on a wiki, do I have to use SixSingleQuotes around each ambiguous class?) Yes.

-- MarkusGaelli


"Changes in change set stubButton" 'From VisualWorks®, Release 3.0 of 25. Februar 1998 on 1. August 2000 at 11:11:01'!

!EtDebugger privateMethodsFor: 'ET-Internal'!

createWindow

"Private - Initialize a browser by defining the type,
 behavior and relative size of each view. Return 
 the topView."

| topView buttons step send define switchHeight composite isStepActive isSendActive lineHeight spec listCallbacksSpec listSpec |

lineHeight := LabeledBooleanView defaultHeight + 2. topView := self initializeBrowser. composite := topView component.

isStepActive := (PluggableAdaptor on: self) getBlock: [:m | m context notNil] putBlock: [:m :v | ] updateBlock: [:m :a :p | a == #theContext]. isStepActive := (PluggableAdaptor on: isStepActive) selectValue: true. isSendActive := (PluggableAdaptor on: self) getBlock: [:m | m context == m interruptedContext] putBlock: [:m :v | ] updateBlock: [:m :a :p | a == #theContext]. isSendActive := (PluggableAdaptor on: isSendActive) selectValue: true.

switchHeight := [LabeledBooleanView defaultHeight + 4]. buttons := CompositePart new. step := (self actionButtonClass model: ((PluggableAdaptor on: self) performAction: #step)) labelString: 'step'. send := (self actionButtonClass model: ((PluggableAdaptor on: self) performAction: #send)) labelString: 'send'. define := (self actionButtonClass model: ((PluggableAdaptor on: self) performAction: #define)) labelString: 'define'. buttons add: (BoundedWrapper on: step) in: (LayoutFrame new leftOffset: 2; topOffset: 0.2; rightOffset: 53; bottomFraction: 1). buttons add: (BoundedWrapper on: send) in: (LayoutFrame new leftOffset: 54; topOffset: 0.2; rightOffset: 106; bottomFraction: 1). buttons add: (BoundedWrapper on: define) in: (LayoutFrame new leftOffset: 106; topOffset: 0.2; rightOffset: 158; bottomFraction: 1). builder componentAt: #step put: step. builder componentAt: #send put: send. builder componentAt: #define put: define.

listCallbacksSpec := UIEventCallbackSubSpec new. listCallbacksSpec requestValueChangeSelector: #changeRequest. builder aspectAt: #contextListHolder put: self contextListHolder. listSpec := SequenceViewSpec new. listSpec performer: self. listSpec name: #contextListHolder. listSpec model: self contextListHolder. listSpec callbacksSpec: listCallbacksSpec. listSpec menu: self contextListMenuHolder. listSpec layout: (LayoutFrame leftFraction: 0 offset: 0 rightFraction: 1 offset: 0 topFraction: 0 offset: 0 bottomFraction: 0.2 offset: 0). builder add: listSpec.

composite add: buttons in: (LayoutFrame new leftOffset: 0; topFraction: 0.2; rightFraction: 1; bottomFraction: 0.2 offset: switchHeight).

builder add: self textWidget.

composite add: self informationWidget in: (LayoutFrame new leftFraction: 0; rightFraction: 1 offset: (TextAttributes defaultLineGrid * -5); topFraction: 0.8 offset: lineHeight negated; bottomFraction: 0.8).

composite add: self textButtonWidget in: (LayoutFrame new leftFraction: 1 offset: (TextAttributes defaultLineGrid * -5); rightFraction: 1; topFraction: 0.8 offset: lineHeight negated; bottomFraction: 0.8).

builder aspectAt: #receiverInspector put: self receiverInspector. spec := SubCanvasSpec new. spec name: #receiverInspector. spec clientKey: #receiverInspector. spec majorKey: #Inspector. spec minorKey: #windowSpec. spec layout: (LayoutFrame leftFraction: 0 offset: 0 rightFraction: 0.5 offset: 0 topFraction: 0.8 offset: 0 bottomFraction: 1 offset: 0). builder add: spec.

builder aspectAt: #contextInspector put: self contextInspector. spec := SubCanvasSpec new. spec name: #receiverInspector. spec clientKey: #contextInspector. spec majorKey: #Inspector. spec minorKey: #windowSpec. spec layout: (LayoutFrame leftFraction: 0.5 offset: 0 rightFraction: 1 offset: 0 topFraction: 0.8 offset: 0 bottomFraction: 1 offset: 0). builder add: spec. self postBuildWith: builder. ^topView! !

!EtDebugger publicMethodsFor: 'private'!

checkEnablement

builder isNil ifTrue: [^self].
(builder componentAt: #step) isEnabled: self context notNil.
(builder componentAt: #send) isEnabled: (self context == self interruptedContext).
(builder componentAt: #define) isEnabled: ( self context notNil and: [(self context receiver notNil and: [self context selector = #doesNotUnderstand:])])!

define
| anIndex aSelectorString aSourceString aStream|
anIndex := 1.
aStream := WriteStream on: ''.
aSelectorString := (self context localAt: 1) selector asString.
aSelectorString do: [:each | 
aStream nextPut: each.
(each = $:) ifTrue: [
aStream 
nextPutAll: ' anObject';
nextPutAll: anIndex printString;
space.
anIndex := anIndex + 1]].
aSourceString :=
(WriteStream on: '')
nextPutAll
aStream contents;
cr; tab; nextPutAll: 'self halt'; contents.

(AddMethodChange compile: aSourceString in: (self context receiver class)) execute. self context: (self contextList at: 2). self restart! !


EditText of this page (last edited June 28, 2003) or FindPage with title or text search