[squeak-dev] The Trunk: ToolBuilder-Morphic-mt.129.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Apr 14 15:12:51 UTC 2015


Marcel Taeumel uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-mt.129.mcz

==================== Summary ====================

Name: ToolBuilder-Morphic-mt.129
Author: mt
Time: 14 April 2015, 5:12:45.809 pm
UUID: b45b099e-a5a7-1247-87fb-4be9a197efbf
Ancestors: ToolBuilder-Morphic-mt.128

Added possibility to choose multiple items from a list of items in Morphic.

=============== Diff against ToolBuilder-Morphic-mt.128 ===============

Item was added:
+ Model subclass: #ListMultipleChooser
+ 	instanceVariableNames: 'selection labels values title choice'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'ToolBuilder-Morphic'!
+ 
+ !ListMultipleChooser commentStamp: 'mt 4/14/2015 17:09' prior: 0!
+ I am like the ListChooser but for multiple choices. I have no extra search field. Enable the preference #filterableLists if lists get too big to choose from. Also, I do not support adding new items to the choice.!

Item was added:
+ ----- Method: ListMultipleChooser class>>chooseFrom:title: (in category 'ui requests') -----
+ chooseFrom: someLabels title: aString
+ 
+ 	^ self chooseIndexFrom: someLabels title: aString!

Item was added:
+ ----- Method: ListMultipleChooser class>>chooseIndexListFrom:title: (in category 'ui requests') -----
+ chooseIndexListFrom: someObjects title: aString
+ 
+ 	^ self new
+ 		title: aString;
+ 		labels: (someObjects collect: [:ea | ea asString]);
+ 		choose!

Item was added:
+ ----- Method: ListMultipleChooser class>>chooseItemListFrom:title: (in category 'ui requests') -----
+ chooseItemListFrom: someObjects title: aString
+ 
+ 	^ self new
+ 		title: aString;
+ 		labels: (someObjects collect: [:ea | ea asString]);
+ 		values: someObjects;
+ 		choose!

Item was added:
+ ----- Method: ListMultipleChooser>>accept (in category 'actions') -----
+ accept
+ 
+ 	choice := #accepted.
+ 	self changed: #close.!

Item was added:
+ ----- Method: ListMultipleChooser>>buildWith: (in category 'toolbuilder') -----
+ buildWith: builder
+ 
+ 	| windowSpec choicesSpec acceptSpec cancelSpec buttonHeight |
+ 	windowSpec := builder pluggableWindowSpec new
+ 		model: self;
+ 		extent: 250 at 400;
+ 		label: #title;
+ 		children: OrderedCollection new.
+ 	
+ 	buttonHeight := Preferences standardButtonFont height * 4.
+ 	
+ 	choicesSpec := builder pluggableMultiSelectionListSpec new
+ 		model: self;
+ 		list: #labels;
+ 		setIndex: #selectedIndex:;
+ 		getIndex: #selectedIndex;
+ 		setSelectionList: #selectionAt:put:;
+ 		getSelectionList: #selectionAt:;
+ 		frame: (LayoutFrame fractions: (0 at 0 corner: 1 at 1) offsets: (0 at 0 corner: 0@ buttonHeight negated)).
+ 	windowSpec children add: choicesSpec.
+ 	
+ 	acceptSpec := builder pluggableButtonSpec new
+ 		model: self;
+ 		label: 'accept';
+ 		color: ColorTheme current okColor;
+ 		action: #accept;
+ 		frame: (LayoutFrame fractions: (0 at 1 corner: 0.5 at 1) offsets: (0@ buttonHeight negated corner: 0 at 0)).
+ 	windowSpec children add: acceptSpec.
+ 
+ 	cancelSpec := builder pluggableButtonSpec new
+ 		model: self;
+ 		label: 'cancel';
+ 		color: ColorTheme current cancelColor;
+ 		action: #cancel;
+ 		frame: (LayoutFrame fractions: (0.5 at 1 corner: 1 at 1) offsets: (0@ buttonHeight negated corner: 0 at 0)).
+ 	windowSpec children add: cancelSpec.
+ 	
+ 	^ builder build: windowSpec!

Item was added:
+ ----- Method: ListMultipleChooser>>cancel (in category 'actions') -----
+ cancel
+ 
+ 	choice := #cancelled.
+ 	self changed: #close.!

Item was added:
+ ----- Method: ListMultipleChooser>>choose (in category 'actions') -----
+ choose
+ 
+ 	| builder window |
+ 	builder := ToolBuilder default.
+ 	window := builder open: self..
+ 	window center: Sensor cursorPoint. "Avoid morphic dependency here..."
+ 	builder runModal: window.
+ 	
+ 	^ self selectedValues!

Item was added:
+ ----- Method: ListMultipleChooser>>labels (in category 'accessing') -----
+ labels
+ 
+ 	^ labels!

Item was added:
+ ----- Method: ListMultipleChooser>>labels: (in category 'accessing') -----
+ labels: someStrings
+ 
+ 	labels := someStrings.
+ 	self changed: #labels.!

Item was added:
+ ----- Method: ListMultipleChooser>>selectedIndex (in category 'accessing') -----
+ selectedIndex
+ 	"Sigh. Required from widget..."
+ 	^ 0!

Item was added:
+ ----- Method: ListMultipleChooser>>selectedIndex: (in category 'accessing') -----
+ selectedIndex: anIndex
+ 	"Sigh. Required from widget..."
+ 	self changed: #selectedIndex.!

Item was added:
+ ----- Method: ListMultipleChooser>>selectedValues (in category 'accessing') -----
+ selectedValues
+ 	
+ 	| i |
+ 	choice ~~ #accepted ifTrue: [^ nil].
+ 	
+ 	i := 0.
+ 	^ self values select: [:object | i := i + 1. self selection at: i]!

Item was added:
+ ----- Method: ListMultipleChooser>>selection (in category 'accessing') -----
+ selection
+ 
+ 	^ selection ifNil: [selection := Array new: self values size withAll: false]!

Item was added:
+ ----- Method: ListMultipleChooser>>selectionAt: (in category 'accessing') -----
+ selectionAt: index
+ 
+ 	^ self selection at: index!

Item was added:
+ ----- Method: ListMultipleChooser>>selectionAt:put: (in category 'accessing') -----
+ selectionAt: index put: boolean
+ 
+ 	self selection at: index put: boolean.
+ 	self changed: #selectedIndex!

Item was added:
+ ----- Method: ListMultipleChooser>>title (in category 'accessing') -----
+ title
+ 
+ 	^ (title isNil or: [title isEmpty])
+ 		ifFalse: [title]
+ 		ifTrue: ['Choose multiple:']!

Item was added:
+ ----- Method: ListMultipleChooser>>title: (in category 'accessing') -----
+ title: aString
+ 
+ 	title := aString.
+ 	self changed: #title.!

Item was added:
+ ----- Method: ListMultipleChooser>>values (in category 'accessing') -----
+ values
+ 
+ 	^ values ifNil: [values := (1 to: self labels size) asArray]!

Item was added:
+ ----- Method: ListMultipleChooser>>values: (in category 'accessing') -----
+ values: someObjects
+ 
+ 	values := someObjects.!

Item was added:
+ ----- Method: MorphicUIManager>>chooseMultipleFrom:lines:title: (in category 'ui requests') -----
+ chooseMultipleFrom: aList lines: linesArray title: aString
+ 	"Choose one or more items from the given list. Answer the indices of the selected items."
+ 	
+ 	^ ListMultipleChooser
+ 		chooseFrom: aList
+ 		title: aString!

Item was added:
+ ----- Method: MorphicUIManager>>chooseMultipleFrom:values:lines:title: (in category 'ui requests') -----
+ chooseMultipleFrom: labelList values: valueList lines: linesArray title: aString
+ 	"Choose one or more items from the given list. Answer the selected items."
+ 
+ 	^ (ListMultipleChooser
+ 		chooseFrom: labelList
+ 		title: aString) ifNotNil: [:indexList |
+ 			indexList collect: [:index | valueList at: index]]!



More information about the Squeak-dev mailing list