initial checkin
authorClaus Gittinger <cg@exept.de>
Thu, 14 Sep 2000 14:31:11 +0200
changeset 1837 67fd7ad3d699
parent 1836 89a1b938c09e
child 1838 833893f82202
initial checkin
MultipleItemSelectionWidget.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MultipleItemSelectionWidget.st	Thu Sep 14 14:31:11 2000 +0200
@@ -0,0 +1,409 @@
+"{ Package: 'stx:libwidg2' }"
+
+ApplicationModel subclass:#MultipleItemSelectionWidget
+	instanceVariableNames:'possibleItemsLabelHolder possibleItemListSelection
+		listOfPossibleItems selectedItemListSelection
+		removeButtonLabelHolder addButtonLabelHolder
+		canAddItemToSelection selectedItemsLabelHolder
+		listOfSelectedItems canRemoveItemFromSelection'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Views-Lists'
+!
+
+!MultipleItemSelectionWidget class methodsFor:'documentation'!
+
+documentation
+"
+    Replacement for a multiSelectionInList widget;
+    allows construction of a list by adding/removing items.
+
+    For use in a UI-spec, add a subCanvas, and bind the exported aspects to
+    your applications aspects.
+
+    [author:]
+         (cg@smc1)
+
+    [see also:]
+
+    [instance variables:]
+
+    [class variables:]
+"
+!
+
+examples
+"
+                                                                [exBegin]
+        |box|
+
+        box := MultipleItemSelectionWidget new.
+        box listOfPossibleItems value:#('one' 'two' 'three' 'four' 'five').  
+        box listOfSelectedItems value:#().  
+        box open.
+        box listOfSelectedItems inspect
+                                                                [exEnd]
+
+
+                                                                [exBegin]
+        |box|
+
+        box := MultipleItemSelectionWidget new.
+        box listOfPossibleItems value:#('one' 'two' 'three' 'four' 'five') asSortedCollection.  
+        box listOfSelectedItems value:#() asSortedCollection.  
+        box open.
+        box listOfSelectedItems inspect
+                                                                [exEnd]
+"
+! !
+
+!MultipleItemSelectionWidget class methodsFor:'interface specs'!
+
+windowSpec
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "
+     UIPainter new openOnClass:MultipleItemSelectionWidget andSelector:#windowSpec
+     MultipleItemSelectionWidget new openInterface:#windowSpec
+     MultipleItemSelectionWidget open
+    "
+
+    <resource: #canvas>
+
+    ^ 
+     #(#FullSpec
+        #name: #windowSpec
+        #window: 
+       #(#WindowSpec
+          #label: 'NewApplication'
+          #name: 'NewApplication'
+          #min: #(#Point 10 10)
+          #max: #(#Point 1280 1024)
+          #bounds: #(#Rectangle 12 22 312 322)
+        )
+        #component: 
+       #(#SpecCollection
+          #collection: #(
+           #(#LabelSpec
+              #label: 'Possible Items'
+              #name: 'Label1'
+              #layout: #(#LayoutFrame 0 0 0 0 0 0.5 30 0)
+              #translateLabel: true
+              #labelChannel: #possibleItemsLabelHolder
+            )
+           #(#SequenceViewSpec
+              #name: 'List1'
+              #layout: #(#LayoutFrame 0 0 30 0 0 0.5 -30 1)
+              #tabable: true
+              #model: #possibleItemListSelection
+              #hasHorizontalScrollBar: true
+              #hasVerticalScrollBar: true
+              #miniScrollerHorizontal: true
+              #miniScrollerVertical: true
+              #isMultiSelect: true
+              #doubleClickSelector: #addItemsToSelection
+              #valueChangeSelector: #showInfoForItem:
+              #useIndex: false
+              #sequenceList: #listOfPossibleItems
+            )
+           #(#LabelSpec
+              #label: 'Selected Items'
+              #name: 'Label2'
+              #layout: #(#LayoutFrame 0 0.5 0 0 0 1 30 0)
+              #translateLabel: true
+              #labelChannel: #selectedItemsLabelHolder
+            )
+           #(#SequenceViewSpec
+              #name: 'List2'
+              #layout: #(#LayoutFrame 0 0.5 30 0 0 1 -30 1)
+              #tabable: true
+              #model: #selectedItemListSelection
+              #hasHorizontalScrollBar: true
+              #hasVerticalScrollBar: true
+              #miniScrollerHorizontal: true
+              #miniScrollerVertical: true
+              #isMultiSelect: true
+              #doubleClickSelector: #removeItemsFromSelection
+              #valueChangeSelector: #showInfoForItem:
+              #useIndex: false
+              #sequenceList: #listOfSelectedItems
+            )
+           #(#HorizontalPanelViewSpec
+              #name: 'HorizontalPanel2'
+              #layout: #(#LayoutFrame 0 0 -30 1 0 1 0 1)
+              #horizontalLayout: #fitSpace
+              #verticalLayout: #center
+              #horizontalSpace: 3
+              #verticalSpace: 3
+              #component: 
+             #(#SpecCollection
+                #collection: #(
+                 #(#ActionButtonSpec
+                    #label: 'Add >>'
+                    #name: 'addButton'
+                    #translateLabel: true
+                    #labelChannel: #addButtonLabelHolder
+                    #resizeForLabel: false
+                    #tabable: true
+                    #model: #addItemsToSelection
+                    #enableChannel: #canAddItemToSelection
+                    #actionValue: ''
+                    #useDefaultExtent: true
+                  )
+                 #(#ActionButtonSpec
+                    #label: '<< Remove'
+                    #name: 'removeButton'
+                    #translateLabel: true
+                    #labelChannel: #removeButtonLabelHolder
+                    #resizeForLabel: false
+                    #tabable: true
+                    #model: #removeItemsFromSelection
+                    #enableChannel: #canRemoveItemFromSelection
+                    #actionValue: ''
+                    #useDefaultExtent: true
+                  )
+                 )
+               
+              )
+            )
+           )
+         
+        )
+      )
+! !
+
+!MultipleItemSelectionWidget class methodsFor:'plugIn spec'!
+
+aspectSelectors
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this. If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "Return a description of exported aspects;
+     these can be connected to aspects of an embedding application
+     (if this app is embedded in a subCanvas)."
+
+    ^ #(
+        #listOfPossibleItems
+        #listOfSelectedItems
+
+        #addButtonLabelHolder
+        #possibleItemsLabelHolder
+        #removeButtonLabelHolder
+        #selectedItemsLabelHolder
+
+      ).
+
+    "Modified: / 18.8.2000 / 18:49:08 / cg"
+
+! !
+
+!MultipleItemSelectionWidget methodsFor:'actions'!
+
+addItemsToSelection
+    "add selected items from left list to the right list"
+
+    |sel|
+
+    sel := self possibleItemListSelection value.
+    sel size > 0 ifTrue:[
+        self listOfSelectedItems value:(self listOfSelectedItems value copy addAll:sel; yourself).
+        self listOfPossibleItems value:(self listOfPossibleItems value copy removeAll:sel; yourself).
+
+        self possibleItemListSelection value:#()
+    ]
+
+
+!
+
+removeItemsFromSelection
+    "remove selected items from right list to the left list"
+
+    |sel|
+
+    sel := self selectedItemListSelection value.
+    sel size > 0 ifTrue:[
+        self listOfPossibleItems value:(self listOfPossibleItems value copy addAll:sel; yourself).
+        self listOfSelectedItems value:(self listOfSelectedItems value copy removeAll:sel; yourself).
+
+        self selectedItemListSelection value:#()
+    ]
+!
+
+showInfoForItem:anArgument
+! !
+
+!MultipleItemSelectionWidget methodsFor:'aspects'!
+
+canAddItemToSelection
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    canAddItemToSelection isNil ifTrue:[
+       canAddItemToSelection := BlockValue with:[:m | m value size > 0]
+                                    argument:self possibleItemListSelection 
+    ].
+    ^ canAddItemToSelection.
+!
+
+canRemoveItemFromSelection
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    canRemoveItemFromSelection isNil ifTrue:[
+       canRemoveItemFromSelection := BlockValue with:[:m | m value size > 0]
+                                    argument:self selectedItemListSelection 
+    ].
+    ^ canRemoveItemFromSelection.
+!
+
+listOfPossibleItems
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    listOfPossibleItems isNil ifTrue:[
+       listOfPossibleItems := #() asValue.
+    ].
+    ^ listOfPossibleItems.
+!
+
+listOfPossibleItems:aValueHolder
+   listOfPossibleItems := aValueHolder.
+!
+
+listOfSelectedItems
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    listOfSelectedItems isNil ifTrue:[
+       listOfSelectedItems := #() asValue.
+    ].
+    ^ listOfSelectedItems.
+!
+
+listOfSelectedItems:aValueHolder
+   listOfSelectedItems := aValueHolder.
+!
+
+possibleItemListSelection
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    possibleItemListSelection isNil ifTrue:[
+       possibleItemListSelection := #() asValue.
+    ].
+    ^ possibleItemListSelection.
+!
+
+selectedItemListSelection
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    selectedItemListSelection isNil ifTrue:[
+       selectedItemListSelection := #() asValue.
+    ].
+    ^ selectedItemListSelection.
+! !
+
+!MultipleItemSelectionWidget methodsFor:'aspects - look'!
+
+addButtonLabelHolder
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    addButtonLabelHolder isNil ifTrue:[
+       addButtonLabelHolder :=  ValueHolder new.
+    ].
+    ^ addButtonLabelHolder.
+!
+
+addButtonLabelHolder:aValueHolder
+    addButtonLabelHolder := aValueHolder
+
+!
+
+possibleItemsLabelHolder
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    possibleItemsLabelHolder isNil ifTrue:[
+       possibleItemsLabelHolder :=  ValueHolder new.
+    ].
+    ^ possibleItemsLabelHolder.
+!
+
+possibleItemsLabelHolder:aValueHolder
+    possibleItemsLabelHolder := aValueHolder
+
+!
+
+removeButtonLabelHolder
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    removeButtonLabelHolder isNil ifTrue:[
+       removeButtonLabelHolder :=  ValueHolder new.
+    ].
+    ^ removeButtonLabelHolder.
+!
+
+removeButtonLabelHolder:aValueHolder
+    removeButtonLabelHolder := aValueHolder
+
+!
+
+selectedItemsLabelHolder
+    "automatically generated by UIPainter ..."
+
+    "*** the code below creates a default model when invoked."
+    "*** (which may not be the one you wanted)"
+    "*** Please change as required and accept it in the browser."
+
+    selectedItemsLabelHolder isNil ifTrue:[
+       selectedItemsLabelHolder :=  ValueHolder new.
+    ].
+    ^ selectedItemsLabelHolder.
+!
+
+selectedItemsLabelHolder:aValueHolder
+    selectedItemsLabelHolder := aValueHolder
+! !
+
+!MultipleItemSelectionWidget class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libwidg2/MultipleItemSelectionWidget.st,v 1.1 2000-09-14 12:31:11 cg Exp $'
+! !