[squeak-dev] The Trunk: Tools-mt.617.mcz

Levente Uzonyi leves at elte.hu
Sun May 3 12:44:59 UTC 2015


This makes MorphicUIManagerTest >> #testShowAllBinParts fail, because the 
searchString ValueHolder holds nil instead of a string. I suspect that the 
reason for this is:

MorphicUIManagerTest class >> #prototypicalToolWindow
 	"Answer an example of myself seen in a tool window, for the benefit of parts-launching tools"

 	^ self methodBrowserSearchingFor: nil

Levente

On Sun, 3 May 2015, commits at source.squeak.org wrote:

> Marcel Taeumel uploaded a new version of Tools to project The Trunk:
> http://source.squeak.org/trunk/Tools-mt.617.mcz
>
> ==================== Summary ====================
>
> Name: Tools-mt.617
> Author: mt
> Time: 3 May 2015, 12:08:33.481 pm
> UUID: 550a7de0-db51-154d-873a-d2569c50c8a6
> Ancestors: Tools-mt.616
>
> "Message Names" tool refactored.
>
> =============== Diff against Tools-mt.616 ===============
>
> Item was changed:
>  MessageSet subclass: #MessageNames
> + 	instanceVariableNames: 'searchString selectorList selectorListIndex'
> - 	instanceVariableNames: 'searchString selectorList selectorListIndex searchPane'
>  	classVariableNames: ''
>  	poolDictionaries: ''
>  	category: 'Tools-Browser'!
>
> Item was changed:
>  ----- Method: MessageNames>>buildSearchPaneWith: (in category 'toolbuilder') -----
>  buildSearchPaneWith: builder
> +
> + 	| panelSpec textSpec buttonSpec |
> + 	panelSpec := builder pluggablePanelSpec new
> + 		layout: #horizontal;
> + 		children: OrderedCollection new;
> + 		yourself.
> +
> - 	| textSpec |
>  	textSpec := builder pluggableInputFieldSpec new.
>  	textSpec
> + 		model: searchString;
> + 		help: 'Type here, then hit Search.' translated;
> + 		getText: #contents;
> + 		setText: #contents:.
> + 	panelSpec children add: textSpec.
> +
> + 	buttonSpec := builder pluggableActionButtonSpec new.
> + 	buttonSpec
>  		model: self;
> + 		label: 'Search';
> + 		action: #doSearch;
> + 		horizontalResizing: #shrinkWrap.
> + 	panelSpec children add: buttonSpec.
> +
> + 	^ panelSpec!
> - 		name: #search;
> - 		getText: #searchString;
> - 		setText: #searchString:notifying:.
> - 	^textSpec!
>
> Item was changed:
>  ----- Method: MessageNames>>buildWith: (in category 'toolbuilder') -----
>  buildWith: builder
>  	"ToolBuilder open: MessageNames new"
> +
> + 	| windowSpec max searchHeight |
> - 	| windowSpec max buttonSpec result |
>  	max := self wantsOptionalButtons ifTrue:[0.42] ifFalse:[0.5].
> + 	searchHeight := Preferences standardDefaultTextFont height * 2.
> +
>  	windowSpec := self buildWindowWith: builder specs: {
> + 		(self topConstantHeightFrame: searchHeight fromLeft: 0 width: 0.5) -> [self buildSearchPaneWith: builder].
> + 		(self frameOffsetFromTop: searchHeight fromLeft: 0 width: 0.5 bottomFraction: max) -> [self buildSelectorListWith: builder].
> - 		(0.15 at 0 corner: 0.5 at 0.08) -> [self buildSearchPaneWith: builder].
> - 		(0 at 0.08 corner: 0.5 at max) -> [self buildSelectorListWith: builder].
>  		(0.5 at 0.0 corner: 1.0 at max) -> [self buildMessageListWith: builder].
>  		(0 at max corner: 1 at 1) -> [self buildCodePaneWith: builder].
>  	}.
>
> + 	^ builder build: windowSpec!
> - 	buttonSpec := builder pluggableActionButtonSpec new.
> - 	buttonSpec
> - 		model: self;
> - 		label: 'Search';
> - 		action: [self doSearchFrom: searchPane];
> - 		frame: (0.0 at 0 corner: 0.15 at 0.08).
> - 	windowSpec children add: buttonSpec.
> -
> - 	result := builder build: windowSpec.
> - 	searchPane := builder widgetAt: #search.
> - 	^result!
>
> Item was added:
> + ----- Method: MessageNames>>computeMessageList (in category 'search') -----
> + computeMessageList
> +
> + 	^ selectorListIndex = 0
> + 		ifTrue: [#()]
> + 		ifFalse: [self systemNavigation
> + 			allImplementorsOf: (selectorList at: selectorListIndex)]!
>
> Item was added:
> + ----- Method: MessageNames>>computeSelectorListFrom: (in category 'search') -----
> + computeSelectorListFrom: searchString
> + 	"Compute selector list from search string. The searchString is a list of expressions separated by ;. Each expression is matched individually. An expression can be a simple string (same as *expression*), a string with double quotes (exact match) or a match expression (see String >> #match:)."
> +
> + 	^ (Array streamContents: [ :stream |
> + 			(searchString findBetweenSubStrs: ';') do: [ :selPat |
> + 				(selPat first = $" and: [ selPat last = $" and: [ selPat size > 2 ] ])
> + 					ifTrue: [
> + 						Symbol
> + 							hasInterned: (selPat copyFrom: 2 to: selPat size - 1)
> + 							ifTrue: [ :sym | stream nextPut: sym ] ]
> + 					ifFalse: [
> + 						| raw n m |
> + 						n := selPat occurrencesOf: $*.
> + 						m := selPat occurrencesOf:  $#.
> + 						raw := ((n > 0 or: [ m > 0 ]) 	and: [ selPat size > (n + m) ])
> + 							ifTrue: [ Symbol selectorsMatching: selPat ]
> + 							ifFalse: [ Symbol selectorsContaining: selPat ].
> + 						stream nextPutAll: raw ] ] ])
> + 			sort: [ :x :y | x caseInsensitiveLessOrEqual: y ]!
>
> Item was removed:
> - ----- Method: MessageNames>>computeSelectorListFromSearchString (in category 'search') -----
> - computeSelectorListFromSearchString
> - 	"Compute selector list from search string. The searchString is a list of expressions separated by ;. Each expression is matched individually. An expression can be a simple string (same as *expression*), a string with double quotes (exact match) or a match expression (see String >> #match:)."
> -
> - 	searchString := searchString asString copyWithout: $ . "?dubious?"
> - 	^selectorList := Cursor wait showWhile: [
> - 		(Array streamContents: [ :stream |
> - 			(searchString findBetweenSubStrs: ';') do: [ :selPat |
> - 				(selPat first = $" and: [ selPat last = $" and: [ selPat size > 2 ] ])
> - 					ifTrue: [
> - 						Symbol
> - 							hasInterned: (selPat copyFrom: 2 to: selPat size - 1)
> - 							ifTrue: [ :sym | stream nextPut: sym ] ]
> - 					ifFalse: [
> - 						| raw n m |
> - 						n := selPat occurrencesOf: $*.
> - 						m := selPat occurrencesOf:  $#.
> - 						raw := ((n > 0 or: [ m > 0 ]) 	and: [ selPat size > (n + m) ])
> - 							ifTrue: [ Symbol selectorsMatching: selPat ]
> - 							ifFalse: [ Symbol selectorsContaining: selPat ].
> - 						stream nextPutAll: raw ] ] ])
> - 			sort: [ :x :y | x caseInsensitiveLessOrEqual: y ] ]!
>
> Item was removed:
> - ----- Method: MessageNames>>defaultBrowserTitle (in category 'initialization') -----
> - defaultBrowserTitle
> - 	^ 'Message Names'!
>
> Item was added:
> + ----- Method: MessageNames>>doSearch (in category 'search') -----
> + doSearch
> + 	"The user hit the Search button -- treat it as a synonym for the user having hit the Return or Enter (or cmd-s) in the type-in pane"
> +
> + 	searchString changed: #acceptChanges.!
>
> Item was added:
> + ----- Method: MessageNames>>doSearch: (in category 'search') -----
> + doSearch: aSearchString
> +
> + 	| normalizedSearchString |
> + 	normalizedSearchString := aSearchString asString copyWithout: Character space.
> +
> + 	Cursor wait showWhile: [
> + 		self selectorList: (self computeSelectorListFrom: normalizedSearchString)].
> +
> + 	^ true!
>
> Item was removed:
> - ----- Method: MessageNames>>doSearchFrom: (in category 'search') -----
> - doSearchFrom: aPane
> - 	"The user hit the Search button -- treat it as a synonym for the user having hit the Return or Enter (or cmd-s) in the type-in pane"
> -
> - 	aPane accept.
> - 	aPane selectAll!
>
> Item was added:
> + ----- Method: MessageNames>>frameOffsetFromTop:fromLeft:width:bottomFraction: (in category 'toolbuilder') -----
> + frameOffsetFromTop: height fromLeft: leftFraction width: rightFraction bottomFraction: bottomFraction
> + 	^LayoutFrame new
> + 		topFraction: 0 offset: height;
> + 		leftFraction: leftFraction offset: 0;
> + 		rightFraction: (leftFraction + rightFraction) offset: 0;
> + 		bottomFraction: bottomFraction offset: 0;
> + 		yourself.!
>
> Item was added:
> + ----- Method: MessageNames>>initialize (in category 'initialization') -----
> + initialize
> +
> + 	super initialize.
> +
> + 	searchString := ValueHolder new contents: ''.
> + 	searchString addDependent: self.
> +
> + 	selectorList := #().
> + 	selectorListIndex := 0.!
>
> Item was added:
> + ----- Method: MessageNames>>labelString (in category 'initialization') -----
> + labelString
> +
> + 	^ self searchString
> + 		ifEmpty: ['Message Names']
> + 		ifNotEmpty: [:s | 'Message names containing "', s asString asLowercase, '"']!
>
> Item was removed:
> - ----- Method: MessageNames>>messageList (in category 'selector list') -----
> - messageList
> - 	"Answer the receiver's message list, computing it if necessary. The way
> - 	to force a recomputation is to set the messageList to nil"
> - 	messageList
> - 		ifNil: [messageList := selectorListIndex = 0
> - 						ifTrue: [#()]
> - 						ifFalse: [self systemNavigation
> - 								allImplementorsOf: (selectorList at: selectorListIndex)].
> - 			self
> - 				messageListIndex: (messageList size > 0
> - 						ifTrue: [1]
> - 						ifFalse: [0])].
> - 	^ messageList!
>
> Item was added:
> + ----- Method: MessageNames>>messageList: (in category 'message list') -----
> + messageList: someObjects
> +
> + 	messageList := someObjects.
> + 	self changed: #messageList.
> +
> + 	self messageListIndex: (messageList size > 0
> + 			ifTrue: [1]
> + 			ifFalse: [0]).!
>
> Item was changed:
>  ----- Method: MessageNames>>searchString (in category 'search') -----
>  searchString
> - 	"Answer the current searchString, initializing it if need be"
>
> + 	^ searchString contents!
> - 	| pane |
> - 	searchString isEmptyOrNil ifTrue:
> - 		[searchString := 'type here, then hit Search'.
> - 		pane := self containingWindow findDeepSubmorphThat:
> - 			[:m | m knownName = 'Search'] ifAbsent: ["this happens during window creation" ^ searchString].
> - 			pane setText: searchString.
> - 			pane setTextMorphToSelectAllOnMouseEnter.
> - 			pane selectAll].
> - 	^ searchString!
>
> Item was changed:
>  ----- Method: MessageNames>>searchString: (in category 'search') -----
>  searchString: aString
> +
> + 	searchString contents: aString.!
> - 	"Set the current searchString"
> - 	self searchString: aString notifying: nil!
>
> Item was removed:
> - ----- Method: MessageNames>>searchString:notifying: (in category 'search') -----
> - searchString: aString notifying: aController
> - 	"Take what the user typed and find all selectors containing it"
> -
> - 	searchString := aString asString copyWithout: $ .
> - 	self containingWindow ifNotNil:[:w| w setLabel: 'Message names containing "', searchString asLowercase, '"'].
> - 	selectorList := nil.
> - 	self changed: #selectorList.
> - 	self changed: #messageList.
> - 	^ true!
>
> Item was changed:
> + ----- Method: MessageNames>>selectedMessageName (in category 'message list') -----
> - ----- Method: MessageNames>>selectedMessageName (in category 'selection') -----
>  selectedMessageName
>  	selectorList basicSize = 0 ifTrue: [^ nil]. "Deals with selectorList nil or empty"
>  	^selectorList at: (selectorListIndex max: 1) ifAbsent: [nil] "If no selection we can still find a selector"!
>
> Item was changed:
>  ----- Method: MessageNames>>selectorList (in category 'selector list') -----
>  selectorList
> - 	"Answer the selectorList"
>
> - 	selectorList ifNil:
> - 		[self computeSelectorListFromSearchString.
> - 		selectorListIndex :=  selectorList size > 0
> - 			ifTrue:	[1]
> - 			ifFalse: [0].
> - 		messageList := nil].
>  	^ selectorList!
>
> Item was added:
> + ----- Method: MessageNames>>selectorList: (in category 'selector list') -----
> + selectorList: someObjects
> + 	"Answer the selectorList"
> +
> + 	selectorList := someObjects.
> + 	self changed: #selectorList.
> +
> + 	"Select first result if any."
> + 	self selectorListIndex: (selectorList size > 0
> + 			ifTrue: [1]
> + 			ifFalse: [0]).!
>
> Item was changed:
>  ----- Method: MessageNames>>selectorListIndex: (in category 'selector list') -----
>  selectorListIndex: anInteger
>  	"Set the selectorListIndex as specified, and propagate consequences"
>
>  	selectorListIndex := anInteger.
> - 	selectorListIndex = 0
> - 		ifTrue: [^ self].
> - 	messageList := nil.
>  	self changed: #selectorListIndex.
> +
> + 	messageList := self computeMessageList.
> + 	self changed: #messageList.!
> - 	self changed: #messageList!
>
> Item was changed:
> + ----- Method: MessageNames>>selectorListKey:from: (in category 'selector list') -----
> - ----- Method: MessageNames>>selectorListKey:from: (in category 'initialization') -----
>  selectorListKey: aChar from: view
>  	"Respond to a Command key in the message-list pane."
>
>  	aChar == $n ifTrue: [^ self browseSenders].
>  	aChar == $c ifTrue: [^ self copyName].
>  	aChar == $b ifTrue: [^ self browseMethodFull].
>  !
>
> Item was changed:
>  ----- Method: MessageNames>>showOnlyImplementedSelectors (in category 'search') -----
>  showOnlyImplementedSelectors
>  	"Caution -- can be slow!! Filter my selector list down such that it only
>  	shows selectors that are actually implemented somewhere in the system."
> + 	self okToChange ifFalse: [^ self].
> +
> + 	Cursor wait showWhile: [
> + 		self selectorList: (self systemNavigation allSelectorsWithAnyImplementorsIn: selectorList)].!
> - 	self okToChange
> - 		ifTrue: [Cursor wait
> - 				showWhile: [selectorList := self systemNavigation allSelectorsWithAnyImplementorsIn: selectorList.
> - 					self changed: #selectorList.
> - 					self changed: #messageList]]!
>
> Item was changed:
> + ----- Method: MessageNames>>topConstantHeightFrame:fromLeft:width: (in category 'toolbuilder') -----
> - ----- Method: MessageNames>>topConstantHeightFrame:fromLeft:width: (in category 'as yet unclassified') -----
>  topConstantHeightFrame: height fromLeft: leftFraction width: rightFraction
>  	^LayoutFrame new
>  		topFraction: 0 offset: 0;
>  		leftFraction: leftFraction offset: 0;
>  		rightFraction: (leftFraction + rightFraction) offset: 0;
>  		bottomFraction: 0 offset: height;
>  		yourself.!
>
> Item was added:
> + ----- Method: MessageNames>>update: (in category 'updating') -----
> + update: aspect
> +
> + 	aspect == #contents
> + 		ifTrue: [
> + 			self changed: #labelString.
> + 			self doSearch: self searchString].
> +
> + 	super update: aspect.!
>
>
>


More information about the Squeak-dev mailing list