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
{
27 public String
getCategory() {
31 public ITmfTrace
getTraceForParser(String parser
, IResource resource
) {
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);
40 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
41 if (parser
.equals(CustomXmlTrace
.class.getCanonicalName() + "." + def
.definitionName
)) {
42 return new CustomXmlTrace(name
, def
, path
, 100);
45 } catch (FileNotFoundException e
) {
51 public ITmfTrace
getTraceForContentType(String contentTypeId
, IResource resource
) {
55 public String
getEditorIdForParser(String parser
) {
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
);
64 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
65 parserMap
.put(def
.definitionName
, CustomXmlTrace
.class.getCanonicalName() + "." + def
.definitionName
);
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
);