aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Fraxino Araujo2014-06-18 13:43:45 (EDT)
committerRodrigo Fraxino Araujo2014-06-20 13:32:27 (EDT)
commit5065d0888826959d10a358925c62b9234baf1d09 (patch)
tree56b6589db071eb0c7512c5d0a196fa1791494d1e
parent7c8c7f5e09fff1f7a1432f2bd3638e257b2b4e3b (diff)
downloadorg.eclipse.linuxtools-5065d0888826959d10a358925c62b9234baf1d09.zip
org.eclipse.linuxtools-5065d0888826959d10a358925c62b9234baf1d09.tar.gz
org.eclipse.linuxtools-5065d0888826959d10a358925c62b9234baf1d09.tar.bz2
oprofile: fix double click to source code in synchronized projectsrefs/changes/99/28699/7
Change-Id: Ib90dd72473ad389980719bdac14fb78911a8d6f5 Reviewed-on: https://git.eclipse.org/r/28699 Tested-by: Hudson CI Reviewed-by: Rodrigo Fraxino Araujo <rfaraujo@linux.vnet.ibm.com> Tested-by: Rodrigo Fraxino Araujo <rfaraujo@linux.vnet.ibm.com>
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDoubleClickListener.java17
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF3
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.ui/pom.xml2
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java36
4 files changed, 54 insertions, 4 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDoubleClickListener.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDoubleClickListener.java
index b805823..146f0ee 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDoubleClickListener.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDoubleClickListener.java
@@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.oprofile.ui.view;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
import org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement;
import org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent;
import org.eclipse.linuxtools.oprofile.ui.model.UiModelImage;
@@ -65,13 +68,23 @@ public class OprofileViewDoubleClickListener implements IDoubleClickListener {
// get file name from the parent sample
final String fileName = sample.getFile();
- ProfileUIUtils.openEditorAndSelect(fileName, line);
+ ProfileUIUtils.openEditorAndSelect(fileName, line, getProject());
}
} catch (BadLocationException e1) {
e1.printStackTrace();
} catch (PartInitException e2) {
e2.printStackTrace();
- }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
+ /**
+ * return the project
+ * @since 2.0
+ */
+ protected IProject getProject() {
+ return Oprofile.OprofileProject.getProject();
+ }
+
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF
index 1d8fa79..2d5c891 100644
--- a/profiling/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF
+++ b/profiling/org.eclipse.linuxtools.profiling.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.eclipse.linuxtools.profiling.ui;singleton:=true
-Bundle-Version: 3.0.0.qualifier
+Bundle-Version: 3.1.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.internal.profiling.ui.ProfileUIPlugin
Bundle-Vendor: %Bundle-Vendor.0
Require-Bundle: org.eclipse.ui,
@@ -23,5 +23,6 @@ Import-Package: org.eclipse.cdt.core,
org.eclipse.debug.ui,
org.eclipse.debug.ui.sourcelookup,
org.eclipse.jface.text,
+ org.eclipse.linuxtools.profiling.launch,
org.eclipse.ui.ide,
org.eclipse.ui.texteditor
diff --git a/profiling/org.eclipse.linuxtools.profiling.ui/pom.xml b/profiling/org.eclipse.linuxtools.profiling.ui/pom.xml
index 178b3f2..e24b2c7 100644
--- a/profiling/org.eclipse.linuxtools.profiling.ui/pom.xml
+++ b/profiling/org.eclipse.linuxtools.profiling.ui/pom.xml
@@ -18,7 +18,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.profiling.ui</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools Profiling UI Plug-in</name>
diff --git a/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java b/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
index fdd3389..0d48551 100644
--- a/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
+++ b/profiling/org.eclipse.linuxtools.profiling.ui/src/org/eclipse/linuxtools/profiling/ui/ProfileUIUtils.java
@@ -33,6 +33,7 @@ import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -46,6 +47,8 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.linuxtools.internal.profiling.ui.ProfileUIPlugin;
+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
@@ -86,6 +89,39 @@ public class ProfileUIUtils {
}
}
+ /**
+ * Open a file in the Editor at the specified offset, highlighting the given length
+ *
+ * @param path : Absolute path pointing to the file which will be opened.
+ * @param line - line number to select, 0 to not select a line
+ * @param project - current project object
+ * @throws BadLocationException - Line number not valid in file
+ * @throws PartInitException if the editor could not be initialized
+ * @throws CoreException if the proxy cannot be initialized
+ * @since 3.1
+ */
+ public static void openEditorAndSelect(String path, int line, IProject project) throws PartInitException, BadLocationException, CoreException {
+ IWorkbenchPage activePage = ProfileUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IRemoteFileProxy proxy = null;
+ proxy = RemoteProxyManager.getInstance().getFileProxy(project);
+ IFileStore file = proxy.getResource(path);
+ if (file.fetchInfo().exists()) {
+ IEditorPart editor = IDE.openEditorOnFileStore(activePage, file);
+ if (editor instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) editor;
+
+ if (line > 0) {
+ IDocumentProvider provider = textEditor.getDocumentProvider();
+ IDocument document = provider.getDocument(textEditor.getEditorInput());
+
+ int start = document.getLineOffset(line - 1); //zero-indexed
+ textEditor.selectAndReveal(start, 0);
+ }
+ }
+ }
+ }
+
+
/**
* Opens an editor on the given file and selects the line.
* @param file The file to open.