Update of /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.locate/java/org/objectstyle/wolips/locate
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18533/java/org/objectstyle/wolips/locate
Modified Files:
LocatePlugin.java
Log Message:
Caching of locate results.
Index: LocatePlugin.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.locate/java/org/objectstyle/wolips/locate/LocatePlugin.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- LocatePlugin.java 2 Oct 2005 13:52:37 -0000 1.1
+++ LocatePlugin.java 25 Jan 2006 08:12:45 -0000 1.2
@@ -2,7 +2,7 @@
*
* The ObjectStyle Group Software License, Version 1.0
*
- * Copyright (c) 2005 The ObjectStyle Group,
+ * Copyright (c) 2005 - 2006 The ObjectStyle Group,
* and individual authors of the software. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,13 @@
*/
package org.objectstyle.wolips.locate;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.objectstyle.wolips.core.runtime.AbstractCorePlugin;
+import org.objectstyle.wolips.locate.cache.ComponentLocateCache;
+import org.objectstyle.wolips.locate.result.LocalizedComponentsLocateResult;
+import org.objectstyle.wolips.locate.scope.ComponentLocateScope;
import org.osgi.framework.BundleContext;
/**
@@ -65,6 +71,8 @@
// The shared instance.
private static LocatePlugin plugin;
+ private ComponentLocateCache componentsLocateCache;
+
/**
* The constructor.
*/
@@ -73,11 +81,18 @@
plugin = this;
}
- /**
- * This method is called when the plug-in is stopped
- */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ componentsLocateCache = new ComponentLocateCache();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(
+ componentsLocateCache);
+ }
+
public void stop(BundleContext context) throws Exception {
super.stop(context);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(
+ componentsLocateCache);
+ componentsLocateCache = null;
plugin = null;
}
@@ -88,4 +103,35 @@
return plugin;
}
+ public LocalizedComponentsLocateResult getLocalizedComponentsLocateResult(
+ IFile file) throws CoreException, LocateException {
+ LocalizedComponentsLocateResult localizedComponentsLocateResult = componentsLocateCache
+ .getLocalizedComponentsLocateResult(file);
+ if (localizedComponentsLocateResult != null) {
+ return localizedComponentsLocateResult;
+ }
+ ComponentLocateScope componentLocateScope = ComponentLocateScope
+ .createLocateScope(file);
+ localizedComponentsLocateResult = new LocalizedComponentsLocateResult();
+ Locate locate = new Locate(componentLocateScope,
+ localizedComponentsLocateResult);
+ locate.locate();
+ if (localizedComponentsLocateResult != null) {
+ componentsLocateCache.addToCache(file,
+ localizedComponentsLocateResult);
+ }
+ return localizedComponentsLocateResult;
+ }
+
+ public String fileNameWithoutExtension(IFile file) {
+ String fileName = file.getName();
+ String fileNameWithoutExtension;
+ int dotIndex = fileName.indexOf('.');
+ if (dotIndex != -1) {
+ fileNameWithoutExtension = fileName.substring(0, dotIndex);
+ } else {
+ fileNameWithoutExtension = fileName;
+ }
+ return fileNameWithoutExtension;
+ }
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.