--- a/Tools__VariableList.st Mon May 09 21:47:57 2016 +0200
+++ b/Tools__VariableList.st Thu May 12 08:33:55 2016 +0200
@@ -14,8 +14,9 @@
"{ NameSpace: Tools }"
BrowserList subclass:#VariableList
- instanceVariableNames:'variableList classHolder showClassVars sortVariablesByName
- selectedVariableEntries showWarningAboutMissingEntryInXmlSpec'
+ instanceVariableNames:'classHolder groupVariablesByInheritance selectedVariableEntries
+ showClassVars showWarningAboutMissingEntryInXmlSpec
+ sortVariablesByName variableList'
classVariableNames:''
poolDictionaries:''
category:'Interface-Browsers-New'
@@ -23,7 +24,7 @@
Object subclass:#VariableEntry
instanceVariableNames:'label application class name type icon sortingByNameHolder
- classShown'
+ classShown groupByInheritanceHolder'
classVariableNames:''
poolDictionaries:''
privateIn:VariableList
@@ -131,6 +132,7 @@
#showClassVarsInVariableList
#slaveMode
#sortVariablesByName
+ #groupVariablesByInheritance
).
"Modified: / 24-02-2014 / 10:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -163,6 +165,32 @@
^ false.
!
+groupVariablesByInheritance
+ "/ groupVariablesByInheritance and sortVariablesByName form a 3-state value
+ "/ groupVariablesByInheritance sortVariablesByName
+ "/ T T - sort within each defining class
+ "/ T F - by inst-order grouped by defining class
+ "/ F T - show all of them in one big sorted list
+ "/ F F - useless - show all of them by inst-order
+ groupVariablesByInheritance isNil ifTrue:[
+ groupVariablesByInheritance := true asValue.
+ groupVariablesByInheritance addDependent:self
+ ].
+ ^ groupVariablesByInheritance
+!
+
+groupVariablesByInheritance:aValueHolder
+ "/ self assert:(aValueHolder value isBoolean).
+
+ groupVariablesByInheritance notNil ifTrue:[
+ groupVariablesByInheritance removeDependent:self
+ ].
+ groupVariablesByInheritance := aValueHolder.
+ groupVariablesByInheritance notNil ifTrue:[
+ groupVariablesByInheritance addDependent:self
+ ].
+!
+
selectedVariableEntries
<resource: #uiAspect>
@@ -211,9 +239,15 @@
!
sortVariablesByName
+ "/ groupVariablesByInheritance and sortVariablesByName form a 3-state value
+ "/ groupVariablesByInheritance sortVariablesByName
+ "/ T T - sort within each defining class
+ "/ T F - by inst-order grouped by defining class
+ "/ F T - show all of them in one big sorted list
+ "/ F F - useless - show all of them by inst-order
sortVariablesByName isNil ifTrue:[
- sortVariablesByName := false asValue.
- sortVariablesByName addDependent:self
+ sortVariablesByName := false asValue.
+ sortVariablesByName addDependent:self
].
^ sortVariablesByName
!
@@ -266,6 +300,10 @@
self invalidateList.
^ self.
].
+ changedObject == groupVariablesByInheritance ifTrue:[
+ self invalidateList.
+ ^ self.
+ ].
changedObject == environment ifTrue:[
(something == #projectOrganization) ifTrue:[^ self].
(something == #currentChangeSet) ifTrue:[^ self].
@@ -491,37 +529,17 @@
!
listEntryForClass: cls name:name
-
- " (showWarningAboutMissingEntryInXmlSpec not
- and:[Expecco::ExpeccoXMLDecoder notNil
- and:[cls canUnderstand: #xmlSpecFor:]]) ifTrue:
- [| hasSpecEntry |
- hasSpecEntry := false.
- (Expecco::ExpeccoXMLDecoder xmlSpecForObject:cls basicNew)
- do:[:spec|spec getter = name ifTrue:
- [
- hasSpecEntry := true]].
- showWarningAboutMissingEntryInXmlSpec := hasSpecEntry not]. "
-
- |entry|
-
- entry := VariableEntry application: self class: cls name: name.
- entry sortingByNameHolder:sortVariablesByName.
- ^ entry
-
- "Created: / 12-04-2011 / 15:41:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 12-04-2011 / 21:36:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^ self listEntryForClass: cls name:name info:nil
!
-listEntryForClass: cls name:name info: classInfo
-
- | nm entry |
+listEntryForClass: cls name:name info: classInfoOrNil
+ | entry |
- nm := name.
- entry := Tools::VariableList::VariableEntry application: self class: cls name: nm.
+ entry := Tools::VariableList::VariableEntry application: self class: cls name: name.
entry sortingByNameHolder:sortVariablesByName.
- classInfo notNil ifTrue:[
- entry type: (classInfo infoForInstvarOrNil: name).
+ entry groupByInheritanceHolder:groupVariablesByInheritance.
+ classInfoOrNil notNil ifTrue:[
+ entry type: (classInfoOrNil infoForInstvarOrNil: name).
].
^entry
@@ -532,7 +550,7 @@
listOfVariables
|nameList numClasses classes class commonSubclass showingClassVars
- sortByName classesAlreadyProcessed hasSmallSense smallSenseManager info |
+ sortByName groupByInheritance classesAlreadyProcessed hasSmallSense smallSenseManager info |
classHolder isNil ifTrue:[
"/ testing
@@ -547,7 +565,9 @@
showingClassVars := self showClassVarsInVariableList value == true.
sortByName := self sortVariablesByName value.
- "/ self assert:(sortByName isBoolean).
+ groupByInheritance := self groupVariablesByInheritance value.
+ self assert:(sortByName isBoolean).
+ self assert:(groupByInheritance isBoolean).
classes := classHolder value.
(numClasses := classes size) == 0 ifTrue:[^ #() ].
@@ -657,21 +677,23 @@
].
varNames := showingClassVars ifTrue:[ cls classVarNames ] ifFalse:[ cls instVarNames ].
classShown := (cls ~~ class). "/ only append the class in the shown name, if the var is inherited
-
+ sortByName ifTrue:[
+ varNames sort.
+ ].
varNames reversed do:[:varName|
|entry|
nameList addFirst: (entry := self listEntryForClass: cls name: varName info: info).
classShown ifFalse:[ entry classShown:classShown ].
].
- sortByName ifFalse:[
- nameList addFirst:(("'----- ' , "cls nameInBrowser" , ' -----'") asText colorizeAllWith: Color gray).
+ groupByInheritance ifTrue:[
+ nameList addFirst:(("'----- ' , "cls nameInBrowser" , ' -----'") withColor: Color gray).
]
].
].
].
].
- (numClasses > 1 or:[sortByName]) ifTrue:[
+ (numClasses > 1 or:[sortByName and:[groupByInheritance not]]) ifTrue:[
nameList := nameList asSortedCollection:[:a :b|a name < b name].
].
^ nameList
@@ -791,6 +813,11 @@
classShown := aBoolean.
!
+groupByInheritanceHolder:aValueHolder
+ "/ is there a need for a valueHolder?
+ groupByInheritanceHolder := aValueHolder.
+!
+
icon
icon isNil ifTrue:[
icon := application iconInBrowserForVariable: name in: class.
@@ -814,7 +841,7 @@
label isNil ifTrue:[
label := name.
type notNil ifTrue:[
- label := (label , ' ' , (type displayString colorizeAllWith: Color brown))
+ label := (label , ' ' , (type displayString withColor: Color brown))
] ifFalse:[
"/ Hack for Java classes to display field type
class theNonMetaclass isJavaClass ifTrue:[
@@ -824,7 +851,7 @@
label := label asText ,
' ' ,
(('< ' , (JavaMethod fieldTypeFromStream: (field descriptor readStream) in: class theNonMetaclass javaPackage) , ' >')
- asText colorizeAllWith: Color brown).
+ withColor: Color brown).
].
].
].
@@ -840,7 +867,7 @@
l := self label.
class notNil ifTrue:[
- ^ label,' (' ,(class nameWithoutPrefix colorizeAllWith: Color gray),')'
+ ^ label,' (' ,(class nameWithoutPrefix withColor: Color gray),')'
].
^label
!
@@ -853,8 +880,9 @@
name := aString.
!
-sortingByNameHolder:something
- sortingByNameHolder := something.
+sortingByNameHolder:aValueHolder
+ "/ is there a need for a valueHolder?
+ sortingByNameHolder := aValueHolder.
!
string
@@ -890,7 +918,7 @@
icn displayOn:aGC x:x + 1 y:y - icn height.
].
- shownLabel := ((classShown ? true) and:[sortingByNameHolder value])
+ shownLabel := ((classShown ? true) and:[sortingByNameHolder value and:[groupByInheritanceHolder value not]])
ifTrue:[ self labelWithClass ]
ifFalse: [ self label ].