4e64770ca27d9b179b09d94bacbbfb8a67c921f9
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / parsers / custom / CustomParserProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2010 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.parsers.custom;
14
15 import java.io.FileNotFoundException;
16 import java.util.LinkedHashMap;
17 import java.util.Map;
18
19 import org.eclipse.core.resources.IResource;
20 import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
21 import org.eclipse.linuxtools.tmf.ui.parsers.IParserProvider;
22 import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
23 import org.eclipse.swt.widgets.Composite;
24
25 public class CustomParserProvider implements IParserProvider {
26
27 @Override
28 public String getCategory() {
29 return "Custom";
30 }
31
32 @Override
33 public ITmfTrace getTraceForParser(String parser, IResource resource) {
34 try {
35 String name = resource.getName();
36 String path = resource.getLocation().toOSString();
37 for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
38 if (parser.equals(CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName)) {
39 return new CustomTxtTrace(name, def, path, 100);
40 }
41 }
42 for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
43 if (parser.equals(CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName)) {
44 return new CustomXmlTrace(name, def, path, 100);
45 }
46 }
47 } catch (FileNotFoundException e) {
48 e.printStackTrace();
49 }
50 return null;
51 }
52
53 @Override
54 public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource) {
55 return null;
56 }
57
58 @Override
59 public String getEditorIdForParser(String parser) {
60 return null;
61 }
62
63 @Override
64 public Map<String, String> getParserMap() {
65 Map<String, String> parserMap = new LinkedHashMap<String, String>();
66 for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
67 parserMap.put(def.definitionName, CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName);
68 }
69 for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
70 parserMap.put(def.definitionName, CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName);
71 }
72 return parserMap;
73 }
74
75 @Override
76 public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize) {
77 if (trace instanceof CustomTxtTrace) {
78 return new CustomEventsTable(((CustomTxtTrace) trace).getDefinition(), parent, cacheSize);
79 } else if (trace instanceof CustomXmlTrace) {
80 return new CustomEventsTable(((CustomXmlTrace) trace).getDefinition(), parent, cacheSize);
81 }
82 return null;
83 }
84
85 }
This page took 0.032223 seconds and 5 git commands to generate.