From VisualWorks®, 7.9 of 11. Mai 2012 on 15. Februar 2013 at 20:35:17
Database.GHAdHocQueryTool private
updateTable: list columns: descrs
"This is the TableInterface-oriented method for filling the results table. The code was copied from VW 7.7.
The new results table is a DataSetView filled with #updateDataset:columns: but we found it not convincing."
| table colAdaptors tableAdaptor colNames colWidths mwidth dataWidths |
table := self tableModel.
colAdaptors := RowAdaptor adaptForIndexes: (1 to: descrs size).
tableAdaptor := TableAdaptor on: list adaptors: colAdaptors.
colNames := List new.
colWidths := List new.
mwidth := 'm' asComposedText width. "I.e. width of representative character"
dataWidths := list isEmpty
ifTrue: [Array new: descrs size withAll: 0]
ifFalse: [self columnWidthsFromData: (list first: 10)].
descrs with: dataWidths
do:
[:aColumnDescription :widthOfData |
| width widthOfLabel widthOfTableColumn |
colNames add: aColumnDescription name.
widthOfLabel := aColumnDescription name asComposedText width + 1.
widthOfTableColumn := mwidth
* aColumnDescription maxColumnConstraint asInteger min: 3 * 72.
width := widthOfTableColumn > widthOfData
ifTrue: [widthOfData + ((widthOfTableColumn - widthOfData) // 2)]
ifFalse: [widthOfData].
width := width max: widthOfLabel.
colWidths add: width].
descrs notEmpty
ifTrue:
[table columnWidths: colWidths.
table columnLabelsArray: colNames].
table columnLabelsFormats: #centered.
table selectionInTable table: tableAdaptor