From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:47:31 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>List2Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none selectionInList <imports></imports> <category>Examples-Help</category> <attributes> <package>List2-Example</package> </attributes> </class> <comment> Examples.List2Example
This example integrates two action buttons with a list widget. This example is reused by Subcanvas3Example. In addition, it serves as a parent class for Subcanvas2Example, to demonstrate inheritance of an interface as well as value holders and actions. Instance Variables: selectionInlist <SelectionInList> The value holder for the list widget. The list is initialized to a list of color names, but reusers can install a different list by sending #list: to an instance of this class.
</comment> <methods> Examples.List2Example <category>actions</category>
add "Add an entry to the list." | entry newList | "Prompt for the name to add." entry := Dialog request: 'Add'. "If the entry is blank, exit." entry isEmpty ifTrue: [^nil]. "Update the list." newList := SortedCollection withAll: self selectionInList list. newList add: entry. self selectionInList list: newList.
delete "Delete the selected entry from the list." | deletedElement newList | deletedElement := self selectionInList selection. "If nothing is selected, warn the user and exit." deletedElement isNil ifTrue: [^Dialog warn: 'Please select the entry to be deleted.']. "Update the list." newList := SortedCollection withAll: self selectionInList list. newList remove: deletedElement. self selectionInList list: newList.
</methods> <methods> Examples.List2Example <category>initialize-release</category>
initialize selectionInList := SelectionInList with: ColorValue constantNames.
</methods> <methods> Examples.List2Example <category>aspects</category>
list: aCollection "Install aCollection in the list. This message is provided so reusers can install a list that is different than the default list (color names)." self selectionInList list: aCollection.
selectionInList ^selectionInList
</methods> <methods> Examples.List2Example class <category>interface specs</category>
listSpec "UIPainter new openOnClass: self andSelector: #listSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'List2Example' #min: #(#Point 50 50 ) #bounds: #(#Rectangle 210 307 391 594 ) ) #component: #(#SpecCollection #collection: #( #(#SequenceViewSpec #layout: #(#LayoutFrame 1 0 1 0 -1 1 -40 1 ) #model: #selectionInList ) #(#ActionButtonSpec #layout: #(#LayoutFrame 10 0.5 -35 1 70 0.5 -10 1 ) #name: #deleteButton #model: #delete #label: 'Delete' #defaultable: true ) #(#ActionButtonSpec #layout: #(#LayoutFrame -70 0.5 -35 1 -10 0.5 -10 1 ) #name: #addButton #model: #add #label: 'Add' #defaultable: true ) ) ) )
</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>