2010-07-12 Francois Chouinard <fchouinar@gmail.com> Contributions for Bug319429...
[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 public String getCategory() {
28 return "Custom";
29 }
30
31 public ITmfTrace getTraceForParser(String parser, IResource resource) {
32 try {
33 String name = resource.getName();
34 String path = resource.getLocation().toOSString();
35 for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
36 if (parser.equals(CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName)) {
37 return new CustomTxtTrace(name, def, path, 100);
38 }
39 }
40 for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
41 if (parser.equals(CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName)) {
42 return new CustomXmlTrace(name, def, path, 100);
43 }
44 }
45 } catch (FileNotFoundException e) {
46 e.printStackTrace();
47 }
48 return null;
49 }
50
51 public ITmfTrace getTraceForContentType(String contentTypeId, IResource resource) {
52 return null;
53 }
54
55 public String getEditorIdForParser(String parser) {
56 return null;
57 }
58
59 public Map<String, String> getParserMap() {
60 Map<String, String> parserMap = new LinkedHashMap<String, String>();
61 for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
62 parserMap.put(def.definitionName, CustomTxtTrace.class.getCanonicalName() + "." + def.definitionName);
63 }
64 for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
65 parserMap.put(def.definitionName, CustomXmlTrace.class.getCanonicalName() + "." + def.definitionName);
66 }
67 return parserMap;
68 }
69
70 public TmfEventsTable getEventsTable(ITmfTrace trace, Composite parent, int cacheSize) {
71 if (trace instanceof CustomTxtTrace) {
72 return new CustomEventsTable(((CustomTxtTrace) trace).getDefinition(), parent, cacheSize);
73 } else if (trace instanceof CustomXmlTrace) {
74 return new CustomEventsTable(((CustomXmlTrace) trace).getDefinition(), parent, cacheSize);
75 }
76 return null;
77 }
78
79 }
This page took 0.037433 seconds and 6 git commands to generate.