package searchfiles import Utilities class SearchForm( folder : File ) : PromptForm( "Search Files" ) { constructor() : this( File("") ) var useRegex = boolProperty( "Regular Expression", false) .icon( "regex" ).shortcut( Key.R.control() ) var caseSensitive = boolProperty( "Case Sensitive", false) .icon( "case" ).shortcut( Key.M.control() ) var matchWords = boolProperty( "Match Words", false) .icon( "match_words" ).shortcut( Key.W.control().shift() ) val search = regexProperty( "java", "Search Text", "", useRegex, matchWords, caseSensitive ) .rows( 1 ) val start = fileOrFolderProperty( "Start File/Folder", folder ) val searchHiddenFiles = boolProperty( "Search Hidden Files", false ) .shortcut( Key.PERIOD.control() ).icon( "hidden_file" ) val searchHiddenFolders = boolProperty( "Search Hidden Folders", false ) .shortcut( Key.PERIOD.control().shift() ).icon( "hidden_folder" ) val extensions = Utilities.extensionsProperty( "" ) val searchSubFolders = boolProperty( "Search Subfolders", true ) val maxDepth = intProperty( "Max Depth", 10 ) .minValue( 1 ) val searchSubGroup = HorizontalGroup( 16, searchSubFolders, maxDepth ).includeLabels() val countMatches = boolProperty( "Count Matches", true ) val maxMatchCount = intProperty( "Stop counting at", 20 ) val countGroup = HorizontalGroup( 16, countMatches, maxMatchCount ).includeLabels() val advanced = FormGroup( "Advanced", searchSubGroup, countGroup ) .expanded(false) val replace = stringProperty( "Replacement Text", "" ) override meth copy() = super.copy() as SearchForm override meth elements() = listOf( HorizontalGroup( 2, search, useRegex, matchWords, caseSensitive ).apply { fillHeight = false }, start, HorizontalGroup( "Hidden Files/Folders", 4, searchHiddenFiles, searchHiddenFolders ), extensions, advanced, rowSeparator, FormSectionHeading( "Replace" ), replace ) override meth validate() : FormError { if (search.value.isBlank()) { return FormError( search, "Search text is required" ) } if (!start.value.exists()) { return FormError( start, "File/Folder not found" ) } return null } override meth runner() = SearchBehaviour( this ) }