From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 1:01:18 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>StartupOrderingDrawingController</name> <environment>Tools</environment> <super>Refactory.HotDraw.DrawingController</super> <private>false</private> none rolloverFigure <imports></imports> <category>Tools-StartupOrderingTool</category> <attributes> <package>Tools-StartupOrderingTool</package> </attributes> </class> <comment> Tools.StartupOrderingDrawingController
StartupOrderingDrawingController is a controller for StartupOrderingDrawings which implements a quick and dirty figure rollover. It tracks mouse motion events and notifies those figures that can display rollover state about state changes. A figure with a rollover state should implement #showRolloverState and #showNormalState methods. Instance Variables: rolloverFigure <Figure> The figure under the cursor the last time a motion event was process. On motion events, when this is different from the current figure, both are notified appropriately.
</comment> <class> <name>StartupOrderingDrawing</name> <environment>Tools</environment> <super>Refactory.HotDraw.Drawing</super> <private>false</private> none <imports></imports> <category>HotDraw Framework</category> <attributes> <package>Tools-StartupOrderingTool</package> </attributes> </class> <comment> Tools.StartupOrderingDrawing
This is a drawing subclass for showing startup sequence diagrams. Subsystems that require other subsystems will be drawn lower down than their prerequisites, and with arrows pointing to the prerequisite subsystems.
</comment> <class> <name>SubsystemFigure</name> <environment>Tools</environment> <super>Refactory.HotDraw.RectangleFigure</super> <private>false</private> none <imports></imports> <category>HotDraw Framework</category> <attributes> <package>Tools-StartupOrderingTool</package> </attributes> </class> <comment> Tools.SubsystemFigure
SubsystemFigure is used to display a box corresponding to a Subsystem in a diagram that shows the startup sequence dependencies between subsystems.
</comment> <class> <name>SubsystemOrderingEditor</name> <environment>Tools</environment> <super>Refactory.HotDraw.DrawingEditor</super> <private>false</private> none showAll mainClass <imports></imports> <category>HotDraw Framework</category> <attributes> <package>Tools-StartupOrderingTool</package> </attributes> </class> <comment> Tools.SubsystemOrderingEditor
This is an application model for displaying the startup order dependencies of Subsystem classes in the browser. Instance Variables: mainClass <Subsystem> If this diagram should be centered around a single class, it will be listed here. In that case we will highlight that class, may show only its prerequisites/dependents (see showAll). If this is not set, we show all subsystems, with nothing highlighted. showAll <Boolean> If mainClass is set, should we show all subsystems, or just those that are its prerequisites/dependents.
</comment> <class> <name>SubsystemOrderingSelectionPolicy</name> <environment>Tools</environment> <super>Refactory.Browser.CodeToolSelectionPolicy</super> <private>false</private> none <imports></imports> <category>Browser-BrowserUI</category> <attributes> <package>Tools-StartupOrderingTool</package> </attributes> </class> <comment> Tools.SubsystemOrderingSelectionPolicy
This implements a selection policy for startup sequence diagrams. Primarily, it controls the name we display in the browser tab and makes sure we get the appropriate code tool for the selected objects.
</comment> <class> <name>SubsystemOrderCodeTool</name> <environment>Tools</environment> <super>Refactory.Browser.CodeTool</super> <private>false</private> none subsystemEditor <imports></imports> <category>Browser-StoreExtensions</category> <attributes> <package>Tools-StartupOrderingTool</package> </attributes> </class> <comment> Tools.SubsystemOrderCodeTool
A tool for showing the prerequisite relations between the selected class and other subsystems. Most of the work is actually pawned off on the edtior. Instance Variables: subsystemEditor <SubsystemOrderingEditor>
</comment> <methods> Tools.StartupOrderingDrawingController <category>events</category>
handleEvent: anEvent super handleEvent: anEvent. anEvent isMotionEvent ifTrue: [self mouseMovedEvent: anEvent]
mouseMovedEvent: anEvent | figure | figure := model drawing figureAt: (self sensor mousePointFor: anEvent). figure == rolloverFigure ifTrue: [^self]. (rolloverFigure respondsTo: #showNormalState) ifTrue: [rolloverFigure showNormalState]. (figure respondsTo: #showRolloverState) ifTrue: [figure showRolloverState]. rolloverFigure := figure
</methods> <methods> Tools.StartupOrderingDrawing <category>accessing</category>
menuAt: aPoint | mb item | mb := MenuBuilder new. item := MenuItem labeled: (#ShowAllSubsystems << #browser >> 'Show All'). item value: #toggleShowAll. item indication: self showAll. mb addItem: item. ^mb menu.
showAll ^self model showAll.
toggleShowAll self model toggleShowAll.
</methods> <methods> Tools.StartupOrderingDrawing <category>controller accessing</category>
defaultControllerClass ^StartupOrderingDrawingController
</methods> <methods> Tools.SubsystemFigure <category>accessing</category>
label | label | label := self theClass name asComposedText. (self model activationEvent == #earlySystemInstallation) ifTrue: [label text emphasizeAllWith: #italic]. ^label.
menuAt: aPoint | mb showAllMenuItem | mb := MenuBuilder new. showAllMenuItem := MenuItem labeled: (#ShowAllSubsystems << #browser >> 'Show All'). showAllMenuItem value: [self drawing toggleShowAll]. showAllMenuItem indication: self drawing showAll. mb addItem: showAllMenuItem; line; add: (#BrowseClass << #browser >> 'Browse Class') -> [self model browse]. ^mb menu.
on: aClass self theClass: aClass.
showNormalState self lineWidth: self lineWidth - 1. self invalidate
showRolloverState self lineWidth: self lineWidth + 1. self invalidate
theClass ^model
theClass: aClass model := aClass. bounds := (self label bounds expandedBy: 10@2).
</methods> <methods> Tools.SubsystemFigure <category>printing</category>
printOn: aStream super printOn: aStream. aStream nextPut: $(. aStream print: model. aStream nextPut: $).
</methods> <methods> Tools.SubsystemFigure <category>initialize-release</category>
initialize super initialize. self transparent.
</methods> <methods> Tools.SubsystemFigure <category>layout</category>
layoutIn: classToFigureMap withSpacing: aPoint startingFrom: startPoint "A crude layout algorithm. We are always lower down than our prerequisites. Within a 'layer' of things at an equivalent level of prerequisites, lay them out arbitrarily left to right, so just find the rightmost one that's in our layer so far, and be to the right of that" | y figureWithMaximumXAtThisY x prerequisitesInThisDiagram | (self bounds notNil and: [self bounds origin y > 0]) ifTrue: [^self]. prerequisitesInThisDiagram := self model current allPrerequisiteSystems select: [:each | classToFigureMap includesKey: each]. prerequisitesInThisDiagram do: [:each | (classToFigureMap at: each) layoutIn: classToFigureMap withSpacing: aPoint startingFrom: startPoint]. y := prerequisitesInThisDiagram inject: startPoint y into: [:max :each | (((classToFigureMap at: each) bounds origin y) + aPoint y) max: max]. figureWithMaximumXAtThisY := classToFigureMap inject: nil into: [:max :each | each origin y = y ifFalse: [max] ifTrue: [ max isNil ifTrue: [each] ifFalse: [max origin x <= each origin x ifTrue: [each] ifFalse: [max]]]]. x := figureWithMaximumXAtThisY isNil ifTrue: [startPoint x] ifFalse: [((figureWithMaximumXAtThisY origin x + aPoint x) max: (figureWithMaximumXAtThisY corner x + 5)) max: startPoint x]. "It seems silly to do both direct access and also use the accessor, but bounds: only flushes cache, doesn't actually set the bounds." bounds := ((x @ y) corner: (x + bounds corner x) @ (y + bounds corner y)). self bounds: bounds.
</methods> <methods> Tools.SubsystemFigure <category>displaying</category>
displayFigureOn: aGraphicsContext | text | super displayFigureOn: aGraphicsContext. text := self label. text displayOn: aGraphicsContext at: (self extent - text extent) // 2 + self origin + (1 @ 0)
</methods> <methods> Tools.SubsystemFigure class <category>instance creation</category>
on: aClass ^self new on: aClass.
</methods> <methods> Tools.SubsystemOrderingEditor <category>accessing</category>
clearDrawing self drawing removeAll: self drawing figures copy
displayClass: aClass | allFigures classToFigureMap maxY | self clearDrawing. mainClass := aClass. allFigures := self allFiguresFor: aClass. classToFigureMap := Dictionary new. allFigures do: [:each | classToFigureMap at: each model put: each]. self layout: allFigures accordingTo: classToFigureMap. self connectFigures: allFigures accordingTo: classToFigureMap. "There's an odd problem that it clips the bottom of the last figure, so get out the hatchet and add some pixels" maxY := allFigures inject: 0 into: [:max :each | max max: each corner y]. drawing addAll: allFigures; recomputePreferredBounds; mergeBounds: (0 @ 0 corner: 1 @ (maxY + 10)).
mainClass ^mainClass.
showAll ^showAll.
toggleShowAll showAll := showAll not. self updateDrawing.
</methods> <methods> Tools.SubsystemOrderingEditor <category>drawing description</category>
drawingClass "What type of drawing should we create?" ^StartupOrderingDrawing
toolNames ^(Array with: (#StartupOrderingTool << #browser >> 'System Startup Ordering Tool') asString)
</methods> <methods> Tools.SubsystemOrderingEditor <category>layout</category>
allFiguresFor: aClass | all classes | classes := showAll ifTrue: [Subsystem allSubclasses] ifFalse: [all := Set new. all addAll: aClass allPrerequisiteSystemsRecursively. all addAll: aClass allDependentSystemsRecursively. all add: aClass. all]. ^classes collect: [:each | | figure | figure := SubsystemFigure on: each. aClass == each ifTrue: [figure lineWidth: 3]. figure].
connectFigures: allFigures accordingTo: classToFigureMap "Connect systems to their prerequisites with lines" | lines | lines := OrderedCollection new. allFigures do: [:each | each theClass current allPrerequisiteSystems do: [:eachPrerequisite | classToFigureMap at: eachPrerequisite ifPresent: [:prerequisiteFigure | lines add: (each connectFromPoint: (each topCenter) to: prerequisiteFigure at: prerequisiteFigure bottomCenter)]]]. allFigures addAll: lines.
layout: figures accordingTo: classToFigureMap "Calculate a reasonable position at which to draw each figure." | grouped rightMost early | grouped := figures groupedBy: [:each | each model activationEvent]. early := grouped at: #earlySystemInstallation ifAbsent: [#()]. early do: [:each | each layoutIn: classToFigureMap withSpacing: 175 @ 50 startingFrom: 5 @ 5]. rightMost := early inject: 0 into: [:max :each | max max: each corner x]. (grouped at: #returnFromSnapshot ifAbsent: [#()]) do:[:each | each layoutIn: classToFigureMap withSpacing: 175 @ 50 startingFrom: (rightMost + 5) @ 5].
</methods> <methods> Tools.SubsystemOrderingEditor <category>updating</category>
updateDrawing self clearDrawing. mainClass isNil ifFalse: [self displayClass: mainClass].
</methods> <methods> Tools.SubsystemOrderingEditor <category>initialize-release</category>
initialize super initialize. showAll := false.
</methods> <methods> Tools.SubsystemOrderingEditor <category>interface opening</category>
postBuildWith: aBuilder super postBuildWith: aBuilder. (builder bindings at: #drawing) container scrollGrid x: 10; y: 10.
</methods> <methods> Tools.SubsystemOrderingEditor class <category>private-interface building</category>
markedAsSystemClass "This class not to be shown when browsing user classes."
</methods> <methods> Tools.SubsystemOrderingSelectionPolicy <category>accessing-classes</category>
codeToolClassForClass: aBehavior ^(aBehavior inheritsFrom: Subsystem) ifTrue: [Tools.SubsystemOrderCodeTool] ifFalse: [nil].
</methods> <methods> Tools.SubsystemOrderingSelectionPolicy <category>accessing</category>
name ^(#SubsystemStartupOrdering << #browser >> 'Startup Order') asString
</methods> <methods> Tools.SubsystemOrderingSelectionPolicy class <category>class initialization</category>
initialize (Refactory.Browser.CodeModel dependents includes: self) ifFalse: [Refactory.Browser.CodeModel addDependent: self]. self addSelectionPolicy.
obsolete Refactory.Browser.CodeModel removeDependent: self. self removeSelectionPolicy. ^super obsolete.
</methods> <methods> Tools.SubsystemOrderCodeTool <category>accessing</category>
subsystemEditor ^subsystemEditor isNil ifTrue: [subsystemEditor := SubsystemOrderingEditor new] ifFalse: [subsystemEditor]
subsystemEditor: aSubsystemOrderingEditor subsystemEditor := aSubsystemOrderingEditor
</methods> <methods> Tools.SubsystemOrderCodeTool <category>updating</category>
updateContents super updateContents. self updateDrawing
updateDisplay super updateDisplay. self updateDrawing
updateDrawing [self nonMetaClass notNil ifTrue: [^self subsystemEditor displayClass: self nonMetaClass] ifFalse: [self subsystemEditor clearDrawing]] on: MessageNotUnderstood do: [:ex | ex return].
</methods> <methods> Tools.SubsystemOrderCodeTool <category>tab APIs</category>
isActive "The purpose of isActive is to determine if the receiver should currently be shown in the code model's list of tools displayed in the tabs. Look at the logic found in the obsolete SelectionPolicy's codeToolClassFor* methods and implement a similiar algorithm here, returning true/false where it would have returned a class/nil." | selection | selection := codeModel state mostSpecificObject. ^(selection isKindOf: Behavior) and: [selection inheritsFrom: Subsystem]
tabName ^(#SubsystemStartupOrdering << #browser >> 'Startup Order') asString
</methods> <methods> Tools.SubsystemOrderCodeTool class <category>private-interface building</category>
markedAsSystemClass "This class not to be shown when browsing user classes."
</methods> <methods> Refactory.HotDraw.Tool class <category>tool states</category>
subsystemStartupOrderToolStates "This method was automatically generated by the HotDraw ToolStateMachineEditor. To edit this method, evaluate the comment below" "| states transitions stateTable | states := ((Core.OrderedCollection new) add: (Refactory.HotDraw.ToolStateModel basicNew instVarAt: 1 put: nil; instVarAt: 2 put: 'System Startup Ordering Tool'; instVarAt: 3 put: '[:tool :event | ]'; instVarAt: 4 put: (Core.Point x: 154 y: 34); instVarAt: 5 put: false; instVarAt: 6 put: false; yourself); add: (Refactory.HotDraw.ToolStateModel basicNew instVarAt: 1 put: nil; instVarAt: 2 put: 'Menu'; instVarAt: 3 put: '[:tool :event | ]'; instVarAt: 4 put: (Core.Point x: 327 y: 127); instVarAt: 5 put: false; instVarAt: 6 put: true; yourself); add: (Refactory.HotDraw.ToolStateModel basicNew instVarAt: 1 put: nil; instVarAt: 2 put: 'Compare Editions'; instVarAt: 3 put: '[:tool :event | | startFigure endFigure origin | origin := tool valueAt: #startPoint. tool drawing invalidateRectangle: (Rectangle vertex: origin vertex: (tool valueAt: #lastPoint)) repairNow: true. startFigure := tool valueAt: #figure. endFigure := tool figureAtEvent: event. startFigure ~~ endFigure ifTrue: [startFigure compareVersionTo: endFigure model]]'; instVarAt: 4 put: (Core.Point x: 392 y: 479); instVarAt: 5 put: true; instVarAt: 6 put: false; yourself); add: (Refactory.HotDraw.ToolStateModel basicNew instVarAt: 1 put: nil; instVarAt: 2 put: 'Browse'; instVarAt: 3 put: '[:tool :event | (tool figureAtEvent: event) model browse]'; instVarAt: 4 put: (Core.Point x: 41 y: 311); instVarAt: 5 put: true; instVarAt: 6 put: false; yourself); yourself). stateTable := Dictionary new. states do: [:each | stateTable at: each name put: each]. transitions := OrderedCollection new. transitions add: (ToolStateTransitionModel new from: (stateTable at: 'System Startup Ordering Tool'); to: (stateTable at: 'Menu'); type: (Refactory.HotDraw.TransitionType basicNew instVarAt: 1 put: #yellowButtonPress; yourself); points: ((Core.OrderedCollection new) add: (Core.Point x: 284.922 y: 86.8465); add: (Core.Point x: 327 y: 115); add: (Core.Point x: 369.818 y: 141.254); yourself); yourself). transitions add: (ToolStateTransitionModel new from: (stateTable at: 'System Startup Ordering Tool'); to: (stateTable at: 'Browse'); type: (Refactory.HotDraw.FigureTransitionType basicNew instVarAt: 1 put: #doubleClick; instVarAt: 2 put: ((Core.Array new: 1) at: 1 put: Tools.SubsystemFigure; yourself); yourself); points: ((Core.OrderedCollection new) add: (Core.Point x: 222.159 y: 87.8792); add: (Core.Point x: 64.5494 y: 310.117); yourself); yourself). ToolStateMachineEditor openWithStates: states connections: transitions" Tool states at: 'System Startup Ordering Tool' put: (ToolState name: 'System Startup Ordering Tool' command: [:tool :event | ]). Tool states at: 'Compare Editions' put: (EndToolState name: 'Compare Editions' command: [:tool :event | | startFigure endFigure origin | origin := tool valueAt: #startPoint. tool drawing invalidateRectangle: (Rectangle vertex: origin vertex: (tool valueAt: #lastPoint)) repairNow: true. startFigure := tool valueAt: #figure. endFigure := tool figureAtEvent: event. startFigure ~~ endFigure ifTrue: [startFigure compareVersionTo: endFigure model]]). Tool states at: 'Browse' put: (EndToolState name: 'Browse' command: [:tool :event | (tool figureAtEvent: event) model browse]). (Tool stateFor: 'System Startup Ordering Tool') yellowButtonPress: ((SimpleTransitionTable new) goto: (Tool stateFor: 'Menu'); yourself). (Tool stateFor: 'System Startup Ordering Tool') doubleClick: ((FigureTransitionTable new) on: SubsystemFigure goto: (Tool stateFor: 'Browse'); yourself).
</methods> <methods> Tools.SubsystemOrderingEditor class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: #(#{Kernel.UserMessage} #key: #DrawingEditor #defaultString: 'Drawing Editor' #catalogID: #browser) #bounds: #(#{Graphics.Rectangle} 800 600 1355 1080 ) #isEventDriven: true ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.ArbitraryComponentSpec} #layout: #(#{Graphics.LayoutFrame} 0 0 0 0 0 1 0 1 ) #flags: 11 #component: #drawing ) ) ) )
</methods> <methods> Tools.SubsystemOrderCodeTool class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: #(#{Kernel.UserMessage} #key: #DrawingEditor #defaultString: 'Drawing Editor' #catalogID: #browser) #bounds: #(#{Graphics.Rectangle} 800 600 1355 1080 ) #colors: #(#{UI.LookPreferences} ) #isEventDriven: true ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.SubCanvasSpec} #layout: #(#{Graphics.LayoutFrame} 0 0 0 0 0 1 0 1 ) #name: #versionEditor #flags: 0 #majorKey: #{Tools.SubsystemOrderingEditor} #minorKey: #windowSpec #clientKey: #subsystemEditor ) ) ) )
</methods> <methods> Refactory.Browser.CodeModel class <category>tool registration</category>
subsystemOrderCodeToolClass <tool> ^SubsystemOrderCodeTool
</methods> <initialize> Tools.SubsystemOrderingSelectionPolicy </initialize> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>DrawingEditor</name> <environment>Refactory.HotDraw</environment> <super>UI.ApplicationModel</super> <private>false</private> none buttons drawing <imports></imports> <category>HotDraw-Framework</category> <attributes> <package>HotDraw Framework</package> </attributes> </class> <class> <name>CodeTool</name> <environment>Refactory.Browser</environment> <super>Refactory.Browser.BrowserApplicationModel</super> <private>false</private> none codeModel menu <imports></imports> <category>Browser-Code Tools</category> <attributes> <package>Browser-BrowserUI</package> </attributes> </class> <class> <name>DrawingController</name> <environment>Refactory.HotDraw</environment> <super>UI.Controller</super> <private>false</private> none tool keyboardProcessor <imports></imports> <category>HotDraw-Framework</category> <attributes> <package>HotDraw Framework</package> </attributes> </class> <class> <name>RectangleFigure</name> <environment>Refactory.HotDraw</environment> <super>Refactory.HotDraw.Figure</super> <private>false</private> none <imports></imports> <category>HotDraw-Figures</category> <attributes> <package>HotDraw Framework</package> </attributes> </class> <class> <name>CodeToolSelectionPolicy</name> <environment>Refactory.Browser</environment> <super>Core.Object</super> <private>false</private> none codeModel <imports></imports> <category>Browser-Code Tool Selection Policies</category> <attributes> <package>Browser-BrowserUI</package> </attributes> </class> <class> <name>Drawing</name> <environment>Refactory.HotDraw</environment> <super>Refactory.HotDraw.CompositeFigure</super> <private>false</private> none selections handles controller <imports></imports> <category>HotDraw-Framework</category> <attributes> <package>HotDraw Framework</package> </attributes> </class>