1 /*******************************************************************************
2 * Copyright (c) 2010 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
.parsers
.custom
;
15 import java
.io
.FileNotFoundException
;
16 import java
.util
.LinkedHashMap
;
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
;
25 public class CustomParserProvider
implements IParserProvider
{
28 public String
getCategory() {
33 public ITmfTrace
getTraceForParser(String parser
, IResource resource
) {
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);
42 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
43 if (parser
.equals(CustomXmlTrace
.class.getCanonicalName() + "." + def
.definitionName
)) {
44 return new CustomXmlTrace(name
, def
, path
, 100);
47 } catch (FileNotFoundException e
) {
54 public ITmfTrace
getTraceForContentType(String contentTypeId
, IResource resource
) {
59 public String
getEditorIdForParser(String parser
) {
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
);
69 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
70 parserMap
.put(def
.definitionName
, CustomXmlTrace
.class.getCanonicalName() + "." + def
.definitionName
);
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
);