ToolApplicationModel.st
changeset 1809 cfcbb13afdb5
parent 1767 f94850ee9885
child 1969 8e8f5998d053
--- a/ToolApplicationModel.st	Mon Sep 01 18:52:40 2003 +0200
+++ b/ToolApplicationModel.st	Mon Sep 08 13:55:19 2003 +0200
@@ -1236,32 +1236,40 @@
 !
 
 menuHistory
-    "returns a history submenu"
+    "returns a dynamic history submenu"
 
     <resource: #programMenu >
 
-    |menu|
+    |menu anyItem clearItem|
 
     menu := Menu new receiver: self.
-    (self history collect: [:histEntry| histEntry value]) asSet asOrderedCollection do:
-    [:historyEntryType|    
-        menu addItemGroup:
-                (self history 
-                    select: [:histEntry| 
-                        histEntry value = historyEntryType] 
-                    thenCollect: [:histEntry|  
-                        MenuItem new 
-                            label: histEntry key printString; 
-                            value: histEntry value; 
-                            argument: histEntry key; 
-                            activeHelpKey: #historyMenuItem]).
-    ]. 
+    anyItem := false.
 
-    menu addItem: (MenuItem new 
+    (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'; 
                         value: #emptyHistory; 
                         activeHelpKey: #historyEmptyMenu;
-                        translateLabel:true).
+                        translateLabel:true.
+    clearItem enabled:anyItem.
+    menu addItem: clearItem.
 
     menu findGuiResourcesIn:self.
     ^menu
@@ -1368,5 +1376,5 @@
 !ToolApplicationModel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.118 2003-05-07 14:41:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.119 2003-09-08 11:55:19 cg Exp $'
 ! !