edu.umd.cfar.lamp.viper.gui.core
Class LostFileFinder

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.gui.core.LostFileFinder

public class LostFileFinder
extends java.lang.Object

Since the user shouldn't have to deal with the fact that the viper metadata files and the media files will be stored independently, the need to have a structured way of locating the media files becomes important. What is likely necessary is a user folder with .index files, .project files and the like. How does .ppt handle this? Some lousy hack, no doubt. I really want fs level indexing like bfs, where i can say 'get me the file with the following hash' or something. Damn, that would be cool, and I have to wait until longhorn comes out, and then I still can't use it since I'm trapped in the sandbox. Maybe I just complain too much.


Nested Class Summary
static interface LostFileFinder.SearchCompleted
          Code to run when the search completes or the user has browsed for a file or cancelled the search.
static class LostFileFinder.StoppedFinderException
          Thrown when the search thread is interrupted.
 
Constructor Summary
LostFileFinder()
           
 
Method Summary
static java.io.File findTheFile(java.net.URI oldPath, java.io.File[] paths)
          Looks for the local version of the file, first checking the name of the file as absolute path, then using 'which', then by searching the disk.
static java.io.File[] getDefaultSearchPaths()
          Gets the default search list: the user directory, the current directory, then all the roots.
static java.awt.Window getSearchDialog(java.net.URI oldURI, java.io.File[] paths, LostFileFinder.SearchCompleted whenDone, java.awt.Frame parent)
          Gets a 'Browse for file' dialog box, while starting a search for a file with the same name in the background.
static java.io.File smartFindLocalPath(java.lang.String[] oldPath, java.util.Set dirs, java.io.File root, java.util.Set except)
          Searches from root on down for the first file it finds named oldPath[0], and returns the absolute path to same. oldPath, dirs and except are lists or sets of strings or paths that hopefully keep the search somewhat focused.
static java.io.File smartFindLocalPath(java.lang.String oldPath, java.io.File[] paths)
          If which doesn't work, open up a can of whoop-ass on it.
static java.io.File which(java.lang.String fname, java.io.File[] paths)
          Searches all directories specified in the paths variable for the first occurance of the given fname.
static java.io.File which(java.lang.String fname, java.lang.String paths)
          Searches all directories specified in the paths variable for the first occurance of the given fname.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LostFileFinder

public LostFileFinder()
Method Detail

which

public static java.io.File which(java.lang.String fname,
                                 java.lang.String paths)
Searches all directories specified in the paths variable for the first occurance of the given fname.

Parameters:
fname -
paths -
Returns:
File

which

public static java.io.File which(java.lang.String fname,
                                 java.io.File[] paths)
Searches all directories specified in the paths variable for the first occurance of the given fname.

Parameters:
fname -
paths -
Returns:
File

smartFindLocalPath

public static java.io.File smartFindLocalPath(java.lang.String oldPath,
                                              java.io.File[] paths)
If which doesn't work, open up a can of whoop-ass on it.

Parameters:
oldPath - the path of the old file to look for; used as a heuristic
paths - the paths to search beneath
Returns:
the found file, or null if none is found with the given name

getDefaultSearchPaths

public static java.io.File[] getDefaultSearchPaths()
Gets the default search list: the user directory, the current directory, then all the roots.

Returns:
Places to look for files

findTheFile

public static java.io.File findTheFile(java.net.URI oldPath,
                                       java.io.File[] paths)
Looks for the local version of the file, first checking the name of the file as absolute path, then using 'which', then by searching the disk.

Parameters:
oldPath -
paths - roots and which directories
Returns:
String
Throws:
LostFileFinder.StoppedFinderException - if the thread is interrupted

smartFindLocalPath

public static java.io.File smartFindLocalPath(java.lang.String[] oldPath,
                                              java.util.Set dirs,
                                              java.io.File root,
                                              java.util.Set except)
Searches from root on down for the first file it finds named oldPath[0], and returns the absolute path to same. oldPath, dirs and except are lists or sets of strings or paths that hopefully keep the search somewhat focused.

Parameters:
oldPath - The path we thought the file had, reversed by path, like dns (eg /fs/lamp/something.mpg is {"something.mpg", "lamp", "fs"})
dirs - A set (probably a HashSet) containing oldPath[1:] These are Strings
root - The current search root. This searches recursively
except - Don't look at these absolute paths. These are File objects.
Returns:
String The absolute path to the first file named oldPath[0] found except those named explicitly in except or those down paths blocked by except. Returns null if not found.

getSearchDialog

public static java.awt.Window getSearchDialog(java.net.URI oldURI,
                                              java.io.File[] paths,
                                              LostFileFinder.SearchCompleted whenDone,
                                              java.awt.Frame parent)
Gets a 'Browse for file' dialog box, while starting a search for a file with the same name in the background.

Parameters:
oldURI - The file to look for
paths - Places to check
whenDone - Code to run when the file is found or the user selected it, or hit cancel or it was not found
parent - The frame to which the dialog should be attached
Returns:
the dialog window