1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 05:15:43 +02:00

Fixed opening search external markers.

This commit is contained in:
Bogdan Gheorghe 2004-06-22 05:03:56 +00:00
parent 726c615400
commit 0c2b43cb02
3 changed files with 23 additions and 2 deletions

View file

@ -1,3 +1,6 @@
2004-06-21 Bogdan Gheorghe
Fixed opening search external markers.
2004-06-21 Alain Magloire 2004-06-21 Alain Magloire
Big Patch from Vladimir Hirsl Big Patch from Vladimir Hirsl

View file

@ -38,6 +38,7 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.search.ui.IContextMenuConstants; import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.SearchUI; import org.eclipse.search.ui.SearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match; import org.eclipse.search.ui.text.Match;
@ -174,7 +175,7 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException { private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException {
try { try {
IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER); IMarker marker= file.createMarker(NewSearchUI.SEARCH_MARKER);
HashMap attributes= new HashMap(4); HashMap attributes= new HashMap(4);
attributes.put(IMarker.CHAR_START, new Integer(offset)); attributes.put(IMarker.CHAR_START, new Integer(offset));
attributes.put(IMarker.CHAR_END, new Integer(offset + length)); attributes.put(IMarker.CHAR_END, new Integer(offset + length));
@ -269,7 +270,7 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
canonicalPath = tempFile.getCanonicalPath(); canonicalPath = tempFile.getCanonicalPath();
} catch (IOException e1) {} } catch (IOException e1) {}
if (canonicalPath != null){ if (canonicalPath != null && (!(originalFile.isLinked()))){
IPath path = new Path(canonicalPath); IPath path = new Path(canonicalPath);
originalFile = CUIPlugin.getWorkspace().getRoot().getFileForLocation(path); originalFile = CUIPlugin.getWorkspace().getRoot().getFileForLocation(path);
} }

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.internal.ui.cview.CViewMessages;
import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages; import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput; import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
@ -28,6 +29,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
@ -115,6 +117,11 @@ public class EditorUtility {
} }
private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException { private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
if (!file.getProject().isAccessible()){
closedProject();
return null;
}
if (file != null) { if (file != null) {
try { try {
File tempFile = file.getRawLocation().toFile(); File tempFile = file.getRawLocation().toFile();
@ -140,6 +147,16 @@ public class EditorUtility {
return null; return null;
} }
/**
*
*/
private static void closedProject() {
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
errorMsg.setText("ARGHH!"); //$NON-NLS-1$
errorMsg.setMessage ("You tried to open that which cannot be opened..."); //$NON-NLS-1$
errorMsg.open();
}
private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException { private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
if (input != null) { if (input != null) {
IWorkbenchPage p= CUIPlugin.getActivePage(); IWorkbenchPage p= CUIPlugin.getActivePage();