From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:49:27 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>RefreshSelectListExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none removeSelect undoList targetList redoList <imports></imports> <category>Examples-List + Selection Updates</category> <attributes> <package>RefreshSelectionList-Examples</package> </attributes> </class> <comment> Examples.RefreshSelectListExample
The RefreshSelectListExample application demonstrates how the contents of a single-select list widget may be refreshed without moving the selection visually during the transition as much as possible. Its application interface includes a user editable supply list that determines the new content of a target list. Items from the supply list may be selected for removal by the user and these changes may be later removed or restored to compare its affect on the target list. The selection and its position visible in the targetList should remain unaltered unless the formerly selected item is missing in the new list. Instance Variables: redoList <OrderedCollection of: OrderedCollection> zero or more collections of items by index and value that might be removed later from the removeSelect list. removeSelect <MultiSelectionInList> list model of class names used to set the targetList list. targetList <SelectionInList> list model whose list but not selection and position is changed by removeSelect. undoList <OrderedCollection of: OrderedCollection> zero or more collections of items by index and value to be restored to the removeSelect list.
</comment> <class> <name>RefreshMultiSelectListExample</name> <environment>Examples</environment> <super>Examples.RefreshSelectListExample</super> <private>false</private> none <imports></imports> <category>Examples-List + Selection Updates</category> <attributes> <package>RefreshSelectionList-Examples</package> </attributes> </class> <comment> Examples.RefreshMultiSelectListExample
The RefreshMultiSelectListExample application demonstrates how the contents of a multiple selection list widget may be refreshed without moving selections visually during the transition as much as possible. Its application interface includes a user editable supply list that determines the new content of a target list. Items from the supply list may be selected for removal by the user and these changes may be later removed or restored to compare its affect on the target list. The selections and their position visible in the targetList should remain unaltered unless any formerly selected item is missing in the new list. Instance Variables: redoList <OrderedCollection of: OrderedCollection> zero or more collections of items by index and value that might be removed later from the removeSelect list. removeSelect <MultiSelectionInList> list model of class names used to set the targetList list. targetList <MultiSelectionInList> list model whose list but not selections and position is changed by removeSelect. undoList <OrderedCollection of: OrderedCollection> zero or more collections of items by index and value to be restored to the removeSelect list.
</comment> <methods> Examples.RefreshSelectListExample <category>testing</category>
hasRedo ^redoList notEmpty
hasSelections ^self removeSelect selectionIndexes notEmpty
hasUndo ^undoList notEmpty
</methods> <methods> Examples.RefreshSelectListExample <category>actions</category>
redoSelectionsRemove | list | list := self removeSelect list. (undoList add: redoList removeLast) do: [:assoc | list remove: assoc value]. self targetList refreshList: list copy
removeSelections | list | list := self removeSelect list. undoList add:(self removeSelect selectionIndexes asSortedCollection asArray collect:[:index| index -> (list at: index)]). redoList := OrderedCollection new. list removeAll: self removeSelect selections. self targetList refreshList: list copy
undoSelectionsRemove | list | list := self removeSelect list. (redoList add: undoList removeLast) do: [:assoc | list add: assoc value beforeIndex: assoc key. self removeSelect selectionIndexes add: assoc key]. self targetList refreshList: list copy
</methods> <methods> Examples.RefreshSelectListExample <category>initialize-release</category>
initialize super initialize. undoList := OrderedCollection new. redoList := OrderedCollection new. removeSelect := MultiSelectionInList with: (Object allSubclasses asSortedCollection:[:a :b| a name < b name]) asList.
</methods> <methods> Examples.RefreshSelectListExample <category>aspects</category>
removeSelect ^removeSelect
targetList ^targetList isNil ifTrue: [targetList := SelectionInList with: self removeSelect list copy] ifFalse: [targetList]
</methods> <methods> Examples.RefreshMultiSelectListExample <category>aspects</category>
targetList ^targetList isNil ifTrue: [targetList := MultiSelectionInList with: self removeSelect list copy] ifFalse: [targetList]
</methods> <methods> Examples.RefreshSelectListExample class <category>resources</category>
classMenu "Tools.MenuEditor new openOnClass: self andSelector: #classMenu" <resource: #menu> ^#(#{UI.Menu} #( #(#{UI.MenuItem} #rawLabel: 'remove' #enabled: false #value: #removeSelections #enablementSelector: #hasSelections ) #(#{UI.MenuItem} #rawLabel: 'undo remove' #enabled: false #value: #undoSelectionsRemove #enablementSelector: #hasUndo ) #(#{UI.MenuItem} #rawLabel: 'redo remove' #enabled: false #value: #redoSelectionsRemove #enablementSelector: #hasRedo ) ) #(3 ) nil ) decodeAsLiteralArray
</methods> <methods> Examples.RefreshSelectListExample class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'Single Select List Refresh' #min: #(#{Core.Point} 322 491 ) #max: #(#{Core.Point} 1600 1200 ) #bounds: #(#{Graphics.Rectangle} 800 600 1235 1093 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 10 1 ) #name: #Label1 #label: 'Any items removed here' ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutOrigin} 5 0.5 1 0 ) #name: #Label2 #label: 'Must not change my select position' ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.LayoutFrame} 10 0 25 0 -5 0.5 -10 1 ) #name: #List2 #model: #removeSelect #menu: #classMenu #multipleSelections: true #useModifierKeys: true #selectionType: #highlight ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.LayoutFrame} 5 0.5 25 0 -5 1 -10 1 ) #name: #List3 #model: #targetList #useModifierKeys: true #selectionType: #highlight ) ) ) )
</methods> <methods> Examples.RefreshMultiSelectListExample class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'Multi Select List Refresh' #min: #(#{Core.Point} 322 491 ) #max: #(#{Core.Point} 1600 1200 ) #bounds: #(#{Graphics.Rectangle} 800 600 1235 1093 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 10 1 ) #name: #Label1 #label: 'Any items removed here' ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutOrigin} 5 0.5 1 0 ) #name: #Label2 #label: 'Must not change my select position' ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.LayoutFrame} 10 0 25 0 -5 0.5 -10 1 ) #name: #List2 #model: #removeSelect #menu: #classMenu #multipleSelections: true #useModifierKeys: true #selectionType: #highlight ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.LayoutFrame} 5 0.5 25 0 -5 1 -10 1 ) #name: #List3 #model: #targetList #multipleSelections: true #useModifierKeys: true #selectionType: #highlight ) ) ) )
</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>