SystemBrowser.st
changeset 3131 883d7b34bb86
parent 3125 ed9aa14fe97b
child 3151 910fd5bcfb6e
--- a/SystemBrowser.st	Sat Sep 08 22:30:28 2001 +0200
+++ b/SystemBrowser.st	Mon Sep 10 11:05:55 2001 +0200
@@ -14,11 +14,18 @@
 
 ApplicationModel subclass:#SystemBrowser
 	instanceVariableNames:''
-	classVariableNames:'CheckForInstancesWhenRemovingClasses Icons'
+	classVariableNames:'CheckForInstancesWhenRemovingClasses Icons ClassHistory'
 	poolDictionaries:''
 	category:'Interface-Browsers'
 !
 
+Object subclass:#BrowserHistoryEntry
+	instanceVariableNames:'className meta selector'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:SystemBrowser
+!
+
 !SystemBrowser class methodsFor:'documentation'!
 
 copyright
@@ -196,6 +203,84 @@
     "Created: / 27.10.1997 / 20:10:39 / cg"
 ! !
 
+!SystemBrowser class methodsFor:'accessing - history'!
+
+addToHistory:aClass selector:aSelectorOrNil
+    |newEntry|
+
+    (newEntry := self historyEntryForClass:aClass selector:aSelectorOrNil) isNil ifTrue:[^ self].
+
+    ClassHistory isNil ifTrue:[
+        ClassHistory := OrderedCollection new
+    ].
+    ClassHistory := ClassHistory select:[:entry | entry className ~= newEntry className].
+    ClassHistory addFirst:newEntry.
+    ClassHistory size > self visitedHistoryMaxSize ifTrue:[
+        ClassHistory removeLast
+    ].
+!
+
+checkClassHistory
+    "checks the class history for non-existing classes"
+
+    "/ reverse, since we might modify while enumerating
+    self classHistory reverseDo:[:histEntry|
+        (Smalltalk at: (histEntry className) asSymbol) isBehavior
+        ifFalse:[
+            self classHistory remove: histEntry
+        ]
+    ]
+!
+
+classHistory
+    ^ ClassHistory ? #()
+!
+
+classHistory:newCollection
+    ClassHistory := newCollection
+!
+
+emptyClassHistory
+    "removes all class history entries"
+
+    self classHistory removeAll
+!
+
+historyEntryForClass:aClass selector:aSelectorOrNil
+    |newEntry meta cls|
+
+    aClass isBehavior ifFalse:[^ nil].
+
+    newEntry := BrowserHistoryEntry new.
+    newEntry meta:(meta := aClass isMeta).
+    meta ifTrue:[
+        cls := aClass theNonMetaclass.
+    ] ifFalse:[
+        cls := aClass
+    ].
+    newEntry className:cls name.
+    newEntry selector:aSelectorOrNil.
+    ^ newEntry
+
+    "Modified: / 24.2.2000 / 18:03:52 / cg"
+! !
+
+!SystemBrowser class methodsFor:'defaults'!
+
+classHistoryMaxLevels
+    ^ 3
+!
+
+classHistoryMaxSize
+    ^ 15
+!
+
+visitedHistoryMaxSize
+    "the maximum number of remembered visited-class-history entries"
+
+    ^ 15
+! !
+
 !SystemBrowser class methodsFor:'image specs'!
 
 abstractMethodIcon
@@ -3293,9 +3378,59 @@
     "Modified: / 6.2.2000 / 00:57:08 / cg"
 ! !
 
+!SystemBrowser::BrowserHistoryEntry methodsFor:'accessing'!
+
+className
+    "return the value of the instance variable 'className' (automatically generated)"
+
+    ^ className
+!
+
+className:something
+    "set the value of the instance variable 'className' (automatically generated)"
+
+    className := something.
+!
+
+meta
+    "return the value of the instance variable 'meta' (automatically generated)"
+
+    ^ meta
+!
+
+meta:something
+    "set the value of the instance variable 'meta' (automatically generated)"
+
+    meta := something.
+!
+
+selector
+    "return the value of the instance variable 'selector' (automatically generated)"
+
+    ^ selector
+!
+
+selector:something
+    "set the value of the instance variable 'selector' (automatically generated)"
+
+    selector := something.
+!
+
+theClass
+    ^ Smalltalk at:className asSymbol
+! !
+
+!SystemBrowser::BrowserHistoryEntry methodsFor:'comparing'!
+
+= anEntry
+    ^ className = anEntry className
+      and:[meta = anEntry meta
+      and:[selector = anEntry selector]]
+! !
+
 !SystemBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.131 2001-09-07 17:12:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.132 2001-09-10 09:05:55 cg Exp $'
 ! !
 SystemBrowser initialize!