OWASP O2 Platform Blog

Util – Java, Jsp and Xml File Search (Example using Spring MVC JPetStore)

Here is a script that creates a regex based file search. The user can define both the file location and search filters.

This is what it looks like when using the files from JPetStore (note: above the files, the textbox on the left is a file filter and the textbox on the right is a regex text search)

This is the source code that creates the above GUI:

var simpleSearch  = O2Gui.open<ascx_SimpleFileSearch>("Util - Java, Jsp and Xml File Search", 900,500);           
simpleSearch.Path.splitContainer().panel1Collapsed(true);  
Action<string, string > loadFiles =
    (path, fileFilters)=>{                            
                            var files = path.files(true,fileFilters.split(",")
                                                                   .ToArray());
                            simpleSearch.loadFiles(path, files); 
                        };
           
var folderToLoad = @"C:\O2\Demos\jPetStore - O2 Demo Pack\sourceCode";
var filter = "*.jsp,*.xml,*.java"; 
Action refresh =
    ()=>{
            loadFiles(folderToLoad,filter);
        };
       
simpleSearch.insert_Above(20)
            .add_TextBox("Path",folderToLoad)
            .onTextChange((text)=> folderToLoad = text)
            .onEnter((text)=> refresh() )  
            .parent()
            .insert_Right(200)
            .add_TextBox("Filter",filter)
            .onTextChange((text)=> filter = text)
            .onEnter((text)=> refresh()) ;
           
refresh();

//O2File:ascx_SimpleFileSearch.cs

July 18, 2011 - Posted by | JPetStore, Spring MVC

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: