From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:48:28 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>Subcanvas3Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none classNames displayAspect listApplication <imports></imports> <category>Examples-Help</category> <attributes> <package>Subcanvas3-Example</package> </attributes> </class> <comment> Examples.Subcanvas3Example
Subcanvas3Example demonstrates substituting different interfaces in a subcanvas while the application is running.
</comment> <methods> Examples.Subcanvas3Example <category>change messages</category>
changedAspect | aspectOfClass | aspectOfClass := self displayAspect value. "If no class is selected, blank the subcanvas." self classNames selection isNil ifTrue: [self showNothing] "A class is selected -- display its hierarchy, comment or methods." ifFalse: [ aspectOfClass == #hierarchy ifTrue: [self showHierarchy]. aspectOfClass == #comment ifTrue: [self showComment]. aspectOfClass == #methods ifTrue: [self showMethods]].
showComment | selectedClass subcanvas spec application | selectedClass := Smalltalk at: self classNames selection. "Create the subapplication and initialize it." application := Editor2Example new. application text value: selectedClass comment. "Get the spec object for the embedded canvas." spec := Editor2Example interfaceSpecFor: #windowSpec. "Get the subcanvas and install the editing application." subcanvas := (self builder componentAt: #subcanvas) widget. subcanvas client: application spec: spec.
showHierarchy | selectedClass subcanvas spec application | selectedClass := Smalltalk at: self classNames selection. "Create the subapplication and initialize it." application := Editor2Example new. application text value: selectedClass printHierarchy. "Get the spec object for the embedded canvas." spec := Editor2Example interfaceSpecFor: #windowSpec. "Get the subcanvas and install the editing application." subcanvas := (self builder componentAt: #subcanvas) widget. subcanvas client: application spec: spec.
showMethods | selectedClass subcanvas spec | selectedClass := Smalltalk at: self classNames selection. spec := List2Example interfaceSpecFor: #listSpec. "Install the method names as the collection in the list application." self listApplication list: selectedClass selectors asSortedCollection. "Set the subbuilder to nil to discard the old builder. This is only necessary when the application uses the builder later to access widgets." listApplication builder: nil. "Get the subcanvas and install the list application." subcanvas := (self builder componentAt: #subcanvas) widget. subcanvas client: listApplication spec: spec. "Disable the embedded buttons (just to show that we can)." (listApplication builder componentAt: #addButton) disable. (listApplication builder componentAt: #deleteButton) disable.
showNothing | subcanvas | subcanvas := (self builder componentAt: #subcanvas) widget. subcanvas client: nil.
</methods> <methods> Examples.Subcanvas3Example <category>aspects</category>
classNames ^classNames
displayAspect ^displayAspect
embeddedApplication ^nil asValue
listApplication ^listApplication
</methods> <methods> Examples.Subcanvas3Example <category>initialize-release</category>
initialize classNames := SelectionInList with: Core classNames. classNames selectionIndexHolder onChangeSend: #changedAspect to: self. displayAspect := #hierarchy asValue. displayAspect onChangeSend: #changedAspect to: self. listApplication := List2Example new.
</methods> <methods> Examples.Subcanvas3Example class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'Subcanvas3Example' #min: #(#Point 50 50 ) #bounds: #(#Rectangle 752 275 1220 591 ) ) #component: #(#SpecCollection #collection: #( #(#SubCanvasSpec #layout: #(#LayoutFrame 1 0.333333 30 0 -1 1 -1 1 ) #name: #subcanvas #flags: 0 #clientKey: #embeddedApplication ) #(#SequenceViewSpec #layout: #(#LayoutFrame 1 0 30 0 0 0.333333 -1 1 ) #model: #classNames ) #(#LabelSpec #layout: #(#AlignmentOrigin 0 0.166667 5 0 0.5 0 ) #label: 'Classes' ) #(#RadioButtonSpec #layout: #(#LayoutOrigin 95 0.333333 8 0 ) #model: #displayAspect #label: 'Class comment' #style: #small #select: #comment ) #(#RadioButtonSpec #layout: #(#LayoutOrigin 223 0.333333 8 0 ) #model: #displayAspect #label: 'Methods' #style: #small #select: #methods ) #(#RadioButtonSpec #layout: #(#LayoutOrigin 4 0.333333 8 0 ) #model: #displayAspect #label: 'Hierarchy' #style: #small #select: #hierarchy ) ) ) )
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class>