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>
''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
<eventsTableType
class="org.eclipse.tracecompass.internal.gdbtrace.ui.views.events.GdbEventsTable">
</eventsTableType>
+ <perspective
+ id="org.eclipse.tracecompass.gdbtrace.ui.perspective">
+ </perspective>
</type>
</extension>
<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
<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
<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>
<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>
</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"/>
<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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
</documentation>
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;
/** 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$
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);
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
*