1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
15 import java
.util
.LinkedList
;
16 import java
.util
.List
;
18 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
19 import org
.eclipse
.core
.runtime
.Platform
;
22 * Utility class for accessing TMF trace type extensions from the platform's extensions registry.
25 * @author Patrick Tasse
28 public class TmfTraceType
{
33 public static final String TMF_TRACE_TYPE_ID
= "org.eclipse.linuxtools.tmf.ui.tracetype"; //$NON-NLS-1$
36 * Extension point element 'Category'
38 public static final String CATEGORY_ELEM
= "category"; //$NON-NLS-1$
40 * Extension point element 'Type'
42 public static final String TYPE_ELEM
= "type"; //$NON-NLS-1$
44 * Extension point element 'Default editor'
46 public static final String DEFAULT_EDITOR_ELEM
= "defaultEditor"; //$NON-NLS-1$
48 * Extension point element 'Events table type'
50 public static final String EVENTS_TABLE_TYPE_ELEM
= "eventsTableType"; //$NON-NLS-1$
53 * Extension point attribute 'ID'
55 public static final String ID_ATTR
= "id"; //$NON-NLS-1$
57 * Extension point attribute 'name'
59 public static final String NAME_ATTR
= "name"; //$NON-NLS-1$
61 * Extension point attribute 'category'
63 public static final String CATEGORY_ATTR
= "category"; //$NON-NLS-1$
65 * Extension point attribute 'trace_type'
67 public static final String TRACE_TYPE_ATTR
= "trace_type"; //$NON-NLS-1$
69 * Extension point attribute 'event_type'
71 public static final String EVENT_TYPE_ATTR
= "event_type"; //$NON-NLS-1$
73 * Extension point attribute 'icon'
75 public static final String ICON_ATTR
= "icon"; //$NON-NLS-1$
77 * Extension point attribute 'class'
79 public static final String CLASS_ATTR
= "class"; //$NON-NLS-1$
82 * Retrieves the category name from the platform extension registry based on the category ID
83 * @param categoryId The category ID
84 * @return the category name or empty string if not found
86 public static String
getCategoryName(String categoryId
) {
87 IConfigurationElement
[] elements
= Platform
.getExtensionRegistry()
88 .getConfigurationElementsFor(TMF_TRACE_TYPE_ID
);
89 for (IConfigurationElement element
: elements
) {
90 if (element
.getName().equals(CATEGORY_ELEM
) && categoryId
.equals(element
.getAttribute(ID_ATTR
))) {
91 return element
.getAttribute(NAME_ATTR
);
94 return ""; //$NON-NLS-1$
98 * Retrieves all configuration elements from the platform extension registry
99 * for the trace type extension.
101 * @return an array of trace type configuration elements
103 public static IConfigurationElement
[] getTypeElements() {
104 IConfigurationElement
[] elements
= Platform
.getExtensionRegistry()
105 .getConfigurationElementsFor(TMF_TRACE_TYPE_ID
);
106 List
<IConfigurationElement
> typeElements
= new LinkedList
<IConfigurationElement
>();
107 for (IConfigurationElement element
: elements
) {
108 if (element
.getName().equals(TYPE_ELEM
)) {
109 typeElements
.add(element
);
112 return typeElements
.toArray(new IConfigurationElement
[typeElements
.size()]);