From: <sh...@us...> - 2009-09-08 10:46:08
|
Revision: 16177 http://jedit.svn.sourceforge.net/jedit/?rev=16177&view=rev Author: shlomy Date: 2009-09-08 10:46:02 +0000 (Tue, 08 Sep 2009) Log Message: ----------- When indexing a project, perform the collection of the project files in the background as well as the actual indexing, as this can take a long time if the project uses network or remote file system. Modified Paths: -------------- plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/IndexProjectAction.java plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/LucenePlugin.java Modified: plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/IndexProjectAction.java =================================================================== --- plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/IndexProjectAction.java 2009-09-08 08:33:04 UTC (rev 16176) +++ plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/IndexProjectAction.java 2009-09-08 10:46:02 UTC (rev 16177) @@ -5,6 +5,7 @@ import java.util.Vector; import org.gjt.sp.jedit.io.VFSFile; +import org.gjt.sp.jedit.io.VFSManager; import projectviewer.action.Action; import projectviewer.vpt.VPTFile; @@ -42,6 +43,22 @@ null);*/ return; } + ProjectIndexer indexer = new ProjectIndexer(project, indexName); + VFSManager.runInWorkThread(indexer); + } + } + + private class ProjectIndexer implements Runnable + { + private VPTProject project; + private String indexName; + public ProjectIndexer(VPTProject project, String indexName) + { + this.project = project; + this.indexName = indexName; + } + public void run() + { Collection<VPTNode> nodes = project.getOpenableNodes(); Vector<VFSFile> files = new Vector<VFSFile>(); for (VPTNode n: nodes) @@ -59,5 +76,4 @@ LucenePlugin.instance.addToIndex(indexName, fileArray, true); } } - } Modified: plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/LucenePlugin.java =================================================================== --- plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/LucenePlugin.java 2009-09-08 08:33:04 UTC (rev 16176) +++ plugins/LucenePlugin/trunk/src/gatchan/jedit/lucene/LucenePlugin.java 2009-09-08 10:46:02 UTC (rev 16177) @@ -282,28 +282,22 @@ public void addToIndex(final String indexName, final VFSFile[] files, final boolean sharedSession) { - VFSManager.runInWorkThread(new Runnable() + Index index = getIndex(indexName); + if (index == null) { - public void run() + Log.log(Log.ERROR, this, "Unable to get index " + indexName); + return; + } + if (sharedSession) + index.addFiles(files); + else + { + for (VFSFile file : files) { - Index index = getIndex(indexName); - if (index == null) - { - Log.log(Log.ERROR, this, "Unable to get index " + indexName); - return; - } - if (sharedSession) - index.addFiles(files); - else - { - for (VFSFile file : files) - { - index.addFile(file.getPath()); - } - } - index.commit(); + index.addFile(file.getPath()); } - }); + } + index.commit(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |