Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2009-02-02 16:27:44 +0000
committerMarkus Schorn2009-02-02 16:27:44 +0000
commitfb5c539efc8b0f3cb35cbc8c4414244be9dce84e (patch)
tree493701d513b0f82d5200277e8009da2ac2a07cf7 /core/org.eclipse.cdt.ui
parent251635be7d218b8a3c9a9ded359035e7b32097ba (diff)
downloadorg.eclipse.cdt-fb5c539efc8b0f3cb35cbc8c4414244be9dce84e.tar.gz
org.eclipse.cdt-fb5c539efc8b0f3cb35cbc8c4414244be9dce84e.tar.xz
org.eclipse.cdt-fb5c539efc8b0f3cb35cbc8c4414244be9dce84e.zip
Position trackers for non-local external files, bug 261912.
Diffstat (limited to 'core/org.eclipse.cdt.ui')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java39
1 files changed, 36 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
index bbd1ce17ea0..8e45922946a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@@ -9,11 +9,14 @@
* Markus Schorn - initial API and implementation
* Ed Swartz (Nokia)
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.viewsupport;
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -38,7 +41,6 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
/**
* An utility to open editors for references or elements.
- * @author markus.schorn@windriver.com
*/
public class EditorOpener {
@@ -70,6 +72,17 @@ public class EditorOpener {
te.selectAndReveal(region.getOffset(), region.getLength());
}
}
+
+ private static void selectRegion(URI locationURI, IRegion region, long timestamp, IEditorPart editor) {
+ if (editor instanceof ITextEditor) {
+ ITextEditor te= (ITextEditor) editor;
+ IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(locationURI, timestamp);
+ if (pc != null) {
+ region= pc.historicToActual(region);
+ }
+ te.selectAndReveal(region.getOffset(), region.getLength());
+ }
+ }
/**
* Opens the editor for an external location, selecting the given region.
@@ -86,6 +99,26 @@ public class EditorOpener {
CUIPlugin.log(e);
}
}
+
+ /**
+ * Opens the editor for an external EFS location, selecting the given region.
+ */
+ public static void openExternalFile(IWorkbenchPage page, URI locationURI, IRegion region, long timestamp, ICElement context) {
+ IEditorPart editor= null;
+ try {
+ editor= EditorUtility.openInEditor(locationURI, context);
+ if (timestamp == 0) {
+ try {
+ timestamp= EFS.getStore(locationURI).fetchInfo().getLastModified();
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ selectRegion(locationURI, region, timestamp, editor);
+ } catch (PartInitException e) {
+ CUIPlugin.log(e);
+ }
+ }
/**
* Opens the editor for an ICElement, selecting the id.

Back to the top