tmf: bug 494698 Add per-event fields to custom parsers
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / internal / tmf / ui / parsers / wizards / CustomXmlParserInputWizardPage.java
index a9f966710ce462a25e64cd85a81c6712e02dcdeb..6a1f45b24ce43d2fda6768f0f70208e3a66aeb51 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -19,8 +19,10 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.text.ParseException;
+import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map.Entry;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -75,10 +77,11 @@ import org.eclipse.swt.widgets.Text;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.Messages;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.Tag;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute;
 import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
 import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
@@ -118,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;
@@ -204,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);
@@ -240,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));
@@ -380,7 +391,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
         addChildButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                CustomXmlInputElement inputElement = new CustomXmlInputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+                CustomXmlInputElement inputElement = new CustomXmlInputElement("", false, Tag.IGNORE, Tag.IGNORE.toString(), 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
                 if (definition.rootInputElement == null) {
                     definition.rootInputElement = inputElement;
                     inputElement.setElementName(getChildNameSuggestion(null));
@@ -402,7 +413,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
         addNextButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                CustomXmlInputElement inputElement = new CustomXmlInputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+                CustomXmlInputElement inputElement = new CustomXmlInputElement("", false, Tag.IGNORE, Tag.IGNORE.toString(), 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
                 if (definition.rootInputElement == null) {
                     definition.rootInputElement = inputElement;
                     inputElement.setElementName(getChildNameSuggestion(null));
@@ -430,7 +441,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 CustomXmlInputElement inputElement = null;
                 if (definition.rootInputElement == null) {
                     if (getChildNameSuggestion(null).length() != 0) {
-                        inputElement = new CustomXmlInputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+                        inputElement = new CustomXmlInputElement(getChildNameSuggestion(null), false, Tag.IGNORE, Tag.IGNORE.toString(), 0, "", null); //$NON-NLS-1$
                         definition.rootInputElement = inputElement;
                         feelingLucky(inputElement);
                     } else {
@@ -495,7 +506,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
             if (attributeName.length() == 0) {
                 break;
             }
-            CustomXmlInputAttribute attribute = new CustomXmlInputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+            CustomXmlInputAttribute attribute = new CustomXmlInputAttribute(attributeName, Tag.OTHER, attributeName, 0, ""); //$NON-NLS-1$
             inputElement.addAttribute(attribute);
         }
         while (true) {
@@ -503,7 +514,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
             if (childName.length() == 0) {
                 break;
             }
-            CustomXmlInputElement childElement = new CustomXmlInputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+            CustomXmlInputElement childElement = new CustomXmlInputElement(childName, false, Tag.IGNORE, Tag.IGNORE.toString(), 0, "", null); //$NON-NLS-1$
             inputElement.addChild(childElement);
             feelingLucky(childElement);
         }
@@ -617,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) {
@@ -648,42 +663,42 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
     }
 
     /**
-     * Get the global list of input names.
+     * Get the global list of inputs.
      *
-     * @return The list of input names
+     * @return The list of inputs
      */
-    public List<String> getInputNames() {
-        return getInputNames(definition.rootInputElement);
+    public List<Entry<Tag, String>> getInputs() {
+        return getInputs(definition.rootInputElement);
     }
 
     /**
-     * Get the list of input names for a given element.
+     * Get the list of inputs for a given element, recursively.
      *
      * @param inputElement
      *            The element
-     * @return The input names for this element
+     * @return The list of inputs
      */
-    public List<String> getInputNames(CustomXmlInputElement inputElement) {
-        List<String> inputs = new ArrayList<>();
-        if (inputElement.getInputName() != null && !inputElement.getInputName().equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
-            String inputName = inputElement.getInputName();
-            if (!inputs.contains(inputName)) {
-                inputs.add(inputName);
+    public List<Entry<Tag, String>> getInputs(CustomXmlInputElement inputElement) {
+        List<Entry<Tag, String>> inputs = new ArrayList<>();
+        if (inputElement.getInputTag() != null && !inputElement.getInputTag().equals(Tag.IGNORE)) {
+            Entry<Tag, String> input = new SimpleEntry<>(inputElement.getInputTag(), inputElement.getInputName());
+            if (!inputs.contains(input)) {
+                inputs.add(input);
             }
         }
         if (inputElement.getAttributes() != null) {
             for (CustomXmlInputAttribute attribute : inputElement.getAttributes()) {
-                String inputName = attribute.getInputName();
-                if (!inputs.contains(inputName)) {
-                    inputs.add(inputName);
+                Entry<Tag, String> input = new SimpleEntry<>(attribute.getInputTag(), attribute.getInputName());
+                if (!inputs.contains(input)) {
+                    inputs.add(input);
                 }
             }
         }
         if (inputElement.getChildElements() != null) {
             for (CustomXmlInputElement childInputElement : inputElement.getChildElements()) {
-                for (String inputName : getInputNames(childInputElement)) {
-                    if (!inputs.contains(inputName)) {
-                        inputs.add(inputName);
+                for (Entry<Tag, String> input : getInputs(childInputElement)) {
+                    if (!inputs.contains(input)) {
+                        inputs.add(input);
                     }
                 }
             }
@@ -804,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$
@@ -872,6 +891,8 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
         private Label previewLabel;
         private Text previewText;
         private Button logEntryButton;
+        private Button eventTypeButton;
+        private Text eventTypeText;
         private Label fillerLabel;
         private Composite addAttributeComposite;
         private Button addAttributeButton;
@@ -941,8 +962,14 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
                 tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
-                tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomTraceDefinition.TAG_TIMESTAMP,
-                        CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });
+                tagCombo.setItems(new String[] {
+                        Tag.IGNORE.toString(),
+                        Tag.TIMESTAMP.toString(),
+                        Tag.EVENT_TYPE.toString(),
+                        Tag.MESSAGE.toString(),
+                        Tag.EXTRA_FIELD_NAME.toString(),
+                        Tag.EXTRA_FIELD_VALUE.toString(),
+                        Tag.OTHER.toString() });
                 tagCombo.setVisibleItemCount(tagCombo.getItemCount());
                 tagCombo.addSelectionListener(new SelectionListener() {
                     @Override
@@ -965,13 +992,28 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                             tagText.addModifyListener(updateListener);
                             actionCombo.setVisible(true);
                             break;
-                        case 2: // Message
+                        case 2: // Event type
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 3: // Message
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 4: // Field names
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(false);
+                            break;
+                        case 5: // Field values
                             tagLabel.setVisible(false);
                             tagText.setVisible(false);
                             actionCombo.setVisible(true);
                             break;
-                        case 3: // Other
-                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                        case 6: // Other
+                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
                             tagLabel.setVisible(true);
                             if (tagText.getText().trim().length() == 0) {
                                 tagText.setText(elementNameText.getText().trim());
@@ -1003,26 +1045,72 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 actionCombo.select(inputElement.getInputAction());
                 actionCombo.addSelectionListener(updateListener);
 
-                if (inputElement.getInputName().equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+                if (inputElement.getInputTag().equals(Tag.IGNORE)) {
                     tagCombo.select(0);
                     tagLabel.setVisible(false);
                     tagText.setVisible(false);
                     actionCombo.setVisible(false);
-                } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                } else if (inputElement.getInputTag().equals(Tag.TIMESTAMP)) {
                     tagCombo.select(1);
                     tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
                     tagText.setText(inputElement.getInputFormat());
                     tagText.addModifyListener(updateListener);
-                } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                    actionCombo.setVisible(true);
+                } else if (inputElement.getInputTag().equals(Tag.EVENT_TYPE)) {
                     tagCombo.select(2);
                     tagLabel.setVisible(false);
                     tagText.setVisible(false);
-                } else {
+                    actionCombo.setVisible(true);
+                } else if (inputElement.getInputTag().equals(Tag.MESSAGE)) {
                     tagCombo.select(3);
-                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                    actionCombo.setVisible(true);
+                } else if (inputElement.getInputTag().equals(Tag.EXTRA_FIELD_NAME)) {
+                    tagCombo.select(4);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                    actionCombo.setVisible(false);
+                } else if (inputElement.getInputTag().equals(Tag.EXTRA_FIELD_VALUE)) {
+                    tagCombo.select(5);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                    actionCombo.setVisible(true);
+                } else {
+                    tagCombo.select(6);
+                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
                     tagText.setText(inputElement.getInputName());
                     tagText.addModifyListener(updateListener);
+                    actionCombo.setVisible(true);
                 }
+
+                eventTypeButton = new Button(group, SWT.CHECK);
+                eventTypeButton.setText(Messages.CustomTxtParserInputWizardPage_eventType);
+                eventTypeButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+                eventTypeButton.addSelectionListener(new SelectionAdapter() {
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        if (eventTypeButton.getSelection()) {
+                            eventTypeText.setEnabled(true);
+                        } else {
+                            eventTypeText.setEnabled(false);
+                        }
+                    }
+                });
+                eventTypeButton.addSelectionListener(updateListener);
+
+                eventTypeText = new Text(group, SWT.BORDER | SWT.SINGLE);
+                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+                gd.widthHint = 0;
+                eventTypeText.setLayoutData(gd);
+                if (inputElement.getEventType() != null) {
+                    eventTypeText.setText(inputElement.getEventType());
+                    eventTypeButton.setSelection(true);
+                } else {
+                    eventTypeText.setEnabled(false);
+                    eventTypeButton.setSelection(false);
+                }
+                eventTypeText.addModifyListener(updateListener);
             }
 
             if (inputElement.getAttributes() != null) {
@@ -1037,8 +1125,8 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
 
         private void updatePreview() {
             Element element = getPreviewElement(inputElement);
-            if (inputElement.getParentElement() != null) { // no preview text for
-                                                      // document element
+            // no preview text for document element
+            if (inputElement.getParentElement() != null) {
                 previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
                 if (element != null) {
                     previewText.setText(CustomXmlTrace.parseElement(element, new StringBuffer()).toString());
@@ -1047,11 +1135,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                             logEntryFound = true;
                             logEntriesCount++;
                         } else {
-                            logEntryButton.setSelection(false); // remove nested
-                                                                // log entry
+                            // remove nested log entry
+                            logEntryButton.setSelection(false);
                         }
                     }
-                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
+                    if (tagCombo.getText().equals(Tag.TIMESTAMP.toString()) && logEntriesCount <= 1) {
                         String value = previewText.getText().trim();
                         if (value.length() != 0) {
                             if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {
@@ -1067,8 +1155,8 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                                 }
                             } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
                                 if (timeStampValue != null) {
-                                    timeStampValue += " | " + value; //$NON-NLS-1$
-                                    timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$
+                                    timeStampValue += CustomTraceDefinition.SEPARATOR + value;
+                                    timeStampFormat += CustomTraceDefinition.SEPARATOR + tagText.getText().trim();
                                 } else {
                                     timeStampValue = value;
                                     timeStampFormat = tagText.getText().trim();
@@ -1083,7 +1171,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                     String value = element.getAttribute(attribute.attributeNameText.getText().trim());
                     if (value.length() != 0) {
                         attribute.previewText.setText(value);
-                        if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
+                        if (attribute.tagCombo.getText().equals(Tag.TIMESTAMP.toString()) && logEntriesCount <= 1) {
                             if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {
                                 timeStampValue = value;
                                 timeStampFormat = attribute.tagText.getText().trim();
@@ -1138,7 +1226,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 public void widgetSelected(SelectionEvent e) {
                     removeAddButton();
                     String attributeName = getAttributeNameSuggestion(inputElement);
-                    CustomXmlInputAttribute inputAttribute = new CustomXmlInputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+                    CustomXmlInputAttribute inputAttribute = new CustomXmlInputAttribute(attributeName, Tag.OTHER, attributeName, 0, ""); //$NON-NLS-1$
                     attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));
                     createAddButton();
                     elementContainer.layout();
@@ -1182,11 +1270,14 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
             inputElement.setElementName(elementNameText.getText().trim());
             if (inputElement.getParentElement() != null) {
                 inputElement.setLogEntry(logEntryButton.getSelection());
-                if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                inputElement.setEventType(eventTypeButton.getSelection() ? eventTypeText.getText().trim() : null);
+                Tag inputTag = Tag.fromLabel(tagCombo.getText());
+                inputElement.setInputTag(inputTag);
+                if (inputTag.equals(Tag.OTHER)) {
                     inputElement.setInputName(tagText.getText().trim());
                 } else {
-                    inputElement.setInputName(tagCombo.getText());
-                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                    inputElement.setInputName(inputTag.toString());
+                    if (inputTag.equals(Tag.TIMESTAMP)) {
                         inputElement.setInputFormat(tagText.getText().trim());
                     }
                 }
@@ -1198,16 +1289,17 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 String inputFormat = null;
                 Attribute attribute = attributes.get(i);
                 String attributeName = attribute.attributeNameText.getText().trim();
-                if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                Tag inputTag = Tag.fromLabel(attribute.tagCombo.getText());
+                if (inputTag.equals(Tag.OTHER)) {
                     inputName = attribute.tagText.getText().trim();
                 } else {
-                    inputName = attribute.tagCombo.getText();
-                    if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                    inputName = inputTag.toString();
+                    if (inputTag.equals(Tag.TIMESTAMP)) {
                         inputFormat = attribute.tagText.getText().trim();
                     }
                 }
                 int inputAction = attribute.actionCombo.getSelectionIndex();
-                inputElement.addAttribute(new CustomXmlInputAttribute(attributeName, inputName, inputAction, inputFormat));
+                inputElement.addAttribute(new CustomXmlInputAttribute(attributeName, inputTag, inputName, inputAction, inputFormat));
             }
         }
     }
@@ -1298,9 +1390,14 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
             tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
             tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
-            tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_MESSAGE,
-                    CustomTraceDefinition.TAG_OTHER });
-            tagCombo.select(2); // Other
+            tagCombo.setItems(new String[] {
+                    Tag.TIMESTAMP.toString(),
+                    Tag.EVENT_TYPE.toString(),
+                    Tag.MESSAGE.toString(),
+                    Tag.EXTRA_FIELD_NAME.toString(),
+                    Tag.EXTRA_FIELD_VALUE.toString(),
+                    Tag.OTHER.toString() });
+            tagCombo.select(3); // Other
             tagCombo.addSelectionListener(new SelectionListener() {
                 @Override
                 public void widgetDefaultSelected(SelectionEvent e) {
@@ -1315,19 +1412,37 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                         tagLabel.setVisible(true);
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
+                        actionCombo.setVisible(true);
+                        break;
+                    case 1: // Event type
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        actionCombo.setVisible(true);
+                        break;
+                    case 2: // Message
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        actionCombo.setVisible(true);
+                        break;
+                    case 3: // Field names
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        actionCombo.setVisible(false);
                         break;
-                    case 1: // Message
+                    case 4: // Field values
                         tagLabel.setVisible(false);
                         tagText.setVisible(false);
+                        actionCombo.setVisible(true);
                         break;
-                    case 2: // Other
-                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                    case 5: // Other
+                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
                         tagLabel.setVisible(true);
                         if (tagText.getText().trim().length() == 0) {
                             tagText.setText(attributeNameText.getText().trim());
                         }
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
+                        actionCombo.setVisible(true);
                         break;
                     default:
                         break;
@@ -1353,20 +1468,38 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
             actionCombo.select(inputAttribute.getInputAction());
             actionCombo.addSelectionListener(updateListener);
 
-            if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+            if (inputAttribute.getInputTag().equals(Tag.TIMESTAMP)) {
                 tagCombo.select(0);
                 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
                 tagText.setText(inputAttribute.getInputFormat());
                 tagText.addModifyListener(updateListener);
-            } else if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                actionCombo.setVisible(true);
+            } else if (inputAttribute.getInputTag().equals(Tag.EVENT_TYPE)) {
                 tagCombo.select(1);
                 tagLabel.setVisible(false);
                 tagText.setVisible(false);
-            } else {
+                actionCombo.setVisible(true);
+            } else if (inputAttribute.getInputTag().equals(Tag.MESSAGE)) {
                 tagCombo.select(2);
-                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                tagLabel.setVisible(false);
+                tagText.setVisible(false);
+                actionCombo.setVisible(true);
+            } else if (inputAttribute.getInputTag().equals(Tag.EXTRA_FIELD_NAME)) {
+                tagCombo.select(3);
+                tagLabel.setVisible(false);
+                tagText.setVisible(false);
+                actionCombo.setVisible(false);
+            } else if (inputAttribute.getInputTag().equals(Tag.EXTRA_FIELD_VALUE)) {
+                tagCombo.select(4);
+                tagLabel.setVisible(false);
+                tagText.setVisible(false);
+                actionCombo.setVisible(true);
+            } else {
+                tagCombo.select(5);
+                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
                 tagText.setText(inputAttribute.getInputName());
                 tagText.addModifyListener(updateListener);
+                actionCombo.setVisible(true);
             }
         }
 
@@ -1528,21 +1661,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 {
@@ -1587,7 +1718,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
             if (inputElement.isLogEntry()) {
                 logEntryFound = true;
             }
-            if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+            if (inputElement.getInputTag().equals(Tag.TIMESTAMP)) {
                 timeStampFound = true;
                 if (inputElement.getInputFormat().length() == 0) {
                     errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_elementMissingTimestampFmtError, getName(inputElement)));
@@ -1612,11 +1743,26 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 if (elementNode != null) {
                     elementNode.tagText.setBackground(COLOR_LIGHT_RED);
                 }
+            } else if (inputElement.getInputTag().equals(Tag.OTHER) && Tag.fromLabel(inputElement.getInputName()) != null) {
+                errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_elementReservedInputNameError, getName(inputElement)));
+                if (elementNode != null) {
+                    elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                }
             } else {
                 if (elementNode != null) {
                     elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
                 }
             }
+            if (inputElement.getEventType() != null && inputElement.getEventType().trim().isEmpty()) {
+                errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_emptyEventTypeError, getName(inputElement)));
+                if (elementNode != null) {
+                    elementNode.eventTypeText.setBackground(COLOR_LIGHT_RED);
+                }
+            } else {
+                if (elementNode != null) {
+                    elementNode.eventTypeText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
         }
         if (inputElement.getAttributes() != null) {
             if (elementNode != null) {
@@ -1647,7 +1793,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                         elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
                     }
                 }
-                if (attribute.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                if (attribute.getInputTag().equals(Tag.TIMESTAMP)) {
                     timeStampFound = true;
                     if (attribute.getInputFormat().length() == 0) {
                         errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_attributeMissingTimestampFmtError, getName(attribute, inputElement)));
@@ -1672,6 +1818,11 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                     if (elementNode != null) {
                         elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
                     }
+                } else if (attribute.getInputTag().equals(Tag.OTHER) && Tag.fromLabel(attribute.getInputName()) != null) {
+                    errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_attributeReservedInputNameError, getName(attribute, inputElement)));
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
+                    }
                 } else {
                     if (elementNode != null) {
                         elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
This page took 0.040603 seconds and 5 git commands to generate.