summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAnsgar Radermacher2013-01-16 12:19:54 (EST)
committer Alexandre Montplaisir2013-01-17 11:43:34 (EST)
commit426d6e3be569b9e9604f81b13741155622504a0f (patch)
treea2f1901fe173bd1d7b9ac745acc959b693d23257
parent9aa720e5d4384393e1f3e1cbe9d315a7a7942c60 (diff)
downloadorg.eclipse.linuxtools-426d6e3be569b9e9604f81b13741155622504a0f.zip
org.eclipse.linuxtools-426d6e3be569b9e9604f81b13741155622504a0f.tar.gz
org.eclipse.linuxtools-426d6e3be569b9e9604f81b13741155622504a0f.tar.bz2
tmf: Support the model URI of a trace eventrefs/changes/99/9699/5
Fixes bug 396956. Change-Id: I03cc2b1b34760fe3d9f9c9139cd4c0dca77a6670 Reviewed-on: https://git.eclipse.org/r/9699 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Ansgar Radermacher <ansgar.radermacher@cea.fr> Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> IP-Clean: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfCustomAttributes.java25
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java71
-rw-r--r--lttng/org.eclipse.linuxtools.tmf/feature.xml2
6 files changed, 102 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfCustomAttributes.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfCustomAttributes.java
new file mode 100644
index 0000000..44ccdb4
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfCustomAttributes.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2013 Ericsson, Ecole Polytechnique de Montreal 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ansgar Radermacher - support for model URI
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.ctfadaptor;
+
+/**
+ * Set of constants defining common custom attribute names (key within hash table)
+ *
+ * @since 2.0
+ */
+public abstract class CtfCustomAttributes {
+ /**
+ * Model URI for traces related to EMF models
+ */
+ public final static String MODEL_URI_KEY = "model.emf.uri"; //$NON-NLS-1$
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
index 943a7c4..d2ce307 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
@@ -60,3 +60,5 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l
org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model,
org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets,
org.eclipse.linuxtools.tmf.ui.widgets.virtualtable
+Import-Package: org.eclipse.emf.common.util,
+ org.eclipse.emf.ecore
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
index 7f00f9c..428771c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
@@ -68,6 +68,7 @@ public class Messages extends NLS {
public static String TmfEventsTable_AddBookmarkDialogTitle;
public static String TmfEventsTable_ApplyPresetFilterMenuName;
public static String TmfEventsTable_ClearFiltersActionText;
+ public static String TmfEventsTable_NavigateToModelActionText;
public static String TmfEventsTable_ContentColumnHeader;
public static String TmfEventsTable_FilterHint;
public static String TmfEventsTable_HideRawActionText;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
index f804e50..5794b6f 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
@@ -50,6 +50,7 @@ TmfEventsTable_AddBookmarkDialogMessage=Enter Bookmark description:
TmfEventsTable_AddBookmarkDialogTitle=Add Bookmark
TmfEventsTable_ApplyPresetFilterMenuName=Apply preset filter...
TmfEventsTable_ClearFiltersActionText=Clear Filters
+TmfEventsTable_NavigateToModelActionText=Navigate to Associated Model Element
TmfEventsTable_ContentColumnHeader=Content
TmfEventsTable_FilterHint=<filter>
TmfEventsTable_HideRawActionText=Hide Raw
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
index b6079c0..9028830 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
@@ -11,6 +11,7 @@
* Patrick Tasse - Factored out from events view
* Francois Chouinard - Replaced Table by TmfVirtualTable
* Patrick Tasse - Filter implementation (inspired by www.eclipse.org/mat)
+ * Ansgar Radermacher - Support navigation to model URIs (Bug 396956)
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.viewers.events;
@@ -27,12 +28,17 @@ import java.util.regex.PatternSyntaxException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EValidator;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
@@ -44,6 +50,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -56,6 +63,8 @@ import org.eclipse.linuxtools.internal.tmf.ui.Messages;
import org.eclipse.linuxtools.internal.tmf.ui.dialogs.MultiLineInputDialog;
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfCustomAttributes;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
@@ -114,7 +123,9 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.themes.ColorUtil;
@@ -566,6 +577,56 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
}
};
+ final IAction navigateToEventAction = new Action(Messages.TmfEventsTable_NavigateToModelActionText) {
+ @Override
+ public void run() {
+
+ final TableItem items[] = fTable.getSelection();
+ if (items.length != 1) {
+ return;
+ }
+ final TableItem item = items[0];
+
+ final Object eventData = item.getData();
+ if (eventData instanceof CtfTmfEvent) {
+ String modelURI = ((CtfTmfEvent) eventData).getCustomAttribute(CtfCustomAttributes.MODEL_URI_KEY);
+
+ if (modelURI != null) {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ IFile file = null;
+ final URI uri = URI.createURI(modelURI);
+ if (uri.isPlatformResource()) {
+ IPath path = new Path(uri.toPlatformString(true));
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ } else if (uri.isFile() && !uri.isRelative()) {
+ file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
+ new Path(uri.toFileString()));
+ }
+
+ if (file != null) {
+ try {
+ /*
+ * create a temporary validation marker on the
+ * model file, remove it afterwards thus,
+ * navigation works with all model editors
+ * supporting the navigation to a marker
+ */
+ IMarker marker = file.createMarker(EValidator.MARKER);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, modelURI);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
+
+ IDE.openEditor(activePage, marker, OpenStrategy.activateOnOpen());
+ marker.delete();
+ }
+ catch (CoreException e) {
+ displayException(e);
+ }
+ }
+ }
+ }
+ }
+ };
final IAction showSearchBarAction = new Action(Messages.TmfEventsTable_ShowSearchBarActionText) {
@Override
public void run() {
@@ -647,6 +708,16 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
tablePopupMenu.add(showRawAction);
}
tablePopupMenu.add(new Separator());
+ if (item != null) {
+ // add navigation action, if event meta data contain a model URI
+ final Object eventData = item.getData();
+ if (eventData instanceof CtfTmfEvent) {
+ if (((CtfTmfEvent) eventData).listCustomAttributes().contains(CtfCustomAttributes.MODEL_URI_KEY)) {
+ tablePopupMenu.add(navigateToEventAction);
+ tablePopupMenu.add(new Separator());
+ }
+ }
+ }
tablePopupMenu.add(clearFiltersAction);
final ITmfFilterTreeNode[] savedFilters = FilterManager.getSavedFilters();
if (savedFilters.length > 0) {
diff --git a/lttng/org.eclipse.linuxtools.tmf/feature.xml b/lttng/org.eclipse.linuxtools.tmf/feature.xml
index a573238..b51a977 100644
--- a/lttng/org.eclipse.linuxtools.tmf/feature.xml
+++ b/lttng/org.eclipse.linuxtools.tmf/feature.xml
@@ -37,6 +37,8 @@
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.ui.navigator"/>
<import plugin="org.eclipse.ui.navigator.resources"/>
+ <import plugin="org.eclipse.emf.common" version="2.5.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.emf.ecore" version="2.5.0" match="greaterOrEqual"/>
</requires>
<plugin