From 4d12b563f3ba1a7da40c16dcf3d6ef27763fcfcf Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Mon, 18 Jul 2016 15:26:57 -0400 Subject: [PATCH] tmf: Support default timestamp output format in custom parsers The timestamp output format can now be left blank to use the default Time Format preference. In that case the Timestamp base aspect will be used. When the default format is used, the Timestamp is no longer stored as a content field, as it is already stored in the event's timestamp. Change-Id: I1e6f83ffb35f44be7828e3d25ee43f87fa8a97e1 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/77497 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- .../doc/User-Guide.mediawiki | 4 +- .../parsers/custom/CustomEventAspects.java | 3 +- .../tmf/core/parsers/custom/CustomEvent.java | 8 ++-- .../custom/CustomTxtTraceDefinition.java | 8 ++-- .../custom/CustomXmlTraceDefinition.java | 8 ++-- .../internal/tmf/ui/Messages.java | 3 +- .../internal/tmf/ui/messages.properties | 3 +- .../CustomTxtParserInputWizardPage.java | 40 ++++++++++------- .../CustomXmlParserInputWizardPage.java | 44 ++++++++++++------- 9 files changed, 77 insertions(+), 44 deletions(-) diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki b/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki index b4a37db26c..b439829ae2 100644 --- a/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki +++ b/doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki @@ -928,7 +928,7 @@ Fill out the first wizard page with 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.
+* '''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.
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: @@ -999,7 +999,7 @@ Fill out the first wizard page with 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.
+* '''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.
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. diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java index 5987f25cca..23fb11a067 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java @@ -47,7 +47,8 @@ public class CustomEventAspects { public static @NonNull Iterable> generateAspects(CustomTraceDefinition definition) { ImmutableList.Builder> 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()); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java index cc6b43302a..8b1a4eca0f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java @@ -270,9 +270,11 @@ public class CustomEvent extends TmfEvent { List 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)); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java index 4364a23b3e..20371425db 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java @@ -539,9 +539,11 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { 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) { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java index 6fc26120c8..a2319a2fcb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java @@ -195,9 +195,11 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { 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)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java index 7aa2c6499b..d1ec202d25 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java @@ -182,6 +182,7 @@ public class Messages extends NLS { 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; @@ -223,6 +224,7 @@ public class Messages extends NLS { 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; @@ -231,7 +233,6 @@ public class Messages extends NLS { 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; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties index 736fdf19c2..e2e0f058e7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties @@ -182,6 +182,7 @@ CustomTxtParserInputWizardPage_appendWith=Append with | 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: @@ -223,6 +224,7 @@ CustomTxtParserOutputWizardPage_description=Customize the output of the parser 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. @@ -231,7 +233,6 @@ CustomXmlParserInputWizardPage_invalidLogTypeError=Invalid character ':' in trac 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}). diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java index 3b646a44a9..dde744266c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java @@ -124,6 +124,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { 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; @@ -201,6 +202,13 @@ 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.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); @@ -359,7 +367,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { 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)); @@ -551,7 +559,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage { 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); @@ -868,7 +880,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage { 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$ @@ -1581,20 +1597,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage { 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); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java index 4f9cc2f623..f574f08499 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java @@ -121,6 +121,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { 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; @@ -207,6 +208,13 @@ 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.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); @@ -243,7 +251,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { 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)); @@ -620,7 +628,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage { 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) { @@ -807,7 +819,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage { 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$ @@ -1589,21 +1605,19 @@ public class CustomXmlParserInputWizardPage extends WizardPage { 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 { -- 2.34.1