Package org.photovault.swingui.indexer

Examples of org.photovault.swingui.indexer.IndexerFileChooser


     Asks user to select a directory, creates an external volume from it and
     indexes all images in it. The actual indexing is done asynchronously in a
     separate thread.
     */
    protected void indexDir() {
  IndexerFileChooser fc = new IndexerFileChooser();
        fc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
        int retval = fc.showDialog( this, "Select directory to index" );
        if ( retval == JFileChooser.APPROVE_OPTION ) {
            File dir = fc.getSelectedFile();
           
            // First check that this directory has not been indexed previously
            VolumeBase prevVolume = null;
            try {
                prevVolume = VolumeBase.getVolumeOfFile( dir );
            } catch (IOException ex) {
                JOptionPane.showMessageDialog( this, "Problem reading directory: "
                        + ex.getMessage(), "Photovault error",
                        JOptionPane.ERROR_MESSAGE );
                return;               
            }
            if ( prevVolume != null ) {
                JOptionPane.showMessageDialog( this, "Directory " + dir.getAbsolutePath() +
                        "\n has already been indexed to Photovault.", "Already indexed",
                        JOptionPane.ERROR_MESSAGE );
                return;
            }
           
            // Generate a unique name for the new volume
            String extVolName = "extvol_" + dir.getName();
            if ( VolumeBase.getVolume( extVolName ) != null ) {
                int n = 2;
                while ( VolumeBase.getVolume( extVolName + n ) != null ) {
                    n++;
                }
                extVolName += n;
            }
            ExternalVolume v = new ExternalVolume( extVolName,
                    dir.getAbsolutePath() );
            PhotovaultSettings settings = PhotovaultSettings.getSettings();
            PVDatabase db = settings.getCurrentDatabase();
            try {
                db.addVolume( v );
            } catch (PhotovaultException ex) {
                // This should not happen since we just checked for it!!!
            }
           
            // Set up the indexer
            ExtVolIndexer indexer = new ExtVolIndexer( v );
            PhotoFolder parentFolder = fc.getExtvolParentFolder();
            if ( parentFolder == null ) {
                parentFolder = PhotoFolder.getRoot();
            }
            String rootFolderName = "extvol_" + dir.getName();
            if ( rootFolderName.length() > PhotoFolder.NAME_LENGTH ) {
View Full Code Here

TOP

Related Classes of org.photovault.swingui.indexer.IndexerFileChooser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.