tmf: Add perspective element to trace type UI extension point
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 20 Jan 2017 18:16:16 +0000 (13:16 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 2 Feb 2017 18:08:53 +0000 (13:08 -0500)
The 'perspective' element is added to the tracetypeui extension point.

The method TmfTraceTypeUIUtils.getPerspectiveId(ITmfTrace) is added.

The associated perspective is set for some plug-in extensions.

Change-Id: Ib62add83a99cd50a6b56b4e0099705ec0f88d168
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/89629
Reviewed-by: Hudson CI
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
doc/org.eclipse.tracecompass.doc.dev/doc/Developer-Guide.mediawiki
gdbtrace/org.eclipse.tracecompass.gdbtrace.ui/plugin.xml
lttng/org.eclipse.tracecompass.lttng2.kernel.ui/plugin.xml
pcap/org.eclipse.tracecompass.tmf.pcap.ui/plugin.xml
tmf/org.eclipse.tracecompass.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetypeui.exsd
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceTypeUIUtils.java

index b99decb16465ec5945abe05c2d0c673e82ee9334..d52c03e2b9cc425b4a21f06d6eca477c4fe105b8 100644 (file)
@@ -138,6 +138,25 @@ can be defined. See the class
 ''org.eclipse.tracecompass.internal.gdbtrace.ui.views.events.GdbEventsTable''
 for an example implementation.
 
+=== Perspective ===
+
+The  '''perspective''' element of the '''org.eclipse.linuxtools.tmf.ui.tracetypeui'''
+extension point allows for configuring the default perspective associated with a
+trace type. If omitted, the current perspective will be used.
+
+To configure an associated perspective, first add the
+'''perspective''' element to the trace type in the extension definition.
+This can be done by selecting the trace type in the plug-in manifest editor.
+Then click the right mouse button and select '''New -> perspective''' in the
+context sensitive menu. Then select the newly added element and select the
+''id'' text field on the right side of the manifest editor. Enter the associated
+perspective id, which can be found in the '''org.eclipse.ui.perspectives'''
+extension that defines the perspective.
+
+By using this element, the workbench will switch to the associated perspective
+when a trace of this trace type is opened. This behavior can be controlled by a
+user dialog or preference.
+
 == Other Considerations ==
 
 Other views and components may provide additional features that are active only
index 851ef30887deb30c0cd1a988b96db93caed89a28..20bae5042b5ee2be67f356064128f24af025da84 100644 (file)
@@ -92,6 +92,9 @@
          <eventsTableType
                class="org.eclipse.tracecompass.internal.gdbtrace.ui.views.events.GdbEventsTable">
          </eventsTableType>
+         <perspective
+               id="org.eclipse.tracecompass.gdbtrace.ui.perspective">
+         </perspective>
       </type>
    </extension>
 
index d730444d95f7137f79c2a30b194ea7c626bd0876..441c8d7f45e36f38aca8ffa9ba8f719836d33f20 100644 (file)
@@ -52,6 +52,9 @@
       <type
             icon="icons/obj16/garland16.png"
             tracetype="org.eclipse.linuxtools.lttng2.kernel.tracetype">
+         <perspective
+               id="org.eclipse.linuxtools.lttng2.kernel.ui.perspective">
+         </perspective>
       </type>
    </extension>
    <extension
index 84ccf311f5b9f62489e0ad5b38e482d4211c76b4..ceb4b75e43ac788329f6cefe71638732a476b9c0 100644 (file)
@@ -6,6 +6,9 @@
       <type
             icon="icons/pcap.png"
             tracetype="org.eclipse.linuxtools.tmf.pcap.core.pcaptrace">
+         <perspective
+               id="org.eclipse.linuxtools.tmf.pcap.ui.perspective.network">
+         </perspective>
       </type>
    </extension>
    <extension
index 01f14a51d88a62c08ffcf12801543e15c9ed2154..cede33afa434de8fdf69ed4626bc48dca6cbb4b2 100644 (file)
@@ -58,6 +58,7 @@
          <sequence>
             <element ref="eventsTableType" minOccurs="0" maxOccurs="1"/>
             <element ref="defaultEditor" minOccurs="0" maxOccurs="1"/>
+            <element ref="perspective" minOccurs="0" maxOccurs="1"/>
          </sequence>
          <attribute name="tracetype" type="string" use="required">
             <annotation>
@@ -92,6 +93,7 @@
          <sequence>
             <element ref="eventsTableType" minOccurs="0" maxOccurs="1"/>
             <element ref="defaultEditor" minOccurs="0" maxOccurs="1"/>
+            <element ref="perspective" minOccurs="0" maxOccurs="1"/>
          </sequence>
          <attribute name="tracetype" type="string" use="required">
             <annotation>
@@ -157,6 +159,25 @@ If empty, the default events editor will be used.
       </complexType>
    </element>
 
+   <element name="perspective">
+      <annotation>
+         <documentation>
+            The associated perspective to use for this trace type.
+If omitted, the current perspective will be used.
+         </documentation>
+      </annotation>
+      <complexType>
+         <attribute name="id" type="string" use="default" value="org.eclipse.linuxtools.tmf.ui.perspective">
+            <annotation>
+               <documentation>
+                  The associated perspective to use for this trace type.
+If empty, the current perspective will be used.
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
    <annotation>
       <appinfo>
          <meta.section type="since"/>
@@ -213,7 +234,7 @@ If empty, the default events editor will be used.
          <meta.section type="copyright"/>
       </appinfo>
       <documentation>
-         Copyright (c) 2014 Ericsson
+         Copyright (c) 2014, 2017 Ericsson
 
 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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
       </documentation>
index 9707ac26b4e451ae600ef1b9d693aeb4cb23774d..dd2cade7f9e940a7fe5404d9a1f406210bb730fe 100644 (file)
@@ -42,6 +42,7 @@ import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
 import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType.TraceElementType;
 import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
 import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable;
 import org.osgi.framework.Bundle;
 
@@ -73,6 +74,14 @@ public final class TmfTraceTypeUIUtils {
     /** Extension point element 'Event Table Columns' */
     public static final String EVENT_TABLE_COLUMNS = "eventTableColumns"; //$NON-NLS-1$
 
+    /** Extension point element 'perspective'
+     * @since 2.3*/
+    public static final String PERSPECTIVE_ELEM = "perspective"; //$NON-NLS-1$
+
+    /** Extension point attribute 'id'
+     * @since 2.3*/
+    public static final String ID_ATTR = "id"; //$NON-NLS-1$
+
     /** Extension point attribute 'tracetype' */
     public static final String TRACETYPE_ATTR = "tracetype"; //$NON-NLS-1$
 
@@ -292,7 +301,8 @@ public final class TmfTraceTypeUIUtils {
             return null;
         }
 
-        for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(TraceElementType.TRACE)) {
+        TraceElementType elType = (trace instanceof TmfExperiment) ? TraceElementType.EXPERIMENT : TraceElementType.TRACE;
+        for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(elType)) {
             if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(traceType)) {
                 final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceTypeUIUtils.EVENTS_TABLE_TYPE_ELEM);
 
@@ -320,6 +330,40 @@ public final class TmfTraceTypeUIUtils {
         return null;
     }
 
+    /**
+     * Get the perspective id specified by the trace type's extension point, if
+     * there is one.
+     *
+     * @param trace
+     *            The trace for which we want the perspective id.
+     * @return The corresponding perspective id, or 'null' if this trace type
+     *         did not specify any.
+     * @since 2.3
+     */
+    public static @Nullable String getPerspectiveId(ITmfTrace trace) {
+        final String traceType = getTraceType(trace);
+        if (traceType == null) {
+            return null;
+        }
+
+        TraceElementType elType = (trace instanceof TmfExperiment) ? TraceElementType.EXPERIMENT : TraceElementType.TRACE;
+        for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(elType)) {
+            if (ce.getAttribute(TRACETYPE_ATTR).equals(traceType)) {
+                final IConfigurationElement[] perspectiveCE = ce.getChildren(PERSPECTIVE_ELEM);
+
+                if (perspectiveCE.length != 1) {
+                    break;
+                }
+                final String perspectiveId = perspectiveCE[0].getAttribute(ID_ATTR);
+                if (!perspectiveId.isEmpty()) {
+                    return perspectiveId;
+                }
+                break;
+            }
+        }
+        return null;
+    }
+
     /**
      * Get the trace type (as a String) for the given trace
      *
This page took 0.03378 seconds and 5 git commands to generate.