custom.parsers: bug 494697 Define event names in custom parsers
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 26 May 2016 21:20:03 +0000 (17:20 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 29 Jun 2016 19:53:08 +0000 (15:53 -0400)
In custom traces, all events had the same name which corresponded to the
custom parser name. Now it is possible to define a field for the custom
event type.

Change-Id: Icdef3b0dfc73e403b39bd7ceb0e8ff2afaa12db2
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/73803
Reviewed-by: Hudson CI
15 files changed:
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterTraceTypeNodeTest.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtEvent.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtEventType.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTrace.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlEvent.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlEventType.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/Messages.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/messages.properties
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/parsers/custom/TestCustomTxtWizard.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java

index 7ecbb3b3357f6b8ae4d6d8a3e2b3eee512e95fe3..65a81e01a6bfca8b3375bda93f46d4982f9e0cc9 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 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
@@ -20,6 +20,7 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
@@ -60,8 +61,8 @@ public class TmfFilterTraceTypeNodeTest extends TmfFilterTreeNodeTestBase {
 
     private static final String CATEGORY_TXT = "txt";
     private static final String CATEGORY_XML = "xml";
-    private static final String DEFINITION_NAME_TXT = "name txt";
-    private static final String DEFINITION_NAME_XML = "name xml";
+    private static final @NonNull String DEFINITION_NAME_TXT = "name txt";
+    private static final @NonNull String DEFINITION_NAME_XML = "name xml";
     private static final String SEP = ":";
     private static final String CUSTOM_TXT_TRACE_TYPE_PREFIX = "custom.txt.trace" + SEP;
     private static final String CUSTOM_XML_TRACE_TYPE_PREFIX = "custom.xml.trace" + SEP;
@@ -76,8 +77,8 @@ public class TmfFilterTraceTypeNodeTest extends TmfFilterTreeNodeTestBase {
     }
     private static CustomTxtTrace fCustomTxtTrace = new CustomTxtTrace(fCustomTxtDefinition);
     private static CustomXmlTrace fCustomXmlTrace = new CustomXmlTrace(fCustomXmlDefinition);
-    private static TmfEventType fCustomTxtEventType = new CustomTxtEventType(fCustomTxtDefinition);
-    private static TmfEventType fCustomXmlEventType = new CustomXmlEventType(fCustomXmlDefinition);
+    private static TmfEventType fCustomTxtEventType = new CustomTxtEventType(DEFINITION_NAME_TXT, null);
+    private static TmfEventType fCustomXmlEventType = new CustomXmlEventType(DEFINITION_NAME_XML, null);
     private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
     private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
     private TmfEvent fEvent2 = new CustomTxtEvent(fCustomTxtDefinition, fCustomTxtTrace, TmfTimestamp.fromNanos(2), fCustomTxtEventType);
index 14333459bd210309d89a56ee01a7e715e419791a..f1bae00e172734ea2d8923b6015c230b7255f246 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
@@ -147,6 +147,14 @@ public class CustomEvent extends TmfEvent {
         return customEventType;
     }
 
+    @Override
+    public String getName() {
+        if (fData != null) {
+            processData();
+        }
+        return super.getName();
+    }
+
     // ------------------------------------------------------------------------
     // Setters
     // ------------------------------------------------------------------------
@@ -233,6 +241,13 @@ public class CustomEvent extends TmfEvent {
             setTimestamp(TmfTimestamp.ZERO);
         }
 
+        // Update the custom event type of this event if set
+        String eventName = fData.get(CustomTraceDefinition.TAG_EVENT_TYPE);
+        ITmfEventType type = getType();
+        if (eventName != null && type instanceof CustomEventType) {
+            ((CustomEventType) type).setName(eventName);
+        }
+
         int i = 0;
         fColumnData = new TmfEventField[fDefinition.outputs.size()];
         for (OutputColumn outputColumn : fDefinition.outputs) {
index 08b7c9c7c29111b31a0647e990f35b222b86e644..49014c187c76cc752b2b5a3a10e9b44ea06e64eb 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
@@ -14,6 +14,7 @@ package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
@@ -25,17 +26,53 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
  */
 public abstract class CustomEventType extends TmfEventType {
 
+    private static final @NonNull String EMPTY = ""; //$NON-NLS-1$
+    private @NonNull String fEventName;
+
     /**
      * Constructor
      *
      * @param definition
      *            Trace definition
+     * @deprecated Use {@link #CustomEventType(String, ITmfEventField)} instead.
      */
+    @Deprecated
     public CustomEventType(CustomTraceDefinition definition) {
-        super(checkNotNull(definition.definitionName), getRootField(definition));
+        super(EMPTY, getRootField(definition));
+        fEventName = checkNotNull(definition.definitionName);
+    }
+
+    /**
+     * Constructor
+     *
+     * @param eventName
+     *            the event name
+     * @param root
+     *            the root field
+     * @since 2.1
+     */
+    public CustomEventType(@NonNull String eventName, ITmfEventField root) {
+        super(EMPTY, root);
+        fEventName = eventName;
+    }
+
+    @Override
+    public @NonNull String getName() {
+        return fEventName;
+    }
+
+    /**
+     * Set the event name.
+     *
+     * @param eventName
+     *            the event name
+     * @since 2.1
+     */
+    public void setName(@NonNull String eventName) {
+        fEventName = eventName;
     }
 
-    private static ITmfEventField getRootField(CustomTraceDefinition definition) {
+    static ITmfEventField getRootField(CustomTraceDefinition definition) {
         ITmfEventField[] fields = new ITmfEventField[definition.outputs.size()];
         for (int i = 0; i < fields.length; i++) {
             fields[i] = new TmfEventField(definition.outputs.get(i).name, null, null);
@@ -44,4 +81,23 @@ public abstract class CustomEventType extends TmfEventType {
         return rootField;
     }
 
+    @Override
+    public int hashCode() {
+        int result = super.hashCode();
+        result += fEventName.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (super.equals(obj) && (obj.getClass().equals(getClass()))) {
+            return fEventName.equals(((CustomEventType) obj).fEventName);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return fEventName;
+    }
 }
index 93ef98ec644f687f0c741d0f827a73d57563f268..d2b9935b591c6c63048079ac92cd0323c428ccb8 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2015 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
@@ -49,6 +49,10 @@ public abstract class CustomTraceDefinition {
     /** "Other" tag */
     public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;
 
+    /** Event type tag
+     * @since 2.1*/
+    public static final String TAG_EVENT_TYPE = Messages.CustomTraceDefinition_eventTypeTag;
+
     /** Category of this trace definition */
     public String categoryName;
 
index 13cdfce413266b8c3d8b12456f56296548e8aa6f..02f3954c3d78b132ffe814b88273c6a36b705e2a 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
@@ -38,7 +38,6 @@ public class CustomTxtEvent extends CustomEvent {
      */
     public CustomTxtEvent(CustomTxtTraceDefinition definition) {
         super(definition);
-        setType(new CustomTxtEventType(definition));
     }
 
     /**
index aaca34a7bfcb5d8d2d792729316f2edcd7f17630..613373f9d77df64e3adee710f749a68ed41c9286 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
@@ -12,6 +12,9 @@
 
 package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+
 /**
  * Event type for custom text traces.
  *
@@ -24,9 +27,25 @@ public class CustomTxtEventType extends CustomEventType {
      *
      * @param definition
      *            Custom text trace definition
+     * @deprecated Use {@link #CustomTxtEventType(String, ITmfEventField)}
+     *             instead.
      */
+    @Deprecated
     public CustomTxtEventType(CustomTxtTraceDefinition definition) {
         super(definition);
     }
 
+    /**
+     * Constructor
+     *
+     * @param eventName
+     *            the event name
+     * @param root
+     *            the root field
+     * @since 2.1
+     */
+    public CustomTxtEventType(@NonNull String eventName, ITmfEventField root) {
+        super(eventName, root);
+    }
+
 }
index e89e3e42c75d6a15862677755f76019b29a21aa0..318a56660b1d3676040b694c22ad0b45b37130b2 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2015 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
@@ -33,6 +33,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
@@ -66,9 +67,9 @@ public class CustomTxtTrace extends TmfTrace implements ITmfPersistentlyIndexabl
     private static final int MAX_CONFIDENCE = 100;
 
     private final CustomTxtTraceDefinition fDefinition;
-    private final CustomTxtEventType fEventType;
+    private final ITmfEventField fRootField;
     private BufferedRandomAccessFile fFile;
-    private final String fTraceTypeId;
+    private final @NonNull String fTraceTypeId;
 
     private static final char SEPARATOR = ':';
     private static final String CUSTOM_TXT_TRACE_TYPE_PREFIX = "custom.txt.trace" + SEPARATOR; //$NON-NLS-1$
@@ -83,7 +84,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfPersistentlyIndexabl
      */
     public CustomTxtTrace(final CustomTxtTraceDefinition definition) {
         fDefinition = definition;
-        fEventType = new CustomTxtEventType(fDefinition);
+        fRootField = CustomEventType.getRootField(definition);
         fTraceTypeId = buildTraceTypeId(definition.categoryName, definition.definitionName);
         setCacheSize(DEFAULT_CACHE_SIZE);
     }
@@ -413,7 +414,8 @@ public class CustomTxtTrace extends TmfTrace implements ITmfPersistentlyIndexabl
      * @return The first event
      */
     public CustomTxtEvent parseFirstLine(final CustomTxtTraceContext context) {
-        final CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.ZERO, fEventType);
+        CustomTxtEventType eventType = new CustomTxtEventType(checkNotNull(fDefinition.definitionName), fRootField);
+        final CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.ZERO, eventType);
         event.processGroups(context.inputLine, context.firstLineMatcher);
         event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine)));
         return event;
index fc4f9674d1b1cd0532507b16a9cbd7d3f8949f48..ba862b54849d4e030a3b06d4e75d019e6363c688 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
@@ -34,7 +34,6 @@ public class CustomXmlEvent extends CustomEvent {
      */
     public CustomXmlEvent(CustomXmlTraceDefinition definition) {
         super(definition);
-        setType(new CustomXmlEventType(definition));
     }
 
     /**
index 58293579e5c986aa73955bad6521b8c139b063c3..90156b9fc2cd4d4e8fb9c03950f7873807109749 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
@@ -12,6 +12,9 @@
 
 package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+
 /**
  * Event type class for custom XML traces.
  *
@@ -24,9 +27,25 @@ public class CustomXmlEventType extends CustomEventType {
      *
      * @param definition
      *            Trace definition
+     * @deprecated Use {@link #CustomXmlEventType(String, ITmfEventField)}
+     *             instead.
      */
+    @Deprecated
     public CustomXmlEventType(CustomXmlTraceDefinition definition) {
         super(definition);
     }
 
+    /**
+     * Constructor
+     *
+     * @param eventName
+     *            the event name
+     * @param root
+     *            the root field
+     * @since 2.1
+     */
+    public CustomXmlEventType(@NonNull String eventName, ITmfEventField root) {
+        super(eventName, root);
+    }
+
 }
index 65326e6e7e2b8ac9c6f0ed14e19c5fb1956ee841..1ac4a245cf898b0dffdc63bb8271f931b6ad83b8 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2015 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
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -31,6 +33,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
@@ -72,10 +75,10 @@ public class CustomXmlTrace extends TmfTrace implements ITmfPersistentlyIndexabl
     private static final int CONFIDENCE = 100;
 
     private final CustomXmlTraceDefinition fDefinition;
-    private final CustomXmlEventType fEventType;
+    private final ITmfEventField fRootField;
     private final CustomXmlInputElement fRecordInputElement;
     private BufferedRandomAccessFile fFile;
-    private final String fTraceTypeId;
+    private final @NonNull String fTraceTypeId;
 
     private static final char SEPARATOR = ':';
     private static final String CUSTOM_XML_TRACE_TYPE_PREFIX = "custom.xml.trace" + SEPARATOR; //$NON-NLS-1$
@@ -90,7 +93,7 @@ public class CustomXmlTrace extends TmfTrace implements ITmfPersistentlyIndexabl
      */
     public CustomXmlTrace(final CustomXmlTraceDefinition definition) {
         fDefinition = definition;
-        fEventType = new CustomXmlEventType(fDefinition);
+        fRootField = CustomEventType.getRootField(definition);
         fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement);
         fTraceTypeId = buildTraceTypeId(definition.categoryName, definition.definitionName);
         setCacheSize(DEFAULT_CACHE_SIZE);
@@ -506,7 +509,8 @@ public class CustomXmlTrace extends TmfTrace implements ITmfPersistentlyIndexabl
      * @return The extracted event
      */
     public CustomXmlEvent extractEvent(final Element element, final CustomXmlInputElement inputElement) {
-        final CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.ZERO, fEventType);
+        CustomXmlEventType eventType = new CustomXmlEventType(checkNotNull(fDefinition.definitionName), fRootField);
+        final CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.ZERO, eventType);
         event.setContent(new CustomEventContent(event, new StringBuffer()));
         parseElement(element, event, inputElement);
         return event;
index b6c2de94667a46b1e681b6f6c476329e9387872a..282862bfe749c4c809d6de33c3a9c80154b0e70d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson.
+ * Copyright (c) 2013, 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 accompanies this distribution, and is available at
@@ -21,6 +21,8 @@ public class Messages extends NLS {
     public static String CustomTrace_FileNotFound;
 
     // TODO: These strings should not be externalized
+    /** @since 2.1 */
+    public static String CustomTraceDefinition_eventTypeTag;
     public static String CustomTraceDefinition_messageTag;
     public static String CustomTraceDefinition_otherTag;
     public static String CustomTraceDefinition_timestampTag;
index 5f12afdde8435e6e1e6734fc78eec502cc4f21f6..996150ebdb204998c247d62118a80f30d8df3070 100644 (file)
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2013, 2014 Ericsson
+# Copyright (c) 2013, 2016 Ericsson
 #
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
 
 CustomTrace_FileNotFound=File not found
 
+CustomTraceDefinition_eventTypeTag=Event type
 CustomTraceDefinition_messageTag=Message
 CustomTraceDefinition_otherTag=Other
 CustomTraceDefinition_timestampTag=Time Stamp
index 7c8fd433218e202fcfc9db731a1239154dbc69a0..f524162df6c0a27499b10b821e842bf0e14a0860 100644 (file)
@@ -97,10 +97,11 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard {
     @Test
     public void testNew() throws FileNotFoundException, IOException {
         File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_txt_parsers.xml").toFile();
+        // Open the custom parsers dialog
         SWTBotUtils.createProject(PROJECT_NAME);
-        SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
-        proejctExplorerBot.show();
-        SWTBotTreeItem treeItem = proejctExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
+        SWTBotView projectExplorerBot = fBot.viewByTitle("Project Explorer");
+        projectExplorerBot.show();
+        SWTBotTreeItem treeItem = projectExplorerBot.bot().tree().getTreeItem(PROJECT_NAME);
         treeItem.select();
         treeItem.expand();
         SWTBotTreeItem treeNode = null;
@@ -116,15 +117,21 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard {
         fBot.waitUntil(Conditions.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE));
         fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
 
+        // Open the new custom txt parser dialog
         fBot.button("New...").click();
         fBot.waitUntil(Conditions.shellIsActive(CUSTOM_TEXT_PARSER_SHELL_TITLE));
 
+        // Setting header
         fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
         fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
         fBot.textWithLabel("Time Stamp format:").setText("ss");
+
+        // Fill Group 1 as time stamp
         fBot.comboBox(1).setSelection("Time Stamp");
         fBot.textWithLabel("format:").setText("ss");
+        // Click on the New group button
         fBot.button(8).click();
+        // Add next line
         fBot.button(2).click();
         SWTBotTreeItem[] treeItems = fBot.tree().getAllItems();
         SWTBotTreeItem eventLine[] = new SWTBotTreeItem[2];
@@ -139,12 +146,14 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard {
         }
         assertNotNull(eventLine[0]);
         assertNotNull(eventLine[1]);
+        // Set the regular expression for each event line
         fBot.styledText().setText("12 Hello\nWorld\n23 Goodbye\ncruel world");
         eventLine[0].select();
         SWTBotUtils.waitForJobs();
         fBot.textWithLabel("Regular expression:").setText("\\s*(\\d\\d)\\s(.*\\S)");
         eventLine[1].select();
         fBot.textWithLabel("Regular expression:").setText("([^0-9]*)");
+        // Click on the new group of root line 2
         fBot.button(7).click();
         fBot.comboBox("Set").setSelection("Append with |");
         fBot.button("Highlight All").click();
@@ -204,6 +213,7 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard {
             fw.write(xmlContent);
             fw.flush();
         }
+        // Open the custom parsers dialog
         SWTBotUtils.createProject(PROJECT_NAME);
         SWTBotView proejctExplorerBot = fBot.viewByTitle("Project Explorer");
         proejctExplorerBot.show();
@@ -221,14 +231,18 @@ public class TestCustomTxtWizard extends AbstractCustomParserWizard {
         assertNotNull(treeNode);
         treeNode.contextMenu("Manage Custom Parsers...").click();
         fBot.waitUntil(Conditions.shellIsActive(MANAGE_CUSTOM_PARSERS_SHELL_TITLE));
+        // Open the edition dialog for txt parser
         fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).setFocus();
         fBot.list().select("Demo Category : Demo trace");
         fBot.button("Edit...").click();
         fBot.waitUntil(Conditions.shellIsActive(CUSTOM_TEXT_PARSER_SHELL_TITLE));
 
+        // update parser's data
         fBot.textWithLabel("Category:").setText(CATEGORY_NAME);
         fBot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
         fBot.textWithLabel("Time Stamp format:").setText("ss");
+
+        // update time stamp format
         fBot.comboBox(1).setSelection("Time Stamp");
         fBot.textWithLabel("format:").setText("ss");
         fBot.button(2).click();
index 88f0a8941ea46f8749d0c7c4cd36d20452770d5d..44b3b2914f5e012fd51392fe92b7ecea46e44cec 100644 (file)
@@ -1234,10 +1234,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                         inputGroup.tagLabel.setVisible(true);
                         inputGroup.tagText.setVisible(true);
                         inputGroup.tagText.addModifyListener(updateListener);
-                    } else if (inputData.name.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                    } else if (inputData.name.equals(CustomTraceDefinition.TAG_EVENT_TYPE)) {
                         inputGroup.tagCombo.select(1);
-                    } else {
+                    } else if (inputData.name.equals(CustomTraceDefinition.TAG_MESSAGE)) {
                         inputGroup.tagCombo.select(2);
+                    } else {
+                        inputGroup.tagCombo.select(3);
                         inputGroup.tagText.setText(inputData.name);
                         inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_name);
                         inputGroup.tagLabel.setVisible(true);
@@ -1409,9 +1411,10 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
             tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
             tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP,
+                    CustomTraceDefinition.TAG_EVENT_TYPE,
                     CustomTraceDefinition.TAG_MESSAGE,
-                    CustomTraceDefinition.TAG_OTHER });
-            tagCombo.select(1);
+                    CustomTraceDefinition.TAG_OTHER});
+            tagCombo.select(2);
             tagCombo.addSelectionListener(new SelectionListener() {
                 @Override
                 public void widgetDefaultSelected(SelectionEvent e) {
@@ -1427,20 +1430,20 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
                         break;
-                    case 1: // Message
+                    case 1: // Event type
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        break;
+                    case 2: // Message
                         tagLabel.setVisible(false);
                         tagText.setVisible(false);
                         break;
-                    case 2: // Other
+                    case 3: // Other
                         tagLabel.setText(Messages.CustomTxtParserInputWizardPage_name);
                         tagLabel.setVisible(true);
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
                         break;
-                    case 3: // Continue
-                        tagLabel.setVisible(false);
-                        tagText.setVisible(false);
-                        break;
                     default:
                         break;
                     }
index 61325a1afe3d4774281ba85442d68513196e1bb0..bd6ff9c02d8eeeab5f751af4ba70b398df932f7b 100644 (file)
@@ -942,7 +942,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
 
                 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 });
+                        CustomTraceDefinition.TAG_EVENT_TYPE, CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });
                 tagCombo.setVisibleItemCount(tagCombo.getItemCount());
                 tagCombo.addSelectionListener(new SelectionListener() {
                     @Override
@@ -965,12 +965,17 @@ 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: // Other
+                        case 3: // Message
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 4: // Other
                             tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
                             tagLabel.setVisible(true);
                             if (tagText.getText().trim().length() == 0) {
@@ -1013,12 +1018,16 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                     tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
                     tagText.setText(inputElement.getInputFormat());
                     tagText.addModifyListener(updateListener);
-                } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_EVENT_TYPE)) {
                     tagCombo.select(2);
                     tagLabel.setVisible(false);
                     tagText.setVisible(false);
-                } else {
+                } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
                     tagCombo.select(3);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                } else {
+                    tagCombo.select(4);
                     tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
                     tagText.setText(inputElement.getInputName());
                     tagText.addModifyListener(updateListener);
@@ -1298,9 +1307,9 @@ 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[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_EVENT_TYPE,
+                    CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });
+            tagCombo.select(3); // Other
             tagCombo.addSelectionListener(new SelectionListener() {
                 @Override
                 public void widgetDefaultSelected(SelectionEvent e) {
@@ -1316,11 +1325,15 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
                         break;
-                    case 1: // Message
+                    case 1: // Event type
                         tagLabel.setVisible(false);
                         tagText.setVisible(false);
                         break;
-                    case 2: // Other
+                    case 2: // Message
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        break;
+                    case 3: // Other
                         tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
                         tagLabel.setVisible(true);
                         if (tagText.getText().trim().length() == 0) {
@@ -1358,12 +1371,16 @@ public class CustomXmlParserInputWizardPage extends WizardPage {
                 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
                 tagText.setText(inputAttribute.getInputFormat());
                 tagText.addModifyListener(updateListener);
-            } else if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
+            } else if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_EVENT_TYPE)) {
                 tagCombo.select(1);
                 tagLabel.setVisible(false);
                 tagText.setVisible(false);
-            } else {
+            } else if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
                 tagCombo.select(2);
+                tagLabel.setVisible(false);
+                tagText.setVisible(false);
+            } else {
+                tagCombo.select(3);
                 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
                 tagText.setText(inputAttribute.getInputName());
                 tagText.addModifyListener(updateListener);
This page took 0.03939 seconds and 5 git commands to generate.