Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 0000000000..44ccdb45a4
--- /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 943a7c4a03..d2ce307d45 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 7f00f9c5ee..428771cfc3 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 f804e502f4..5794b6fcd5 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 b6079c022e..9028830e06 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 a573238e1e..b51a977df3 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

Back to the top