* '''Category:''' Enter a category name for the trace type.
* '''Trace type:''' Enter a name for the trace type, which is also the name of the custom parser. This will also be the default event type name.
-* '''Time Stamp format:''' Enter the date and time pattern that will be used to output the Time Stamp.<br>
+* '''Time Stamp format:''' Enter the date and time pattern that will be used to output the Time Stamp, or leave blank to use the default Time Format preference.<br>
Note: information about date and time patterns can be found here: [http://archive.eclipse.org/tracecompass/doc/stable/org.eclipse.tracecompass.doc.user/reference/api/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampFormat.html TmfTimestampFormat]
Click the '''Add next line''', '''Add child line''' or '''Remove line''' buttons to create a new line of input or delete it. For each line of input, enter the following information:
* '''Category:''' Enter a category name for the trace type.
* '''Trace type:''' Enter a name for the trace type, which is also the name of the custom parser. This will also be the default event type name.
-* '''Time Stamp format:''' Enter the date and time pattern that will be used to output the Time Stamp.<br>
+* '''Time Stamp format:''' Enter the date and time pattern that will be used to output the Time Stamp, or leave blank to use the default Time Format preference.<br>
Note: information about date and time patterns can be found here: [http://archive.eclipse.org/tracecompass/doc/stable/org.eclipse.tracecompass.doc.user/reference/api/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampFormat.html TmfTimestampFormat]
Click the '''Add document element''' button to create a new document element and enter a name for the root-level document element of the XML file.
public static @NonNull Iterable<ITmfEventAspect<?>> generateAspects(CustomTraceDefinition definition) {
ImmutableList.Builder<ITmfEventAspect<?>> builder = new ImmutableList.Builder<>();
for (OutputColumn output : definition.outputs) {
- if (output.tag.equals(Tag.TIMESTAMP) && definition.timeStampOutputFormat == null) {
+ if (output.tag.equals(Tag.TIMESTAMP) &&
+ (definition.timeStampOutputFormat == null || definition.timeStampOutputFormat.isEmpty())) {
builder.add(TmfBaseAspects.getTimestampAspect());
} else if (output.tag.equals(Tag.EVENT_TYPE)) {
builder.add(TmfBaseAspects.getEventTypeAspect());
List<ITmfEventField> fields = new ArrayList<>(fDefinition.outputs.size());
for (OutputColumn outputColumn : fDefinition.outputs) {
Object key = (outputColumn.tag.equals(Tag.OTHER) ? outputColumn.name : outputColumn.tag);
- if (outputColumn.tag.equals(Tag.TIMESTAMP) && timestamp != null) {
- TmfTimestampFormat timestampFormat = new TmfTimestampFormat(fDefinition.timeStampOutputFormat);
- fields.add(new TmfEventField(outputColumn.name, timestampFormat.format(timestamp.getValue()), null));
+ if (outputColumn.tag.equals(Tag.TIMESTAMP)) {
+ if (timestamp != null && fDefinition.timeStampOutputFormat != null && !fDefinition.timeStampOutputFormat.isEmpty()) {
+ TmfTimestampFormat timestampFormat = new TmfTimestampFormat(fDefinition.timeStampOutputFormat);
+ fields.add(new TmfEventField(outputColumn.name, timestampFormat.format(timestamp.getValue()), null));
+ }
} else if (!outputColumn.tag.equals(Tag.EVENT_TYPE)){
fields.add(new TmfEventField(outputColumn.name, nullToEmptyString(fData.get(key)), null));
}
definitionElement.setAttribute(CATEGORY_ATTRIBUTE, categoryName);
definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);
- Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);
- definitionElement.appendChild(formatElement);
- formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));
+ if (timeStampOutputFormat != null && !timeStampOutputFormat.isEmpty()) {
+ Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);
+ definitionElement.appendChild(formatElement);
+ formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));
+ }
if (inputs != null) {
for (InputLine inputLine : inputs) {
definitionElement.setAttribute(CATEGORY_ATTRIBUTE, categoryName);
definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);
- Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);
- definitionElement.appendChild(formatElement);
- formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));
+ if (timeStampOutputFormat != null && !timeStampOutputFormat.isEmpty()) {
+ Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);
+ definitionElement.appendChild(formatElement);
+ formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));
+ }
if (rootInputElement != null) {
definitionElement.appendChild(createInputElementElement(rootInputElement, doc));
public static String CustomTxtParserInputWizardPage_capturedGroup;
public static String CustomTxtParserInputWizardPage_cardinality;
public static String CustomTxtParserInputWizardPage_category;
+ public static String CustomTxtParserInputWizardPage_default;
public static String CustomTxtParserInputWizardPage_desccriptionEdit;
public static String CustomTxtParserInputWizardPage_descriptionNew;
public static String CustomTxtParserInputWizardPage_eventType;
public static String CustomTxtParserOutputWizardPage_moveAfter;
public static String CustomTxtParserOutputWizardPage_moveBefore;
public static String CustomTxtParserOutputWizardPage_visible;
+ public static String CustomXmlParserInputWizardPage_default;
public static String CustomXmlParserInputWizardPage_emptyCategoryError;
public static String CustomXmlParserInputWizardPage_emptyEventTypeError;
public static String CustomXmlParserInputWizardPage_emptyLogTypeError;
public static String CustomXmlParserInputWizardPage_duplicatelogTypeError;
public static String CustomXmlParserInputWizardPage_noDocumentError;
public static String CustomXmlParserInputWizardPage_missingLogEntryError;
- public static String CustomXmlParserInputWizardPage_missingTimestampFmtError;
public static String CustomXmlParserInputWizardPage_missingDocumentElementError;
public static String CustomXmlParserInputWizardPage_noTimestampElementOrAttribute;
public static String CustomXmlParserInputWizardPage_elementMissingNameError;
CustomTxtParserInputWizardPage_capturedGroup=Captured group
CustomTxtParserInputWizardPage_cardinality=Cardinality:
CustomTxtParserInputWizardPage_category=Category:
+CustomTxtParserInputWizardPage_default=default
CustomTxtParserInputWizardPage_desccriptionEdit=Edit an existing custom parser for text trace files
CustomTxtParserInputWizardPage_descriptionNew=Create a new custom parser for text trace files
CustomTxtParserInputWizardPage_eventType=Event type:
CustomTxtParserOutputWizardPage_moveAfter=Move After
CustomTxtParserOutputWizardPage_moveBefore=Move Before
CustomTxtParserOutputWizardPage_visible=Visible
+CustomXmlParserInputWizardPage_default=default
CustomXmlParserInputWizardPage_emptyCategoryError=Enter a category for the new trace type.
CustomXmlParserInputWizardPage_emptyEventTypeError=Enter the event type for the element (Element {0}).
CustomXmlParserInputWizardPage_emptyLogTypeError=Enter a name for the new trace type.
CustomXmlParserInputWizardPage_duplicatelogTypeError=The trace type name already exists.
CustomXmlParserInputWizardPage_noDocumentError=Add a document element.
CustomXmlParserInputWizardPage_missingLogEntryError=Identify a Log Entry element.
-CustomXmlParserInputWizardPage_missingTimestampFmtError=Enter the output format for the Time Stamp field.
CustomXmlParserInputWizardPage_missingDocumentElementError=Enter a name for the document element.
CustomXmlParserInputWizardPage_noTimestampElementOrAttribute=*no time stamp element or attribute*
CustomXmlParserInputWizardPage_elementMissingNameError=Enter a name for the element (Element {0}).
private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);
private static final Color COLOR_TEXT_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
private static final Color COLOR_WIDGET_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+ private static final Color COLOR_GRAY = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
private final ISelection selection;
private CustomTxtTraceDefinition definition;
timestampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
+ timestampOutputFormatText.addPaintListener(e -> {
+ if (!timestampOutputFormatText.isFocusControl() && timestampOutputFormatText.getText().trim().isEmpty()) {
+ e.gc.setForeground(COLOR_GRAY);
+ int borderWidth = timestampOutputFormatText.getBorderWidth();
+ e.gc.drawText(Messages.CustomTxtParserInputWizardPage_default, borderWidth, borderWidth);
+ }
+ });
Button timeStampFormatHelpButton = new Button(headerComposite, SWT.PUSH);
timeStampFormatHelpButton.setImage(HELP_IMAGE);
SashForm vSash = new SashForm(container, SWT.VERTICAL);
vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+ vSash.setBackground(COLOR_GRAY);
SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);
hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
private void loadDefinition(CustomTxtTraceDefinition def) {
categoryText.setText(def.categoryName);
logtypeText.setText(def.definitionName);
- timestampOutputFormatText.setText(def.timeStampOutputFormat);
+ if (def.timeStampOutputFormat != null) {
+ timestampOutputFormatText.setText(def.timeStampOutputFormat);
+ } else {
+ timestampOutputFormatText.setText(""); //$NON-NLS-1$
+ }
treeViewer.setInput(def.inputs);
if (def.inputs.size() > 0) {
InputLine inputLine = def.inputs.get(0);
try {
TmfTimestampFormat timestampFormat = new TmfTimestampFormat(firstEntryTimeStampInputFormat);
long timestamp = timestampFormat.parseValue(firstEntryTimeStamp);
- timestampFormat = new TmfTimestampFormat(timestampOutputFormatText.getText().trim());
+ if (timestampOutputFormatText.getText().trim().isEmpty()) {
+ timestampFormat = new TmfTimestampFormat();
+ } else {
+ timestampFormat = new TmfTimestampFormat(timestampOutputFormatText.getText().trim());
+ }
timestampPreviewText.setText(timestampFormat.format(timestamp));
} catch (ParseException e) {
timestampPreviewText.setText("*parse exception* [" + firstEntryTimeStamp + "] <> [" + firstEntryTimeStampInputFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = Integer.toString(i + 1);
errors.append(validateLine(inputLine, name));
}
- if (timestampFound) {
- if (definition.timeStampOutputFormat.length() == 0) {
- errors.append("Enter the output format for the Time Stamp field. "); //$NON-NLS-1$
+ if (timestampFound && !definition.timeStampOutputFormat.isEmpty()) {
+ try {
+ new TmfTimestampFormat(definition.timeStampOutputFormat);
+ timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+ } catch (IllegalArgumentException e) {
+ errors.append("Enter a valid output format for the Time Stamp field [" + e.getMessage() + "]."); //$NON-NLS-1$ //$NON-NLS-2$
timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);
- } else {
- try {
- new TmfTimestampFormat(definition.timeStampOutputFormat);
- timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
- } catch (IllegalArgumentException e) {
- errors.append("Enter a valid output format for the Time Stamp field [" + e.getMessage() + "]."); //$NON-NLS-1$ //$NON-NLS-2$
- timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);
- }
}
-
} else {
timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
}
private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);
private static final Color COLOR_TEXT_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
private static final Color COLOR_WIDGET_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+ private static final Color COLOR_GRAY = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
private final ISelection selection;
private CustomXmlTraceDefinition definition;
timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
+ timeStampOutputFormatText.addPaintListener(e -> {
+ if (!timeStampOutputFormatText.isFocusControl() && timeStampOutputFormatText.getText().trim().isEmpty()) {
+ e.gc.setForeground(COLOR_GRAY);
+ int borderWidth = timeStampOutputFormatText.getBorderWidth();
+ e.gc.drawText(Messages.CustomXmlParserInputWizardPage_default, borderWidth, borderWidth);
+ }
+ });
Button timeStampFormatHelpButton = new Button(headerComposite, SWT.PUSH);
timeStampFormatHelpButton.setImage(HELP_IMAGE);
SashForm vSash = new SashForm(container, SWT.VERTICAL);
vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+ vSash.setBackground(COLOR_GRAY);
SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);
hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
private void loadDefinition(CustomXmlTraceDefinition def) {
categoryText.setText(def.categoryName);
logtypeText.setText(def.definitionName);
- timeStampOutputFormatText.setText(def.timeStampOutputFormat);
+ if (def.timeStampOutputFormat != null) {
+ timeStampOutputFormatText.setText(def.timeStampOutputFormat);
+ } else {
+ timeStampOutputFormatText.setText(""); //$NON-NLS-1$
+ }
treeViewer.setInput(def);
if (def.rootInputElement != null) {
try {
TmfTimestampFormat timestampFormat = new TmfTimestampFormat(timeStampFormat);
long timestamp = timestampFormat.parseValue(timeStampValue);
- timestampFormat = new TmfTimestampFormat(timeStampOutputFormatText.getText().trim());
+ if (timeStampOutputFormatText.getText().trim().isEmpty()) {
+ timestampFormat = new TmfTimestampFormat();
+ } else {
+ timestampFormat = new TmfTimestampFormat(timeStampOutputFormatText.getText().trim());
+ }
timeStampPreviewText.setText(timestampFormat.format(timestamp));
} catch (ParseException e) {
timeStampPreviewText.setText("*parse exception* [" + timeStampValue + "] <> [" + timeStampFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
errors.add(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);
}
- if (timeStampFound) {
- if (timeStampOutputFormatText.getText().trim().length() == 0) {
- errors.add(Messages.CustomXmlParserInputWizardPage_missingTimestampFmtError);
+ if (timeStampFound && !definition.timeStampOutputFormat.isEmpty()) {
+ try {
+ new TmfTimestampFormat(timeStampOutputFormatText.getText().trim());
+ timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+ } catch (IllegalArgumentException e) {
+ errors.add(Messages.CustomXmlParserInputWizardPage_elementInvalidTimestampFmtError);
timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
- } else {
- try {
- new TmfTimestampFormat(timeStampOutputFormatText.getText().trim());
- timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
- } catch (IllegalArgumentException e) {
- errors.add(Messages.CustomXmlParserInputWizardPage_elementInvalidTimestampFmtError);
- timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
- }
}
} else {
- timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_noTimestampElementOrAttribute);
+ timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+ if (!timeStampFound) {
+ timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_noTimestampElementOrAttribute);
+ }
}
}
} else {