diff options
author | Dani Megert | 2010-01-25 12:09:01 +0000 |
---|---|---|
committer | Dani Megert | 2010-01-25 12:09:01 +0000 |
commit | f1e0ed9087ddea2faa84135464b7b11bae5264a6 (patch) | |
tree | c24cd2d9793f0aa2f01e6dad60430f00c23c7756 | |
parent | 68d746db0b378433a87d5c0c51b8e5a1ae4cae49 (diff) | |
download | eclipse.platform.text-f1e0ed9087ddea2faa84135464b7b11bae5264a6.tar.gz eclipse.platform.text-f1e0ed9087ddea2faa84135464b7b11bae5264a6.tar.xz eclipse.platform.text-f1e0ed9087ddea2faa84135464b7b11bae5264a6.zip |
Fixed bug 187225: Rework opening of editors from Search viewv20100125-1300
3 files changed, 60 insertions, 8 deletions
diff --git a/org.eclipse.search/META-INF/MANIFEST.MF b/org.eclipse.search/META-INF/MANIFEST.MF index 2d56bbd34fb..f3a96552498 100644 --- a/org.eclipse.search/META-INF/MANIFEST.MF +++ b/org.eclipse.search/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.search; singleton:=true -Bundle-Version: 3.5.100.qualifier +Bundle-Version: 3.6.0.qualifier Bundle-Activator: org.eclipse.search.internal.ui.SearchPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java index 9480b18bd0e..919740b5750 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,6 +32,8 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; +import org.eclipse.core.resources.IFile; + import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; @@ -61,8 +63,11 @@ import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IMemento; import org.eclipse.ui.IWorkbenchCommandConstants; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.OpenAndLinkWithEditorHelper; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; @@ -78,6 +83,7 @@ import org.eclipse.search.internal.ui.CopyToClipboardAction; import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.internal.ui.SearchPluginImages; import org.eclipse.search.internal.ui.SelectAllAction; +import org.eclipse.search.internal.ui.text.EditorOpener; import org.eclipse.search.ui.IContextMenuConstants; import org.eclipse.search.ui.IQueryListener; import org.eclipse.search.ui.ISearchQuery; @@ -241,6 +247,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch private Integer fElementLimit; /** + * The editor opener. + * @since 3.6 + */ + private EditorOpener fEditorOpener= new EditorOpener(); + + /** * Flag (<code>value 1</code>) denoting flat list layout. */ public static final int FLAG_LAYOUT_FLAT = 1; @@ -412,6 +424,48 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } /** + * Opens an editor on the given file resource and tries to select the given offset and length. + * <p> + * If the page already has an editor open on the target object then that editor is brought to + * front; otherwise, a new editor is opened. If <code>activate == true</code> the editor will be + * activated. + * <p> + * + * @param page the workbench page in which the editor will be opened + * @param file the file to open + * @param offset the offset to select in the editor + * @param length the length to select in the editor + * @param activate if <code>true</code> the editor will be activated + * @return an open editor or <code>null</code> if an external editor was opened + * @throws PartInitException if the editor could not be initialized + * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String, boolean) + * @since 3.6 + */ + protected final IEditorPart openAndSelect(IWorkbenchPage page, IFile file, int offset, int length, boolean activate) throws PartInitException { + return fEditorOpener.openAndSelect(page, file, offset, length, activate); + } + + /** + * Opens an editor on the given file resource. + * <p> + * If the page already has an editor open on the target object then that editor is brought to + * front; otherwise, a new editor is opened. If <code>activate == true</code> the editor will be + * activated. + * <p> + * + * @param page the workbench page in which the editor will be opened + * @param file the file to open + * @param activate if <code>true</code> the editor will be activated + * @return an open editor or <code>null</code> if an external editor was opened + * @throws PartInitException if the editor could not be initialized + * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String, boolean) + * @since 3.6 + */ + protected final IEditorPart open(IWorkbenchPage page, IFile file, boolean activate) throws PartInitException { + return fEditorOpener.open(page, file, activate); + } + + /** * This method is called whenever the set of matches for the given elements * changes. This method is guaranteed to be called in the UI thread. Note * that this notification is asynchronous. i.e. further changes may have diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java index 945d9e6e152..6496befec47 100644 --- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java +++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,8 +112,6 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt private SortAction fSortByNameAction; private SortAction fSortByPathAction; - private EditorOpener fEditorOpener= new EditorOpener(); - private static final String[] SHOW_IN_TARGETS= new String[] { IPageLayout.ID_RES_NAV }; private static final IShowInTargetList SHOW_IN_TARGET_LIST= new IShowInTargetList() { @@ -169,9 +167,9 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt IFile file= (IFile) match.getElement(); IWorkbenchPage page= getSite().getPage(); if (offset >= 0 && length != 0) { - fEditorOpener.openAndSelect(page, file, offset, length, activate); + openAndSelect(page, file, offset, length, activate); } else { - fEditorOpener.open(page, file, activate); + open(page, file, activate); } } @@ -181,7 +179,7 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt if (firstElement instanceof IFile) { if (getDisplayedMatchCount(firstElement) == 0) { try { - fEditorOpener.open(getSite().getPage(), (IFile) firstElement, false); + open(getSite().getPage(), (IFile)firstElement, false); } catch (PartInitException e) { ErrorDialog.openError(getSite().getShell(), SearchMessages.FileSearchPage_open_file_dialog_title, SearchMessages.FileSearchPage_open_file_failed, e.getStatus()); } |