[Pkg] The Trunk: Tools-mt.541.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Mar 6 11:13:03 UTC 2015


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

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

Name: Tools-mt.541
Author: mt
Time: 6 March 2015, 12:12:46.401 pm
UUID: 90ab74c7-c1e5-f140-8d75-91822baedb7b
Ancestors: Tools-topa.540

Object explorer now supports two columns: one for the keys and one for the values. Icons are shown in the second column.

=============== Diff against Tools-topa.540 ===============

Item was added:
+ ----- Method: IndentingListItemMorph class>>iconColumnIndex (in category 'defaults') -----
+ iconColumnIndex
+ 	"Hack. For now, say who gets the icon here. We need a generic solution for icons in multi-column trees. PluggableTreeMorph does something in that direction."
+ 	^ 2!

Item was added:
+ ----- Method: IndentingListItemMorph>>contentsAtColumn: (in category 'accessing - columns') -----
+ contentsAtColumn: index
+ 	"Split string contents at <tab> character."
+ 	
+ 	| column scanner cell |
+ 	column := 0.
+ 	scanner := ReadStream on: contents asString.
+ 	[(cell := scanner upTo: Character tab) notEmpty]
+ 		whileTrue: [column := column + 1. column = index ifTrue: [^ cell]].
+ 	^ ''!

Item was added:
+ ----- Method: IndentingListItemMorph>>contentsSplitByColumns (in category 'accessing - columns') -----
+ contentsSplitByColumns
+ 	"Split string contents at <tab> character."
+ 	
+ 	| result scanner cell |
+ 	result := OrderedCollection new.
+ 	scanner := ReadStream on: contents asString.
+ 	[(cell := scanner upTo: Character tab) notEmpty]
+ 		whileTrue: [result add: cell].
+ 	^ result!

Item was changed:
  ----- Method: IndentingListItemMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas
  
  	
  	| tRect sRect columnScanner columnLeft |
  
  	
  	tRect := self toggleRectangle.
  	
  	sRect := bounds withLeft: tRect right + 4.
+ 	sRect := sRect top: sRect top + sRect bottom - self fontToUse height // 2.
  	self drawToggleOn: aCanvas in: tRect.
  
- 	icon isNil ifFalse:[
- 		aCanvas
- 			translucentImage: icon
- 	
- 			at: sRect left @ (self top + (self height - icon height // 2)).
- 	
- 
- 		sRect := sRect left: sRect left + icon width + 2.
- 	].
- 
  	(container columns isNil or: [(contents asString indexOf: Character tab) = 0]) ifTrue: [
+ 		icon ifNotNil: [
+ 			aCanvas
+ 				translucentImage: icon
+ 				at: sRect left @ (self top + (self height - icon height // 2)).
+ 			sRect := sRect left: sRect left + icon width + 2.
+ 		].
+ 		
- 		sRect := sRect top: sRect top + sRect bottom - self fontToUse height // 2.
  		aCanvas drawString: contents asString in: sRect font: self fontToUse color: color.
  	
  	] ifFalse: [
  		columnLeft := sRect left.
  		columnScanner := ReadStream on: contents asString.
+ 		container columns withIndexDo: [ :widthSpec :column | | columnRect columnData columnWidth |
+ 			"Draw icon."
+ 			column = self class iconColumnIndex ifTrue: [
+ 				icon ifNotNil: [
+ 					aCanvas
+ 						translucentImage: icon
+ 						at: columnLeft @ (self top + (self height - icon height // 2)).
+ 					columnLeft := columnLeft + icon width + 2]].
+ 
+ 			columnWidth := widthSpec isNumber
+ 				ifTrue: [widthSpec]
+ 				ifFalse: [widthSpec isBlock
+ 					ifTrue: [widthSpec cull: container cull: self]
+ 					ifFalse: [widthSpec ifNil: [self width] ifNotNil: [50 "Fall back"]]]. 
+ 			columnRect := columnLeft @ sRect top extent: columnWidth @ sRect height.
- 		container columns do: [ :width | | columnRect columnData |
- 			columnRect := columnLeft @ sRect top extent: width @ sRect height.
  			columnData := columnScanner upTo: Character tab.
+ 			
+ 			"Draw string."
+ 			columnData ifNotEmpty: [
+ 				aCanvas drawString: columnData in: columnRect font: self fontToUse color: color].
+ 
+ 			"Compute next column offset."			
- 			columnData isEmpty ifFalse: [
- 				aCanvas drawString: columnData in: columnRect font: self fontToUse color: color
- .
- 			].
  			columnLeft := columnRect right + 5.
+ 			column = 1 ifTrue: [columnLeft := columnLeft - tRect right + self left].
+ 			
  		].
+ 	]!
- 	]
- !

Item was added:
+ ----- Method: IndentingListItemMorph>>preferredColumnCount (in category 'accessing - columns') -----
+ preferredColumnCount
+ 
+ 	^ self contentsSplitByColumns size!

Item was added:
+ ----- Method: IndentingListItemMorph>>preferredWidthOfColumn: (in category 'accessing - columns') -----
+ preferredWidthOfColumn: index
+ 
+ 	^ (self fontToUse widthOfString: (self contentsAtColumn: index)) + 
+ 		(index = 1 ifTrue: [self toggleRectangle right - self left] ifFalse: [0])!

Item was changed:
+ ----- Method: ObjectExplorer>>explorerFor: (in category 'user interface') -----
- ----- Method: ObjectExplorer>>explorerFor: (in category 'accessing') -----
  explorerFor: anObject
+ 	| window view |
- 	| window listMorph |
  	rootObject := anObject.
  	window := (SystemWindow labelled: self label) model: self.
+ 	window addMorph: (view := (SimpleHierarchicalListMorph 
- 	window addMorph: (listMorph := SimpleHierarchicalListMorph 
  			on: self
  			list: #getList
  			selected: #getCurrentSelection
  			changeSelected: #noteNewSelection:
  			menu: #genericMenu:
  			keystroke: #explorerKey:from:)
+ 				columns: (ObjectExplorerWrapper showContentsInColumns
+ 					ifTrue: [{
+ 						[:listMorph | (listMorph scroller submorphs collect: [:item |
+ 							item preferredWidthOfColumn: 1]) max].
+ 						nil "take all the space"}]
+ 					ifFalse: []);
+ 				yourself)
  		frame: (0 at 0 corner: 1 at 0.8).
  	window addMorph: ((PluggableTextMorph on: self text: #trash accept: #trash:
  				readSelection: #contentsSelection menu: #codePaneMenu:shifted:)
  					askBeforeDiscardingEdits: false)
  		frame: (0 at 0.8 corner: 1 at 1).
+ 	view
- 	listMorph
  		autoDeselect: false.
       ^ window!

Item was changed:
  ----- Method: ObjectExplorer>>explorerFor:withLabel: (in category 'user interface') -----
  explorerFor: anObject withLabel: label 
+ 	| window view |
- 	| window listMorph |
  	rootObject := anObject.
  	window := (SystemWindow labelled: label) 
  				model: self.
+ 
  	window
+ 		addMorph: (view := (SimpleHierarchicalListMorph
- 		addMorph: (listMorph := SimpleHierarchicalListMorph
  						on: self
  						list: #getList
  						selected: #getCurrentSelection
  						changeSelected: #noteNewSelection:
  						menu: #genericMenu:
  						keystroke: nil)
+ 							columns: (ObjectExplorerWrapper showContentsInColumns
+ 								ifTrue: [{
+ 									[:listMorph | (listMorph scroller submorphs collect: [:item |
+ 										item preferredWidthOfColumn: 1]) max].
+ 									nil "take all the space"}]
+ 								ifFalse: []);
+ 							yourself)
  		frame: (0 @ 0 corner: 1 @ 0.8).
  	window
  		addMorph: ((PluggableTextMorph
  				on: self
  				text: #trash
  				accept: #trash:
  				readSelection: #contentsSelection
  				menu: #codePaneMenu:shifted:)
  				askBeforeDiscardingEdits: false)
  		frame: (0 @ 0.8 corner: 1 @ 1).
+ 	view autoDeselect: false.
- 	listMorph autoDeselect: false.
  	^ window!



More information about the Packages mailing list