diff -r 65c1148c41f6 -r 5c129972b1fd FindFileApplication.st --- a/FindFileApplication.st Wed Apr 11 17:14:22 2012 +0100 +++ b/FindFileApplication.st Fri Apr 13 14:15:47 2012 +0100 @@ -20,7 +20,8 @@ rememberInCache searchOnlyInCache searchForSameContents contentsInfoCache contentsInfoCacheAccessLock fileSizeOperatorHolder fileSizeHolder enableFileSizeFilter - fileSizeUnitHolder' + fileSizeUnitHolder modificationTimeOperatorHolder + modificationTimeHolder enableModificationTimeFilter' classVariableNames:'ContentsInfoCache ContentsInfoCacheAccessLock LastRememberInCache LastSearchIgnoredCaseInContents LastSearchIgnoredCaseInFilename SearchStringHistory LastSearchIgnoredCaseInExcludedFilename' @@ -133,9 +134,11 @@ #fileSize 'Search for files with a specific size constraint ("~" means: +/- 10%)' +#modificationTime +'Search for files which are newer or older' ) - "Modified: / 13-01-2012 / 14:40:34 / cg" + "Modified: / 28-03-2012 / 23:03:39 / cg" ! ! !FindFileApplication class methodsFor:'history'! @@ -181,7 +184,7 @@ label: 'File Search' name: 'File Search' min: (Point 377 131) - bounds: (Rectangle 0 0 758 512) + bounds: (Rectangle 0 0 758 419) ) component: (SpecCollection @@ -203,7 +206,7 @@ ) (ViewSpec name: 'Box1' - layout: (LayoutFrame 0 0.0 32 0 0 1.0 200 0) + layout: (LayoutFrame 0 0.0 32 0 0 1.0 231 0) component: (SpecCollection collection: ( @@ -348,7 +351,7 @@ ) (InputFieldSpec name: 'FileSizeEntryField' - layout: (LayoutFrame 219 0 148 0 -430 1 168 0) + layout: (LayoutFrame 219 0 148 0 -349 1 168 0) activeHelpKey: fileSize enableChannel: enableFileSizeFilterAndNotSearchForSameContents tabable: true @@ -369,6 +372,49 @@ showLamp: false lampColor: (Color 100.0 100.0 0.0) ) + (LabelSpec + label: 'Modified:' + name: 'Label2' + layout: (LayoutFrame 2 0 175 0 154 0 192 0) + activeHelpKey: modificationTime + translateLabel: true + adjust: right + ) + (PopUpListSpec + label: 'PopUp List' + name: 'PopUpList1' + layout: (LayoutFrame 157 0 172 0 212 0 192 0) + activeHelpKey: modificationTime + tabable: true + model: modificationTimeOperatorHolder + enableChannel: enableModificationTimeFilter + menu: + (Array + ' before' ' after ' + ) + ) + (InputFieldSpec + name: 'EntryField2' + layout: (LayoutFrame 219 0 172 0 -349 1 192 0) + activeHelpKey: modificationTime + enableChannel: enableModificationTimeFilter + tabable: true + model: modificationTimeHolder + type: timestamp + immediateAccept: false + acceptOnLeave: true + acceptOnLostFocus: true + acceptOnPointerLeave: true + ) + (CheckToggleSpec + name: 'CheckToggle1' + layout: (LayoutOrigin -334 1 175 0) + activeHelpKey: modificationTime + model: enableModificationTimeFilter + isTriggerOnDown: true + showLamp: false + lampColor: (Color 100.0 100.0 0.0) + ) (CheckBoxSpec label: 'Use ''locate'' Cmd' name: 'UseLocateCheckBox' @@ -468,7 +514,7 @@ ) (SequenceViewSpec name: 'List1' - layout: (LayoutFrame 0 0.0 210 0 0 1.0 0 1) + layout: (LayoutFrame 0 0.0 238 0 0 1.0 0 1) model: selectionHolder menu: menu hasHorizontalScrollBar: true @@ -491,7 +537,6 @@ ) ) - "Modified: / 13-01-2012 / 14:40:06 / cg" ! ! !FindFileApplication class methodsFor:'menu specs'! @@ -503,6 +548,7 @@ "Do not manually edit this!! If it is corrupted, the MenuEditor may not be able to read the specification." + " MenuEditor new openOnClass:FindFileApplication andSelector:#menu (Menu new fromLiteralArrayEncoding:(FindFileApplication menu)) startUp @@ -553,16 +599,17 @@ label: '-' ) (MenuItem - enabled: hasListEntries - label: 'Delete all Files' - itemValue: deleteAllFiles + enabled: hasSelection + label: 'Delete Selected File(s)...' + itemValue: deleteSelectedFiles translateLabel: true ) (MenuItem - enabled: hasSelection - label: 'Delete Selected Files' - itemValue: deleteSelectedFiles + enabled: hasListEntries + label: 'Delete all Files...' + itemValue: deleteAllFiles translateLabel: true + isVisible: false ) (MenuItem label: '-' @@ -600,8 +647,6 @@ nil nil ) - - "Modified: / 01-03-2007 / 22:56:59 / cg" ! searchMenu @@ -703,7 +748,9 @@ files := self shownList copy. self deleteFiles:files confirm:true. - self clearShownList. + self removeFilesFromResultList:files + + "Modified: / 29-03-2012 / 10:06:09 / cg" ! deleteFiles:colOfFiles confirm:confirm @@ -738,8 +785,10 @@ files := sel collect:[:idx | self shownList at:idx]. self deleteFiles:files confirm:true. result == true ifTrue:[ - self removeSelectedFilesFromResultList. + self removeFilesFromResultList:files ]. + + "Modified: / 29-03-2012 / 10:05:39 / cg" ! doSearch @@ -858,16 +907,23 @@ "Created: / 03-08-2011 / 18:19:20 / cg" ! -removeSelectedFilesFromResultList - |sel list| +removeFilesFromResultList:listOfFiles + |list| - sel := self selectionHolder value. list := self shownList. - (sel notEmptyOrNil) ifTrue:[ - sel reverseDo:[: key | + (listOfFiles notEmptyOrNil) ifTrue:[ + listOfFiles reverseDo:[: key | list removeAtIndex:key ] ]. + + "Created: / 29-03-2012 / 10:04:58 / cg" +! + +removeSelectedFilesFromResultList + self removeFilesFromResultList:(self selectionHolder value) + + "Modified: / 29-03-2012 / 10:05:11 / cg" ! showMatchedFiles:aBoolean @@ -920,6 +976,15 @@ ^ BlockValue forLogical:self notSearchForSameContents and:self enableFileSizeFilter ! +enableModificationTimeFilter + enableModificationTimeFilter isNil ifTrue:[ + enableModificationTimeFilter := false asValue. + ]. + ^ enableModificationTimeFilter. + + "Created: / 28-03-2012 / 23:11:58 / cg" +! + excludedNamePatternHolder excludedNamePatternHolder isNil ifTrue:[ excludedNamePatternHolder := '' asValue. @@ -993,6 +1058,24 @@ ^ ignoreCaseInNotContents. ! +modificationTimeHolder + modificationTimeHolder isNil ifTrue:[ + modificationTimeHolder := (Timestamp now subtractDays:1) asValue. + ]. + ^ modificationTimeHolder. + + "Created: / 28-03-2012 / 23:08:25 / cg" +! + +modificationTimeOperatorHolder + modificationTimeOperatorHolder isNil ifTrue:[ + modificationTimeOperatorHolder := 'after' asValue. + ]. + ^ modificationTimeOperatorHolder. + + "Created: / 28-03-2012 / 23:04:44 / cg" +! + namePatternHolder namePatternHolder isNil ifTrue:[ @@ -1190,7 +1273,8 @@ |dir lines contentsToCompare resultList inStream doesFileMatch contentsString notContentsString check checkNot - grepCommand nameMatch nameExcludedMatch realNameMatch fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor + grepCommand nameMatch nameExcludedMatch realNameMatch + fileSizesToSearchFor filesToSearchFor fileMD5sToSearchFor setOfFilesToSearchFor remember cache fn dirSearchedRelative| contentsString := contentsStringArg. @@ -1423,6 +1507,8 @@ doesFileMatch := self fileSizeWrapperFor:doesFileMatch. ]. + doesFileMatch := self modificationTimeWrapperFor:doesFileMatch. + namePatterns isNil ifTrue:[ nameMatch := [:fn | true] ] ifFalse:[ @@ -1620,6 +1706,33 @@ ^ [:f | (sizeMatch value:f) and:[ aFileMatchBlock value:f ]] "Created: / 11-01-2012 / 23:17:02 / cg" +! + +modificationTimeWrapperFor:aFileMatchBlock + "possibly wrap the search-match block into a modification time matcher" + + |timeToCompare timeMatch op compare| + + self enableModificationTimeFilter value ifFalse:[ ^ aFileMatchBlock ]. + + timeToCompare := self modificationTimeHolder value. + op := self modificationTimeOperatorHolder value withoutSeparators. + op = 'after' ifTrue:[ + compare := [:t | t > timeToCompare ]. + ] ifFalse:[ + compare := [:t | t < timeToCompare ]. + ]. + + timeMatch := [:f | + |t| + + t := f modificationTime. + t notNil and:[ compare value:t ] + ]. + + ^ [:f | (timeMatch value:f) and:[ aFileMatchBlock value:f ]] + + "Created: / 28-03-2012 / 23:18:32 / cg" ! ! !FindFileApplication methodsFor:'queries'! @@ -1683,13 +1796,13 @@ !FindFileApplication class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.101 2012/03/16 09:10:56 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.103 2012/03/29 08:06:59 cg Exp $' ! version_CVS - ^ '§Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.101 2012/03/16 09:10:56 cg Exp §' + ^ '§Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.103 2012/03/29 08:06:59 cg Exp §' ! version_SVN - ^ '$Id: FindFileApplication.st 7952 2012-03-21 17:50:14Z vranyj1 $' + ^ '$Id: FindFileApplication.st 7978 2012-04-13 13:15:47Z vranyj1 $' ! !