From d7fcacc994c67ea105ddb752b32854fef03c62ee Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Fri, 11 Mar 2011 16:34:47 -0500 Subject: [PATCH] Fix for Bug327265 --- .../ui/dialogs/ManageCustomParsersDialog.java | 2 +- .../tmf/ui/parsers/custom/CustomEvent.java | 11 +----- .../ui/parsers/custom/CustomEventContent.java | 24 ++++++++++++ .../ui/parsers/custom/CustomEventType.java | 19 ++++++++++ .../ui/parsers/custom/CustomEventsTable.java | 20 +--------- .../tmf/ui/parsers/custom/CustomTxtEvent.java | 3 ++ .../ui/parsers/custom/CustomTxtEventType.java | 21 ++++++++++ .../tmf/ui/parsers/custom/CustomTxtTrace.java | 38 +++++++++---------- .../parsers/custom/CustomTxtTraceContext.java | 5 ++- .../ui/parsers/custom/CustomXmlEventType.java | 21 ++++++++++ .../tmf/ui/parsers/custom/CustomXmlTrace.java | 24 +++++++----- .../parsers/custom/CustomXmlTraceContext.java | 5 +-- .../tmf/ui/viewers/events/TmfEventsTable.java | 4 ++ .../CustomTxtParserInputWizardPage.java | 29 ++++++-------- .../CustomTxtParserOutputWizardPage.java | 6 ++- .../CustomXmlParserInputWizardPage.java | 23 +++++------ .../CustomXmlParserOutputWizardPage.java | 6 ++- .../linuxtools/tmf/trace/TmfTrace.java | 2 +- 18 files changed, 165 insertions(+), 98 deletions(-) create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEventType.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEventType.java diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java index aa82f13a3f..1ed8ccfba7 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/dialogs/ManageCustomParsersDialog.java @@ -60,7 +60,7 @@ import org.eclipse.ui.part.FileEditorInput; public class ManageCustomParsersDialog extends Dialog { - private static final Image image = TmfUiPlugin.getDefault().getImageFromPath("/icons/customparser_wizard.gif"); //$NON-NLS-1$ + private static final Image image = TmfUiPlugin.getDefault().getImageFromPath("/icons/etool16/customparser_wizard.gif"); //$NON-NLS-1$ Button txtButton; Button xmlButton; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java index 06b059a6f6..1993bfe4d5 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java @@ -19,7 +19,6 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.linuxtools.tmf.event.TmfEvent; -import org.eclipse.linuxtools.tmf.event.TmfEventContent; import org.eclipse.linuxtools.tmf.event.TmfEventReference; import org.eclipse.linuxtools.tmf.event.TmfEventSource; import org.eclipse.linuxtools.tmf.event.TmfEventType; @@ -66,12 +65,6 @@ public class CustomEvent extends TmfEvent { return super.getOriginalTimestamp(); } - @Override - public TmfEventContent getContent() { - if (fData != null) processData(); - return super.getContent(); - } - public String[] extractItemFields() { if (fData != null) processData(); return fColumnData; @@ -101,11 +94,9 @@ public class CustomEvent extends TmfEvent { SimpleDateFormat dateFormat = new SimpleDateFormat(fDefinition.timeStampOutputFormat); fColumnData[i++] = dateFormat.format(date); } else { - fColumnData[i++] = value; + fColumnData[i++] = (value != null ? value : ""); //$NON-NLS-1$ } } - String message = fData.get(CustomTraceDefinition.TAG_MESSAGE);; - setContent(new TmfEventContent(this, message)); fData = null; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java new file mode 100644 index 0000000000..3db0494693 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java @@ -0,0 +1,24 @@ +package org.eclipse.linuxtools.tmf.ui.parsers.custom; + +import java.util.Arrays; + +import org.eclipse.linuxtools.tmf.event.TmfEventContent; + +public class CustomEventContent extends TmfEventContent { + + public CustomEventContent(CustomEvent parent, Object content) { + super(parent, content); + } + + @Override + protected void parseContent() { + CustomEvent event = (CustomEvent) fParentEvent; + fFields = event.extractItemFields(); + } + + @Override + public String toString() { + return Arrays.toString(getFields()); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java new file mode 100644 index 0000000000..1d07fef18d --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java @@ -0,0 +1,19 @@ +package org.eclipse.linuxtools.tmf.ui.parsers.custom; + +import org.eclipse.linuxtools.tmf.event.TmfEventType; + +public abstract class CustomEventType extends TmfEventType { + + public CustomEventType(CustomTraceDefinition definition) { + super(definition.definitionName, getLabels(definition)); + } + + private static String[] getLabels(CustomTraceDefinition definition) { + String[] labels = new String[definition.outputs.size()]; + for (int i = 0; i < labels.length; i++) { + labels[i] = definition.outputs.get(i).name; + } + return labels; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java index 87192142ec..89e31003b1 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java @@ -12,10 +12,8 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; -import java.text.SimpleDateFormat; import java.util.LinkedList; import java.util.List; -import java.util.TimeZone; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; @@ -29,17 +27,11 @@ public class CustomEventsTable extends TmfEventsTable { private CustomTraceDefinition fDefinition; public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) { - super(parent, cacheSize); + super(parent, cacheSize, new ColumnData[0]); fDefinition = definition; createColumnHeaders(); } - public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$ - private static final SimpleDateFormat TIMESTAMP_SIMPLE_DATE_FORMAT = new SimpleDateFormat(TIMESTAMP_FORMAT); - static { - TIMESTAMP_SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ - } - protected void createColumnHeaders() { if (fDefinition == null) return; @@ -51,16 +43,6 @@ public class CustomEventsTable extends TmfEventsTable { setColumnHeaders((ColumnData[]) columnData.toArray(new ColumnData[0])); } -// @Override -// public void createColumnHeaders(final Table table) { -// if (fDefinition == null) return; // ignore when called by the super constructor -// for (OutputColumn outputColumn : fDefinition.outputs) { -// TableColumn column = new TableColumn(table, SWT.LEFT); -// column.setText(outputColumn.name); -// column.pack(); -// } -// } - @Override public String[] extractItemFields(TmfEvent event) { if (event instanceof CustomEvent) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java index 7008ee5827..c4ced9d578 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEvent.java @@ -37,6 +37,9 @@ public class CustomTxtEvent extends CustomEvent { } public void processGroups(InputLine input, Matcher matcher) { + if (input.columns == null) { + return; + } for (int i = 0; i < input.columns.size(); i++) { InputData column = input.columns.get(i); if (i < matcher.groupCount() && matcher.group(i + 1) != null) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEventType.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEventType.java new file mode 100644 index 0000000000..e3168e56b3 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtEventType.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tasse - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.parsers.custom; + +public class CustomTxtEventType extends CustomEventType { + + public CustomTxtEventType(CustomTxtTraceDefinition definition) { + super(definition); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java index 4bb339b458..ae365e0fad 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -15,19 +15,17 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.RandomAccessFile; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfEventReference; import org.eclipse.linuxtools.tmf.event.TmfEventSource; -import org.eclipse.linuxtools.tmf.event.TmfEventType; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.io.BufferedRandomAccessFile; import org.eclipse.linuxtools.tmf.trace.ITmfContext; import org.eclipse.linuxtools.tmf.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; @@ -38,11 +36,15 @@ import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.Inp public class CustomTxtTrace extends TmfTrace { + private static final TmfLocation NULL_LOCATION = new TmfLocation((Long) null); + private CustomTxtTraceDefinition fDefinition; + private CustomTxtEventType fEventType; public CustomTxtTrace(String name, CustomTxtTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException { super(name, CustomTxtEvent.class, path, cacheSize); fDefinition = definition; + fEventType = new CustomTxtEventType(fDefinition); } @Override @@ -55,24 +57,25 @@ public class CustomTxtTrace extends TmfTrace { public TmfContext seekLocation(ITmfLocation location) { //System.out.println(Thread.currentThread().getName() + "::" + getName() + " seekLocation(" + ((location == null || location.getLocation() == null) ? "null" : location) + ")"); //new Throwable().printStackTrace(); - CustomTxtTraceContext context = new CustomTxtTraceContext(new TmfLocation((Long)null), ITmfContext.INITIAL_RANK); - if (!new File(getPath()).isFile()) { + CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK); + if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile()) { return context; } try { - RandomAccessFile raFile = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$ + BufferedRandomAccessFile raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$ if (location != null && location.getLocation() instanceof Long) { raFile.seek((Long)location.getLocation()); } String line; long rawPos = raFile.getFilePointer(); - while ((line = raFile.readLine()) != null) { + while ((line = raFile.getNextLine()) != null) { for (InputLine input : getFirstLines()) { Matcher matcher = input.getPattern().matcher(line); if (matcher.find()) { context.setLocation(new TmfLocation(rawPos)); context.raFile = raFile; context.firstLineMatcher = matcher; + context.firstLine = line; context.nextLineLocation = raFile.getFilePointer(); context.inputLine = input; return context; @@ -116,7 +119,7 @@ public class CustomTxtTrace extends TmfTrace { } CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext; - if (!(context.getLocation().getLocation() instanceof Long)) { + if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) { return null; } @@ -136,7 +139,7 @@ public class CustomTxtTrace extends TmfTrace { } String line; long rawPos = context.raFile.getFilePointer(); - while ((line = context.raFile.readLine()) != null) { + while ((line = context.raFile.getNextLine()) != null) { boolean processed = false; if (currentInput == null) { for (InputLine input : getFirstLines()) { @@ -144,6 +147,7 @@ public class CustomTxtTrace extends TmfTrace { if (matcher.find()) { context.setLocation(new TmfLocation(rawPos)); context.firstLineMatcher = matcher; + context.firstLine = line; context.nextLineLocation = context.raFile.getFilePointer(); context.inputLine = input; return event; @@ -158,6 +162,7 @@ public class CustomTxtTrace extends TmfTrace { if (matcher.find()) { context.setLocation(new TmfLocation(rawPos)); context.firstLineMatcher = matcher; + context.firstLine = line; context.nextLineLocation = context.raFile.getFilePointer(); context.inputLine = input; return event; @@ -236,6 +241,7 @@ public class CustomTxtTrace extends TmfTrace { } } } + ((StringBuffer) event.getContent().getContent()).append("\n").append(line); //$NON-NLS-1$ } } rawPos = context.raFile.getFilePointer(); @@ -249,7 +255,7 @@ public class CustomTxtTrace extends TmfTrace { event = null; } } - context.setLocation(new TmfLocation((Long)null)); + context.setLocation(NULL_LOCATION); return event; } @@ -258,20 +264,12 @@ public class CustomTxtTrace extends TmfTrace { } public CustomTxtEvent parseFirstLine(CustomTxtTraceContext context) { - CustomTxtEvent event = new CustomTxtEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), new TmfEventType(fDefinition.definitionName, new String[0]), new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ + CustomTxtEvent event = new CustomTxtEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ event.processGroups(context.inputLine, context.firstLineMatcher); + event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine))); return event; } - public void parseNextLine(CustomTxtEvent event, String line, InputLine input) { - Pattern pattern = input.getPattern(); - Matcher matcher = pattern.matcher(line); - if (matcher.find()) { - event.processGroups(input, matcher); - return; - } - } - public CustomTraceDefinition getDefinition() { return fDefinition; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceContext.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceContext.java index 38e142d183..38853bc08c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceContext.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceContext.java @@ -12,16 +12,17 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; -import java.io.RandomAccessFile; import java.util.regex.Matcher; +import org.eclipse.linuxtools.tmf.io.BufferedRandomAccessFile; import org.eclipse.linuxtools.tmf.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.trace.TmfContext; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine; public class CustomTxtTraceContext extends TmfContext { - public RandomAccessFile raFile; + public BufferedRandomAccessFile raFile; public Matcher firstLineMatcher; + public String firstLine; public long nextLineLocation; public InputLine inputLine; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEventType.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEventType.java new file mode 100644 index 0000000000..6df4936e3e --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlEventType.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tasse - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.parsers.custom; + +public class CustomXmlEventType extends CustomEventType { + + public CustomXmlEventType(CustomXmlTraceDefinition definition) { + super(definition); + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java index 772d38cfed..d61a0a9b50 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -25,8 +25,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfEventReference; import org.eclipse.linuxtools.tmf.event.TmfEventSource; -import org.eclipse.linuxtools.tmf.event.TmfEventType; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; +import org.eclipse.linuxtools.tmf.io.BufferedRandomAccessFile; import org.eclipse.linuxtools.tmf.trace.ITmfContext; import org.eclipse.linuxtools.tmf.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; @@ -47,12 +47,16 @@ import org.xml.sax.SAXParseException; public class CustomXmlTrace extends TmfTrace { + private static final TmfLocation NULL_LOCATION = new TmfLocation((Long) null); + private CustomXmlTraceDefinition fDefinition; + private CustomXmlEventType fEventType; private InputElement fRecordInputElement; public CustomXmlTrace(String name, CustomXmlTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException { super(name, CustomXmlEvent.class, path, cacheSize); fDefinition = definition; + fEventType = new CustomXmlEventType(fDefinition); fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement); } @@ -60,12 +64,12 @@ public class CustomXmlTrace extends TmfTrace { public TmfContext seekLocation(ITmfLocation location) { //System.out.println(Thread.currentThread().getName() + "::" + getName() + " seekLocation(" + ((location == null || location.getLocation() == null) ? "null" : location) + ")"); //new Throwable().printStackTrace(); - CustomXmlTraceContext context = new CustomXmlTraceContext(new TmfLocation((Long)null), ITmfContext.INITIAL_RANK); - if (!new File(getPath()).isFile()) { + CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK); + if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile()) { return context; } try { - context.raFile = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$ + context.raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$ if (location != null && location.getLocation() instanceof Long) { context.raFile.seek((Long)location.getLocation()); } @@ -74,7 +78,7 @@ public class CustomXmlTrace extends TmfTrace { String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$ long rawPos = context.raFile.getFilePointer(); - while ((line = context.raFile.readLine()) != null) { + while ((line = context.raFile.getNextLine()) != null) { int idx = line.indexOf(recordElementStart); if (idx != -1) { context.setLocation(new TmfLocation(rawPos + idx)); @@ -123,7 +127,7 @@ public class CustomXmlTrace extends TmfTrace { } CustomXmlTraceContext context = (CustomXmlTraceContext) tmfContext; - if (!(context.getLocation().getLocation() instanceof Long)) { + if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) { return null; } @@ -138,12 +142,13 @@ public class CustomXmlTrace extends TmfTrace { Element element = parseElementBuffer(elementBuffer); event = extractEvent(element, fRecordInputElement); + ((StringBuffer) event.getContent().getContent()).append(elementBuffer); String line; String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$ long rawPos = context.raFile.getFilePointer(); - while ((line = context.raFile.readLine()) != null) { + while ((line = context.raFile.getNextLine()) != null) { int idx = line.indexOf(recordElementStart); if (idx != -1) { context.setLocation(new TmfLocation(rawPos + idx)); @@ -154,7 +159,7 @@ public class CustomXmlTrace extends TmfTrace { } catch (IOException e) { e.printStackTrace(); } - context.setLocation(new TmfLocation((Long)null)); + context.setLocation(NULL_LOCATION); return event; } } @@ -313,7 +318,8 @@ public class CustomXmlTrace extends TmfTrace { } public CustomXmlEvent extractEvent(Element element, InputElement inputElement) { - CustomXmlEvent event = new CustomXmlEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), new TmfEventType(fDefinition.definitionName, new String[0]), new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ + CustomXmlEvent event = new CustomXmlEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$ + event.setContent(new CustomEventContent(event, new StringBuffer())); parseElement(element, event, inputElement); return event; } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceContext.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceContext.java index 0dd3df52af..7bd0dfe291 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceContext.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceContext.java @@ -12,13 +12,12 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; -import java.io.RandomAccessFile; - +import org.eclipse.linuxtools.tmf.io.BufferedRandomAccessFile; import org.eclipse.linuxtools.tmf.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.trace.TmfContext; public class CustomXmlTraceContext extends TmfContext { - public RandomAccessFile raFile; + public BufferedRandomAccessFile raFile; public CustomXmlTraceContext(ITmfLocation location, long rank) { super(location, rank); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index 19e2595d5f..a04416265c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -162,6 +162,10 @@ public class TmfEventsTable extends TmfComponent { return fTable; } + public void setLayoutData(Object layoutData) { +// FIXME: fComposite.setLayoutData(layoutData); + } + /** * @param table * diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java index 0299372326..a62b4c9293 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java @@ -72,14 +72,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage { private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$ private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$ private static final String PATTERN_URL = "http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html#sum"; //$NON-NLS-1$ - private static final Image lineImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/line_icon.gif"); //$NON-NLS-1$ - private static final Image addImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/add_button.gif"); //$NON-NLS-1$ - private static final Image addNextImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/addnext_button.gif"); //$NON-NLS-1$ - private static final Image addChildImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/addchild_button.gif"); //$NON-NLS-1$ - private static final Image deleteImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/delete_button.gif"); //$NON-NLS-1$ - private static final Image moveUpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/moveup_button.gif"); //$NON-NLS-1$ - private static final Image moveDownImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/movedown_button.gif"); //$NON-NLS-1$ - private static final Image helpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/help_button.gif"); //$NON-NLS-1$ + private static final Image lineImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/line_icon.gif"); //$NON-NLS-1$ + private static final Image addImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$ + private static final Image addNextImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$ + private static final Image addChildImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$ + private static final Image deleteImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$ + private static final Image moveUpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$ + private static final Image moveDownImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$ + private static final Image helpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$ private static final Color COLOR_BLACK = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK); private static final Color COLOR_LIGHT_GREEN = new Color(Display.getDefault(), 192, 255, 192); private static final Color COLOR_GREEN = Display.getCurrent().getSystemColor(SWT.COLOR_GREEN); @@ -105,16 +105,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage { private TreeViewer treeViewer; private Composite treeContainer; private Composite lineContainer; - @SuppressWarnings("unused") - private Group addLineGroup; private StyledText inputText; private Font fixedFont; private UpdateListener updateListener; private Browser helpBrowser; // variables used recursively through line traversal - @SuppressWarnings("unused") - private String timeStampValue; private String timeStampFormat; private boolean timestampFound; @@ -154,7 +150,6 @@ public class CustomTxtParserInputWizardPage extends WizardPage { logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE); logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT)); - logtypeText.addModifyListener(updateListener); Label timestampFormatLabel = new Label(headerComposite, SWT.NULL); timestampFormatLabel.setText(Messages.CustomTxtParserInputWizardPage_timestampFormat); @@ -162,7 +157,6 @@ public class CustomTxtParserInputWizardPage extends WizardPage { timestampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE); timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT); - timestampOutputFormatText.addModifyListener(updateListener); Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH); dateFormatHelpButton.setImage(helpImage); @@ -346,6 +340,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage { treeViewer.expandAll(); lineContainer.layout(); + logtypeText.addModifyListener(updateListener); + timestampOutputFormatText.addModifyListener(updateListener); + lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1); hSash.setWeights(new int[] {1, 2}); @@ -548,10 +545,6 @@ public class CustomTxtParserInputWizardPage extends WizardPage { container.layout(); } -// private void removeAddLineButton() { -// addLineGroup.dispose(); -// } - private String getSelectionText() { if (this.selection instanceof IStructuredSelection) { Object selection = ((IStructuredSelection)this.selection).getFirstElement(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java index 715bb3fd75..a4de395534 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java @@ -30,8 +30,8 @@ import org.eclipse.swt.widgets.Text; public class CustomTxtParserOutputWizardPage extends WizardPage { - private static final Image upImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/up_button.gif"); //$NON-NLS-1$ - private static final Image downImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/down_button.gif"); //$NON-NLS-1$ + private static final Image upImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$ + private static final Image downImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$ private CustomTxtParserWizard wizard; private CustomTxtTraceDefinition definition; ArrayList outputs = new ArrayList(); @@ -85,6 +85,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { tableLayout.marginWidth = 0; tableContainer.setLayout(tableLayout); previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0); + previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); if (wizard.definition != null) { loadDefinition(wizard.definition); @@ -206,6 +207,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { ITmfTrace trace = new CustomTxtTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); previewTable.dispose(); previewTable = new CustomEventsTable(definition, tableContainer, MAX_NUM_ENTRIES); + previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); previewTable.setTrace(trace, true); previewTable.getTable().setItemCount(MAX_NUM_ENTRIES); // Trigger parsing } catch (FileNotFoundException e) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java index 02ad4c13ab..538bf95f98 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java @@ -76,15 +76,15 @@ public class CustomXmlParserInputWizardPage extends WizardPage { private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$ private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$ - private static final Image elementImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/element_icon.gif"); //$NON-NLS-1$ - private static final Image addImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/add_button.gif"); //$NON-NLS-1$ - private static final Image addNextImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/addnext_button.gif"); //$NON-NLS-1$ - private static final Image addChildImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/addchild_button.gif"); //$NON-NLS-1$ - private static final Image addManyImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/addmany_button.gif"); //$NON-NLS-1$ - private static final Image deleteImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/delete_button.gif"); //$NON-NLS-1$ - private static final Image moveUpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/moveup_button.gif"); //$NON-NLS-1$ - private static final Image moveDownImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/movedown_button.gif"); //$NON-NLS-1$ - private static final Image helpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/help_button.gif"); //$NON-NLS-1$ + private static final Image elementImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$ + private static final Image addImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$ + private static final Image addNextImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$ + private static final Image addChildImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$ + private static final Image addManyImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$ + private static final Image deleteImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$ + private static final Image moveUpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$ + private static final Image moveDownImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$ + private static final Image helpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$ private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192); private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); @@ -160,7 +160,6 @@ public class CustomXmlParserInputWizardPage extends WizardPage { logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE); logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT)); - logtypeText.addModifyListener(updateListener); Label timeStampFormatLabel = new Label(headerComposite, SWT.NULL); timeStampFormatLabel.setText(Messages.CustomXmlParserInputWizardPage_timestampFormat); @@ -168,7 +167,6 @@ public class CustomXmlParserInputWizardPage extends WizardPage { timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE); timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT); - timeStampOutputFormatText.addModifyListener(updateListener); Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH); dateFormatHelpButton.setImage(helpImage); @@ -231,6 +229,9 @@ public class CustomXmlParserInputWizardPage extends WizardPage { treeViewer.expandAll(); elementContainer.layout(); + logtypeText.addModifyListener(updateListener); + timeStampOutputFormatText.addModifyListener(updateListener); + elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1); hSash.setWeights(new int[] {1, 2}); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java index 92ab5f3789..4f69f886f1 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java @@ -31,8 +31,8 @@ import org.eclipse.swt.widgets.Text; public class CustomXmlParserOutputWizardPage extends WizardPage { - private static final Image upImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/up_button.gif"); //$NON-NLS-1$ - private static final Image downImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/down_button.gif"); //$NON-NLS-1$ + private static final Image upImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$ + private static final Image downImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$ private CustomXmlParserWizard wizard; private CustomXmlTraceDefinition definition; ArrayList outputs = new ArrayList(); @@ -86,6 +86,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { tableLayout.marginWidth = 0; tableContainer.setLayout(tableLayout); previewTable = new CustomEventsTable(new CustomXmlTraceDefinition(), tableContainer, 0); + previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); if (wizard.definition != null) { loadDefinition(wizard.definition); @@ -207,6 +208,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { ITmfTrace trace = new CustomXmlTrace(tmpFile.getName(), definition, tmpFile.getAbsolutePath(), MAX_NUM_ENTRIES); previewTable.dispose(); previewTable = new CustomEventsTable(definition, tableContainer, MAX_NUM_ENTRIES); + previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); previewTable.setTrace(trace, true); previewTable.getTable().setItemCount(MAX_NUM_ENTRIES); // Trigger parsing } catch (FileNotFoundException e) { diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java index ece1fc32d2..0d09512bca 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java @@ -423,7 +423,7 @@ public abstract class TmfTrace extends TmfEventProvider i * event). */ - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "unchecked", "unused" }) private void indexTrace(boolean waitForCompletion) { final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$ -- 2.34.1