tmf: Generalization of the statistics view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfTraceType.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.project.model;
14
15 import java.util.LinkedList;
16 import java.util.List;
17
18 import org.eclipse.core.runtime.IConfigurationElement;
19 import org.eclipse.core.runtime.Platform;
20
21 /**
22 * Utility class for accessing TMF trace type extensions from the platform's extensions registry.
23 *
24 * @version 1.0
25 * @author Patrick Tasse
26 *
27 */
28 public class TmfTraceType {
29
30 /**
31 * Extension point ID
32 */
33 public static final String TMF_TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.ui.tracetype"; //$NON-NLS-1$
34
35 /**
36 * Extension point element 'Category'
37 */
38 public static final String CATEGORY_ELEM = "category"; //$NON-NLS-1$
39 /**
40 * Extension point element 'Type'
41 */
42 public static final String TYPE_ELEM = "type"; //$NON-NLS-1$
43 /**
44 * Extension point element 'Default editor'
45 */
46 public static final String DEFAULT_EDITOR_ELEM = "defaultEditor"; //$NON-NLS-1$
47 /**
48 * Extension point element 'Events table type'
49 */
50 public static final String EVENTS_TABLE_TYPE_ELEM = "eventsTableType"; //$NON-NLS-1$
51 /**
52 * Extension point element 'Statistics viewer type'
53 *
54 * @since 2.0
55 */
56 public static final String STATISTICS_VIEWER_ELEM = "statisticsViewerType"; //$NON-NLS-1$
57
58 /**
59 * Extension point attribute 'ID'
60 */
61 public static final String ID_ATTR = "id"; //$NON-NLS-1$
62 /**
63 * Extension point attribute 'name'
64 */
65 public static final String NAME_ATTR = "name"; //$NON-NLS-1$
66 /**
67 * Extension point attribute 'category'
68 */
69 public static final String CATEGORY_ATTR = "category"; //$NON-NLS-1$
70 /**
71 * Extension point attribute 'trace_type'
72 */
73 public static final String TRACE_TYPE_ATTR = "trace_type"; //$NON-NLS-1$
74 /**
75 * Extension point attribute 'event_type'
76 */
77 public static final String EVENT_TYPE_ATTR = "event_type"; //$NON-NLS-1$
78 /**
79 * Extension point attribute 'icon'
80 */
81 public static final String ICON_ATTR = "icon"; //$NON-NLS-1$
82 /**
83 * Extension point attribute 'class'
84 */
85 public static final String CLASS_ATTR = "class"; //$NON-NLS-1$
86
87 /**
88 * Retrieves the category name from the platform extension registry based on the category ID
89 * @param categoryId The category ID
90 * @return the category name or empty string if not found
91 */
92 public static String getCategoryName(String categoryId) {
93 IConfigurationElement[] elements = Platform.getExtensionRegistry()
94 .getConfigurationElementsFor(TMF_TRACE_TYPE_ID);
95 for (IConfigurationElement element : elements) {
96 if (element.getName().equals(CATEGORY_ELEM) && categoryId.equals(element.getAttribute(ID_ATTR))) {
97 return element.getAttribute(NAME_ATTR);
98 }
99 }
100 return ""; //$NON-NLS-1$
101 }
102
103 /**
104 * Retrieves all configuration elements from the platform extension registry
105 * for the trace type extension.
106 *
107 * @return an array of trace type configuration elements
108 */
109 public static IConfigurationElement[] getTypeElements() {
110 IConfigurationElement[] elements = Platform.getExtensionRegistry()
111 .getConfigurationElementsFor(TMF_TRACE_TYPE_ID);
112 List<IConfigurationElement> typeElements = new LinkedList<IConfigurationElement>();
113 for (IConfigurationElement element : elements) {
114 if (element.getName().equals(TYPE_ELEM)) {
115 typeElements.add(element);
116 }
117 }
118 return typeElements.toArray(new IConfigurationElement[typeElements.size()]);
119 }
120 }
This page took 0.033387 seconds and 6 git commands to generate.