1 /*******************************************************************************
2 * Copyright (c) 2011 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
.util
;
15 import java
.util
.LinkedList
;
16 import java
.util
.List
;
18 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
19 import org
.eclipse
.core
.runtime
.Platform
;
21 public class TmfTraceType
{
24 public static final String TMF_TRACE_TYPE_ID
= "org.eclipse.linuxtools.tmf.tracetype"; //$NON-NLS-1$
26 // Extension point elements
27 public static final String CATEGORY_ELEM
= "category"; //$NON-NLS-1$
28 public static final String TYPE_ELEM
= "type"; //$NON-NLS-1$
29 public static final String DEFAULT_EDITOR_ELEM
= "defaultEditor"; //$NON-NLS-1$
30 public static final String EVENTS_TABLE_TYPE_ELEM
= "eventsTableType"; //$NON-NLS-1$
32 // Extension point attributes
33 public static final String ID_ATTR
= "id"; //$NON-NLS-1$
34 public static final String NAME_ATTR
= "name"; //$NON-NLS-1$
35 public static final String CATEGORY_ATTR
= "category"; //$NON-NLS-1$
36 public static final String TRACE_TYPE_ATTR
= "trace_type"; //$NON-NLS-1$
37 public static final String EVENT_TYPE_ATTR
= "event_type"; //$NON-NLS-1$
38 public static final String ICON_ATTR
= "icon"; //$NON-NLS-1$
39 public static final String CLASS_ATTR
= "class"; //$NON-NLS-1$
41 public static String
getCategoryName(String categoryId
) {
42 IConfigurationElement
[] elements
= Platform
.getExtensionRegistry()
43 .getConfigurationElementsFor(TMF_TRACE_TYPE_ID
);
44 for (IConfigurationElement element
: elements
) {
45 if (element
.getName().equals(CATEGORY_ELEM
) && categoryId
.equals(element
.getAttribute(ID_ATTR
))) {
46 return element
.getAttribute(NAME_ATTR
);
49 return ""; //$NON-NLS-1$
52 public static IConfigurationElement
[] getTypeElements() {
53 IConfigurationElement
[] elements
= Platform
.getExtensionRegistry()
54 .getConfigurationElementsFor(TMF_TRACE_TYPE_ID
);
55 List
<IConfigurationElement
> typeElements
= new LinkedList
<IConfigurationElement
>();
56 for (IConfigurationElement element
: elements
) {
57 if (element
.getName().equals(TYPE_ELEM
)) {
58 typeElements
.add(element
);
61 return typeElements
.toArray(new IConfigurationElement
[0]);