From: Alexandre Montplaisir Date: Thu, 20 Feb 2014 22:30:33 +0000 (-0500) Subject: tmf: Move the tmftracetype extension point to tmf.core X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=a926c25ca7e061247e83da28339c473fc7a6c86a;p=deliverable%2Ftracecompass.git tmf: Move the tmftracetype extension point to tmf.core Split the current "tmf.ui.tracetype" extension point into a tmf.core.tracetype and tmf.ui.tracetypeui. "tracetypeui" refers to the ID of the "tracetype", to add UI elements like type-specific icon and events editor. This separation makes it possible to unit-test the trace validation without depending on UI/SWTBot tests. We will also eventually be able to handle trace opening/validation in completely headless mode. Change-Id: I227a199d1dddf62ad07b60392793b4694d0ec2de Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/21421 Tested-by: Hudson CI Reviewed-by: Marc-Andre Laperle IP-Clean: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- diff --git a/org.eclipse.linuxtools.gdbtrace.core/build.properties b/org.eclipse.linuxtools.gdbtrace.core/build.properties index 5e7e2cbe1d..5140553a31 100644 --- a/org.eclipse.linuxtools.gdbtrace.core/build.properties +++ b/org.eclipse.linuxtools.gdbtrace.core/build.properties @@ -15,5 +15,6 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ plugin.properties,\ - about.html + about.html,\ + plugin.xml src.includes = about.html diff --git a/org.eclipse.linuxtools.gdbtrace.core/plugin.xml b/org.eclipse.linuxtools.gdbtrace.core/plugin.xml new file mode 100644 index 0000000000..06b4921349 --- /dev/null +++ b/org.eclipse.linuxtools.gdbtrace.core/plugin.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/org.eclipse.linuxtools.gdbtrace.ui/plugin.xml b/org.eclipse.linuxtools.gdbtrace.ui/plugin.xml index f5eda173e7..b6613ea625 100644 --- a/org.eclipse.linuxtools.gdbtrace.ui/plugin.xml +++ b/org.eclipse.linuxtools.gdbtrace.ui/plugin.xml @@ -18,24 +18,6 @@ name="%perspective.name"> - - - - - - - - + + + + + + diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/plugin.properties b/org.eclipse.linuxtools.lttng2.kernel.core/plugin.properties index 1b3c83845f..d9003d47e4 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/plugin.properties +++ b/org.eclipse.linuxtools.lttng2.kernel.core/plugin.properties @@ -14,4 +14,5 @@ Bundle-Vendor = Eclipse Linux Tools Bundle-Name = Linux Tools LTTng Kernel Analysis Core Plug-in +tracetype.type.kernel = LTTng Kernel Trace analysis.lttngkernel = LTTng Kernel Analysis diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/plugin.xml b/org.eclipse.linuxtools.lttng2.kernel.core/plugin.xml index cf7aefb756..278e8222f5 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/plugin.xml +++ b/org.eclipse.linuxtools.lttng2.kernel.core/plugin.xml @@ -1,6 +1,17 @@ + + + + - - - - - - + + + + + + diff --git a/org.eclipse.linuxtools.lttng2.ust.core/build.properties b/org.eclipse.linuxtools.lttng2.ust.core/build.properties index ddfbe617f6..001f6323b5 100644 --- a/org.eclipse.linuxtools.lttng2.ust.core/build.properties +++ b/org.eclipse.linuxtools.lttng2.ust.core/build.properties @@ -15,5 +15,6 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ about.html,\ - plugin.properties + plugin.properties,\ + plugin.xml src.includes = about.html diff --git a/org.eclipse.linuxtools.lttng2.ust.core/plugin.properties b/org.eclipse.linuxtools.lttng2.ust.core/plugin.properties index 4b3a353a3b..b5e6b597ef 100644 --- a/org.eclipse.linuxtools.lttng2.ust.core/plugin.properties +++ b/org.eclipse.linuxtools.lttng2.ust.core/plugin.properties @@ -12,4 +12,6 @@ #Properties file for org.eclipse.linuxtools.lttng2.ust.core Bundle-Vendor = Eclipse Linux Tools -Bundle-Name = Linux Tools LTTng Userspace Tracer Analysis Core Plug-in \ No newline at end of file +Bundle-Name = Linux Tools LTTng Userspace Tracer Analysis Core Plug-in + +tracetype.type.ust = LTTng UST Trace diff --git a/org.eclipse.linuxtools.lttng2.ust.core/plugin.xml b/org.eclipse.linuxtools.lttng2.ust.core/plugin.xml new file mode 100644 index 0000000000..5bcebafc86 --- /dev/null +++ b/org.eclipse.linuxtools.lttng2.ust.core/plugin.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/org.eclipse.linuxtools.lttng2.ust.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng2.ust.ui/META-INF/MANIFEST.MF index ac0be4a209..1b78306d29 100644 --- a/org.eclipse.linuxtools.lttng2.ust.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng2.ust.ui/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.ui, org.eclipse.linuxtools.lttng2.ust.core;bundle-version="3.0.0", org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0", - org.eclipse.linuxtools.tmf.ui + org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0" Export-Package: org.eclipse.linuxtools.internal.lttng2.ust.ui;x-friends:="org.eclipse.linuxtools.lttng2.ust.ui.tests", org.eclipse.linuxtools.internal.lttng2.ust.ui.views.memusage;x-friends:="org.eclipse.linuxtools.lttng2.ust.ui.tests", org.eclipse.linuxtools.lttng2.ust.ui.analysis.callstack, diff --git a/org.eclipse.linuxtools.lttng2.ust.ui/plugin.xml b/org.eclipse.linuxtools.lttng2.ust.ui/plugin.xml index a756b42ceb..fb339882d5 100644 --- a/org.eclipse.linuxtools.lttng2.ust.ui/plugin.xml +++ b/org.eclipse.linuxtools.lttng2.ust.ui/plugin.xml @@ -2,15 +2,10 @@ + point="org.eclipse.linuxtools.tmf.ui.tracetypeui"> + tracetype="org.eclipse.linuxtools.lttng2.ust.tracetype"> + + + + + + + + diff --git a/org.eclipse.linuxtools.tmf.core/plugin.properties b/org.eclipse.linuxtools.tmf.core/plugin.properties index 032b57e3aa..3b0a7ae22e 100644 --- a/org.eclipse.linuxtools.tmf.core/plugin.properties +++ b/org.eclipse.linuxtools.tmf.core/plugin.properties @@ -13,3 +13,7 @@ #Properties file for org.eclipse.linuxtools.tmf.core Bundle-Vendor = Eclipse Linux Tools Bundle-Name = Linux Tools TMF Core Plug-in + +# CTF trace type +tracetype.category.ctf = Common Trace Format +tracetype.type.ctf = Generic CTF Trace diff --git a/org.eclipse.linuxtools.tmf.core/plugin.xml b/org.eclipse.linuxtools.tmf.core/plugin.xml index 6fce198ca7..e48f58b236 100644 --- a/org.eclipse.linuxtools.tmf.core/plugin.xml +++ b/org.eclipse.linuxtools.tmf.core/plugin.xml @@ -1,17 +1,34 @@ + + + - + + + + + + diff --git a/org.eclipse.linuxtools.tmf.core/schema/org.eclipse.linuxtools.tmf.core.tracetype.exsd b/org.eclipse.linuxtools.tmf.core/schema/org.eclipse.linuxtools.tmf.core.tracetype.exsd new file mode 100644 index 0000000000..61e2a51d54 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core/schema/org.eclipse.linuxtools.tmf.core.tracetype.exsd @@ -0,0 +1,183 @@ + + + + + + + + + This extension point is used to contribute new trace types to the generic components of the TMF framework. + + + + + + + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + a unique name that will be used to identify this category + + + + + + + a translatable name that will be used in the UI for this category + + + + + + + + + + + + The unique ID that identifies this trace type. + + + + + + + The type name as it is displayed to the end user. + + + + + + + An optional attribute that is composed of the category ID. The referenced category must be declared in a corresponding category element. + + + + + + + + + + The fully qualified name of a class that implements the <samp>ITmfTrace</samp> interface. + + + + + + + + + + The fully qualified name of a class that implements the <samp>ITmfEvent</samp> interface + + + + + + + + + + Indicates whether the trace type is for traces that are directories (true) or files (false) + + + + + + + + + + + + 3.0 + + + + + + + + + Example use of the tmftracetype extension point for generic CTF traces (CtfTmfTrace): + +<extension + point="org.eclipse.linuxtools.tmf.core.tracetype"> + <category + id="org.eclipse.linuxtools.tmf.core.category.ctf" + name="Common Trace Format"> + </category> + <type + category="org.eclipse.linuxtools.tmf.core.category.ctf" + event_type="org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent" + id="org.eclipse.linuxtools.tmf.core.type.ctf" + name="Generic CTF Trace" + trace_type="org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace"> + </type> +</extension> + + + + + + + + + Trace types using this extension point have to specify the two following classes: + +* trace_type: Has to implement ITmfTrace. It's *highly* recommend to extend 'TmfTrace' to get default implementations. +* event_type: Has to implement ITmfEvent. Once again, TmfEvent provides a reference implementation that should work in most cases. + + + + + + + + + + Copyright (c) 2014 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> + + + + diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java index f67044b946..e3fa565ace 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java @@ -23,12 +23,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; -import org.eclipse.linuxtools.internal.tmf.core.Activator; -import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTrace; import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition; import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomXmlTrace; @@ -50,7 +47,7 @@ public final class TmfTraceType { private static final char SEPARATOR = ':'; /** Extension point ID */ - public static final String TMF_TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.ui.tracetype"; //$NON-NLS-1$ + public static final String TMF_TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.core.tracetype"; //$NON-NLS-1$ /** Extension point element 'Category' */ public static final String CATEGORY_ELEM = "category"; //$NON-NLS-1$ @@ -58,15 +55,6 @@ public final class TmfTraceType { /** Extension point element 'Type' */ public static final String TYPE_ELEM = "type"; //$NON-NLS-1$ - /** Extension point element 'Default editor' */ - public static final String DEFAULT_EDITOR_ELEM = "defaultEditor"; //$NON-NLS-1$ - - /** Extension point element 'Events table type' */ - public static final String EVENTS_TABLE_TYPE_ELEM = "eventsTableType"; //$NON-NLS-1$ - - /** Extension point element 'Statistics viewer type' */ - public static final String STATISTICS_VIEWER_ELEM = "statisticsViewerType"; //$NON-NLS-1$ - /** Extension point attribute 'ID' */ public static final String ID_ATTR = "id"; //$NON-NLS-1$ @@ -82,12 +70,6 @@ public final class TmfTraceType { /** Extension point attribute 'event_type' */ public static final String EVENT_TYPE_ATTR = "event_type"; //$NON-NLS-1$ - /** Extension point attribute 'icon' */ - public static final String ICON_ATTR = "icon"; //$NON-NLS-1$ - - /** Extension point attribute 'class' */ - public static final String CLASS_ATTR = "class"; //$NON-NLS-1$ - /** Extension point attribute 'isDirectory' */ public static final String IS_DIR_ATTR = "isDirectory"; //$NON-NLS-1$ @@ -129,45 +111,6 @@ public final class TmfTraceType { return ""; //$NON-NLS-1$ } - /** - * Retrieves and instantiates an element's object based on his plug-in - * definition for a specific trace type. - * - * The element's object is instantiated using its 0-argument constructor. - * - * @param resource - * The resource where to find the information about the trace - * properties - * @param element - * The name of the element to find under the trace type - * definition - * @return a new Object based on his definition in plugin.xml, or null if no - * definition was found - */ - public static Object getTraceTypeElement(IResource resource, String element) { - try { - if (resource != null) { - String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE); - /* - * Search in the configuration if there is any viewer specified - * for this kind of trace type. - */ - for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { - if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) { - IConfigurationElement[] viewerCE = ce.getChildren(element); - if (viewerCE.length != 1) { - break; - } - return viewerCE[0].createExecutableExtension(TmfTraceType.CLASS_ATTR); - } - } - } - } catch (CoreException e) { - Activator.logError("Error creating the element from the resource", e); //$NON-NLS-1$ - } - return null; - } - /** * Retrieves all configuration elements from the platform extension registry * for the trace type extension. diff --git a/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml b/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml index 4b17ad330c..5e7f3a6a3f 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml +++ b/org.eclipse.linuxtools.tmf.ui.tests/plugin.xml @@ -63,31 +63,6 @@ - - - - - - - - - - - + @@ -1615,22 +1615,6 @@ type="org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement"> - - - - - - - + + + + diff --git a/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd b/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd deleted file mode 100644 index 1644017dd6..0000000000 --- a/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - - - This extension point is used to contribute new trace types to the generic components of the TMF framework. - - - - - - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - a unique name that will be used to identify this category - - - - - - - a translatable name that will be used in the UI for this category - - - - - - - - - - - - - - - - - The unique ID that identifies this trace type. - - - - - - - The type name as it is displayed to the end user. - - - - - - - An optional attribute that is composed of the category ID. The referenced category must be declared in a corresponding category element. - - - - - - - - - - The fully qualified name of a class that implements the <samp>ITmfTrace</samp> interface. - - - - - - - - - - The fully qualified name of a class that implements the <samp>ITmfEvent</samp> interface - - - - - - - - - - The icon associated to the trace type. - - - - - - - - - - Indicates whether the trace type is for traces that are directories (true) or files (false) - - - - - - - - - - The default editor to use for this trace type. -If omitted, the default events editor will be used. - - - - - - - The id of the editor to use for this trace type. -If empty, the default events editor will be used. - - - - - - - - - - The events table to use for this trace type. -If omitted, the default events table will be used. - - - - - - - The fully qualified name of a class that extends <samp>TmfEventsTable</samp> . -If empty, the default events table will be used. - - - - - - - - - - - - - The statistics viewer to use for this trace type. -If omitted, the default statistics viewer will be used. - - - - - - - The fully qualified name of a class that extends <samp>TmfStatisticsViewer</samp> . -If empty, the default statistics viewer will be used. - - - - - - - - - - - - - - - 0.9 - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetypeui.exsd b/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetypeui.exsd new file mode 100644 index 0000000000..d8c55fde05 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetypeui.exsd @@ -0,0 +1,178 @@ + + + + + + + + + This extension point is used to assign UI elements to a trace type defined by org.eclipse.linuxtools.tmf.core.tracetype. + + + + + + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + + + + + The unique ID that identifies this trace type. + + + + + + + + + + The icon associated to the trace type. + + + + + + + + + + + + + The events table to use for this trace type. +If omitted, the default events table will be used. + + + + + + + The fully qualified name of a class that extends <samp>TmfEventsTable</samp> . +If empty, the default events table will be used. + + + + + + + + + + + + + The default editor to use for this trace type. +If omitted, the default events editor will be used. + + + + + + + The id of the editor to use for this trace type. +If empty, the default events editor will be used. + + + + + + + + + + + + 3.0 + + + + + + + + + Example use of the extension point: the GDB trace type, which specifies a custom icon and a custom editor. The 'type/tracetype' element has to point to an existing tmf.core.tracetype extension! + +<extension + point="org.eclipse.linuxtools.tmf.ui.tracetypeui"> + <type + icon="icons/obj16/gdb_icon16.png" + tracetype="org.eclipse.linuxtools.gdbtrace.core.type.gdb"> + <eventsTableType + class="org.eclipse.linuxtools.internal.gdbtrace.ui.views.events.GdbEventsTable"> + </eventsTableType> + </type> +</extension> + + + + + + + + + The 'eventsTableType/class' element has to extend TmfEventsTable. It is optional however ; if it is not specified, the default TmfEventsTable will be used. + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + Copyright (c) 2014 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> + + + + diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java index 11dd13763a..0869fdd5cf 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeContributionItem.java @@ -33,6 +33,7 @@ import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomXmlTrace; import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomXmlTraceDefinition; import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceTypeUIUtils; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; @@ -107,11 +108,17 @@ public class SelectTraceTypeContributionItem extends CompoundContributionItem { if (ce.getName().equals(TmfTraceType.TYPE_ELEM)) { String traceBundle = ce.getContributor().getName(); String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); - String traceIcon = ce.getAttribute(TmfTraceType.ICON_ATTR); String label = ce.getAttribute(TmfTraceType.NAME_ATTR).replaceAll("&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ boolean selected = selectedTraceTypes.contains(traceTypeId); MenuManager subMenu = categoriesMap.get(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)); + /* Get the icon from the tmftracetypeui extension, if it exists */ + String traceIcon = null; + IConfigurationElement uiCE = TmfTraceTypeUIUtils.getTraceUIAttributes(traceTypeId); + if (uiCE != null) { + traceIcon = uiCE.getAttribute(TmfTraceTypeUIUtils.ICON_ATTR); + } + addContributionItem(list, traceBundle, traceTypeId, traceIcon, label, selected, subMenu); } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index a01f050905..d4121ccced 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -41,7 +41,6 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable; import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTrace; import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomXmlTrace; -import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal; @@ -58,6 +57,7 @@ import org.eclipse.linuxtools.tmf.ui.project.model.TmfOpenTraceHelper; import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry; import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceTypeUIUtils; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -318,13 +318,13 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus if (traceType.startsWith(CustomXmlTrace.class.getCanonicalName())) { return new CustomEventsTable(((CustomXmlTrace) fTrace).getDefinition(), parent, cacheSize); } - for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) { - if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) { - final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM); + for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements()) { + if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(traceType)) { + final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceTypeUIUtils.EVENTS_TABLE_TYPE_ELEM); if (eventsTableTypeCE.length != 1) { break; } - final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR); + final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.CLASS_ATTR); if ((eventsTableType == null) || (eventsTableType.length() == 0)) { break; } @@ -397,13 +397,13 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus if (commonTraceType.startsWith(CustomXmlTrace.class.getCanonicalName())) { return new CustomEventsTable(((CustomXmlTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize); } - for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) { - if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(commonTraceType)) { - final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM); + for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements()) { + if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(commonTraceType)) { + final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceTypeUIUtils.EVENTS_TABLE_TYPE_ELEM); if (eventsTableTypeCE.length != 1) { break; } - final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR); + final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceTypeUIUtils.CLASS_ATTR); if ((eventsTableType == null) || (eventsTableType.length() == 0)) { break; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java index c5e3be12ec..0f4d7cdb72 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java @@ -135,6 +135,7 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt // The mapping of available trace type IDs to their corresponding // configuration element private static final Map sfTraceTypeAttributes = new HashMap<>(); + private static final Map sfTraceTypeUIAttributes = new HashMap<>(); private static final Map sfTraceCategories = new HashMap<>(); /** @@ -142,15 +143,32 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt * extension registry. */ public static void init() { + /* Read the tmf.core "tracetype" extension point */ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID); for (IConfigurationElement ce : config) { - String elementName = ce.getName(); - if (elementName.equals(TmfTraceType.TYPE_ELEM)) { + switch (ce.getName()) { + case TmfTraceType.TYPE_ELEM: String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); sfTraceTypeAttributes.put(traceTypeId, ce); - } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) { + break; + case TmfTraceType.CATEGORY_ELEM: String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR); sfTraceCategories.put(categoryId, ce); + break; + default: + } + } + + /* + * Read the corresponding tmf.ui "tracetypeui" extension point for this + * trace type, if it exists. + */ + config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceTypeUIUtils.TMF_TRACE_TYPE_UI_ID); + for (IConfigurationElement ce : config) { + String elemName = ce.getName(); + if (TmfTraceTypeUIUtils.TYPE_ELEM.equals(elemName)) { + String traceType = ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR); + sfTraceTypeUIAttributes.put(traceType, ce); } } } @@ -375,8 +393,12 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { return TmfEventsEditor.ID; } - IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); - IConfigurationElement[] defaultEditorCE = ce.getChildren(TmfTraceType.DEFAULT_EDITOR_ELEM); + IConfigurationElement ce = sfTraceTypeUIAttributes.get(fTraceTypeId); + if (ce == null) { + /* This trace type does not define UI attributes */ + return null; + } + IConfigurationElement[] defaultEditorCE = ce.getChildren(TmfTraceTypeUIUtils.DEFAULT_EDITOR_ELEM); if (defaultEditorCE.length == 1) { return defaultEditorCE[0].getAttribute(TmfTraceType.ID_ATTR); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceTypeUIUtils.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceTypeUIUtils.java index cc282d26d8..2ca16b7b3a 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceTypeUIUtils.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceTypeUIUtils.java @@ -16,6 +16,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeSet; @@ -26,7 +27,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.linuxtools.internal.tmf.ui.Activator; import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceImportException; @@ -50,6 +53,27 @@ import org.eclipse.swt.widgets.Shell; */ public final class TmfTraceTypeUIUtils { + /** Extension point ID */ + public static final String TMF_TRACE_TYPE_UI_ID = "org.eclipse.linuxtools.tmf.ui.tracetypeui"; //$NON-NLS-1$ + + /** Extension point element 'type' (should match the type in TmfTraceType) */ + public static final String TYPE_ELEM = "type"; //$NON-NLS-1$ + + /** Extension point element 'Default editor' */ + public static final String DEFAULT_EDITOR_ELEM = "defaultEditor"; //$NON-NLS-1$ + + /** Extension point element 'Events table type' */ + public static final String EVENTS_TABLE_TYPE_ELEM = "eventsTableType"; //$NON-NLS-1$ + + /** Extension point attribute 'tracetype' */ + public static final String TRACETYPE_ATTR = "tracetype"; //$NON-NLS-1$ + + /** Extension point attribute 'icon' */ + public static final String ICON_ATTR = "icon"; //$NON-NLS-1$ + + /** Extension point attribute 'class' (attribute of eventsTableType) */ + public static final String CLASS_ATTR = "class"; //$NON-NLS-1$ + private static final String DEFAULT_TRACE_ICON_PATH = "icons" + File.separator + "elcl16" + File.separator + "trace.gif"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ private static final char SEPARATOR = ':'; @@ -237,14 +261,21 @@ public final class TmfTraceTypeUIUtils { */ public static IStatus setTraceType(IPath path, TraceTypeHelper traceType) throws CoreException { IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); - String traceBundle = null, traceTypeId = traceType.getCanonicalName(), traceIcon = null; + String traceBundle = null; + String traceTypeId = traceType.getCanonicalName(); + String traceIcon = DEFAULT_TRACE_ICON_PATH; + if (isCustomTraceId(traceTypeId)) { traceBundle = Activator.getDefault().getBundle().getSymbolicName(); - traceIcon = DEFAULT_TRACE_ICON_PATH; } else { IConfigurationElement ce = TmfTraceType.getInstance().getTraceAttributes(traceTypeId); traceBundle = ce.getContributor().getName(); - traceIcon = ce.getAttribute(TmfTraceType.ICON_ATTR); + } + + /* Check if there is an icon defined in tmftracetypeui */ + IConfigurationElement ce = getTraceUIAttributes(traceTypeId); + if (ce != null) { + traceIcon = ce.getAttribute(TmfTraceTypeUIUtils.ICON_ATTR); } resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE, traceBundle); @@ -263,4 +294,41 @@ public final class TmfTraceTypeUIUtils { tmfProject.refresh(); return Status.OK_STATUS; } + + /** + * Retrieves all configuration elements from the platform extension registry + * for the trace type UI extension. + * + * @return An array of trace type configuration elements + */ + public static IConfigurationElement[] getTypeUIElements() { + IConfigurationElement[] elements = + Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_TRACE_TYPE_UI_ID); + List typeElements = new LinkedList<>(); + for (IConfigurationElement element : elements) { + if (element.getName().equals(TYPE_ELEM)) { + typeElements.add(element); + } + } + return typeElements.toArray(new IConfigurationElement[typeElements.size()]); + } + + /** + * Get the UI elements for the given trace type + * + * @param traceType + * The tracetype ID + * @return The top-level configuration element (access its children with + * .getChildren()). Or null if there is no such element. + */ + @Nullable + public static IConfigurationElement getTraceUIAttributes(String traceType) { + IConfigurationElement[] elements = getTypeUIElements(); + for (IConfigurationElement ce : elements) { + if (traceType.equals(ce.getAttribute(TRACETYPE_ATTR))) { + return ce; + } + } + return null; + } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java index d1f36f547c..17512e2756 100755 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java @@ -16,15 +16,12 @@ package org.eclipse.linuxtools.tmf.ui.views.statistics; -import org.eclipse.core.resources.IResource; -import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; -import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; import org.eclipse.linuxtools.tmf.ui.viewers.ITmfViewer; import org.eclipse.linuxtools.tmf.ui.viewers.statistics.TmfStatisticsViewer; import org.eclipse.linuxtools.tmf.ui.views.TmfView; @@ -221,21 +218,6 @@ public class TmfStatisticsView extends TmfView { TmfStatisticsViewer globalViewer = new TmfStatisticsViewer(folder, Messages.TmfStatisticsView_GlobalTabName + " - " + fTrace.getName(), fTrace); //$NON-NLS-1$ fStatsViewers.addTab(globalViewer, Messages.TmfStatisticsView_GlobalTabName, defaultStyle); - // Creates a statistics viewer for each trace. - for (ITmfTrace trace : TmfTraceManager.getTraceSet(fTrace)) { - String traceName = trace.getName(); - IResource traceResource = trace.getResource(); - TmfStatisticsViewer viewer = getStatisticsViewer(traceResource); - /* - * Adds a new viewer only if there is one defined for the - * selected trace type, since the global tab already contains - * all the basic event counts for the trace(s) - */ - if (viewer != null) { - viewer.init(folder, traceName, trace); - fStatsViewers.addTab(viewer, viewer.getName(), defaultStyle); - } - } } else { // There is no trace selected. Shows an empty global tab TmfStatisticsViewer globalViewer = new TmfStatisticsViewer(folder, Messages.TmfStatisticsView_GlobalTabName, fTrace); @@ -244,22 +226,4 @@ public class TmfStatisticsView extends TmfView { // Makes the global viewer visible fStatsViewers.setSelection(0); } - - /** - * Retrieves and instantiates a viewer based on his plug-in definition for a - * specific trace type. It is specific to the statistics viewer. - * - * It only calls the 0-parameter constructor without performing any other - * initialization on the viewer. - * - * @param resource - * The resource where to find the information about the trace - * properties - * @return a new statistics viewer based on his plug-in definition, or null - * if no statistics definition was found for the trace type. - * @since 2.0 - */ - protected static TmfStatisticsViewer getStatisticsViewer(IResource resource) { - return (TmfStatisticsViewer) TmfTraceType.getTraceTypeElement(resource, TmfTraceType.STATISTICS_VIEWER_ELEM); - } }