#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Fri, 01 Sep 2017 10:17:17 +0200
changeset 4008 f7f1b89886ef
parent 4007 fee18ec30eb3
child 4009 bece1481d314
#UI_ENHANCEMENT by cg care for invalid history entries class: ToolApplicationModel changed: #menuHistory class: ToolApplicationModel::HistoryEntry added: #isValid class: ToolApplicationModel::HistoryEntryForFile added: #isValid
ToolApplicationModel.st
--- a/ToolApplicationModel.st	Fri Sep 01 10:06:50 2017 +0200
+++ b/ToolApplicationModel.st	Fri Sep 01 10:17:17 2017 +0200
@@ -1411,19 +1411,22 @@
     ((self history 
         collect: [:histEntry| histEntry class] as:Set) 
             asSortedCollection:[:a :b | a name < b name]) 
-                do:
-                    [:historyEntryType|    
-                        menu addItemGroup:
-                                (self history 
-                                    select: [:histEntry| 
-                                        histEntry class = historyEntryType] 
-                                    thenCollect: [:histEntry|
-                                        anyItem := true.
-                                        MenuItem new 
-                                            label: histEntry printStringInMenu 
-                                            itemValue: #loadFromHistoryEntry: argument: histEntry; 
-                                            activeHelpKey: #historyMenuItem]).
-                    ]. 
+                do:[:historyEntryType|    
+                    menu addItemGroup:
+                            (self history 
+                                select: [:histEntry| 
+                                    (histEntry class = historyEntryType)
+                                    and:[ histEntry isValid ] 
+                                ] 
+                                thenCollect: [:histEntry|
+                                    anyItem := true.
+                                    MenuItem new 
+                                        label: histEntry printStringInMenu 
+                                        itemValue: #loadFromHistoryEntry: argument: histEntry; 
+                                        activeHelpKey: #historyMenuItem
+                                ]
+                            ).
+                ]. 
 
     clearItem := MenuItem label: 'Clear History' itemValue: #emptyHistory enabled:anyItem. 
     clearItem activeHelpKey: #historyEmptyMenu.
@@ -1432,8 +1435,7 @@
     menu findGuiResourcesIn:self.
     ^menu
 
-    "Modified: / 09-09-2012 / 13:10:38 / cg"
-    "Modified (comment): / 01-09-2017 / 10:06:09 / cg"
+    "Modified: / 01-09-2017 / 10:16:26 / cg"
 !
 
 remove:aHistoryEntry fromHistory: aHistory
@@ -1570,6 +1572,17 @@
     ^ false
 ! !
 
+!ToolApplicationModel::HistoryEntry methodsFor:'queries'!
+
+isValid
+    "can be redefined to return false if a history item is no longer
+     valid (for example file-items for files which no longer exist)"
+     
+    ^ true
+
+    "Created: / 01-09-2017 / 10:12:12 / cg"
+! !
+
 !ToolApplicationModel::HistoryEntryForFile class methodsFor:'instance creation'!
 
 filename:arg
@@ -1608,6 +1621,16 @@
     ^ filename
 ! !
 
+!ToolApplicationModel::HistoryEntryForFile methodsFor:'queries'!
+
+isValid
+    "redefined to return false if the file no longer exists"
+
+    ^ filename notNil and:[ filename asFilename exists ]
+
+    "Created: / 01-09-2017 / 10:13:08 / cg"
+! !
+
 !ToolApplicationModel::HistoryEntryForMethod class methodsFor:'instance creation'!
 
 class:classToAdd selector:selectorToAdd
@@ -1656,6 +1679,10 @@
 
 !ToolApplicationModel class methodsFor:'documentation'!
 
+version
+    ^ '$Header$'
+!
+
 version_CVS
     ^ '$Header$'
 ! !