FindFileApplication.st
branchjv
changeset 16827 5f036e451583
parent 16643 9fcec4cdfc7e
parent 16810 dee205471698
child 16829 a86b1a96af41
--- a/FindFileApplication.st	Tue Aug 23 07:03:59 2016 +0200
+++ b/FindFileApplication.st	Wed Aug 31 22:53:21 2016 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2002 by eXept Software AG
               All Rights Reserved
@@ -24,7 +26,8 @@
 		fileSizeOperatorHolder fileSizeHolder enableFileSizeFilter
 		fileSizeUnitHolder modificationTimeOperatorHolder
 		modificationTimeHolder enableModificationTimeFilter
-		showUnreadableFilesAndDirectoriesHolder'
+		showUnreadableFilesAndDirectoriesHolder
+		modificationTimeOperatorIndexHolder'
 	classVariableNames:'ContentsInfoCache ContentsInfoCacheAccessLock LastRememberInCache
 		LastSearchIgnoredCaseInContents LastSearchIgnoredCaseInFilename
 		SearchStringHistory LastSearchIgnoredCaseInExcludedFilename
@@ -204,7 +207,7 @@
              name: 'ProgressIndicator1'
              layout: (LayoutFrame 125 0 11 0 231 0 21 0)
              visibilityChannel: enableStop
-             backgroundColor: (Color 0.0 66.9993133440147 66.9993133440147)
+             backgroundColor: (Color 0.0 67.0 67.0)
              showPercentage: false
              isActivityIndicator: true
            )
@@ -217,14 +220,14 @@
                 (LabelSpec
                    label: 'Directory:'
                    name: 'DirectoryLabel'
-                   layout: (LayoutFrame 2 0 7 0 154 0 24 0)
+                   layout: (LayoutFrame 2 0 7 0 180 0 24 0)
                    activeHelpKey: searchDirectory
                    translateLabel: true
                    adjust: right
                  )
                 (FilenameInputFieldSpec
                    name: 'DirectoryEntryField'
-                   layout: (LayoutFrame 156 0 4 0 -315 1 24 0)
+                   layout: (LayoutFrame 180 0 4 0 -350 1 24 0)
                    activeHelpKey: searchDirectory
                    model: searchDirectoryHolder
                    immediateAccept: true
@@ -233,14 +236,14 @@
                 (LabelSpec
                    label: 'Search Files Named:'
                    name: 'FileNameLabel'
-                   layout: (LayoutFrame 2 0 31 0 154 0 48 0)
+                   layout: (LayoutFrame 2 0 31 0 180 0 48 0)
                    activeHelpKey: namePattern
                    translateLabel: true
                    adjust: right
                  )
                 (InputFieldSpec
                    name: 'FileNameEntryField'
-                   layout: (LayoutFrame 156 0 28 0 -315 1 48 0)
+                   layout: (LayoutFrame 180 0 28 0 -350 1 48 0)
                    activeHelpKey: namePattern
                    tabable: true
                    model: namePatternHolder
@@ -251,14 +254,14 @@
                 (LabelSpec
                    label: 'But not Named:'
                    name: 'Label1'
-                   layout: (LayoutFrame 2 0 55 0 154 0 72 0)
+                   layout: (LayoutFrame 2 0 55 0 180 0 72 0)
                    activeHelpKey: excludedNamePattern
                    translateLabel: true
                    adjust: right
                  )
                 (InputFieldSpec
                    name: 'EntryField1'
-                   layout: (LayoutFrame 156 0 52 0 -315 1 72 0)
+                   layout: (LayoutFrame 180 0 52 0 -350 1 72 0)
                    activeHelpKey: excludedNamePattern
                    tabable: true
                    model: excludedNamePatternHolder
@@ -269,14 +272,14 @@
                 (LabelSpec
                    label: 'Containing:'
                    name: 'ContentsLabel'
-                   layout: (LayoutFrame 2 0 79 0 154 0 96 0)
+                   layout: (LayoutFrame 2 0 79 0 180 0 96 0)
                    activeHelpKey: contentsPattern
                    translateLabel: true
                    adjust: right
                  )
                 (ComboBoxSpec
                    name: 'ComboBox1'
-                   layout: (LayoutFrame 156 0 76 0 -315 1 96 0)
+                   layout: (LayoutFrame 180 0 76 0 -350 1 96 0)
                    activeHelpKey: contentsPattern
                    enableChannel: notSearchForSameContents
                    tabable: true
@@ -284,18 +287,19 @@
                    immediateAccept: true
                    acceptOnPointerLeave: false
                    comboList: searchStringHistory
+                   useIndex: false
                  )
                 (LabelSpec
                    label: 'Not Containing:'
                    name: 'NotContentsLabel'
-                   layout: (LayoutFrame 2 0 103 0 154 0 120 0)
+                   layout: (LayoutFrame 2 0 103 0 180 0 120 0)
                    activeHelpKey: notContentsPattern
                    translateLabel: true
                    adjust: right
                  )
                 (InputFieldSpec
                    name: 'NotContentsEntryField'
-                   layout: (LayoutFrame 156 0 100 0 -315 1 120 0)
+                   layout: (LayoutFrame 180 0 100 0 -350 1 120 0)
                    activeHelpKey: notContentsPattern
                    enableChannel: notSearchForSameContents
                    tabable: true
@@ -306,14 +310,14 @@
                 (LabelSpec
                    label: 'Same Contents As:'
                    name: 'SameContentsAsLabel'
-                   layout: (LayoutFrame 2 0 127 0 154 0 144 0)
+                   layout: (LayoutFrame 2 0 127 0 180 0 144 0)
                    activeHelpKey: sameContents
                    translateLabel: true
                    adjust: right
                  )
                 (InputFieldSpec
                    name: 'SameContentsAsEntryField'
-                   layout: (LayoutFrame 156 0 124 0 -339 1 144 0)
+                   layout: (LayoutFrame 180 0 124 0 -367 1 144 0)
                    activeHelpKey: sameContents
                    enableChannel: searchForSameContents
                    tabable: true
@@ -323,8 +327,9 @@
                  )
                 (CheckToggleSpec
                    name: 'EnableSameContentsCheckToggle'
-                   layout: (LayoutOrigin -334 1 128 0)
+                   layout: (LayoutOrigin -366 1 128 0)
                    activeHelpKey: sameContents
+                   translateLabel: true
                    model: searchForSameContents
                    isTriggerOnDown: true
                    showLamp: false
@@ -333,7 +338,7 @@
                 (LabelSpec
                    label: 'File Size:'
                    name: 'FileSizeLabel'
-                   layout: (LayoutFrame 2 0 151 0 154 0 168 0)
+                   layout: (LayoutFrame 2 0 151 0 180 0 168 0)
                    activeHelpKey: fileSize
                    translateLabel: true
                    adjust: right
@@ -341,8 +346,9 @@
                 (PopUpListSpec
                    label: 'PopUp List'
                    name: 'FileSizeOperatorPopUpList'
-                   layout: (LayoutFrame 157 0 148 0 212 0 168 0)
+                   layout: (LayoutFrame 180 0 148 0 260 0 168 0)
                    activeHelpKey: fileSize
+                   translateLabel: true
                    tabable: true
                    model: fileSizeOperatorHolder
                    enableChannel: enableFileSizeFilterAndNotSearchForSameContents
@@ -355,7 +361,7 @@
                  )
                 (InputFieldSpec
                    name: 'FileSizeEntryField'
-                   layout: (LayoutFrame 219 0 148 0 -349 1 168 0)
+                   layout: (LayoutFrame 260 0 148 0 -367 1 168 0)
                    activeHelpKey: fileSize
                    enableChannel: enableFileSizeFilterAndNotSearchForSameContents
                    tabable: true
@@ -368,8 +374,9 @@
                  )
                 (CheckToggleSpec
                    name: 'EnableSizeCheckToggle'
-                   layout: (LayoutOrigin -334 1 151 0)
+                   layout: (LayoutOrigin -366 1 151 0)
                    activeHelpKey: fileSize
+                   translateLabel: true
                    model: enableFileSizeFilter
                    enableChannel: notSearchForSameContents
                    isTriggerOnDown: true
@@ -379,7 +386,7 @@
                 (LabelSpec
                    label: 'Modified:'
                    name: 'Label2'
-                   layout: (LayoutFrame 2 0 175 0 154 0 192 0)
+                   layout: (LayoutFrame 2 0 175 0 180 0 192 0)
                    activeHelpKey: modificationTime
                    translateLabel: true
                    adjust: right
@@ -387,19 +394,18 @@
                 (PopUpListSpec
                    label: 'PopUp List'
                    name: 'PopUpList1'
-                   layout: (LayoutFrame 157 0 172 0 212 0 192 0)
+                   layout: (LayoutFrame 180 0 172 0 260 0 192 0)
                    activeHelpKey: modificationTime
+                   translateLabel: true
                    tabable: true
-                   model: modificationTimeOperatorHolder
+                   model: modificationTimeOperatorIndexHolder
                    enableChannel: enableModificationTimeFilter
-                   menu: 
-                  (Array
-                     ' before' ' after '
-                   )
+                   menu: modificationTimeOperatorLabelList
+                   useIndex: true
                  )
                 (InputFieldSpec
-                   name: 'EntryField2'
-                   layout: (LayoutFrame 219 0 172 0 -349 1 192 0)
+                   name: 'ModifiedEntryField'
+                   layout: (LayoutFrame 260 0 172 0 -367 1 192 0)
                    activeHelpKey: modificationTime
                    enableChannel: enableModificationTimeFilter
                    tabable: true
@@ -412,8 +418,9 @@
                  )
                 (CheckToggleSpec
                    name: 'CheckToggle1'
-                   layout: (LayoutOrigin -334 1 175 0)
+                   layout: (LayoutOrigin -366 1 175 0)
                    activeHelpKey: modificationTime
+                   translateLabel: true
                    model: enableModificationTimeFilter
                    isTriggerOnDown: true
                    showLamp: false
@@ -422,7 +429,7 @@
                 (CheckBoxSpec
                    label: 'Use ''locate'' Cmd'
                    name: 'UseLocateCheckBox'
-                   layout: (LayoutFrame -309 1 5 0 -167 1 28 0)
+                   layout: (LayoutFrame -350 1 5 0 -167 1 28 0)
                    activeHelpKey: useLocate
                    visibilityChannel: canUseLocate
                    tabable: true
@@ -432,7 +439,7 @@
                 (CheckBoxSpec
                    label: 'Recursive'
                    name: 'RecursiveSearchCheckBox'
-                   layout: (LayoutFrame -169 1 5 0 -4 1 28 0)
+                   layout: (LayoutFrame -200 1 5 0 -4 1 28 0)
                    activeHelpKey: recursiveSearch
                    tabable: true
                    model: searchRecursively
@@ -441,7 +448,7 @@
                 (CheckBoxSpec
                    label: 'Directories'
                    name: 'SearchDirectoriesCheckBox'
-                   layout: (LayoutFrame -309 1 29 0 -167 1 52 0)
+                   layout: (LayoutFrame -350 1 29 0 -167 1 52 0)
                    enableChannel: notSearchForSameContents
                    tabable: true
                    model: searchDirectories
@@ -450,7 +457,7 @@
                 (CheckBoxSpec
                    label: 'Ignore Case'
                    name: 'IgnoreCaseInNameCheckBox'
-                   layout: (LayoutFrame -169 1 29 0 -4 1 52 0)
+                   layout: (LayoutFrame -200 1 29 0 -4 1 52 0)
                    activeHelpKey: ignoreCase
                    tabable: true
                    model: ignoreCaseInName
@@ -459,7 +466,7 @@
                 (CheckBoxSpec
                    label: 'Ignore Case'
                    name: 'CheckBox1'
-                   layout: (LayoutFrame -169 1 53 0 -4 1 76 0)
+                   layout: (LayoutFrame -200 1 53 0 -4 1 76 0)
                    activeHelpKey: ignoreCase
                    tabable: true
                    model: ignoreCaseInExcludedName
@@ -468,7 +475,7 @@
                 (CheckBoxSpec
                    label: 'Use ''grep'' Cmd'
                    name: 'UseGrepCheckBox'
-                   layout: (LayoutFrame -309 1 77 0 -167 1 100 0)
+                   layout: (LayoutFrame -350 1 77 0 -167 1 100 0)
                    visibilityChannel: canUseGrep
                    enableChannel: notSearchForSameContents
                    tabable: true
@@ -478,7 +485,7 @@
                 (CheckBoxSpec
                    label: 'Ignore Case'
                    name: 'IgnoreCaseInContentsCheckBox'
-                   layout: (LayoutFrame -169 1 77 0 -4 1 100 0)
+                   layout: (LayoutFrame -200 1 77 0 -4 1 100 0)
                    activeHelpKey: ignoreCase
                    enableChannel: notSearchForSameContents
                    tabable: true
@@ -488,7 +495,7 @@
                 (CheckBoxSpec
                    label: 'Ignore Case'
                    name: 'IgnoreCaseInNotContentsCheckBox'
-                   layout: (LayoutFrame -169 1 101 0 -4 1 124 0)
+                   layout: (LayoutFrame -200 1 101 0 -4 1 124 0)
                    activeHelpKey: ignoreCase
                    enableChannel: notSearchForSameContents
                    tabable: true
@@ -498,7 +505,7 @@
                 (CheckBoxSpec
                    label: 'Cache Info'
                    name: 'RememberInCacheCheckBox'
-                   layout: (LayoutFrame -309 1 125 0 -167 1 148 0)
+                   layout: (LayoutFrame -350 1 125 0 -167 1 148 0)
                    visibilityChannel: canUseGrep
                    enableChannel: searchForSameContents
                    tabable: true
@@ -515,7 +522,7 @@
                 (CheckBoxSpec
                    label: 'Show Unreadable Files and Folders'
                    name: 'CheckBox2'
-                   layout: (LayoutFrame -309 1 149 0 0 1 172 0)
+                   layout: (LayoutFrame -350 1 149 0 0 1 172 0)
                    tabable: true
                    model: showUnreadableFilesAndDirectoriesHolder
                    translateLabel: true
@@ -538,9 +545,9 @@
              sequenceList: shownListHolder
              properties: 
             (PropertyListDictionary
+               dropObjectSelector: getDropObjects:
                displayObjectSelector: getDisplayObjects:
                startDragSelector: doStartDrag:in:
-               dropObjectSelector: getDropObjects:
                dragArgument: findFileList
              )
            )
@@ -548,6 +555,7 @@
         
        )
      )
+
 ! !
 
 !FindFileApplication class methodsFor:'menu specs'!
@@ -1139,12 +1147,41 @@
 modificationTimeOperatorHolder
     modificationTimeOperatorHolder isNil ifTrue:[
         modificationTimeOperatorHolder := 'after' asValue.
+        modificationTimeOperatorHolder onChangeSend:#modificationTimeOperatorChanged to:self.
     ].
     ^ modificationTimeOperatorHolder.
 
     "Created: / 28-03-2012 / 23:04:44 / cg"
 !
 
+modificationTimeOperatorIndexHolder
+    modificationTimeOperatorIndexHolder isNil ifTrue:[
+        modificationTimeOperatorIndexHolder := 1 asValue.
+        modificationTimeOperatorIndexHolder onChangeSend:#modificationTimeOperatorChanged to:self.
+    ].
+    ^ modificationTimeOperatorIndexHolder.
+
+    "Created: / 28-03-2012 / 23:04:44 / cg"
+!
+
+modificationTimeOperatorLabelList
+    ^ self modificationTimeOperatorSpecList collect:#first
+!
+
+modificationTimeOperatorSpecList
+    ^ #(
+        ('before'   #before)
+        ('after'    #after)
+        ('in day'   #inDay)
+        ('in month' #inMonth)
+        ('in year'  #inYear)
+    )
+!
+
+modificationTimeOperatorValueList
+    ^ self modificationTimeOperatorSpecList collect:#second
+!
+
 namePatternHolder
 
     namePatternHolder isNil ifTrue:[
@@ -1244,6 +1281,42 @@
     ^ useLocate.
 ! !
 
+!FindFileApplication methodsFor:'change & update'!
+
+modificationTimeOperatorChanged
+    |timeEditField converter realModel idx operator|
+
+    timeEditField := (self componentAt:'ModifiedEntryField').
+    converter := timeEditField model.
+    realModel := converter model.
+    self assert:(self modificationTimeHolder == realModel).
+    idx := self modificationTimeOperatorIndexHolder value.
+    operator := self modificationTimeOperatorValueList at:idx.
+    
+    ((operator == #after) or:[operator = #before]) ifTrue:[
+        realModel setValue:(realModel value asTimestamp).    
+        converter timeOfClass:Timestamp withFormat:nil orDefault:Timestamp now    
+    ] ifFalse:[    
+        operator = #inDay ifTrue:[
+            realModel setValue:(realModel value asDate).    
+            converter timeOfClass:Date withFormat:'%y-%m-%d' orDefault:Date today    
+        ] ifFalse:[    
+            operator = #inMonth ifTrue:[
+                realModel setValue:(realModel value asDate).    
+                converter monthAndYear    
+            ] ifFalse:[    
+                operator = #inYear ifTrue:[
+                    realModel setValue:(realModel value asDate).    
+                    converter year    
+                ] ifFalse:[
+                    self halt.
+                ].    
+            ].    
+        ].    
+    ].    
+    realModel changed.
+! !
+
 !FindFileApplication methodsFor:'private'!
 
 changeExtentToSeeSearchResult
@@ -1888,16 +1961,37 @@
 modificationTimeWrapperFor:aFileMatchBlock
     "possibly wrap the search-match block into a modification time matcher"
 
-    |timeToCompare timeMatch op compare|
+    |timeToCompare timeMatch idx op compare|
 
     self enableModificationTimeFilter value ifFalse:[ ^ aFileMatchBlock ].
 
     timeToCompare := self modificationTimeHolder value.
-    op := self modificationTimeOperatorHolder value withoutSeparators.
-    op = 'after' ifTrue:[
+    idx := self modificationTimeOperatorIndexHolder value.
+    op := self modificationTimeOperatorValueList at:idx.
+    op = #after ifTrue:[
         compare := [:t | t > timeToCompare ].
     ] ifFalse:[
-        compare := [:t | t < timeToCompare ].
+        op = #before ifTrue:[
+            compare := [:t | t < timeToCompare ].
+        ] ifFalse:[
+            op = #inDay ifTrue:[
+                timeToCompare := timeToCompare asDate.
+                compare := [:t | t asDate = timeToCompare ].
+            ] ifFalse:[
+                op = #inMonth ifTrue:[
+                    timeToCompare := timeToCompare asDate.
+                    compare := [:t | t month = timeToCompare month
+                                     and:[t year = timeToCompare year] ].
+                ] ifFalse:[
+                    op = #inYear ifTrue:[
+                        timeToCompare := timeToCompare asDate.
+                        compare := [:t | t year = timeToCompare year ].
+                    ] ifFalse:[
+                        self halt.
+                    ].    
+                ].    
+            ].    
+        ].
     ].
 
     timeMatch := [:f |