Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2001-12-11 08:36:24 -0500
committerDani Megert2001-12-11 08:36:24 -0500
commitb2bc57e0f7bcb003ec847a9eee71a6e42eefff70 (patch)
treea98c5e34135f4e3deca53ca38ca6809a57a1bdd1
parent29aed32021b19826878b49eb6b329cdf2d542bc1 (diff)
downloadeclipse.platform.text-b2bc57e0f7bcb003ec847a9eee71a6e42eefff70.tar.gz
eclipse.platform.text-b2bc57e0f7bcb003ec847a9eee71a6e42eefff70.tar.xz
eclipse.platform.text-b2bc57e0f7bcb003ec847a9eee71a6e42eefff70.zip
First part for reuseEditor preference
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java46
-rw-r--r--org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java19
2 files changed, 61 insertions, 4 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java
index 8fc90aaa0..38c1cd93e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/GotoMarkerAction.java
@@ -4,8 +4,28 @@
*/
package org.eclipse.search.internal.ui.text;
-import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.internal.ui.util.ExceptionHandler; import org.eclipse.search.ui.ISearchResultView; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.SearchUI;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.FileEditorInput;
+
+import org.eclipse.search.ui.ISearchResultView;
+import org.eclipse.search.ui.ISearchResultViewEntry;
+import org.eclipse.search.ui.SearchUI;
+
import org.eclipse.search.internal.ui.SearchMessages;
+import org.eclipse.search.internal.ui.SearchPlugin;
+import org.eclipse.search.internal.ui.util.ExceptionHandler;
class GotoMarkerAction extends Action {
@@ -22,8 +42,15 @@ class GotoMarkerAction extends Action {
show(entry.getSelectedMarker());
}
}
-
- public void show(IMarker marker) {
+
+ private void show(IMarker marker) {
+ if (SearchUI.reuseEditor())
+ showWithReuse(marker);
+ else
+ showWithoutReuse(marker);
+ }
+
+ private void showWithReuse(IMarker marker) {
IWorkbenchPage page= SearchPlugin.getActivePage();
IResource resource= marker.getResource();
if (page == null || !(resource instanceof IFile))
@@ -64,4 +91,17 @@ class GotoMarkerAction extends Action {
fEditor= editor;
}
}
+
+ private void showWithoutReuse(IMarker marker) {
+ IWorkbenchPage page= SearchPlugin.getActivePage();
+ if (page == null)
+ return;
+
+ try {
+ page.openEditor(marker, false);
+ } catch (PartInitException ex) {
+ ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.openEditor.title"), SearchMessages.getString("Search.Error.openEditor.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return;
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java b/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
index fbedb8274..8e8c058ee 100644
--- a/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
+++ b/org.eclipse.search/search/org/eclipse/search/ui/SearchUI.java
@@ -133,7 +133,7 @@ public final class SearchUI {
}
/**
- a working set by name.
+ * Returns a working set by name.
*
* This method is for internal use only due to issue below. Once
* the issues is solved there will be an official API.
@@ -150,6 +150,23 @@ public final class SearchUI {
}
/**
+ * Returns the preference whether editors should be reused
+ * when showing search results.
+ *
+ * The goto action can decide to use or ignore this preference.
+ *
+ * <p>
+ * [Issue: Always returns <code>true</code> yet due to bug 6784.]
+ * </p>
+ *
+ * @param name the name the working set
+ * @return <code>true</code> if editors should be reused for showing search results
+ */
+ public static boolean reuseEditor() {
+ return true;
+ }
+
+ /**
* Block instantiation.
*/
private SearchUI() {

Back to the top