ToolApplicationModel.st
changeset 1969 8e8f5998d053
parent 1809 cfcbb13afdb5
child 1989 aaddb1a4a09a
--- a/ToolApplicationModel.st	Mon Mar 29 15:45:20 2004 +0200
+++ b/ToolApplicationModel.st	Mon Mar 29 15:46:59 2004 +0200
@@ -21,7 +21,7 @@
 	category:'Interface-Framework'
 !
 
-ToolApplicationModel class instanceVariableNames:'history clipboard settings showingHelp instances'
+ToolApplicationModel class instanceVariableNames:'history fileHistory clipboard settings showingHelp instances'
 
 "
  The following class instance variables are inherited by this class:
@@ -377,6 +377,13 @@
 
 !ToolApplicationModel class methodsFor:'history'!
 
+getFileHistory
+    "returns the file-history for this tool class"
+
+    fileHistory isNil ifTrue: [fileHistory := OrderedCollection new].
+    ^ fileHistory
+!
+
 getHistory
     "returns the history for this tool class"
 
@@ -877,7 +884,7 @@
 uninitialize
     "resets the class instance variables"
 
-    settings := instances := showingHelp := history := clipboard := nil
+    settings := instances := showingHelp := history := fileHistory := clipboard := nil
 
     "
      self withAllSubclasses do:[:c | c uninitialize]
@@ -1207,14 +1214,34 @@
 
 !ToolApplicationModel methodsFor:'history'!
 
+add:aHistoryEntry toHistory: aHistory
+    "adds aHistoryEntry (format: loadMessage -> evalString) at the top of aHistory,
+     and checks for maximum size of the history"
+
+    aHistoryEntry key size = 0 ifTrue: [^nil].
+    aHistory remove: (aHistory detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil.
+    aHistory addFirst: aHistoryEntry.
+    [aHistory size > self class historyMaxSize] whileTrue: [aHistory removeLast]
+!
+
+addToFileHistory: aHistoryEntry
+    "adds aHistoryEntry (format: loadMessage -> evalString) at the top of the file-history,
+     and checks for maximum size of the history"
+
+    self add: aHistoryEntry toHistory:self fileHistory
+!
+
 addToHistory: aHistoryEntry
     "adds aHistoryEntry (format: loadMessage -> evalString) at the top of the history,
      and checks for maximum size of the history"
 
-    aHistoryEntry key size = 0 ifTrue: [^nil].
-    self history remove: (self history detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil.
-    self history addFirst: aHistoryEntry.
-    [self history size > self class historyMaxSize] whileTrue: [self history removeLast]
+    self add: aHistoryEntry toHistory:self history
+!
+
+emptyFileHistory
+    "removes all history entries"
+
+    ^ self fileHistory removeAll
 !
 
 emptyHistory
@@ -1223,10 +1250,22 @@
     ^self history removeAll
 !
 
+fileHistory
+    "returns the file-history from tool class"
+
+    ^ self class getFileHistory
+!
+
+fileHistoryEntries
+    "returns the file history entries, i.e. the evaluatable values containing the information"
+
+    ^self fileHistory collect: [:asso| asso key]
+!
+
 history
     "returns the history from tool class"
 
-    ^self class getHistory
+    ^ self class getHistory
 !
 
 historyEntries
@@ -1245,23 +1284,24 @@
     menu := Menu new receiver: self.
     anyItem := false.
 
-    (self history collect: [:histEntry| histEntry value]) 
-        asSet 
-            asOrderedCollection 
-                do:
-                    [:historyEntryType|    
-                        menu addItemGroup:
-                                (self history 
-                                    select: [:histEntry| 
-                                        histEntry value = historyEntryType] 
-                                    thenCollect: [:histEntry|
-                                        anyItem := true.
-                                        MenuItem new 
-                                            label: histEntry key printString; 
-                                            value: histEntry value; 
-                                            argument: histEntry key; 
-                                            activeHelpKey: #historyMenuItem]).
-                    ]. 
+    (self history 
+        collect: [:histEntry| histEntry value]) 
+            asSet 
+                asOrderedCollection 
+                    do:
+                        [:historyEntryType|    
+                            menu addItemGroup:
+                                    (self history 
+                                        select: [:histEntry| 
+                                            histEntry value = historyEntryType] 
+                                        thenCollect: [:histEntry|
+                                            anyItem := true.
+                                            MenuItem new 
+                                                label: histEntry key printString; 
+                                                value: histEntry value; 
+                                                argument: histEntry key; 
+                                                activeHelpKey: #historyMenuItem]).
+                        ]. 
 
     clearItem := MenuItem new 
                         label: 'Clear History'; 
@@ -1277,11 +1317,17 @@
     "Modified: / 29.7.1998 / 11:40:11 / cg"
 !
 
+remove:aHistoryEntry fromHistory: aHistory
+    "removes aHistoryEntry from the history"
+
+    aHistory remove: (aHistory detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil.
+    [aHistory size > self class historyMaxSize] whileTrue: [aHistory removeLast]
+!
+
 removeFromHistory: aHistoryEntry
     "removes aHistoryEntry from the history"
 
-    self history remove: (self history detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil.
-    [self history size > self class historyMaxSize] whileTrue: [self history removeLast]
+    self remove:aHistoryEntry fromHistory: self history.
 ! !
 
 !ToolApplicationModel methodsFor:'initialization'!
@@ -1376,5 +1422,5 @@
 !ToolApplicationModel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.119 2003-09-08 11:55:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.120 2004-03-29 13:46:59 cg Exp $'
 ! !