woproject/projects/wolips/plugins/org.objectstyle.wolips.components/java/org/objectstyle/wolips/components/input ComponentEditorInput.java,1.5,1.6

[email protected]
Newsgroups gmane.comp.web.webobjects.woproject.cvs
Message-ID <[email protected]>
Update of /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.components/java/org/objectstyle/wolips/components/input
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18645/java/org/objectstyle/wolips/components/input

Modified Files:
	ComponentEditorInput.java 
Log Message:
Caching of locate results.

Index: ComponentEditorInput.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.components/java/org/objectstyle/wolips/components/input/ComponentEditorInput.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ComponentEditorInput.java	6 Jan 2006 12:42:30 -0000	1.5
+++ ComponentEditorInput.java	25 Jan 2006 08:13:05 -0000	1.6
@@ -3,7 +3,7 @@
  * 
  * The ObjectStyle Group Software License, Version 1.0
  * 
- * Copyright (c) 2005 The ObjectStyle Group and individual authors of the
+ * 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
@@ -45,7 +45,6 @@
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.ui.JavaUI;
 import org.eclipse.ui.IEditorInput;
@@ -54,10 +53,9 @@
 import org.eclipse.ui.part.MultiEditorInput;
 import org.objectstyle.wolips.components.ComponentsPlugin;
 import org.objectstyle.wolips.editors.EditorsPlugin;
-import org.objectstyle.wolips.locate.Locate;
 import org.objectstyle.wolips.locate.LocateException;
+import org.objectstyle.wolips.locate.LocatePlugin;
 import org.objectstyle.wolips.locate.result.LocalizedComponentsLocateResult;
-import org.objectstyle.wolips.locate.scope.ComponentLocateScope;
 
 public class ComponentEditorInput extends MultiEditorInput implements
 		IPersistableElement {
@@ -91,8 +89,8 @@
 			allInput = new ComponentEditorFileEditorInput[4];
 		}
 		ids[0] = JavaUI.ID_CU_EDITOR;
-		allInput[0] = new ComponentEditorFileEditorInput(localizedComponentsLocateResult
-				.getDotJava());
+		allInput[0] = new ComponentEditorFileEditorInput(
+				localizedComponentsLocateResult.getDotJava());
 		ids[1] = EditorsPlugin.HTMLEditorID;
 		IFolder folder = localizedComponentsLocateResult.getComponents()[0];
 		IFile htmlFile = LocalizedComponentsLocateResult.getHtml(folder);
@@ -102,12 +100,12 @@
 		allInput[2] = new ComponentEditorFileEditorInput(wodFile);
 		if (localizedComponentsLocateResult.getDotApi() != null) {
 			ids[3] = EditorsPlugin.ApiEditorID;
-			allInput[3] = new ComponentEditorFileEditorInput(localizedComponentsLocateResult
-					.getDotApi());
+			allInput[3] = new ComponentEditorFileEditorInput(
+					localizedComponentsLocateResult.getDotApi());
 		}
 		ComponentEditorInput input = new ComponentEditorInput(ids, allInput);
 		input.localizedComponentsLocateResult = localizedComponentsLocateResult;
-		for(int i = 0; i < allInput.length; i++) {
+		for (int i = 0; i < allInput.length; i++) {
 			allInput[i].setComponentEditorInput(input);
 		}
 		return input;
@@ -116,15 +114,11 @@
 	/*
 	 * may return null
 	 */
-	private static ComponentEditorInput create(IProject project, String fileName)
-			throws CoreException {
-		ComponentLocateScope componentLocateScope = new ComponentLocateScope(
-				project, fileName);
-		LocalizedComponentsLocateResult localizedComponentsLocateResult = new LocalizedComponentsLocateResult();
-		Locate locate = new Locate(componentLocateScope,
-				localizedComponentsLocateResult);
+	private static ComponentEditorInput create(IFile file) throws CoreException {
+		LocalizedComponentsLocateResult localizedComponentsLocateResult = null;
 		try {
-			locate.locate();
+			localizedComponentsLocateResult = LocatePlugin.getDefault()
+					.getLocalizedComponentsLocateResult(file);
 		} catch (CoreException e) {
 			ComponentsPlugin.getDefault().log(e);
 			return null;
@@ -146,10 +140,7 @@
 	 */
 	public static ComponentEditorInput createWithDotJava(IFile file)
 			throws CoreException {
-		IProject project = file.getProject();
-		String fileName = file.getName().substring(0,
-				file.getName().length() - 5);
-		ComponentEditorInput input = create(project, fileName);
+		ComponentEditorInput input = create(file);
 		if (input != null) {
 			input.displayJavaPartOnReveal = true;
 		}
@@ -161,10 +152,7 @@
 	 */
 	public static ComponentEditorInput createWithDotHtml(IFile file)
 			throws CoreException {
-		IProject project = file.getProject();
-		String fileName = file.getName().substring(0,
-				file.getName().length() - 5);
-		ComponentEditorInput input = create(project, fileName);
+		ComponentEditorInput input = create(file);
 		if (input != null) {
 			input.displayHtmlPartOnReveal = true;
 		}
@@ -176,10 +164,7 @@
 	 */
 	public static ComponentEditorInput createWithDotWod(IFile file)
 			throws CoreException {
-		IProject project = file.getProject();
-		String fileName = file.getName().substring(0,
-				file.getName().length() - 4);
-		ComponentEditorInput input = create(project, fileName);
+		ComponentEditorInput input = create(file);
 		if (input != null) {
 			input.displayWodPartOnReveal = true;
 		}
@@ -191,10 +176,7 @@
 	 */
 	public static ComponentEditorInput createWithDotApi(IFile file)
 			throws CoreException {
-		IProject project = file.getProject();
-		String fileName = file.getName().substring(0,
-				file.getName().length() - 4);
-		ComponentEditorInput input = create(project, fileName);
+		ComponentEditorInput input = create(file);
 		input.displayApiPartOnReveal = true;
 		return input;
 	}
@@ -204,10 +186,7 @@
 	 */
 	public static ComponentEditorInput createWithDotWoo(IFile file)
 			throws CoreException {
-		IProject project = file.getProject();
-		String fileName = file.getName().substring(0,
-				file.getName().length() - 4);
-		ComponentEditorInput input = create(project, fileName);
+		ComponentEditorInput input = create(file);
 		if (input != null) {
 			input.displayWooPartOnReveal = true;
 		}



-------------------------------------------------------
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.