Convert Windows line delimiters to Unix.
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 2 Oct 2012 21:02:07 +0000 (17:02 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 2 Oct 2012 21:02:07 +0000 (17:02 -0400)
Change-Id: Idb33e8cc17d49436d2ed3edd49869cf965c86d13

118 files changed:
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/Attributes.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/viewers/events/LTTng2EventsTable.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/common/EventIterator.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowEntry.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowEvent.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowPresentationProvider.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesEntry.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesEvent.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesPresentationProvider.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/Tracer.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/ITmfFilter.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/ITmfFilterTreeNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterOrNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterRootNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/xml/TmfFilterContentHandler.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/xml/TmfFilterXMLParser.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/xml/TmfFilterXMLWriter.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/io/BufferedRandomAccessFile.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfTraceSelectedSignal.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/adaption/TsfImplProvider.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/EventImpl.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceImpl.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/model/TraceModelImplFactory.java
org.eclipse.linuxtools.tmf.ui/plugin.xml
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/TmfUiTracer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/commands/ManageCustomParsersCommandHandler.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/dialogs/ManageCustomParsersDialog.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/editors/handlers/AddBookmarkHandler.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventContent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventType.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventsTable.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTraceDefinition.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtEventType.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTraceContext.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlEventType.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTraceContext.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserWizard.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomXmlParserWizard.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/signal/TmfTraceClosedSignal.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/signal/TmfTraceOpenedSignal.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/signal/TmfTraceParserUpdatedSignal.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/ITmfTraceEditor.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditor.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditorInput.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfMultiPageEditorPart.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentFolder.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/signal/TmfTraceClosedSignal.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/signal/TmfTraceOpenedSignal.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/signal/TmfTraceParserUpdatedSignal.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/ITmfEventsFilterListener.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/ITmfEventsFilterProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorSetting.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorSettingsManager.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorSettingsXML.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/IColorSettingsListener.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterDialog.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterManager.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterTreeContentProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterTreeLabelProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartDecorationProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/rawviewer/TmfRawEventViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphPresentationProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphRangeListener.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphSelectionListener.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphTimeListener.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphTreeListener.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphPresentationProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphRangeUpdateEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphSelectionEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphTimeEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphTreeExpansionEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphLegend.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITimeEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/TimeEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphBaseControl.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphColorScheme.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphItem.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphSelection.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/ColumnData.java

index 2867c22b569ff17de7794623caf3202b41a22e67..d02918608aafd2572ed7b42f3b0cd02879926ac3 100644 (file)
@@ -34,11 +34,11 @@ public abstract class Attributes {
 
     /* Sub-attributes of the CPU nodes */
     public static final String CURRENT_THREAD = "Current_thread";
-    public static final String STATUS = "Status";\r
+    public static final String STATUS = "Status";
 
     /* Sub-attributes of the Thread nodes */
     public static final String PPID = "PPID";
-    //public static final String STATUS = "Status"\r
+    //public static final String STATUS = "Status"
     public static final String EXEC_NAME = "Exec_name";
     public static final String SYSTEM_CALL = "System_call";
 
index c805a5d9956f554e217af919eedc9979de7fee89..8911c963f8bc3fcb0322fcf750c1cabf5de96027 100644 (file)
@@ -165,11 +165,11 @@ class CtfKernelHandler implements Runnable {
                 quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
                 value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
                 ss.modifyAttribute(ts, value, quark);
-\r
-                /* Change the status of the CPU to interrupted */\r
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);\r
-                value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IRQ);\r
-                ss.modifyAttribute(ts, value, quark);\r
+
+                /* Change the status of the CPU to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IRQ);
+                ss.modifyAttribute(ts, value, quark);
             }
                 break;
 
@@ -185,9 +185,9 @@ class CtfKernelHandler implements Runnable {
 
                 /* Set the previous process back to running */
                 setProcessToRunning(ts, currentThreadNode);
-\r
-                /* Set the CPU status back to running or "idle" */\r
-                cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);\r
+
+                /* Set the CPU status back to running or "idle" */
+                cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);
             }
                 break;
 
@@ -206,11 +206,11 @@ class CtfKernelHandler implements Runnable {
                 quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
                 value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
                 ss.modifyAttribute(ts, value, quark);
-\r
-                /* Change the status of the CPU to interrupted */\r
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);\r
-                value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_SOFTIRQ);\r
-                ss.modifyAttribute(ts, value, quark);\r
+
+                /* Change the status of the CPU to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_SOFTIRQ);
+                ss.modifyAttribute(ts, value, quark);
             }
                 break;
 
@@ -226,9 +226,9 @@ class CtfKernelHandler implements Runnable {
 
                 /* Set the previous process back to running */
                 setProcessToRunning(ts, currentThreadNode);
-\r
-                /* Set the CPU status back to "busy" or "idle" */\r
-                cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);\r
+
+                /* Set the CPU status back to "busy" or "idle" */
+                cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);
             }
                 break;
 
@@ -291,7 +291,7 @@ class CtfKernelHandler implements Runnable {
                 quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
                 value = TmfStateValue.newValueInt(nextTid);
                 ss.modifyAttribute(ts, value, quark);
-\r
+
                 /* Set the status of the CPU itself */
                 if (nextTid > 0) {
                     /* Check if the entering process is in kernel or user mode */
@@ -300,12 +300,12 @@ class CtfKernelHandler implements Runnable {
                         value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
                     } else {
                         value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
-                    }\r
-                } else {\r
-                    value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);\r
+                    }
+                } else {
+                    value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
                 }
                 quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-                ss.modifyAttribute(ts, value, quark);\r
+                ss.modifyAttribute(ts, value, quark);
             }
                 break;
 
@@ -543,22 +543,22 @@ class CtfKernelHandler implements Runnable {
         quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
         ss.modifyAttribute(ts, value, quark);
     }
-\r
-    /**\r
-     * Similar logic as above, but to set the CPU's status when it's coming out\r
-     * of an interruption.\r
-     * @throws AttributeNotFoundException\r
-     * @throws StateValueTypeException\r
-     * @throws TimeRangeException\r
-     */\r
-    private void cpuExitInterrupt(long ts, int currentCpuNode, int currentThreadNode)\r
-            throws StateValueTypeException, AttributeNotFoundException,\r
-            TimeRangeException {\r
-        int quark;\r
-        ITmfStateValue value;\r
-\r
-        quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);\r
-        if (ss.queryOngoingState(quark).unboxInt() > 0) {\r
+
+    /**
+     * Similar logic as above, but to set the CPU's status when it's coming out
+     * of an interruption.
+     * @throws AttributeNotFoundException
+     * @throws StateValueTypeException
+     * @throws TimeRangeException
+     */
+    private void cpuExitInterrupt(long ts, int currentCpuNode, int currentThreadNode)
+            throws StateValueTypeException, AttributeNotFoundException,
+            TimeRangeException {
+        int quark;
+        ITmfStateValue value;
+
+        quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);
+        if (ss.queryOngoingState(quark).unboxInt() > 0) {
             /* There was a process on the CPU */
             quark = ss.getQuarkRelative(currentThreadNode, Attributes.SYSTEM_CALL);
             if (ss.queryOngoingState(quark).isNull()) {
@@ -568,11 +568,11 @@ class CtfKernelHandler implements Runnable {
                 /* That process was in a system call */
                 value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
             }
-        } else {\r
-            /* There was no real process scheduled, CPU was idle */\r
-            value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);\r
-        }\r
-        quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);\r
-        ss.modifyAttribute(ts, value, quark);\r
-    }\r
+        } else {
+            /* There was no real process scheduled, CPU was idle */
+            value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
+        }
+        quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);
+        ss.modifyAttribute(ts, value, quark);
+    }
 }
index 6fa7d7867d4a446d0d7a60829507229135bd5555..09fc768d74d829c1594402d3bd8c714d12f6757f 100644 (file)
@@ -1,40 +1,40 @@
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui;\r
-\r
-import org.eclipse.osgi.util.NLS;\r
-\r
-@SuppressWarnings("javadoc")\r
-public class Messages extends NLS {\r
-    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.lttng2.kernel.ui.messages"; //$NON-NLS-1$\r
-\r
-    public static String ControlFlowView_birthTimeColumn;\r
-    public static String ControlFlowView_tidColumn;\r
-    public static String ControlFlowView_ptidColumn;\r
-    public static String ControlFlowView_processColumn;\r
-    public static String ControlFlowView_traceColumn;\r
-\r
-    public static String ControlFlowView_stateTypeName;\r
-    public static String ControlFlowView_nextProcessActionNameText;\r
-    public static String ControlFlowView_nextProcessActionToolTipText;\r
-    public static String ControlFlowView_previousProcessActionNameText;\r
-    public static String ControlFlowView_previousProcessActionToolTipText;\r
-\r
-    public static String ControlFlowView_attributeSyscallName;\r
-    public static String ControlFlowView_attributeCpuName;\r
-\r
-    public static String ResourcesView_stateTypeName;\r
-    public static String ResourcesView_nextResourceActionNameText;\r
-    public static String ResourcesView_nextResourceActionToolTipText;\r
-    public static String ResourcesView_previousResourceActionNameText;\r
-    public static String ResourcesView_previousResourceActionToolTipText;\r
-    public static String ResourcesView_attributeCpuName;\r
-    public static String ResourcesView_attributeIrqName;\r
-    public static String ResourcesView_attributeSoftIrqName;\r
-\r
-    static {\r
-        // initialize resource bundle\r
-        NLS.initializeMessages(BUNDLE_NAME, Messages.class);\r
-    }\r
-\r
-    private Messages() {\r
-    }\r
-}\r
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+@SuppressWarnings("javadoc")
+public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.lttng2.kernel.ui.messages"; //$NON-NLS-1$
+
+    public static String ControlFlowView_birthTimeColumn;
+    public static String ControlFlowView_tidColumn;
+    public static String ControlFlowView_ptidColumn;
+    public static String ControlFlowView_processColumn;
+    public static String ControlFlowView_traceColumn;
+
+    public static String ControlFlowView_stateTypeName;
+    public static String ControlFlowView_nextProcessActionNameText;
+    public static String ControlFlowView_nextProcessActionToolTipText;
+    public static String ControlFlowView_previousProcessActionNameText;
+    public static String ControlFlowView_previousProcessActionToolTipText;
+
+    public static String ControlFlowView_attributeSyscallName;
+    public static String ControlFlowView_attributeCpuName;
+
+    public static String ResourcesView_stateTypeName;
+    public static String ResourcesView_nextResourceActionNameText;
+    public static String ResourcesView_nextResourceActionToolTipText;
+    public static String ResourcesView_previousResourceActionNameText;
+    public static String ResourcesView_previousResourceActionToolTipText;
+    public static String ResourcesView_attributeCpuName;
+    public static String ResourcesView_attributeIrqName;
+    public static String ResourcesView_attributeSoftIrqName;
+
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
index 27ff12516c7c1a426d45e3524f84736c776b2acd..ea6c7755d76547970509d6432b22671d04158cae 100644 (file)
@@ -1,23 +1,23 @@
-ControlFlowView_birthTimeColumn=Birth time\r
-ControlFlowView_tidColumn=TID\r
-ControlFlowView_ptidColumn=PTID\r
-ControlFlowView_processColumn=Process\r
-ControlFlowView_traceColumn=Trace\r
-\r
-ControlFlowView_stateTypeName=Process\r
-ControlFlowView_nextProcessActionNameText=Next Process\r
-ControlFlowView_nextProcessActionToolTipText=Select Next Process\r
-ControlFlowView_previousProcessActionNameText=Previous Process\r
-ControlFlowView_previousProcessActionToolTipText=Select Previous Process\r
-\r
-ControlFlowView_attributeSyscallName=System Call\r
-ControlFlowView_attributeCpuName=CPU\r
-\r
-ResourcesView_stateTypeName=Resource\r
-ResourcesView_nextResourceActionNameText=Next Resource\r
-ResourcesView_nextResourceActionToolTipText=Select Next Resource\r
-ResourcesView_previousResourceActionNameText=Previous Resource\r
-ResourcesView_previousResourceActionToolTipText=Select Previous Resource\r
-ResourcesView_attributeCpuName=CPU\r
-ResourcesView_attributeIrqName=IRQ\r
-ResourcesView_attributeSoftIrqName=SOFT IRQ\r
+ControlFlowView_birthTimeColumn=Birth time
+ControlFlowView_tidColumn=TID
+ControlFlowView_ptidColumn=PTID
+ControlFlowView_processColumn=Process
+ControlFlowView_traceColumn=Trace
+
+ControlFlowView_stateTypeName=Process
+ControlFlowView_nextProcessActionNameText=Next Process
+ControlFlowView_nextProcessActionToolTipText=Select Next Process
+ControlFlowView_previousProcessActionNameText=Previous Process
+ControlFlowView_previousProcessActionToolTipText=Select Previous Process
+
+ControlFlowView_attributeSyscallName=System Call
+ControlFlowView_attributeCpuName=CPU
+
+ResourcesView_stateTypeName=Resource
+ResourcesView_nextResourceActionNameText=Next Resource
+ResourcesView_nextResourceActionToolTipText=Select Next Resource
+ResourcesView_previousResourceActionNameText=Previous Resource
+ResourcesView_previousResourceActionToolTipText=Select Previous Resource
+ResourcesView_attributeCpuName=CPU
+ResourcesView_attributeIrqName=IRQ
+ResourcesView_attributeSoftIrqName=SOFT IRQ
index 7a413ad5fb7994929b77f1fd7642159eb686f71c..f0d1671b54be80713a111b8204a8548d0eee881c 100644 (file)
@@ -1,89 +1,89 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Francois Chouinard - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-/**\r
- * Events table specific for LTTng 2.0 kernel traces\r
- */\r
-public class LTTng2EventsTable extends TmfEventsTable {\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Table data\r
-    // ------------------------------------------------------------------------\r
-\r
-    // Table column names\r
-    static private final String TIMESTAMP_COLUMN = Messages.EventsTable_timestampColumn;\r
-    static private final String CHANNEL_COLUMN = Messages.EventsTable_channelColumn;\r
-    static private final String TYPE_COLUMN = Messages.EventsTable_typeColumn;\r
-    static private final String CONTENT_COLUMN = Messages.EventsTable_contentColumn;\r
-    static private final String[] COLUMN_NAMES = new String[] {\r
-            TIMESTAMP_COLUMN,\r
-            CHANNEL_COLUMN,\r
-            TYPE_COLUMN,\r
-            CONTENT_COLUMN\r
-    };\r
-\r
-    static private final ColumnData[] COLUMN_DATA = new ColumnData[] {\r
-            new ColumnData(COLUMN_NAMES[0], 150, SWT.LEFT),\r
-            new ColumnData(COLUMN_NAMES[1], 120, SWT.LEFT),\r
-            new ColumnData(COLUMN_NAMES[2], 200, SWT.LEFT),\r
-            new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT)\r
-    };\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructor\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param parent\r
-     *            The parent composite\r
-     * @param cacheSize\r
-     *            The size of the rows cache\r
-     */\r
-    public LTTng2EventsTable(Composite parent, int cacheSize) {\r
-        super(parent, cacheSize, COLUMN_DATA);\r
-        fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP);\r
-        fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE);\r
-        fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE);\r
-        fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT);\r
-    }\r
-\r
-    /**\r
-     * @param event\r
-     * @return\r
-     */\r
-    @Override\r
-    protected ITmfEventField[] extractItemFields(ITmfEvent event) {\r
-        ITmfEventField[] fields = new TmfEventField[0];\r
-        if (event != null) {\r
-            fields = new TmfEventField[] {\r
-                     new TmfEventField(ITmfEvent.EVENT_FIELD_TIMESTAMP, event.getTimestamp().toString()),\r
-                     new TmfEventField(ITmfEvent.EVENT_FIELD_REFERENCE, event.getReference()),\r
-                     new TmfEventField(ITmfEvent.EVENT_FIELD_TYPE, event.getType().getName()),\r
-                     new TmfEventField(ITmfEvent.EVENT_FIELD_CONTENT, event.getContent().toString())\r
-                    };\r
-        }\r
-        return fields;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
+import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Events table specific for LTTng 2.0 kernel traces
+ */
+public class LTTng2EventsTable extends TmfEventsTable {
+
+    // ------------------------------------------------------------------------
+    // Table data
+    // ------------------------------------------------------------------------
+
+    // Table column names
+    static private final String TIMESTAMP_COLUMN = Messages.EventsTable_timestampColumn;
+    static private final String CHANNEL_COLUMN = Messages.EventsTable_channelColumn;
+    static private final String TYPE_COLUMN = Messages.EventsTable_typeColumn;
+    static private final String CONTENT_COLUMN = Messages.EventsTable_contentColumn;
+    static private final String[] COLUMN_NAMES = new String[] {
+            TIMESTAMP_COLUMN,
+            CHANNEL_COLUMN,
+            TYPE_COLUMN,
+            CONTENT_COLUMN
+    };
+
+    static private final ColumnData[] COLUMN_DATA = new ColumnData[] {
+            new ColumnData(COLUMN_NAMES[0], 150, SWT.LEFT),
+            new ColumnData(COLUMN_NAMES[1], 120, SWT.LEFT),
+            new ColumnData(COLUMN_NAMES[2], 200, SWT.LEFT),
+            new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT)
+    };
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     * Constructor
+     *
+     * @param parent
+     *            The parent composite
+     * @param cacheSize
+     *            The size of the rows cache
+     */
+    public LTTng2EventsTable(Composite parent, int cacheSize) {
+        super(parent, cacheSize, COLUMN_DATA);
+        fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP);
+        fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE);
+        fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE);
+        fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT);
+    }
+
+    /**
+     * @param event
+     * @return
+     */
+    @Override
+    protected ITmfEventField[] extractItemFields(ITmfEvent event) {
+        ITmfEventField[] fields = new TmfEventField[0];
+        if (event != null) {
+            fields = new TmfEventField[] {
+                     new TmfEventField(ITmfEvent.EVENT_FIELD_TIMESTAMP, event.getTimestamp().toString()),
+                     new TmfEventField(ITmfEvent.EVENT_FIELD_REFERENCE, event.getReference()),
+                     new TmfEventField(ITmfEvent.EVENT_FIELD_TYPE, event.getType().getName()),
+                     new TmfEventField(ITmfEvent.EVENT_FIELD_CONTENT, event.getContent().toString())
+                    };
+        }
+        return fields;
+    }
+
+}
index d1acc54c55cb3483b56770af624bd0833f34cde9..35d9d50ca58ecd5cdf53d9297425be0e6fa78e00 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common;\r
-\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.NoSuchElementException;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
-\r
-/**\r
- * An iterator for time events\r
- */\r
-public class EventIterator implements Iterator<ITimeEvent> {\r
-\r
-    private final long fStartTime;\r
-    private final long fEndTime;\r
-    private List<ITimeEvent> fEventList;\r
-    private List<ITimeEvent> fZoomedEventList;\r
-    private long fZoomedStartTime;\r
-    private long fZoomedEndTime;\r
-    private int fIndex = 0;\r
-    private int fZoomedIndex= 0;\r
-    private ITimeEvent fNext = null;\r
-    private ITimeEvent fZoomedNext = null;\r
-\r
-    /**\r
-     * Basic constructor, with start time and end times equal to the lowest and\r
-     * highest values possible, respectively.\r
-     *\r
-     * @param eventList\r
-     *            The list on which this iterator will iterate\r
-     * @param zoomedEventList\r
-     *            The "zoomed" list\r
-     */\r
-    public EventIterator(List<ITimeEvent> eventList, List<ITimeEvent> zoomedEventList) {\r
-        this(eventList, zoomedEventList, Long.MIN_VALUE, Long.MAX_VALUE);\r
-    }\r
-\r
-    /**\r
-     * Complete constructor, where we specify start and end times.\r
-     *\r
-     * @param eventList\r
-     *            The list on which this iterator will iterate\r
-     * @param zoomedEventList\r
-     *            The "zoomed" list\r
-     * @param startTime\r
-     *            The start time\r
-     * @param endTime\r
-     *            The end time\r
-     */\r
-    public EventIterator(List<ITimeEvent> eventList,\r
-            List<ITimeEvent> zoomedEventList, long startTime, long endTime) {\r
-        fEventList = eventList;\r
-        fZoomedEventList = zoomedEventList;\r
-        if (zoomedEventList != null && zoomedEventList.size() > 0) {\r
-            fZoomedStartTime = zoomedEventList.get(0).getTime();\r
-            ITimeEvent lastEvent = zoomedEventList.get(zoomedEventList.size() - 1);\r
-            fZoomedEndTime = lastEvent.getTime() + lastEvent.getDuration();\r
-        } else {\r
-            fZoomedStartTime = Long.MAX_VALUE;\r
-            fZoomedEndTime = Long.MIN_VALUE;\r
-        }\r
-        fStartTime = startTime;\r
-        fEndTime = endTime;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasNext() {\r
-        if (fNext == null && fEventList != null) {\r
-            while (fIndex < fEventList.size()) {\r
-                ITimeEvent event = fEventList.get(fIndex++);\r
-                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime) {\r
-                    fNext = event;\r
-                    break;\r
-                }\r
-            }\r
-            if (fNext == null) {\r
-                fEventList = null;\r
-            }\r
-        }\r
-\r
-        if (fZoomedNext == null && fZoomedEventList != null) {\r
-            while (fZoomedIndex < fZoomedEventList.size()) {\r
-                ITimeEvent event = fZoomedEventList.get(fZoomedIndex++);\r
-                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime) {\r
-                    fZoomedNext = event;\r
-                    break;\r
-                }\r
-            }\r
-            if (fZoomedNext == null) {\r
-                fZoomedEventList = null;\r
-            }\r
-        }\r
-\r
-        return fNext != null || fZoomedNext != null;\r
-    }\r
-\r
-    @Override\r
-    public ITimeEvent next() {\r
-        if (hasNext()) {\r
-            if (fZoomedNext != null && (fNext == null || fZoomedNext.getTime() <= fNext.getTime())) {\r
-                if (fNext != null && fNext.getTime() == fZoomedNext.getTime()) {\r
-                    long duration = fNext.getTime() + fNext.getDuration() - fZoomedEndTime;\r
-                    if (duration > 0) {\r
-                        fNext = new TimeEvent(fNext.getEntry(), fZoomedEndTime, duration);\r
-                    } else {\r
-                        fNext = null;\r
-                    }\r
-                }\r
-                ITimeEvent event = fZoomedNext;\r
-                fZoomedNext = null;\r
-                return event;\r
-            }\r
-            if (fNext.getTime() < fZoomedEndTime && fNext.getTime() + fNext.getDuration() > fZoomedStartTime) {\r
-                ITimeEvent event = new TimeEvent(fNext.getEntry(), fNext.getTime(), fZoomedStartTime - fNext.getTime());\r
-                long duration = fNext.getTime() + fNext.getDuration() - fZoomedEndTime;\r
-                if (duration > 0) {\r
-                    fNext = new TimeEvent(fNext.getEntry(), fZoomedEndTime, duration);\r
-                } else {\r
-                    fNext = null;\r
-                }\r
-                return event;\r
-            }\r
-            ITimeEvent event = fNext;\r
-            fNext = null;\r
-            return event;\r
-        }\r
-        throw new NoSuchElementException();\r
-    }\r
-\r
-    @Override\r
-    public void remove() {\r
-        throw new UnsupportedOperationException();\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
+
+/**
+ * An iterator for time events
+ */
+public class EventIterator implements Iterator<ITimeEvent> {
+
+    private final long fStartTime;
+    private final long fEndTime;
+    private List<ITimeEvent> fEventList;
+    private List<ITimeEvent> fZoomedEventList;
+    private long fZoomedStartTime;
+    private long fZoomedEndTime;
+    private int fIndex = 0;
+    private int fZoomedIndex= 0;
+    private ITimeEvent fNext = null;
+    private ITimeEvent fZoomedNext = null;
+
+    /**
+     * Basic constructor, with start time and end times equal to the lowest and
+     * highest values possible, respectively.
+     *
+     * @param eventList
+     *            The list on which this iterator will iterate
+     * @param zoomedEventList
+     *            The "zoomed" list
+     */
+    public EventIterator(List<ITimeEvent> eventList, List<ITimeEvent> zoomedEventList) {
+        this(eventList, zoomedEventList, Long.MIN_VALUE, Long.MAX_VALUE);
+    }
+
+    /**
+     * Complete constructor, where we specify start and end times.
+     *
+     * @param eventList
+     *            The list on which this iterator will iterate
+     * @param zoomedEventList
+     *            The "zoomed" list
+     * @param startTime
+     *            The start time
+     * @param endTime
+     *            The end time
+     */
+    public EventIterator(List<ITimeEvent> eventList,
+            List<ITimeEvent> zoomedEventList, long startTime, long endTime) {
+        fEventList = eventList;
+        fZoomedEventList = zoomedEventList;
+        if (zoomedEventList != null && zoomedEventList.size() > 0) {
+            fZoomedStartTime = zoomedEventList.get(0).getTime();
+            ITimeEvent lastEvent = zoomedEventList.get(zoomedEventList.size() - 1);
+            fZoomedEndTime = lastEvent.getTime() + lastEvent.getDuration();
+        } else {
+            fZoomedStartTime = Long.MAX_VALUE;
+            fZoomedEndTime = Long.MIN_VALUE;
+        }
+        fStartTime = startTime;
+        fEndTime = endTime;
+    }
+
+    @Override
+    public boolean hasNext() {
+        if (fNext == null && fEventList != null) {
+            while (fIndex < fEventList.size()) {
+                ITimeEvent event = fEventList.get(fIndex++);
+                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime) {
+                    fNext = event;
+                    break;
+                }
+            }
+            if (fNext == null) {
+                fEventList = null;
+            }
+        }
+
+        if (fZoomedNext == null && fZoomedEventList != null) {
+            while (fZoomedIndex < fZoomedEventList.size()) {
+                ITimeEvent event = fZoomedEventList.get(fZoomedIndex++);
+                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime) {
+                    fZoomedNext = event;
+                    break;
+                }
+            }
+            if (fZoomedNext == null) {
+                fZoomedEventList = null;
+            }
+        }
+
+        return fNext != null || fZoomedNext != null;
+    }
+
+    @Override
+    public ITimeEvent next() {
+        if (hasNext()) {
+            if (fZoomedNext != null && (fNext == null || fZoomedNext.getTime() <= fNext.getTime())) {
+                if (fNext != null && fNext.getTime() == fZoomedNext.getTime()) {
+                    long duration = fNext.getTime() + fNext.getDuration() - fZoomedEndTime;
+                    if (duration > 0) {
+                        fNext = new TimeEvent(fNext.getEntry(), fZoomedEndTime, duration);
+                    } else {
+                        fNext = null;
+                    }
+                }
+                ITimeEvent event = fZoomedNext;
+                fZoomedNext = null;
+                return event;
+            }
+            if (fNext.getTime() < fZoomedEndTime && fNext.getTime() + fNext.getDuration() > fZoomedStartTime) {
+                ITimeEvent event = new TimeEvent(fNext.getEntry(), fNext.getTime(), fZoomedStartTime - fNext.getTime());
+                long duration = fNext.getTime() + fNext.getDuration() - fZoomedEndTime;
+                if (duration > 0) {
+                    fNext = new TimeEvent(fNext.getEntry(), fZoomedEndTime, duration);
+                } else {
+                    fNext = null;
+                }
+                return event;
+            }
+            ITimeEvent event = fNext;
+            fNext = null;
+            return event;
+        }
+        throw new NoSuchElementException();
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+}
index 0bf076993dff89074d52e99b588f0d8b1d526c1a..97b6ef03e753d8bf3be419e1a86aeabc100e7f08 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;\r
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * An entry in the Control Flow view\r
- */\r
-public class ControlFlowEntry implements ITimeGraphEntry {\r
-    private final int fThreadQuark;\r
-    private final CtfKernelTrace fTrace;\r
-    private ControlFlowEntry fParent = null;\r
-    private final ArrayList<ControlFlowEntry> fChildren = new ArrayList<ControlFlowEntry>();\r
-    private final String fName;\r
-    private final int fThreadId;\r
-    private final int fParentThreadId;\r
-    private long fBirthTime = -1;\r
-    private long fStartTime = -1;\r
-    private long fEndTime = -1;\r
-    private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();\r
-    private List<ITimeEvent> fZoomedEventList = null;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param threadQuark\r
-     *            The attribute quark matching the thread\r
-     * @param trace\r
-     *            The trace on which we are working\r
-     * @param execName\r
-     *            The exec_name of this entry\r
-     * @param threadId\r
-     *            The TID of the thread\r
-     * @param parentThreadId\r
-     *            the Parent_TID of this thread\r
-     * @param birthTime\r
-     *            The birth time of this entry (this allows separating different\r
-     *            process that could have the same TID)\r
-     * @param startTime\r
-     *            The start time of this process's lifetime\r
-     * @param endTime\r
-     *            The end time of this process\r
-     */\r
-    public ControlFlowEntry(int threadQuark, CtfKernelTrace trace, String execName, int threadId, int parentThreadId, long birthTime, long startTime, long endTime) {\r
-        fThreadQuark = threadQuark;\r
-        fTrace = trace;\r
-        fName = execName;\r
-        fThreadId = threadId;\r
-        fParentThreadId = parentThreadId;\r
-        fBirthTime = birthTime;\r
-        fStartTime = startTime;\r
-        fEndTime = endTime;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry getParent() {\r
-        return fParent;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasChildren() {\r
-        return fChildren != null && fChildren.size() > 0;\r
-    }\r
-\r
-    @Override\r
-    public ControlFlowEntry[] getChildren() {\r
-        return fChildren.toArray(new ControlFlowEntry[0]);\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return fName;\r
-    }\r
-\r
-    @Override\r
-    public long getStartTime() {\r
-        return fStartTime;\r
-    }\r
-\r
-    @Override\r
-    public long getEndTime() {\r
-        return fEndTime;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasTimeEvents() {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator() {\r
-        return new EventIterator(fEventList, fZoomedEventList);\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {\r
-        return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);\r
-    }\r
-\r
-    /**\r
-     * Get the quark of the attribute matching this thread's TID\r
-     *\r
-     * @return The quark\r
-     */\r
-    public int getThreadQuark() {\r
-        return fThreadQuark;\r
-    }\r
-\r
-    /**\r
-     * Get the CTF trace object\r
-     *\r
-     * @return The trace\r
-     */\r
-    public CtfKernelTrace getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    /**\r
-     * Get this entry's thread ID\r
-     *\r
-     * @return The TID\r
-     */\r
-    public int getThreadId() {\r
-        return fThreadId;\r
-    }\r
-\r
-    /**\r
-     * Get this thread's parent TID\r
-     *\r
-     * @return The "PTID"\r
-     */\r
-    public int getParentThreadId() {\r
-        return fParentThreadId;\r
-    }\r
-\r
-    /**\r
-     * Get the birth time of this entry/process\r
-     *\r
-     * @return The birth time\r
-     */\r
-    public long getBirthTime() {\r
-        return fBirthTime;\r
-    }\r
-\r
-    /**\r
-     * Add an event to this process's timeline\r
-     *\r
-     * @param event\r
-     *            The time event\r
-     */\r
-    public void addEvent(ITimeEvent event) {\r
-        long start = event.getTime();\r
-        long end = start + event.getDuration();\r
-        synchronized (fEventList) {\r
-            fEventList.add(event);\r
-            if (fStartTime == -1 || start < fStartTime) {\r
-                fStartTime = start;\r
-            }\r
-            if (fEndTime == -1 || end > fEndTime) {\r
-                fEndTime = end;\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Set the general event list of this entry\r
-     *\r
-     * @param eventList\r
-     *            The list of time events\r
-     */\r
-    public void setEventList(List<ITimeEvent> eventList) {\r
-        fEventList = eventList;\r
-    }\r
-\r
-    /**\r
-     * Set the zoomed event list of this entry\r
-     *\r
-     * @param eventList\r
-     *            The list of time events\r
-     */\r
-    public void setZoomedEventList(List<ITimeEvent> eventList) {\r
-        fZoomedEventList = eventList;\r
-    }\r
-\r
-    /**\r
-     * Add a child entry to this one (to show relationships between processes as\r
-     * a tree)\r
-     *\r
-     * @param child\r
-     *            The child entry\r
-     */\r
-    public void addChild(ControlFlowEntry child) {\r
-        child.fParent = this;\r
-        fChildren.add(child);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * An entry in the Control Flow view
+ */
+public class ControlFlowEntry implements ITimeGraphEntry {
+    private final int fThreadQuark;
+    private final CtfKernelTrace fTrace;
+    private ControlFlowEntry fParent = null;
+    private final ArrayList<ControlFlowEntry> fChildren = new ArrayList<ControlFlowEntry>();
+    private final String fName;
+    private final int fThreadId;
+    private final int fParentThreadId;
+    private long fBirthTime = -1;
+    private long fStartTime = -1;
+    private long fEndTime = -1;
+    private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();
+    private List<ITimeEvent> fZoomedEventList = null;
+
+    /**
+     * Constructor
+     *
+     * @param threadQuark
+     *            The attribute quark matching the thread
+     * @param trace
+     *            The trace on which we are working
+     * @param execName
+     *            The exec_name of this entry
+     * @param threadId
+     *            The TID of the thread
+     * @param parentThreadId
+     *            the Parent_TID of this thread
+     * @param birthTime
+     *            The birth time of this entry (this allows separating different
+     *            process that could have the same TID)
+     * @param startTime
+     *            The start time of this process's lifetime
+     * @param endTime
+     *            The end time of this process
+     */
+    public ControlFlowEntry(int threadQuark, CtfKernelTrace trace, String execName, int threadId, int parentThreadId, long birthTime, long startTime, long endTime) {
+        fThreadQuark = threadQuark;
+        fTrace = trace;
+        fName = execName;
+        fThreadId = threadId;
+        fParentThreadId = parentThreadId;
+        fBirthTime = birthTime;
+        fStartTime = startTime;
+        fEndTime = endTime;
+    }
+
+    @Override
+    public ITimeGraphEntry getParent() {
+        return fParent;
+    }
+
+    @Override
+    public boolean hasChildren() {
+        return fChildren != null && fChildren.size() > 0;
+    }
+
+    @Override
+    public ControlFlowEntry[] getChildren() {
+        return fChildren.toArray(new ControlFlowEntry[0]);
+    }
+
+    @Override
+    public String getName() {
+        return fName;
+    }
+
+    @Override
+    public long getStartTime() {
+        return fStartTime;
+    }
+
+    @Override
+    public long getEndTime() {
+        return fEndTime;
+    }
+
+    @Override
+    public boolean hasTimeEvents() {
+        return true;
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator() {
+        return new EventIterator(fEventList, fZoomedEventList);
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
+        return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);
+    }
+
+    /**
+     * Get the quark of the attribute matching this thread's TID
+     *
+     * @return The quark
+     */
+    public int getThreadQuark() {
+        return fThreadQuark;
+    }
+
+    /**
+     * Get the CTF trace object
+     *
+     * @return The trace
+     */
+    public CtfKernelTrace getTrace() {
+        return fTrace;
+    }
+
+    /**
+     * Get this entry's thread ID
+     *
+     * @return The TID
+     */
+    public int getThreadId() {
+        return fThreadId;
+    }
+
+    /**
+     * Get this thread's parent TID
+     *
+     * @return The "PTID"
+     */
+    public int getParentThreadId() {
+        return fParentThreadId;
+    }
+
+    /**
+     * Get the birth time of this entry/process
+     *
+     * @return The birth time
+     */
+    public long getBirthTime() {
+        return fBirthTime;
+    }
+
+    /**
+     * Add an event to this process's timeline
+     *
+     * @param event
+     *            The time event
+     */
+    public void addEvent(ITimeEvent event) {
+        long start = event.getTime();
+        long end = start + event.getDuration();
+        synchronized (fEventList) {
+            fEventList.add(event);
+            if (fStartTime == -1 || start < fStartTime) {
+                fStartTime = start;
+            }
+            if (fEndTime == -1 || end > fEndTime) {
+                fEndTime = end;
+            }
+        }
+    }
+
+    /**
+     * Set the general event list of this entry
+     *
+     * @param eventList
+     *            The list of time events
+     */
+    public void setEventList(List<ITimeEvent> eventList) {
+        fEventList = eventList;
+    }
+
+    /**
+     * Set the zoomed event list of this entry
+     *
+     * @param eventList
+     *            The list of time events
+     */
+    public void setZoomedEventList(List<ITimeEvent> eventList) {
+        fZoomedEventList = eventList;
+    }
+
+    /**
+     * Add a child entry to this one (to show relationships between processes as
+     * a tree)
+     *
+     * @param child
+     *            The child entry
+     */
+    public void addChild(ControlFlowEntry child) {
+        child.fParent = this;
+        fChildren.add(child);
+    }
+}
index 52d6f6784d6cae4ef20c90450506bd70e882806c..5651b1ca5adee2852c17ee520beb1fbbfc0f4625 100644 (file)
@@ -1,51 +1,51 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
-\r
-/**\r
- * Time Event specific to the control flow view\r
- */\r
-public class ControlFlowEvent extends TimeEvent {\r
-\r
-    private final int fStatus;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param entry\r
-     *            The entry to which this time event is assigned\r
-     * @param time\r
-     *            The timestamp of this event\r
-     * @param duration\r
-     *            The duration of this event\r
-     * @param status\r
-     *            The status assigned to the event\r
-     */\r
-    public ControlFlowEvent(ITimeGraphEntry entry, long time, long duration,\r
-            int status) {\r
-        super(entry, time, duration);\r
-        fStatus = status;\r
-    }\r
-\r
-    /**\r
-     * Get this event's status\r
-     *\r
-     * @return The integer matching this status\r
-     */\r
-    public int getStatus() {\r
-        return fStatus;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
+
+/**
+ * Time Event specific to the control flow view
+ */
+public class ControlFlowEvent extends TimeEvent {
+
+    private final int fStatus;
+
+    /**
+     * Constructor
+     *
+     * @param entry
+     *            The entry to which this time event is assigned
+     * @param time
+     *            The timestamp of this event
+     * @param duration
+     *            The duration of this event
+     * @param status
+     *            The status assigned to the event
+     */
+    public ControlFlowEvent(ITimeGraphEntry entry, long time, long duration,
+            int status) {
+        super(entry, time, duration);
+        fStatus = status;
+    }
+
+    /**
+     * Get this event's status
+     *
+     * @return The integer matching this status
+     */
+    public int getStatus() {
+        return fStatus;
+    }
+}
index 7e2e9e5551c7d891c8048a4f6abd14d3c6317069..89d02b56231d0162a2f944820631f0bc3dce704a 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;\r
-\r
-import java.util.LinkedHashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
-import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;\r
-import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.swt.graphics.RGB;\r
-\r
-/**\r
- * Presentation provider for the control flow view\r
- */\r
-public class ControlFlowPresentationProvider extends TimeGraphPresentationProvider {\r
-\r
-    private enum State {\r
-        UNKNOWN     (new RGB(100, 100, 100)),\r
-        WAIT        (new RGB(200, 200, 0)),\r
-        USERMODE    (new RGB(0, 200, 0)),\r
-        SYSCALL     (new RGB(0, 0, 200)),\r
-        INTERRUPTED (new RGB(200, 100, 100));\r
-\r
-        public final RGB rgb;\r
-\r
-        private State (RGB rgb) {\r
-            this.rgb = rgb;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public String getStateTypeName() {\r
-        return Messages.ControlFlowView_stateTypeName;\r
-    }\r
-\r
-    @Override\r
-    public StateItem[] getStateTable() {\r
-        StateItem[] stateTable = new StateItem[State.values().length];\r
-        for (int i = 0; i < stateTable.length; i++) {\r
-            State state = State.values()[i];\r
-            stateTable[i] = new StateItem(state.rgb, state.toString());\r
-        }\r
-        return stateTable;\r
-    }\r
-\r
-    @Override\r
-    public int getStateTableIndex(ITimeEvent event) {\r
-        if (event instanceof ControlFlowEvent) {\r
-            int status = ((ControlFlowEvent) event).getStatus();\r
-            if (status == StateValues.PROCESS_STATUS_WAIT) {\r
-                return State.WAIT.ordinal();\r
-            } else if (status == StateValues.PROCESS_STATUS_RUN_USERMODE) {\r
-                return State.USERMODE.ordinal();\r
-            } else if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {\r
-                return State.SYSCALL.ordinal();\r
-            } else if (status == StateValues.PROCESS_STATUS_INTERRUPTED) {\r
-                return State.INTERRUPTED.ordinal();\r
-            }\r
-        }\r
-        return State.UNKNOWN.ordinal();\r
-    }\r
-\r
-    @Override\r
-    public String getEventName(ITimeEvent event) {\r
-        if (event instanceof ControlFlowEvent) {\r
-            int status = ((ControlFlowEvent) event).getStatus();\r
-            if (status == StateValues.PROCESS_STATUS_WAIT) {\r
-                return State.WAIT.toString();\r
-            } else if (status == StateValues.PROCESS_STATUS_RUN_USERMODE) {\r
-                return State.USERMODE.toString();\r
-            } else if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {\r
-                return State.SYSCALL.toString();\r
-            } else if (status == StateValues.PROCESS_STATUS_INTERRUPTED) {\r
-                return State.INTERRUPTED.toString();\r
-            }\r
-        }\r
-        return State.UNKNOWN.toString();\r
-    }\r
-\r
-    @Override\r
-    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
-        Map<String, String> retMap = new LinkedHashMap<String, String>();\r
-        if (event instanceof ControlFlowEvent) {\r
-            ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();\r
-            IStateSystemQuerier ssq = entry.getTrace().getStateSystem();\r
-            int tid = entry.getThreadId();\r
-\r
-            try {\r
-                //Find every CPU first, then get the current thread\r
-                int cpusQuark = ssq.getQuarkAbsolute(Attributes.CPUS);\r
-                List<Integer> cpuQuarks = ssq.getSubAttributes(cpusQuark, false);\r
-                for (Integer cpuQuark : cpuQuarks) {\r
-                    int currentThreadQuark = ssq.getQuarkRelative(cpuQuark, Attributes.CURRENT_THREAD);\r
-                    ITmfStateInterval interval = ssq.querySingleState(event.getTime(), currentThreadQuark);\r
-                    if (!interval.getStateValue().isNull()) {\r
-                        ITmfStateValue state = interval.getStateValue();\r
-                        int currentThreadId = state.unboxInt();\r
-                        if (tid == currentThreadId) {\r
-                            retMap.put(Messages.ControlFlowView_attributeCpuName, ssq.getAttributeName(cpuQuark));\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-\r
-            } catch (AttributeNotFoundException e) {\r
-                e.printStackTrace();\r
-            } catch (TimeRangeException e) {\r
-                e.printStackTrace();\r
-            } catch (StateValueTypeException e) {\r
-                e.printStackTrace();\r
-            }\r
-            int status = ((ControlFlowEvent) event).getStatus();\r
-            if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {\r
-                try {\r
-                    int syscallQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.SYSTEM_CALL);\r
-                    ITmfStateInterval value = ssq.querySingleState(event.getTime(), syscallQuark);\r
-                    if (!value.getStateValue().isNull()) {\r
-                        ITmfStateValue state = value.getStateValue();\r
-                        retMap.put(Messages.ControlFlowView_attributeSyscallName, state.toString());\r
-                    }\r
-\r
-                } catch (AttributeNotFoundException e) {\r
-                    e.printStackTrace();\r
-                } catch (TimeRangeException e) {\r
-                    e.printStackTrace();\r
-                }\r
-            }\r
-        }\r
-\r
-        return retMap;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
+import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
+import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
+import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Presentation provider for the control flow view
+ */
+public class ControlFlowPresentationProvider extends TimeGraphPresentationProvider {
+
+    private enum State {
+        UNKNOWN     (new RGB(100, 100, 100)),
+        WAIT        (new RGB(200, 200, 0)),
+        USERMODE    (new RGB(0, 200, 0)),
+        SYSCALL     (new RGB(0, 0, 200)),
+        INTERRUPTED (new RGB(200, 100, 100));
+
+        public final RGB rgb;
+
+        private State (RGB rgb) {
+            this.rgb = rgb;
+        }
+    }
+
+    @Override
+    public String getStateTypeName() {
+        return Messages.ControlFlowView_stateTypeName;
+    }
+
+    @Override
+    public StateItem[] getStateTable() {
+        StateItem[] stateTable = new StateItem[State.values().length];
+        for (int i = 0; i < stateTable.length; i++) {
+            State state = State.values()[i];
+            stateTable[i] = new StateItem(state.rgb, state.toString());
+        }
+        return stateTable;
+    }
+
+    @Override
+    public int getStateTableIndex(ITimeEvent event) {
+        if (event instanceof ControlFlowEvent) {
+            int status = ((ControlFlowEvent) event).getStatus();
+            if (status == StateValues.PROCESS_STATUS_WAIT) {
+                return State.WAIT.ordinal();
+            } else if (status == StateValues.PROCESS_STATUS_RUN_USERMODE) {
+                return State.USERMODE.ordinal();
+            } else if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {
+                return State.SYSCALL.ordinal();
+            } else if (status == StateValues.PROCESS_STATUS_INTERRUPTED) {
+                return State.INTERRUPTED.ordinal();
+            }
+        }
+        return State.UNKNOWN.ordinal();
+    }
+
+    @Override
+    public String getEventName(ITimeEvent event) {
+        if (event instanceof ControlFlowEvent) {
+            int status = ((ControlFlowEvent) event).getStatus();
+            if (status == StateValues.PROCESS_STATUS_WAIT) {
+                return State.WAIT.toString();
+            } else if (status == StateValues.PROCESS_STATUS_RUN_USERMODE) {
+                return State.USERMODE.toString();
+            } else if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {
+                return State.SYSCALL.toString();
+            } else if (status == StateValues.PROCESS_STATUS_INTERRUPTED) {
+                return State.INTERRUPTED.toString();
+            }
+        }
+        return State.UNKNOWN.toString();
+    }
+
+    @Override
+    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {
+        Map<String, String> retMap = new LinkedHashMap<String, String>();
+        if (event instanceof ControlFlowEvent) {
+            ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
+            IStateSystemQuerier ssq = entry.getTrace().getStateSystem();
+            int tid = entry.getThreadId();
+
+            try {
+                //Find every CPU first, then get the current thread
+                int cpusQuark = ssq.getQuarkAbsolute(Attributes.CPUS);
+                List<Integer> cpuQuarks = ssq.getSubAttributes(cpusQuark, false);
+                for (Integer cpuQuark : cpuQuarks) {
+                    int currentThreadQuark = ssq.getQuarkRelative(cpuQuark, Attributes.CURRENT_THREAD);
+                    ITmfStateInterval interval = ssq.querySingleState(event.getTime(), currentThreadQuark);
+                    if (!interval.getStateValue().isNull()) {
+                        ITmfStateValue state = interval.getStateValue();
+                        int currentThreadId = state.unboxInt();
+                        if (tid == currentThreadId) {
+                            retMap.put(Messages.ControlFlowView_attributeCpuName, ssq.getAttributeName(cpuQuark));
+                            break;
+                        }
+                    }
+                }
+
+            } catch (AttributeNotFoundException e) {
+                e.printStackTrace();
+            } catch (TimeRangeException e) {
+                e.printStackTrace();
+            } catch (StateValueTypeException e) {
+                e.printStackTrace();
+            }
+            int status = ((ControlFlowEvent) event).getStatus();
+            if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {
+                try {
+                    int syscallQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.SYSTEM_CALL);
+                    ITmfStateInterval value = ssq.querySingleState(event.getTime(), syscallQuark);
+                    if (!value.getStateValue().isNull()) {
+                        ITmfStateValue state = value.getStateValue();
+                        retMap.put(Messages.ControlFlowView_attributeSyscallName, state.toString());
+                    }
+
+                } catch (AttributeNotFoundException e) {
+                    e.printStackTrace();
+                } catch (TimeRangeException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        return retMap;
+    }
+
+}
index 03d2c4f94dfd5f9ac7b8c7f1dbcb542e5fc2cc05..93a2f625284e52a4ee06d331b71c2b3ddb127dc1 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-import java.util.List;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.IToolBarManager;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.viewers.ILabelProviderListener;\r
-import org.eclipse.jface.viewers.ITableLabelProvider;\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;\r
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;\r
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
-import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;\r
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;\r
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier2;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;\r
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphCombo;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphSelectionEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.TreeColumn;\r
-import org.eclipse.ui.IActionBars;\r
-\r
-/**\r
- * The Control Flow view main object\r
- *\r
- */\r
-public class ControlFlowView extends TmfView {\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constants\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * View ID.\r
-     */\r
-    public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.ui.views.controlflow"; //$NON-NLS-1$\r
-\r
-    /**\r
-     * Initial time range\r
-     */\r
-    private static final long INITIAL_WINDOW_OFFSET = (1L * 100  * 1000 * 1000); // .1sec\r
-\r
-    private static final String PROCESS_COLUMN    = Messages.ControlFlowView_processColumn;\r
-    private static final String TID_COLUMN        = Messages.ControlFlowView_tidColumn;\r
-    private static final String PTID_COLUMN       = Messages.ControlFlowView_ptidColumn;\r
-    private static final String BIRTH_TIME_COLUMN = Messages.ControlFlowView_birthTimeColumn;\r
-    private static final String TRACE_COLUMN      = Messages.ControlFlowView_traceColumn;\r
-\r
-    private final String[] COLUMN_NAMES = new String[] {\r
-            PROCESS_COLUMN,\r
-            TID_COLUMN,\r
-            PTID_COLUMN,\r
-            BIRTH_TIME_COLUMN,\r
-            TRACE_COLUMN\r
-    };\r
-\r
-    /**\r
-     * Redraw state enum\r
-     */\r
-    private enum State { IDLE, BUSY, PENDING }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Fields\r
-    // ------------------------------------------------------------------------\r
-\r
-    // The timegraph combo\r
-    private TimeGraphCombo fTimeGraphCombo;\r
-\r
-    // The selected experiment\r
-    private TmfExperiment<ITmfEvent> fSelectedExperiment;\r
-\r
-    // The timegraph entry list\r
-    private ArrayList<ControlFlowEntry> fEntryList;\r
-\r
-    // The time graph entry list synchronization object\r
-    final private Object fEntryListSyncObj = new Object();\r
-\r
-    // The start time\r
-    private long fStartTime;\r
-\r
-    // The end time\r
-    private long fEndTime;\r
-\r
-    // The display width\r
-    private final int fDisplayWidth;\r
-\r
-    // The zoom thread\r
-    private ZoomThread fZoomThread;\r
-\r
-    // The next resource action\r
-    private Action fNextResourceAction;\r
-\r
-    // The previous resource action\r
-    private Action fPreviousResourceAction;\r
-\r
-    // A comparator class\r
-    private final ControlFlowEntryComparator fControlFlowEntryComparator = new ControlFlowEntryComparator();\r
-\r
-    // The redraw state used to prevent unnecessary queuing of display runnables\r
-    private State fRedrawState = State.IDLE;\r
-\r
-    // The redraw synchronization object\r
-    final private Object fSyncObj = new Object();\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Classes\r
-    // ------------------------------------------------------------------------\r
-\r
-    private class TreeContentProvider implements ITreeContentProvider {\r
-\r
-        @Override\r
-        public void dispose() {\r
-        }\r
-\r
-        @Override\r
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-        }\r
-\r
-        @Override\r
-        public Object[] getElements(Object inputElement) {\r
-            return (ITimeGraphEntry[]) inputElement;\r
-        }\r
-\r
-        @Override\r
-        public Object[] getChildren(Object parentElement) {\r
-            ITimeGraphEntry entry = (ITimeGraphEntry) parentElement;\r
-            return entry.getChildren();\r
-        }\r
-\r
-        @Override\r
-        public Object getParent(Object element) {\r
-            ITimeGraphEntry entry = (ITimeGraphEntry) element;\r
-            return entry.getParent();\r
-        }\r
-\r
-        @Override\r
-        public boolean hasChildren(Object element) {\r
-            ITimeGraphEntry entry = (ITimeGraphEntry) element;\r
-            return entry.hasChildren();\r
-        }\r
-\r
-    }\r
-\r
-    private class TreeLabelProvider implements ITableLabelProvider {\r
-\r
-        @Override\r
-        public void addListener(ILabelProviderListener listener) {\r
-        }\r
-\r
-        @Override\r
-        public void dispose() {\r
-        }\r
-\r
-        @Override\r
-        public boolean isLabelProperty(Object element, String property) {\r
-            return false;\r
-        }\r
-\r
-        @Override\r
-        public void removeListener(ILabelProviderListener listener) {\r
-        }\r
-\r
-        @Override\r
-        public Image getColumnImage(Object element, int columnIndex) {\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public String getColumnText(Object element, int columnIndex) {\r
-            ControlFlowEntry entry = (ControlFlowEntry) element;\r
-            if (columnIndex == 0) {\r
-                return entry.getName();\r
-            } else if (columnIndex == 1) {\r
-                return Integer.toString(entry.getThreadId());\r
-            } else if (columnIndex == 2) {\r
-                if (entry.getParentThreadId() > 0) {\r
-                    return Integer.toString(entry.getParentThreadId());\r
-                }\r
-            } else if (columnIndex == 3) {\r
-                return Utils.formatTime(entry.getBirthTime(), TimeFormat.ABSOLUTE, Resolution.NANOSEC);\r
-            } else if (columnIndex == 4) {\r
-                return entry.getTrace().getName();\r
-            }\r
-            return ""; //$NON-NLS-1$\r
-        }\r
-\r
-    }\r
-\r
-    private static class ControlFlowEntryComparator implements Comparator<ITimeGraphEntry> {\r
-\r
-        @Override\r
-        public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {\r
-            int result = 0;\r
-\r
-            if ((o1 instanceof ControlFlowEntry) && (o2 instanceof ControlFlowEntry)) {\r
-                ControlFlowEntry entry1 = (ControlFlowEntry) o1;\r
-                ControlFlowEntry entry2 = (ControlFlowEntry) o2;\r
-                result = entry1.getTrace().getStartTime().compareTo(entry2.getTrace().getStartTime());\r
-                if (result == 0) {\r
-                    result = entry1.getTrace().getName().compareTo(entry2.getTrace().getName());\r
-                }\r
-                if (result == 0) {\r
-                    result = entry1.getThreadId() < entry2.getThreadId() ? -1 : entry1.getThreadId() > entry2.getThreadId() ? 1 : 0;\r
-                }\r
-            }\r
-\r
-            if (result == 0) {\r
-                result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;\r
-            }\r
-\r
-            return result;\r
-        }\r
-    }\r
-\r
-\r
-    private class ZoomThread extends Thread {\r
-        private final long fZoomStartTime;\r
-        private final long fZoomEndTime;\r
-        private final long fResolution;\r
-        private final IProgressMonitor fMonitor;\r
-\r
-        public ZoomThread(long startTime, long endTime) {\r
-            super("ControlFlowView zoom"); //$NON-NLS-1$\r
-            fZoomStartTime = startTime;\r
-            fZoomEndTime = endTime;\r
-            fResolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);\r
-            fMonitor = new NullProgressMonitor();\r
-        }\r
-\r
-        @Override\r
-        public void run() {\r
-            ArrayList<ControlFlowEntry> entryList = null;\r
-            synchronized (fEntryListSyncObj) {\r
-                entryList = fEntryList;\r
-            }\r
-            if (entryList == null) {\r
-                return;\r
-            }\r
-            for (ControlFlowEntry entry : entryList) {\r
-                if (fMonitor.isCanceled()) {\r
-                    break;\r
-                }\r
-                zoom(entry, fMonitor);\r
-            }\r
-        }\r
-\r
-        private void zoom(ControlFlowEntry entry, IProgressMonitor monitor) {\r
-            if (fZoomStartTime <= fStartTime && fZoomEndTime >= fEndTime) {\r
-                entry.setZoomedEventList(null);\r
-            } else {\r
-                List<ITimeEvent> zoomedEventList = getEventList(entry, fZoomStartTime, fZoomEndTime, fResolution, monitor);\r
-                if (zoomedEventList != null) {\r
-                    entry.setZoomedEventList(zoomedEventList);\r
-                }\r
-            }\r
-            redraw();\r
-            for (ControlFlowEntry child : entry.getChildren()) {\r
-                if (fMonitor.isCanceled()) {\r
-                    return;\r
-                }\r
-                zoom(child, monitor);\r
-            }\r
-        }\r
-\r
-        public void cancel() {\r
-            fMonitor.setCanceled(true);\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructors\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Constructor\r
-     */\r
-    public ControlFlowView() {\r
-        super(ID);\r
-        fDisplayWidth = Display.getDefault().getBounds().width;\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // ViewPart\r
-    // ------------------------------------------------------------------------\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)\r
-     */\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        fTimeGraphCombo = new TimeGraphCombo(parent, SWT.NONE);\r
-\r
-        fTimeGraphCombo.setTreeContentProvider(new TreeContentProvider());\r
-\r
-        fTimeGraphCombo.setTreeLabelProvider(new TreeLabelProvider());\r
-\r
-        fTimeGraphCombo.setTimeGraphProvider(new ControlFlowPresentationProvider());\r
-\r
-        fTimeGraphCombo.setTreeColumns(COLUMN_NAMES);\r
-\r
-        fTimeGraphCombo.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {\r
-            @Override\r
-            public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {\r
-                final long startTime = event.getStartTime();\r
-                final long endTime = event.getEndTime();\r
-                TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));\r
-                TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphCombo.getTimeGraphViewer().getSelectedTime());\r
-                broadcast(new TmfRangeSynchSignal(ControlFlowView.this, range, time));\r
-                if (fZoomThread != null) {\r
-                    fZoomThread.cancel();\r
-                }\r
-                startZoomThread(startTime, endTime);\r
-            }\r
-        });\r
-\r
-        fTimeGraphCombo.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {\r
-            @Override\r
-            public void timeSelected(TimeGraphTimeEvent event) {\r
-                long time = event.getTime();\r
-                broadcast(new TmfTimeSynchSignal(ControlFlowView.this, new CtfTmfTimestamp(time)));\r
-            }\r
-        });\r
-\r
-        fTimeGraphCombo.addSelectionListener(new ITimeGraphSelectionListener() {\r
-            @Override\r
-            public void selectionChanged(TimeGraphSelectionEvent event) {\r
-                //ITimeGraphEntry selection = event.getSelection();\r
-            }\r
-        });\r
-\r
-        fTimeGraphCombo.getTimeGraphViewer().setTimeCalendarFormat(true);\r
-\r
-        final Thread thread = new Thread("ControlFlowView build") { //$NON-NLS-1$\r
-            @Override\r
-            public void run() {\r
-                if (TmfExperiment.getCurrentExperiment() != null) {\r
-                    selectExperiment(TmfExperiment.getCurrentExperiment());\r
-                }\r
-            }\r
-        };\r
-        thread.start();\r
-\r
-        // View Action Handling\r
-        makeActions();\r
-        contributeToActionBars();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\r
-     */\r
-    @Override\r
-    public void setFocus() {\r
-        fTimeGraphCombo.setFocus();\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Signal handlers\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Handler for the experiment selected signal\r
-     *\r
-     * @param signal\r
-     *            The signal that's received\r
-     */\r
-    @TmfSignalHandler\r
-    public void experimentSelected(final TmfExperimentSelectedSignal<? extends ITmfEvent> signal) {\r
-        if (signal.getExperiment().equals(fSelectedExperiment)) {\r
-            return;\r
-        }\r
-\r
-        final Thread thread = new Thread("ControlFlowView build") { //$NON-NLS-1$\r
-            @Override\r
-            public void run() {\r
-                selectExperiment(signal.getExperiment());\r
-            }\r
-        };\r
-        thread.start();\r
-    }\r
-\r
-    /**\r
-     * Handler for the synch signal\r
-     *\r
-     * @param signal\r
-     *            The signal that's received\r
-     */\r
-    @TmfSignalHandler\r
-    public void synchToTime(final TmfTimeSynchSignal signal) {\r
-        if (signal.getSource() == this || fSelectedExperiment == null || fSelectedExperiment.getTraces() == null) {\r
-            return;\r
-        }\r
-        final long time = signal.getCurrentTime().normalize(0, -9).getValue();\r
-\r
-        int thread = -1;\r
-        for (ITmfTrace<?> trace : fSelectedExperiment.getTraces()) {\r
-            if (thread > 0) {\r
-                break;\r
-            }\r
-            if (trace instanceof CtfKernelTrace) {\r
-                CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;\r
-                IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
-                if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {\r
-                    List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD);  //$NON-NLS-1$\r
-                    for (int currentThreadQuark : currentThreadQuarks) {\r
-                        try {\r
-                            ITmfStateInterval currentThreadInterval = ssq.querySingleState(time, currentThreadQuark);\r
-                            int currentThread = currentThreadInterval.getStateValue().unboxInt();\r
-                            if (currentThread > 0) {\r
-                                int statusQuark = ssq.getQuarkAbsolute(Attributes.THREADS, Integer.toString(currentThread), Attributes.STATUS);\r
-                                ITmfStateInterval statusInterval = ssq.querySingleState(time, statusQuark);\r
-                                if (statusInterval.getStartTime() == time) {\r
-                                    thread = currentThread;\r
-                                    break;\r
-                                }\r
-                            }\r
-                        } catch (AttributeNotFoundException e) {\r
-                            e.printStackTrace();\r
-                        } catch (TimeRangeException e) {\r
-                            e.printStackTrace();\r
-                        } catch (StateValueTypeException e) {\r
-                            e.printStackTrace();\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        final int selectedThread = thread;\r
-\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphCombo.isDisposed()) {\r
-                    return;\r
-                }\r
-                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true);\r
-                startZoomThread(fTimeGraphCombo.getTimeGraphViewer().getTime0(), fTimeGraphCombo.getTimeGraphViewer().getTime1());\r
-\r
-                if (selectedThread > 0) {\r
-                    for (Object element : fTimeGraphCombo.getTimeGraphViewer().getExpandedElements()) {\r
-                        if (element instanceof ControlFlowEntry) {\r
-                            ControlFlowEntry entry = (ControlFlowEntry) element;\r
-                            if (entry.getThreadId() == selectedThread) {\r
-                                fTimeGraphCombo.setSelection(entry);\r
-                                break;\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        });\r
-    }\r
-\r
-    /**\r
-     * Handler for the range sync signal\r
-     *\r
-     * @param signal\r
-     *            The signal that's received\r
-     */\r
-    @TmfSignalHandler\r
-    public void synchToRange(final TmfRangeSynchSignal signal) {\r
-        if (signal.getSource() == this || fSelectedExperiment == null) {\r
-            return;\r
-        }\r
-        final long startTime = signal.getCurrentRange().getStartTime().normalize(0, -9).getValue();\r
-        final long endTime = signal.getCurrentRange().getEndTime().normalize(0, -9).getValue();\r
-        final long time = signal.getCurrentTime().normalize(0, -9).getValue();\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphCombo.isDisposed()) {\r
-                    return;\r
-                }\r
-                fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);\r
-                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, false);\r
-                startZoomThread(startTime, endTime);\r
-            }\r
-        });\r
-    }\r
-\r
-    /**\r
-     * Handler for the state system build completed signal\r
-     *\r
-     * @param signal\r
-     *            The signal that's received\r
-     */\r
-    @TmfSignalHandler\r
-    public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal) {\r
-        final TmfExperiment<?> selectedExperiment = fSelectedExperiment;\r
-        if (selectedExperiment == null || selectedExperiment.getTraces() == null) {\r
-            return;\r
-        }\r
-        for (ITmfTrace<?> trace : selectedExperiment.getTraces()) {\r
-            if (trace == signal.getTrace() && trace instanceof CtfKernelTrace) {\r
-                final Thread thread = new Thread("ControlFlowView build") { //$NON-NLS-1$\r
-                    @Override\r
-                    public void run() {\r
-                        // rebuild the model\r
-                        selectExperiment(selectedExperiment);\r
-                    }\r
-                };\r
-                thread.start();\r
-            }\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Internal\r
-    // ------------------------------------------------------------------------\r
-\r
-    @SuppressWarnings("unchecked")\r
-    private void selectExperiment(TmfExperiment<?> experiment) {\r
-        fStartTime = Long.MAX_VALUE;\r
-        fEndTime = Long.MIN_VALUE;\r
-        fSelectedExperiment = (TmfExperiment<ITmfEvent>) experiment;\r
-        ArrayList<ControlFlowEntry> rootList = new ArrayList<ControlFlowEntry>();\r
-        for (ITmfTrace<?> trace : experiment.getTraces()) {\r
-            if (trace instanceof CtfKernelTrace) {\r
-                ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();\r
-                CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;\r
-                IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
-                long start = ssq.getStartTime();\r
-                long end = ssq.getCurrentEndTime() + 1;\r
-                fStartTime = Math.min(fStartTime, start);\r
-                fEndTime = Math.max(fEndTime, end);\r
-                List<Integer> threadQuarks = ssq.getQuarks(Attributes.THREADS, "*"); //$NON-NLS-1$\r
-                for (int threadQuark : threadQuarks) {\r
-                    String threadName = ssq.getAttributeName(threadQuark);\r
-                    int threadId = -1;\r
-                    try {\r
-                        threadId = Integer.parseInt(threadName);\r
-                    } catch (NumberFormatException e1) {\r
-                        continue;\r
-                    }\r
-                    if (threadId == 0) { // ignore the swapper thread\r
-                        continue;\r
-                    }\r
-                    int execNameQuark = -1;\r
-                    try {\r
-                        try {\r
-                            execNameQuark = ssq.getQuarkRelative(threadQuark, Attributes.EXEC_NAME);\r
-                        } catch (AttributeNotFoundException e) {\r
-                            continue;\r
-                        }\r
-                        int ppidQuark = ssq.getQuarkRelative(threadQuark, Attributes.PPID);\r
-                        List<ITmfStateInterval> execNameIntervals = ssq.queryHistoryRange(execNameQuark, start, end - 1);\r
-                        long birthTime = -1;\r
-                        for (ITmfStateInterval execNameInterval : execNameIntervals) {\r
-                            if (!execNameInterval.getStateValue().isNull() && execNameInterval.getStateValue().getType() == 1) {\r
-                                String execName = execNameInterval.getStateValue().unboxStr();\r
-                                long startTime = execNameInterval.getStartTime();\r
-                                long endTime = execNameInterval.getEndTime() + 1;\r
-                                if (birthTime == -1) {\r
-                                    birthTime = startTime;\r
-                                }\r
-                                int ppid = -1;\r
-                                if (ppidQuark != -1) {\r
-                                    ITmfStateInterval ppidInterval = ssq.querySingleState(startTime, ppidQuark);\r
-                                    ppid = ppidInterval.getStateValue().unboxInt();\r
-                                }\r
-                                ControlFlowEntry entry = new ControlFlowEntry(threadQuark, ctfKernelTrace, execName, threadId, ppid, birthTime, startTime, endTime);\r
-                                entryList.add(entry);\r
-                                entry.addEvent(new TimeEvent(entry, startTime, endTime - startTime));\r
-                            } else {\r
-                                birthTime = -1;\r
-                            }\r
-                        }\r
-                    } catch (AttributeNotFoundException e) {\r
-                        e.printStackTrace();\r
-                    } catch (TimeRangeException e) {\r
-                        e.printStackTrace();\r
-                    } catch (StateValueTypeException e) {\r
-                        e.printStackTrace();\r
-                    }\r
-                }\r
-                buildTree(entryList, rootList);\r
-            }\r
-            Collections.sort(rootList, fControlFlowEntryComparator);\r
-            synchronized (fEntryListSyncObj) {\r
-                fEntryList = (ArrayList<ControlFlowEntry>) rootList.clone();\r
-            }\r
-            refresh(INITIAL_WINDOW_OFFSET);\r
-        }\r
-        for (ControlFlowEntry entry : rootList) {\r
-            buildStatusEvents(entry);\r
-        }\r
-    }\r
-\r
-    private static void buildTree(ArrayList<ControlFlowEntry> entryList,\r
-            ArrayList<ControlFlowEntry> rootList) {\r
-        for (ControlFlowEntry entry : entryList) {\r
-            boolean root = true;\r
-            if (entry.getParentThreadId() > 0) {\r
-                for (ControlFlowEntry parent : entryList) {\r
-                    if (parent.getThreadId() == entry.getParentThreadId() &&\r
-                            entry.getStartTime() >= parent.getStartTime() &&\r
-                            entry.getStartTime() <= parent.getEndTime()) {\r
-                        parent.addChild(entry);\r
-                        root = false;\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-            if (root) {\r
-                rootList.add(entry);\r
-            }\r
-        }\r
-    }\r
-\r
-    private void buildStatusEvents(ControlFlowEntry entry) {\r
-        IStateSystemQuerier ssq = entry.getTrace().getStateSystem();\r
-        long start = ssq.getStartTime();\r
-        long end = ssq.getCurrentEndTime() + 1;\r
-        long resolution = Math.max(1, (end - start) / fDisplayWidth);\r
-        List<ITimeEvent> eventList = getEventList(entry, entry.getStartTime(), entry.getEndTime(), resolution, new NullProgressMonitor());\r
-        entry.setEventList(eventList);\r
-        redraw();\r
-        for (ITimeGraphEntry child : entry.getChildren()) {\r
-            buildStatusEvents((ControlFlowEntry) child);\r
-        }\r
-    }\r
-\r
-    private static List<ITimeEvent> getEventList(ControlFlowEntry entry,\r
-            long startTime, long endTime, long resolution,\r
-            IProgressMonitor monitor) {\r
-        startTime = Math.max(startTime, entry.getStartTime());\r
-        endTime = Math.min(endTime, entry.getEndTime());\r
-        if (endTime <= startTime) {\r
-            return null;\r
-        }\r
-        IStateSystemQuerier2 ssq = (IStateSystemQuerier2) entry.getTrace().getStateSystem();\r
-        List<ITimeEvent> eventList = null;\r
-        try {\r
-            int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);\r
-            List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);\r
-            eventList = new ArrayList<ITimeEvent>(statusIntervals.size());\r
-            long lastEndTime = -1;\r
-            for (ITmfStateInterval statusInterval : statusIntervals) {\r
-                if (monitor.isCanceled()) {\r
-                    return null;\r
-                }\r
-                long time = statusInterval.getStartTime();\r
-                long duration = statusInterval.getEndTime() - time + 1;\r
-                int status = -1;\r
-                try {\r
-                    status = statusInterval.getStateValue().unboxInt();\r
-                } catch (StateValueTypeException e) {\r
-                    e.printStackTrace();\r
-                }\r
-                if (lastEndTime != time && lastEndTime != -1) {\r
-                    eventList.add(new ControlFlowEvent(entry, lastEndTime, time - lastEndTime, 0));\r
-                }\r
-                eventList.add(new ControlFlowEvent(entry, time, duration, status));\r
-                lastEndTime = time + duration;\r
-            }\r
-        } catch (AttributeNotFoundException e) {\r
-            e.printStackTrace();\r
-        } catch (TimeRangeException e) {\r
-            e.printStackTrace();\r
-        }\r
-        return eventList;\r
-    }\r
-\r
-    private void refresh(final long windowRange) {\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphCombo.isDisposed()) {\r
-                    return;\r
-                }\r
-                ITimeGraphEntry[] entries = null;\r
-                synchronized (fEntryListSyncObj) {\r
-                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
-                }\r
-                Arrays.sort(entries, fControlFlowEntryComparator);\r
-                fTimeGraphCombo.setInput(entries);\r
-                fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);\r
-\r
-                long endTime = fStartTime + windowRange;\r
-\r
-                if (fEndTime < endTime) {\r
-                    endTime = fEndTime;\r
-                }\r
-                fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(fStartTime, endTime);\r
-                for (TreeColumn column : fTimeGraphCombo.getTreeViewer().getTree().getColumns()) {\r
-                    column.pack();\r
-                }\r
-\r
-                startZoomThread(fStartTime, endTime);\r
-            }\r
-        });\r
-    }\r
-\r
-    private void redraw() {\r
-        synchronized (fSyncObj) {\r
-            if (fRedrawState == State.IDLE) {\r
-                fRedrawState = State.BUSY;\r
-            } else {\r
-                fRedrawState = State.PENDING;\r
-                return;\r
-            }\r
-        }\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphCombo.isDisposed()) {\r
-                    return;\r
-                }\r
-                fTimeGraphCombo.redraw();\r
-                fTimeGraphCombo.update();\r
-                synchronized (fSyncObj) {\r
-                    if (fRedrawState == State.PENDING) {\r
-                        fRedrawState = State.IDLE;\r
-                        redraw();\r
-                    } else {\r
-                        fRedrawState = State.IDLE;\r
-                    }\r
-                }\r
-            }\r
-        });\r
-    }\r
-\r
-    private void startZoomThread(long startTime, long endTime) {\r
-        if (fZoomThread != null) {\r
-            fZoomThread.cancel();\r
-        }\r
-        fZoomThread = new ZoomThread(startTime, endTime);\r
-        fZoomThread.start();\r
-    }\r
-\r
-    private void makeActions() {\r
-        fPreviousResourceAction = fTimeGraphCombo.getTimeGraphViewer().getPreviousItemAction();\r
-        fPreviousResourceAction.setText(Messages.ControlFlowView_previousProcessActionNameText);\r
-        fPreviousResourceAction.setToolTipText(Messages.ControlFlowView_previousProcessActionToolTipText);\r
-        fNextResourceAction = fTimeGraphCombo.getTimeGraphViewer().getNextItemAction();\r
-        fNextResourceAction.setText(Messages.ControlFlowView_nextProcessActionNameText);\r
-        fNextResourceAction.setToolTipText(Messages.ControlFlowView_nextProcessActionToolTipText);\r
-    }\r
-\r
-    private void contributeToActionBars() {\r
-        IActionBars bars = getViewSite().getActionBars();\r
-        fillLocalToolBar(bars.getToolBarManager());\r
-    }\r
-\r
-    private void fillLocalToolBar(IToolBarManager manager) {\r
-        manager.add(fTimeGraphCombo.getTimeGraphViewer().getShowLegendAction());\r
-        manager.add(new Separator());\r
-        manager.add(fTimeGraphCombo.getTimeGraphViewer().getResetScaleAction());\r
-        manager.add(fTimeGraphCombo.getTimeGraphViewer().getPreviousEventAction());\r
-        manager.add(fTimeGraphCombo.getTimeGraphViewer().getNextEventAction());\r
-        manager.add(fPreviousResourceAction);\r
-        manager.add(fNextResourceAction);\r
-        manager.add(fTimeGraphCombo.getTimeGraphViewer().getZoomInAction());\r
-        manager.add(fTimeGraphCombo.getTimeGraphViewer().getZoomOutAction());\r
-        manager.add(new Separator());\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
+import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier2;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
+import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphCombo;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphSelectionEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.IActionBars;
+
+/**
+ * The Control Flow view main object
+ *
+ */
+public class ControlFlowView extends TmfView {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    /**
+     * View ID.
+     */
+    public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.ui.views.controlflow"; //$NON-NLS-1$
+
+    /**
+     * Initial time range
+     */
+    private static final long INITIAL_WINDOW_OFFSET = (1L * 100  * 1000 * 1000); // .1sec
+
+    private static final String PROCESS_COLUMN    = Messages.ControlFlowView_processColumn;
+    private static final String TID_COLUMN        = Messages.ControlFlowView_tidColumn;
+    private static final String PTID_COLUMN       = Messages.ControlFlowView_ptidColumn;
+    private static final String BIRTH_TIME_COLUMN = Messages.ControlFlowView_birthTimeColumn;
+    private static final String TRACE_COLUMN      = Messages.ControlFlowView_traceColumn;
+
+    private final String[] COLUMN_NAMES = new String[] {
+            PROCESS_COLUMN,
+            TID_COLUMN,
+            PTID_COLUMN,
+            BIRTH_TIME_COLUMN,
+            TRACE_COLUMN
+    };
+
+    /**
+     * Redraw state enum
+     */
+    private enum State { IDLE, BUSY, PENDING }
+
+    // ------------------------------------------------------------------------
+    // Fields
+    // ------------------------------------------------------------------------
+
+    // The timegraph combo
+    private TimeGraphCombo fTimeGraphCombo;
+
+    // The selected experiment
+    private TmfExperiment<ITmfEvent> fSelectedExperiment;
+
+    // The timegraph entry list
+    private ArrayList<ControlFlowEntry> fEntryList;
+
+    // The time graph entry list synchronization object
+    final private Object fEntryListSyncObj = new Object();
+
+    // The start time
+    private long fStartTime;
+
+    // The end time
+    private long fEndTime;
+
+    // The display width
+    private final int fDisplayWidth;
+
+    // The zoom thread
+    private ZoomThread fZoomThread;
+
+    // The next resource action
+    private Action fNextResourceAction;
+
+    // The previous resource action
+    private Action fPreviousResourceAction;
+
+    // A comparator class
+    private final ControlFlowEntryComparator fControlFlowEntryComparator = new ControlFlowEntryComparator();
+
+    // The redraw state used to prevent unnecessary queuing of display runnables
+    private State fRedrawState = State.IDLE;
+
+    // The redraw synchronization object
+    final private Object fSyncObj = new Object();
+
+    // ------------------------------------------------------------------------
+    // Classes
+    // ------------------------------------------------------------------------
+
+    private class TreeContentProvider implements ITreeContentProvider {
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        }
+
+        @Override
+        public Object[] getElements(Object inputElement) {
+            return (ITimeGraphEntry[]) inputElement;
+        }
+
+        @Override
+        public Object[] getChildren(Object parentElement) {
+            ITimeGraphEntry entry = (ITimeGraphEntry) parentElement;
+            return entry.getChildren();
+        }
+
+        @Override
+        public Object getParent(Object element) {
+            ITimeGraphEntry entry = (ITimeGraphEntry) element;
+            return entry.getParent();
+        }
+
+        @Override
+        public boolean hasChildren(Object element) {
+            ITimeGraphEntry entry = (ITimeGraphEntry) element;
+            return entry.hasChildren();
+        }
+
+    }
+
+    private class TreeLabelProvider implements ITableLabelProvider {
+
+        @Override
+        public void addListener(ILabelProviderListener listener) {
+        }
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public boolean isLabelProperty(Object element, String property) {
+            return false;
+        }
+
+        @Override
+        public void removeListener(ILabelProviderListener listener) {
+        }
+
+        @Override
+        public Image getColumnImage(Object element, int columnIndex) {
+            return null;
+        }
+
+        @Override
+        public String getColumnText(Object element, int columnIndex) {
+            ControlFlowEntry entry = (ControlFlowEntry) element;
+            if (columnIndex == 0) {
+                return entry.getName();
+            } else if (columnIndex == 1) {
+                return Integer.toString(entry.getThreadId());
+            } else if (columnIndex == 2) {
+                if (entry.getParentThreadId() > 0) {
+                    return Integer.toString(entry.getParentThreadId());
+                }
+            } else if (columnIndex == 3) {
+                return Utils.formatTime(entry.getBirthTime(), TimeFormat.ABSOLUTE, Resolution.NANOSEC);
+            } else if (columnIndex == 4) {
+                return entry.getTrace().getName();
+            }
+            return ""; //$NON-NLS-1$
+        }
+
+    }
+
+    private static class ControlFlowEntryComparator implements Comparator<ITimeGraphEntry> {
+
+        @Override
+        public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
+            int result = 0;
+
+            if ((o1 instanceof ControlFlowEntry) && (o2 instanceof ControlFlowEntry)) {
+                ControlFlowEntry entry1 = (ControlFlowEntry) o1;
+                ControlFlowEntry entry2 = (ControlFlowEntry) o2;
+                result = entry1.getTrace().getStartTime().compareTo(entry2.getTrace().getStartTime());
+                if (result == 0) {
+                    result = entry1.getTrace().getName().compareTo(entry2.getTrace().getName());
+                }
+                if (result == 0) {
+                    result = entry1.getThreadId() < entry2.getThreadId() ? -1 : entry1.getThreadId() > entry2.getThreadId() ? 1 : 0;
+                }
+            }
+
+            if (result == 0) {
+                result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;
+            }
+
+            return result;
+        }
+    }
+
+
+    private class ZoomThread extends Thread {
+        private final long fZoomStartTime;
+        private final long fZoomEndTime;
+        private final long fResolution;
+        private final IProgressMonitor fMonitor;
+
+        public ZoomThread(long startTime, long endTime) {
+            super("ControlFlowView zoom"); //$NON-NLS-1$
+            fZoomStartTime = startTime;
+            fZoomEndTime = endTime;
+            fResolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
+            fMonitor = new NullProgressMonitor();
+        }
+
+        @Override
+        public void run() {
+            ArrayList<ControlFlowEntry> entryList = null;
+            synchronized (fEntryListSyncObj) {
+                entryList = fEntryList;
+            }
+            if (entryList == null) {
+                return;
+            }
+            for (ControlFlowEntry entry : entryList) {
+                if (fMonitor.isCanceled()) {
+                    break;
+                }
+                zoom(entry, fMonitor);
+            }
+        }
+
+        private void zoom(ControlFlowEntry entry, IProgressMonitor monitor) {
+            if (fZoomStartTime <= fStartTime && fZoomEndTime >= fEndTime) {
+                entry.setZoomedEventList(null);
+            } else {
+                List<ITimeEvent> zoomedEventList = getEventList(entry, fZoomStartTime, fZoomEndTime, fResolution, monitor);
+                if (zoomedEventList != null) {
+                    entry.setZoomedEventList(zoomedEventList);
+                }
+            }
+            redraw();
+            for (ControlFlowEntry child : entry.getChildren()) {
+                if (fMonitor.isCanceled()) {
+                    return;
+                }
+                zoom(child, monitor);
+            }
+        }
+
+        public void cancel() {
+            fMonitor.setCanceled(true);
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Constructor
+     */
+    public ControlFlowView() {
+        super(ID);
+        fDisplayWidth = Display.getDefault().getBounds().width;
+    }
+
+    // ------------------------------------------------------------------------
+    // ViewPart
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+    public void createPartControl(Composite parent) {
+        fTimeGraphCombo = new TimeGraphCombo(parent, SWT.NONE);
+
+        fTimeGraphCombo.setTreeContentProvider(new TreeContentProvider());
+
+        fTimeGraphCombo.setTreeLabelProvider(new TreeLabelProvider());
+
+        fTimeGraphCombo.setTimeGraphProvider(new ControlFlowPresentationProvider());
+
+        fTimeGraphCombo.setTreeColumns(COLUMN_NAMES);
+
+        fTimeGraphCombo.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
+            @Override
+            public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
+                final long startTime = event.getStartTime();
+                final long endTime = event.getEndTime();
+                TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
+                TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphCombo.getTimeGraphViewer().getSelectedTime());
+                broadcast(new TmfRangeSynchSignal(ControlFlowView.this, range, time));
+                if (fZoomThread != null) {
+                    fZoomThread.cancel();
+                }
+                startZoomThread(startTime, endTime);
+            }
+        });
+
+        fTimeGraphCombo.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
+            @Override
+            public void timeSelected(TimeGraphTimeEvent event) {
+                long time = event.getTime();
+                broadcast(new TmfTimeSynchSignal(ControlFlowView.this, new CtfTmfTimestamp(time)));
+            }
+        });
+
+        fTimeGraphCombo.addSelectionListener(new ITimeGraphSelectionListener() {
+            @Override
+            public void selectionChanged(TimeGraphSelectionEvent event) {
+                //ITimeGraphEntry selection = event.getSelection();
+            }
+        });
+
+        fTimeGraphCombo.getTimeGraphViewer().setTimeCalendarFormat(true);
+
+        final Thread thread = new Thread("ControlFlowView build") { //$NON-NLS-1$
+            @Override
+            public void run() {
+                if (TmfExperiment.getCurrentExperiment() != null) {
+                    selectExperiment(TmfExperiment.getCurrentExperiment());
+                }
+            }
+        };
+        thread.start();
+
+        // View Action Handling
+        makeActions();
+        contributeToActionBars();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+     */
+    @Override
+    public void setFocus() {
+        fTimeGraphCombo.setFocus();
+    }
+
+    // ------------------------------------------------------------------------
+    // Signal handlers
+    // ------------------------------------------------------------------------
+
+    /**
+     * Handler for the experiment selected signal
+     *
+     * @param signal
+     *            The signal that's received
+     */
+    @TmfSignalHandler
+    public void experimentSelected(final TmfExperimentSelectedSignal<? extends ITmfEvent> signal) {
+        if (signal.getExperiment().equals(fSelectedExperiment)) {
+            return;
+        }
+
+        final Thread thread = new Thread("ControlFlowView build") { //$NON-NLS-1$
+            @Override
+            public void run() {
+                selectExperiment(signal.getExperiment());
+            }
+        };
+        thread.start();
+    }
+
+    /**
+     * Handler for the synch signal
+     *
+     * @param signal
+     *            The signal that's received
+     */
+    @TmfSignalHandler
+    public void synchToTime(final TmfTimeSynchSignal signal) {
+        if (signal.getSource() == this || fSelectedExperiment == null || fSelectedExperiment.getTraces() == null) {
+            return;
+        }
+        final long time = signal.getCurrentTime().normalize(0, -9).getValue();
+
+        int thread = -1;
+        for (ITmfTrace<?> trace : fSelectedExperiment.getTraces()) {
+            if (thread > 0) {
+                break;
+            }
+            if (trace instanceof CtfKernelTrace) {
+                CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
+                IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();
+                if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {
+                    List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD);  //$NON-NLS-1$
+                    for (int currentThreadQuark : currentThreadQuarks) {
+                        try {
+                            ITmfStateInterval currentThreadInterval = ssq.querySingleState(time, currentThreadQuark);
+                            int currentThread = currentThreadInterval.getStateValue().unboxInt();
+                            if (currentThread > 0) {
+                                int statusQuark = ssq.getQuarkAbsolute(Attributes.THREADS, Integer.toString(currentThread), Attributes.STATUS);
+                                ITmfStateInterval statusInterval = ssq.querySingleState(time, statusQuark);
+                                if (statusInterval.getStartTime() == time) {
+                                    thread = currentThread;
+                                    break;
+                                }
+                            }
+                        } catch (AttributeNotFoundException e) {
+                            e.printStackTrace();
+                        } catch (TimeRangeException e) {
+                            e.printStackTrace();
+                        } catch (StateValueTypeException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+        final int selectedThread = thread;
+
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphCombo.isDisposed()) {
+                    return;
+                }
+                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true);
+                startZoomThread(fTimeGraphCombo.getTimeGraphViewer().getTime0(), fTimeGraphCombo.getTimeGraphViewer().getTime1());
+
+                if (selectedThread > 0) {
+                    for (Object element : fTimeGraphCombo.getTimeGraphViewer().getExpandedElements()) {
+                        if (element instanceof ControlFlowEntry) {
+                            ControlFlowEntry entry = (ControlFlowEntry) element;
+                            if (entry.getThreadId() == selectedThread) {
+                                fTimeGraphCombo.setSelection(entry);
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * Handler for the range sync signal
+     *
+     * @param signal
+     *            The signal that's received
+     */
+    @TmfSignalHandler
+    public void synchToRange(final TmfRangeSynchSignal signal) {
+        if (signal.getSource() == this || fSelectedExperiment == null) {
+            return;
+        }
+        final long startTime = signal.getCurrentRange().getStartTime().normalize(0, -9).getValue();
+        final long endTime = signal.getCurrentRange().getEndTime().normalize(0, -9).getValue();
+        final long time = signal.getCurrentTime().normalize(0, -9).getValue();
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphCombo.isDisposed()) {
+                    return;
+                }
+                fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
+                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, false);
+                startZoomThread(startTime, endTime);
+            }
+        });
+    }
+
+    /**
+     * Handler for the state system build completed signal
+     *
+     * @param signal
+     *            The signal that's received
+     */
+    @TmfSignalHandler
+    public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal) {
+        final TmfExperiment<?> selectedExperiment = fSelectedExperiment;
+        if (selectedExperiment == null || selectedExperiment.getTraces() == null) {
+            return;
+        }
+        for (ITmfTrace<?> trace : selectedExperiment.getTraces()) {
+            if (trace == signal.getTrace() && trace instanceof CtfKernelTrace) {
+                final Thread thread = new Thread("ControlFlowView build") { //$NON-NLS-1$
+                    @Override
+                    public void run() {
+                        // rebuild the model
+                        selectExperiment(selectedExperiment);
+                    }
+                };
+                thread.start();
+            }
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Internal
+    // ------------------------------------------------------------------------
+
+    @SuppressWarnings("unchecked")
+    private void selectExperiment(TmfExperiment<?> experiment) {
+        fStartTime = Long.MAX_VALUE;
+        fEndTime = Long.MIN_VALUE;
+        fSelectedExperiment = (TmfExperiment<ITmfEvent>) experiment;
+        ArrayList<ControlFlowEntry> rootList = new ArrayList<ControlFlowEntry>();
+        for (ITmfTrace<?> trace : experiment.getTraces()) {
+            if (trace instanceof CtfKernelTrace) {
+                ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();
+                CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
+                IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();
+                long start = ssq.getStartTime();
+                long end = ssq.getCurrentEndTime() + 1;
+                fStartTime = Math.min(fStartTime, start);
+                fEndTime = Math.max(fEndTime, end);
+                List<Integer> threadQuarks = ssq.getQuarks(Attributes.THREADS, "*"); //$NON-NLS-1$
+                for (int threadQuark : threadQuarks) {
+                    String threadName = ssq.getAttributeName(threadQuark);
+                    int threadId = -1;
+                    try {
+                        threadId = Integer.parseInt(threadName);
+                    } catch (NumberFormatException e1) {
+                        continue;
+                    }
+                    if (threadId == 0) { // ignore the swapper thread
+                        continue;
+                    }
+                    int execNameQuark = -1;
+                    try {
+                        try {
+                            execNameQuark = ssq.getQuarkRelative(threadQuark, Attributes.EXEC_NAME);
+                        } catch (AttributeNotFoundException e) {
+                            continue;
+                        }
+                        int ppidQuark = ssq.getQuarkRelative(threadQuark, Attributes.PPID);
+                        List<ITmfStateInterval> execNameIntervals = ssq.queryHistoryRange(execNameQuark, start, end - 1);
+                        long birthTime = -1;
+                        for (ITmfStateInterval execNameInterval : execNameIntervals) {
+                            if (!execNameInterval.getStateValue().isNull() && execNameInterval.getStateValue().getType() == 1) {
+                                String execName = execNameInterval.getStateValue().unboxStr();
+                                long startTime = execNameInterval.getStartTime();
+                                long endTime = execNameInterval.getEndTime() + 1;
+                                if (birthTime == -1) {
+                                    birthTime = startTime;
+                                }
+                                int ppid = -1;
+                                if (ppidQuark != -1) {
+                                    ITmfStateInterval ppidInterval = ssq.querySingleState(startTime, ppidQuark);
+                                    ppid = ppidInterval.getStateValue().unboxInt();
+                                }
+                                ControlFlowEntry entry = new ControlFlowEntry(threadQuark, ctfKernelTrace, execName, threadId, ppid, birthTime, startTime, endTime);
+                                entryList.add(entry);
+                                entry.addEvent(new TimeEvent(entry, startTime, endTime - startTime));
+                            } else {
+                                birthTime = -1;
+                            }
+                        }
+                    } catch (AttributeNotFoundException e) {
+                        e.printStackTrace();
+                    } catch (TimeRangeException e) {
+                        e.printStackTrace();
+                    } catch (StateValueTypeException e) {
+                        e.printStackTrace();
+                    }
+                }
+                buildTree(entryList, rootList);
+            }
+            Collections.sort(rootList, fControlFlowEntryComparator);
+            synchronized (fEntryListSyncObj) {
+                fEntryList = (ArrayList<ControlFlowEntry>) rootList.clone();
+            }
+            refresh(INITIAL_WINDOW_OFFSET);
+        }
+        for (ControlFlowEntry entry : rootList) {
+            buildStatusEvents(entry);
+        }
+    }
+
+    private static void buildTree(ArrayList<ControlFlowEntry> entryList,
+            ArrayList<ControlFlowEntry> rootList) {
+        for (ControlFlowEntry entry : entryList) {
+            boolean root = true;
+            if (entry.getParentThreadId() > 0) {
+                for (ControlFlowEntry parent : entryList) {
+                    if (parent.getThreadId() == entry.getParentThreadId() &&
+                            entry.getStartTime() >= parent.getStartTime() &&
+                            entry.getStartTime() <= parent.getEndTime()) {
+                        parent.addChild(entry);
+                        root = false;
+                        break;
+                    }
+                }
+            }
+            if (root) {
+                rootList.add(entry);
+            }
+        }
+    }
+
+    private void buildStatusEvents(ControlFlowEntry entry) {
+        IStateSystemQuerier ssq = entry.getTrace().getStateSystem();
+        long start = ssq.getStartTime();
+        long end = ssq.getCurrentEndTime() + 1;
+        long resolution = Math.max(1, (end - start) / fDisplayWidth);
+        List<ITimeEvent> eventList = getEventList(entry, entry.getStartTime(), entry.getEndTime(), resolution, new NullProgressMonitor());
+        entry.setEventList(eventList);
+        redraw();
+        for (ITimeGraphEntry child : entry.getChildren()) {
+            buildStatusEvents((ControlFlowEntry) child);
+        }
+    }
+
+    private static List<ITimeEvent> getEventList(ControlFlowEntry entry,
+            long startTime, long endTime, long resolution,
+            IProgressMonitor monitor) {
+        startTime = Math.max(startTime, entry.getStartTime());
+        endTime = Math.min(endTime, entry.getEndTime());
+        if (endTime <= startTime) {
+            return null;
+        }
+        IStateSystemQuerier2 ssq = (IStateSystemQuerier2) entry.getTrace().getStateSystem();
+        List<ITimeEvent> eventList = null;
+        try {
+            int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
+            List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);
+            eventList = new ArrayList<ITimeEvent>(statusIntervals.size());
+            long lastEndTime = -1;
+            for (ITmfStateInterval statusInterval : statusIntervals) {
+                if (monitor.isCanceled()) {
+                    return null;
+                }
+                long time = statusInterval.getStartTime();
+                long duration = statusInterval.getEndTime() - time + 1;
+                int status = -1;
+                try {
+                    status = statusInterval.getStateValue().unboxInt();
+                } catch (StateValueTypeException e) {
+                    e.printStackTrace();
+                }
+                if (lastEndTime != time && lastEndTime != -1) {
+                    eventList.add(new ControlFlowEvent(entry, lastEndTime, time - lastEndTime, 0));
+                }
+                eventList.add(new ControlFlowEvent(entry, time, duration, status));
+                lastEndTime = time + duration;
+            }
+        } catch (AttributeNotFoundException e) {
+            e.printStackTrace();
+        } catch (TimeRangeException e) {
+            e.printStackTrace();
+        }
+        return eventList;
+    }
+
+    private void refresh(final long windowRange) {
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphCombo.isDisposed()) {
+                    return;
+                }
+                ITimeGraphEntry[] entries = null;
+                synchronized (fEntryListSyncObj) {
+                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);
+                }
+                Arrays.sort(entries, fControlFlowEntryComparator);
+                fTimeGraphCombo.setInput(entries);
+                fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);
+
+                long endTime = fStartTime + windowRange;
+
+                if (fEndTime < endTime) {
+                    endTime = fEndTime;
+                }
+                fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(fStartTime, endTime);
+                for (TreeColumn column : fTimeGraphCombo.getTreeViewer().getTree().getColumns()) {
+                    column.pack();
+                }
+
+                startZoomThread(fStartTime, endTime);
+            }
+        });
+    }
+
+    private void redraw() {
+        synchronized (fSyncObj) {
+            if (fRedrawState == State.IDLE) {
+                fRedrawState = State.BUSY;
+            } else {
+                fRedrawState = State.PENDING;
+                return;
+            }
+        }
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphCombo.isDisposed()) {
+                    return;
+                }
+                fTimeGraphCombo.redraw();
+                fTimeGraphCombo.update();
+                synchronized (fSyncObj) {
+                    if (fRedrawState == State.PENDING) {
+                        fRedrawState = State.IDLE;
+                        redraw();
+                    } else {
+                        fRedrawState = State.IDLE;
+                    }
+                }
+            }
+        });
+    }
+
+    private void startZoomThread(long startTime, long endTime) {
+        if (fZoomThread != null) {
+            fZoomThread.cancel();
+        }
+        fZoomThread = new ZoomThread(startTime, endTime);
+        fZoomThread.start();
+    }
+
+    private void makeActions() {
+        fPreviousResourceAction = fTimeGraphCombo.getTimeGraphViewer().getPreviousItemAction();
+        fPreviousResourceAction.setText(Messages.ControlFlowView_previousProcessActionNameText);
+        fPreviousResourceAction.setToolTipText(Messages.ControlFlowView_previousProcessActionToolTipText);
+        fNextResourceAction = fTimeGraphCombo.getTimeGraphViewer().getNextItemAction();
+        fNextResourceAction.setText(Messages.ControlFlowView_nextProcessActionNameText);
+        fNextResourceAction.setToolTipText(Messages.ControlFlowView_nextProcessActionToolTipText);
+    }
+
+    private void contributeToActionBars() {
+        IActionBars bars = getViewSite().getActionBars();
+        fillLocalToolBar(bars.getToolBarManager());
+    }
+
+    private void fillLocalToolBar(IToolBarManager manager) {
+        manager.add(fTimeGraphCombo.getTimeGraphViewer().getShowLegendAction());
+        manager.add(new Separator());
+        manager.add(fTimeGraphCombo.getTimeGraphViewer().getResetScaleAction());
+        manager.add(fTimeGraphCombo.getTimeGraphViewer().getPreviousEventAction());
+        manager.add(fTimeGraphCombo.getTimeGraphViewer().getNextEventAction());
+        manager.add(fPreviousResourceAction);
+        manager.add(fNextResourceAction);
+        manager.add(fTimeGraphCombo.getTimeGraphViewer().getZoomInAction());
+        manager.add(fTimeGraphCombo.getTimeGraphViewer().getZoomOutAction());
+        manager.add(new Separator());
+    }
+}
index d2acc99600aca294daee7d8112d3affdc20a0405..585c2e8953efcb77e3dc7a0ffccab9d5543d0775 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;\r
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * An entry, or row, in the resource view\r
- *\r
- * @author Patrick Tasse\r
- */\r
-public class ResourcesEntry implements ITimeGraphEntry {\r
-\r
-    /** Type of resource */\r
-    public static enum Type {\r
-        /** Null resources (filler rows, etc.) */\r
-        NULL,\r
-        /** Entries for CPUs */\r
-        CPU,\r
-        /** Entries for IRQs */\r
-        IRQ,\r
-        /** Entries for Soft IRQ */\r
-        SOFT_IRQ }\r
-\r
-    private final int fQuark;\r
-    private final CtfKernelTrace fTrace;\r
-    private ITimeGraphEntry fParent = null;\r
-    private final ITimeGraphEntry[] children = null;\r
-    private final String fName;\r
-    private final Type fType;\r
-    private final int fId;\r
-    private long fStartTime;\r
-    private long fEndTime;\r
-    private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();\r
-    private List<ITimeEvent> fZoomedEventList = null;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param quark\r
-     *            The quark of the state system attribute whose state is shown\r
-     *            on this row\r
-     * @param trace\r
-     *            The trace that this view is talking about\r
-     * @param type\r
-     *            Type of entry, see the Type enum\r
-     * @param id\r
-     *            The integer id associated with this entry or row\r
-     */\r
-    public ResourcesEntry(int quark, CtfKernelTrace trace, Type type, int id) {\r
-        fQuark = quark;\r
-        fTrace = trace;\r
-        fType = type;\r
-        fId = id;\r
-        fName = type.toString() + ' ' + Integer.toString(id);\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry getParent() {\r
-        return fParent;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasChildren() {\r
-        return children != null && children.length > 0;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry[] getChildren() {\r
-        return children;\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return fName;\r
-    }\r
-\r
-    @Override\r
-    public long getStartTime() {\r
-        return fStartTime;\r
-    }\r
-\r
-    @Override\r
-    public long getEndTime() {\r
-        return fEndTime;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasTimeEvents() {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator() {\r
-        return new EventIterator(fEventList, fZoomedEventList);\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {\r
-        return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);\r
-    }\r
-\r
-    /**\r
-     * Assign a parent entry to this one, to organize them in a tree in the\r
-     * view.\r
-     *\r
-     * @param parent\r
-     *            The parent entry\r
-     */\r
-    public void setParent(ITimeGraphEntry parent) {\r
-        fParent = parent;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the attribute quark that's represented by this entry.\r
-     *\r
-     * @return The integer quark\r
-     */\r
-    public int getQuark() {\r
-        return fQuark;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the trace that is associated to this Resource view.\r
-     *\r
-     * @return The LTTng 2 kernel trace\r
-     */\r
-    public CtfKernelTrace getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    /**\r
-     * Get the entry Type of this entry. Uses the inner Type enum.\r
-     *\r
-     * @return The entry type\r
-     */\r
-    public Type getType() {\r
-        return fType;\r
-    }\r
-\r
-    /**\r
-     * Get the integer ID associated with this entry.\r
-     *\r
-     * @return The ID\r
-     */\r
-    public int getId() {\r
-        return fId;\r
-    }\r
-\r
-    /**\r
-     * Assign the target event list to this view.\r
-     *\r
-     * @param eventList\r
-     *            The list of time events\r
-     */\r
-    public void setEventList(List<ITimeEvent> eventList) {\r
-        fEventList = eventList;\r
-        if (eventList != null && eventList.size() > 0) {\r
-            fStartTime = eventList.get(0).getTime();\r
-            ITimeEvent lastEvent = eventList.get(eventList.size() - 1);\r
-            fEndTime = lastEvent.getTime() + lastEvent.getDuration();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Assign the zoomed event list to this view.\r
-     *\r
-     * @param eventList\r
-     *            The list of "zoomed" time events\r
-     */\r
-    public void setZoomedEventList(List<ITimeEvent> eventList) {\r
-        fZoomedEventList = eventList;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * An entry, or row, in the resource view
+ *
+ * @author Patrick Tasse
+ */
+public class ResourcesEntry implements ITimeGraphEntry {
+
+    /** Type of resource */
+    public static enum Type {
+        /** Null resources (filler rows, etc.) */
+        NULL,
+        /** Entries for CPUs */
+        CPU,
+        /** Entries for IRQs */
+        IRQ,
+        /** Entries for Soft IRQ */
+        SOFT_IRQ }
+
+    private final int fQuark;
+    private final CtfKernelTrace fTrace;
+    private ITimeGraphEntry fParent = null;
+    private final ITimeGraphEntry[] children = null;
+    private final String fName;
+    private final Type fType;
+    private final int fId;
+    private long fStartTime;
+    private long fEndTime;
+    private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();
+    private List<ITimeEvent> fZoomedEventList = null;
+
+    /**
+     * Standard constructor
+     *
+     * @param quark
+     *            The quark of the state system attribute whose state is shown
+     *            on this row
+     * @param trace
+     *            The trace that this view is talking about
+     * @param type
+     *            Type of entry, see the Type enum
+     * @param id
+     *            The integer id associated with this entry or row
+     */
+    public ResourcesEntry(int quark, CtfKernelTrace trace, Type type, int id) {
+        fQuark = quark;
+        fTrace = trace;
+        fType = type;
+        fId = id;
+        fName = type.toString() + ' ' + Integer.toString(id);
+    }
+
+    @Override
+    public ITimeGraphEntry getParent() {
+        return fParent;
+    }
+
+    @Override
+    public boolean hasChildren() {
+        return children != null && children.length > 0;
+    }
+
+    @Override
+    public ITimeGraphEntry[] getChildren() {
+        return children;
+    }
+
+    @Override
+    public String getName() {
+        return fName;
+    }
+
+    @Override
+    public long getStartTime() {
+        return fStartTime;
+    }
+
+    @Override
+    public long getEndTime() {
+        return fEndTime;
+    }
+
+    @Override
+    public boolean hasTimeEvents() {
+        return true;
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator() {
+        return new EventIterator(fEventList, fZoomedEventList);
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
+        return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);
+    }
+
+    /**
+     * Assign a parent entry to this one, to organize them in a tree in the
+     * view.
+     *
+     * @param parent
+     *            The parent entry
+     */
+    public void setParent(ITimeGraphEntry parent) {
+        fParent = parent;
+    }
+
+    /**
+     * Retrieve the attribute quark that's represented by this entry.
+     *
+     * @return The integer quark
+     */
+    public int getQuark() {
+        return fQuark;
+    }
+
+    /**
+     * Retrieve the trace that is associated to this Resource view.
+     *
+     * @return The LTTng 2 kernel trace
+     */
+    public CtfKernelTrace getTrace() {
+        return fTrace;
+    }
+
+    /**
+     * Get the entry Type of this entry. Uses the inner Type enum.
+     *
+     * @return The entry type
+     */
+    public Type getType() {
+        return fType;
+    }
+
+    /**
+     * Get the integer ID associated with this entry.
+     *
+     * @return The ID
+     */
+    public int getId() {
+        return fId;
+    }
+
+    /**
+     * Assign the target event list to this view.
+     *
+     * @param eventList
+     *            The list of time events
+     */
+    public void setEventList(List<ITimeEvent> eventList) {
+        fEventList = eventList;
+        if (eventList != null && eventList.size() > 0) {
+            fStartTime = eventList.get(0).getTime();
+            ITimeEvent lastEvent = eventList.get(eventList.size() - 1);
+            fEndTime = lastEvent.getTime() + lastEvent.getDuration();
+        }
+    }
+
+    /**
+     * Assign the zoomed event list to this view.
+     *
+     * @param eventList
+     *            The list of "zoomed" time events
+     */
+    public void setZoomedEventList(List<ITimeEvent> eventList) {
+        fZoomedEventList = eventList;
+    }
+}
index a2714f71a3f3f50464ff8f5acac0a7841736cc26..ab7361d1e4d6659e9299860b4039e310c9055c68 100644 (file)
@@ -1,79 +1,79 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;\r
-\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
-\r
-/**\r
- * Time Event implementation specific to the Resource View\r
- *\r
- * @author Patrick Tasse\r
- */\r
-public class ResourcesEvent extends TimeEvent {\r
-\r
-    private final Type fType;\r
-    private int fValue;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param entry\r
-     *            The entry that this event affects\r
-     * @param time\r
-     *            The start time of the event\r
-     * @param duration\r
-     *            The duration of the event\r
-     * @param value\r
-     *            The value type associated to this event\r
-     */\r
-    public ResourcesEvent(ResourcesEntry entry, long time, long duration,\r
-            int value) {\r
-        super(entry, time, duration);\r
-        fType = entry.getType();\r
-        fValue = value;\r
-    }\r
-\r
-    /**\r
-     * Base constructor, with no value assigned\r
-     *\r
-     * @param entry\r
-     *            The entry that this event affects\r
-     * @param time\r
-     *            The start time of the event\r
-     * @param duration\r
-     *            The duration of the event\r
-     */\r
-    public ResourcesEvent(ResourcesEntry entry, long time, long duration) {\r
-        super(entry, time, duration);\r
-        fType = Type.NULL;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the value associated with this event\r
-     *\r
-     * @return The integer value\r
-     */\r
-    public int getValue() {\r
-        return fValue;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the type of this entry. Uses the ResourcesEntry.Type interface.\r
-     *\r
-     * @return The entry type\r
-     */\r
-    public Type getType() {\r
-        return fType;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
+
+/**
+ * Time Event implementation specific to the Resource View
+ *
+ * @author Patrick Tasse
+ */
+public class ResourcesEvent extends TimeEvent {
+
+    private final Type fType;
+    private int fValue;
+
+    /**
+     * Standard constructor
+     *
+     * @param entry
+     *            The entry that this event affects
+     * @param time
+     *            The start time of the event
+     * @param duration
+     *            The duration of the event
+     * @param value
+     *            The value type associated to this event
+     */
+    public ResourcesEvent(ResourcesEntry entry, long time, long duration,
+            int value) {
+        super(entry, time, duration);
+        fType = entry.getType();
+        fValue = value;
+    }
+
+    /**
+     * Base constructor, with no value assigned
+     *
+     * @param entry
+     *            The entry that this event affects
+     * @param time
+     *            The start time of the event
+     * @param duration
+     *            The duration of the event
+     */
+    public ResourcesEvent(ResourcesEntry entry, long time, long duration) {
+        super(entry, time, duration);
+        fType = Type.NULL;
+    }
+
+    /**
+     * Retrieve the value associated with this event
+     *
+     * @return The integer value
+     */
+    public int getValue() {
+        return fValue;
+    }
+
+    /**
+     * Retrieve the type of this entry. Uses the ResourcesEntry.Type interface.
+     *
+     * @return The entry type
+     */
+    public Type getType() {
+        return fType;
+    }
+}
index d53de1f102934622f5ae38b6292427422558e364..e4a149bc5aa5e7cdb7b76750257950d88d8aece9 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
-import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.swt.graphics.RGB;\r
-\r
-/**\r
- * Presentation provider for the Resource view, based on the generic TMF\r
- * presentation provider.\r
- *\r
- * @author Patrick Tasse\r
- */\r
-public class ResourcesPresentationProvider extends TimeGraphPresentationProvider {\r
-\r
-    private enum State {\r
-        UNKNOWN         (new RGB(100, 100, 100)),\r
-        IDLE            (new RGB(200, 200, 200)),\r
-        USERMODE        (new RGB(0, 200, 0)),\r
-        SYSCALL         (new RGB(0, 0, 200)),\r
-        IRQ             (new RGB(200, 100, 100)),\r
-        SOFT_IRQ        (new RGB(200, 150, 100)),\r
-        IRQ_ACTIVE      (new RGB(200, 100, 100)),\r
-        SOFT_IRQ_RAISED (new RGB(200, 200, 0)),\r
-        SOFT_IRQ_ACTIVE (new RGB(200, 150, 100));\r
-\r
-        public final RGB rgb;\r
-\r
-        private State (RGB rgb) {\r
-            this.rgb = rgb;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public String getStateTypeName() {\r
-        return Messages.ResourcesView_stateTypeName;\r
-    }\r
-\r
-    @Override\r
-    public StateItem[] getStateTable() {\r
-        StateItem[] stateTable = new StateItem[State.values().length];\r
-        for (int i = 0; i < stateTable.length; i++) {\r
-            State state = State.values()[i];\r
-            stateTable[i] = new StateItem(state.rgb, state.toString());\r
-        }\r
-        return stateTable;\r
-    }\r
-\r
-    @Override\r
-    public int getStateTableIndex(ITimeEvent event) {\r
-        if (event instanceof ResourcesEvent) {\r
-            ResourcesEvent resourcesEvent = (ResourcesEvent) event;\r
-            if (resourcesEvent.getType() == Type.CPU) {\r
-                int status = resourcesEvent.getValue();\r
-                if (status == StateValues.CPU_STATUS_IDLE) {\r
-                    return State.IDLE.ordinal();\r
-                } else if (status == StateValues.CPU_STATUS_RUN_USERMODE) {\r
-                    return State.USERMODE.ordinal();\r
-                } else if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {\r
-                    return State.SYSCALL.ordinal();\r
-                } else if (status == StateValues.CPU_STATUS_IRQ) {\r
-                    return State.IRQ.ordinal();\r
-                } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {\r
-                    return State.SOFT_IRQ.ordinal();\r
-                }\r
-            } else if (resourcesEvent.getType() == Type.IRQ) {\r
-                return State.IRQ_ACTIVE.ordinal();\r
-            } else if (resourcesEvent.getType() == Type.SOFT_IRQ) {\r
-                int cpu = resourcesEvent.getValue();\r
-                if (cpu == StateValues.SOFT_IRQ_RAISED) {\r
-                    return State.SOFT_IRQ_RAISED.ordinal();\r
-                }\r
-                return State.SOFT_IRQ_ACTIVE.ordinal();\r
-            } else {\r
-                return -1; // NULL\r
-            }\r
-        }\r
-        return State.UNKNOWN.ordinal();\r
-    }\r
-\r
-    @Override\r
-    public String getEventName(ITimeEvent event) {\r
-        if (event instanceof ResourcesEvent) {\r
-            ResourcesEvent resourcesEvent = (ResourcesEvent) event;\r
-            if (resourcesEvent.getType() == Type.CPU) {\r
-                int status = resourcesEvent.getValue();\r
-                if (status == StateValues.CPU_STATUS_IDLE) {\r
-                    return State.IDLE.toString();\r
-                } else if (status == StateValues.CPU_STATUS_RUN_USERMODE) {\r
-                    return State.USERMODE.toString();\r
-                } else if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {\r
-                    return State.SYSCALL.toString();\r
-                } else if (status == StateValues.CPU_STATUS_IRQ) {\r
-                    return State.IRQ.toString();\r
-                } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {\r
-                    return State.SOFT_IRQ.toString();\r
-                }\r
-            } else if (resourcesEvent.getType() == Type.IRQ) {\r
-                return State.IRQ_ACTIVE.toString();\r
-            } else if (resourcesEvent.getType() == Type.SOFT_IRQ) {\r
-                int cpu = resourcesEvent.getValue();\r
-                if (cpu == StateValues.SOFT_IRQ_RAISED) {\r
-                    return State.SOFT_IRQ_RAISED.toString();\r
-                }\r
-                return State.SOFT_IRQ_ACTIVE.toString();\r
-            } else {\r
-                return null;\r
-            }\r
-        }\r
-        return State.UNKNOWN.toString();\r
-    }\r
-\r
-    @Override\r
-    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
-\r
-        Map<String, String> retMap = new HashMap<String, String>();\r
-        if (event instanceof ResourcesEvent) {\r
-\r
-            ResourcesEvent resourcesEvent = (ResourcesEvent) event;\r
-\r
-            // Check for IRQ or Soft_IRQ type\r
-            if (resourcesEvent.getType().equals(Type.IRQ) || resourcesEvent.getType().equals(Type.SOFT_IRQ)) {\r
-\r
-                // Get CPU of IRQ or SoftIRQ and provide it for the tooltip display\r
-                int cpu = resourcesEvent.getValue();\r
-                if (cpu >= 0) {\r
-                    retMap.put(Messages.ResourcesView_attributeCpuName, String.valueOf(cpu));\r
-                }\r
-            }\r
-\r
-            // Check for type CPU\r
-            if (resourcesEvent.getType().equals(Type.CPU)) {\r
-                int status = resourcesEvent.getValue();\r
-\r
-                if (status == StateValues.CPU_STATUS_IRQ) {\r
-                    // In IRQ state get the IRQ that caused the interruption\r
-                    ResourcesEntry entry = (ResourcesEntry) event.getEntry();\r
-                    IStateSystemQuerier ssq = entry.getTrace().getStateSystem();\r
-                    int cpu = entry.getId();\r
-\r
-                    IStateSystemQuerier ss = entry.getTrace().getStateSystem();\r
-                    try {\r
-                        List<ITmfStateInterval> fullState = ss.queryFullState(event.getTime());\r
-                        List<Integer> irqQuarks = ss.getQuarks(Attributes.RESOURCES, Attributes.IRQS, "*"); //$NON-NLS-1$\r
-\r
-                        for (int irqQuark : irqQuarks) {\r
-                            if (fullState.get(irqQuark).getStateValue().unboxInt() == cpu) {\r
-                                ITmfStateInterval value = ssq.querySingleState(event.getTime(), irqQuark);\r
-                                if (!value.getStateValue().isNull()) {\r
-                                    int irq = Integer.parseInt(ssq.getAttributeName(irqQuark));\r
-                                    retMap.put(Messages.ResourcesView_attributeIrqName, String.valueOf(irq));\r
-                                }\r
-                                break;\r
-                            }\r
-                        }\r
-                    } catch (AttributeNotFoundException e) {\r
-                        e.printStackTrace();\r
-                    } catch (TimeRangeException e) {\r
-                        e.printStackTrace();\r
-                    } catch (StateValueTypeException e) {\r
-                        e.printStackTrace();\r
-                    }\r
-                } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {\r
-                    // In SOFT_IRQ state get the SOFT_IRQ that caused the interruption\r
-                    ResourcesEntry entry = (ResourcesEntry) event.getEntry();\r
-                    IStateSystemQuerier ssq = entry.getTrace().getStateSystem();\r
-                    int cpu = entry.getId();\r
-\r
-                    IStateSystemQuerier ss = entry.getTrace().getStateSystem();\r
-                    try {\r
-                        List<ITmfStateInterval> fullState = ss.queryFullState(event.getTime());\r
-                        List<Integer> softIrqQuarks = ss.getQuarks(Attributes.RESOURCES, Attributes.SOFT_IRQS, "*"); //$NON-NLS-1$\r
-\r
-                        for (int softIrqQuark : softIrqQuarks) {\r
-                            if (fullState.get(softIrqQuark).getStateValue().unboxInt() == cpu) {\r
-                                ITmfStateInterval value = ssq.querySingleState(event.getTime(), softIrqQuark);\r
-                                if (!value.getStateValue().isNull()) {\r
-                                    int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));\r
-                                    retMap.put(Messages.ResourcesView_attributeSoftIrqName, String.valueOf(softIrq));\r
-                                }\r
-                                break;\r
-                            }\r
-                        }\r
-                    } catch (AttributeNotFoundException e) {\r
-                        e.printStackTrace();\r
-                    } catch (TimeRangeException e) {\r
-                        e.printStackTrace();\r
-                    } catch (StateValueTypeException e) {\r
-                        e.printStackTrace();\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        return retMap;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
+import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
+import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Presentation provider for the Resource view, based on the generic TMF
+ * presentation provider.
+ *
+ * @author Patrick Tasse
+ */
+public class ResourcesPresentationProvider extends TimeGraphPresentationProvider {
+
+    private enum State {
+        UNKNOWN         (new RGB(100, 100, 100)),
+        IDLE            (new RGB(200, 200, 200)),
+        USERMODE        (new RGB(0, 200, 0)),
+        SYSCALL         (new RGB(0, 0, 200)),
+        IRQ             (new RGB(200, 100, 100)),
+        SOFT_IRQ        (new RGB(200, 150, 100)),
+        IRQ_ACTIVE      (new RGB(200, 100, 100)),
+        SOFT_IRQ_RAISED (new RGB(200, 200, 0)),
+        SOFT_IRQ_ACTIVE (new RGB(200, 150, 100));
+
+        public final RGB rgb;
+
+        private State (RGB rgb) {
+            this.rgb = rgb;
+        }
+    }
+
+    @Override
+    public String getStateTypeName() {
+        return Messages.ResourcesView_stateTypeName;
+    }
+
+    @Override
+    public StateItem[] getStateTable() {
+        StateItem[] stateTable = new StateItem[State.values().length];
+        for (int i = 0; i < stateTable.length; i++) {
+            State state = State.values()[i];
+            stateTable[i] = new StateItem(state.rgb, state.toString());
+        }
+        return stateTable;
+    }
+
+    @Override
+    public int getStateTableIndex(ITimeEvent event) {
+        if (event instanceof ResourcesEvent) {
+            ResourcesEvent resourcesEvent = (ResourcesEvent) event;
+            if (resourcesEvent.getType() == Type.CPU) {
+                int status = resourcesEvent.getValue();
+                if (status == StateValues.CPU_STATUS_IDLE) {
+                    return State.IDLE.ordinal();
+                } else if (status == StateValues.CPU_STATUS_RUN_USERMODE) {
+                    return State.USERMODE.ordinal();
+                } else if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {
+                    return State.SYSCALL.ordinal();
+                } else if (status == StateValues.CPU_STATUS_IRQ) {
+                    return State.IRQ.ordinal();
+                } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
+                    return State.SOFT_IRQ.ordinal();
+                }
+            } else if (resourcesEvent.getType() == Type.IRQ) {
+                return State.IRQ_ACTIVE.ordinal();
+            } else if (resourcesEvent.getType() == Type.SOFT_IRQ) {
+                int cpu = resourcesEvent.getValue();
+                if (cpu == StateValues.SOFT_IRQ_RAISED) {
+                    return State.SOFT_IRQ_RAISED.ordinal();
+                }
+                return State.SOFT_IRQ_ACTIVE.ordinal();
+            } else {
+                return -1; // NULL
+            }
+        }
+        return State.UNKNOWN.ordinal();
+    }
+
+    @Override
+    public String getEventName(ITimeEvent event) {
+        if (event instanceof ResourcesEvent) {
+            ResourcesEvent resourcesEvent = (ResourcesEvent) event;
+            if (resourcesEvent.getType() == Type.CPU) {
+                int status = resourcesEvent.getValue();
+                if (status == StateValues.CPU_STATUS_IDLE) {
+                    return State.IDLE.toString();
+                } else if (status == StateValues.CPU_STATUS_RUN_USERMODE) {
+                    return State.USERMODE.toString();
+                } else if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {
+                    return State.SYSCALL.toString();
+                } else if (status == StateValues.CPU_STATUS_IRQ) {
+                    return State.IRQ.toString();
+                } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
+                    return State.SOFT_IRQ.toString();
+                }
+            } else if (resourcesEvent.getType() == Type.IRQ) {
+                return State.IRQ_ACTIVE.toString();
+            } else if (resourcesEvent.getType() == Type.SOFT_IRQ) {
+                int cpu = resourcesEvent.getValue();
+                if (cpu == StateValues.SOFT_IRQ_RAISED) {
+                    return State.SOFT_IRQ_RAISED.toString();
+                }
+                return State.SOFT_IRQ_ACTIVE.toString();
+            } else {
+                return null;
+            }
+        }
+        return State.UNKNOWN.toString();
+    }
+
+    @Override
+    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {
+
+        Map<String, String> retMap = new HashMap<String, String>();
+        if (event instanceof ResourcesEvent) {
+
+            ResourcesEvent resourcesEvent = (ResourcesEvent) event;
+
+            // Check for IRQ or Soft_IRQ type
+            if (resourcesEvent.getType().equals(Type.IRQ) || resourcesEvent.getType().equals(Type.SOFT_IRQ)) {
+
+                // Get CPU of IRQ or SoftIRQ and provide it for the tooltip display
+                int cpu = resourcesEvent.getValue();
+                if (cpu >= 0) {
+                    retMap.put(Messages.ResourcesView_attributeCpuName, String.valueOf(cpu));
+                }
+            }
+
+            // Check for type CPU
+            if (resourcesEvent.getType().equals(Type.CPU)) {
+                int status = resourcesEvent.getValue();
+
+                if (status == StateValues.CPU_STATUS_IRQ) {
+                    // In IRQ state get the IRQ that caused the interruption
+                    ResourcesEntry entry = (ResourcesEntry) event.getEntry();
+                    IStateSystemQuerier ssq = entry.getTrace().getStateSystem();
+                    int cpu = entry.getId();
+
+                    IStateSystemQuerier ss = entry.getTrace().getStateSystem();
+                    try {
+                        List<ITmfStateInterval> fullState = ss.queryFullState(event.getTime());
+                        List<Integer> irqQuarks = ss.getQuarks(Attributes.RESOURCES, Attributes.IRQS, "*"); //$NON-NLS-1$
+
+                        for (int irqQuark : irqQuarks) {
+                            if (fullState.get(irqQuark).getStateValue().unboxInt() == cpu) {
+                                ITmfStateInterval value = ssq.querySingleState(event.getTime(), irqQuark);
+                                if (!value.getStateValue().isNull()) {
+                                    int irq = Integer.parseInt(ssq.getAttributeName(irqQuark));
+                                    retMap.put(Messages.ResourcesView_attributeIrqName, String.valueOf(irq));
+                                }
+                                break;
+                            }
+                        }
+                    } catch (AttributeNotFoundException e) {
+                        e.printStackTrace();
+                    } catch (TimeRangeException e) {
+                        e.printStackTrace();
+                    } catch (StateValueTypeException e) {
+                        e.printStackTrace();
+                    }
+                } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
+                    // In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
+                    ResourcesEntry entry = (ResourcesEntry) event.getEntry();
+                    IStateSystemQuerier ssq = entry.getTrace().getStateSystem();
+                    int cpu = entry.getId();
+
+                    IStateSystemQuerier ss = entry.getTrace().getStateSystem();
+                    try {
+                        List<ITmfStateInterval> fullState = ss.queryFullState(event.getTime());
+                        List<Integer> softIrqQuarks = ss.getQuarks(Attributes.RESOURCES, Attributes.SOFT_IRQS, "*"); //$NON-NLS-1$
+
+                        for (int softIrqQuark : softIrqQuarks) {
+                            if (fullState.get(softIrqQuark).getStateValue().unboxInt() == cpu) {
+                                ITmfStateInterval value = ssq.querySingleState(event.getTime(), softIrqQuark);
+                                if (!value.getStateValue().isNull()) {
+                                    int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));
+                                    retMap.put(Messages.ResourcesView_attributeSoftIrqName, String.valueOf(softIrq));
+                                }
+                                break;
+                            }
+                        }
+                    } catch (AttributeNotFoundException e) {
+                        e.printStackTrace();
+                    } catch (TimeRangeException e) {
+                        e.printStackTrace();
+                    } catch (StateValueTypeException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        return retMap;
+    }
+
+}
index 4dca24190cd3a45aff584771417d58aaa2bf1fac..7ba9aff5d1bcebec752835421441251cf130dd22 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.Comparator;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.IToolBarManager;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;\r
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;\r
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;\r
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
-import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;\r
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;\r
-import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier2;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;\r
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.IActionBars;\r
-\r
-/**\r
- * Main implementation for the LTTng 2.0 kernel Resource view\r
- *\r
- * @author Patrick Tasse\r
- */\r
-public class ResourcesView extends TmfView {\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constants\r
-    // ------------------------------------------------------------------------\r
-\r
-    /** View ID. */\r
-    public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.ui.views.resources"; //$NON-NLS-1$\r
-\r
-    /** Initial time range */\r
-    private static final long INITIAL_WINDOW_OFFSET = (1L * 100  * 1000 * 1000); // .1sec\r
-\r
-    /**\r
-     * Redraw state enum\r
-     */\r
-    private enum State { IDLE, BUSY, PENDING }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Fields\r
-    // ------------------------------------------------------------------------\r
-\r
-    // The time graph viewer\r
-    TimeGraphViewer fTimeGraphViewer;\r
-\r
-    // The selected experiment\r
-    private TmfExperiment<ITmfEvent> fSelectedExperiment;\r
-\r
-    // The time graph entry list\r
-    private ArrayList<TraceEntry> fEntryList;\r
-\r
-    // The time graph entry list synchronization object\r
-    final private Object fEntryListSyncObj = new Object();\r
-\r
-    // The start time\r
-    private long fStartTime;\r
-\r
-    // The end time\r
-    private long fEndTime;\r
-\r
-    // The display width\r
-    private final int fDisplayWidth;\r
-\r
-    // The next resource action\r
-    private Action fNextResourceAction;\r
-\r
-    // The previous resource action\r
-    private Action fPreviousResourceAction;\r
-\r
-    // The zoom thread\r
-    private ZoomThread fZoomThread;\r
-\r
-    // The redraw state used to prevent unnecessary queuing of display runnables\r
-    private State fRedrawState = State.IDLE;\r
-\r
-    // The redraw synchronization object\r
-    final private Object fSyncObj = new Object();\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Classes\r
-    // ------------------------------------------------------------------------\r
-\r
-    private class TraceEntry implements ITimeGraphEntry {\r
-        // The Trace\r
-        private final CtfKernelTrace fTrace;\r
-        // The start time\r
-        private final long fTraceStartTime;\r
-        // The end time\r
-        private final long fTraceEndTime;\r
-        // The children of the entry\r
-        private final ArrayList<ResourcesEntry> fChildren;\r
-        // The name of entry\r
-        private final String fName;\r
-\r
-        public TraceEntry(CtfKernelTrace trace, String name, long startTime, long endTime) {\r
-            fTrace = trace;\r
-            fChildren = new ArrayList<ResourcesEntry>();\r
-            fName = name;\r
-            fTraceStartTime = startTime;\r
-            fTraceEndTime = endTime;\r
-        }\r
-\r
-        @Override\r
-        public ITimeGraphEntry getParent() {\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public boolean hasChildren() {\r
-            return fChildren != null && fChildren.size() > 0;\r
-        }\r
-\r
-        @Override\r
-        public ResourcesEntry[] getChildren() {\r
-            return fChildren.toArray(new ResourcesEntry[0]);\r
-        }\r
-\r
-        @Override\r
-        public String getName() {\r
-            return fName;\r
-        }\r
-\r
-        @Override\r
-        public long getStartTime() {\r
-            return fTraceStartTime;\r
-        }\r
-\r
-        @Override\r
-        public long getEndTime() {\r
-            return fTraceEndTime;\r
-        }\r
-\r
-        @Override\r
-        public boolean hasTimeEvents() {\r
-            return false;\r
-        }\r
-\r
-        @Override\r
-        public Iterator<ITimeEvent> getTimeEventsIterator() {\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {\r
-            return null;\r
-        }\r
-\r
-        public CtfKernelTrace getTrace() {\r
-            return fTrace;\r
-        }\r
-\r
-        public void addChild(ResourcesEntry entry) {\r
-            int index;\r
-            for (index = 0; index < fChildren.size(); index++) {\r
-                ResourcesEntry other = fChildren.get(index);\r
-                if (entry.getType().compareTo(other.getType()) < 0) {\r
-                    break;\r
-                } else if (entry.getType().equals(other.getType())) {\r
-                    if (entry.getId() < other.getId()) {\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-            entry.setParent(this);\r
-            fChildren.add(index, entry);\r
-        }\r
-    }\r
-\r
-    private static class TraceEntryComparator implements Comparator<ITimeGraphEntry> {\r
-        @Override\r
-        public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {\r
-            int result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;\r
-            if (result == 0) {\r
-                result = o1.getName().compareTo(o2.getName());\r
-            }\r
-            return result;\r
-        }\r
-    }\r
-\r
-    private class ZoomThread extends Thread {\r
-        private final long fZoomStartTime;\r
-        private final long fZoomEndTime;\r
-        private final IProgressMonitor fMonitor;\r
-\r
-        public ZoomThread(long startTime, long endTime) {\r
-            super("ResourcesView zoom"); //$NON-NLS-1$\r
-            fZoomStartTime = startTime;\r
-            fZoomEndTime = endTime;\r
-            fMonitor = new NullProgressMonitor();\r
-        }\r
-\r
-        @Override\r
-        public void run() {\r
-            ArrayList<TraceEntry> entryList = null;\r
-            synchronized (fEntryListSyncObj) {\r
-                entryList = fEntryList;\r
-            }\r
-            if (entryList == null) {\r
-                return;\r
-            }\r
-            long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);\r
-            for (TraceEntry traceEntry : entryList) {\r
-                for (ITimeGraphEntry child : traceEntry.getChildren()) {\r
-                    if (fMonitor.isCanceled()) {\r
-                        break;\r
-                    }\r
-                    ResourcesEntry entry = (ResourcesEntry) child;\r
-                    if (fZoomStartTime <= fStartTime && fZoomEndTime >= fEndTime) {\r
-                        entry.setZoomedEventList(null);\r
-                    } else {\r
-                        List<ITimeEvent> zoomedEventList = getEventList(entry, fZoomStartTime, fZoomEndTime, resolution, true, fMonitor);\r
-                        if (zoomedEventList != null) {\r
-                            entry.setZoomedEventList(zoomedEventList);\r
-                        }\r
-                    }\r
-                    redraw();\r
-                }\r
-            }\r
-        }\r
-\r
-        public void cancel() {\r
-            fMonitor.setCanceled(true);\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructors\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Default constructor\r
-     */\r
-    public ResourcesView() {\r
-        super(ID);\r
-        fDisplayWidth = Display.getDefault().getBounds().width;\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // ViewPart\r
-    // ------------------------------------------------------------------------\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)\r
-     */\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        fTimeGraphViewer = new TimeGraphViewer(parent, SWT.NONE);\r
-\r
-        fTimeGraphViewer.setTimeGraphProvider(new ResourcesPresentationProvider());\r
-\r
-        fTimeGraphViewer.setTimeCalendarFormat(true);\r
-\r
-        fTimeGraphViewer.addRangeListener(new ITimeGraphRangeListener() {\r
-            @Override\r
-            public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {\r
-                long startTime = event.getStartTime();\r
-                long endTime = event.getEndTime();\r
-                TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));\r
-                TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphViewer.getSelectedTime());\r
-                broadcast(new TmfRangeSynchSignal(ResourcesView.this, range, time));\r
-                startZoomThread(startTime, endTime);\r
-            }\r
-        });\r
-\r
-        fTimeGraphViewer.addTimeListener(new ITimeGraphTimeListener() {\r
-            @Override\r
-            public void timeSelected(TimeGraphTimeEvent event) {\r
-                long time = event.getTime();\r
-                broadcast(new TmfTimeSynchSignal(ResourcesView.this, new CtfTmfTimestamp(time)));\r
-            }\r
-        });\r
-\r
-        final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$\r
-            @Override\r
-            public void run() {\r
-                if (TmfExperiment.getCurrentExperiment() != null) {\r
-                    selectExperiment(TmfExperiment.getCurrentExperiment());\r
-                }\r
-            }\r
-        };\r
-        thread.start();\r
-\r
-        // View Action Handling\r
-        makeActions();\r
-        contributeToActionBars();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\r
-     */\r
-    @Override\r
-    public void setFocus() {\r
-        fTimeGraphViewer.setFocus();\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Signal handlers\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Handler for the ExperimentSelected signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void experimentSelected(final TmfExperimentSelectedSignal<? extends TmfEvent> signal) {\r
-        if (signal.getExperiment().equals(fSelectedExperiment)) {\r
-            return;\r
-        }\r
-\r
-        final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$\r
-            @Override\r
-            public void run() {\r
-                selectExperiment(signal.getExperiment());\r
-            }\r
-        };\r
-        thread.start();\r
-    }\r
-\r
-    /**\r
-     * Handler for the TimeSynch signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void synchToTime(final TmfTimeSynchSignal signal) {\r
-        if (signal.getSource() == this || fSelectedExperiment == null) {\r
-            return;\r
-        }\r
-        final long time = signal.getCurrentTime().normalize(0, -9).getValue();\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphViewer.getControl().isDisposed()) {\r
-                    return;\r
-                }\r
-                fTimeGraphViewer.setSelectedTime(time, true);\r
-                startZoomThread(fTimeGraphViewer.getTime0(), fTimeGraphViewer.getTime1());\r
-            }\r
-        });\r
-    }\r
-\r
-    /**\r
-     * Handler for the RangeSynch signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void synchToRange(final TmfRangeSynchSignal signal) {\r
-        if (signal.getSource() == this || fSelectedExperiment == null) {\r
-            return;\r
-        }\r
-        final long startTime = signal.getCurrentRange().getStartTime().normalize(0, -9).getValue();\r
-        final long endTime = signal.getCurrentRange().getEndTime().normalize(0, -9).getValue();\r
-        final long time = signal.getCurrentTime().normalize(0, -9).getValue();\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphViewer.getControl().isDisposed()) {\r
-                    return;\r
-                }\r
-                fTimeGraphViewer.setStartFinishTime(startTime, endTime);\r
-                fTimeGraphViewer.setSelectedTime(time, false);\r
-                startZoomThread(startTime, endTime);\r
-            }\r
-        });\r
-    }\r
-\r
-    /**\r
-     * Handler for the StatesystemBuildCompleted signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal) {\r
-        final TmfExperiment<?> selectedExperiment = fSelectedExperiment;\r
-        if (selectedExperiment == null || selectedExperiment.getTraces() == null) {\r
-            return;\r
-        }\r
-        for (ITmfTrace<?> trace : selectedExperiment.getTraces()) {\r
-            if (trace == signal.getTrace() && trace instanceof CtfKernelTrace) {\r
-                final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$\r
-                    @Override\r
-                    public void run() {\r
-                        // rebuild the model\r
-                        selectExperiment(selectedExperiment);\r
-                    }\r
-                };\r
-                thread.start();\r
-            }\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Internal\r
-    // ------------------------------------------------------------------------\r
-\r
-    @SuppressWarnings("unchecked")\r
-    private void selectExperiment(TmfExperiment<?> experiment) {\r
-        fStartTime = Long.MAX_VALUE;\r
-        fEndTime = Long.MIN_VALUE;\r
-        fSelectedExperiment = (TmfExperiment<ITmfEvent>) experiment;\r
-        ArrayList<TraceEntry> entryList = new ArrayList<TraceEntry>();\r
-        for (ITmfTrace<?> trace : experiment.getTraces()) {\r
-            if (trace instanceof CtfKernelTrace) {\r
-                CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;\r
-                IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
-                long startTime = ssq.getStartTime();\r
-                long endTime = ssq.getCurrentEndTime() + 1;\r
-                TraceEntry groupEntry = new TraceEntry(ctfKernelTrace, trace.getName(), startTime, endTime);\r
-                entryList.add(groupEntry);\r
-                fStartTime = Math.min(fStartTime, startTime);\r
-                fEndTime = Math.max(fEndTime, endTime);\r
-                List<Integer> cpuQuarks = ssq.getQuarks(Attributes.CPUS, "*"); //$NON-NLS-1$\r
-                ResourcesEntry[] cpuEntries = new ResourcesEntry[cpuQuarks.size()];\r
-                for (int i = 0; i < cpuQuarks.size(); i++) {\r
-                    int cpuQuark = cpuQuarks.get(i);\r
-                    int cpu = Integer.parseInt(ssq.getAttributeName(cpuQuark));\r
-                    ResourcesEntry entry = new ResourcesEntry(cpuQuark, ctfKernelTrace, Type.CPU, cpu);\r
-                    groupEntry.addChild(entry);\r
-                    cpuEntries[i] = entry;\r
-                }\r
-                List<Integer> irqQuarks = ssq.getQuarks(Attributes.RESOURCES, Attributes.IRQS, "*"); //$NON-NLS-1$\r
-                ResourcesEntry[] irqEntries = new ResourcesEntry[irqQuarks.size()];\r
-                for (int i = 0; i < irqQuarks.size(); i++) {\r
-                    int irqQuark = irqQuarks.get(i);\r
-                    int irq = Integer.parseInt(ssq.getAttributeName(irqQuark));\r
-                    ResourcesEntry entry = new ResourcesEntry(irqQuark, ctfKernelTrace, Type.IRQ, irq);\r
-                    groupEntry.addChild(entry);\r
-                    irqEntries[i] = entry;\r
-                }\r
-                List<Integer> softIrqQuarks = ssq.getQuarks(Attributes.RESOURCES, Attributes.SOFT_IRQS, "*"); //$NON-NLS-1$\r
-                ResourcesEntry[] softIrqEntries = new ResourcesEntry[softIrqQuarks.size()];\r
-                for (int i = 0; i < softIrqQuarks.size(); i++) {\r
-                    int softIrqQuark = softIrqQuarks.get(i);\r
-                    int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));\r
-                    ResourcesEntry entry = new ResourcesEntry(softIrqQuark, ctfKernelTrace, Type.SOFT_IRQ, softIrq);\r
-                    groupEntry.addChild(entry);\r
-                    softIrqEntries[i] = entry;\r
-                }\r
-            }\r
-        }\r
-        synchronized (fEntryListSyncObj) {\r
-            fEntryList = (ArrayList<TraceEntry>) entryList.clone();\r
-        }\r
-        refresh(INITIAL_WINDOW_OFFSET);\r
-        for (TraceEntry traceEntry : entryList) {\r
-            CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();\r
-            IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
-            long startTime = ssq.getStartTime();\r
-            long endTime = ssq.getCurrentEndTime() + 1;\r
-            long resolution = (endTime - startTime) / fDisplayWidth;\r
-            for (ResourcesEntry entry : traceEntry.getChildren()) {\r
-                List<ITimeEvent> eventList = getEventList(entry, startTime, endTime, resolution, false, new NullProgressMonitor());\r
-                entry.setEventList(eventList);\r
-                redraw();\r
-            }\r
-        }\r
-    }\r
-\r
-    private static List<ITimeEvent> getEventList(ResourcesEntry entry,\r
-            long startTime, long endTime, long resolution, boolean includeNull,\r
-            IProgressMonitor monitor) {\r
-        IStateSystemQuerier2 ssq = (IStateSystemQuerier2) entry.getTrace().getStateSystem();\r
-        startTime = Math.max(startTime, ssq.getStartTime());\r
-        endTime = Math.min(endTime, ssq.getCurrentEndTime() + 1);\r
-        if (endTime <= startTime) {\r
-            return null;\r
-        }\r
-        List<ITimeEvent> eventList = null;\r
-        int quark = entry.getQuark();\r
-        try {\r
-            if (entry.getType().equals(Type.CPU)) {\r
-                int statusQuark = ssq.getQuarkRelative(quark, Attributes.STATUS);\r
-                List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);\r
-                eventList = new ArrayList<ITimeEvent>(statusIntervals.size());\r
-                long lastEndTime = -1;\r
-                for (ITmfStateInterval statusInterval : statusIntervals) {\r
-                    if (monitor.isCanceled()) {\r
-                        return null;\r
-                    }\r
-                    int status = statusInterval.getStateValue().unboxInt();\r
-                    long time = statusInterval.getStartTime();\r
-                    long duration = statusInterval.getEndTime() - time + 1;\r
-                    if (!statusInterval.getStateValue().isNull()) {\r
-                        if (lastEndTime != time && lastEndTime != -1) {\r
-                            eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));\r
-                        }\r
-                        eventList.add(new ResourcesEvent(entry, time, duration, status));\r
-                        lastEndTime = time + duration;\r
-                    } else {\r
-                        if (includeNull) {\r
-                            eventList.add(new ResourcesEvent(entry, time, duration));\r
-                        }\r
-                    }\r
-                }\r
-            } else if (entry.getType().equals(Type.IRQ)) {\r
-                List<ITmfStateInterval> irqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);\r
-                eventList = new ArrayList<ITimeEvent>(irqIntervals.size());\r
-                long lastEndTime = -1;\r
-                boolean lastIsNull = true;\r
-                for (ITmfStateInterval irqInterval : irqIntervals) {\r
-                    if (monitor.isCanceled()) {\r
-                        return null;\r
-                    }\r
-                    long time = irqInterval.getStartTime();\r
-                    long duration = irqInterval.getEndTime() - time + 1;\r
-                    if (!irqInterval.getStateValue().isNull()) {\r
-                        int cpu = irqInterval.getStateValue().unboxInt();\r
-                        eventList.add(new ResourcesEvent(entry, time, duration, cpu));\r
-                        lastIsNull = false;\r
-                    } else {\r
-                        if (lastEndTime != time && lastEndTime != -1 && lastIsNull) {\r
-                            eventList.add(new ResourcesEvent(entry, lastEndTime, time - lastEndTime, -1));\r
-                        }\r
-                        if (includeNull) {\r
-                            eventList.add(new ResourcesEvent(entry, time, duration));\r
-                        }\r
-                        lastIsNull = true;\r
-                    }\r
-                    lastEndTime = time + duration;\r
-                }\r
-            } else if (entry.getType().equals(Type.SOFT_IRQ)) {\r
-                List<ITmfStateInterval> softIrqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);\r
-                eventList = new ArrayList<ITimeEvent>(softIrqIntervals.size());\r
-                long lastEndTime = -1;\r
-                boolean lastIsNull = true;\r
-                for (ITmfStateInterval softIrqInterval : softIrqIntervals) {\r
-                    if (monitor.isCanceled()) {\r
-                        return null;\r
-                    }\r
-                    long time = softIrqInterval.getStartTime();\r
-                    long duration = softIrqInterval.getEndTime() - time + 1;\r
-                    if (!softIrqInterval.getStateValue().isNull()) {\r
-                        int cpu = softIrqInterval.getStateValue().unboxInt();\r
-                        eventList.add(new ResourcesEvent(entry, time, duration, cpu));\r
-                    } else {\r
-                        if (lastEndTime != time && lastEndTime != -1 && lastIsNull) {\r
-                            eventList.add(new ResourcesEvent(entry, lastEndTime, time - lastEndTime, -1));\r
-                        }\r
-                        if (includeNull) {\r
-                            eventList.add(new ResourcesEvent(entry, time, duration));\r
-                        }\r
-                        lastIsNull = true;\r
-                    }\r
-                    lastEndTime = time + duration;\r
-                }\r
-            }\r
-        } catch (AttributeNotFoundException e) {\r
-            e.printStackTrace();\r
-        } catch (TimeRangeException e) {\r
-            e.printStackTrace();\r
-        } catch (StateValueTypeException e) {\r
-            e.printStackTrace();\r
-        }\r
-        return eventList;\r
-    }\r
-\r
-    private void refresh(final long windowRange) {\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphViewer.getControl().isDisposed()) {\r
-                    return;\r
-                }\r
-                ITimeGraphEntry[] entries = null;\r
-                synchronized (fEntryListSyncObj) {\r
-                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
-                }\r
-                Arrays.sort(entries, new TraceEntryComparator());\r
-                fTimeGraphViewer.setInput(entries);\r
-                fTimeGraphViewer.setTimeBounds(fStartTime, fEndTime);\r
-\r
-                long endTime = fStartTime + windowRange;\r
-\r
-                if (fEndTime < endTime) {\r
-                    endTime = fEndTime;\r
-                }\r
-                fTimeGraphViewer.setStartFinishTime(fStartTime, endTime);\r
-\r
-                startZoomThread(fStartTime, endTime);\r
-            }\r
-        });\r
-    }\r
-\r
-\r
-    private void redraw() {\r
-        synchronized (fSyncObj) {\r
-            if (fRedrawState == State.IDLE) {\r
-                fRedrawState = State.BUSY;\r
-            } else {\r
-                fRedrawState = State.PENDING;\r
-                return;\r
-            }\r
-        }\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fTimeGraphViewer.getControl().isDisposed()) {\r
-                    return;\r
-                }\r
-                fTimeGraphViewer.getControl().redraw();\r
-                fTimeGraphViewer.getControl().update();\r
-                synchronized (fSyncObj) {\r
-                    if (fRedrawState == State.PENDING) {\r
-                        fRedrawState = State.IDLE;\r
-                        redraw();\r
-                    } else {\r
-                        fRedrawState = State.IDLE;\r
-                    }\r
-                }\r
-            }\r
-        });\r
-    }\r
-\r
-    private void startZoomThread(long startTime, long endTime) {\r
-        if (fZoomThread != null) {\r
-            fZoomThread.cancel();\r
-        }\r
-        fZoomThread = new ZoomThread(startTime, endTime);\r
-        fZoomThread.start();\r
-    }\r
-\r
-    private void makeActions() {\r
-        fPreviousResourceAction = fTimeGraphViewer.getPreviousItemAction();\r
-        fPreviousResourceAction.setText(Messages.ResourcesView_previousResourceActionNameText);\r
-        fPreviousResourceAction.setToolTipText(Messages.ResourcesView_previousResourceActionToolTipText);\r
-        fNextResourceAction = fTimeGraphViewer.getNextItemAction();\r
-        fNextResourceAction.setText(Messages.ResourcesView_nextResourceActionNameText);\r
-        fNextResourceAction.setToolTipText(Messages.ResourcesView_previousResourceActionToolTipText);\r
-    }\r
-\r
-    private void contributeToActionBars() {\r
-        IActionBars bars = getViewSite().getActionBars();\r
-        fillLocalToolBar(bars.getToolBarManager());\r
-    }\r
-\r
-    private void fillLocalToolBar(IToolBarManager manager) {\r
-        manager.add(fTimeGraphViewer.getShowLegendAction());\r
-        manager.add(new Separator());\r
-        manager.add(fTimeGraphViewer.getResetScaleAction());\r
-        manager.add(fTimeGraphViewer.getPreviousEventAction());\r
-        manager.add(fTimeGraphViewer.getNextEventAction());\r
-        manager.add(fPreviousResourceAction);\r
-        manager.add(fNextResourceAction);\r
-        manager.add(fTimeGraphViewer.getZoomInAction());\r
-        manager.add(fTimeGraphViewer.getZoomOutAction());\r
-        manager.add(new Separator());\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;
+import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier2;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
+import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+
+/**
+ * Main implementation for the LTTng 2.0 kernel Resource view
+ *
+ * @author Patrick Tasse
+ */
+public class ResourcesView extends TmfView {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    /** View ID. */
+    public static final String ID = "org.eclipse.linuxtools.lttng2.kernel.ui.views.resources"; //$NON-NLS-1$
+
+    /** Initial time range */
+    private static final long INITIAL_WINDOW_OFFSET = (1L * 100  * 1000 * 1000); // .1sec
+
+    /**
+     * Redraw state enum
+     */
+    private enum State { IDLE, BUSY, PENDING }
+
+    // ------------------------------------------------------------------------
+    // Fields
+    // ------------------------------------------------------------------------
+
+    // The time graph viewer
+    TimeGraphViewer fTimeGraphViewer;
+
+    // The selected experiment
+    private TmfExperiment<ITmfEvent> fSelectedExperiment;
+
+    // The time graph entry list
+    private ArrayList<TraceEntry> fEntryList;
+
+    // The time graph entry list synchronization object
+    final private Object fEntryListSyncObj = new Object();
+
+    // The start time
+    private long fStartTime;
+
+    // The end time
+    private long fEndTime;
+
+    // The display width
+    private final int fDisplayWidth;
+
+    // The next resource action
+    private Action fNextResourceAction;
+
+    // The previous resource action
+    private Action fPreviousResourceAction;
+
+    // The zoom thread
+    private ZoomThread fZoomThread;
+
+    // The redraw state used to prevent unnecessary queuing of display runnables
+    private State fRedrawState = State.IDLE;
+
+    // The redraw synchronization object
+    final private Object fSyncObj = new Object();
+
+    // ------------------------------------------------------------------------
+    // Classes
+    // ------------------------------------------------------------------------
+
+    private class TraceEntry implements ITimeGraphEntry {
+        // The Trace
+        private final CtfKernelTrace fTrace;
+        // The start time
+        private final long fTraceStartTime;
+        // The end time
+        private final long fTraceEndTime;
+        // The children of the entry
+        private final ArrayList<ResourcesEntry> fChildren;
+        // The name of entry
+        private final String fName;
+
+        public TraceEntry(CtfKernelTrace trace, String name, long startTime, long endTime) {
+            fTrace = trace;
+            fChildren = new ArrayList<ResourcesEntry>();
+            fName = name;
+            fTraceStartTime = startTime;
+            fTraceEndTime = endTime;
+        }
+
+        @Override
+        public ITimeGraphEntry getParent() {
+            return null;
+        }
+
+        @Override
+        public boolean hasChildren() {
+            return fChildren != null && fChildren.size() > 0;
+        }
+
+        @Override
+        public ResourcesEntry[] getChildren() {
+            return fChildren.toArray(new ResourcesEntry[0]);
+        }
+
+        @Override
+        public String getName() {
+            return fName;
+        }
+
+        @Override
+        public long getStartTime() {
+            return fTraceStartTime;
+        }
+
+        @Override
+        public long getEndTime() {
+            return fTraceEndTime;
+        }
+
+        @Override
+        public boolean hasTimeEvents() {
+            return false;
+        }
+
+        @Override
+        public Iterator<ITimeEvent> getTimeEventsIterator() {
+            return null;
+        }
+
+        @Override
+        public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
+            return null;
+        }
+
+        public CtfKernelTrace getTrace() {
+            return fTrace;
+        }
+
+        public void addChild(ResourcesEntry entry) {
+            int index;
+            for (index = 0; index < fChildren.size(); index++) {
+                ResourcesEntry other = fChildren.get(index);
+                if (entry.getType().compareTo(other.getType()) < 0) {
+                    break;
+                } else if (entry.getType().equals(other.getType())) {
+                    if (entry.getId() < other.getId()) {
+                        break;
+                    }
+                }
+            }
+            entry.setParent(this);
+            fChildren.add(index, entry);
+        }
+    }
+
+    private static class TraceEntryComparator implements Comparator<ITimeGraphEntry> {
+        @Override
+        public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
+            int result = o1.getStartTime() < o2.getStartTime() ? -1 : o1.getStartTime() > o2.getStartTime() ? 1 : 0;
+            if (result == 0) {
+                result = o1.getName().compareTo(o2.getName());
+            }
+            return result;
+        }
+    }
+
+    private class ZoomThread extends Thread {
+        private final long fZoomStartTime;
+        private final long fZoomEndTime;
+        private final IProgressMonitor fMonitor;
+
+        public ZoomThread(long startTime, long endTime) {
+            super("ResourcesView zoom"); //$NON-NLS-1$
+            fZoomStartTime = startTime;
+            fZoomEndTime = endTime;
+            fMonitor = new NullProgressMonitor();
+        }
+
+        @Override
+        public void run() {
+            ArrayList<TraceEntry> entryList = null;
+            synchronized (fEntryListSyncObj) {
+                entryList = fEntryList;
+            }
+            if (entryList == null) {
+                return;
+            }
+            long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
+            for (TraceEntry traceEntry : entryList) {
+                for (ITimeGraphEntry child : traceEntry.getChildren()) {
+                    if (fMonitor.isCanceled()) {
+                        break;
+                    }
+                    ResourcesEntry entry = (ResourcesEntry) child;
+                    if (fZoomStartTime <= fStartTime && fZoomEndTime >= fEndTime) {
+                        entry.setZoomedEventList(null);
+                    } else {
+                        List<ITimeEvent> zoomedEventList = getEventList(entry, fZoomStartTime, fZoomEndTime, resolution, true, fMonitor);
+                        if (zoomedEventList != null) {
+                            entry.setZoomedEventList(zoomedEventList);
+                        }
+                    }
+                    redraw();
+                }
+            }
+        }
+
+        public void cancel() {
+            fMonitor.setCanceled(true);
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Default constructor
+     */
+    public ResourcesView() {
+        super(ID);
+        fDisplayWidth = Display.getDefault().getBounds().width;
+    }
+
+    // ------------------------------------------------------------------------
+    // ViewPart
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+    public void createPartControl(Composite parent) {
+        fTimeGraphViewer = new TimeGraphViewer(parent, SWT.NONE);
+
+        fTimeGraphViewer.setTimeGraphProvider(new ResourcesPresentationProvider());
+
+        fTimeGraphViewer.setTimeCalendarFormat(true);
+
+        fTimeGraphViewer.addRangeListener(new ITimeGraphRangeListener() {
+            @Override
+            public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
+                long startTime = event.getStartTime();
+                long endTime = event.getEndTime();
+                TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
+                TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphViewer.getSelectedTime());
+                broadcast(new TmfRangeSynchSignal(ResourcesView.this, range, time));
+                startZoomThread(startTime, endTime);
+            }
+        });
+
+        fTimeGraphViewer.addTimeListener(new ITimeGraphTimeListener() {
+            @Override
+            public void timeSelected(TimeGraphTimeEvent event) {
+                long time = event.getTime();
+                broadcast(new TmfTimeSynchSignal(ResourcesView.this, new CtfTmfTimestamp(time)));
+            }
+        });
+
+        final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$
+            @Override
+            public void run() {
+                if (TmfExperiment.getCurrentExperiment() != null) {
+                    selectExperiment(TmfExperiment.getCurrentExperiment());
+                }
+            }
+        };
+        thread.start();
+
+        // View Action Handling
+        makeActions();
+        contributeToActionBars();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+     */
+    @Override
+    public void setFocus() {
+        fTimeGraphViewer.setFocus();
+    }
+
+    // ------------------------------------------------------------------------
+    // Signal handlers
+    // ------------------------------------------------------------------------
+
+    /**
+     * Handler for the ExperimentSelected signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void experimentSelected(final TmfExperimentSelectedSignal<? extends TmfEvent> signal) {
+        if (signal.getExperiment().equals(fSelectedExperiment)) {
+            return;
+        }
+
+        final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$
+            @Override
+            public void run() {
+                selectExperiment(signal.getExperiment());
+            }
+        };
+        thread.start();
+    }
+
+    /**
+     * Handler for the TimeSynch signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void synchToTime(final TmfTimeSynchSignal signal) {
+        if (signal.getSource() == this || fSelectedExperiment == null) {
+            return;
+        }
+        final long time = signal.getCurrentTime().normalize(0, -9).getValue();
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
+                    return;
+                }
+                fTimeGraphViewer.setSelectedTime(time, true);
+                startZoomThread(fTimeGraphViewer.getTime0(), fTimeGraphViewer.getTime1());
+            }
+        });
+    }
+
+    /**
+     * Handler for the RangeSynch signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void synchToRange(final TmfRangeSynchSignal signal) {
+        if (signal.getSource() == this || fSelectedExperiment == null) {
+            return;
+        }
+        final long startTime = signal.getCurrentRange().getStartTime().normalize(0, -9).getValue();
+        final long endTime = signal.getCurrentRange().getEndTime().normalize(0, -9).getValue();
+        final long time = signal.getCurrentTime().normalize(0, -9).getValue();
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
+                    return;
+                }
+                fTimeGraphViewer.setStartFinishTime(startTime, endTime);
+                fTimeGraphViewer.setSelectedTime(time, false);
+                startZoomThread(startTime, endTime);
+            }
+        });
+    }
+
+    /**
+     * Handler for the StatesystemBuildCompleted signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal) {
+        final TmfExperiment<?> selectedExperiment = fSelectedExperiment;
+        if (selectedExperiment == null || selectedExperiment.getTraces() == null) {
+            return;
+        }
+        for (ITmfTrace<?> trace : selectedExperiment.getTraces()) {
+            if (trace == signal.getTrace() && trace instanceof CtfKernelTrace) {
+                final Thread thread = new Thread("ResourcesView build") { //$NON-NLS-1$
+                    @Override
+                    public void run() {
+                        // rebuild the model
+                        selectExperiment(selectedExperiment);
+                    }
+                };
+                thread.start();
+            }
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Internal
+    // ------------------------------------------------------------------------
+
+    @SuppressWarnings("unchecked")
+    private void selectExperiment(TmfExperiment<?> experiment) {
+        fStartTime = Long.MAX_VALUE;
+        fEndTime = Long.MIN_VALUE;
+        fSelectedExperiment = (TmfExperiment<ITmfEvent>) experiment;
+        ArrayList<TraceEntry> entryList = new ArrayList<TraceEntry>();
+        for (ITmfTrace<?> trace : experiment.getTraces()) {
+            if (trace instanceof CtfKernelTrace) {
+                CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
+                IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();
+                long startTime = ssq.getStartTime();
+                long endTime = ssq.getCurrentEndTime() + 1;
+                TraceEntry groupEntry = new TraceEntry(ctfKernelTrace, trace.getName(), startTime, endTime);
+                entryList.add(groupEntry);
+                fStartTime = Math.min(fStartTime, startTime);
+                fEndTime = Math.max(fEndTime, endTime);
+                List<Integer> cpuQuarks = ssq.getQuarks(Attributes.CPUS, "*"); //$NON-NLS-1$
+                ResourcesEntry[] cpuEntries = new ResourcesEntry[cpuQuarks.size()];
+                for (int i = 0; i < cpuQuarks.size(); i++) {
+                    int cpuQuark = cpuQuarks.get(i);
+                    int cpu = Integer.parseInt(ssq.getAttributeName(cpuQuark));
+                    ResourcesEntry entry = new ResourcesEntry(cpuQuark, ctfKernelTrace, Type.CPU, cpu);
+                    groupEntry.addChild(entry);
+                    cpuEntries[i] = entry;
+                }
+                List<Integer> irqQuarks = ssq.getQuarks(Attributes.RESOURCES, Attributes.IRQS, "*"); //$NON-NLS-1$
+                ResourcesEntry[] irqEntries = new ResourcesEntry[irqQuarks.size()];
+                for (int i = 0; i < irqQuarks.size(); i++) {
+                    int irqQuark = irqQuarks.get(i);
+                    int irq = Integer.parseInt(ssq.getAttributeName(irqQuark));
+                    ResourcesEntry entry = new ResourcesEntry(irqQuark, ctfKernelTrace, Type.IRQ, irq);
+                    groupEntry.addChild(entry);
+                    irqEntries[i] = entry;
+                }
+                List<Integer> softIrqQuarks = ssq.getQuarks(Attributes.RESOURCES, Attributes.SOFT_IRQS, "*"); //$NON-NLS-1$
+                ResourcesEntry[] softIrqEntries = new ResourcesEntry[softIrqQuarks.size()];
+                for (int i = 0; i < softIrqQuarks.size(); i++) {
+                    int softIrqQuark = softIrqQuarks.get(i);
+                    int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));
+                    ResourcesEntry entry = new ResourcesEntry(softIrqQuark, ctfKernelTrace, Type.SOFT_IRQ, softIrq);
+                    groupEntry.addChild(entry);
+                    softIrqEntries[i] = entry;
+                }
+            }
+        }
+        synchronized (fEntryListSyncObj) {
+            fEntryList = (ArrayList<TraceEntry>) entryList.clone();
+        }
+        refresh(INITIAL_WINDOW_OFFSET);
+        for (TraceEntry traceEntry : entryList) {
+            CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();
+            IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();
+            long startTime = ssq.getStartTime();
+            long endTime = ssq.getCurrentEndTime() + 1;
+            long resolution = (endTime - startTime) / fDisplayWidth;
+            for (ResourcesEntry entry : traceEntry.getChildren()) {
+                List<ITimeEvent> eventList = getEventList(entry, startTime, endTime, resolution, false, new NullProgressMonitor());
+                entry.setEventList(eventList);
+                redraw();
+            }
+        }
+    }
+
+    private static List<ITimeEvent> getEventList(ResourcesEntry entry,
+            long startTime, long endTime, long resolution, boolean includeNull,
+            IProgressMonitor monitor) {
+        IStateSystemQuerier2 ssq = (IStateSystemQuerier2) entry.getTrace().getStateSystem();
+        startTime = Math.max(startTime, ssq.getStartTime());
+        endTime = Math.min(endTime, ssq.getCurrentEndTime() + 1);
+        if (endTime <= startTime) {
+            return null;
+        }
+        List<ITimeEvent> eventList = null;
+        int quark = entry.getQuark();
+        try {
+            if (entry.getType().equals(Type.CPU)) {
+                int statusQuark = ssq.getQuarkRelative(quark, Attributes.STATUS);
+                List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);
+                eventList = new ArrayList<ITimeEvent>(statusIntervals.size());
+                long lastEndTime = -1;
+                for (ITmfStateInterval statusInterval : statusIntervals) {
+                    if (monitor.isCanceled()) {
+                        return null;
+                    }
+                    int status = statusInterval.getStateValue().unboxInt();
+                    long time = statusInterval.getStartTime();
+                    long duration = statusInterval.getEndTime() - time + 1;
+                    if (!statusInterval.getStateValue().isNull()) {
+                        if (lastEndTime != time && lastEndTime != -1) {
+                            eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));
+                        }
+                        eventList.add(new ResourcesEvent(entry, time, duration, status));
+                        lastEndTime = time + duration;
+                    } else {
+                        if (includeNull) {
+                            eventList.add(new ResourcesEvent(entry, time, duration));
+                        }
+                    }
+                }
+            } else if (entry.getType().equals(Type.IRQ)) {
+                List<ITmfStateInterval> irqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);
+                eventList = new ArrayList<ITimeEvent>(irqIntervals.size());
+                long lastEndTime = -1;
+                boolean lastIsNull = true;
+                for (ITmfStateInterval irqInterval : irqIntervals) {
+                    if (monitor.isCanceled()) {
+                        return null;
+                    }
+                    long time = irqInterval.getStartTime();
+                    long duration = irqInterval.getEndTime() - time + 1;
+                    if (!irqInterval.getStateValue().isNull()) {
+                        int cpu = irqInterval.getStateValue().unboxInt();
+                        eventList.add(new ResourcesEvent(entry, time, duration, cpu));
+                        lastIsNull = false;
+                    } else {
+                        if (lastEndTime != time && lastEndTime != -1 && lastIsNull) {
+                            eventList.add(new ResourcesEvent(entry, lastEndTime, time - lastEndTime, -1));
+                        }
+                        if (includeNull) {
+                            eventList.add(new ResourcesEvent(entry, time, duration));
+                        }
+                        lastIsNull = true;
+                    }
+                    lastEndTime = time + duration;
+                }
+            } else if (entry.getType().equals(Type.SOFT_IRQ)) {
+                List<ITmfStateInterval> softIrqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);
+                eventList = new ArrayList<ITimeEvent>(softIrqIntervals.size());
+                long lastEndTime = -1;
+                boolean lastIsNull = true;
+                for (ITmfStateInterval softIrqInterval : softIrqIntervals) {
+                    if (monitor.isCanceled()) {
+                        return null;
+                    }
+                    long time = softIrqInterval.getStartTime();
+                    long duration = softIrqInterval.getEndTime() - time + 1;
+                    if (!softIrqInterval.getStateValue().isNull()) {
+                        int cpu = softIrqInterval.getStateValue().unboxInt();
+                        eventList.add(new ResourcesEvent(entry, time, duration, cpu));
+                    } else {
+                        if (lastEndTime != time && lastEndTime != -1 && lastIsNull) {
+                            eventList.add(new ResourcesEvent(entry, lastEndTime, time - lastEndTime, -1));
+                        }
+                        if (includeNull) {
+                            eventList.add(new ResourcesEvent(entry, time, duration));
+                        }
+                        lastIsNull = true;
+                    }
+                    lastEndTime = time + duration;
+                }
+            }
+        } catch (AttributeNotFoundException e) {
+            e.printStackTrace();
+        } catch (TimeRangeException e) {
+            e.printStackTrace();
+        } catch (StateValueTypeException e) {
+            e.printStackTrace();
+        }
+        return eventList;
+    }
+
+    private void refresh(final long windowRange) {
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
+                    return;
+                }
+                ITimeGraphEntry[] entries = null;
+                synchronized (fEntryListSyncObj) {
+                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);
+                }
+                Arrays.sort(entries, new TraceEntryComparator());
+                fTimeGraphViewer.setInput(entries);
+                fTimeGraphViewer.setTimeBounds(fStartTime, fEndTime);
+
+                long endTime = fStartTime + windowRange;
+
+                if (fEndTime < endTime) {
+                    endTime = fEndTime;
+                }
+                fTimeGraphViewer.setStartFinishTime(fStartTime, endTime);
+
+                startZoomThread(fStartTime, endTime);
+            }
+        });
+    }
+
+
+    private void redraw() {
+        synchronized (fSyncObj) {
+            if (fRedrawState == State.IDLE) {
+                fRedrawState = State.BUSY;
+            } else {
+                fRedrawState = State.PENDING;
+                return;
+            }
+        }
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
+                    return;
+                }
+                fTimeGraphViewer.getControl().redraw();
+                fTimeGraphViewer.getControl().update();
+                synchronized (fSyncObj) {
+                    if (fRedrawState == State.PENDING) {
+                        fRedrawState = State.IDLE;
+                        redraw();
+                    } else {
+                        fRedrawState = State.IDLE;
+                    }
+                }
+            }
+        });
+    }
+
+    private void startZoomThread(long startTime, long endTime) {
+        if (fZoomThread != null) {
+            fZoomThread.cancel();
+        }
+        fZoomThread = new ZoomThread(startTime, endTime);
+        fZoomThread.start();
+    }
+
+    private void makeActions() {
+        fPreviousResourceAction = fTimeGraphViewer.getPreviousItemAction();
+        fPreviousResourceAction.setText(Messages.ResourcesView_previousResourceActionNameText);
+        fPreviousResourceAction.setToolTipText(Messages.ResourcesView_previousResourceActionToolTipText);
+        fNextResourceAction = fTimeGraphViewer.getNextItemAction();
+        fNextResourceAction.setText(Messages.ResourcesView_nextResourceActionNameText);
+        fNextResourceAction.setToolTipText(Messages.ResourcesView_previousResourceActionToolTipText);
+    }
+
+    private void contributeToActionBars() {
+        IActionBars bars = getViewSite().getActionBars();
+        fillLocalToolBar(bars.getToolBarManager());
+    }
+
+    private void fillLocalToolBar(IToolBarManager manager) {
+        manager.add(fTimeGraphViewer.getShowLegendAction());
+        manager.add(new Separator());
+        manager.add(fTimeGraphViewer.getResetScaleAction());
+        manager.add(fTimeGraphViewer.getPreviousEventAction());
+        manager.add(fTimeGraphViewer.getNextEventAction());
+        manager.add(fPreviousResourceAction);
+        manager.add(fNextResourceAction);
+        manager.add(fTimeGraphViewer.getZoomInAction());
+        manager.add(fTimeGraphViewer.getZoomOutAction());
+        manager.add(new Separator());
+    }
+}
index 3dad637b1bf6cc2720a82f17bbcc28025d482d5e..d024e1d479a46d6707e52f92bbf9be09afdd6a9d 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.core;\r
-\r
-import java.io.BufferedWriter;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.io.OutputStreamWriter;\r
-\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;\r
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-\r
-@SuppressWarnings({"nls", "javadoc"})\r
-public class Tracer {\r
-\r
-    private static String pluginID = Activator.PLUGIN_ID;\r
-\r
-    static Boolean ERROR = Boolean.FALSE;\r
-    static Boolean WARNING = Boolean.FALSE;\r
-    static Boolean INFO = Boolean.FALSE;\r
-\r
-    static Boolean COMPONENT = Boolean.FALSE;\r
-    static Boolean REQUEST = Boolean.FALSE;\r
-    static Boolean SIGNAL = Boolean.FALSE;\r
-    static Boolean EVENT = Boolean.FALSE;\r
-\r
-    private static String LOGNAME = "trace.log";\r
-    private static BufferedWriter fTraceLog = new BufferedWriter(new OutputStreamWriter(System.out));\r
-\r
-    private static BufferedWriter openLogFile(String filename) {\r
-        BufferedWriter outfile = null;\r
-        try {\r
-            outfile = new BufferedWriter(new FileWriter(filename));\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error opening log file " + filename, e);\r
-        }\r
-        return outfile;\r
-    }\r
-\r
-    public static void init() {\r
-\r
-        String traceKey;\r
-        boolean isTracing = false;\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/error");\r
-        if (traceKey != null) {\r
-            ERROR = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= ERROR;\r
-        }\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/warning");\r
-        if (traceKey != null) {\r
-            WARNING = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= WARNING;\r
-        }\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/info");\r
-        if (traceKey != null) {\r
-            INFO = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= INFO;\r
-        }\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/component");\r
-        if (traceKey != null) {\r
-            COMPONENT = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= COMPONENT;\r
-        }\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/request");\r
-        if (traceKey != null) {\r
-            REQUEST = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= REQUEST;\r
-        }\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/signal");\r
-        if (traceKey != null) {\r
-            SIGNAL = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= SIGNAL;\r
-        }\r
-\r
-        traceKey = Platform.getDebugOption(pluginID + "/event");\r
-        if (traceKey != null) {\r
-            EVENT = (Boolean.valueOf(traceKey)).booleanValue();\r
-            isTracing |= EVENT;\r
-        }\r
-\r
-        // Create trace log file if needed\r
-        if (isTracing) {\r
-            fTraceLog = openLogFile(LOGNAME);\r
-        }\r
-    }\r
-\r
-    public static void stop() {\r
-        if (fTraceLog == null) {\r
-            return;\r
-        }\r
-\r
-        try {\r
-            fTraceLog.close();\r
-            fTraceLog = null;\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error closing log file", e);\r
-        }\r
-    }\r
-\r
-    // Predicates\r
-    public static boolean isErrorTraced() {\r
-        return ERROR;\r
-    }\r
-\r
-    public static boolean isComponentTraced() {\r
-        return COMPONENT;\r
-    }\r
-\r
-    public static boolean isRequestTraced() {\r
-        return REQUEST;\r
-    }\r
-\r
-    public static boolean isSignalTraced() {\r
-        return SIGNAL;\r
-    }\r
-\r
-    public static boolean isEventTraced() {\r
-        return EVENT;\r
-    }\r
-\r
-    // Tracers\r
-    public static synchronized void trace(String msg) {\r
-        long currentTime = System.currentTimeMillis();\r
-        StringBuilder message = new StringBuilder("[");\r
-        message.append(currentTime / 1000);\r
-        message.append(".");\r
-        message.append(String.format("%1$03d", currentTime % 1000));\r
-        message.append("] ");\r
-\r
-        message.append("[Th=");\r
-        message.append(String.format("%1$03d", Thread.currentThread().getId()));\r
-        message.append("] ");\r
-\r
-        message.append(msg);\r
-\r
-        if (fTraceLog != null) {\r
-            try {\r
-                fTraceLog.write(message.toString());\r
-                fTraceLog.newLine();\r
-                fTraceLog.flush();\r
-            } catch (IOException e) {\r
-                Activator.getDefault().logError("Error writing to log file", e);\r
-            }\r
-        }\r
-    }\r
-\r
-    public static void traceComponent(ITmfComponent component, String msg) {\r
-        String message = ("[CMP] Cmp=" + component.getName() + " " + msg);\r
-        trace(message);\r
-    }\r
-\r
-    public static void traceRequest(ITmfDataRequest<?> request, String msg) {\r
-        String message = ("[REQ] Req=" + request.getRequestId() + " " + msg);\r
-        trace(message);\r
-    }\r
-\r
-    public static void traceSignal(TmfSignal signal, String msg) {\r
-        String message = ("[SIG] Sig=" + signal.getClass().getSimpleName() + " Target=" + msg);\r
-        trace(message);\r
-    }\r
-\r
-    public static void traceEvent(ITmfDataProvider<?> provider, ITmfDataRequest<?> request, ITmfEvent event) {\r
-        String message = ("[EVT] Provider=" + provider.toString() + ", Req=" + request.getRequestId() + ", Event=" + event.getTimestamp());\r
-        trace(message);\r
-    }\r
-\r
-    public static void traceError(String msg) {\r
-        String message = ("[ERR] Err=" + msg);\r
-        trace(message);\r
-    }\r
-\r
-    public static void traceInfo(String msg) {\r
-        String message = ("[INF] " + msg);\r
-        trace(message);\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.core;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
+import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+
+@SuppressWarnings({"nls", "javadoc"})
+public class Tracer {
+
+    private static String pluginID = Activator.PLUGIN_ID;
+
+    static Boolean ERROR = Boolean.FALSE;
+    static Boolean WARNING = Boolean.FALSE;
+    static Boolean INFO = Boolean.FALSE;
+
+    static Boolean COMPONENT = Boolean.FALSE;
+    static Boolean REQUEST = Boolean.FALSE;
+    static Boolean SIGNAL = Boolean.FALSE;
+    static Boolean EVENT = Boolean.FALSE;
+
+    private static String LOGNAME = "trace.log";
+    private static BufferedWriter fTraceLog = new BufferedWriter(new OutputStreamWriter(System.out));
+
+    private static BufferedWriter openLogFile(String filename) {
+        BufferedWriter outfile = null;
+        try {
+            outfile = new BufferedWriter(new FileWriter(filename));
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error opening log file " + filename, e);
+        }
+        return outfile;
+    }
+
+    public static void init() {
+
+        String traceKey;
+        boolean isTracing = false;
+
+        traceKey = Platform.getDebugOption(pluginID + "/error");
+        if (traceKey != null) {
+            ERROR = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= ERROR;
+        }
+
+        traceKey = Platform.getDebugOption(pluginID + "/warning");
+        if (traceKey != null) {
+            WARNING = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= WARNING;
+        }
+
+        traceKey = Platform.getDebugOption(pluginID + "/info");
+        if (traceKey != null) {
+            INFO = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= INFO;
+        }
+
+        traceKey = Platform.getDebugOption(pluginID + "/component");
+        if (traceKey != null) {
+            COMPONENT = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= COMPONENT;
+        }
+
+        traceKey = Platform.getDebugOption(pluginID + "/request");
+        if (traceKey != null) {
+            REQUEST = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= REQUEST;
+        }
+
+        traceKey = Platform.getDebugOption(pluginID + "/signal");
+        if (traceKey != null) {
+            SIGNAL = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= SIGNAL;
+        }
+
+        traceKey = Platform.getDebugOption(pluginID + "/event");
+        if (traceKey != null) {
+            EVENT = (Boolean.valueOf(traceKey)).booleanValue();
+            isTracing |= EVENT;
+        }
+
+        // Create trace log file if needed
+        if (isTracing) {
+            fTraceLog = openLogFile(LOGNAME);
+        }
+    }
+
+    public static void stop() {
+        if (fTraceLog == null) {
+            return;
+        }
+
+        try {
+            fTraceLog.close();
+            fTraceLog = null;
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error closing log file", e);
+        }
+    }
+
+    // Predicates
+    public static boolean isErrorTraced() {
+        return ERROR;
+    }
+
+    public static boolean isComponentTraced() {
+        return COMPONENT;
+    }
+
+    public static boolean isRequestTraced() {
+        return REQUEST;
+    }
+
+    public static boolean isSignalTraced() {
+        return SIGNAL;
+    }
+
+    public static boolean isEventTraced() {
+        return EVENT;
+    }
+
+    // Tracers
+    public static synchronized void trace(String msg) {
+        long currentTime = System.currentTimeMillis();
+        StringBuilder message = new StringBuilder("[");
+        message.append(currentTime / 1000);
+        message.append(".");
+        message.append(String.format("%1$03d", currentTime % 1000));
+        message.append("] ");
+
+        message.append("[Th=");
+        message.append(String.format("%1$03d", Thread.currentThread().getId()));
+        message.append("] ");
+
+        message.append(msg);
+
+        if (fTraceLog != null) {
+            try {
+                fTraceLog.write(message.toString());
+                fTraceLog.newLine();
+                fTraceLog.flush();
+            } catch (IOException e) {
+                Activator.getDefault().logError("Error writing to log file", e);
+            }
+        }
+    }
+
+    public static void traceComponent(ITmfComponent component, String msg) {
+        String message = ("[CMP] Cmp=" + component.getName() + " " + msg);
+        trace(message);
+    }
+
+    public static void traceRequest(ITmfDataRequest<?> request, String msg) {
+        String message = ("[REQ] Req=" + request.getRequestId() + " " + msg);
+        trace(message);
+    }
+
+    public static void traceSignal(TmfSignal signal, String msg) {
+        String message = ("[SIG] Sig=" + signal.getClass().getSimpleName() + " Target=" + msg);
+        trace(message);
+    }
+
+    public static void traceEvent(ITmfDataProvider<?> provider, ITmfDataRequest<?> request, ITmfEvent event) {
+        String message = ("[EVT] Provider=" + provider.toString() + ", Req=" + request.getRequestId() + ", Event=" + event.getTimestamp());
+        trace(message);
+    }
+
+    public static void traceError(String msg) {
+        String message = ("[ERR] Err=" + msg);
+        trace(message);
+    }
+
+    public static void traceInfo(String msg) {
+        String message = ("[INF] " + msg);
+        trace(message);
+    }
+
+}
index 00ce5c28f7072e8cffb40e2b05934f9aa64bb3db..dd9f0654c8f2a7cdbe30be606495bef66f37698c 100644 (file)
@@ -1,33 +1,33 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * The TMF filter interface.\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITmfFilter {\r
-\r
-       /**\r
-        * Verify the filter conditions on an event\r
-        * \r
-        * @param event The event to verify.\r
-        * @return True if the event matches the filter conditions.\r
-        */\r
-       public boolean matches(ITmfEvent event);\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * The TMF filter interface.
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITmfFilter {
+
+       /**
+        * Verify the filter conditions on an event
+        * 
+        * @param event The event to verify.
+        * @return True if the event matches the filter conditions.
+        */
+       public boolean matches(ITmfEvent event);
+       
+}
index d55ee636efc1a23a7b070c07f5327f2da732b65f..aa9d347cb8b3233f2f3ba7ed6fa3de682aee839d 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Francois Godin (copelnug@gmail.com) - Initial API\r
- *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;\r
-\r
-\r
-/**\r
- * <h4>This is Node Interface in the Filter Tree</h4>\r
- */\r
-public interface ITmfFilterTreeNode extends ITmfFilter {\r
-\r
-       /**\r
-        * <h4>Get the parent node of current node</h4>\r
-        *\r
-        * @return The parent node (null when the node has no parent).\r
-        */\r
-       public ITmfFilterTreeNode getParent();\r
-\r
-       /**\r
-        * <h4>Get the current node name</h4>\r
-        *\r
-        * @return The name of the current node.\r
-        */\r
-       public String getNodeName();\r
-\r
-       /**\r
-        * <h4>Tell if the node has children</h4>\r
-        *\r
-        * @return True if the node has children.\r
-        */\r
-       public boolean hasChildren();\r
-\r
-       /**\r
-        * <h4>Return the number of children</h4>\r
-        *\r
-        * @return The number of children.\r
-        */\r
-       public int getChildrenCount();\r
-\r
-       /**\r
-        * <h4>Get the array of children</h4>\r
-        *\r
-        * @return The array (possibly empty) of children nodes.\r
-        */\r
-       public ITmfFilterTreeNode[] getChildren();\r
-\r
-       /**\r
-        * <h4>Get the node by index</h4>\r
-        *\r
-        * @param index The index of node to return.\r
-        * @return The desired node (null if the node is not exists).\r
-        */\r
-       public ITmfFilterTreeNode getChild(int index);\r
-\r
-       /**\r
-        * <h4>Remove the node from its parent</h4>\r
-        *\r
-        * <p>Shifts all nodes after the removed one to prevent having an empty spot.\r
-        * See {@link #replaceChild(int, ITmfFilterTreeNode)} to replace a node.</p>\r
-        *\r
-        * @return The removed node.\r
-        */\r
-       public ITmfFilterTreeNode remove();\r
-\r
-       /**\r
-        * <h4>Remove the child from the current node</h4>\r
-        *\r
-        * <p>Shifts all nodes after the removed one to prevent having an empty spot.\r
-        * See {@link #replaceChild(int, ITmfFilterTreeNode)} to replace a node.</p>\r
-        *\r
-        * @param node the parent node\r
-        *\r
-        * @return The removed node.\r
-        */\r
-       public ITmfFilterTreeNode removeChild(ITmfFilterTreeNode node);\r
-\r
-       /**\r
-        * <h4>Append a node to the current children</h4>\r
-        *\r
-        * @param node Node to append.\r
-        * @return Index of added node (-1 if the node cannot be added).\r
-        */\r
-       public int addChild(ITmfFilterTreeNode node);\r
-\r
-       /**\r
-        * <h4>Replace a child node</h4>\r
-        *\r
-        * @param index Index of the node to replace.\r
-        * @param node Node who will replace.\r
-        * @return Node replaced.\r
-        */\r
-       public ITmfFilterTreeNode replaceChild(int index, ITmfFilterTreeNode node);\r
-\r
-       /**\r
-        * <h4>Sets the parent of current node</h4>\r
-        *\r
-        * @param parent The parent of current node.\r
-        */\r
-       public void setParent(ITmfFilterTreeNode parent);\r
-\r
-       /**\r
-        * <h4>Gets the list of valid children node names that could be added to the node</h4>\r
-        *\r
-        * @return The list of valid children node names.\r
-        */\r
-       public List<String> getValidChildren();\r
-\r
-       /**\r
-        * @return a clone of the node\r
-        */\r
-       public ITmfFilterTreeNode clone();\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Francois Godin (copelnug@gmail.com) - Initial API
+ *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
+
+
+/**
+ * <h4>This is Node Interface in the Filter Tree</h4>
+ */
+public interface ITmfFilterTreeNode extends ITmfFilter {
+
+       /**
+        * <h4>Get the parent node of current node</h4>
+        *
+        * @return The parent node (null when the node has no parent).
+        */
+       public ITmfFilterTreeNode getParent();
+
+       /**
+        * <h4>Get the current node name</h4>
+        *
+        * @return The name of the current node.
+        */
+       public String getNodeName();
+
+       /**
+        * <h4>Tell if the node has children</h4>
+        *
+        * @return True if the node has children.
+        */
+       public boolean hasChildren();
+
+       /**
+        * <h4>Return the number of children</h4>
+        *
+        * @return The number of children.
+        */
+       public int getChildrenCount();
+
+       /**
+        * <h4>Get the array of children</h4>
+        *
+        * @return The array (possibly empty) of children nodes.
+        */
+       public ITmfFilterTreeNode[] getChildren();
+
+       /**
+        * <h4>Get the node by index</h4>
+        *
+        * @param index The index of node to return.
+        * @return The desired node (null if the node is not exists).
+        */
+       public ITmfFilterTreeNode getChild(int index);
+
+       /**
+        * <h4>Remove the node from its parent</h4>
+        *
+        * <p>Shifts all nodes after the removed one to prevent having an empty spot.
+        * See {@link #replaceChild(int, ITmfFilterTreeNode)} to replace a node.</p>
+        *
+        * @return The removed node.
+        */
+       public ITmfFilterTreeNode remove();
+
+       /**
+        * <h4>Remove the child from the current node</h4>
+        *
+        * <p>Shifts all nodes after the removed one to prevent having an empty spot.
+        * See {@link #replaceChild(int, ITmfFilterTreeNode)} to replace a node.</p>
+        *
+        * @param node the parent node
+        *
+        * @return The removed node.
+        */
+       public ITmfFilterTreeNode removeChild(ITmfFilterTreeNode node);
+
+       /**
+        * <h4>Append a node to the current children</h4>
+        *
+        * @param node Node to append.
+        * @return Index of added node (-1 if the node cannot be added).
+        */
+       public int addChild(ITmfFilterTreeNode node);
+
+       /**
+        * <h4>Replace a child node</h4>
+        *
+        * @param index Index of the node to replace.
+        * @param node Node who will replace.
+        * @return Node replaced.
+        */
+       public ITmfFilterTreeNode replaceChild(int index, ITmfFilterTreeNode node);
+
+       /**
+        * <h4>Sets the parent of current node</h4>
+        *
+        * @param parent The parent of current node.
+        */
+       public void setParent(ITmfFilterTreeNode parent);
+
+       /**
+        * <h4>Gets the list of valid children node names that could be added to the node</h4>
+        *
+        * @return The list of valid children node names.
+        */
+       public List<String> getValidChildren();
+
+       /**
+        * @return a clone of the node
+        */
+       public ITmfFilterTreeNode clone();
+
+}
index 71559a555baf124646338907ef3ba18ab1735437..158999f43749a430755d6ff287f1370f71e5c70c 100644 (file)
@@ -1,90 +1,90 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-\r
-/**\r
- * Filter node for the 'and' operation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterAndNode extends TmfFilterTreeNode {\r
-\r
-       public static final String NODE_NAME = "AND"; //$NON-NLS-1$\r
-       public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
-\r
-       private boolean fNot = false;\r
-\r
-       /**\r
-        * @param parent the parent node\r
-        */\r
-       public TmfFilterAndNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       /**\r
-        * @return the NOT state\r
-        */\r
-       public boolean isNot() {\r
-               return fNot;\r
-       }\r
-\r
-       /**\r
-        * @param not the NOT state\r
-        */\r
-       public void setNot(boolean not) {\r
-               this.fNot = not;\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-               for (ITmfFilterTreeNode node : getChildren()) {\r
-                       if (! node.matches(event)) {\r
-                               return false ^ fNot;\r
-                       }\r
-               }\r
-               return true ^ fNot;\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               StringBuffer buf = new StringBuffer();\r
-               if (fNot) {\r
-                       buf.append("not "); //$NON-NLS-1$\r
-               }\r
-               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
-                       buf.append("( "); //$NON-NLS-1$\r
-               }\r
-               for (int i = 0; i < getChildrenCount(); i++) {\r
-                       ITmfFilterTreeNode node = getChildren()[i];\r
-                       buf.append(node.toString());\r
-                       if (i < getChildrenCount() - 1) {\r
-                               buf.append(" and "); //$NON-NLS-1$\r
-                       }\r
-               }\r
-               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
-                       buf.append(" )"); //$NON-NLS-1$\r
-               }\r
-               return buf.toString();\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+
+/**
+ * Filter node for the 'and' operation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterAndNode extends TmfFilterTreeNode {
+
+       public static final String NODE_NAME = "AND"; //$NON-NLS-1$
+       public static final String NOT_ATTR = "not"; //$NON-NLS-1$
+
+       private boolean fNot = false;
+
+       /**
+        * @param parent the parent node
+        */
+       public TmfFilterAndNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       /**
+        * @return the NOT state
+        */
+       public boolean isNot() {
+               return fNot;
+       }
+
+       /**
+        * @param not the NOT state
+        */
+       public void setNot(boolean not) {
+               this.fNot = not;
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+               for (ITmfFilterTreeNode node : getChildren()) {
+                       if (! node.matches(event)) {
+                               return false ^ fNot;
+                       }
+               }
+               return true ^ fNot;
+       }
+
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer();
+               if (fNot) {
+                       buf.append("not "); //$NON-NLS-1$
+               }
+               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
+                       buf.append("( "); //$NON-NLS-1$
+               }
+               for (int i = 0; i < getChildrenCount(); i++) {
+                       ITmfFilterTreeNode node = getChildren()[i];
+                       buf.append(node.toString());
+                       if (i < getChildrenCount() - 1) {
+                               buf.append(" and "); //$NON-NLS-1$
+                       }
+               }
+               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
+                       buf.append(" )"); //$NON-NLS-1$
+               }
+               return buf.toString();
+       }
+
+}
index 9a30f982c91afcbe1869cca77ba07023b3aff70a..e7fc83784df8c0c63092dbf1db1127a69d82ac76 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.text.NumberFormat;\r
-import java.text.ParseException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-\r
-\r
-/**\r
- * Filter node for the comparison operation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterCompareNode extends TmfFilterTreeNode {\r
-\r
-    public static final String NODE_NAME = "COMPARE"; //$NON-NLS-1$\r
-       public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
-       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
-       public static final String RESULT_ATTR = "result"; //$NON-NLS-1$\r
-       public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
-       public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
-\r
-       /**\r
-        * Supported comparison types\r
-        */\r
-       public static enum Type {\r
-               NUM,\r
-               ALPHA,\r
-               TIMESTAMP\r
-       }\r
-\r
-       private boolean fNot = false;\r
-       private String fField;\r
-       private int fResult;\r
-       private Type fType = Type.NUM;\r
-       private String fValue;\r
-       private Number fValueNumber;\r
-       private TmfTimestamp fValueTimestamp;\r
-\r
-       /**\r
-        * @param parent the parent node\r
-        */\r
-       public TmfFilterCompareNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       /**\r
-        * @return the NOT state\r
-        */\r
-       public boolean isNot() {\r
-               return fNot;\r
-       }\r
-\r
-    /**\r
-     * @param not the NOT state\r
-     */\r
-       public void setNot(boolean not) {\r
-               this.fNot = not;\r
-       }\r
-\r
-       /**\r
-        * @return the field name\r
-        */\r
-       public String getField() {\r
-               return fField;\r
-       }\r
-\r
-       /**\r
-        * @param field the field name\r
-        */\r
-       public void setField(String field) {\r
-               this.fField = field;\r
-       }\r
-\r
-       /**\r
-        * @return the compare result\r
-        */\r
-       public int getResult() {\r
-               return fResult;\r
-       }\r
-\r
-       /**\r
-        * @param result the compare result\r
-        */\r
-       public void setResult(int result) {\r
-               this.fResult = result;\r
-       }\r
-\r
-       /**\r
-        * @return the comparison type\r
-        */\r
-       public Type getType() {\r
-               return fType;\r
-       }\r
-\r
-       /**\r
-        * @param type the comparison type\r
-        */\r
-       public void setType(Type type) {\r
-               this.fType = type;\r
-               setValue(fValue);\r
-       }\r
-\r
-       /**\r
-        * @return the comparison value\r
-        */\r
-       public String getValue() {\r
-               return fValue;\r
-       }\r
-\r
-       /**\r
-        * @param value the comparison value\r
-        */\r
-       public void setValue(String value) {\r
-               this.fValue = value;\r
-               fValueNumber = null;\r
-               fValueTimestamp = null;\r
-               if (value == null) {\r
-                       return;\r
-               }\r
-               if (fType == Type.NUM) {\r
-                       try {\r
-                               fValueNumber = NumberFormat.getInstance().parse(value).doubleValue();\r
-                       } catch (ParseException e) {\r
-                       }\r
-               } else if (fType == Type.TIMESTAMP) {\r
-                       try {\r
-                               fValueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat.getInstance().parse(value.toString()).doubleValue()));\r
-                       } catch (ParseException e) {\r
-                       }\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-        Object value = getFieldValue(event, fField);\r
-        if (value == null) {\r
-            return false ^ fNot;\r
-        }\r
-        if (fType == Type.NUM) {\r
-            if (fValueNumber != null) {\r
-                if (value instanceof Number) {\r
-                    Double valueDouble = ((Number) value).doubleValue();\r
-                    return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot;\r
-                }\r
-                try {\r
-                    Double valueDouble = NumberFormat.getInstance().parse(value.toString())\r
-                                    .doubleValue();\r
-                    return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult)\r
-                                    ^ fNot;\r
-                } catch (ParseException e) {\r
-                }\r
-            }\r
-        } else if (fType == Type.ALPHA) {\r
-            String valueString = value.toString();\r
-            int comp = valueString.compareTo(fValue.toString());\r
-            if (comp < -1) {\r
-                comp = -1;\r
-            } else if (comp > 1) {\r
-                comp = 1;\r
-            }\r
-            return (comp == fResult) ^ fNot;\r
-        } else if (fType == Type.TIMESTAMP) {\r
-            if (fValueTimestamp != null) {\r
-                if (value instanceof TmfTimestamp) {\r
-                    TmfTimestamp valueTimestamp = (TmfTimestamp) value;\r
-                    return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
-                }\r
-                try {\r
-                    TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat\r
-                                    .getInstance().parse(value.toString()).doubleValue()));\r
-                    return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
-                } catch (ParseException e) {\r
-                }\r
-            }\r
-        }\r
-        return false ^ fNot;\r
-       }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               return new ArrayList<String>(0);\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               String result = (fResult == 0 ? "= " : fResult < 0 ? "< " : "> "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-               String open = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "["); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-               String close = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-               return fField + (fNot ? " not " : " ") + result + open + fValue + close; //$NON-NLS-1$ //$NON-NLS-2$\r
-       }\r
-\r
-       @Override\r
-       public ITmfFilterTreeNode clone() {\r
-               TmfFilterCompareNode clone = (TmfFilterCompareNode) super.clone();\r
-               clone.fField = fField;\r
-               clone.setValue(fValue);\r
-               return clone;\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+
+
+/**
+ * Filter node for the comparison operation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterCompareNode extends TmfFilterTreeNode {
+
+    public static final String NODE_NAME = "COMPARE"; //$NON-NLS-1$
+       public static final String NOT_ATTR = "not"; //$NON-NLS-1$
+       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$
+       public static final String RESULT_ATTR = "result"; //$NON-NLS-1$
+       public static final String TYPE_ATTR = "type"; //$NON-NLS-1$
+       public static final String VALUE_ATTR = "value"; //$NON-NLS-1$
+
+       /**
+        * Supported comparison types
+        */
+       public static enum Type {
+               NUM,
+               ALPHA,
+               TIMESTAMP
+       }
+
+       private boolean fNot = false;
+       private String fField;
+       private int fResult;
+       private Type fType = Type.NUM;
+       private String fValue;
+       private Number fValueNumber;
+       private TmfTimestamp fValueTimestamp;
+
+       /**
+        * @param parent the parent node
+        */
+       public TmfFilterCompareNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       /**
+        * @return the NOT state
+        */
+       public boolean isNot() {
+               return fNot;
+       }
+
+    /**
+     * @param not the NOT state
+     */
+       public void setNot(boolean not) {
+               this.fNot = not;
+       }
+
+       /**
+        * @return the field name
+        */
+       public String getField() {
+               return fField;
+       }
+
+       /**
+        * @param field the field name
+        */
+       public void setField(String field) {
+               this.fField = field;
+       }
+
+       /**
+        * @return the compare result
+        */
+       public int getResult() {
+               return fResult;
+       }
+
+       /**
+        * @param result the compare result
+        */
+       public void setResult(int result) {
+               this.fResult = result;
+       }
+
+       /**
+        * @return the comparison type
+        */
+       public Type getType() {
+               return fType;
+       }
+
+       /**
+        * @param type the comparison type
+        */
+       public void setType(Type type) {
+               this.fType = type;
+               setValue(fValue);
+       }
+
+       /**
+        * @return the comparison value
+        */
+       public String getValue() {
+               return fValue;
+       }
+
+       /**
+        * @param value the comparison value
+        */
+       public void setValue(String value) {
+               this.fValue = value;
+               fValueNumber = null;
+               fValueTimestamp = null;
+               if (value == null) {
+                       return;
+               }
+               if (fType == Type.NUM) {
+                       try {
+                               fValueNumber = NumberFormat.getInstance().parse(value).doubleValue();
+                       } catch (ParseException e) {
+                       }
+               } else if (fType == Type.TIMESTAMP) {
+                       try {
+                               fValueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat.getInstance().parse(value.toString()).doubleValue()));
+                       } catch (ParseException e) {
+                       }
+               }
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+        Object value = getFieldValue(event, fField);
+        if (value == null) {
+            return false ^ fNot;
+        }
+        if (fType == Type.NUM) {
+            if (fValueNumber != null) {
+                if (value instanceof Number) {
+                    Double valueDouble = ((Number) value).doubleValue();
+                    return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot;
+                }
+                try {
+                    Double valueDouble = NumberFormat.getInstance().parse(value.toString())
+                                    .doubleValue();
+                    return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult)
+                                    ^ fNot;
+                } catch (ParseException e) {
+                }
+            }
+        } else if (fType == Type.ALPHA) {
+            String valueString = value.toString();
+            int comp = valueString.compareTo(fValue.toString());
+            if (comp < -1) {
+                comp = -1;
+            } else if (comp > 1) {
+                comp = 1;
+            }
+            return (comp == fResult) ^ fNot;
+        } else if (fType == Type.TIMESTAMP) {
+            if (fValueTimestamp != null) {
+                if (value instanceof TmfTimestamp) {
+                    TmfTimestamp valueTimestamp = (TmfTimestamp) value;
+                    return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;
+                }
+                try {
+                    TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat
+                                    .getInstance().parse(value.toString()).doubleValue()));
+                    return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;
+                } catch (ParseException e) {
+                }
+            }
+        }
+        return false ^ fNot;
+       }
+
+       @Override
+       public List<String> getValidChildren() {
+               return new ArrayList<String>(0);
+       }
+
+       @Override
+       public String toString() {
+               String result = (fResult == 0 ? "= " : fResult < 0 ? "< " : "> "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               String open = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "["); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               String close = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               return fField + (fNot ? " not " : " ") + result + open + fValue + close; //$NON-NLS-1$ //$NON-NLS-2$
+       }
+
+       @Override
+       public ITmfFilterTreeNode clone() {
+               TmfFilterCompareNode clone = (TmfFilterCompareNode) super.clone();
+               clone.fField = fField;
+               clone.setValue(fValue);
+               return clone;
+       }
+}
index a00af6f4ec7db3ecd8ff86f58f5e73ae530b23c2..97410f98f34bf8d107f4f259d7baa75c8fc799de 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * Filter node for the 'contains' operation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterContainsNode extends TmfFilterTreeNode {\r
-\r
-       public static final String NODE_NAME = "CONTAINS"; //$NON-NLS-1$\r
-    public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
-       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
-       public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
-       public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$\r
-\r
-       private boolean fNot = false;\r
-       private String fField;\r
-       private String fValue;\r
-       private String fValueUpperCase;\r
-       private boolean fIgnoreCase = false;\r
-\r
-       /**\r
-        * @param parent the parent node\r
-        */\r
-       public TmfFilterContainsNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       /**\r
-        * @return the NOT state\r
-        */\r
-       public boolean isNot() {\r
-               return fNot;\r
-       }\r
-\r
-       /**\r
-        * @param not the NOT state\r
-        */\r
-       public void setNot(boolean not) {\r
-               this.fNot = not;\r
-       }\r
-\r
-       /**\r
-        * @return the field name\r
-        */\r
-       public String getField() {\r
-               return fField;\r
-       }\r
-\r
-       /**\r
-        * @param field the field name\r
-        */\r
-       public void setField(String field) {\r
-               this.fField = field;\r
-       }\r
-\r
-       /**\r
-        * @return the contains value\r
-        */\r
-       public String getValue() {\r
-               return fValue;\r
-       }\r
-\r
-       /**\r
-        * @param value the contains value\r
-        */\r
-       public void setValue(String value) {\r
-               this.fValue = value;\r
-               fValueUpperCase = value.toUpperCase();\r
-       }\r
-\r
-       /**\r
-        * @return the ignoreCase state\r
-        */\r
-       public boolean isIgnoreCase() {\r
-               return fIgnoreCase;\r
-       }\r
-\r
-       /**\r
-        * @param ignoreCase the ignoreCase state\r
-        */\r
-       public void setIgnoreCase(boolean ignoreCase) {\r
-               this.fIgnoreCase = ignoreCase;\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-        Object value = getFieldValue(event, fField);\r
-        if (value == null) {\r
-            return false ^ fNot;\r
-        }\r
-        String valueString = value.toString();\r
-        if (fIgnoreCase) {\r
-            return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot;\r
-        }\r
-        return valueString.contains(fValue) ^ fNot;\r
-       }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               return new ArrayList<String>(0);\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$\r
-       }\r
-\r
-       @Override\r
-       public ITmfFilterTreeNode clone() {\r
-               TmfFilterContainsNode clone = (TmfFilterContainsNode) super.clone();\r
-               clone.fField = fField;\r
-               clone.setValue(fValue);\r
-               return clone;\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Filter node for the 'contains' operation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterContainsNode extends TmfFilterTreeNode {
+
+       public static final String NODE_NAME = "CONTAINS"; //$NON-NLS-1$
+    public static final String NOT_ATTR = "not"; //$NON-NLS-1$
+       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$
+       public static final String VALUE_ATTR = "value"; //$NON-NLS-1$
+       public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$
+
+       private boolean fNot = false;
+       private String fField;
+       private String fValue;
+       private String fValueUpperCase;
+       private boolean fIgnoreCase = false;
+
+       /**
+        * @param parent the parent node
+        */
+       public TmfFilterContainsNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       /**
+        * @return the NOT state
+        */
+       public boolean isNot() {
+               return fNot;
+       }
+
+       /**
+        * @param not the NOT state
+        */
+       public void setNot(boolean not) {
+               this.fNot = not;
+       }
+
+       /**
+        * @return the field name
+        */
+       public String getField() {
+               return fField;
+       }
+
+       /**
+        * @param field the field name
+        */
+       public void setField(String field) {
+               this.fField = field;
+       }
+
+       /**
+        * @return the contains value
+        */
+       public String getValue() {
+               return fValue;
+       }
+
+       /**
+        * @param value the contains value
+        */
+       public void setValue(String value) {
+               this.fValue = value;
+               fValueUpperCase = value.toUpperCase();
+       }
+
+       /**
+        * @return the ignoreCase state
+        */
+       public boolean isIgnoreCase() {
+               return fIgnoreCase;
+       }
+
+       /**
+        * @param ignoreCase the ignoreCase state
+        */
+       public void setIgnoreCase(boolean ignoreCase) {
+               this.fIgnoreCase = ignoreCase;
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+        Object value = getFieldValue(event, fField);
+        if (value == null) {
+            return false ^ fNot;
+        }
+        String valueString = value.toString();
+        if (fIgnoreCase) {
+            return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot;
+        }
+        return valueString.contains(fValue) ^ fNot;
+       }
+
+       @Override
+       public List<String> getValidChildren() {
+               return new ArrayList<String>(0);
+       }
+
+       @Override
+       public String toString() {
+               return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       }
+
+       @Override
+       public ITmfFilterTreeNode clone() {
+               TmfFilterContainsNode clone = (TmfFilterContainsNode) super.clone();
+               clone.fField = fField;
+               clone.setValue(fValue);
+               return clone;
+       }
+}
index 8c54f04f569012982201ef45d0e232775ab4d14e..9bd3efda64dd02e88624f9bd9c583ff20785a63f 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-\r
-/**\r
- * Filter node for the '==' operation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterEqualsNode extends TmfFilterTreeNode {\r
-\r
-    public static final String NODE_NAME = "EQUALS"; //$NON-NLS-1$\r
-       public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
-       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
-       public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
-       public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$\r
-\r
-       private boolean fNot = false;\r
-       private String fField;\r
-       private String fValue;\r
-       private boolean fIgnoreCase = false;\r
-\r
-       /**\r
-        * @param parent the aprent node\r
-        */\r
-       public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       /**\r
-        * @return the NOT state\r
-        */\r
-       public boolean isNot() {\r
-               return fNot;\r
-       }\r
-\r
-       /**\r
-        * @param not the NOT state\r
-        */\r
-       public void setNot(boolean not) {\r
-               this.fNot = not;\r
-       }\r
-\r
-    /**\r
-     * @return the field name\r
-     */\r
-       public String getField() {\r
-               return fField;\r
-       }\r
-\r
-       /**\r
-        * @param field the field name\r
-        */\r
-       public void setField(String field) {\r
-               this.fField = field;\r
-       }\r
-\r
-       /**\r
-        * @return the equals value\r
-        */\r
-       public String getValue() {\r
-               return fValue;\r
-       }\r
-\r
-       /**\r
-        * @param value the equals value\r
-        */\r
-       public void setValue(String value) {\r
-               this.fValue = value;\r
-       }\r
-\r
-       /**\r
-        * @return the ignoreCase state\r
-        */\r
-       public boolean isIgnoreCase() {\r
-               return fIgnoreCase;\r
-       }\r
-\r
-       /**\r
-        * @param ignoreCase the ignoreCase state\r
-        */\r
-       public void setIgnoreCase(boolean ignoreCase) {\r
-               this.fIgnoreCase = ignoreCase;\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-        Object value = getFieldValue(event, fField);\r
-        if (value == null) {\r
-            return false ^ fNot;\r
-        }\r
-        String valueString = value.toString();\r
-        if (valueString == null) {\r
-            return false ^ fNot;\r
-        }\r
-        if (fIgnoreCase) {\r
-            return valueString.equalsIgnoreCase(fValue) ^ fNot;\r
-        }\r
-        return valueString.equals(fValue) ^ fNot;\r
-       }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               return new ArrayList<String>(0);\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               return fField + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$\r
-       }\r
-\r
-       @Override\r
-       public ITmfFilterTreeNode clone() {\r
-               TmfFilterEqualsNode clone = (TmfFilterEqualsNode) super.clone();\r
-               clone.fField = fField;\r
-               clone.fValue = fValue;\r
-               return clone;\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+
+/**
+ * Filter node for the '==' operation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterEqualsNode extends TmfFilterTreeNode {
+
+    public static final String NODE_NAME = "EQUALS"; //$NON-NLS-1$
+       public static final String NOT_ATTR = "not"; //$NON-NLS-1$
+       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$
+       public static final String VALUE_ATTR = "value"; //$NON-NLS-1$
+       public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$
+
+       private boolean fNot = false;
+       private String fField;
+       private String fValue;
+       private boolean fIgnoreCase = false;
+
+       /**
+        * @param parent the aprent node
+        */
+       public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       /**
+        * @return the NOT state
+        */
+       public boolean isNot() {
+               return fNot;
+       }
+
+       /**
+        * @param not the NOT state
+        */
+       public void setNot(boolean not) {
+               this.fNot = not;
+       }
+
+    /**
+     * @return the field name
+     */
+       public String getField() {
+               return fField;
+       }
+
+       /**
+        * @param field the field name
+        */
+       public void setField(String field) {
+               this.fField = field;
+       }
+
+       /**
+        * @return the equals value
+        */
+       public String getValue() {
+               return fValue;
+       }
+
+       /**
+        * @param value the equals value
+        */
+       public void setValue(String value) {
+               this.fValue = value;
+       }
+
+       /**
+        * @return the ignoreCase state
+        */
+       public boolean isIgnoreCase() {
+               return fIgnoreCase;
+       }
+
+       /**
+        * @param ignoreCase the ignoreCase state
+        */
+       public void setIgnoreCase(boolean ignoreCase) {
+               this.fIgnoreCase = ignoreCase;
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+        Object value = getFieldValue(event, fField);
+        if (value == null) {
+            return false ^ fNot;
+        }
+        String valueString = value.toString();
+        if (valueString == null) {
+            return false ^ fNot;
+        }
+        if (fIgnoreCase) {
+            return valueString.equalsIgnoreCase(fValue) ^ fNot;
+        }
+        return valueString.equals(fValue) ^ fNot;
+       }
+
+       @Override
+       public List<String> getValidChildren() {
+               return new ArrayList<String>(0);
+       }
+
+       @Override
+       public String toString() {
+               return fField + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       }
+
+       @Override
+       public ITmfFilterTreeNode clone() {
+               TmfFilterEqualsNode clone = (TmfFilterEqualsNode) super.clone();
+               clone.fField = fField;
+               clone.fValue = fValue;
+               return clone;
+       }
+}
index 70137b78577a7e132c5569127e72d2575403dcb4..223abe6a88ddc05f66fc26c6bea8399f031cb131 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * Filter node for an event\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterEventTypeNode extends TmfFilterTreeNode {\r
-\r
-    public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$\r
-       public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
-       public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
-\r
-       private String fType;\r
-       private String fName;\r
-\r
-       /**\r
-        * @param parent the parent node\r
-        */\r
-       public TmfFilterEventTypeNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       /**\r
-        * @return the event type\r
-        */\r
-       public String getEventType() {\r
-               return fType;\r
-       }\r
-\r
-       /**\r
-        * @param type the event type\r
-        */\r
-       public void setEventType(String type) {\r
-               this.fType = type;\r
-       }\r
-\r
-       /**\r
-        * @return TBD\r
-        */\r
-       public String getName() {\r
-               return fName;\r
-       }\r
-\r
-       /**\r
-        * @param name TBD\r
-        */\r
-       public void setName(String name) {\r
-               this.fName = name;\r
-       }\r
-\r
-    @Override\r
-    public boolean matches(ITmfEvent event) {\r
-        boolean match = false;\r
-        if (fType.contains(":")) { //$NON-NLS-1$\r
-            // special case for custom parsers\r
-            if (fType.startsWith(event.getClass().getCanonicalName())) {\r
-                if (fType.endsWith(event.getType().getName())) {\r
-                    match = true;\r
-                }\r
-            }\r
-        } else {\r
-            if (event.getClass().getCanonicalName().equals(fType)) {\r
-                match = true;\r
-            }\r
-        }\r
-        if (match) {\r
-            // There should be at most one child\r
-            for (ITmfFilterTreeNode node : getChildren()) {\r
-                if (! node.matches(event)) {\r
-                    return false;\r
-                }\r
-            }\r
-            return true;\r
-        }\r
-        return false;\r
-    }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               if (getChildrenCount() == 0) {\r
-                       return super.getValidChildren();\r
-               }\r
-        return new ArrayList<String>(0); // only one child allowed\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               StringBuffer buf = new StringBuffer();\r
-               buf.append("EventType is " + fName); //$NON-NLS-1$\r
-               if (getChildrenCount() > 0) {\r
-                       buf.append(" and "); //$NON-NLS-1$\r
-               }\r
-               if (getChildrenCount() > 1) {\r
-                       buf.append("( "); //$NON-NLS-1$\r
-               }\r
-               for (int i = 0; i < getChildrenCount(); i++) {\r
-                       ITmfFilterTreeNode node = getChildren()[i];\r
-                       buf.append(node.toString());\r
-                       if (i < getChildrenCount() - 1) {\r
-                               buf.append(" and "); //$NON-NLS-1$\r
-                       }\r
-               }\r
-               if (getChildrenCount() > 1) {\r
-                       buf.append(" )"); //$NON-NLS-1$\r
-               }\r
-               return buf.toString();\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Filter node for an event
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterEventTypeNode extends TmfFilterTreeNode {
+
+    public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$
+       public static final String TYPE_ATTR = "type"; //$NON-NLS-1$
+       public static final String NAME_ATTR = "name"; //$NON-NLS-1$
+
+       private String fType;
+       private String fName;
+
+       /**
+        * @param parent the parent node
+        */
+       public TmfFilterEventTypeNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       /**
+        * @return the event type
+        */
+       public String getEventType() {
+               return fType;
+       }
+
+       /**
+        * @param type the event type
+        */
+       public void setEventType(String type) {
+               this.fType = type;
+       }
+
+       /**
+        * @return TBD
+        */
+       public String getName() {
+               return fName;
+       }
+
+       /**
+        * @param name TBD
+        */
+       public void setName(String name) {
+               this.fName = name;
+       }
+
+    @Override
+    public boolean matches(ITmfEvent event) {
+        boolean match = false;
+        if (fType.contains(":")) { //$NON-NLS-1$
+            // special case for custom parsers
+            if (fType.startsWith(event.getClass().getCanonicalName())) {
+                if (fType.endsWith(event.getType().getName())) {
+                    match = true;
+                }
+            }
+        } else {
+            if (event.getClass().getCanonicalName().equals(fType)) {
+                match = true;
+            }
+        }
+        if (match) {
+            // There should be at most one child
+            for (ITmfFilterTreeNode node : getChildren()) {
+                if (! node.matches(event)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+       @Override
+       public List<String> getValidChildren() {
+               if (getChildrenCount() == 0) {
+                       return super.getValidChildren();
+               }
+        return new ArrayList<String>(0); // only one child allowed
+       }
+
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer();
+               buf.append("EventType is " + fName); //$NON-NLS-1$
+               if (getChildrenCount() > 0) {
+                       buf.append(" and "); //$NON-NLS-1$
+               }
+               if (getChildrenCount() > 1) {
+                       buf.append("( "); //$NON-NLS-1$
+               }
+               for (int i = 0; i < getChildrenCount(); i++) {
+                       ITmfFilterTreeNode node = getChildren()[i];
+                       buf.append(node.toString());
+                       if (i < getChildrenCount() - 1) {
+                               buf.append(" and "); //$NON-NLS-1$
+                       }
+               }
+               if (getChildrenCount() > 1) {
+                       buf.append(" )"); //$NON-NLS-1$
+               }
+               return buf.toString();
+       }
+}
index 8d2c35c87597b8badc53cbd0f8b284f2e96fbe15..eb3d5ae48e7149e22cb5610ec24471515ec350f1 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.regex.Pattern;\r
-import java.util.regex.PatternSyntaxException;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * Filter node for the regex match\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterMatchesNode extends TmfFilterTreeNode {\r
-\r
-    public static final String NODE_NAME = "MATCHES"; //$NON-NLS-1$\r
-       public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
-       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
-       public static final String REGEX_ATTR = "regex"; //$NON-NLS-1$\r
-\r
-       private boolean fNot = false;\r
-       private String fField;\r
-       private String fRegex;\r
-       private Pattern fPattern;\r
-\r
-       /**\r
-        * @param parent the parent node\r
-        */\r
-       public TmfFilterMatchesNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       /**\r
-        * @return the NOT state\r
-        */\r
-       public boolean isNot() {\r
-               return fNot;\r
-       }\r
-\r
-       /**\r
-        * @param not the NOT state\r
-        */\r
-       public void setNot(boolean not) {\r
-               this.fNot = not;\r
-       }\r
-\r
-       /**\r
-        * @return the field name\r
-        */\r
-       public String getField() {\r
-               return fField;\r
-       }\r
-\r
-       /**\r
-        * @param field the field name\r
-        */\r
-       public void setField(String field) {\r
-               this.fField = field;\r
-       }\r
-\r
-       /**\r
-        * @return the regular expression\r
-        */\r
-       public String getRegex() {\r
-               return fRegex;\r
-       }\r
-\r
-       /**\r
-        * @param regex the regular expression\r
-        */\r
-       public void setRegex(String regex) {\r
-               this.fRegex = regex;\r
-               try {\r
-                       this.fPattern = Pattern.compile(regex);\r
-               } catch (PatternSyntaxException e) {\r
-                       this.fPattern = null;\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-        if (fPattern == null) {\r
-            return false ^ fNot;\r
-        }\r
-\r
-        Object value = getFieldValue(event, fField);\r
-        if (value == null) {\r
-            return false ^ fNot;\r
-        }\r
-        String valueString = value.toString();\r
-\r
-        return fPattern.matcher(valueString).matches() ^ fNot;\r
-       }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               return new ArrayList<String>(0);\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               return fField + (fNot ? " not" : "") + " matches \"" + fRegex + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$\r
-       }\r
-\r
-       @Override\r
-       public ITmfFilterTreeNode clone() {\r
-               TmfFilterMatchesNode clone = (TmfFilterMatchesNode) super.clone();\r
-               clone.fField = fField;\r
-               clone.setRegex(fRegex);\r
-               return clone;\r
-       }\r
-\r
-       /**\r
-        * @param pattern the rough regex pattern\r
-        * @return the compliant regex\r
-        */\r
-       public static String regexFix(String pattern) {\r
-               // if the pattern does not contain one of the expressions .* !^\r
-               // (at the beginning) $ (at the end), then a .* is added at the\r
-               // beginning and at the end of the pattern\r
-               if (!(pattern.indexOf(".*") >= 0 || pattern.charAt(0) == '^' || pattern.charAt(pattern.length() - 1) == '$')) { //$NON-NLS-1$\r
-                       pattern = ".*" + pattern + ".*"; //$NON-NLS-1$ //$NON-NLS-2$\r
-               }\r
-               return pattern;\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Filter node for the regex match
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterMatchesNode extends TmfFilterTreeNode {
+
+    public static final String NODE_NAME = "MATCHES"; //$NON-NLS-1$
+       public static final String NOT_ATTR = "not"; //$NON-NLS-1$
+       public static final String FIELD_ATTR = "field"; //$NON-NLS-1$
+       public static final String REGEX_ATTR = "regex"; //$NON-NLS-1$
+
+       private boolean fNot = false;
+       private String fField;
+       private String fRegex;
+       private Pattern fPattern;
+
+       /**
+        * @param parent the parent node
+        */
+       public TmfFilterMatchesNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       /**
+        * @return the NOT state
+        */
+       public boolean isNot() {
+               return fNot;
+       }
+
+       /**
+        * @param not the NOT state
+        */
+       public void setNot(boolean not) {
+               this.fNot = not;
+       }
+
+       /**
+        * @return the field name
+        */
+       public String getField() {
+               return fField;
+       }
+
+       /**
+        * @param field the field name
+        */
+       public void setField(String field) {
+               this.fField = field;
+       }
+
+       /**
+        * @return the regular expression
+        */
+       public String getRegex() {
+               return fRegex;
+       }
+
+       /**
+        * @param regex the regular expression
+        */
+       public void setRegex(String regex) {
+               this.fRegex = regex;
+               try {
+                       this.fPattern = Pattern.compile(regex);
+               } catch (PatternSyntaxException e) {
+                       this.fPattern = null;
+               }
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+        if (fPattern == null) {
+            return false ^ fNot;
+        }
+
+        Object value = getFieldValue(event, fField);
+        if (value == null) {
+            return false ^ fNot;
+        }
+        String valueString = value.toString();
+
+        return fPattern.matcher(valueString).matches() ^ fNot;
+       }
+
+       @Override
+       public List<String> getValidChildren() {
+               return new ArrayList<String>(0);
+       }
+
+       @Override
+       public String toString() {
+               return fField + (fNot ? " not" : "") + " matches \"" + fRegex + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       }
+
+       @Override
+       public ITmfFilterTreeNode clone() {
+               TmfFilterMatchesNode clone = (TmfFilterMatchesNode) super.clone();
+               clone.fField = fField;
+               clone.setRegex(fRegex);
+               return clone;
+       }
+
+       /**
+        * @param pattern the rough regex pattern
+        * @return the compliant regex
+        */
+       public static String regexFix(String pattern) {
+               // if the pattern does not contain one of the expressions .* !^
+               // (at the beginning) $ (at the end), then a .* is added at the
+               // beginning and at the end of the pattern
+               if (!(pattern.indexOf(".*") >= 0 || pattern.charAt(0) == '^' || pattern.charAt(pattern.length() - 1) == '$')) { //$NON-NLS-1$
+                       pattern = ".*" + pattern + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+               return pattern;
+       }
+}
index 9c610f30732c9e110714005b35e3f885fb93e761..ad08829f43a5dee868c9beb0618ef369096b3d90 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * Filter node for the event match operation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterNode extends TmfFilterTreeNode {\r
-\r
-    public static final String NODE_NAME = "FILTER"; //$NON-NLS-1$\r
-       public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
-\r
-       String fFilterName;\r
-\r
-       /**\r
-        * @param filterName the filter name\r
-        */\r
-       public TmfFilterNode(String filterName) {\r
-               super(null);\r
-               fFilterName = filterName;\r
-       }\r
-\r
-       /**\r
-        * @param parent the parent node\r
-     * @param filterName the filter name\r
-        */\r
-       public TmfFilterNode(ITmfFilterTreeNode parent, String filterName) {\r
-               super(parent);\r
-               fFilterName = filterName;\r
-       }\r
-\r
-       /**\r
-        * @return the filer name\r
-        */\r
-       public String getFilterName() {\r
-               return fFilterName;\r
-       }\r
-\r
-       /**\r
-        * @param filterName the filer name\r
-        */\r
-       public void setFilterName(String filterName) {\r
-               fFilterName = filterName;\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-               // There should be at most one child\r
-               for (ITmfFilterTreeNode node : getChildren()) {\r
-                       if (node.matches(event)) {\r
-                               return true;\r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               if (getChildrenCount() == 0) {\r
-                       return super.getValidChildren();\r
-               }\r
-        return new ArrayList<String>(0); // only one child allowed\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               StringBuffer buf = new StringBuffer();\r
-               if (getChildrenCount() > 1) {\r
-                       buf.append("( "); //$NON-NLS-1$\r
-               }\r
-               for (int i = 0; i < getChildrenCount(); i++) {\r
-                       ITmfFilterTreeNode node = getChildren()[i];\r
-                       buf.append(node.toString());\r
-                       if (i < (getChildrenCount() - 1)) {\r
-                               buf.append(" and "); //$NON-NLS-1$\r
-                       }\r
-               }\r
-               if (getChildrenCount() > 1) {\r
-                       buf.append(" )"); //$NON-NLS-1$\r
-               }\r
-               return buf.toString();\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Filter node for the event match operation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterNode extends TmfFilterTreeNode {
+
+    public static final String NODE_NAME = "FILTER"; //$NON-NLS-1$
+       public static final String NAME_ATTR = "name"; //$NON-NLS-1$
+
+       String fFilterName;
+
+       /**
+        * @param filterName the filter name
+        */
+       public TmfFilterNode(String filterName) {
+               super(null);
+               fFilterName = filterName;
+       }
+
+       /**
+        * @param parent the parent node
+     * @param filterName the filter name
+        */
+       public TmfFilterNode(ITmfFilterTreeNode parent, String filterName) {
+               super(parent);
+               fFilterName = filterName;
+       }
+
+       /**
+        * @return the filer name
+        */
+       public String getFilterName() {
+               return fFilterName;
+       }
+
+       /**
+        * @param filterName the filer name
+        */
+       public void setFilterName(String filterName) {
+               fFilterName = filterName;
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+               // There should be at most one child
+               for (ITmfFilterTreeNode node : getChildren()) {
+                       if (node.matches(event)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       @Override
+       public List<String> getValidChildren() {
+               if (getChildrenCount() == 0) {
+                       return super.getValidChildren();
+               }
+        return new ArrayList<String>(0); // only one child allowed
+       }
+
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer();
+               if (getChildrenCount() > 1) {
+                       buf.append("( "); //$NON-NLS-1$
+               }
+               for (int i = 0; i < getChildrenCount(); i++) {
+                       ITmfFilterTreeNode node = getChildren()[i];
+                       buf.append(node.toString());
+                       if (i < (getChildrenCount() - 1)) {
+                               buf.append(" and "); //$NON-NLS-1$
+                       }
+               }
+               if (getChildrenCount() > 1) {
+                       buf.append(" )"); //$NON-NLS-1$
+               }
+               return buf.toString();
+       }
+}
index fa474e1959c3322939005c33945f1222598672c3..05969daca32f8ed510dc4fc5f81398f8efb13685 100644 (file)
@@ -1,88 +1,88 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * Filter node for the 'or' operation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TmfFilterOrNode extends TmfFilterTreeNode {\r
-\r
-    public static final String NODE_NAME = "OR"; //$NON-NLS-1$\r
-       public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
-\r
-       private boolean fNot = false;\r
-\r
-       /**\r
-        * @param parent the parent node\r
-        */\r
-       public TmfFilterOrNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       /**\r
-        * @return the NOT state\r
-        */\r
-       public boolean isNot() {\r
-               return fNot;\r
-       }\r
-\r
-       /**\r
-        * @param not the NOT state\r
-        */\r
-       public void setNot(boolean not) {\r
-               this.fNot = not;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-               for (ITmfFilterTreeNode node : getChildren()) {\r
-                       if (node.matches(event)) {\r
-                               return true ^ fNot;\r
-                       }\r
-               }\r
-               return false & fNot;\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               StringBuffer buf = new StringBuffer();\r
-               if (fNot) {\r
-                       buf.append("not "); //$NON-NLS-1$\r
-               }\r
-               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
-                       buf.append("( "); //$NON-NLS-1$\r
-               }\r
-               for (int i = 0; i < getChildrenCount(); i++) {\r
-                       ITmfFilterTreeNode node = getChildren()[i];\r
-                       buf.append(node.toString());\r
-                       if (i < getChildrenCount() - 1) {\r
-                               buf.append(" or "); //$NON-NLS-1$\r
-                       }\r
-               }\r
-               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
-                       buf.append(" )"); //$NON-NLS-1$\r
-               }\r
-               return buf.toString();\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Filter node for the 'or' operation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterOrNode extends TmfFilterTreeNode {
+
+    public static final String NODE_NAME = "OR"; //$NON-NLS-1$
+       public static final String NOT_ATTR = "not"; //$NON-NLS-1$
+
+       private boolean fNot = false;
+
+       /**
+        * @param parent the parent node
+        */
+       public TmfFilterOrNode(ITmfFilterTreeNode parent) {
+               super(parent);
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       /**
+        * @return the NOT state
+        */
+       public boolean isNot() {
+               return fNot;
+       }
+
+       /**
+        * @param not the NOT state
+        */
+       public void setNot(boolean not) {
+               this.fNot = not;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+               for (ITmfFilterTreeNode node : getChildren()) {
+                       if (node.matches(event)) {
+                               return true ^ fNot;
+                       }
+               }
+               return false & fNot;
+       }
+
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer();
+               if (fNot) {
+                       buf.append("not "); //$NON-NLS-1$
+               }
+               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
+                       buf.append("( "); //$NON-NLS-1$
+               }
+               for (int i = 0; i < getChildrenCount(); i++) {
+                       ITmfFilterTreeNode node = getChildren()[i];
+                       buf.append(node.toString());
+                       if (i < getChildrenCount() - 1) {
+                               buf.append(" or "); //$NON-NLS-1$
+                       }
+               }
+               if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
+                       buf.append(" )"); //$NON-NLS-1$
+               }
+               return buf.toString();
+       }
+}
index f7f00be67a6da1f1a10f58b504948e5662f9e103..6a3cb99a7a3739099126d373a85395ddc4c4972f 100644 (file)
@@ -1,62 +1,62 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-\r
-/**\r
- * The Filter tree root node\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfFilterRootNode extends TmfFilterTreeNode {\r
-\r
-       @SuppressWarnings("javadoc")\r
-    public static final String NODE_NAME = "ROOT"; //$NON-NLS-1$\r
-\r
-       private static final String[] VALID_CHILDREN = {\r
-               TmfFilterNode.NODE_NAME\r
-       };\r
-\r
-       /**\r
-        * Default constructor\r
-        */\r
-       public TmfFilterRootNode() {\r
-               super(null);\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       @Override\r
-       public boolean matches(ITmfEvent event) {\r
-               for (ITmfFilterTreeNode node : getChildren()) {\r
-                       if (! node.matches(event)) {\r
-                               return false;\r
-                       }\r
-               }\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               return Arrays.asList(VALID_CHILDREN);\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * The Filter tree root node
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfFilterRootNode extends TmfFilterTreeNode {
+
+       @SuppressWarnings("javadoc")
+    public static final String NODE_NAME = "ROOT"; //$NON-NLS-1$
+
+       private static final String[] VALID_CHILDREN = {
+               TmfFilterNode.NODE_NAME
+       };
+
+       /**
+        * Default constructor
+        */
+       public TmfFilterRootNode() {
+               super(null);
+       }
+
+       @Override
+       public String getNodeName() {
+               return NODE_NAME;
+       }
+
+       @Override
+       public boolean matches(ITmfEvent event) {
+               for (ITmfFilterTreeNode node : getChildren()) {
+                       if (! node.matches(event)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       @Override
+       public List<String> getValidChildren() {
+               return Arrays.asList(VALID_CHILDREN);
+       }
+
+}
index d5cb9b5d5af87d26fb8dddd1a89e589d2717f51b..6f65440c8cc6d1eabb2a43d297a2454d8d2461d8 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
- *   Patrick Tasse - Refactoring\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
-\r
-/**\r
- * The base class for the Filter tree nodes\r
- *\r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- * @author Patrick Tasse\r
- */\r
-public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable {\r
-\r
-       private static final String[] VALID_CHILDREN = {\r
-               TmfFilterEventTypeNode.NODE_NAME,\r
-               TmfFilterAndNode.NODE_NAME,\r
-               TmfFilterOrNode.NODE_NAME,\r
-               TmfFilterContainsNode.NODE_NAME,\r
-               TmfFilterEqualsNode.NODE_NAME,\r
-               TmfFilterMatchesNode.NODE_NAME,\r
-               TmfFilterCompareNode.NODE_NAME\r
-       };\r
-\r
-       private ITmfFilterTreeNode parent = null;\r
-       private ArrayList<ITmfFilterTreeNode> children = new ArrayList<ITmfFilterTreeNode>();\r
-\r
-    /**\r
-     * @param parent the parent node\r
-     */\r
-    public TmfFilterTreeNode(final ITmfFilterTreeNode parent) {\r
-       if (parent != null) {\r
-               parent.addChild(this);\r
-       }\r
-    }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getParent()\r
-        */\r
-       @Override\r
-       public ITmfFilterTreeNode getParent() {\r
-               return parent;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getNodeName()\r
-        */\r
-       @Override\r
-       public abstract String getNodeName();\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#hasChildren()\r
-        */\r
-       @Override\r
-       public boolean hasChildren() {\r
-               return (children.size() > 0);\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChildrenCount()\r
-        */\r
-       @Override\r
-       public int getChildrenCount() {\r
-               return children.size();\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChildren()\r
-        */\r
-       @Override\r
-       public ITmfFilterTreeNode[] getChildren() {\r
-               return children.toArray(new ITmfFilterTreeNode[0]);\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChild(int)\r
-        */\r
-       @Override\r
-       public ITmfFilterTreeNode getChild(final int index) throws IndexOutOfBoundsException {\r
-               return children.get(index);\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#remove()\r
-        */\r
-       @Override\r
-       public ITmfFilterTreeNode remove() {\r
-               if (getParent() != null) {\r
-                       getParent().removeChild(this);\r
-               }\r
-               return this;\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#removeChild(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
-        */\r
-       @Override\r
-       public ITmfFilterTreeNode removeChild(ITmfFilterTreeNode node) {\r
-               children.remove(node);\r
-               node.setParent(null);\r
-               return node;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#addChild(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
-        */\r
-       @Override\r
-       public int addChild(final ITmfFilterTreeNode node) {\r
-               node.setParent(this);\r
-               if(children.add(node)) {\r
-                       return (children.size() - 1);\r
-               }\r
-               return -1;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#replaceChild(int, org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
-        */\r
-       @Override\r
-       public ITmfFilterTreeNode replaceChild(final int index, final ITmfFilterTreeNode node) throws IndexOutOfBoundsException {\r
-               node.setParent(this);\r
-               return children.set(index, node);\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#setParent(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
-        */\r
-       @Override\r
-       public void setParent(final ITmfFilterTreeNode parent) {\r
-               this.parent = parent;\r
-       }\r
-\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#matches(org.eclipse.linuxtools.tmf.event.TmfEvent)\r
-        */\r
-       @Override\r
-       public abstract boolean matches(ITmfEvent event);\r
-\r
-    /**\r
-     * @param event the event\r
-     * @param field the field id\r
-     * @return the field value\r
-     */\r
-    protected Object getFieldValue(ITmfEvent event, String field) {\r
-        Object value = null;\r
-        if (ITmfEvent.EVENT_FIELD_CONTENT.equals(field)) {\r
-            ITmfEventField content = event.getContent();\r
-            value = (content.getValue() != null) ? content.getValue().toString() : content.toString();\r
-        }\r
-        else if (ITmfEvent.EVENT_FIELD_TYPE.equals(field)) {\r
-            value = event.getType().getName();\r
-        }\r
-        else if (ITmfEvent.EVENT_FIELD_TIMESTAMP.equals(field)) {\r
-            value = event.getTimestamp().toString();\r
-        }\r
-        else if (ITmfEvent.EVENT_FIELD_SOURCE.equals(field)) {\r
-            value = event.getSource();\r
-        }\r
-        else if (ITmfEvent.EVENT_FIELD_REFERENCE.equals(field)) {\r
-            value = event.getReference();\r
-        }\r
-        else {\r
-            ITmfEventField eventField = event.getContent().getField(field);\r
-            if (eventField != null) {\r
-                value = eventField.getValue();\r
-            }\r
-        }\r
-        return value;\r
-    }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getValidChildren()\r
-        *\r
-        * By default, all node types are valid children. Override if different.\r
-        */\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               return Arrays.asList(VALID_CHILDREN);\r
-       }\r
-\r
-       @Override\r
-       public ITmfFilterTreeNode clone() {\r
-               try {\r
-                       TmfFilterTreeNode clone = (TmfFilterTreeNode) super.clone();\r
-                       clone.parent = null;\r
-                       clone.children = new ArrayList<ITmfFilterTreeNode>(children.size());\r
-                       for (ITmfFilterTreeNode child : getChildren()) {\r
-                               clone.addChild(child.clone());\r
-                       }\r
-                       return clone;\r
-               } catch (CloneNotSupportedException e) {\r
-                       return null;\r
-               }\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation
+ *   Patrick Tasse - Refactoring
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+
+/**
+ * The base class for the Filter tree nodes
+ *
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ * @author Patrick Tasse
+ */
+public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable {
+
+       private static final String[] VALID_CHILDREN = {
+               TmfFilterEventTypeNode.NODE_NAME,
+               TmfFilterAndNode.NODE_NAME,
+               TmfFilterOrNode.NODE_NAME,
+               TmfFilterContainsNode.NODE_NAME,
+               TmfFilterEqualsNode.NODE_NAME,
+               TmfFilterMatchesNode.NODE_NAME,
+               TmfFilterCompareNode.NODE_NAME
+       };
+
+       private ITmfFilterTreeNode parent = null;
+       private ArrayList<ITmfFilterTreeNode> children = new ArrayList<ITmfFilterTreeNode>();
+
+    /**
+     * @param parent the parent node
+     */
+    public TmfFilterTreeNode(final ITmfFilterTreeNode parent) {
+       if (parent != null) {
+               parent.addChild(this);
+       }
+    }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getParent()
+        */
+       @Override
+       public ITmfFilterTreeNode getParent() {
+               return parent;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getNodeName()
+        */
+       @Override
+       public abstract String getNodeName();
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#hasChildren()
+        */
+       @Override
+       public boolean hasChildren() {
+               return (children.size() > 0);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChildrenCount()
+        */
+       @Override
+       public int getChildrenCount() {
+               return children.size();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChildren()
+        */
+       @Override
+       public ITmfFilterTreeNode[] getChildren() {
+               return children.toArray(new ITmfFilterTreeNode[0]);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChild(int)
+        */
+       @Override
+       public ITmfFilterTreeNode getChild(final int index) throws IndexOutOfBoundsException {
+               return children.get(index);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#remove()
+        */
+       @Override
+       public ITmfFilterTreeNode remove() {
+               if (getParent() != null) {
+                       getParent().removeChild(this);
+               }
+               return this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#removeChild(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)
+        */
+       @Override
+       public ITmfFilterTreeNode removeChild(ITmfFilterTreeNode node) {
+               children.remove(node);
+               node.setParent(null);
+               return node;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#addChild(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)
+        */
+       @Override
+       public int addChild(final ITmfFilterTreeNode node) {
+               node.setParent(this);
+               if(children.add(node)) {
+                       return (children.size() - 1);
+               }
+               return -1;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#replaceChild(int, org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)
+        */
+       @Override
+       public ITmfFilterTreeNode replaceChild(final int index, final ITmfFilterTreeNode node) throws IndexOutOfBoundsException {
+               node.setParent(this);
+               return children.set(index, node);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#setParent(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)
+        */
+       @Override
+       public void setParent(final ITmfFilterTreeNode parent) {
+               this.parent = parent;
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#matches(org.eclipse.linuxtools.tmf.event.TmfEvent)
+        */
+       @Override
+       public abstract boolean matches(ITmfEvent event);
+
+    /**
+     * @param event the event
+     * @param field the field id
+     * @return the field value
+     */
+    protected Object getFieldValue(ITmfEvent event, String field) {
+        Object value = null;
+        if (ITmfEvent.EVENT_FIELD_CONTENT.equals(field)) {
+            ITmfEventField content = event.getContent();
+            value = (content.getValue() != null) ? content.getValue().toString() : content.toString();
+        }
+        else if (ITmfEvent.EVENT_FIELD_TYPE.equals(field)) {
+            value = event.getType().getName();
+        }
+        else if (ITmfEvent.EVENT_FIELD_TIMESTAMP.equals(field)) {
+            value = event.getTimestamp().toString();
+        }
+        else if (ITmfEvent.EVENT_FIELD_SOURCE.equals(field)) {
+            value = event.getSource();
+        }
+        else if (ITmfEvent.EVENT_FIELD_REFERENCE.equals(field)) {
+            value = event.getReference();
+        }
+        else {
+            ITmfEventField eventField = event.getContent().getField(field);
+            if (eventField != null) {
+                value = eventField.getValue();
+            }
+        }
+        return value;
+    }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getValidChildren()
+        *
+        * By default, all node types are valid children. Override if different.
+        */
+       @Override
+       public List<String> getValidChildren() {
+               return Arrays.asList(VALID_CHILDREN);
+       }
+
+       @Override
+       public ITmfFilterTreeNode clone() {
+               try {
+                       TmfFilterTreeNode clone = (TmfFilterTreeNode) super.clone();
+                       clone.parent = null;
+                       clone.children = new ArrayList<ITmfFilterTreeNode>(children.size());
+                       for (ITmfFilterTreeNode child : getChildren()) {
+                               clone.addChild(child.clone());
+                       }
+                       return clone;
+               } catch (CloneNotSupportedException e) {
+                       return null;
+               }
+       }
+}
index befbae1c3ab6b5cc90549d144b63260e5df5f855..5fb2298013d92558eb137a51d17738ffe05da179 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
- *       based on http://smeric.developpez.com/java/cours/xml/sax/\r
- *   Patrick Tasse - Refactoring\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.xml;\r
-\r
-import java.util.Stack;\r
-\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.helpers.DefaultHandler;\r
-\r
-/**\r
- * The SAX Content Handler\r
- * \r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- * @author Patrick Tasse\r
- */\r
-public class TmfFilterContentHandler extends DefaultHandler {\r
-       \r
-       private ITmfFilterTreeNode fRoot = null;\r
-       private Stack<ITmfFilterTreeNode> fFilterTreeStack = null;\r
-\r
-       /**\r
-        * The default constructor\r
-        */ \r
-       public TmfFilterContentHandler() {\r
-               super();\r
-               fFilterTreeStack = new Stack<ITmfFilterTreeNode>();\r
-       }\r
-\r
-       /**\r
-        * Getter of tree\r
-        * \r
-        * @return The builded tree\r
-        */ \r
-       public ITmfFilterTreeNode getTree() {\r
-               return fRoot;\r
-       }\r
-       \r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)\r
-        */\r
-       @Override\r
-       public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {\r
-               ITmfFilterTreeNode node = null;\r
-               \r
-               if (localName.equalsIgnoreCase(TmfFilterRootNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterRootNode();\r
-                       \r
-               } else if (localName.equals(TmfFilterNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterNode(atts.getValue(TmfFilterNode.NAME_ATTR));\r
-                       \r
-               } else if (localName.equals(TmfFilterEventTypeNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterEventTypeNode(null);\r
-                       ((TmfFilterEventTypeNode) node).setEventType(atts.getValue(TmfFilterEventTypeNode.TYPE_ATTR));\r
-                       ((TmfFilterEventTypeNode) node).setName(atts.getValue(TmfFilterEventTypeNode.NAME_ATTR));\r
-                       \r
-               } else if (localName.equals(TmfFilterAndNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterAndNode(null);\r
-                       String value = atts.getValue(TmfFilterAndNode.NOT_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterAndNode) node).setNot(true);\r
-                       }\r
-                       \r
-               } else if (localName.equals(TmfFilterOrNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterOrNode(null);\r
-                       String value = atts.getValue(TmfFilterOrNode.NOT_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterOrNode) node).setNot(true);\r
-                       }\r
-                       \r
-               } else if (localName.equals(TmfFilterContainsNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterContainsNode(null);\r
-                       String value = atts.getValue(TmfFilterContainsNode.NOT_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterContainsNode) node).setNot(true);\r
-                       }\r
-                       ((TmfFilterContainsNode) node).setField(atts.getValue(TmfFilterContainsNode.FIELD_ATTR));\r
-                       ((TmfFilterContainsNode) node).setValue(atts.getValue(TmfFilterContainsNode.VALUE_ATTR));\r
-                       value = atts.getValue(TmfFilterContainsNode.IGNORECASE_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterContainsNode) node).setIgnoreCase(true);\r
-                       }\r
-                       \r
-               } else if (localName.equals(TmfFilterEqualsNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterEqualsNode(null);\r
-                       String value = atts.getValue(TmfFilterEqualsNode.NOT_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterEqualsNode) node).setNot(true);\r
-                       }\r
-                       ((TmfFilterEqualsNode) node).setField(atts.getValue(TmfFilterEqualsNode.FIELD_ATTR));\r
-                       ((TmfFilterEqualsNode) node).setValue(atts.getValue(TmfFilterEqualsNode.VALUE_ATTR));\r
-                       value = atts.getValue(TmfFilterEqualsNode.IGNORECASE_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterEqualsNode) node).setIgnoreCase(true);\r
-                       }\r
-                       \r
-               } else if (localName.equals(TmfFilterMatchesNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterMatchesNode(null);\r
-                       String value = atts.getValue(TmfFilterMatchesNode.NOT_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterMatchesNode) node).setNot(true);\r
-                       }\r
-                       ((TmfFilterMatchesNode) node).setField(atts.getValue(TmfFilterMatchesNode.FIELD_ATTR));\r
-                       ((TmfFilterMatchesNode) node).setRegex(atts.getValue(TmfFilterMatchesNode.REGEX_ATTR));\r
-                       \r
-               } else if (localName.equals(TmfFilterCompareNode.NODE_NAME)) {\r
-                       \r
-                       node = new TmfFilterCompareNode(null);\r
-                       String value = atts.getValue(TmfFilterCompareNode.NOT_ATTR);\r
-                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
-                               ((TmfFilterCompareNode) node).setNot(true);\r
-                       }\r
-                       ((TmfFilterCompareNode) node).setField(atts.getValue(TmfFilterCompareNode.FIELD_ATTR));\r
-                       value = atts.getValue(TmfFilterCompareNode.TYPE_ATTR);\r
-                       if (value != null) {\r
-                               ((TmfFilterCompareNode) node).setType(Type.valueOf(value));\r
-                       }\r
-                       value = atts.getValue(TmfFilterCompareNode.RESULT_ATTR);\r
-                       if (value != null) {\r
-                               if (value.equals(Integer.toString(-1))) {\r
-                                       ((TmfFilterCompareNode) node).setResult(-1);\r
-                               } else if (value.equals(Integer.toString(1))) {\r
-                                       ((TmfFilterCompareNode) node).setResult(1);\r
-                               } else {\r
-                                       ((TmfFilterCompareNode) node).setResult(0);\r
-                               }\r
-                       }\r
-                       ((TmfFilterCompareNode) node).setValue(atts.getValue(TmfFilterCompareNode.VALUE_ATTR));\r
-                       \r
-               }\r
-\r
-               fFilterTreeStack.push(node);\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)\r
-        */\r
-       @Override\r
-       public void endElement(String uri, String localName, String qName) throws SAXException {\r
-               ITmfFilterTreeNode node = fFilterTreeStack.pop();\r
-\r
-               if (fFilterTreeStack.isEmpty()) {\r
-                       fRoot = node;\r
-               } else if (fFilterTreeStack.lastElement() instanceof TmfFilterTreeNode &&\r
-                               node instanceof TmfFilterTreeNode) {\r
-                       fFilterTreeStack.lastElement().addChild(node);\r
-               }\r
-                       \r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation
+ *       based on http://smeric.developpez.com/java/cours/xml/sax/
+ *   Patrick Tasse - Refactoring
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.xml;
+
+import java.util.Stack;
+
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * The SAX Content Handler
+ * 
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ * @author Patrick Tasse
+ */
+public class TmfFilterContentHandler extends DefaultHandler {
+       
+       private ITmfFilterTreeNode fRoot = null;
+       private Stack<ITmfFilterTreeNode> fFilterTreeStack = null;
+
+       /**
+        * The default constructor
+        */ 
+       public TmfFilterContentHandler() {
+               super();
+               fFilterTreeStack = new Stack<ITmfFilterTreeNode>();
+       }
+
+       /**
+        * Getter of tree
+        * 
+        * @return The builded tree
+        */ 
+       public ITmfFilterTreeNode getTree() {
+               return fRoot;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+        */
+       @Override
+       public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+               ITmfFilterTreeNode node = null;
+               
+               if (localName.equalsIgnoreCase(TmfFilterRootNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterRootNode();
+                       
+               } else if (localName.equals(TmfFilterNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterNode(atts.getValue(TmfFilterNode.NAME_ATTR));
+                       
+               } else if (localName.equals(TmfFilterEventTypeNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterEventTypeNode(null);
+                       ((TmfFilterEventTypeNode) node).setEventType(atts.getValue(TmfFilterEventTypeNode.TYPE_ATTR));
+                       ((TmfFilterEventTypeNode) node).setName(atts.getValue(TmfFilterEventTypeNode.NAME_ATTR));
+                       
+               } else if (localName.equals(TmfFilterAndNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterAndNode(null);
+                       String value = atts.getValue(TmfFilterAndNode.NOT_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterAndNode) node).setNot(true);
+                       }
+                       
+               } else if (localName.equals(TmfFilterOrNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterOrNode(null);
+                       String value = atts.getValue(TmfFilterOrNode.NOT_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterOrNode) node).setNot(true);
+                       }
+                       
+               } else if (localName.equals(TmfFilterContainsNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterContainsNode(null);
+                       String value = atts.getValue(TmfFilterContainsNode.NOT_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterContainsNode) node).setNot(true);
+                       }
+                       ((TmfFilterContainsNode) node).setField(atts.getValue(TmfFilterContainsNode.FIELD_ATTR));
+                       ((TmfFilterContainsNode) node).setValue(atts.getValue(TmfFilterContainsNode.VALUE_ATTR));
+                       value = atts.getValue(TmfFilterContainsNode.IGNORECASE_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterContainsNode) node).setIgnoreCase(true);
+                       }
+                       
+               } else if (localName.equals(TmfFilterEqualsNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterEqualsNode(null);
+                       String value = atts.getValue(TmfFilterEqualsNode.NOT_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterEqualsNode) node).setNot(true);
+                       }
+                       ((TmfFilterEqualsNode) node).setField(atts.getValue(TmfFilterEqualsNode.FIELD_ATTR));
+                       ((TmfFilterEqualsNode) node).setValue(atts.getValue(TmfFilterEqualsNode.VALUE_ATTR));
+                       value = atts.getValue(TmfFilterEqualsNode.IGNORECASE_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterEqualsNode) node).setIgnoreCase(true);
+                       }
+                       
+               } else if (localName.equals(TmfFilterMatchesNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterMatchesNode(null);
+                       String value = atts.getValue(TmfFilterMatchesNode.NOT_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterMatchesNode) node).setNot(true);
+                       }
+                       ((TmfFilterMatchesNode) node).setField(atts.getValue(TmfFilterMatchesNode.FIELD_ATTR));
+                       ((TmfFilterMatchesNode) node).setRegex(atts.getValue(TmfFilterMatchesNode.REGEX_ATTR));
+                       
+               } else if (localName.equals(TmfFilterCompareNode.NODE_NAME)) {
+                       
+                       node = new TmfFilterCompareNode(null);
+                       String value = atts.getValue(TmfFilterCompareNode.NOT_ATTR);
+                       if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {
+                               ((TmfFilterCompareNode) node).setNot(true);
+                       }
+                       ((TmfFilterCompareNode) node).setField(atts.getValue(TmfFilterCompareNode.FIELD_ATTR));
+                       value = atts.getValue(TmfFilterCompareNode.TYPE_ATTR);
+                       if (value != null) {
+                               ((TmfFilterCompareNode) node).setType(Type.valueOf(value));
+                       }
+                       value = atts.getValue(TmfFilterCompareNode.RESULT_ATTR);
+                       if (value != null) {
+                               if (value.equals(Integer.toString(-1))) {
+                                       ((TmfFilterCompareNode) node).setResult(-1);
+                               } else if (value.equals(Integer.toString(1))) {
+                                       ((TmfFilterCompareNode) node).setResult(1);
+                               } else {
+                                       ((TmfFilterCompareNode) node).setResult(0);
+                               }
+                       }
+                       ((TmfFilterCompareNode) node).setValue(atts.getValue(TmfFilterCompareNode.VALUE_ATTR));
+                       
+               }
+
+               fFilterTreeStack.push(node);
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+        */
+       @Override
+       public void endElement(String uri, String localName, String qName) throws SAXException {
+               ITmfFilterTreeNode node = fFilterTreeStack.pop();
+
+               if (fFilterTreeStack.isEmpty()) {
+                       fRoot = node;
+               } else if (fFilterTreeStack.lastElement() instanceof TmfFilterTreeNode &&
+                               node instanceof TmfFilterTreeNode) {
+                       fFilterTreeStack.lastElement().addChild(node);
+               }
+                       
+       }
+
+}
index e5befebc189596b604a1141c8fbf91af0075e1c3..e1c6d6990da54da1a53c910921fc56ad092f7b9e 100644 (file)
@@ -1,70 +1,70 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.xml;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.xml.parsers.ParserConfigurationException;\r
-import javax.xml.parsers.SAXParserFactory;\r
-\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.XMLReader;\r
-\r
-/**\r
- * The SAX based XML parser\r
- *\r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- * @author Patrick Tasse\r
- */\r
-public class TmfFilterXMLParser {\r
-\r
-    private static ITmfFilterTreeNode fRoot = null;\r
-\r
-    /**\r
-     * The XMLParser constructor\r
-     *\r
-     * @param uri The XML file to parse\r
-     * @throws SAXException  SAX exception\r
-     * @throws IOException  IO exception\r
-     */\r
-    public TmfFilterXMLParser(final String uri) throws SAXException, IOException {\r
-\r
-        SAXParserFactory m_parserFactory = null;\r
-        m_parserFactory = SAXParserFactory.newInstance();\r
-        m_parserFactory.setNamespaceAware(true);\r
-\r
-        XMLReader saxReader = null;\r
-        try {\r
-\r
-            saxReader = m_parserFactory.newSAXParser().getXMLReader();\r
-            saxReader.setContentHandler(new TmfFilterContentHandler());\r
-            saxReader.parse(uri);\r
-\r
-            fRoot = ((TmfFilterContentHandler) saxReader.getContentHandler()).getTree();\r
-\r
-        } catch (ParserConfigurationException e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Getter of tree\r
-     *\r
-     * @return The builded tree\r
-     */\r
-    public ITmfFilterTreeNode getTree() {\r
-        return fRoot;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.xml;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * The SAX based XML parser
+ *
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ * @author Patrick Tasse
+ */
+public class TmfFilterXMLParser {
+
+    private static ITmfFilterTreeNode fRoot = null;
+
+    /**
+     * The XMLParser constructor
+     *
+     * @param uri The XML file to parse
+     * @throws SAXException  SAX exception
+     * @throws IOException  IO exception
+     */
+    public TmfFilterXMLParser(final String uri) throws SAXException, IOException {
+
+        SAXParserFactory m_parserFactory = null;
+        m_parserFactory = SAXParserFactory.newInstance();
+        m_parserFactory.setNamespaceAware(true);
+
+        XMLReader saxReader = null;
+        try {
+
+            saxReader = m_parserFactory.newSAXParser().getXMLReader();
+            saxReader.setContentHandler(new TmfFilterContentHandler());
+            saxReader.parse(uri);
+
+            fRoot = ((TmfFilterContentHandler) saxReader.getContentHandler()).getTree();
+
+        } catch (ParserConfigurationException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Getter of tree
+     *
+     * @return The builded tree
+     */
+    public ITmfFilterTreeNode getTree() {
+        return fRoot;
+    }
+}
index 5a5fca5db0cc57b120ba3fe15eb2ec7bbc15fdd3..264a96082e91049c0ddab3893909d2e97a3f4fbe 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.xml;\r
-\r
-import java.io.File;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerConfigurationException;\r
-import javax.xml.transform.TransformerException;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-\r
-/**\r
- * The SAX based XML writer\r
- *\r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- * @author Patrick Tasse\r
- */\r
-public class TmfFilterXMLWriter {\r
-\r
-       private Document document = null;\r
-\r
-       /**\r
-        * The XMLParser constructor\r
-        *\r
-     * @param root The tree root\r
-        * @throws ParserConfigurationException if a DocumentBuilder\r
-     *   cannot be created which satisfies the configuration requested.\r
-        */\r
-       public TmfFilterXMLWriter(final ITmfFilterTreeNode root) throws ParserConfigurationException {\r
-               DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();\r
-               DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();\r
-               document = documentBuilder.newDocument();\r
-\r
-               Element rootElement = document.createElement(root.getNodeName());\r
-               document.appendChild(rootElement);\r
-\r
-               for (ITmfFilterTreeNode node : root.getChildren()) {\r
-                       buildXMLTree(document, node, rootElement);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * The Tree to XML parser\r
-        *\r
-        * @param document The XML document\r
-        * @param treenode The node to write\r
-        * @param parentElement The XML element of the parent\r
-        */\r
-       public static void buildXMLTree(final Document document, final ITmfFilterTreeNode treenode, Element parentElement) {\r
-               Element element = document.createElement(treenode.getNodeName());\r
-\r
-               if (treenode instanceof TmfFilterNode) {\r
-\r
-                       TmfFilterNode node = (TmfFilterNode) treenode;\r
-                       element.setAttribute(TmfFilterNode.NAME_ATTR, node.getFilterName());\r
-\r
-               } else if (treenode instanceof TmfFilterEventTypeNode) {\r
-\r
-                       TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) treenode;\r
-                       element.setAttribute(TmfFilterEventTypeNode.TYPE_ATTR, node.getEventType());\r
-                       element.setAttribute(TmfFilterEventTypeNode.NAME_ATTR, node.getName());\r
-\r
-               } else if (treenode instanceof TmfFilterAndNode) {\r
-\r
-                       TmfFilterAndNode node = (TmfFilterAndNode) treenode;\r
-                       element.setAttribute(TmfFilterAndNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
-\r
-               } else if (treenode instanceof TmfFilterOrNode) {\r
-\r
-                       TmfFilterOrNode node = (TmfFilterOrNode) treenode;\r
-                       element.setAttribute(TmfFilterOrNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
-\r
-               } else if (treenode instanceof TmfFilterContainsNode) {\r
-\r
-                       TmfFilterContainsNode node = (TmfFilterContainsNode) treenode;\r
-                       element.setAttribute(TmfFilterContainsNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
-                       element.setAttribute(TmfFilterContainsNode.FIELD_ATTR, node.getField());\r
-                       element.setAttribute(TmfFilterContainsNode.VALUE_ATTR, node.getValue());\r
-                       element.setAttribute(TmfFilterContainsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));\r
-\r
-               } else if (treenode instanceof TmfFilterEqualsNode) {\r
-\r
-                       TmfFilterEqualsNode node = (TmfFilterEqualsNode) treenode;\r
-                       element.setAttribute(TmfFilterEqualsNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
-                       element.setAttribute(TmfFilterEqualsNode.FIELD_ATTR, node.getField());\r
-                       element.setAttribute(TmfFilterEqualsNode.VALUE_ATTR, node.getValue());\r
-                       element.setAttribute(TmfFilterEqualsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));\r
-\r
-               } else if (treenode instanceof TmfFilterMatchesNode) {\r
-\r
-                       TmfFilterMatchesNode node = (TmfFilterMatchesNode) treenode;\r
-                       element.setAttribute(TmfFilterMatchesNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
-                       element.setAttribute(TmfFilterMatchesNode.FIELD_ATTR, node.getField());\r
-                       element.setAttribute(TmfFilterMatchesNode.REGEX_ATTR, node.getRegex());\r
-\r
-               } else if (treenode instanceof TmfFilterCompareNode) {\r
-\r
-                       TmfFilterCompareNode node = (TmfFilterCompareNode) treenode;\r
-                       element.setAttribute(TmfFilterCompareNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
-                       element.setAttribute(TmfFilterCompareNode.FIELD_ATTR, node.getField());\r
-                       element.setAttribute(TmfFilterCompareNode.RESULT_ATTR, Integer.toString(node.getResult()));\r
-                       element.setAttribute(TmfFilterCompareNode.TYPE_ATTR, node.getType().toString());\r
-                       element.setAttribute(TmfFilterCompareNode.VALUE_ATTR, node.getValue());\r
-\r
-               }\r
-\r
-               parentElement.appendChild(element);\r
-\r
-               for (int i = 0; i < treenode.getChildrenCount(); i++) {\r
-                       buildXMLTree(document, treenode.getChild(i), element);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Save the tree\r
-        *\r
-        * @param uri The new Filter XML path\r
-        */\r
-       public void saveTree(final String uri) {\r
-               TransformerFactory transformerFactory = TransformerFactory.newInstance();\r
-\r
-               try {\r
-                       Transformer transformer = transformerFactory.newTransformer();\r
-               DOMSource source = new DOMSource(document);\r
-               StreamResult result =  new StreamResult(new File(uri));\r
-                       transformer.transform(source, result);\r
-               } catch (TransformerConfigurationException e) {\r
-                       e.printStackTrace();\r
-               } catch (TransformerException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.xml;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * The SAX based XML writer
+ *
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ * @author Patrick Tasse
+ */
+public class TmfFilterXMLWriter {
+
+       private Document document = null;
+
+       /**
+        * The XMLParser constructor
+        *
+     * @param root The tree root
+        * @throws ParserConfigurationException if a DocumentBuilder
+     *   cannot be created which satisfies the configuration requested.
+        */
+       public TmfFilterXMLWriter(final ITmfFilterTreeNode root) throws ParserConfigurationException {
+               DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+               DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+               document = documentBuilder.newDocument();
+
+               Element rootElement = document.createElement(root.getNodeName());
+               document.appendChild(rootElement);
+
+               for (ITmfFilterTreeNode node : root.getChildren()) {
+                       buildXMLTree(document, node, rootElement);
+               }
+       }
+
+       /**
+        * The Tree to XML parser
+        *
+        * @param document The XML document
+        * @param treenode The node to write
+        * @param parentElement The XML element of the parent
+        */
+       public static void buildXMLTree(final Document document, final ITmfFilterTreeNode treenode, Element parentElement) {
+               Element element = document.createElement(treenode.getNodeName());
+
+               if (treenode instanceof TmfFilterNode) {
+
+                       TmfFilterNode node = (TmfFilterNode) treenode;
+                       element.setAttribute(TmfFilterNode.NAME_ATTR, node.getFilterName());
+
+               } else if (treenode instanceof TmfFilterEventTypeNode) {
+
+                       TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) treenode;
+                       element.setAttribute(TmfFilterEventTypeNode.TYPE_ATTR, node.getEventType());
+                       element.setAttribute(TmfFilterEventTypeNode.NAME_ATTR, node.getName());
+
+               } else if (treenode instanceof TmfFilterAndNode) {
+
+                       TmfFilterAndNode node = (TmfFilterAndNode) treenode;
+                       element.setAttribute(TmfFilterAndNode.NOT_ATTR, Boolean.toString(node.isNot()));
+
+               } else if (treenode instanceof TmfFilterOrNode) {
+
+                       TmfFilterOrNode node = (TmfFilterOrNode) treenode;
+                       element.setAttribute(TmfFilterOrNode.NOT_ATTR, Boolean.toString(node.isNot()));
+
+               } else if (treenode instanceof TmfFilterContainsNode) {
+
+                       TmfFilterContainsNode node = (TmfFilterContainsNode) treenode;
+                       element.setAttribute(TmfFilterContainsNode.NOT_ATTR, Boolean.toString(node.isNot()));
+                       element.setAttribute(TmfFilterContainsNode.FIELD_ATTR, node.getField());
+                       element.setAttribute(TmfFilterContainsNode.VALUE_ATTR, node.getValue());
+                       element.setAttribute(TmfFilterContainsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));
+
+               } else if (treenode instanceof TmfFilterEqualsNode) {
+
+                       TmfFilterEqualsNode node = (TmfFilterEqualsNode) treenode;
+                       element.setAttribute(TmfFilterEqualsNode.NOT_ATTR, Boolean.toString(node.isNot()));
+                       element.setAttribute(TmfFilterEqualsNode.FIELD_ATTR, node.getField());
+                       element.setAttribute(TmfFilterEqualsNode.VALUE_ATTR, node.getValue());
+                       element.setAttribute(TmfFilterEqualsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));
+
+               } else if (treenode instanceof TmfFilterMatchesNode) {
+
+                       TmfFilterMatchesNode node = (TmfFilterMatchesNode) treenode;
+                       element.setAttribute(TmfFilterMatchesNode.NOT_ATTR, Boolean.toString(node.isNot()));
+                       element.setAttribute(TmfFilterMatchesNode.FIELD_ATTR, node.getField());
+                       element.setAttribute(TmfFilterMatchesNode.REGEX_ATTR, node.getRegex());
+
+               } else if (treenode instanceof TmfFilterCompareNode) {
+
+                       TmfFilterCompareNode node = (TmfFilterCompareNode) treenode;
+                       element.setAttribute(TmfFilterCompareNode.NOT_ATTR, Boolean.toString(node.isNot()));
+                       element.setAttribute(TmfFilterCompareNode.FIELD_ATTR, node.getField());
+                       element.setAttribute(TmfFilterCompareNode.RESULT_ATTR, Integer.toString(node.getResult()));
+                       element.setAttribute(TmfFilterCompareNode.TYPE_ATTR, node.getType().toString());
+                       element.setAttribute(TmfFilterCompareNode.VALUE_ATTR, node.getValue());
+
+               }
+
+               parentElement.appendChild(element);
+
+               for (int i = 0; i < treenode.getChildrenCount(); i++) {
+                       buildXMLTree(document, treenode.getChild(i), element);
+               }
+       }
+
+       /**
+        * Save the tree
+        *
+        * @param uri The new Filter XML path
+        */
+       public void saveTree(final String uri) {
+               TransformerFactory transformerFactory = TransformerFactory.newInstance();
+
+               try {
+                       Transformer transformer = transformerFactory.newTransformer();
+               DOMSource source = new DOMSource(document);
+               StreamResult result =  new StreamResult(new File(uri));
+                       transformer.transform(source, result);
+               } catch (TransformerConfigurationException e) {
+                       e.printStackTrace();
+               } catch (TransformerException e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
index cc70b168e0a7b1bad5dc6e66c59bdeaada54819b..84f961227faf4308215a958aaab6f1431d943a18 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation, based on article by Nick Zhang\r
- *                   (http://www.javaworld.com/javatips/jw-javatip26.html)\r
- ******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.io;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.RandomAccessFile;\r
-import java.nio.charset.Charset;\r
-\r
-/**\r
- * A class to mitigate the Java I/O inefficiency of RandomAccessFile.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class BufferedRandomAccessFile extends RandomAccessFile {\r
-\r
-       private static final int DEFAULT_BUF_SIZE = 8192;\r
-       private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8"); //$NON-NLS-1$\r
-\r
-       final int BUF_SIZE;\r
-       byte buffer[];\r
-       int buf_end = 0;\r
-       int buf_pos = 0;\r
-       long real_pos = 0;\r
-       StringBuilder sb = new StringBuilder();\r
-\r
-    /**\r
-     * Constructor using the default buffer size\r
-     *\r
-     * @param name\r
-     *            File path. This is passed as-is to the RandomeAccessFile's\r
-     *            constructor.\r
-     * @param mode\r
-     *            File open mode ("r", "rw", etc.). This is passed as-is to\r
-     *            RandomAccessFile's constructor.\r
-     * @throws IOException\r
-     *             If the file was not found or couldn't be opened with the\r
-     *             request permissions\r
-     */\r
-       public BufferedRandomAccessFile(String name, String mode) throws IOException {\r
-               this(name, mode, DEFAULT_BUF_SIZE);\r
-       }\r
-\r
-    /**\r
-     * Constructor using the default buffer size\r
-     *\r
-     * @param file\r
-     *            File object. This is passed as-is to the RandomeAccessFile's\r
-     *            constructor.\r
-     * @param mode\r
-     *            File open mode ("r", "rw", etc.). This is passed as-is to\r
-     *            RandomAccessFile's constructor.\r
-     * @throws IOException\r
-     *             If the file was not found or couldn't be opened with the\r
-     *             request permissions\r
-     */\r
-       public BufferedRandomAccessFile(File file, String mode) throws IOException {\r
-               this(file, mode, DEFAULT_BUF_SIZE);\r
-       }\r
-\r
-    /**\r
-     * Standard constructor.\r
-     *\r
-     * @param name\r
-     *            File path. This is passed as-is to the RandomeAccessFile's\r
-     *            constructor.\r
-     * @param mode\r
-     *            File open mode ("r", "rw", etc.). This is passed as-is to\r
-     *            RandomAccessFile's constructor.\r
-     * @param bufsize\r
-     *            Buffer size to use, in bytes\r
-     * @throws IOException\r
-     *             If the file was not found or couldn't be opened with the\r
-     *             request permissions\r
-     */\r
-       public BufferedRandomAccessFile(String name, String mode, int bufsize) throws IOException {\r
-           super(name, mode);\r
-           invalidate();\r
-           BUF_SIZE = bufsize;\r
-           buffer = new byte[BUF_SIZE];\r
-    }\r
-\r
-    /**\r
-     * Standard constructor.\r
-     *\r
-     * @param file\r
-     *            File object. This is passed as-is to the RandomeAccessFile's\r
-     *            constructor.\r
-     * @param mode\r
-     *            File open mode ("r", "rw", etc.). This is passed as-is to\r
-     *            RandomAccessFile's constructor.\r
-     * @param bufsize\r
-     *            Buffer size to use, in bytes\r
-     * @throws IOException\r
-     *             If the file was not found or couldn't be opened with the\r
-     *             request permissions\r
-     */\r
-       public BufferedRandomAccessFile(File file, String mode, int bufsize) throws IOException {\r
-           super(file, mode);\r
-           invalidate();\r
-           BUF_SIZE = bufsize;\r
-           buffer = new byte[BUF_SIZE];\r
-    }\r
-\r
-       @Override\r
-    public final int read() throws IOException{\r
-               if (buf_pos >= buf_end) {\r
-                       if (fillBuffer() < 0) {\r
-                               return -1;\r
-                       }\r
-               }\r
-               if (buf_end == 0) {\r
-                       return -1;\r
-               }\r
-        return buffer[buf_pos++];\r
-       }\r
-\r
-       @Override\r
-    public int read(byte b[], int off, int len) throws IOException {\r
-               int leftover = buf_end - buf_pos;\r
-               if (len <= leftover) {\r
-                       System.arraycopy(buffer, buf_pos, b, off, len);\r
-                       buf_pos += len;\r
-                       return len;\r
-               }\r
-               for(int i = 0; i < len; i++) {\r
-                       int c = this.read();\r
-                       if (c != -1) {\r
-                               b[off+i] = (byte) c;\r
-                       } else {\r
-                               return i;\r
-                       }\r
-               }\r
-               return len;\r
-       }\r
-\r
-       @Override\r
-    public long getFilePointer() throws IOException{\r
-               long l = real_pos;\r
-               return (l - buf_end + buf_pos);\r
-       }\r
-\r
-       @Override\r
-    public void seek(long pos) throws IOException {\r
-               int n = (int) (real_pos - pos);\r
-               if(n >= 0 && n <= buf_end) {\r
-                       buf_pos = buf_end - n;\r
-               } else {\r
-                       super.seek(pos);\r
-                       invalidate();\r
-               }\r
-       }\r
-\r
-    /**\r
-     * Read the next line from the buffer (ie, until the next '\n'). The bytes\r
-     * are interpreted as UTF-8 characters.\r
-     *\r
-     * @return The String that was read\r
-     * @throws IOException\r
-     *             If we failed reading the file\r
-     */\r
-       public final String getNextLine() throws IOException {\r
-               String str = null;\r
-               if (buf_end - buf_pos <= 0) {\r
-                       if (fillBuffer() < 0) {\r
-                               return null;\r
-                       }\r
-               }\r
-               int lineend = -1;\r
-               for (int i = buf_pos; i < buf_end; i++) {\r
-                       if (buffer[i] == '\n') {\r
-                               lineend = i;\r
-                               break;\r
-                       }\r
-               }\r
-               if (lineend < 0) {\r
-                       sb.delete(0, sb.length());\r
-                       int c;\r
-                       while (((c = read()) != -1) && (c != '\n')) {\r
-                               sb.append((char) c);\r
-                       }\r
-                       if ((c == -1) && (sb.length() == 0)) {\r
-                               return null;\r
-                       }\r
-                       if (sb.charAt(sb.length() - 1) == '\r') {\r
-                               sb.deleteCharAt(sb.length() - 1);\r
-                       }\r
-                       return sb.toString();\r
-               }\r
-               if (lineend > 0 && buffer[lineend - 1] == '\r' && lineend > buf_pos) {\r
-                       str = new String(buffer, buf_pos, lineend - buf_pos - 1, CHARSET_UTF8);\r
-               } else {\r
-                       str = new String(buffer, buf_pos, lineend - buf_pos, CHARSET_UTF8);\r
-               }\r
-               buf_pos = lineend + 1;\r
-               return str;\r
-       }\r
-\r
-       private int fillBuffer() throws IOException {\r
-               int n = super.read(buffer, 0, BUF_SIZE);\r
-               if (n >= 0) {\r
-                       real_pos += n;\r
-                       buf_end = n;\r
-                       buf_pos = 0;\r
-               }\r
-               return n;\r
-       }\r
-\r
-       private void invalidate() throws IOException {\r
-               buf_end = 0;\r
-               buf_pos = 0;\r
-               real_pos = super.getFilePointer();\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation, based on article by Nick Zhang
+ *                   (http://www.javaworld.com/javatips/jw-javatip26.html)
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.io;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.charset.Charset;
+
+/**
+ * A class to mitigate the Java I/O inefficiency of RandomAccessFile.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class BufferedRandomAccessFile extends RandomAccessFile {
+
+       private static final int DEFAULT_BUF_SIZE = 8192;
+       private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8"); //$NON-NLS-1$
+
+       final int BUF_SIZE;
+       byte buffer[];
+       int buf_end = 0;
+       int buf_pos = 0;
+       long real_pos = 0;
+       StringBuilder sb = new StringBuilder();
+
+    /**
+     * Constructor using the default buffer size
+     *
+     * @param name
+     *            File path. This is passed as-is to the RandomeAccessFile's
+     *            constructor.
+     * @param mode
+     *            File open mode ("r", "rw", etc.). This is passed as-is to
+     *            RandomAccessFile's constructor.
+     * @throws IOException
+     *             If the file was not found or couldn't be opened with the
+     *             request permissions
+     */
+       public BufferedRandomAccessFile(String name, String mode) throws IOException {
+               this(name, mode, DEFAULT_BUF_SIZE);
+       }
+
+    /**
+     * Constructor using the default buffer size
+     *
+     * @param file
+     *            File object. This is passed as-is to the RandomeAccessFile's
+     *            constructor.
+     * @param mode
+     *            File open mode ("r", "rw", etc.). This is passed as-is to
+     *            RandomAccessFile's constructor.
+     * @throws IOException
+     *             If the file was not found or couldn't be opened with the
+     *             request permissions
+     */
+       public BufferedRandomAccessFile(File file, String mode) throws IOException {
+               this(file, mode, DEFAULT_BUF_SIZE);
+       }
+
+    /**
+     * Standard constructor.
+     *
+     * @param name
+     *            File path. This is passed as-is to the RandomeAccessFile's
+     *            constructor.
+     * @param mode
+     *            File open mode ("r", "rw", etc.). This is passed as-is to
+     *            RandomAccessFile's constructor.
+     * @param bufsize
+     *            Buffer size to use, in bytes
+     * @throws IOException
+     *             If the file was not found or couldn't be opened with the
+     *             request permissions
+     */
+       public BufferedRandomAccessFile(String name, String mode, int bufsize) throws IOException {
+           super(name, mode);
+           invalidate();
+           BUF_SIZE = bufsize;
+           buffer = new byte[BUF_SIZE];
+    }
+
+    /**
+     * Standard constructor.
+     *
+     * @param file
+     *            File object. This is passed as-is to the RandomeAccessFile's
+     *            constructor.
+     * @param mode
+     *            File open mode ("r", "rw", etc.). This is passed as-is to
+     *            RandomAccessFile's constructor.
+     * @param bufsize
+     *            Buffer size to use, in bytes
+     * @throws IOException
+     *             If the file was not found or couldn't be opened with the
+     *             request permissions
+     */
+       public BufferedRandomAccessFile(File file, String mode, int bufsize) throws IOException {
+           super(file, mode);
+           invalidate();
+           BUF_SIZE = bufsize;
+           buffer = new byte[BUF_SIZE];
+    }
+
+       @Override
+    public final int read() throws IOException{
+               if (buf_pos >= buf_end) {
+                       if (fillBuffer() < 0) {
+                               return -1;
+                       }
+               }
+               if (buf_end == 0) {
+                       return -1;
+               }
+        return buffer[buf_pos++];
+       }
+
+       @Override
+    public int read(byte b[], int off, int len) throws IOException {
+               int leftover = buf_end - buf_pos;
+               if (len <= leftover) {
+                       System.arraycopy(buffer, buf_pos, b, off, len);
+                       buf_pos += len;
+                       return len;
+               }
+               for(int i = 0; i < len; i++) {
+                       int c = this.read();
+                       if (c != -1) {
+                               b[off+i] = (byte) c;
+                       } else {
+                               return i;
+                       }
+               }
+               return len;
+       }
+
+       @Override
+    public long getFilePointer() throws IOException{
+               long l = real_pos;
+               return (l - buf_end + buf_pos);
+       }
+
+       @Override
+    public void seek(long pos) throws IOException {
+               int n = (int) (real_pos - pos);
+               if(n >= 0 && n <= buf_end) {
+                       buf_pos = buf_end - n;
+               } else {
+                       super.seek(pos);
+                       invalidate();
+               }
+       }
+
+    /**
+     * Read the next line from the buffer (ie, until the next '\n'). The bytes
+     * are interpreted as UTF-8 characters.
+     *
+     * @return The String that was read
+     * @throws IOException
+     *             If we failed reading the file
+     */
+       public final String getNextLine() throws IOException {
+               String str = null;
+               if (buf_end - buf_pos <= 0) {
+                       if (fillBuffer() < 0) {
+                               return null;
+                       }
+               }
+               int lineend = -1;
+               for (int i = buf_pos; i < buf_end; i++) {
+                       if (buffer[i] == '\n') {
+                               lineend = i;
+                               break;
+                       }
+               }
+               if (lineend < 0) {
+                       sb.delete(0, sb.length());
+                       int c;
+                       while (((c = read()) != -1) && (c != '\n')) {
+                               sb.append((char) c);
+                       }
+                       if ((c == -1) && (sb.length() == 0)) {
+                               return null;
+                       }
+                       if (sb.charAt(sb.length() - 1) == '\r') {
+                               sb.deleteCharAt(sb.length() - 1);
+                       }
+                       return sb.toString();
+               }
+               if (lineend > 0 && buffer[lineend - 1] == '\r' && lineend > buf_pos) {
+                       str = new String(buffer, buf_pos, lineend - buf_pos - 1, CHARSET_UTF8);
+               } else {
+                       str = new String(buffer, buf_pos, lineend - buf_pos, CHARSET_UTF8);
+               }
+               buf_pos = lineend + 1;
+               return str;
+       }
+
+       private int fillBuffer() throws IOException {
+               int n = super.read(buffer, 0, BUF_SIZE);
+               if (n >= 0) {
+                       real_pos += n;
+                       buf_end = n;
+                       buf_pos = 0;
+               }
+               return n;
+       }
+
+       private void invalidate() throws IOException {
+               buf_end = 0;
+               buf_pos = 0;
+               real_pos = super.getFilePointer();
+       }
+}
index c4a2d2507c0c6794583a615173ff99f2efeffa40..cc0abf52e4d878daf03e51428f6fcde43e8e9a42 100644 (file)
@@ -1,51 +1,51 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.signal;\r
-\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-/**\r
- * A trace was selected\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceSelectedSignal extends TmfSignal {\r
-\r
-    private final ITmfTrace<?> fTrace;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param source\r
-     *            Object sending this signal\r
-     * @param trace\r
-     *            The trace that was selected\r
-     */\r
-    public TmfTraceSelectedSignal(Object source, ITmfTrace<?> trace) {\r
-        super(source);\r
-        fTrace = trace;\r
-    }\r
-\r
-    /**\r
-     * @return The trace referred to by this signal\r
-     */\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceSelectedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.signal;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * A trace was selected
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceSelectedSignal extends TmfSignal {
+
+    private final ITmfTrace<?> fTrace;
+
+    /**
+     * Constructor
+     *
+     * @param source
+     *            Object sending this signal
+     * @param trace
+     *            The trace that was selected
+     */
+    public TmfTraceSelectedSignal(Object source, ITmfTrace<?> trace) {
+        super(source);
+        fTrace = trace;
+    }
+
+    /**
+     * @return The trace referred to by this signal
+     */
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceSelectedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index 2672ec0feb8117c25429c0c41ec9813ec362dcfd..101e8f3f078ffdaba2370af639728a3d84837c11 100644 (file)
@@ -1,55 +1,55 @@
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r
- *******************************************************************************/\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.adaption;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model.EventImpl;\r
-\r
-/**\r
- * Time Graph Presentation Provider Stub.\r
- */\r
-@SuppressWarnings("nls")\r
-public class TsfImplProvider extends TimeGraphPresentationProvider {\r
-\r
-       // ========================================================================\r
-       // Methods\r
-       // ========================================================================\r
-       @Override\r
-       public int getStateTableIndex(ITimeEvent event) {\r
-           return 0;\r
-       }\r
-\r
-       @Override\r
-       public Map<String, String> getEventHoverToolTipInfo(ITimeEvent revent) {\r
-               Map<String, String> toolTipEventMsgs = new HashMap<String, String>();\r
-               if (revent instanceof EventImpl) {\r
-                       toolTipEventMsgs.put("Test Tip1", "Test Value tip1");\r
-                       toolTipEventMsgs.put("Test Tip2", "Test Value tip2");\r
-               }\r
-\r
-               return toolTipEventMsgs;\r
-       }\r
-\r
-       @Override\r
-       public String getEventName(ITimeEvent event) {\r
-               String name = "Unknown";\r
-               if (event instanceof EventImpl) {\r
-                       EventImpl devent = (EventImpl) event;\r
-                       name = devent.getType().toString();\r
-               }\r
-               return name;\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.adaption;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model.EventImpl;
+
+/**
+ * Time Graph Presentation Provider Stub.
+ */
+@SuppressWarnings("nls")
+public class TsfImplProvider extends TimeGraphPresentationProvider {
+
+       // ========================================================================
+       // Methods
+       // ========================================================================
+       @Override
+       public int getStateTableIndex(ITimeEvent event) {
+           return 0;
+       }
+
+       @Override
+       public Map<String, String> getEventHoverToolTipInfo(ITimeEvent revent) {
+               Map<String, String> toolTipEventMsgs = new HashMap<String, String>();
+               if (revent instanceof EventImpl) {
+                       toolTipEventMsgs.put("Test Tip1", "Test Value tip1");
+                       toolTipEventMsgs.put("Test Tip2", "Test Value tip2");
+               }
+
+               return toolTipEventMsgs;
+       }
+
+       @Override
+       public String getEventName(ITimeEvent event) {
+               String name = "Unknown";
+               if (event instanceof EventImpl) {
+                       EventImpl devent = (EventImpl) event;
+                       name = devent.getType().toString();
+               }
+               return name;
+       }
+}
index a557620b031e6c91f10791ba0c20c06b1902c828..b88f9c90e96c1012f6121d690ea3ce69d6cc6b15 100644 (file)
@@ -1,85 +1,85 @@
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r
- *******************************************************************************/\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * ITimeEvent implementation for test purposes.\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class EventImpl implements ITimeEvent {\r
-       // ========================================================================\r
-       // Data\r
-       // ========================================================================\r
-       public static enum Type {ERROR, WARNING, TIMEADJUSTMENT, ALARM, EVENT, INFORMATION, UNKNOWN, INFO1, INFO2, INFO3, INFO4, INFO5, INFO6, INFO7, INFO8, INFO9}\r
-\r
-       private long time = 0;\r
-       private ITimeGraphEntry trace = null;\r
-       private Type myType = Type.UNKNOWN;\r
-       private long duration;\r
-\r
-       // ========================================================================\r
-       // Constructor\r
-       // ========================================================================\r
-       public EventImpl(long time, ITimeGraphEntry trace, Type type) {\r
-               this.time = time;\r
-               this.trace = trace;\r
-               this.myType = type;\r
-       }\r
-\r
-       // ========================================================================\r
-       // Methods\r
-       // ========================================================================\r
-       public Type getType() {\r
-               return myType;\r
-       }\r
-\r
-       public void setType(Type myType) {\r
-               this.myType = myType;\r
-       }\r
-\r
-       public void setTime(long time) {\r
-               this.time = time;\r
-       }\r
-\r
-       public void setTrace(ITimeGraphEntry trace) {\r
-               this.trace = trace;\r
-       }\r
-\r
-       @Override\r
-       public long getTime() {\r
-               return time;\r
-       }\r
-\r
-       @Override\r
-       public ITimeGraphEntry getEntry() {\r
-               return trace;\r
-       }\r
-\r
-       /**\r
-        * @param duration the duration to set\r
-        */\r
-       public void setDuration(long duration) {\r
-               this.duration = duration;\r
-       }\r
-\r
-       /**\r
-        * @return the duration\r
-        */\r
-       @Override\r
-       public long getDuration() {\r
-               return duration;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * ITimeEvent implementation for test purposes.
+ */
+@SuppressWarnings("javadoc")
+public class EventImpl implements ITimeEvent {
+       // ========================================================================
+       // Data
+       // ========================================================================
+       public static enum Type {ERROR, WARNING, TIMEADJUSTMENT, ALARM, EVENT, INFORMATION, UNKNOWN, INFO1, INFO2, INFO3, INFO4, INFO5, INFO6, INFO7, INFO8, INFO9}
+
+       private long time = 0;
+       private ITimeGraphEntry trace = null;
+       private Type myType = Type.UNKNOWN;
+       private long duration;
+
+       // ========================================================================
+       // Constructor
+       // ========================================================================
+       public EventImpl(long time, ITimeGraphEntry trace, Type type) {
+               this.time = time;
+               this.trace = trace;
+               this.myType = type;
+       }
+
+       // ========================================================================
+       // Methods
+       // ========================================================================
+       public Type getType() {
+               return myType;
+       }
+
+       public void setType(Type myType) {
+               this.myType = myType;
+       }
+
+       public void setTime(long time) {
+               this.time = time;
+       }
+
+       public void setTrace(ITimeGraphEntry trace) {
+               this.trace = trace;
+       }
+
+       @Override
+       public long getTime() {
+               return time;
+       }
+
+       @Override
+       public ITimeGraphEntry getEntry() {
+               return trace;
+       }
+
+       /**
+        * @param duration the duration to set
+        */
+       public void setDuration(long duration) {
+               this.duration = duration;
+       }
+
+       /**
+        * @return the duration
+        */
+       @Override
+       public long getDuration() {
+               return duration;
+       }
+
+}
index 74e0c9fad252eb51b20f97e9e47b7dac7ed5def3..210c5b0c8ce71dd670234c77346e3444ddf4aa8f 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r
- *******************************************************************************/\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;\r
-\r
-import java.util.Iterator;\r
-import java.util.Vector;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-@SuppressWarnings({"javadoc", "nls"})\r
-public class TraceImpl implements ITimeGraphEntry {\r
-    // ========================================================================\r
-    // Data\r
-    // ========================================================================\r
-    private String name = "traceDefaultName";\r
-    private long startTime = 0;\r
-    private long stopTime = 1;\r
-    private String className = "defaultClassName";\r
-    private Vector<ITimeEvent> traceEvents = new Vector<ITimeEvent>();\r
-\r
-    // ========================================================================\r
-    // Constructor\r
-    // ========================================================================\r
-\r
-    public TraceImpl(String name, long sTime, long stopTime, String className) {\r
-        this.name = name;\r
-        this.startTime = sTime;\r
-        this.stopTime = stopTime;\r
-        this.className = className;\r
-    }\r
-\r
-    // ========================================================================\r
-    // Methods\r
-    // ========================================================================\r
-\r
-    public String getClassName() {\r
-        return className;\r
-    }\r
-\r
-    public void setClassName(String className) {\r
-        this.className = className;\r
-    }\r
-\r
-    public void setName(String name) {\r
-        this.name = name;\r
-    }\r
-\r
-    public void setStartTime(long startTime) {\r
-        this.startTime = startTime;\r
-    }\r
-\r
-    public void setStopTime(long stopTime) {\r
-        this.stopTime = stopTime;\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return name;\r
-    }\r
-\r
-    @Override\r
-    public long getStartTime() {\r
-        return startTime;\r
-    }\r
-\r
-    @Override\r
-    public long getEndTime() {\r
-        return stopTime;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasTimeEvents() {\r
-        return traceEvents != null;\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator() {\r
-        return traceEvents.iterator();\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator(long aStartTime, long aStopTime, long maxDuration) {\r
-        return traceEvents.iterator();\r
-    }\r
-\r
-    public void addTraceEvent(ITimeEvent event) {\r
-        traceEvents.add(event);\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry[] getChildren() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry getParent() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasChildren() {\r
-        return false;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+@SuppressWarnings({"javadoc", "nls"})
+public class TraceImpl implements ITimeGraphEntry {
+    // ========================================================================
+    // Data
+    // ========================================================================
+    private String name = "traceDefaultName";
+    private long startTime = 0;
+    private long stopTime = 1;
+    private String className = "defaultClassName";
+    private Vector<ITimeEvent> traceEvents = new Vector<ITimeEvent>();
+
+    // ========================================================================
+    // Constructor
+    // ========================================================================
+
+    public TraceImpl(String name, long sTime, long stopTime, String className) {
+        this.name = name;
+        this.startTime = sTime;
+        this.stopTime = stopTime;
+        this.className = className;
+    }
+
+    // ========================================================================
+    // Methods
+    // ========================================================================
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setStartTime(long startTime) {
+        this.startTime = startTime;
+    }
+
+    public void setStopTime(long stopTime) {
+        this.stopTime = stopTime;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public long getStartTime() {
+        return startTime;
+    }
+
+    @Override
+    public long getEndTime() {
+        return stopTime;
+    }
+
+    @Override
+    public boolean hasTimeEvents() {
+        return traceEvents != null;
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator() {
+        return traceEvents.iterator();
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator(long aStartTime, long aStopTime, long maxDuration) {
+        return traceEvents.iterator();
+    }
+
+    public void addTraceEvent(ITimeEvent event) {
+        traceEvents.add(event);
+    }
+
+    @Override
+    public ITimeGraphEntry[] getChildren() {
+        return null;
+    }
+
+    @Override
+    public ITimeGraphEntry getParent() {
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren() {
+        return false;
+    }
+
+}
index b28d75b66b28d0689c90e8f66d526de42398da50..bbd8877f65d2bcc071940d1b226896526cacb443 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r
- *******************************************************************************/\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;\r
-\r
-import java.util.Date;\r
-\r
-@SuppressWarnings({"javadoc", "nls"})\r
-public class TraceModelImplFactory {\r
-\r
-       // ========================================================================\r
-       // Data\r
-       // ========================================================================\r
-       private int count = 0;\r
-       private final TraceStrings[] traceNames;\r
-       private static final long msTons = 1000000;\r
-       private final Long timeRef = new Date().getTime() * msTons;\r
-\r
-       // ========================================================================\r
-       // Constructor\r
-       // ========================================================================\r
-       public TraceModelImplFactory() {\r
-               traceNames = new TraceStrings[17];\r
-               loadTraceNameStrings();\r
-       }\r
-\r
-       // ========================================================================\r
-       // Methods\r
-       // ========================================================================\r
-       public TraceImpl[] createTraces() {\r
-               TraceImpl trace;\r
-               TraceImpl[] traceArr = new TraceImpl[17];\r
-               for (int i = 0; i < traceArr.length; i++) {\r
-                       trace = new TraceImpl(traceNames[i].name, timeRef, timeRef + 40,\r
-                                       traceNames[i].classNmme);\r
-                       count = i;\r
-                       createEvents(trace);\r
-                       traceArr[i] = trace;\r
-               }\r
-               return traceArr;\r
-       }\r
-\r
-       /**\r
-        * 5000 Events per Trace.\r
-        * @param number\r
-        * @return\r
-        */\r
-       public TraceImpl[] createLargeTraces(int number) {\r
-               TraceImpl trace;\r
-               TraceImpl[] traceArr = new TraceImpl[number];\r
-               for (int i = 0; i < traceArr.length; i++) {\r
-                       int counter = i%17;\r
-                       long sTime = i * (long) 1E6;\r
-                       trace = new TraceImpl(traceNames[counter].name, sTime  , sTime + 20000,\r
-                                       traceNames[counter].classNmme);\r
-                       create5000Events(trace);\r
-                       traceArr[i] = trace;\r
-               }\r
-               return traceArr;\r
-       }\r
-\r
-       private static void create5000Events(TraceImpl trace) {\r
-               EventImpl event;\r
-               Long eventTime;\r
-               int numEvents = 5000;\r
-               long sTime = trace.getStartTime();\r
-               long eTime = trace.getEndTime();\r
-               long duration = (eTime - sTime)/numEvents;\r
-               for (int i = 0; i < numEvents; i++) {\r
-                       eventTime = sTime + (i * duration);\r
-                       // eventTime = timeRef + (5 * (count % 4) + (5 * (int) (i/2) ));\r
-                       // System.out.println("Trace: " + trace.getName() + " EventTime: "\r
-                       // + eventTime);\r
-//                     duration = i * msTons + (long) ((i % 4));\r
-\r
-                       event = new EventImpl(eventTime, trace, getEventType(i%16));\r
-                       event.setDuration(duration);\r
-                       trace.addTraceEvent(event);\r
-               }\r
-       }\r
-\r
-       private void createEvents(TraceImpl trace) {\r
-               EventImpl event;\r
-               Long eventTime;\r
-               int numEvents = 17;\r
-               long duration = 0;\r
-               for (int i = 0; i < numEvents; i++) {\r
-                       eventTime = timeRef + msTons * i + (5 * msTons * count) + (5 * i);\r
-                       duration = msTons + i * msTons + ((i % 4));\r
-//                     duration = i  + (long) ((i % 4));\r
-                       event = new EventImpl(eventTime, trace, getEventType(i));\r
-                       event.setDuration(duration);\r
-                       trace.addTraceEvent(event);\r
-               }\r
-       }\r
-\r
-    private static EventImpl.Type getEventType(int val) {\r
-        if (EventImpl.Type.ALARM.ordinal() == val) {\r
-            return EventImpl.Type.ALARM;\r
-        }\r
-        if (EventImpl.Type.ERROR.ordinal() == val) {\r
-            return EventImpl.Type.ERROR;\r
-        }\r
-        if (EventImpl.Type.EVENT.ordinal() == val) {\r
-            return EventImpl.Type.EVENT;\r
-        }\r
-        if (EventImpl.Type.INFORMATION.ordinal() == val) {\r
-            return EventImpl.Type.INFORMATION;\r
-        }\r
-        if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val) {\r
-            return EventImpl.Type.TIMEADJUSTMENT;\r
-        }\r
-        if (EventImpl.Type.WARNING.ordinal() == val) {\r
-            return EventImpl.Type.WARNING;\r
-        }\r
-        if (EventImpl.Type.INFO1.ordinal() == val) {\r
-            return EventImpl.Type.INFO1;\r
-        }\r
-        if (EventImpl.Type.INFO2.ordinal() == val) {\r
-            return EventImpl.Type.INFO2;\r
-        }\r
-        if (EventImpl.Type.INFO3.ordinal() == val) {\r
-            return EventImpl.Type.INFO3;\r
-        }\r
-        if (EventImpl.Type.INFO4.ordinal() == val) {\r
-            return EventImpl.Type.INFO4;\r
-        }\r
-        if (EventImpl.Type.INFO5.ordinal() == val) {\r
-            return EventImpl.Type.INFO5;\r
-        }\r
-        if (EventImpl.Type.INFO6.ordinal() == val) {\r
-            return EventImpl.Type.INFO6;\r
-        }\r
-        if (EventImpl.Type.INFO7.ordinal() == val) {\r
-            return EventImpl.Type.INFO7;\r
-        }\r
-        if (EventImpl.Type.INFO8.ordinal() == val) {\r
-            return EventImpl.Type.INFO8;\r
-        }\r
-        if (EventImpl.Type.INFO9.ordinal() == val) {\r
-            return EventImpl.Type.INFO9;\r
-        }\r
-        return EventImpl.Type.UNKNOWN;\r
-    }\r
-\r
-       private void loadTraceNameStrings() {\r
-               traceNames[0] = new TraceStrings();\r
-               traceNames[0].name = "TE Log - TATA BSC11";\r
-               traceNames[0].classNmme = "All Boards";\r
-\r
-               traceNames[1] = new TraceStrings();\r
-               traceNames[1].name = "System Log";\r
-               traceNames[1].classNmme = "BSC11";\r
-\r
-               traceNames[2] = new TraceStrings();\r
-               traceNames[2].name = "Alarm Log";\r
-               traceNames[2].classNmme = "BSC11";\r
-\r
-               traceNames[3] = new TraceStrings();\r
-               traceNames[3].name = "Events Log";\r
-               traceNames[3].classNmme = "BSC 11";\r
-\r
-               traceNames[4] = new TraceStrings();\r
-               traceNames[4].name = "CPU Load";\r
-               traceNames[4].classNmme = "All Boards";\r
-\r
-               traceNames[5] = new TraceStrings();\r
-               traceNames[5].name = "Performance Log";\r
-               traceNames[5].classNmme = "BSC11";\r
-\r
-               traceNames[6] = new TraceStrings();\r
-               traceNames[6].name = "TE Log  - TATA BSC14";\r
-               traceNames[6].classNmme = "Board 24";\r
-\r
-               traceNames[7] = new TraceStrings();\r
-               traceNames[7].name = "TE Log - TATA BSC14";\r
-               traceNames[7].classNmme = "Board 23";\r
-\r
-               traceNames[8] = new TraceStrings();\r
-               traceNames[8].name = "TE Log - TATA BSC14";\r
-               traceNames[8].classNmme = "Board 11";\r
-\r
-               traceNames[9] = new TraceStrings();\r
-               traceNames[9].name = "TE Log - TATA BSC14";\r
-               traceNames[9].classNmme = "Board 14, SPO";\r
-\r
-               traceNames[10] = new TraceStrings();\r
-               traceNames[10].name = "INFO 1";\r
-               traceNames[10].classNmme = "All Boards";\r
-\r
-               traceNames[11] = new TraceStrings();\r
-               traceNames[11].name = "INFO2";\r
-               traceNames[11].classNmme = "BSC11";\r
-\r
-               traceNames[12] = new TraceStrings();\r
-               traceNames[12].name = "INFO3";\r
-               traceNames[12].classNmme = "Board 24";\r
-\r
-               traceNames[13] = new TraceStrings();\r
-               traceNames[13].name = "MISC1";\r
-               traceNames[13].classNmme = "Board 23";\r
-\r
-               traceNames[14] = new TraceStrings();\r
-               traceNames[14].name = "MISC2";\r
-               traceNames[14].classNmme = "Board 11";\r
-\r
-               traceNames[15] = new TraceStrings();\r
-               traceNames[15].name = "MISC3";\r
-               traceNames[15].classNmme = "Board 23";\r
-\r
-               traceNames[16] = new TraceStrings();\r
-               traceNames[16].name = "MISC4";\r
-               traceNames[16].classNmme = "Board 11";\r
-\r
-       }\r
-\r
-       // ========================================================================\r
-       // Inner Class\r
-       // ========================================================================\r
-       private static class TraceStrings {\r
-               public String name = "";\r
-               public String classNmme = name + " class";\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.model;
+
+import java.util.Date;
+
+@SuppressWarnings({"javadoc", "nls"})
+public class TraceModelImplFactory {
+
+       // ========================================================================
+       // Data
+       // ========================================================================
+       private int count = 0;
+       private final TraceStrings[] traceNames;
+       private static final long msTons = 1000000;
+       private final Long timeRef = new Date().getTime() * msTons;
+
+       // ========================================================================
+       // Constructor
+       // ========================================================================
+       public TraceModelImplFactory() {
+               traceNames = new TraceStrings[17];
+               loadTraceNameStrings();
+       }
+
+       // ========================================================================
+       // Methods
+       // ========================================================================
+       public TraceImpl[] createTraces() {
+               TraceImpl trace;
+               TraceImpl[] traceArr = new TraceImpl[17];
+               for (int i = 0; i < traceArr.length; i++) {
+                       trace = new TraceImpl(traceNames[i].name, timeRef, timeRef + 40,
+                                       traceNames[i].classNmme);
+                       count = i;
+                       createEvents(trace);
+                       traceArr[i] = trace;
+               }
+               return traceArr;
+       }
+
+       /**
+        * 5000 Events per Trace.
+        * @param number
+        * @return
+        */
+       public TraceImpl[] createLargeTraces(int number) {
+               TraceImpl trace;
+               TraceImpl[] traceArr = new TraceImpl[number];
+               for (int i = 0; i < traceArr.length; i++) {
+                       int counter = i%17;
+                       long sTime = i * (long) 1E6;
+                       trace = new TraceImpl(traceNames[counter].name, sTime  , sTime + 20000,
+                                       traceNames[counter].classNmme);
+                       create5000Events(trace);
+                       traceArr[i] = trace;
+               }
+               return traceArr;
+       }
+
+       private static void create5000Events(TraceImpl trace) {
+               EventImpl event;
+               Long eventTime;
+               int numEvents = 5000;
+               long sTime = trace.getStartTime();
+               long eTime = trace.getEndTime();
+               long duration = (eTime - sTime)/numEvents;
+               for (int i = 0; i < numEvents; i++) {
+                       eventTime = sTime + (i * duration);
+                       // eventTime = timeRef + (5 * (count % 4) + (5 * (int) (i/2) ));
+                       // System.out.println("Trace: " + trace.getName() + " EventTime: "
+                       // + eventTime);
+//                     duration = i * msTons + (long) ((i % 4));
+
+                       event = new EventImpl(eventTime, trace, getEventType(i%16));
+                       event.setDuration(duration);
+                       trace.addTraceEvent(event);
+               }
+       }
+
+       private void createEvents(TraceImpl trace) {
+               EventImpl event;
+               Long eventTime;
+               int numEvents = 17;
+               long duration = 0;
+               for (int i = 0; i < numEvents; i++) {
+                       eventTime = timeRef + msTons * i + (5 * msTons * count) + (5 * i);
+                       duration = msTons + i * msTons + ((i % 4));
+//                     duration = i  + (long) ((i % 4));
+                       event = new EventImpl(eventTime, trace, getEventType(i));
+                       event.setDuration(duration);
+                       trace.addTraceEvent(event);
+               }
+       }
+
+    private static EventImpl.Type getEventType(int val) {
+        if (EventImpl.Type.ALARM.ordinal() == val) {
+            return EventImpl.Type.ALARM;
+        }
+        if (EventImpl.Type.ERROR.ordinal() == val) {
+            return EventImpl.Type.ERROR;
+        }
+        if (EventImpl.Type.EVENT.ordinal() == val) {
+            return EventImpl.Type.EVENT;
+        }
+        if (EventImpl.Type.INFORMATION.ordinal() == val) {
+            return EventImpl.Type.INFORMATION;
+        }
+        if (EventImpl.Type.TIMEADJUSTMENT.ordinal() == val) {
+            return EventImpl.Type.TIMEADJUSTMENT;
+        }
+        if (EventImpl.Type.WARNING.ordinal() == val) {
+            return EventImpl.Type.WARNING;
+        }
+        if (EventImpl.Type.INFO1.ordinal() == val) {
+            return EventImpl.Type.INFO1;
+        }
+        if (EventImpl.Type.INFO2.ordinal() == val) {
+            return EventImpl.Type.INFO2;
+        }
+        if (EventImpl.Type.INFO3.ordinal() == val) {
+            return EventImpl.Type.INFO3;
+        }
+        if (EventImpl.Type.INFO4.ordinal() == val) {
+            return EventImpl.Type.INFO4;
+        }
+        if (EventImpl.Type.INFO5.ordinal() == val) {
+            return EventImpl.Type.INFO5;
+        }
+        if (EventImpl.Type.INFO6.ordinal() == val) {
+            return EventImpl.Type.INFO6;
+        }
+        if (EventImpl.Type.INFO7.ordinal() == val) {
+            return EventImpl.Type.INFO7;
+        }
+        if (EventImpl.Type.INFO8.ordinal() == val) {
+            return EventImpl.Type.INFO8;
+        }
+        if (EventImpl.Type.INFO9.ordinal() == val) {
+            return EventImpl.Type.INFO9;
+        }
+        return EventImpl.Type.UNKNOWN;
+    }
+
+       private void loadTraceNameStrings() {
+               traceNames[0] = new TraceStrings();
+               traceNames[0].name = "TE Log - TATA BSC11";
+               traceNames[0].classNmme = "All Boards";
+
+               traceNames[1] = new TraceStrings();
+               traceNames[1].name = "System Log";
+               traceNames[1].classNmme = "BSC11";
+
+               traceNames[2] = new TraceStrings();
+               traceNames[2].name = "Alarm Log";
+               traceNames[2].classNmme = "BSC11";
+
+               traceNames[3] = new TraceStrings();
+               traceNames[3].name = "Events Log";
+               traceNames[3].classNmme = "BSC 11";
+
+               traceNames[4] = new TraceStrings();
+               traceNames[4].name = "CPU Load";
+               traceNames[4].classNmme = "All Boards";
+
+               traceNames[5] = new TraceStrings();
+               traceNames[5].name = "Performance Log";
+               traceNames[5].classNmme = "BSC11";
+
+               traceNames[6] = new TraceStrings();
+               traceNames[6].name = "TE Log  - TATA BSC14";
+               traceNames[6].classNmme = "Board 24";
+
+               traceNames[7] = new TraceStrings();
+               traceNames[7].name = "TE Log - TATA BSC14";
+               traceNames[7].classNmme = "Board 23";
+
+               traceNames[8] = new TraceStrings();
+               traceNames[8].name = "TE Log - TATA BSC14";
+               traceNames[8].classNmme = "Board 11";
+
+               traceNames[9] = new TraceStrings();
+               traceNames[9].name = "TE Log - TATA BSC14";
+               traceNames[9].classNmme = "Board 14, SPO";
+
+               traceNames[10] = new TraceStrings();
+               traceNames[10].name = "INFO 1";
+               traceNames[10].classNmme = "All Boards";
+
+               traceNames[11] = new TraceStrings();
+               traceNames[11].name = "INFO2";
+               traceNames[11].classNmme = "BSC11";
+
+               traceNames[12] = new TraceStrings();
+               traceNames[12].name = "INFO3";
+               traceNames[12].classNmme = "Board 24";
+
+               traceNames[13] = new TraceStrings();
+               traceNames[13].name = "MISC1";
+               traceNames[13].classNmme = "Board 23";
+
+               traceNames[14] = new TraceStrings();
+               traceNames[14].name = "MISC2";
+               traceNames[14].classNmme = "Board 11";
+
+               traceNames[15] = new TraceStrings();
+               traceNames[15].name = "MISC3";
+               traceNames[15].classNmme = "Board 23";
+
+               traceNames[16] = new TraceStrings();
+               traceNames[16].name = "MISC4";
+               traceNames[16].classNmme = "Board 11";
+
+       }
+
+       // ========================================================================
+       // Inner Class
+       // ========================================================================
+       private static class TraceStrings {
+               public String name = "";
+               public String classNmme = name + " class";
+       }
+}
index 2952adc4eafe0ddaeb7bbe33a7974a6aaf721463..12cfe6ba8244d5fbe2d26cec00e6289d8f4fcb0a 100644 (file)
-<?xml version="1.0" encoding="UTF-8"?>\r
-<?eclipse version="3.4"?>\r
-<plugin>\r
-   <extension-point id="org.eclipse.linuxtools.tmf.ui.uml2SDLoader" name="TMF UML 2 Sequence Diagram Loader" schema="schema/org.eclipse.linuxtools.tmf.ui.uml2SDLoader.exsd"/>\r
-   <extension-point id="org.eclipse.linuxtools.tmf.ui.tracetype" name="Tmf Trace Type" schema="schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd"/>\r
-\r
-    <extension\r
-         point="org.eclipse.ui.perspectives">\r
-      <perspective\r
-            class="org.eclipse.linuxtools.tmf.ui.views.TracingPerspectiveFactory"\r
-            icon="icons/eview16/tracing_pers.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.perspective"\r
-            name="%perspective.category.name">\r
-      </perspective>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.views">\r
-      <category\r
-            id="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            name="%views.category.name">\r
-      </category>\r
-      <view\r
-            allowMultiple="false"\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.events.TmfEventsView"\r
-            icon="icons/eview16/events_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.events"\r
-            name="%events.view.name"\r
-            restorable="true">\r
-      </view>\r
-      <view\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartView"\r
-            icon="icons/eview16/timechart_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.timechart"\r
-            name="%timechart.view.name"\r
-            restorable="true">\r
-      </view> \r
-      <view\r
-            allowMultiple="false"\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.environment.TmfEnvironmentView"\r
-            icon="icons/eview16/events_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.environment"\r
-            name="%environment.view.name"\r
-            restorable="true">\r
-      </view>\r
-      <view\r
-            allowMultiple="false"\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.colors.ColorsView"\r
-            icon="icons/eview16/colors_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.colors"\r
-            name="%colors.view.name"\r
-            restorable="true">\r
-      </view> \r
-      <view\r
-            allowMultiple="false"\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.filter.FilterView"\r
-            icon="icons/eview16/filters_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.filter"\r
-            name="%filters.view.name"\r
-            restorable="true">\r
-      </view>\r
-      <view\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView"\r
-            icon="icons/eview16/sequencediagram_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.tmfUml2SDSyncView"\r
-            name="%uml2sd.view.name"\r
-            restorable="true">\r
-      </view>\r
-      <view\r
-            allowMultiple="false"\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.statistics.TmfStatisticsView"\r
-            icon="icons/eview16/statistics_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.statistics"\r
-            name="%statistics.view.name"\r
-            restorable="true">\r
-      </view>\r
-      <view\r
-            allowMultiple="false"\r
-            category="org.eclipse.linuxtools.tmf.ui.views.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramView"\r
-            icon="icons/eview16/histogram.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.histogram"\r
-            name="%histogram.view.name"\r
-            restorable="true">\r
-      </view>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.editors">\r
-      <editor\r
-            class="org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor"\r
-            default="false"\r
-            icon="icons/eview16/events_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.editors.events"\r
-            name="%events.editor.name">\r
-         <contentTypeBinding\r
-               contentTypeId="org.eclipse.linuxtools.tmf.ui.content-type.trace">\r
-         </contentTypeBinding>\r
-      </editor>\r
-      <editor\r
-            class="org.eclipse.linuxtools.tmf.ui.editors.EventsViewEditor"\r
-            default="false"\r
-            icon="icons/eview16/events_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.editors.eventsView"\r
-            name="%eventsview.editor.name">\r
-         <contentTypeBinding\r
-               contentTypeId="org.eclipse.linuxtools.tmf.ui.content-type.trace">\r
-         </contentTypeBinding>\r
-      </editor>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.newWizards">\r
-      <category\r
-            id="org.eclipse.linuxtools.tmf.ui.wizards.new"\r
-            name="%project.new.category.name">\r
-      </category>\r
-      <wizard\r
-            category="org.eclipse.linuxtools.tmf.ui.wizards.new"\r
-            class="org.eclipse.linuxtools.tmf.ui.project.wizards.NewTmfProjectWizard"\r
-            icon="icons/elcl16/new_tracing_prj.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.ui.wizards.newProject"\r
-            name="%project.new.wizard.name"\r
-            project="true">\r
-         <description>\r
-            %project.new.wizard.description\r
-            \r
-         </description>\r
-      </wizard>\r
-      <wizard\r
-            category="org.eclipse.linuxtools.tmf.ui.wizards.new"\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomTxtParserWizard"\r
-            icon="icons/etool16/customparser_wizard.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.wizards.custom.text"\r
-            name="%project.new.wizard.custom.text.parser">\r
-      </wizard>\r
-      <wizard\r
-            category="org.eclipse.linuxtools.tmf.ui.wizards.new"\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomXmlParserWizard"\r
-            icon="icons/etool16/customparser_wizard.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.wizards.custom.xml"\r
-            name="%project.new.wizard.custom.xml.parser">\r
-      </wizard>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.importWizards">\r
-      <category\r
-            id="org.eclipse.linuxtools.tmf.import.category"\r
-            name="%project.new.category.name">\r
-      </category>\r
-      <wizard\r
-            category="org.eclipse.linuxtools.tmf.import.category"\r
-            class="org.eclipse.linuxtools.tmf.ui.project.wizards.ImportTraceWizard"\r
-            icon="icons/etool16/import.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.trace.import.wizard"\r
-            name="%project.import.wizard.name">\r
-      </wizard>\r
-   </extension>\r
-   <extension\r
-         id="org.eclipse.linuxtools.tmf.project.nature"\r
-         point="org.eclipse.core.resources.natures">\r
-      <runtime>\r
-         <run\r
-               class="org.eclipse.linuxtools.tmf.core.TmfProjectNature">\r
-         </run>\r
-      </runtime>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.ide.projectNatureImages">\r
-      <image\r
-            icon="icons/ovr16/trace_nature_ovr.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.nature.image"\r
-            natureId="org.eclipse.linuxtools.tmf.project.nature">\r
-      </image>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.navigator.navigatorContent">\r
-      <navigatorContent\r
-            activeByDefault="true"\r
-            contentProvider="org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider"\r
-            icon="icons/eview16/tracing_pers.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.navigator.content"\r
-            labelProvider="org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorLabelProvider"\r
-            name="%navigatorContent.name"\r
-            priority="normal">\r
-         <triggerPoints>\r
-            <or>\r
-               <and>\r
-                  <instanceof\r
-                        value="org.eclipse.core.resources.IProject">\r
-                  </instanceof>\r
-                  <test\r
-                        property="org.eclipse.core.resources.projectNature"\r
-                        value="org.eclipse.linuxtools.tmf.project.nature">\r
-                  </test>\r
-               </and>\r
-               <instanceof\r
-                     value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">\r
-               </instanceof>\r
-            </or>\r
-         </triggerPoints>\r
-         <possibleChildren>\r
-            <or>\r
-               <instanceof\r
-                     value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">\r
-               </instanceof>\r
-               <instanceof\r
-                     value="org.eclipse.core.resources.IResource">\r
-               </instanceof>\r
-            </or></possibleChildren>\r
-         <override\r
-               policy="InvokeAlwaysRegardlessOfSuppressedExt"\r
-               suppressedExtensionId="org.eclipse.ui.navigator.resourceContent">\r
-         </override>\r
-         <actionProvider\r
-               class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.TmfActionProvider"\r
-               id="org.eclipse.linuxtools.tmf.ui.navigator.actions.provider">\r
-            <enablement>\r
-               <or>\r
-                  <instanceof\r
-                        value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">\r
-                  </instanceof>\r
-               </or>\r
-            </enablement>\r
-         </actionProvider>\r
-         <dropAssistant\r
-               class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DropAdapterAssistant"\r
-               id="org.eclipse.linuxtools.tmf.ui.navigator.dropAssistant">\r
-            <possibleDropTargets>\r
-               <or>\r
-                  <and>\r
-                     <instanceof\r
-                           value="org.eclipse.core.resources.IProject">\r
-                     </instanceof>\r
-                     <test\r
-                           property="org.eclipse.core.resources.projectNature"\r
-                           value="org.eclipse.linuxtools.tmf.project.nature">\r
-                     </test>\r
-                  </and>\r
-                  <instanceof\r
-                        value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">\r
-                  </instanceof>\r
-               </or>\r
-            </possibleDropTargets>\r
-         </dropAssistant>\r
-         <commonWizard\r
-               menuGroupId="org.eclipse.linuxtools.tmf.ui.views.ui.wizards.menuGroupId"\r
-               type="new"\r
-               wizardId="org.eclipse.linuxtools.tmf.ui.views.ui.wizards.newProject">\r
-            <enablement></enablement>\r
-         </commonWizard>\r
-      </navigatorContent>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.navigator.viewer">\r
-      <viewerContentBinding\r
-            viewerId="org.eclipse.ui.navigator.ProjectExplorer">\r
-         <includes>\r
-            <contentExtension\r
-                  pattern="org.eclipse.linuxtools.tmf.ui.navigator.content">\r
-            </contentExtension>\r
-            <contentExtension\r
-                  pattern="org.eclipse.ui.navigator.resources.filters.*">\r
-            </contentExtension>\r
-         </includes>\r
-      </viewerContentBinding>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.decorators">\r
-      <decorator\r
-            icon="icons/ovr16/trace_folder_ovr.png"\r
-            id="org.eclipse.linuxtools.tmf.ui.trace_folder.decorator"\r
-            label="Trace Folder"\r
-            lightweight="true"\r
-            location="TOP_RIGHT"\r
-            state="true">\r
-         <enablement>\r
-            <objectClass\r
-                  name="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">\r
-            </objectClass>\r
-         </enablement>\r
-      </decorator>\r
-      <decorator\r
-            icon="icons/ovr16/experiment_folder_ovr.png"\r
-            id="org.eclipse.linuxtools.tmf.ui.experiment_folder.decorator"\r
-            label="Trace Experiment Folder"\r
-            lightweight="true"\r
-            location="TOP_RIGHT"\r
-            state="true">\r
-         <enablement>\r
-            <objectClass\r
-                  name="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder">\r
-            </objectClass>\r
-         </enablement>\r
-      </decorator>\r
-      <decorator\r
-            icon="icons/ovr16/link_ovr.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.linked_trace.decorator"\r
-            label="Linked Trace"\r
-            lightweight="true"\r
-            location="BOTTOM_RIGHT"\r
-            state="true">\r
-         <enablement>\r
-            <and>\r
-               <objectClass\r
-                     name="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-               </objectClass>\r
-               <objectState\r
-                     name="isLinked"\r
-                     value="true">\r
-               </objectState>\r
-            </and>\r
-         </enablement>\r
-      </decorator>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.menus">\r
-      <menuContribution\r
-            locationURI="menu:org.eclipse.ui.navigator.ProjectExplorer">\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"\r
-               id="org.eclipse.linuxtools.tmf.ui.menu.managecustomparsers"\r
-               style="push">\r
-         </command>\r
-      </menuContribution>\r
-      <menuContribution\r
-            locationURI="popup:org.eclipse.ui.popup.any?after=additions">\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.import"\r
-               disabledIcon="icons/dtool16/import.gif"\r
-               icon="icons/etool16/import.gif"\r
-               label="%commands.trace_folder.import"\r
-               mnemonic="%commands.trace_folder.import.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace_folder.import.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator1"\r
-               visible="true">\r
-         </separator>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh"\r
-               disabledIcon="icons/dlcl16/refresh.gif"\r
-               icon="icons/elcl16/refresh.gif"\r
-               label="%commands.trace_folder.refresh"\r
-               mnemonic="%commands.trace_folder.refresh.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace_folder.refresh.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.open"\r
-               disabledIcon="icons/dlcl16/open.gif"\r
-               icon="icons/elcl16/open.gif"\r
-               label="%commands.trace.open"\r
-               mnemonic="%commands.trace.open.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.open.descritption">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy"\r
-               disabledIcon="IMG_TOOL_COPY_DISABLED"\r
-               icon="IMG_TOOL_COPY"\r
-               label="%commands.trace.copy"\r
-               mnemonic="%commands.trace.copy.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.copy.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename"\r
-               disabledIcon="icons/dlcl16/rename.gif"\r
-               icon="icons/elcl16/rename.gif"\r
-               label="%commands.trace.rename"\r
-               mnemonic="%commands.trace.rename.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.rename.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"\r
-               disabledIcon="IMG_ETOOL_DELETE_DISABLED"\r
-               icon="IMG_ETOOL_DELETE"\r
-               label="%commands.trace.delete"\r
-               mnemonic="%commands.trace.delete.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.delete.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <and>\r
-                        <instanceof\r
-                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                        </instanceof>\r
-                        <not>\r
-                           <test\r
-                                 forcePluginActivation="true"\r
-                                 property="org.eclipse.linuxtools.tmf.ui.isExperimentTrace">\r
-                           </test>\r
-                        </not>\r
-                     </and>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"\r
-               disabledIcon="IMG_ETOOL_DELETE_DISABLED"\r
-               icon="IMG_ETOOL_DELETE"\r
-               label="%commands.trace.remove"\r
-               mnemonic="%commands.trace.remove.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.remove.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <and>\r
-                        <instanceof\r
-                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                        </instanceof>\r
-                        <test\r
-                              forcePluginActivation="true"\r
-                              property="org.eclipse.linuxtools.tmf.ui.isExperimentTrace">\r
-                        </test>\r
-                     </and>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator2"\r
-               visible="true">\r
-         </separator>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.deleteSupplementaryFiles"\r
-               label="%commands.trace.deleteSupplementaryFiles"\r
-               mnemonic="%commands.trace.deleteSupplementaryFiles.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.deleteSupplementaryFiles.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <iterate\r
-                       ifEmpty="false"\r
-                       operator="and">\r
-                     <and>\r
-                        <instanceof\r
-                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                        </instanceof>\r
-                        <test\r
-                              forcePluginActivation="true"\r
-                              property="org.eclipse.linuxtools.tmf.ui.hasSupplementaryFiles">\r
-                        </test>\r
-                     </and>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator3"\r
-               visible="true">\r
-         </separator>\r
-         <menu\r
-               label="%commands.trace.select_trace_type"\r
-               mnemonic="%commands.trace.select_trace_type.mnemonic"\r
-               tooltip="%commands.trace.select_trace_type.description">\r
-            <dynamic\r
-                  class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTraceTypeContributionItem"\r
-                  id="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type.dynamic">\r
-            </dynamic>\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </menu>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new"\r
-               disabledIcon="icons/dtool16/new.gif"\r
-               icon="icons/etool16/new.gif"\r
-               label="%commands.experiment_folder.new"\r
-               mnemonic="%commands.experiment_folder.new.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.trace.select_trace_type">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator4"\r
-               visible="true">\r
-         </separator>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh"\r
-               disabledIcon="icons/dlcl16/refresh.gif"\r
-               icon="icons/elcl16/refresh.gif"\r
-               label="%commands.experiment_folder.refresh"\r
-               mnemonic="%commands.experiment_folder.refresh.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment_folder.refresh.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.select"\r
-               icon="IMG_OBJ_ADD"\r
-               label="%commands.experiment.selecttraces"\r
-               mnemonic="%commands.experiment.selecttraces.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.selecttraces.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator5"\r
-               visible="true">\r
-         </separator>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.open"\r
-               icon="icons/elcl16/open.gif"\r
-               label="%commands.experiment.open"\r
-               mnemonic="%commands.experiment.open.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.open.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy"\r
-               disabledIcon="IMG_TOOL_COPY_DISABLED"\r
-               icon="IMG_TOOL_COPY"\r
-               label="%commands.experiment.copy"\r
-               mnemonic="%commands.experiment.copy.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.copy.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename"\r
-               icon="icons/elcl16/rename.gif"\r
-               label="%commands.experiment.rename"\r
-               mnemonic="%commands.experiment.rename.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.rename.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete"\r
-               disabledIcon="IMG_ETOOL_DELETE_DISABLED"\r
-               icon="IMG_ETOOL_DELETE"\r
-               label="%commands.experiment.delete"\r
-               mnemonic="%commands.experiment.delete.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.delete.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator6"\r
-               visible="true">\r
-         </separator>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.deleteSupplementaryFiles"\r
-               label="%commands.experiment.deleteSupplementaryFiles"\r
-               mnemonic="%commands.experiment.deleteSupplementaryFiles.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.deleteSupplementaryFiles.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <iterate\r
-                       ifEmpty="false"\r
-                       operator="and">\r
-                     <and>\r
-                        <instanceof\r
-                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                        </instanceof>\r
-                        <test\r
-                              forcePluginActivation="true"\r
-                              property="org.eclipse.linuxtools.tmf.ui.hasSupplementaryFiles">\r
-                        </test>\r
-                     </and>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-         <separator\r
-               name="org.eclipse.linuxtools.tmf.ui.separator7"\r
-               visible="true">\r
-         </separator>\r
-         <command\r
-               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh"\r
-               disabledIcon="icons/dlcl16/refresh.gif"\r
-               icon="icons/elcl16/refresh.gif"\r
-               label="%commands.experiment.refresh"\r
-               mnemonic="%commands.experiment.refresh.mnemonic"\r
-               style="push"\r
-               tooltip="%commands.experiment.refresh.description">\r
-            <visibleWhen\r
-                  checkEnabled="false">\r
-               <with\r
-                     variable="selection">\r
-                  <count\r
-                        value="1">\r
-                  </count>\r
-                  <iterate\r
-                        ifEmpty="false"\r
-                        operator="and">\r
-                     <instanceof\r
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">\r
-                     </instanceof>\r
-                  </iterate>\r
-               </with>\r
-            </visibleWhen>\r
-         </command>\r
-      </menuContribution>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.commands">\r
-      <category\r
-            description="%commands.trace_folder.category.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category"\r
-            name="%commands.trace_folder.category.name">\r
-      </category>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category"\r
-            description="%commands.trace_folder.import.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.import"\r
-            name="%commands.trace_folder.import">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category"\r
-            description="%commands.trace_folder.refresh.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh"\r
-            name="%commands.trace_folder.refresh">\r
-      </command>\r
-      <category\r
-            description="%commands.trace.category.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            name="%commands.trace.category.name">\r
-      </category>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            description="%commands.trace.open.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.open"\r
-            name="%commands.trace.open">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            description="%commands.trace.copy.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy"\r
-            name="%commands.trace.copy">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            description="%commands.trace.rename.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename"\r
-            name="%commands.trace.rename">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            description="%commands.trace.deleteSupplementaryFiles.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.deleteSupplementaryFiles"\r
-            name="%commands.trace.deleteSupplementaryFiles">\r
-      </command>\r
-      <category\r
-            description="%commands.experiment_folder.category.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.commands.experiment_folder.category"\r
-            name="%commands.experiment_folder.category.name">\r
-      </category>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment_folder.category"\r
-            description="%commands.experiment_folder.new.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new"\r
-            name="%commands.experiment_folder.new">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment_folder.category"\r
-            description="%commands.experiment_folder.refresh.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh"\r
-            name="%commands.experiment_folder.refresh">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            description="%commands.trace.select_trace_type.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type"\r
-            name="%commands.trace.select_trace_type">\r
-         <commandParameter\r
-               id="org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"\r
-               name="%commands.trace.select_trace_type.bundle"\r
-               optional="false">\r
-         </commandParameter>\r
-         <commandParameter\r
-               id="org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"\r
-               name="%commands.trace.select_trace_type.type"\r
-               optional="false">\r
-         </commandParameter>\r
-         <commandParameter\r
-               id="org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"\r
-               name="%commands.trace.select_trace_type.icon"\r
-               optional="false">\r
-         </commandParameter>\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"\r
-            description="%commands.trace.delete.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"\r
-            name="%commands.trace.delete">\r
-      </command>\r
-      <category\r
-            description="%commands.experiment.category.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            name="%commands.experiment.category.name">\r
-      </category>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.selecttraces.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.select"\r
-            name="%commands.experiment.selecttraces">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.open.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.open"\r
-            name="%commands.experiment.open">\r
-      </command>\r
-       <command\r
-             categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.copy.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy"\r
-            name="%commands.experiment.copy">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.rename.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename"\r
-            name="%commands.experiment.rename">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.delete.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete"\r
-            name="%commands.experiment.delete">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.deleteSupplementaryFiles.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.deleteSupplementaryFiles"\r
-            name="%commands.experiment.deleteSupplementaryFiles">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"\r
-            description="%commands.experiment.refresh.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh"\r
-            name="%commands.experiment.refresh">\r
-      </command>\r
-      <category\r
-            description="%commands.parser.category.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.commands.parser.category"\r
-            name="%commands.parser.category.name">\r
-      </category>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.commands.parser.category"\r
-            description="%commands.parser.manage.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"\r
-            name="%commands.parser.manage">\r
-      </command>\r
-      <category\r
-            description="%commands.uml2sd.category.name"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"    \r
-            name="%commands.uml2sd.category.name">\r
-      </category>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.goto.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.GoToMessage"\r
-            name="%commands.uml2sd.goto">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.showend.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd"\r
-            name="%commands.uml2sd.showend">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.showstart.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart"\r
-            name="%commands.uml2sd.showstart">\r
-      </command>      \r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.scrollup.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDUp"\r
-            name="%commands.uml2sd.scrollup">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.scrolldown.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDDown"\r
-            name="%commands.uml2sd.scrolldown">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.scrollleft.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDLeft"\r
-            name="%commands.uml2sd.scrollleft">\r
-      </command>\r
-      <command\r
-            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"\r
-            description="%commands.uml2sd.scrollright.description"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDRight"\r
-            name="%commands.uml2sd.scrollright">\r
-      </command>\r
-   </extension>\r
-   <extension point="org.eclipse.ui.bindings">\r
-      <key\r
-            sequence="ALT+R"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.GoToMessage"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>   \r
-      <key\r
-            sequence="SHIFT+ALT+END"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>   \r
-      <key\r
-            sequence="SHIFT+ALT+HOME"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>    \r
-      <key\r
-            sequence="SHIFT+ALT+ARROW_UP"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDUp"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>  \r
-      <key\r
-            sequence="SHIFT+ALT+ARROW_DOWN"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDDown"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>\r
-      <key\r
-            sequence="SHIFT+ALT+ARROW_LEFT"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDLeft"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>\r
-      <key\r
-            sequence="SHIFT+ALT+ARROW_RIGHT"\r
-            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDRight"\r
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">\r
-      </key>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.handlers">\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.ImportTraceHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.import">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.OpenTraceHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.open">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.CopyTraceHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RenameTraceHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteTraceHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteTraceSupplementaryFilesHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.deleteSupplementaryFiles">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTraceTypeHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.NewExperimentHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTracesHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.select">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.OpenExperimentHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.open">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.CopyExperimentHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RenameExperimentHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteExperimentHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteExperimentSupplementaryFilesHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.deleteSupplementaryFiles">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.commands.ManageCustomParsersCommandHandler"\r
-            commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers">\r
-      </handler>\r
-      <handler\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.editors.handlers.AddBookmarkHandler"\r
-            commandId="org.eclipse.ui.edit.addBookmark">\r
-         <activeWhen>\r
-            <with\r
-                  variable="activeEditor">\r
-               <instanceof\r
-                     value="org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor">\r
-               </instanceof>\r
-            </with>\r
-         </activeWhen>\r
-      </handler>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.core.contenttype.contentTypes">\r
-      <content-type\r
-            id="org.eclipse.linuxtools.tmf.ui.content-type.trace"\r
-            name="%contenttype.trace"\r
-            priority="normal">\r
-      </content-type>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.contexts">\r
-      <context\r
-            id="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"\r
-            name="%contexts.uml2sd">\r
-      </context>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.preferencePages">\r
-      <page\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.preferences.TmfTracingPreferencePage"\r
-            id="org.eclipse.linuxtools.tmf.ui.TmfTracingPreferences"\r
-            name="%preference.page.trace.name">\r
-      </page>\r
-      <page\r
-            category="org.eclipse.linuxtools.tmf.ui.TmfTracingPreferences"\r
-            class="org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewerPage"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewerPage"\r
-            name="%preference.page.uml2sd.name">\r
-      </page>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.linuxtools.tmf.ui.uml2SDLoader">\r
-      <uml2SDLoader\r
-            class="org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader"\r
-            default="true"\r
-            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl.TmfUml2SDSyncLoader"\r
-            name="TMF UML2SD Loader"\r
-            view="org.eclipse.linuxtools.tmf.ui.tmfUml2SDSyncView">\r
-      </uml2SDLoader>\r
-   </extension>\r
-   <!--extension\r
-         point="org.eclipse.core.expressions.propertyTesters">\r
-      <propertyTester\r
-            class="org.eclipse.linuxtools.tmf.ui.project.handlers.PropertyTester"\r
-            id="org.eclipse.linuxtools.tmf.ui.propertyTester.isInTraceFolder"\r
-            namespace="org.eclipse.linuxtools.tmf.ui.propertyTester"\r
-            properties="isInTraceFolder"\r
-            type="org.eclipse.jface.viewers.ISelection">\r
-      </propertyTester>\r
-   </extension -->\r
-   <extension\r
-         point="org.eclipse.core.expressions.propertyTesters">\r
-      <propertyTester\r
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.TracePropertyTester"\r
-            id="org.eclipse.linuxtools.tmf.ui.tracePropertyTester"\r
-            namespace="org.eclipse.linuxtools.tmf.ui"\r
-            properties="isExperimentTrace,hasSupplementaryFiles"\r
-            type="org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement">\r
-      </propertyTester>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.linuxtools.tmf.ui.tracetype">\r
-      <category\r
-            id="org.eclipse.linuxtools.tmf.ui.category.ctf"\r
-            name="%tracetype.category.ctf">\r
-      </category>\r
-      <type\r
-            category="org.eclipse.linuxtools.tmf.ui.category.ctf"\r
-            event_type="org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent"\r
-            icon="icons/eview16/events_view.gif"\r
-            id="org.eclipse.linuxtools.tmf.ui.type.ctf"\r
-            name="%tracetype.type.ctf"\r
-            trace_type="org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace">\r
-      </type>\r
-   </extension>\r
-\r
-</plugin>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension-point id="org.eclipse.linuxtools.tmf.ui.uml2SDLoader" name="TMF UML 2 Sequence Diagram Loader" schema="schema/org.eclipse.linuxtools.tmf.ui.uml2SDLoader.exsd"/>
+   <extension-point id="org.eclipse.linuxtools.tmf.ui.tracetype" name="Tmf Trace Type" schema="schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd"/>
+
+    <extension
+         point="org.eclipse.ui.perspectives">
+      <perspective
+            class="org.eclipse.linuxtools.tmf.ui.views.TracingPerspectiveFactory"
+            icon="icons/eview16/tracing_pers.gif"
+            id="org.eclipse.linuxtools.tmf.ui.perspective"
+            name="%perspective.category.name">
+      </perspective>
+   </extension>
+   <extension
+         point="org.eclipse.ui.views">
+      <category
+            id="org.eclipse.linuxtools.tmf.ui.views.category"
+            name="%views.category.name">
+      </category>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.events.TmfEventsView"
+            icon="icons/eview16/events_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.events"
+            name="%events.view.name"
+            restorable="true">
+      </view>
+      <view
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartView"
+            icon="icons/eview16/timechart_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.timechart"
+            name="%timechart.view.name"
+            restorable="true">
+      </view> 
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.environment.TmfEnvironmentView"
+            icon="icons/eview16/events_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.environment"
+            name="%environment.view.name"
+            restorable="true">
+      </view>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.colors.ColorsView"
+            icon="icons/eview16/colors_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.colors"
+            name="%colors.view.name"
+            restorable="true">
+      </view> 
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.filter.FilterView"
+            icon="icons/eview16/filters_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.filter"
+            name="%filters.view.name"
+            restorable="true">
+      </view>
+      <view
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView"
+            icon="icons/eview16/sequencediagram_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.tmfUml2SDSyncView"
+            name="%uml2sd.view.name"
+            restorable="true">
+      </view>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.statistics.TmfStatisticsView"
+            icon="icons/eview16/statistics_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.statistics"
+            name="%statistics.view.name"
+            restorable="true">
+      </view>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramView"
+            icon="icons/eview16/histogram.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.histogram"
+            name="%histogram.view.name"
+            restorable="true">
+      </view>
+   </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor"
+            default="false"
+            icon="icons/eview16/events_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.editors.events"
+            name="%events.editor.name">
+         <contentTypeBinding
+               contentTypeId="org.eclipse.linuxtools.tmf.ui.content-type.trace">
+         </contentTypeBinding>
+      </editor>
+      <editor
+            class="org.eclipse.linuxtools.tmf.ui.editors.EventsViewEditor"
+            default="false"
+            icon="icons/eview16/events_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.editors.eventsView"
+            name="%eventsview.editor.name">
+         <contentTypeBinding
+               contentTypeId="org.eclipse.linuxtools.tmf.ui.content-type.trace">
+         </contentTypeBinding>
+      </editor>
+   </extension>
+   <extension
+         point="org.eclipse.ui.newWizards">
+      <category
+            id="org.eclipse.linuxtools.tmf.ui.wizards.new"
+            name="%project.new.category.name">
+      </category>
+      <wizard
+            category="org.eclipse.linuxtools.tmf.ui.wizards.new"
+            class="org.eclipse.linuxtools.tmf.ui.project.wizards.NewTmfProjectWizard"
+            icon="icons/elcl16/new_tracing_prj.gif"
+            id="org.eclipse.linuxtools.tmf.ui.views.ui.wizards.newProject"
+            name="%project.new.wizard.name"
+            project="true">
+         <description>
+            %project.new.wizard.description
+            
+         </description>
+      </wizard>
+      <wizard
+            category="org.eclipse.linuxtools.tmf.ui.wizards.new"
+            class="org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomTxtParserWizard"
+            icon="icons/etool16/customparser_wizard.gif"
+            id="org.eclipse.linuxtools.tmf.ui.wizards.custom.text"
+            name="%project.new.wizard.custom.text.parser">
+      </wizard>
+      <wizard
+            category="org.eclipse.linuxtools.tmf.ui.wizards.new"
+            class="org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomXmlParserWizard"
+            icon="icons/etool16/customparser_wizard.gif"
+            id="org.eclipse.linuxtools.tmf.ui.wizards.custom.xml"
+            name="%project.new.wizard.custom.xml.parser">
+      </wizard>
+   </extension>
+   <extension
+         point="org.eclipse.ui.importWizards">
+      <category
+            id="org.eclipse.linuxtools.tmf.import.category"
+            name="%project.new.category.name">
+      </category>
+      <wizard
+            category="org.eclipse.linuxtools.tmf.import.category"
+            class="org.eclipse.linuxtools.tmf.ui.project.wizards.ImportTraceWizard"
+            icon="icons/etool16/import.gif"
+            id="org.eclipse.linuxtools.tmf.ui.trace.import.wizard"
+            name="%project.import.wizard.name">
+      </wizard>
+   </extension>
+   <extension
+         id="org.eclipse.linuxtools.tmf.project.nature"
+         point="org.eclipse.core.resources.natures">
+      <runtime>
+         <run
+               class="org.eclipse.linuxtools.tmf.core.TmfProjectNature">
+         </run>
+      </runtime>
+   </extension>
+   <extension
+         point="org.eclipse.ui.ide.projectNatureImages">
+      <image
+            icon="icons/ovr16/trace_nature_ovr.gif"
+            id="org.eclipse.linuxtools.tmf.ui.nature.image"
+            natureId="org.eclipse.linuxtools.tmf.project.nature">
+      </image>
+   </extension>
+   <extension
+         point="org.eclipse.ui.navigator.navigatorContent">
+      <navigatorContent
+            activeByDefault="true"
+            contentProvider="org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider"
+            icon="icons/eview16/tracing_pers.gif"
+            id="org.eclipse.linuxtools.tmf.ui.navigator.content"
+            labelProvider="org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorLabelProvider"
+            name="%navigatorContent.name"
+            priority="normal">
+         <triggerPoints>
+            <or>
+               <and>
+                  <instanceof
+                        value="org.eclipse.core.resources.IProject">
+                  </instanceof>
+                  <test
+                        property="org.eclipse.core.resources.projectNature"
+                        value="org.eclipse.linuxtools.tmf.project.nature">
+                  </test>
+               </and>
+               <instanceof
+                     value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">
+               </instanceof>
+            </or>
+         </triggerPoints>
+         <possibleChildren>
+            <or>
+               <instanceof
+                     value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">
+               </instanceof>
+               <instanceof
+                     value="org.eclipse.core.resources.IResource">
+               </instanceof>
+            </or></possibleChildren>
+         <override
+               policy="InvokeAlwaysRegardlessOfSuppressedExt"
+               suppressedExtensionId="org.eclipse.ui.navigator.resourceContent">
+         </override>
+         <actionProvider
+               class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.TmfActionProvider"
+               id="org.eclipse.linuxtools.tmf.ui.navigator.actions.provider">
+            <enablement>
+               <or>
+                  <instanceof
+                        value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">
+                  </instanceof>
+               </or>
+            </enablement>
+         </actionProvider>
+         <dropAssistant
+               class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DropAdapterAssistant"
+               id="org.eclipse.linuxtools.tmf.ui.navigator.dropAssistant">
+            <possibleDropTargets>
+               <or>
+                  <and>
+                     <instanceof
+                           value="org.eclipse.core.resources.IProject">
+                     </instanceof>
+                     <test
+                           property="org.eclipse.core.resources.projectNature"
+                           value="org.eclipse.linuxtools.tmf.project.nature">
+                     </test>
+                  </and>
+                  <instanceof
+                        value="org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement">
+                  </instanceof>
+               </or>
+            </possibleDropTargets>
+         </dropAssistant>
+         <commonWizard
+               menuGroupId="org.eclipse.linuxtools.tmf.ui.views.ui.wizards.menuGroupId"
+               type="new"
+               wizardId="org.eclipse.linuxtools.tmf.ui.views.ui.wizards.newProject">
+            <enablement></enablement>
+         </commonWizard>
+      </navigatorContent>
+   </extension>
+   <extension
+         point="org.eclipse.ui.navigator.viewer">
+      <viewerContentBinding
+            viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+         <includes>
+            <contentExtension
+                  pattern="org.eclipse.linuxtools.tmf.ui.navigator.content">
+            </contentExtension>
+            <contentExtension
+                  pattern="org.eclipse.ui.navigator.resources.filters.*">
+            </contentExtension>
+         </includes>
+      </viewerContentBinding>
+   </extension>
+   <extension
+         point="org.eclipse.ui.decorators">
+      <decorator
+            icon="icons/ovr16/trace_folder_ovr.png"
+            id="org.eclipse.linuxtools.tmf.ui.trace_folder.decorator"
+            label="Trace Folder"
+            lightweight="true"
+            location="TOP_RIGHT"
+            state="true">
+         <enablement>
+            <objectClass
+                  name="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
+            </objectClass>
+         </enablement>
+      </decorator>
+      <decorator
+            icon="icons/ovr16/experiment_folder_ovr.png"
+            id="org.eclipse.linuxtools.tmf.ui.experiment_folder.decorator"
+            label="Trace Experiment Folder"
+            lightweight="true"
+            location="TOP_RIGHT"
+            state="true">
+         <enablement>
+            <objectClass
+                  name="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder">
+            </objectClass>
+         </enablement>
+      </decorator>
+      <decorator
+            icon="icons/ovr16/link_ovr.gif"
+            id="org.eclipse.linuxtools.tmf.ui.linked_trace.decorator"
+            label="Linked Trace"
+            lightweight="true"
+            location="BOTTOM_RIGHT"
+            state="true">
+         <enablement>
+            <and>
+               <objectClass
+                     name="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+               </objectClass>
+               <objectState
+                     name="isLinked"
+                     value="true">
+               </objectState>
+            </and>
+         </enablement>
+      </decorator>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="menu:org.eclipse.ui.navigator.ProjectExplorer">
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"
+               id="org.eclipse.linuxtools.tmf.ui.menu.managecustomparsers"
+               style="push">
+         </command>
+      </menuContribution>
+      <menuContribution
+            locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.import"
+               disabledIcon="icons/dtool16/import.gif"
+               icon="icons/etool16/import.gif"
+               label="%commands.trace_folder.import"
+               mnemonic="%commands.trace_folder.import.mnemonic"
+               style="push"
+               tooltip="%commands.trace_folder.import.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator1"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh"
+               disabledIcon="icons/dlcl16/refresh.gif"
+               icon="icons/elcl16/refresh.gif"
+               label="%commands.trace_folder.refresh"
+               mnemonic="%commands.trace_folder.refresh.mnemonic"
+               style="push"
+               tooltip="%commands.trace_folder.refresh.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.open"
+               disabledIcon="icons/dlcl16/open.gif"
+               icon="icons/elcl16/open.gif"
+               label="%commands.trace.open"
+               mnemonic="%commands.trace.open.mnemonic"
+               style="push"
+               tooltip="%commands.trace.open.descritption">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy"
+               disabledIcon="IMG_TOOL_COPY_DISABLED"
+               icon="IMG_TOOL_COPY"
+               label="%commands.trace.copy"
+               mnemonic="%commands.trace.copy.mnemonic"
+               style="push"
+               tooltip="%commands.trace.copy.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename"
+               disabledIcon="icons/dlcl16/rename.gif"
+               icon="icons/elcl16/rename.gif"
+               label="%commands.trace.rename"
+               mnemonic="%commands.trace.rename.mnemonic"
+               style="push"
+               tooltip="%commands.trace.rename.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"
+               disabledIcon="IMG_ETOOL_DELETE_DISABLED"
+               icon="IMG_ETOOL_DELETE"
+               label="%commands.trace.delete"
+               mnemonic="%commands.trace.delete.mnemonic"
+               style="push"
+               tooltip="%commands.trace.delete.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <and>
+                        <instanceof
+                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                        </instanceof>
+                        <not>
+                           <test
+                                 forcePluginActivation="true"
+                                 property="org.eclipse.linuxtools.tmf.ui.isExperimentTrace">
+                           </test>
+                        </not>
+                     </and>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"
+               disabledIcon="IMG_ETOOL_DELETE_DISABLED"
+               icon="IMG_ETOOL_DELETE"
+               label="%commands.trace.remove"
+               mnemonic="%commands.trace.remove.mnemonic"
+               style="push"
+               tooltip="%commands.trace.remove.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <and>
+                        <instanceof
+                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                        </instanceof>
+                        <test
+                              forcePluginActivation="true"
+                              property="org.eclipse.linuxtools.tmf.ui.isExperimentTrace">
+                        </test>
+                     </and>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator2"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.deleteSupplementaryFiles"
+               label="%commands.trace.deleteSupplementaryFiles"
+               mnemonic="%commands.trace.deleteSupplementaryFiles.mnemonic"
+               style="push"
+               tooltip="%commands.trace.deleteSupplementaryFiles.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <iterate
+                       ifEmpty="false"
+                       operator="and">
+                     <and>
+                        <instanceof
+                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                        </instanceof>
+                        <test
+                              forcePluginActivation="true"
+                              property="org.eclipse.linuxtools.tmf.ui.hasSupplementaryFiles">
+                        </test>
+                     </and>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator3"
+               visible="true">
+         </separator>
+         <menu
+               label="%commands.trace.select_trace_type"
+               mnemonic="%commands.trace.select_trace_type.mnemonic"
+               tooltip="%commands.trace.select_trace_type.description">
+            <dynamic
+                  class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTraceTypeContributionItem"
+                  id="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type.dynamic">
+            </dynamic>
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </menu>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new"
+               disabledIcon="icons/dtool16/new.gif"
+               icon="icons/etool16/new.gif"
+               label="%commands.experiment_folder.new"
+               mnemonic="%commands.experiment_folder.new.mnemonic"
+               style="push"
+               tooltip="%commands.trace.select_trace_type">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator4"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh"
+               disabledIcon="icons/dlcl16/refresh.gif"
+               icon="icons/elcl16/refresh.gif"
+               label="%commands.experiment_folder.refresh"
+               mnemonic="%commands.experiment_folder.refresh.mnemonic"
+               style="push"
+               tooltip="%commands.experiment_folder.refresh.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.select"
+               icon="IMG_OBJ_ADD"
+               label="%commands.experiment.selecttraces"
+               mnemonic="%commands.experiment.selecttraces.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.selecttraces.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator5"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.open"
+               icon="icons/elcl16/open.gif"
+               label="%commands.experiment.open"
+               mnemonic="%commands.experiment.open.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.open.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy"
+               disabledIcon="IMG_TOOL_COPY_DISABLED"
+               icon="IMG_TOOL_COPY"
+               label="%commands.experiment.copy"
+               mnemonic="%commands.experiment.copy.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.copy.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename"
+               icon="icons/elcl16/rename.gif"
+               label="%commands.experiment.rename"
+               mnemonic="%commands.experiment.rename.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.rename.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete"
+               disabledIcon="IMG_ETOOL_DELETE_DISABLED"
+               icon="IMG_ETOOL_DELETE"
+               label="%commands.experiment.delete"
+               mnemonic="%commands.experiment.delete.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.delete.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator6"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.deleteSupplementaryFiles"
+               label="%commands.experiment.deleteSupplementaryFiles"
+               mnemonic="%commands.experiment.deleteSupplementaryFiles.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.deleteSupplementaryFiles.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <iterate
+                       ifEmpty="false"
+                       operator="and">
+                     <and>
+                        <instanceof
+                              value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                        </instanceof>
+                        <test
+                              forcePluginActivation="true"
+                              property="org.eclipse.linuxtools.tmf.ui.hasSupplementaryFiles">
+                        </test>
+                     </and>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+         <separator
+               name="org.eclipse.linuxtools.tmf.ui.separator7"
+               visible="true">
+         </separator>
+         <command
+               commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh"
+               disabledIcon="icons/dlcl16/refresh.gif"
+               icon="icons/elcl16/refresh.gif"
+               label="%commands.experiment.refresh"
+               mnemonic="%commands.experiment.refresh.mnemonic"
+               style="push"
+               tooltip="%commands.experiment.refresh.description">
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="selection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate
+                        ifEmpty="false"
+                        operator="and">
+                     <instanceof
+                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+                     </instanceof>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </command>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <category
+            description="%commands.trace_folder.category.description"
+            id="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category"
+            name="%commands.trace_folder.category.name">
+      </category>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category"
+            description="%commands.trace_folder.import.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.import"
+            name="%commands.trace_folder.import">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace_folder.category"
+            description="%commands.trace_folder.refresh.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh"
+            name="%commands.trace_folder.refresh">
+      </command>
+      <category
+            description="%commands.trace.category.description"
+            id="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            name="%commands.trace.category.name">
+      </category>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            description="%commands.trace.open.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.open"
+            name="%commands.trace.open">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            description="%commands.trace.copy.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy"
+            name="%commands.trace.copy">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            description="%commands.trace.rename.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename"
+            name="%commands.trace.rename">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            description="%commands.trace.deleteSupplementaryFiles.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.deleteSupplementaryFiles"
+            name="%commands.trace.deleteSupplementaryFiles">
+      </command>
+      <category
+            description="%commands.experiment_folder.category.description"
+            id="org.eclipse.linuxtools.tmf.ui.commands.experiment_folder.category"
+            name="%commands.experiment_folder.category.name">
+      </category>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment_folder.category"
+            description="%commands.experiment_folder.new.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new"
+            name="%commands.experiment_folder.new">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment_folder.category"
+            description="%commands.experiment_folder.refresh.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh"
+            name="%commands.experiment_folder.refresh">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            description="%commands.trace.select_trace_type.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type"
+            name="%commands.trace.select_trace_type">
+         <commandParameter
+               id="org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"
+               name="%commands.trace.select_trace_type.bundle"
+               optional="false">
+         </commandParameter>
+         <commandParameter
+               id="org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"
+               name="%commands.trace.select_trace_type.type"
+               optional="false">
+         </commandParameter>
+         <commandParameter
+               id="org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"
+               name="%commands.trace.select_trace_type.icon"
+               optional="false">
+         </commandParameter>
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.trace.category"
+            description="%commands.trace.delete.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete"
+            name="%commands.trace.delete">
+      </command>
+      <category
+            description="%commands.experiment.category.description"
+            id="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            name="%commands.experiment.category.name">
+      </category>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.selecttraces.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.select"
+            name="%commands.experiment.selecttraces">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.open.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.open"
+            name="%commands.experiment.open">
+      </command>
+       <command
+             categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.copy.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy"
+            name="%commands.experiment.copy">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.rename.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename"
+            name="%commands.experiment.rename">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.delete.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete"
+            name="%commands.experiment.delete">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.deleteSupplementaryFiles.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.deleteSupplementaryFiles"
+            name="%commands.experiment.deleteSupplementaryFiles">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.experiment.category"
+            description="%commands.experiment.refresh.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh"
+            name="%commands.experiment.refresh">
+      </command>
+      <category
+            description="%commands.parser.category.description"
+            id="org.eclipse.linuxtools.tmf.ui.commands.parser.category"
+            name="%commands.parser.category.name">
+      </category>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.commands.parser.category"
+            description="%commands.parser.manage.description"
+            id="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"
+            name="%commands.parser.manage">
+      </command>
+      <category
+            description="%commands.uml2sd.category.name"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"    
+            name="%commands.uml2sd.category.name">
+      </category>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.goto.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.GoToMessage"
+            name="%commands.uml2sd.goto">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.showend.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd"
+            name="%commands.uml2sd.showend">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.showstart.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart"
+            name="%commands.uml2sd.showstart">
+      </command>      
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.scrollup.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDUp"
+            name="%commands.uml2sd.scrollup">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.scrolldown.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDDown"
+            name="%commands.uml2sd.scrolldown">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.scrollleft.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDLeft"
+            name="%commands.uml2sd.scrollleft">
+      </command>
+      <command
+            categoryId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.category"
+            description="%commands.uml2sd.scrollright.description"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDRight"
+            name="%commands.uml2sd.scrollright">
+      </command>
+   </extension>
+   <extension point="org.eclipse.ui.bindings">
+      <key
+            sequence="ALT+R"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.GoToMessage"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>   
+      <key
+            sequence="SHIFT+ALT+END"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>   
+      <key
+            sequence="SHIFT+ALT+HOME"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>    
+      <key
+            sequence="SHIFT+ALT+ARROW_UP"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDUp"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>  
+      <key
+            sequence="SHIFT+ALT+ARROW_DOWN"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDDown"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+      <key
+            sequence="SHIFT+ALT+ARROW_LEFT"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDLeft"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+      <key
+            sequence="SHIFT+ALT+ARROW_RIGHT"
+            contextId="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            commandId="org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDRight"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+   </extension>
+   <extension
+         point="org.eclipse.ui.handlers">
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.ImportTraceHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.import">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.refresh">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.OpenTraceHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.open">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.CopyTraceHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.copy">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RenameTraceHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.rename">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteTraceHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.delete">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteTraceSupplementaryFilesHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.deleteSupplementaryFiles">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTraceTypeHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.trace.select_trace_type">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.NewExperimentHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.new">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment_folder.refresh">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTracesHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.select">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.OpenExperimentHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.open">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.CopyExperimentHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.copy">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RenameExperimentHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.rename">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteExperimentHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.delete">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.DeleteExperimentSupplementaryFilesHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.deleteSupplementaryFiles">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.project.experiment.refresh">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.commands.ManageCustomParsersCommandHandler"
+            commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers">
+      </handler>
+      <handler
+            class="org.eclipse.linuxtools.internal.tmf.ui.editors.handlers.AddBookmarkHandler"
+            commandId="org.eclipse.ui.edit.addBookmark">
+         <activeWhen>
+            <with
+                  variable="activeEditor">
+               <instanceof
+                     value="org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor">
+               </instanceof>
+            </with>
+         </activeWhen>
+      </handler>
+   </extension>
+   <extension
+         point="org.eclipse.core.contenttype.contentTypes">
+      <content-type
+            id="org.eclipse.linuxtools.tmf.ui.content-type.trace"
+            name="%contenttype.trace"
+            priority="normal">
+      </content-type>
+   </extension>
+   <extension
+         point="org.eclipse.ui.contexts">
+      <context
+            id="org.eclipse.linuxtools.tmf.ui.view.uml2sd.context"
+            name="%contexts.uml2sd">
+      </context>
+   </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            class="org.eclipse.linuxtools.internal.tmf.ui.preferences.TmfTracingPreferencePage"
+            id="org.eclipse.linuxtools.tmf.ui.TmfTracingPreferences"
+            name="%preference.page.trace.name">
+      </page>
+      <page
+            category="org.eclipse.linuxtools.tmf.ui.TmfTracingPreferences"
+            class="org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewerPage"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewerPage"
+            name="%preference.page.uml2sd.name">
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.linuxtools.tmf.ui.uml2SDLoader">
+      <uml2SDLoader
+            class="org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfUml2SDSyncLoader"
+            default="true"
+            id="org.eclipse.linuxtools.tmf.ui.views.uml2sd.impl.TmfUml2SDSyncLoader"
+            name="TMF UML2SD Loader"
+            view="org.eclipse.linuxtools.tmf.ui.tmfUml2SDSyncView">
+      </uml2SDLoader>
+   </extension>
+   <!--extension
+         point="org.eclipse.core.expressions.propertyTesters">
+      <propertyTester
+            class="org.eclipse.linuxtools.tmf.ui.project.handlers.PropertyTester"
+            id="org.eclipse.linuxtools.tmf.ui.propertyTester.isInTraceFolder"
+            namespace="org.eclipse.linuxtools.tmf.ui.propertyTester"
+            properties="isInTraceFolder"
+            type="org.eclipse.jface.viewers.ISelection">
+      </propertyTester>
+   </extension -->
+   <extension
+         point="org.eclipse.core.expressions.propertyTesters">
+      <propertyTester
+            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.TracePropertyTester"
+            id="org.eclipse.linuxtools.tmf.ui.tracePropertyTester"
+            namespace="org.eclipse.linuxtools.tmf.ui"
+            properties="isExperimentTrace,hasSupplementaryFiles"
+            type="org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement">
+      </propertyTester>
+   </extension>
+   <extension
+         point="org.eclipse.linuxtools.tmf.ui.tracetype">
+      <category
+            id="org.eclipse.linuxtools.tmf.ui.category.ctf"
+            name="%tracetype.category.ctf">
+      </category>
+      <type
+            category="org.eclipse.linuxtools.tmf.ui.category.ctf"
+            event_type="org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent"
+            icon="icons/eview16/events_view.gif"
+            id="org.eclipse.linuxtools.tmf.ui.type.ctf"
+            name="%tracetype.type.ctf"
+            trace_type="org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace">
+      </type>
+   </extension>
+
+</plugin>
index 1e33a323421963a3e9abe56862559b85b1a6dd84..29e10702f3ad4ef907c5b3b851e6ef9054bfd3d7 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui;\r
-\r
-import org.eclipse.osgi.util.NLS;\r
-\r
-public class Messages extends NLS {\r
-    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.ui.messages"; //$NON-NLS-1$\r
-\r
-    public static String ManageCustomParsersDialog_DeleteButtonLabel;\r
-    public static String ManageCustomParsersDialog_DeleteConfirmation;\r
-    public static String ManageCustomParsersDialog_DeleteParserDialogHeader;\r
-    public static String ManageCustomParsersDialog_DialogHeader;\r
-    public static String ManageCustomParsersDialog_EditButtonLabel;\r
-    public static String ManageCustomParsersDialog_ExportButtonLabel;\r
-    public static String ManageCustomParsersDialog_ExportParserSelection;\r
-    public static String ManageCustomParsersDialog_ImportButtonLabel;\r
-    public static String ManageCustomParsersDialog_ImportParserSelection;\r
-    public static String ManageCustomParsersDialog_NewButtonLabel;\r
-    public static String ManageCustomParsersDialog_ParseButtonLabel;\r
-    public static String ManageCustomParsersDialog_ParseError;\r
-    public static String ManageCustomParsersDialog_TextButtonLabel;\r
-    public static String ManageCustomParsersDialog_TraceSelection;\r
-\r
-    public static String CustomTraceDefinition_messageTag;\r
-    public static String CustomTraceDefinition_otherTag;\r
-    public static String CustomTraceDefinition_timestampTag;\r
-    public static String CustomTxtTraceDefinition_action;\r
-    public static String CustomTxtTraceDefinition_cardinality;\r
-    public static String CustomTxtTraceDefinition_definition;\r
-    public static String CustomTxtTraceDefinition_definitionRootElement;\r
-    public static String CustomTxtTraceDefinition_format;\r
-    public static String CustomTxtTraceDefinition_inputData;\r
-    public static String CustomTxtTraceDefinition_inputLine;\r
-    public static String CustomTxtTraceDefinition_max;\r
-    public static String CustomTxtTraceDefinition_min;\r
-    public static String CustomTxtTraceDefinition_name;\r
-    public static String CustomTxtTraceDefinition_outputColumn;\r
-    public static String CustomTxtTraceDefinition_regEx;\r
-    public static String CustomTxtTraceDefinition_timestampOutputFormat;\r
-    public static String CustomXmlTraceDefinition_action;\r
-    public static String CustomXmlTraceDefinition_attribute;\r
-    public static String CustomXmlTraceDefinition_definition;\r
-    public static String CustomXmlTraceDefinition_definitionRootElement;\r
-    public static String CustomXmlTraceDefinition_format;\r
-    public static String CustomXmlTraceDefinition_ignoreTag;\r
-    public static String CustomXmlTraceDefinition_inputData;\r
-    public static String CustomXmlTraceDefinition_inputElement;\r
-    public static String CustomXmlTraceDefinition_logEntry;\r
-    public static String CustomXmlTraceDefinition_name;\r
-    public static String CustomXmlTraceDefinition_outputColumn;\r
-    public static String CustomXmlTraceDefinition_timestampOutputFormat;\r
-\r
-    public static String TmfEventsTable_AddBookmarkActionText;\r
-    public static String TmfEventsTable_AddBookmarkDialogText;\r
-    public static String TmfEventsTable_AddBookmarkDialogTitle;\r
-    public static String TmfEventsTable_ApplyPresetFilterMenuName;\r
-    public static String TmfEventsTable_ClearFiltersActionText;\r
-    public static String TmfEventsTable_ContentColumnHeader;\r
-    public static String TmfEventsTable_FilterHint;\r
-    public static String TmfEventsTable_HideRawActionText;\r
-    public static String TmfEventsTable_HideTableActionText;\r
-    public static String TmfEventsTable_ReferenceColumnHeader;\r
-    public static String TmfEventsTable_RemoveBookmarkActionText;\r
-    public static String TmfEventsTable_SearchHint;\r
-    public static String TmfEventsTable_SearchingJobName;\r
-    public static String TmfEventsTable_ShowFilterBarActionText;\r
-    public static String TmfEventsTable_ShowRawActionText;\r
-    public static String TmfEventsTable_ShowSearchBarActionText;\r
-    public static String TmfEventsTable_ShowTableActionText;\r
-    public static String TmfEventsTable_SourceColumnHeader;\r
-    public static String TmfEventsTable_TimestampColumnHeader;\r
-    public static String TmfEventsTable_TypeColumnHeader;\r
-\r
-    public static String TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS;\r
-    public static String TmfTimeFilterDialog_TRACE_FILTER;\r
-    public static String TmfTimeFilterDialog_TRACE_FILTER_DESC;\r
-    public static String TmfTimeFilterDialog_TRACE_ID;\r
-    public static String TmfTimeFilterDialog_TRACE_NAME;\r
-    public static String TmfTimeLegend_LEGEND;\r
-    public static String TmfTimeLegend_TRACE_STATES;\r
-    public static String TmfTimeLegend_TRACE_STATES_TITLE;\r
-    public static String TmfTimeLegend_WINDOW_TITLE;\r
-    public static String TmfTimeLegend_StateTypeName;\r
-\r
-    public static String TmfTimeTipHandler_DURATION;\r
-    public static String TmfTimeTipHandler_TRACE_DATE;\r
-    public static String TmfTimeTipHandler_TRACE_EVENT_TIME;\r
-    public static String TmfTimeTipHandler_TRACE_START_TIME;\r
-    public static String TmfTimeTipHandler_TRACE_STATE;\r
-    public static String TmfTimeTipHandler_TRACE_STOP_TIME;\r
-\r
-    public static String TmfTimeGraphViewer_ResetScaleActionNameText;\r
-    public static String TmfTimeGraphViewer_ResetScaleActionToolTipText;\r
-    public static String TmfTimeGraphViewer_LegendActionNameText;\r
-    public static String TmfTimeGraphViewer_LegendActionToolTipText;\r
-    public static String TmfTimeGraphViewer_NextEventActionNameText;\r
-    public static String TmfTimeGraphViewer_NextEventActionToolTipText;\r
-    public static String TmfTimeGraphViewer_PreviousEventActionNameText;\r
-    public static String TmfTimeGraphViewer_PreviousEventActionToolTipText;\r
-    public static String TmfTimeGraphViewer_NextItemActionNameText;\r
-    public static String TmfTimeGraphViewer_NextItemActionToolTipText;\r
-    public static String TmfTimeGraphViewer_PreviousItemActionNameText;\r
-    public static String TmfTimeGraphViewer_PreviousItemActionToolTipText;\r
-    public static String TmfTimeGraphViewer_ZoomInActionNameText;\r
-    public static String TmfTimeGraphViewer_ZoomInActionToolTipText;\r
-    public static String TmfTimeGraphViewer_ZoomOutActionNameText;\r
-    public static String TmfTimeGraphViewer_ZoomOutActionToolTipText;\r
-\r
-    public static String ColorsView_AddActionToolTipText;\r
-    public static String ColorsView_BackgroundButtonText;\r
-    public static String ColorsView_BackgroundDialogText;\r
-    public static String ColorsView_DeleteActionToolTipText;\r
-    public static String ColorsView_ExportActionToolTipText;\r
-    public static String ColorsView_FilterButtonText;\r
-    public static String ColorsView_ForegroundButtonText;\r
-    public static String ColorsView_ForegroundDialogText;\r
-    public static String ColorsView_ImportActionToolTipText;\r
-    public static String ColorsView_ImportOverwriteDialogMessage1;\r
-    public static String ColorsView_ImportOverwriteDialogMessage2;\r
-    public static String ColorsView_ImportOverwriteDialogTitle;\r
-    public static String ColorsView_MoveDownActionToolTipText;\r
-    public static String ColorsView_MoveUpActionToolTipText;\r
-    public static String ColorsView_TickButtonText;\r
-    public static String TickColorDialog_TickColorDialogTitle;\r
-\r
-    public static String CustomTxtParserInputWizardPage_addChildLine;\r
-    public static String CustomTxtParserInputWizardPage_addGroup;\r
-    public static String CustomTxtParserInputWizardPage_addNextLine;\r
-    public static String CustomTxtParserInputWizardPage_append;\r
-    public static String CustomTxtParserInputWizardPage_appendWith;\r
-    public static String CustomTxtParserInputWizardPage_capturedGroup;\r
-    public static String CustomTxtParserInputWizardPage_cardinality;\r
-    public static String CustomTxtParserInputWizardPage_dateFormatHelp;\r
-    public static String CustomTxtParserInputWizardPage_desccriptionEdit;\r
-    public static String CustomTxtParserInputWizardPage_descriptionNew;\r
-    public static String CustomTxtParserInputWizardPage_format;\r
-    public static String CustomTxtParserInputWizardPage_group;\r
-    public static String CustomTxtParserInputWizardPage_highlightAll;\r
-    public static String CustomTxtParserInputWizardPage_logType;\r
-    public static String CustomTxtParserInputWizardPage_matchingLineRoot;\r
-    public static String CustomTxtParserInputWizardPage_matchingOtherLine;\r
-    public static String CustomTxtParserInputWizardPage_matchingRootLine;\r
-    public static String CustomTxtParserInputWizardPage_max;\r
-    public static String CustomTxtParserInputWizardPage_min;\r
-    public static String CustomTxtParserInputWizardPage_moveDown;\r
-    public static String CustomTxtParserInputWizardPage_moveUp;\r
-    public static String CustomTxtParserInputWizardPage_name;\r
-    public static String CustomTxtParserInputWizardPage_newGroup;\r
-    public static String CustomTxtParserInputWizardPage_noMatch;\r
-    public static String CustomTxtParserInputWizardPage_noMatchingGroup;\r
-    public static String CustomTxtParserInputWizardPage_noMatchingLine;\r
-    public static String CustomTxtParserInputWizardPage_noMatchingTimestamp;\r
-    public static String CustomTxtParserInputWizardPage_noMathcingLine;\r
-    public static String CustomTxtParserInputWizardPage_nonMatchingLine;\r
-    public static String CustomTxtParserInputWizardPage_noTimestampGroup;\r
-    public static String CustomTxtParserInputWizardPage_preview;\r
-    public static String CustomTxtParserInputWizardPage_previewInput;\r
-    public static String CustomTxtParserInputWizardPage_previewLegend;\r
-    public static String CustomTxtParserInputWizardPage_regularExpression;\r
-    public static String CustomTxtParserInputWizardPage_regularExpressionHelp;\r
-    public static String CustomTxtParserInputWizardPage_removeGroup;\r
-    public static String CustomTxtParserInputWizardPage_removeLine;\r
-    public static String CustomTxtParserInputWizardPage_set;\r
-    public static String CustomTxtParserInputWizardPage_timestampFormat;\r
-    public static String CustomTxtParserInputWizardPage_uncapturedText;\r
-    public static String CustomTxtParserInputWizardPage_unidentifiedCaptureGroup;\r
-    public static String CustomTxtParserInputWizardPage_windowTitleEdit;\r
-    public static String CustomTxtParserInputWizardPage_windowTitleNew;\r
-    public static String CustomTxtParserOutputWizardPage_description;\r
-    public static String CustomTxtParserOutputWizardPage_moveAfter;\r
-    public static String CustomTxtParserOutputWizardPage_moveBefore;\r
-    public static String CustomTxtParserOutputWizardPage_visible;\r
-    public static String CustomXmlParserInputWizardPage_emptyLogTypeError;\r
-    public static String CustomXmlParserInputWizardPage_duplicatelogTypeError;\r
-    public static String CustomXmlParserInputWizardPage_noDocumentError;\r
-    public static String CustomXmlParserInputWizardPage_missingLogEntryError;\r
-    public static String CustomXmlParserInputWizardPage_missingTimestampFmtError;\r
-    public static String CustomXmlParserInputWizardPage_invalidTimestampFmtError;\r
-    public static String CustomXmlParserInputWizardPage_notimestamporAttributeError;\r
-    public static String CustomXmlParserInputWizardPage_missingDocumentElementError;\r
-    public static String CustomXmlParserInputWizardPage_timestampFormatPrompt;\r
-    public static String CustomXmlParserInputWizardPage_timestampElementPrompt;\r
-    public static String CustomXmlParserInputWizardPage_missingInputElementNameError;\r
-    public static String CustomXmlParserInputWizardPage_attributePrompt;\r
-    public static String CustomXmlParserInputWizardPage_missingAttribute;\r
-    public static String CustomXmlParserInputWizardPage_duplicateAttributeError;\r
-    public static String CustomXmlParserInputWizardPage_missingTimestampInFmtError;\r
-    public static String CustomXmlParserInputWizardPage_invalidTimestampInFmtError;\r
-    public static String CustomXmlParserInputWizardPage_missingDataGroupNameError;\r
-    public static String CustomXmlParserInputWizardPage_missingElementNameError;\r
-    public static String CustomXmlParserInputWizardPage_duplicateElementNameError;\r
-    public static String CustomXmlParserInputWizardPage_addAttribute;\r
-    public static String CustomXmlParserInputWizardPage_addChildElement;\r
-    public static String CustomXmlParserInputWizardPage_addDocumentEleemnt;\r
-    public static String CustomXmlParserInputWizardPage_addDocumentElement;\r
-    public static String CustomXmlParserInputWizardPage_addNextElement;\r
-    public static String CustomXmlParserInputWizardPage_append;\r
-    public static String CustomXmlParserInputWizardPage_appendWith;\r
-    public static String CustomXmlParserInputWizardPage_attibute;\r
-    public static String CustomXmlParserInputWizardPage_dateFormatHelp;\r
-    public static String CustomXmlParserInputWizardPage_descriptionEdit;\r
-    public static String CustomXmlParserInputWizardPage_descriptionNew;\r
-    public static String CustomXmlParserInputWizardPage_elementName;\r
-    public static String CustomXmlParserInputWizardPage_feelingLucky;\r
-    public static String CustomXmlParserInputWizardPage_format;\r
-    public static String CustomXmlParserInputWizardPage_logEntry;\r
-    public static String CustomXmlParserInputWizardPage_logType;\r
-    public static String CustomXmlParserInputWizardPage_moveDown;\r
-    public static String CustomXmlParserInputWizardPage_moveUp;\r
-    public static String CustomXmlParserInputWizardPage_name;\r
-    public static String CustomXmlParserInputWizardPage_newAttibute;\r
-    public static String CustomXmlParserInputWizardPage_noMatchingAttribute;\r
-    public static String CustomXmlParserInputWizardPage_noMatch;\r
-    public static String CustomXmlParserInputWizardPage_noMatchingElement;\r
-    public static String CustomXmlParserInputWizardPage_preview;\r
-    public static String CustomXmlParserInputWizardPage_previewInput;\r
-    public static String CustomXmlParserInputWizardPage_removeAttribute;\r
-    public static String CustomXmlParserInputWizardPage_removeElement;\r
-    public static String CustomXmlParserInputWizardPage_set;\r
-    public static String CustomXmlParserInputWizardPage_tagName;\r
-    public static String CustomXmlParserInputWizardPage_timestampFormat;\r
-    public static String CustomXmlParserInputWizardPage_titleEdit;\r
-    public static String CustomXmlParserInputWizardPage_titleNew;\r
-    public static String CustomXmlParserOutputWizardPage_description;\r
-    public static String CustomXmlParserOutputWizardPage_moveAfter;\r
-    public static String CustomXmlParserOutputWizardPage_moveBefore;\r
-    public static String CustomXmlParserOutputWizardPage_visible;\r
-\r
-    public static String FilterDialog_FilterDialogTitle;\r
-    public static String FilterView_AddActionToolTipText;\r
-    public static String FilterView_DeleteActionToolTipText;\r
-    public static String FilterView_ExportActionToolTipText;\r
-    public static String FilterView_FileDialogFilterName;\r
-    public static String FilterView_ImportActionToolTipText;\r
-    public static String FilterView_SaveActionToolTipText;\r
-    public static String FilterViewer_EmptyTreeHintText;\r
-    public static String FilterViewer_CommonCategory;\r
-    public static String FilterViewer_AlphaButtonText;\r
-    public static String FilterViewer_DeleteActionText;\r
-    public static String FilterViewer_FieldLabel;\r
-    public static String FilterViewer_FilterNameHint;\r
-    public static String FilterViewer_IgnoreCaseButtonText;\r
-    public static String FilterViewer_NameLabel;\r
-    public static String FilterViewer_NewPrefix;\r
-    public static String FilterViewer_NotLabel;\r
-    public static String FilterViewer_NumButtonText;\r
-    public static String FilterViewer_RegexHint;\r
-    public static String FilterViewer_RegexLabel;\r
-    public static String FilterViewer_ResultLabel;\r
-    public static String FilterViewer_TimestampButtonText;\r
-    public static String FilterViewer_TypeLabel;\r
-    public static String FilterViewer_ValueHint;\r
-    public static String FilterViewer_ValueLabel;\r
-\r
-    public static String TmfView_PinActionNameText;\r
-    public static String TmfView_PinActionToolTipText;\r
-\r
-    static {\r
-        // initialize resource bundle\r
-        NLS.initializeMessages(BUNDLE_NAME, Messages.class);\r
-    }\r
-\r
-    private Messages() {\r
-    }\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.tmf.ui.messages"; //$NON-NLS-1$
+
+    public static String ManageCustomParsersDialog_DeleteButtonLabel;
+    public static String ManageCustomParsersDialog_DeleteConfirmation;
+    public static String ManageCustomParsersDialog_DeleteParserDialogHeader;
+    public static String ManageCustomParsersDialog_DialogHeader;
+    public static String ManageCustomParsersDialog_EditButtonLabel;
+    public static String ManageCustomParsersDialog_ExportButtonLabel;
+    public static String ManageCustomParsersDialog_ExportParserSelection;
+    public static String ManageCustomParsersDialog_ImportButtonLabel;
+    public static String ManageCustomParsersDialog_ImportParserSelection;
+    public static String ManageCustomParsersDialog_NewButtonLabel;
+    public static String ManageCustomParsersDialog_ParseButtonLabel;
+    public static String ManageCustomParsersDialog_ParseError;
+    public static String ManageCustomParsersDialog_TextButtonLabel;
+    public static String ManageCustomParsersDialog_TraceSelection;
+
+    public static String CustomTraceDefinition_messageTag;
+    public static String CustomTraceDefinition_otherTag;
+    public static String CustomTraceDefinition_timestampTag;
+    public static String CustomTxtTraceDefinition_action;
+    public static String CustomTxtTraceDefinition_cardinality;
+    public static String CustomTxtTraceDefinition_definition;
+    public static String CustomTxtTraceDefinition_definitionRootElement;
+    public static String CustomTxtTraceDefinition_format;
+    public static String CustomTxtTraceDefinition_inputData;
+    public static String CustomTxtTraceDefinition_inputLine;
+    public static String CustomTxtTraceDefinition_max;
+    public static String CustomTxtTraceDefinition_min;
+    public static String CustomTxtTraceDefinition_name;
+    public static String CustomTxtTraceDefinition_outputColumn;
+    public static String CustomTxtTraceDefinition_regEx;
+    public static String CustomTxtTraceDefinition_timestampOutputFormat;
+    public static String CustomXmlTraceDefinition_action;
+    public static String CustomXmlTraceDefinition_attribute;
+    public static String CustomXmlTraceDefinition_definition;
+    public static String CustomXmlTraceDefinition_definitionRootElement;
+    public static String CustomXmlTraceDefinition_format;
+    public static String CustomXmlTraceDefinition_ignoreTag;
+    public static String CustomXmlTraceDefinition_inputData;
+    public static String CustomXmlTraceDefinition_inputElement;
+    public static String CustomXmlTraceDefinition_logEntry;
+    public static String CustomXmlTraceDefinition_name;
+    public static String CustomXmlTraceDefinition_outputColumn;
+    public static String CustomXmlTraceDefinition_timestampOutputFormat;
+
+    public static String TmfEventsTable_AddBookmarkActionText;
+    public static String TmfEventsTable_AddBookmarkDialogText;
+    public static String TmfEventsTable_AddBookmarkDialogTitle;
+    public static String TmfEventsTable_ApplyPresetFilterMenuName;
+    public static String TmfEventsTable_ClearFiltersActionText;
+    public static String TmfEventsTable_ContentColumnHeader;
+    public static String TmfEventsTable_FilterHint;
+    public static String TmfEventsTable_HideRawActionText;
+    public static String TmfEventsTable_HideTableActionText;
+    public static String TmfEventsTable_ReferenceColumnHeader;
+    public static String TmfEventsTable_RemoveBookmarkActionText;
+    public static String TmfEventsTable_SearchHint;
+    public static String TmfEventsTable_SearchingJobName;
+    public static String TmfEventsTable_ShowFilterBarActionText;
+    public static String TmfEventsTable_ShowRawActionText;
+    public static String TmfEventsTable_ShowSearchBarActionText;
+    public static String TmfEventsTable_ShowTableActionText;
+    public static String TmfEventsTable_SourceColumnHeader;
+    public static String TmfEventsTable_TimestampColumnHeader;
+    public static String TmfEventsTable_TypeColumnHeader;
+
+    public static String TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS;
+    public static String TmfTimeFilterDialog_TRACE_FILTER;
+    public static String TmfTimeFilterDialog_TRACE_FILTER_DESC;
+    public static String TmfTimeFilterDialog_TRACE_ID;
+    public static String TmfTimeFilterDialog_TRACE_NAME;
+    public static String TmfTimeLegend_LEGEND;
+    public static String TmfTimeLegend_TRACE_STATES;
+    public static String TmfTimeLegend_TRACE_STATES_TITLE;
+    public static String TmfTimeLegend_WINDOW_TITLE;
+    public static String TmfTimeLegend_StateTypeName;
+
+    public static String TmfTimeTipHandler_DURATION;
+    public static String TmfTimeTipHandler_TRACE_DATE;
+    public static String TmfTimeTipHandler_TRACE_EVENT_TIME;
+    public static String TmfTimeTipHandler_TRACE_START_TIME;
+    public static String TmfTimeTipHandler_TRACE_STATE;
+    public static String TmfTimeTipHandler_TRACE_STOP_TIME;
+
+    public static String TmfTimeGraphViewer_ResetScaleActionNameText;
+    public static String TmfTimeGraphViewer_ResetScaleActionToolTipText;
+    public static String TmfTimeGraphViewer_LegendActionNameText;
+    public static String TmfTimeGraphViewer_LegendActionToolTipText;
+    public static String TmfTimeGraphViewer_NextEventActionNameText;
+    public static String TmfTimeGraphViewer_NextEventActionToolTipText;
+    public static String TmfTimeGraphViewer_PreviousEventActionNameText;
+    public static String TmfTimeGraphViewer_PreviousEventActionToolTipText;
+    public static String TmfTimeGraphViewer_NextItemActionNameText;
+    public static String TmfTimeGraphViewer_NextItemActionToolTipText;
+    public static String TmfTimeGraphViewer_PreviousItemActionNameText;
+    public static String TmfTimeGraphViewer_PreviousItemActionToolTipText;
+    public static String TmfTimeGraphViewer_ZoomInActionNameText;
+    public static String TmfTimeGraphViewer_ZoomInActionToolTipText;
+    public static String TmfTimeGraphViewer_ZoomOutActionNameText;
+    public static String TmfTimeGraphViewer_ZoomOutActionToolTipText;
+
+    public static String ColorsView_AddActionToolTipText;
+    public static String ColorsView_BackgroundButtonText;
+    public static String ColorsView_BackgroundDialogText;
+    public static String ColorsView_DeleteActionToolTipText;
+    public static String ColorsView_ExportActionToolTipText;
+    public static String ColorsView_FilterButtonText;
+    public static String ColorsView_ForegroundButtonText;
+    public static String ColorsView_ForegroundDialogText;
+    public static String ColorsView_ImportActionToolTipText;
+    public static String ColorsView_ImportOverwriteDialogMessage1;
+    public static String ColorsView_ImportOverwriteDialogMessage2;
+    public static String ColorsView_ImportOverwriteDialogTitle;
+    public static String ColorsView_MoveDownActionToolTipText;
+    public static String ColorsView_MoveUpActionToolTipText;
+    public static String ColorsView_TickButtonText;
+    public static String TickColorDialog_TickColorDialogTitle;
+
+    public static String CustomTxtParserInputWizardPage_addChildLine;
+    public static String CustomTxtParserInputWizardPage_addGroup;
+    public static String CustomTxtParserInputWizardPage_addNextLine;
+    public static String CustomTxtParserInputWizardPage_append;
+    public static String CustomTxtParserInputWizardPage_appendWith;
+    public static String CustomTxtParserInputWizardPage_capturedGroup;
+    public static String CustomTxtParserInputWizardPage_cardinality;
+    public static String CustomTxtParserInputWizardPage_dateFormatHelp;
+    public static String CustomTxtParserInputWizardPage_desccriptionEdit;
+    public static String CustomTxtParserInputWizardPage_descriptionNew;
+    public static String CustomTxtParserInputWizardPage_format;
+    public static String CustomTxtParserInputWizardPage_group;
+    public static String CustomTxtParserInputWizardPage_highlightAll;
+    public static String CustomTxtParserInputWizardPage_logType;
+    public static String CustomTxtParserInputWizardPage_matchingLineRoot;
+    public static String CustomTxtParserInputWizardPage_matchingOtherLine;
+    public static String CustomTxtParserInputWizardPage_matchingRootLine;
+    public static String CustomTxtParserInputWizardPage_max;
+    public static String CustomTxtParserInputWizardPage_min;
+    public static String CustomTxtParserInputWizardPage_moveDown;
+    public static String CustomTxtParserInputWizardPage_moveUp;
+    public static String CustomTxtParserInputWizardPage_name;
+    public static String CustomTxtParserInputWizardPage_newGroup;
+    public static String CustomTxtParserInputWizardPage_noMatch;
+    public static String CustomTxtParserInputWizardPage_noMatchingGroup;
+    public static String CustomTxtParserInputWizardPage_noMatchingLine;
+    public static String CustomTxtParserInputWizardPage_noMatchingTimestamp;
+    public static String CustomTxtParserInputWizardPage_noMathcingLine;
+    public static String CustomTxtParserInputWizardPage_nonMatchingLine;
+    public static String CustomTxtParserInputWizardPage_noTimestampGroup;
+    public static String CustomTxtParserInputWizardPage_preview;
+    public static String CustomTxtParserInputWizardPage_previewInput;
+    public static String CustomTxtParserInputWizardPage_previewLegend;
+    public static String CustomTxtParserInputWizardPage_regularExpression;
+    public static String CustomTxtParserInputWizardPage_regularExpressionHelp;
+    public static String CustomTxtParserInputWizardPage_removeGroup;
+    public static String CustomTxtParserInputWizardPage_removeLine;
+    public static String CustomTxtParserInputWizardPage_set;
+    public static String CustomTxtParserInputWizardPage_timestampFormat;
+    public static String CustomTxtParserInputWizardPage_uncapturedText;
+    public static String CustomTxtParserInputWizardPage_unidentifiedCaptureGroup;
+    public static String CustomTxtParserInputWizardPage_windowTitleEdit;
+    public static String CustomTxtParserInputWizardPage_windowTitleNew;
+    public static String CustomTxtParserOutputWizardPage_description;
+    public static String CustomTxtParserOutputWizardPage_moveAfter;
+    public static String CustomTxtParserOutputWizardPage_moveBefore;
+    public static String CustomTxtParserOutputWizardPage_visible;
+    public static String CustomXmlParserInputWizardPage_emptyLogTypeError;
+    public static String CustomXmlParserInputWizardPage_duplicatelogTypeError;
+    public static String CustomXmlParserInputWizardPage_noDocumentError;
+    public static String CustomXmlParserInputWizardPage_missingLogEntryError;
+    public static String CustomXmlParserInputWizardPage_missingTimestampFmtError;
+    public static String CustomXmlParserInputWizardPage_invalidTimestampFmtError;
+    public static String CustomXmlParserInputWizardPage_notimestamporAttributeError;
+    public static String CustomXmlParserInputWizardPage_missingDocumentElementError;
+    public static String CustomXmlParserInputWizardPage_timestampFormatPrompt;
+    public static String CustomXmlParserInputWizardPage_timestampElementPrompt;
+    public static String CustomXmlParserInputWizardPage_missingInputElementNameError;
+    public static String CustomXmlParserInputWizardPage_attributePrompt;
+    public static String CustomXmlParserInputWizardPage_missingAttribute;
+    public static String CustomXmlParserInputWizardPage_duplicateAttributeError;
+    public static String CustomXmlParserInputWizardPage_missingTimestampInFmtError;
+    public static String CustomXmlParserInputWizardPage_invalidTimestampInFmtError;
+    public static String CustomXmlParserInputWizardPage_missingDataGroupNameError;
+    public static String CustomXmlParserInputWizardPage_missingElementNameError;
+    public static String CustomXmlParserInputWizardPage_duplicateElementNameError;
+    public static String CustomXmlParserInputWizardPage_addAttribute;
+    public static String CustomXmlParserInputWizardPage_addChildElement;
+    public static String CustomXmlParserInputWizardPage_addDocumentEleemnt;
+    public static String CustomXmlParserInputWizardPage_addDocumentElement;
+    public static String CustomXmlParserInputWizardPage_addNextElement;
+    public static String CustomXmlParserInputWizardPage_append;
+    public static String CustomXmlParserInputWizardPage_appendWith;
+    public static String CustomXmlParserInputWizardPage_attibute;
+    public static String CustomXmlParserInputWizardPage_dateFormatHelp;
+    public static String CustomXmlParserInputWizardPage_descriptionEdit;
+    public static String CustomXmlParserInputWizardPage_descriptionNew;
+    public static String CustomXmlParserInputWizardPage_elementName;
+    public static String CustomXmlParserInputWizardPage_feelingLucky;
+    public static String CustomXmlParserInputWizardPage_format;
+    public static String CustomXmlParserInputWizardPage_logEntry;
+    public static String CustomXmlParserInputWizardPage_logType;
+    public static String CustomXmlParserInputWizardPage_moveDown;
+    public static String CustomXmlParserInputWizardPage_moveUp;
+    public static String CustomXmlParserInputWizardPage_name;
+    public static String CustomXmlParserInputWizardPage_newAttibute;
+    public static String CustomXmlParserInputWizardPage_noMatchingAttribute;
+    public static String CustomXmlParserInputWizardPage_noMatch;
+    public static String CustomXmlParserInputWizardPage_noMatchingElement;
+    public static String CustomXmlParserInputWizardPage_preview;
+    public static String CustomXmlParserInputWizardPage_previewInput;
+    public static String CustomXmlParserInputWizardPage_removeAttribute;
+    public static String CustomXmlParserInputWizardPage_removeElement;
+    public static String CustomXmlParserInputWizardPage_set;
+    public static String CustomXmlParserInputWizardPage_tagName;
+    public static String CustomXmlParserInputWizardPage_timestampFormat;
+    public static String CustomXmlParserInputWizardPage_titleEdit;
+    public static String CustomXmlParserInputWizardPage_titleNew;
+    public static String CustomXmlParserOutputWizardPage_description;
+    public static String CustomXmlParserOutputWizardPage_moveAfter;
+    public static String CustomXmlParserOutputWizardPage_moveBefore;
+    public static String CustomXmlParserOutputWizardPage_visible;
+
+    public static String FilterDialog_FilterDialogTitle;
+    public static String FilterView_AddActionToolTipText;
+    public static String FilterView_DeleteActionToolTipText;
+    public static String FilterView_ExportActionToolTipText;
+    public static String FilterView_FileDialogFilterName;
+    public static String FilterView_ImportActionToolTipText;
+    public static String FilterView_SaveActionToolTipText;
+    public static String FilterViewer_EmptyTreeHintText;
+    public static String FilterViewer_CommonCategory;
+    public static String FilterViewer_AlphaButtonText;
+    public static String FilterViewer_DeleteActionText;
+    public static String FilterViewer_FieldLabel;
+    public static String FilterViewer_FilterNameHint;
+    public static String FilterViewer_IgnoreCaseButtonText;
+    public static String FilterViewer_NameLabel;
+    public static String FilterViewer_NewPrefix;
+    public static String FilterViewer_NotLabel;
+    public static String FilterViewer_NumButtonText;
+    public static String FilterViewer_RegexHint;
+    public static String FilterViewer_RegexLabel;
+    public static String FilterViewer_ResultLabel;
+    public static String FilterViewer_TimestampButtonText;
+    public static String FilterViewer_TypeLabel;
+    public static String FilterViewer_ValueHint;
+    public static String FilterViewer_ValueLabel;
+
+    public static String TmfView_PinActionNameText;
+    public static String TmfView_PinActionToolTipText;
+
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
index 35ab206ef507e42d6af8d0f904e63bb50ff0582a..ac123c2225d88a88ada2f9f45128ce86acf354da 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui;\r
-\r
-import java.io.BufferedWriter;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-\r
-import org.eclipse.core.runtime.Platform;\r
-\r
-@SuppressWarnings("nls")\r
-public class TmfUiTracer {\r
-\r
-       private static String pluginID = Activator.PLUGIN_ID;\r
-\r
-       static Boolean ERROR     = Boolean.FALSE;\r
-       static Boolean WARNING   = Boolean.FALSE;\r
-       static Boolean INFO      = Boolean.FALSE;\r
-\r
-       static Boolean INDEX         = Boolean.FALSE;\r
-       static Boolean DISPLAY       = Boolean.FALSE;\r
-       static Boolean SORTING       = Boolean.FALSE;\r
-\r
-       private static String LOGNAME = "traceUI.log";\r
-       private static BufferedWriter fTraceLog = null;\r
-\r
-       private static BufferedWriter openLogFile(String filename) {\r
-               BufferedWriter outfile = null;\r
-               try {\r
-                       outfile = new BufferedWriter(new FileWriter(filename));\r
-               } catch (IOException e) {\r
-                   Activator.getDefault().logError("Error creating log file " + LOGNAME, e); //$NON-NLS-1$\r
-               }\r
-               return outfile;\r
-       }\r
-\r
-       public static void init() {\r
-\r
-               String traceKey;\r
-               boolean isTracing = false;\r
-               \r
-               traceKey = Platform.getDebugOption(pluginID + "/error");\r
-               if (traceKey != null) {\r
-                       ERROR = (Boolean.valueOf(traceKey)).booleanValue();\r
-                       isTracing |= ERROR;\r
-               }\r
-\r
-               traceKey = Platform.getDebugOption(pluginID + "/warning");\r
-               if (traceKey != null) {\r
-                       WARNING = (Boolean.valueOf(traceKey)).booleanValue();\r
-                       isTracing |= WARNING;\r
-               }\r
-\r
-               traceKey = Platform.getDebugOption(pluginID + "/info");\r
-               if (traceKey != null) {\r
-                       INFO = (Boolean.valueOf(traceKey)).booleanValue();\r
-                       isTracing |= INFO;\r
-               }\r
-\r
-               traceKey = Platform.getDebugOption(pluginID + "/updateindex");\r
-               if (traceKey != null) {\r
-                   INDEX = (Boolean.valueOf(traceKey)).booleanValue();\r
-                       isTracing |= INDEX;\r
-               }\r
-\r
-               traceKey = Platform.getDebugOption(pluginID + "/display");\r
-               if (traceKey != null) {\r
-                   DISPLAY = (Boolean.valueOf(traceKey)).booleanValue();\r
-                       isTracing |= DISPLAY;\r
-               }\r
-\r
-               traceKey = Platform.getDebugOption(pluginID + "/sorting");\r
-               if (traceKey != null) {\r
-                   SORTING = (Boolean.valueOf(traceKey)).booleanValue();\r
-                       isTracing |= SORTING;\r
-               }\r
-\r
-               // Create trace log file if needed\r
-               if (isTracing) {\r
-                       fTraceLog = openLogFile(LOGNAME);\r
-               }\r
-       }\r
-\r
-       public static void stop() {\r
-               if (fTraceLog == null)\r
-                       return;\r
-\r
-               try {\r
-                       fTraceLog.close();\r
-                       fTraceLog = null;\r
-               } catch (IOException e) {\r
-                 Activator.getDefault().logError("Error closing log file " + LOGNAME, e); //$NON-NLS-1$\r
-               }\r
-       }\r
-\r
-       // Predicates\r
-       public static boolean isErrorTraced() {\r
-               return ERROR;\r
-       }\r
-\r
-       public static boolean isIndexTraced() {\r
-               return INDEX;\r
-       }\r
-       \r
-       public static boolean isDisplayTraced() {\r
-               return DISPLAY;\r
-       }\r
-       \r
-       public static boolean isSortingTraced() {\r
-               return SORTING;\r
-       }\r
-\r
-       // Tracers\r
-       public static void trace(String msg) {\r
-               long currentTime = System.currentTimeMillis();\r
-               StringBuilder message = new StringBuilder("[");\r
-               message.append(currentTime / 1000);\r
-               message.append(".");\r
-               message.append(String.format("%1$03d", currentTime % 1000));\r
-               message.append("] ");\r
-               message.append(msg);\r
-\r
-               if (fTraceLog != null) {\r
-                       try {\r
-                               fTraceLog.write(message.toString());\r
-                               fTraceLog.newLine();\r
-                               fTraceLog.flush();\r
-                       } catch (IOException e) {\r
-                        Activator.getDefault().logError("Error writing to log file " + LOGNAME, e); //$NON-NLS-1$\r
-                       }\r
-               }\r
-       }\r
-\r
-       public static void traceIndex(String msg) {\r
-           String message = ("[INDEX] " + msg);\r
-           trace(message);\r
-       }\r
-       \r
-       public static void traceDisplay(String msg) {\r
-               String message = ("[DISPLAY]" + msg);\r
-               trace(message);\r
-       }\r
-\r
-       public static void traceSorting(String msg) {\r
-               String message = ("[SORT] " + msg);\r
-               trace(message);\r
-       }\r
-\r
-       public static void traceError(String msg) {\r
-               String message = ("[ERR] Thread=" + Thread.currentThread().getId() + " " + msg);\r
-               trace(message);\r
-       }\r
-\r
-       public static void traceWarning(String msg) {\r
-           String message = ("[WARN] Thread=" + Thread.currentThread().getId() + " " + msg);\r
-           trace(message);\r
-       }\r
-       \r
-       public static void traceInfo(String msg) {\r
-               String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg);\r
-               trace(message);\r
-       }\r
-       \r
-       \r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.Platform;
+
+@SuppressWarnings("nls")
+public class TmfUiTracer {
+
+       private static String pluginID = Activator.PLUGIN_ID;
+
+       static Boolean ERROR     = Boolean.FALSE;
+       static Boolean WARNING   = Boolean.FALSE;
+       static Boolean INFO      = Boolean.FALSE;
+
+       static Boolean INDEX         = Boolean.FALSE;
+       static Boolean DISPLAY       = Boolean.FALSE;
+       static Boolean SORTING       = Boolean.FALSE;
+
+       private static String LOGNAME = "traceUI.log";
+       private static BufferedWriter fTraceLog = null;
+
+       private static BufferedWriter openLogFile(String filename) {
+               BufferedWriter outfile = null;
+               try {
+                       outfile = new BufferedWriter(new FileWriter(filename));
+               } catch (IOException e) {
+                   Activator.getDefault().logError("Error creating log file " + LOGNAME, e); //$NON-NLS-1$
+               }
+               return outfile;
+       }
+
+       public static void init() {
+
+               String traceKey;
+               boolean isTracing = false;
+               
+               traceKey = Platform.getDebugOption(pluginID + "/error");
+               if (traceKey != null) {
+                       ERROR = (Boolean.valueOf(traceKey)).booleanValue();
+                       isTracing |= ERROR;
+               }
+
+               traceKey = Platform.getDebugOption(pluginID + "/warning");
+               if (traceKey != null) {
+                       WARNING = (Boolean.valueOf(traceKey)).booleanValue();
+                       isTracing |= WARNING;
+               }
+
+               traceKey = Platform.getDebugOption(pluginID + "/info");
+               if (traceKey != null) {
+                       INFO = (Boolean.valueOf(traceKey)).booleanValue();
+                       isTracing |= INFO;
+               }
+
+               traceKey = Platform.getDebugOption(pluginID + "/updateindex");
+               if (traceKey != null) {
+                   INDEX = (Boolean.valueOf(traceKey)).booleanValue();
+                       isTracing |= INDEX;
+               }
+
+               traceKey = Platform.getDebugOption(pluginID + "/display");
+               if (traceKey != null) {
+                   DISPLAY = (Boolean.valueOf(traceKey)).booleanValue();
+                       isTracing |= DISPLAY;
+               }
+
+               traceKey = Platform.getDebugOption(pluginID + "/sorting");
+               if (traceKey != null) {
+                   SORTING = (Boolean.valueOf(traceKey)).booleanValue();
+                       isTracing |= SORTING;
+               }
+
+               // Create trace log file if needed
+               if (isTracing) {
+                       fTraceLog = openLogFile(LOGNAME);
+               }
+       }
+
+       public static void stop() {
+               if (fTraceLog == null)
+                       return;
+
+               try {
+                       fTraceLog.close();
+                       fTraceLog = null;
+               } catch (IOException e) {
+                 Activator.getDefault().logError("Error closing log file " + LOGNAME, e); //$NON-NLS-1$
+               }
+       }
+
+       // Predicates
+       public static boolean isErrorTraced() {
+               return ERROR;
+       }
+
+       public static boolean isIndexTraced() {
+               return INDEX;
+       }
+       
+       public static boolean isDisplayTraced() {
+               return DISPLAY;
+       }
+       
+       public static boolean isSortingTraced() {
+               return SORTING;
+       }
+
+       // Tracers
+       public static void trace(String msg) {
+               long currentTime = System.currentTimeMillis();
+               StringBuilder message = new StringBuilder("[");
+               message.append(currentTime / 1000);
+               message.append(".");
+               message.append(String.format("%1$03d", currentTime % 1000));
+               message.append("] ");
+               message.append(msg);
+
+               if (fTraceLog != null) {
+                       try {
+                               fTraceLog.write(message.toString());
+                               fTraceLog.newLine();
+                               fTraceLog.flush();
+                       } catch (IOException e) {
+                        Activator.getDefault().logError("Error writing to log file " + LOGNAME, e); //$NON-NLS-1$
+                       }
+               }
+       }
+
+       public static void traceIndex(String msg) {
+           String message = ("[INDEX] " + msg);
+           trace(message);
+       }
+       
+       public static void traceDisplay(String msg) {
+               String message = ("[DISPLAY]" + msg);
+               trace(message);
+       }
+
+       public static void traceSorting(String msg) {
+               String message = ("[SORT] " + msg);
+               trace(message);
+       }
+
+       public static void traceError(String msg) {
+               String message = ("[ERR] Thread=" + Thread.currentThread().getId() + " " + msg);
+               trace(message);
+       }
+
+       public static void traceWarning(String msg) {
+           String message = ("[WARN] Thread=" + Thread.currentThread().getId() + " " + msg);
+           trace(message);
+       }
+       
+       public static void traceInfo(String msg) {
+               String message = ("[INF] Thread=" + Thread.currentThread().getId() + " " + msg);
+               trace(message);
+       }
+       
+       
+
+}
index 5d8db1fa3e4a3cfc60cb8f0575853dc84b9dca9b..c03022ab682a107e1d19e3cf0167f6d139e7ed0d 100644 (file)
@@ -1,30 +1,30 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.commands;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.linuxtools.internal.tmf.ui.dialogs.ManageCustomParsersDialog;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-public class ManageCustomParsersCommandHandler extends AbstractHandler {\r
-\r
-    @Override\r
-       public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        ManageCustomParsersDialog dialog = new ManageCustomParsersDialog(Display.getDefault().getActiveShell());\r
-        dialog.open();\r
-        return null;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.internal.tmf.ui.dialogs.ManageCustomParsersDialog;
+import org.eclipse.swt.widgets.Display;
+
+public class ManageCustomParsersCommandHandler extends AbstractHandler {
+
+    @Override
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+        ManageCustomParsersDialog dialog = new ManageCustomParsersDialog(Display.getDefault().getActiveShell());
+        dialog.open();
+        return null;
+    }
+
+}
index fb80cfe12b101842ed00828dd42f406851e438c9..0eb3318a4cf4d50932923c37eaca0d0669cb6f6e 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.dialogs;\r
-\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.jface.wizard.WizardDialog;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomTxtParserWizard;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomXmlParserWizard;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.List;\r
-import org.eclipse.swt.widgets.Shell;\r
-\r
-public class ManageCustomParsersDialog extends Dialog {\r
-\r
-    private static final Image image = Activator.getDefault().getImageFromPath("/icons/etool16/customparser_wizard.gif"); //$NON-NLS-1$\r
-\r
-    Button txtButton;\r
-    Button xmlButton;\r
-    List parserList;\r
-    Button newButton;\r
-    Button editButton;\r
-    Button deleteButton;\r
-    Button importButton;\r
-    Button exportButton;\r
-\r
-    public ManageCustomParsersDialog(Shell parent) {\r
-        super(parent);\r
-        setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle());\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\r
-     */\r
-    @Override\r
-    protected Control createDialogArea(Composite parent) {\r
-        getShell().setText(Messages.ManageCustomParsersDialog_DialogHeader);\r
-        getShell().setImage(image);\r
-\r
-        Composite composite = (Composite) super.createDialogArea(parent);\r
-        composite.setLayout(new GridLayout(2, false));\r
-\r
-        Composite listContainer = new Composite(composite, SWT.NONE);\r
-        listContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        GridLayout lcgl = new GridLayout();\r
-        lcgl.marginHeight = 0;\r
-        lcgl.marginWidth = 0;\r
-        listContainer.setLayout(lcgl);\r
-\r
-        Composite radioContainer = new Composite(listContainer, SWT.NONE);\r
-        GridLayout rcgl = new GridLayout(2, true);\r
-        rcgl.marginHeight = 0;\r
-        rcgl.marginWidth = 0;\r
-        radioContainer.setLayout(rcgl);\r
-\r
-        txtButton = new Button(radioContainer, SWT.RADIO);\r
-        txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel);\r
-        txtButton.setSelection(true);\r
-        txtButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                fillParserList();\r
-            }});\r
-\r
-        xmlButton = new Button(radioContainer, SWT.RADIO);\r
-        xmlButton.setText("XML"); //$NON-NLS-1$\r
-        xmlButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                fillParserList();\r
-            }});\r
-\r
-        parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);\r
-        parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        parserList.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                if (parserList.getSelectionCount() == 0) {\r
-                    editButton.setEnabled(false);\r
-                    deleteButton.setEnabled(false);\r
-                    exportButton.setEnabled(false);\r
-                } else {\r
-                    editButton.setEnabled(true);\r
-                    deleteButton.setEnabled(true);\r
-                    exportButton.setEnabled(true);\r
-                }\r
-            }});\r
-\r
-        Composite buttonContainer = new Composite(composite, SWT.NULL);\r
-        buttonContainer.setLayout(new GridLayout());\r
-        buttonContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));\r
-\r
-        newButton = new Button(buttonContainer, SWT.PUSH);\r
-        newButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        newButton.setText(Messages.ManageCustomParsersDialog_NewButtonLabel);\r
-        newButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                WizardDialog dialog = null;\r
-                if (txtButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(), new CustomTxtParserWizard());\r
-                } else if (xmlButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(), new CustomXmlParserWizard());\r
-                }\r
-                if (dialog != null) {\r
-                    dialog.open();\r
-                    if (dialog.getReturnCode() == Window.OK) {\r
-                        fillParserList();\r
-                    }\r
-                }\r
-            }});\r
-\r
-        editButton = new Button(buttonContainer, SWT.PUSH);\r
-        editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel);\r
-        editButton.setEnabled(false);\r
-        editButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                WizardDialog dialog = null;\r
-                if (txtButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(),\r
-                            new CustomTxtParserWizard(CustomTxtTraceDefinition.load(parserList.getSelection()[0])));\r
-                } else if (xmlButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(),\r
-                            new CustomXmlParserWizard(CustomXmlTraceDefinition.load(parserList.getSelection()[0])));\r
-                }\r
-                if (dialog != null) {\r
-                    dialog.open();\r
-                    if (dialog.getReturnCode() == Window.OK) {\r
-                        fillParserList();\r
-                    }\r
-                }\r
-            }});\r
-\r
-        deleteButton = new Button(buttonContainer, SWT.PUSH);\r
-        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        deleteButton.setText(Messages.ManageCustomParsersDialog_DeleteButtonLabel);\r
-        deleteButton.setEnabled(false);\r
-        deleteButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                boolean confirm = MessageDialog.openQuestion(\r
-                        getShell(),\r
-                        Messages.ManageCustomParsersDialog_DeleteParserDialogHeader,\r
-                        Messages.ManageCustomParsersDialog_DeleteConfirmation + parserList.getSelection()[0] + "?"); //$NON-NLS-1$\r
-                if (confirm) {\r
-                    if (txtButton.getSelection()) {\r
-                        CustomTxtTraceDefinition.delete(parserList.getSelection()[0]);\r
-                    } else if (xmlButton.getSelection()) {\r
-                        CustomXmlTraceDefinition.delete(parserList.getSelection()[0]);\r
-                    }\r
-                    fillParserList();\r
-                }\r
-            }});\r
-\r
-        new Label(buttonContainer, SWT.NONE); // filler\r
-\r
-        importButton = new Button(buttonContainer, SWT.PUSH);\r
-        importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel);\r
-        importButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);\r
-                dialog.setText(Messages.ManageCustomParsersDialog_ImportParserSelection);\r
-                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$\r
-                String path = dialog.open();\r
-                if (path != null) {\r
-                    CustomTraceDefinition[] defs = null;\r
-                    if (txtButton.getSelection()) {\r
-                        defs = CustomTxtTraceDefinition.loadAll(path);\r
-                    } else if (xmlButton.getSelection()) {\r
-                        defs = CustomXmlTraceDefinition.loadAll(path);\r
-                    }\r
-                    if (defs != null && defs.length > 0) {\r
-                        for (CustomTraceDefinition def : defs) {\r
-                            def.save();\r
-                        }\r
-                        fillParserList();\r
-                    }\r
-                }\r
-            }});\r
-\r
-        exportButton = new Button(buttonContainer, SWT.PUSH);\r
-        exportButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        exportButton.setText(Messages.ManageCustomParsersDialog_ExportButtonLabel);\r
-        exportButton.setEnabled(false);\r
-        exportButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);\r
-                dialog.setText(Messages.ManageCustomParsersDialog_ExportParserSelection + parserList.getSelection()[0]);\r
-                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$\r
-                String path = dialog.open();\r
-                if (path != null) {\r
-                    CustomTraceDefinition def = null;\r
-                    if (txtButton.getSelection()) {\r
-                        def = CustomTxtTraceDefinition.load(parserList.getSelection()[0]);\r
-                    } else if (xmlButton.getSelection()) {\r
-                        def = CustomXmlTraceDefinition.load(parserList.getSelection()[0]);\r
-                    }\r
-                    if (def != null) {\r
-                        def.save(path);\r
-                    }\r
-                }\r
-            }});\r
-\r
-        fillParserList();\r
-\r
-        getShell().setMinimumSize(300, 275);\r
-        return composite;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)\r
-     */\r
-    @Override\r
-    protected void createButtonsForButtonBar(Composite parent) {\r
-        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, false);\r
-    }\r
-\r
-    private void fillParserList() {\r
-        parserList.removeAll();\r
-        if (txtButton.getSelection()) {\r
-            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                parserList.add(def.definitionName);\r
-            }\r
-        } else if (xmlButton.getSelection()) {\r
-            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                parserList.add(def.definitionName);\r
-            }\r
-        }\r
-        editButton.setEnabled(false);\r
-        deleteButton.setEnabled(false);\r
-        exportButton.setEnabled(false);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomTxtParserWizard;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomXmlParserWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+public class ManageCustomParsersDialog extends Dialog {
+
+    private static final Image image = Activator.getDefault().getImageFromPath("/icons/etool16/customparser_wizard.gif"); //$NON-NLS-1$
+
+    Button txtButton;
+    Button xmlButton;
+    List parserList;
+    Button newButton;
+    Button editButton;
+    Button deleteButton;
+    Button importButton;
+    Button exportButton;
+
+    public ManageCustomParsersDialog(Shell parent) {
+        super(parent);
+        setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle());
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        getShell().setText(Messages.ManageCustomParsersDialog_DialogHeader);
+        getShell().setImage(image);
+
+        Composite composite = (Composite) super.createDialogArea(parent);
+        composite.setLayout(new GridLayout(2, false));
+
+        Composite listContainer = new Composite(composite, SWT.NONE);
+        listContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        GridLayout lcgl = new GridLayout();
+        lcgl.marginHeight = 0;
+        lcgl.marginWidth = 0;
+        listContainer.setLayout(lcgl);
+
+        Composite radioContainer = new Composite(listContainer, SWT.NONE);
+        GridLayout rcgl = new GridLayout(2, true);
+        rcgl.marginHeight = 0;
+        rcgl.marginWidth = 0;
+        radioContainer.setLayout(rcgl);
+
+        txtButton = new Button(radioContainer, SWT.RADIO);
+        txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel);
+        txtButton.setSelection(true);
+        txtButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                fillParserList();
+            }});
+
+        xmlButton = new Button(radioContainer, SWT.RADIO);
+        xmlButton.setText("XML"); //$NON-NLS-1$
+        xmlButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                fillParserList();
+            }});
+
+        parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+        parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        parserList.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                if (parserList.getSelectionCount() == 0) {
+                    editButton.setEnabled(false);
+                    deleteButton.setEnabled(false);
+                    exportButton.setEnabled(false);
+                } else {
+                    editButton.setEnabled(true);
+                    deleteButton.setEnabled(true);
+                    exportButton.setEnabled(true);
+                }
+            }});
+
+        Composite buttonContainer = new Composite(composite, SWT.NULL);
+        buttonContainer.setLayout(new GridLayout());
+        buttonContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
+
+        newButton = new Button(buttonContainer, SWT.PUSH);
+        newButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        newButton.setText(Messages.ManageCustomParsersDialog_NewButtonLabel);
+        newButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                WizardDialog dialog = null;
+                if (txtButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(), new CustomTxtParserWizard());
+                } else if (xmlButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(), new CustomXmlParserWizard());
+                }
+                if (dialog != null) {
+                    dialog.open();
+                    if (dialog.getReturnCode() == Window.OK) {
+                        fillParserList();
+                    }
+                }
+            }});
+
+        editButton = new Button(buttonContainer, SWT.PUSH);
+        editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel);
+        editButton.setEnabled(false);
+        editButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                WizardDialog dialog = null;
+                if (txtButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(),
+                            new CustomTxtParserWizard(CustomTxtTraceDefinition.load(parserList.getSelection()[0])));
+                } else if (xmlButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(),
+                            new CustomXmlParserWizard(CustomXmlTraceDefinition.load(parserList.getSelection()[0])));
+                }
+                if (dialog != null) {
+                    dialog.open();
+                    if (dialog.getReturnCode() == Window.OK) {
+                        fillParserList();
+                    }
+                }
+            }});
+
+        deleteButton = new Button(buttonContainer, SWT.PUSH);
+        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        deleteButton.setText(Messages.ManageCustomParsersDialog_DeleteButtonLabel);
+        deleteButton.setEnabled(false);
+        deleteButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                boolean confirm = MessageDialog.openQuestion(
+                        getShell(),
+                        Messages.ManageCustomParsersDialog_DeleteParserDialogHeader,
+                        Messages.ManageCustomParsersDialog_DeleteConfirmation + parserList.getSelection()[0] + "?"); //$NON-NLS-1$
+                if (confirm) {
+                    if (txtButton.getSelection()) {
+                        CustomTxtTraceDefinition.delete(parserList.getSelection()[0]);
+                    } else if (xmlButton.getSelection()) {
+                        CustomXmlTraceDefinition.delete(parserList.getSelection()[0]);
+                    }
+                    fillParserList();
+                }
+            }});
+
+        new Label(buttonContainer, SWT.NONE); // filler
+
+        importButton = new Button(buttonContainer, SWT.PUSH);
+        importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel);
+        importButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
+                dialog.setText(Messages.ManageCustomParsersDialog_ImportParserSelection);
+                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
+                String path = dialog.open();
+                if (path != null) {
+                    CustomTraceDefinition[] defs = null;
+                    if (txtButton.getSelection()) {
+                        defs = CustomTxtTraceDefinition.loadAll(path);
+                    } else if (xmlButton.getSelection()) {
+                        defs = CustomXmlTraceDefinition.loadAll(path);
+                    }
+                    if (defs != null && defs.length > 0) {
+                        for (CustomTraceDefinition def : defs) {
+                            def.save();
+                        }
+                        fillParserList();
+                    }
+                }
+            }});
+
+        exportButton = new Button(buttonContainer, SWT.PUSH);
+        exportButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        exportButton.setText(Messages.ManageCustomParsersDialog_ExportButtonLabel);
+        exportButton.setEnabled(false);
+        exportButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
+                dialog.setText(Messages.ManageCustomParsersDialog_ExportParserSelection + parserList.getSelection()[0]);
+                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
+                String path = dialog.open();
+                if (path != null) {
+                    CustomTraceDefinition def = null;
+                    if (txtButton.getSelection()) {
+                        def = CustomTxtTraceDefinition.load(parserList.getSelection()[0]);
+                    } else if (xmlButton.getSelection()) {
+                        def = CustomXmlTraceDefinition.load(parserList.getSelection()[0]);
+                    }
+                    if (def != null) {
+                        def.save(path);
+                    }
+                }
+            }});
+
+        fillParserList();
+
+        getShell().setMinimumSize(300, 275);
+        return composite;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+    protected void createButtonsForButtonBar(Composite parent) {
+        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, false);
+    }
+
+    private void fillParserList() {
+        parserList.removeAll();
+        if (txtButton.getSelection()) {
+            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+                parserList.add(def.definitionName);
+            }
+        } else if (xmlButton.getSelection()) {
+            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                parserList.add(def.definitionName);
+            }
+        }
+        editButton.setEnabled(false);
+        deleteButton.setEnabled(false);
+        exportButton.setEnabled(false);
+    }
+
+}
index 35011cace0760398702cec85a5a39509005cee3b..1793371b3ae32805b5b7dcb68d39bcc91e237613 100644 (file)
@@ -1,43 +1,43 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.editors.handlers;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;\r
-import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.IWorkbench;\r
-import org.eclipse.ui.IWorkbenchPage;\r
-import org.eclipse.ui.PlatformUI;\r
-\r
-public class AddBookmarkHandler extends AbstractHandler {\r
-\r
-       @Override\r
-    public boolean isEnabled() {\r
-               return true;\r
-    }\r
-\r
-       @Override\r
-       public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        IWorkbench wb = PlatformUI.getWorkbench();\r
-        IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();\r
-        IEditorPart activeEditor = activePage.getActiveEditor();\r
-        if (activeEditor instanceof TmfEventsEditor) {\r
-               TmfEventsEditor editor = (TmfEventsEditor) activeEditor;\r
-               editor.addBookmark();\r
-        }\r
-               return null;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.editors.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+public class AddBookmarkHandler extends AbstractHandler {
+
+       @Override
+    public boolean isEnabled() {
+               return true;
+    }
+
+       @Override
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+        IWorkbench wb = PlatformUI.getWorkbench();
+        IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
+        IEditorPart activeEditor = activePage.getActiveEditor();
+        if (activeEditor instanceof TmfEventsEditor) {
+               TmfEventsEditor editor = (TmfEventsEditor) activeEditor;
+               editor.addBookmark();
+        }
+               return null;
+       }
+
+}
index a3db451b196fdb001a7336cfa439be83a63ebebf..36367fe50811b74330fa8e0ff8c4c2159e8ac1ca 100644 (file)
-# org.eclipse.linuxtools.tmf.ui.dialogs\r
-ManageCustomParsersDialog_DeleteButtonLabel=Delete\r
-ManageCustomParsersDialog_DeleteConfirmation=Are you sure you want to delete \r
-ManageCustomParsersDialog_DeleteParserDialogHeader=Delete Custom Parser\r
-ManageCustomParsersDialog_DialogHeader=Manage Custom Parsers\r
-ManageCustomParsersDialog_EditButtonLabel=Edit...\r
-ManageCustomParsersDialog_ExportButtonLabel=Export...\r
-ManageCustomParsersDialog_ExportParserSelection=Select file to export \r
-ManageCustomParsersDialog_ImportButtonLabel=Import...\r
-ManageCustomParsersDialog_ImportParserSelection=Select custom parser file to import\r
-ManageCustomParsersDialog_NewButtonLabel=New...\r
-ManageCustomParsersDialog_ParseButtonLabel=Parse...\r
-ManageCustomParsersDialog_ParseError=Parse Error\r
-ManageCustomParsersDialog_TextButtonLabel=Text\r
-ManageCustomParsersDialog_TraceSelection=Select log file to parse using \r
-\r
-# org.eclipse.linuxtools.tmf.ui.parsers.custom\r
-CustomTraceDefinition_messageTag=Message\r
-CustomTraceDefinition_otherTag=Other\r
-CustomTraceDefinition_timestampTag=Time Stamp\r
-CustomTxtTraceDefinition_action=action\r
-CustomTxtTraceDefinition_cardinality=Cardinality\r
-CustomTxtTraceDefinition_definition=Definition\r
-CustomTxtTraceDefinition_definitionRootElement=CustomTxtTraceDefinitionList\r
-CustomTxtTraceDefinition_format=format\r
-CustomTxtTraceDefinition_inputData=InputData\r
-CustomTxtTraceDefinition_inputLine=InputLine\r
-CustomTxtTraceDefinition_max=max\r
-CustomTxtTraceDefinition_min=min\r
-CustomTxtTraceDefinition_name=name\r
-CustomTxtTraceDefinition_outputColumn=OutputColumn\r
-CustomTxtTraceDefinition_regEx=RegEx\r
-CustomTxtTraceDefinition_timestampOutputFormat=TimeStampOutputFormat\r
-CustomXmlTraceDefinition_action=action\r
-CustomXmlTraceDefinition_attribute=Attribute\r
-CustomXmlTraceDefinition_definition=Definition\r
-CustomXmlTraceDefinition_definitionRootElement=CustomXMLTraceDefinitionList\r
-CustomXmlTraceDefinition_format=format\r
-CustomXmlTraceDefinition_ignoreTag=Ignore\r
-CustomXmlTraceDefinition_inputData=InputData\r
-CustomXmlTraceDefinition_inputElement=InputElement\r
-CustomXmlTraceDefinition_logEntry=logentry\r
-CustomXmlTraceDefinition_name=name\r
-CustomXmlTraceDefinition_outputColumn=OutputColumn\r
-CustomXmlTraceDefinition_timestampOutputFormat=TimeStampOutputFormat\r
-\r
-# org.eclipse.linuxtools.tmf.ui.viewers.events\r
-TmfEventsTable_AddBookmarkActionText=Add Bookmark...\r
-TmfEventsTable_AddBookmarkDialogText=Enter Bookmark name:\r
-TmfEventsTable_AddBookmarkDialogTitle=Add Bookmark\r
-TmfEventsTable_ApplyPresetFilterMenuName=Apply preset filter...\r
-TmfEventsTable_ClearFiltersActionText=Clear Filters\r
-TmfEventsTable_ContentColumnHeader=Content\r
-TmfEventsTable_FilterHint=<filter>\r
-TmfEventsTable_HideRawActionText=Hide Raw\r
-TmfEventsTable_HideTableActionText=Hide Table\r
-TmfEventsTable_ReferenceColumnHeader=File\r
-TmfEventsTable_RemoveBookmarkActionText=Remove Bookmark\r
-TmfEventsTable_SearchHint=<srch>\r
-TmfEventsTable_SearchingJobName=Searching...\r
-TmfEventsTable_ShowFilterBarActionText=Show Filter Bar\r
-TmfEventsTable_ShowRawActionText=Show Raw\r
-TmfEventsTable_ShowSearchBarActionText=Show Search Bar\r
-TmfEventsTable_ShowTableActionText=Show Table\r
-TmfEventsTable_SourceColumnHeader=Source\r
-TmfEventsTable_TimestampColumnHeader=Timestamp\r
-TmfEventsTable_TypeColumnHeader=Type\r
-\r
-# org.eclipse.linuxtools.tmf.ui.viewers.timegraph.dialogs\r
-TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS=Edit Profiling Options\r
-TmfTimeFilterDialog_TRACE_FILTER=Trace Filter\r
-TmfTimeFilterDialog_TRACE_FILTER_DESC=Define the filter set\r
-TmfTimeFilterDialog_TRACE_ID=Trace Id\r
-TmfTimeFilterDialog_TRACE_NAME=Trace Name\r
-TmfTimeLegend_LEGEND=Legend\r
-TmfTimeLegend_TRACE_STATES=Trace states\r
-TmfTimeLegend_TRACE_STATES_TITLE=States Transition Visualizer\r
-TmfTimeLegend_WINDOW_TITLE=Trace Visualizer's Legend\r
-TmfTimeLegend_StateTypeName=States\r
-\r
-# org.eclipse.linuxtools.tmf.ui.viewers.timegraph.widgets\r
-TmfTimeTipHandler_DURATION=Duration\r
-TmfTimeTipHandler_TRACE_DATE=Date\r
-TmfTimeTipHandler_TRACE_EVENT_TIME=Event Time\r
-TmfTimeTipHandler_TRACE_START_TIME=Start Time\r
-TmfTimeTipHandler_TRACE_STATE=State\r
-TmfTimeTipHandler_TRACE_STOP_TIME=Stop Time\r
-\r
-\r
-TmfTimeGraphViewer_ResetScaleActionNameText=Reset\r
-TmfTimeGraphViewer_ResetScaleActionToolTipText=Reset the Time Scale to Default\r
-TmfTimeGraphViewer_LegendActionNameText=Legend\r
-TmfTimeGraphViewer_LegendActionToolTipText=Show Legend\r
-TmfTimeGraphViewer_NextEventActionNameText=Next Event\r
-TmfTimeGraphViewer_NextEventActionToolTipText=Select Next Event\r
-TmfTimeGraphViewer_PreviousEventActionNameText=Previous Event\r
-TmfTimeGraphViewer_PreviousEventActionToolTipText=Select Previous Event\r
-TmfTimeGraphViewer_NextItemActionNameText=Next Item\r
-TmfTimeGraphViewer_NextItemActionToolTipText=Select Next Item\r
-TmfTimeGraphViewer_PreviousItemActionNameText=Previous Item\r
-TmfTimeGraphViewer_PreviousItemActionToolTipText=Select Previous Item\r
-TmfTimeGraphViewer_ZoomInActionNameText=Zoom In\r
-TmfTimeGraphViewer_ZoomInActionToolTipText=Zoom In\r
-TmfTimeGraphViewer_ZoomOutActionNameText=Zoom Out\r
-TmfTimeGraphViewer_ZoomOutActionToolTipText=Zoom Out\r
-\r
-# org.eclipse.linuxtools.tmf.ui.views.colors\r
-ColorsView_AddActionToolTipText=Insert new color setting\r
-ColorsView_BackgroundButtonText=BG\r
-ColorsView_BackgroundDialogText=Set background color\r
-ColorsView_DeleteActionToolTipText=Delete color setting\r
-ColorsView_ExportActionToolTipText=Export color settings\r
-ColorsView_FilterButtonText=Filter...\r
-ColorsView_ForegroundButtonText=FG\r
-ColorsView_ForegroundDialogText=Set foreground color\r
-ColorsView_ImportActionToolTipText=Import color settings\r
-ColorsView_ImportOverwriteDialogMessage1=Do you want to overwrite the current color settings?\n\r
-ColorsView_ImportOverwriteDialogMessage2=Answering No will insert the imported settings above the current selection.\r
-ColorsView_ImportOverwriteDialogTitle=Overwrite current settings\r
-ColorsView_MoveDownActionToolTipText=Decrease priority\r
-ColorsView_MoveUpActionToolTipText=Increase priority\r
-ColorsView_TickButtonText=Tick\r
-TickColorDialog_TickColorDialogTitle=Choose tick color\r
-\r
-# org.eclipse.linuxtools.tmf.ui.wizards\r
-CustomTxtParserInputWizardPage_addChildLine=Add child line\r
-CustomTxtParserInputWizardPage_addGroup=Add group\r
-CustomTxtParserInputWizardPage_addNextLine=Add next line\r
-CustomTxtParserInputWizardPage_append=Append\r
-CustomTxtParserInputWizardPage_appendWith=Append with |\r
-CustomTxtParserInputWizardPage_capturedGroup=Captured group\r
-CustomTxtParserInputWizardPage_cardinality=Cardinality:\r
-CustomTxtParserInputWizardPage_dateFormatHelp=Date Format Help\r
-CustomTxtParserInputWizardPage_desccriptionEdit=Edit an existing custom parser for text log files\r
-CustomTxtParserInputWizardPage_descriptionNew=Create a new custom parser for text log files\r
-CustomTxtParserInputWizardPage_format=format:\r
-CustomTxtParserInputWizardPage_group=Group \r
-CustomTxtParserInputWizardPage_highlightAll=Highlight All\r
-CustomTxtParserInputWizardPage_logType=Log type:\r
-CustomTxtParserInputWizardPage_matchingLineRoot=Matching root line : \r
-CustomTxtParserInputWizardPage_matchingOtherLine=Matching other line: \r
-CustomTxtParserInputWizardPage_matchingRootLine=matchingRootLine\r
-CustomTxtParserInputWizardPage_max=max:\r
-CustomTxtParserInputWizardPage_min=min:\r
-CustomTxtParserInputWizardPage_moveDown=Move down\r
-CustomTxtParserInputWizardPage_moveUp=Move up\r
-CustomTxtParserInputWizardPage_name=name:\r
-CustomTxtParserInputWizardPage_newGroup=New group\r
-CustomTxtParserInputWizardPage_noMatch=*no match*\r
-CustomTxtParserInputWizardPage_noMatchingGroup=*no matching group*\r
-CustomTxtParserInputWizardPage_noMatchingLine=*no matching line*\r
-CustomTxtParserInputWizardPage_noMatchingTimestamp=*no matching timestamp*\r
-CustomTxtParserInputWizardPage_noMathcingLine=*no matching line*\r
-CustomTxtParserInputWizardPage_nonMatchingLine=Non-matching line\n\r
-CustomTxtParserInputWizardPage_noTimestampGroup=*no timestamp group*\r
-CustomTxtParserInputWizardPage_preview=Preview:\r
-CustomTxtParserInputWizardPage_previewInput=Preview input\r
-CustomTxtParserInputWizardPage_previewLegend=Preview Legend\r
-CustomTxtParserInputWizardPage_regularExpression=Regular expression:\r
-CustomTxtParserInputWizardPage_regularExpressionHelp=Regular Expression Help\r
-CustomTxtParserInputWizardPage_removeGroup=Remove group\r
-CustomTxtParserInputWizardPage_removeLine=Remove line\r
-CustomTxtParserInputWizardPage_set=Set\r
-CustomTxtParserInputWizardPage_timestampFormat=Time Stamp format:\r
-CustomTxtParserInputWizardPage_uncapturedText=Uncaptured text\r
-CustomTxtParserInputWizardPage_unidentifiedCaptureGroup=Unidentified captured group\r
-CustomTxtParserInputWizardPage_windowTitleEdit=Edit Custom Text Parser\r
-CustomTxtParserInputWizardPage_windowTitleNew=New Custom Text Parser\r
-CustomTxtParserOutputWizardPage_description=Customize the output of the parser\r
-CustomTxtParserOutputWizardPage_moveAfter=Move After\r
-CustomTxtParserOutputWizardPage_moveBefore=Move Before\r
-CustomTxtParserOutputWizardPage_visible=Visible\r
-CustomXmlParserInputWizardPage_emptyLogTypeError=Enter a name for the new log type. \r
-CustomXmlParserInputWizardPage_duplicatelogTypeError=The log type name already exists. \r
-CustomXmlParserInputWizardPage_noDocumentError=Add a document element. \r
-CustomXmlParserInputWizardPage_missingLogEntryError=Identify a Log Entry element. \r
-CustomXmlParserInputWizardPage_missingTimestampFmtError=Enter the output format for the Time Stamp field. \r
-CustomXmlParserInputWizardPage_invalidTimestampFmtError=Enter a valid output format for the Time Stamp field. \r
-CustomXmlParserInputWizardPage_notimestamporAttributeError=*no time stamp element or attribute*\r
-CustomXmlParserInputWizardPage_missingDocumentElementError=Enter a name for the document element. \r
-CustomXmlParserInputWizardPage_timestampElementPrompt=Element\r
-CustomXmlParserInputWizardPage_timestampFormatPrompt=Enter the input format for the Time Stamp\r
-CustomXmlParserInputWizardPage_missingInputElementNameError=Enter a name for the input\r
-CustomXmlParserInputWizardPage_attributePrompt=Attribute\r
-CustomXmlParserInputWizardPage_missingAttribute=Enter a name for the attribute\r
-CustomXmlParserInputWizardPage_duplicateAttributeError=Duplicate attribute names\r
-CustomXmlParserInputWizardPage_missingTimestampInFmtError=Enter the input format for the Time Stamp\r
-CustomXmlParserInputWizardPage_invalidTimestampInFmtError=Enter a valid input format for the Time Stamp\r
-CustomXmlParserInputWizardPage_missingDataGroupNameError=Enter a name for the data group\r
-CustomXmlParserInputWizardPage_missingElementNameError=Enter a name for the element\r
-CustomXmlParserInputWizardPage_duplicateElementNameError=Duplicate element names \r
-CustomXmlParserInputWizardPage_addAttribute=Add attribute\r
-CustomXmlParserInputWizardPage_addChildElement=Add child element\r
-CustomXmlParserInputWizardPage_addDocumentEleemnt=Add document element\r
-CustomXmlParserInputWizardPage_addDocumentElement=Add document element\r
-CustomXmlParserInputWizardPage_addNextElement=Add next element\r
-CustomXmlParserInputWizardPage_append=Append\r
-CustomXmlParserInputWizardPage_appendWith=Append with |\r
-CustomXmlParserInputWizardPage_attibute=Attribute\r
-CustomXmlParserInputWizardPage_dateFormatHelp=Date Format Help\r
-CustomXmlParserInputWizardPage_descriptionEdit=Edit an existing custom parser for XML log files\r
-CustomXmlParserInputWizardPage_descriptionNew=Create a new custom parser for XML log files\r
-CustomXmlParserInputWizardPage_elementName=Element name:\r
-CustomXmlParserInputWizardPage_feelingLucky=Feeling lucky\r
-CustomXmlParserInputWizardPage_format=format:\r
-CustomXmlParserInputWizardPage_logEntry=Log Entry\r
-CustomXmlParserInputWizardPage_logType=Log type:\r
-CustomXmlParserInputWizardPage_moveDown=Move down\r
-CustomXmlParserInputWizardPage_moveUp=Move up\r
-CustomXmlParserInputWizardPage_name=name:\r
-CustomXmlParserInputWizardPage_newAttibute=New attribute\r
-CustomXmlParserInputWizardPage_noMatch=*no match*\r
-CustomXmlParserInputWizardPage_noMatchingAttribute=*no matching attribute*\r
-CustomXmlParserInputWizardPage_noMatchingElement=*no matching element*\r
-CustomXmlParserInputWizardPage_preview=Preview:\r
-CustomXmlParserInputWizardPage_previewInput=Preview input\r
-CustomXmlParserInputWizardPage_removeAttribute=Remove attribute\r
-CustomXmlParserInputWizardPage_removeElement=Remove element\r
-CustomXmlParserInputWizardPage_set=Set\r
-CustomXmlParserInputWizardPage_tagName=tag name:\r
-CustomXmlParserInputWizardPage_timestampFormat=Time Stamp format:\r
-CustomXmlParserInputWizardPage_titleEdit=Edit Custom XML Parser\r
-CustomXmlParserInputWizardPage_titleNew=New Custom XML Parser\r
-CustomXmlParserOutputWizardPage_description=Customize the output of the parser\r
-CustomXmlParserOutputWizardPage_moveAfter=Move After\r
-CustomXmlParserOutputWizardPage_moveBefore=Move Before\r
-CustomXmlParserOutputWizardPage_visible=Visible\r
-\r
-# org.eclipse.linuxtools.tmf.ui.views.filter\r
-FilterDialog_FilterDialogTitle=Edit filter\r
-FilterView_AddActionToolTipText=Add new filter\r
-FilterView_DeleteActionToolTipText=Delete filter node\r
-FilterView_ExportActionToolTipText=Export filters\r
-FilterView_FileDialogFilterName=TMF Filter files\r
-FilterView_ImportActionToolTipText=Import filters\r
-FilterView_SaveActionToolTipText=Save filters\r
-FilterViewer_EmptyTreeHintText=<Right-click to add filter node>\r
-FilterViewer_CommonCategory=[common]\r
-FilterViewer_AlphaButtonText=Alpha\r
-FilterViewer_DeleteActionText=Delete\r
-FilterViewer_FieldLabel=field:\r
-FilterViewer_FilterNameHint=type filter name\r
-FilterViewer_IgnoreCaseButtonText=ignore case\r
-FilterViewer_NameLabel=name:\r
-FilterViewer_NewPrefix=New\r
-FilterViewer_NotLabel=not:\r
-FilterViewer_NumButtonText=Num\r
-FilterViewer_RegexHint=type regular expression\r
-FilterViewer_RegexLabel=regex:\r
-FilterViewer_ResultLabel=result:\r
-FilterViewer_TimestampButtonText=Timestamp\r
-FilterViewer_TypeLabel=type:\r
-FilterViewer_ValueHint=type value\r
-FilterViewer_ValueLabel=value:\r
-\r
-TmfView_PinActionNameText=Pin View\r
-TmfView_PinActionToolTipText=Pin View\r
-\r
+# org.eclipse.linuxtools.tmf.ui.dialogs
+ManageCustomParsersDialog_DeleteButtonLabel=Delete
+ManageCustomParsersDialog_DeleteConfirmation=Are you sure you want to delete 
+ManageCustomParsersDialog_DeleteParserDialogHeader=Delete Custom Parser
+ManageCustomParsersDialog_DialogHeader=Manage Custom Parsers
+ManageCustomParsersDialog_EditButtonLabel=Edit...
+ManageCustomParsersDialog_ExportButtonLabel=Export...
+ManageCustomParsersDialog_ExportParserSelection=Select file to export 
+ManageCustomParsersDialog_ImportButtonLabel=Import...
+ManageCustomParsersDialog_ImportParserSelection=Select custom parser file to import
+ManageCustomParsersDialog_NewButtonLabel=New...
+ManageCustomParsersDialog_ParseButtonLabel=Parse...
+ManageCustomParsersDialog_ParseError=Parse Error
+ManageCustomParsersDialog_TextButtonLabel=Text
+ManageCustomParsersDialog_TraceSelection=Select log file to parse using 
+
+# org.eclipse.linuxtools.tmf.ui.parsers.custom
+CustomTraceDefinition_messageTag=Message
+CustomTraceDefinition_otherTag=Other
+CustomTraceDefinition_timestampTag=Time Stamp
+CustomTxtTraceDefinition_action=action
+CustomTxtTraceDefinition_cardinality=Cardinality
+CustomTxtTraceDefinition_definition=Definition
+CustomTxtTraceDefinition_definitionRootElement=CustomTxtTraceDefinitionList
+CustomTxtTraceDefinition_format=format
+CustomTxtTraceDefinition_inputData=InputData
+CustomTxtTraceDefinition_inputLine=InputLine
+CustomTxtTraceDefinition_max=max
+CustomTxtTraceDefinition_min=min
+CustomTxtTraceDefinition_name=name
+CustomTxtTraceDefinition_outputColumn=OutputColumn
+CustomTxtTraceDefinition_regEx=RegEx
+CustomTxtTraceDefinition_timestampOutputFormat=TimeStampOutputFormat
+CustomXmlTraceDefinition_action=action
+CustomXmlTraceDefinition_attribute=Attribute
+CustomXmlTraceDefinition_definition=Definition
+CustomXmlTraceDefinition_definitionRootElement=CustomXMLTraceDefinitionList
+CustomXmlTraceDefinition_format=format
+CustomXmlTraceDefinition_ignoreTag=Ignore
+CustomXmlTraceDefinition_inputData=InputData
+CustomXmlTraceDefinition_inputElement=InputElement
+CustomXmlTraceDefinition_logEntry=logentry
+CustomXmlTraceDefinition_name=name
+CustomXmlTraceDefinition_outputColumn=OutputColumn
+CustomXmlTraceDefinition_timestampOutputFormat=TimeStampOutputFormat
+
+# org.eclipse.linuxtools.tmf.ui.viewers.events
+TmfEventsTable_AddBookmarkActionText=Add Bookmark...
+TmfEventsTable_AddBookmarkDialogText=Enter Bookmark name:
+TmfEventsTable_AddBookmarkDialogTitle=Add Bookmark
+TmfEventsTable_ApplyPresetFilterMenuName=Apply preset filter...
+TmfEventsTable_ClearFiltersActionText=Clear Filters
+TmfEventsTable_ContentColumnHeader=Content
+TmfEventsTable_FilterHint=<filter>
+TmfEventsTable_HideRawActionText=Hide Raw
+TmfEventsTable_HideTableActionText=Hide Table
+TmfEventsTable_ReferenceColumnHeader=File
+TmfEventsTable_RemoveBookmarkActionText=Remove Bookmark
+TmfEventsTable_SearchHint=<srch>
+TmfEventsTable_SearchingJobName=Searching...
+TmfEventsTable_ShowFilterBarActionText=Show Filter Bar
+TmfEventsTable_ShowRawActionText=Show Raw
+TmfEventsTable_ShowSearchBarActionText=Show Search Bar
+TmfEventsTable_ShowTableActionText=Show Table
+TmfEventsTable_SourceColumnHeader=Source
+TmfEventsTable_TimestampColumnHeader=Timestamp
+TmfEventsTable_TypeColumnHeader=Type
+
+# org.eclipse.linuxtools.tmf.ui.viewers.timegraph.dialogs
+TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS=Edit Profiling Options
+TmfTimeFilterDialog_TRACE_FILTER=Trace Filter
+TmfTimeFilterDialog_TRACE_FILTER_DESC=Define the filter set
+TmfTimeFilterDialog_TRACE_ID=Trace Id
+TmfTimeFilterDialog_TRACE_NAME=Trace Name
+TmfTimeLegend_LEGEND=Legend
+TmfTimeLegend_TRACE_STATES=Trace states
+TmfTimeLegend_TRACE_STATES_TITLE=States Transition Visualizer
+TmfTimeLegend_WINDOW_TITLE=Trace Visualizer's Legend
+TmfTimeLegend_StateTypeName=States
+
+# org.eclipse.linuxtools.tmf.ui.viewers.timegraph.widgets
+TmfTimeTipHandler_DURATION=Duration
+TmfTimeTipHandler_TRACE_DATE=Date
+TmfTimeTipHandler_TRACE_EVENT_TIME=Event Time
+TmfTimeTipHandler_TRACE_START_TIME=Start Time
+TmfTimeTipHandler_TRACE_STATE=State
+TmfTimeTipHandler_TRACE_STOP_TIME=Stop Time
+
+
+TmfTimeGraphViewer_ResetScaleActionNameText=Reset
+TmfTimeGraphViewer_ResetScaleActionToolTipText=Reset the Time Scale to Default
+TmfTimeGraphViewer_LegendActionNameText=Legend
+TmfTimeGraphViewer_LegendActionToolTipText=Show Legend
+TmfTimeGraphViewer_NextEventActionNameText=Next Event
+TmfTimeGraphViewer_NextEventActionToolTipText=Select Next Event
+TmfTimeGraphViewer_PreviousEventActionNameText=Previous Event
+TmfTimeGraphViewer_PreviousEventActionToolTipText=Select Previous Event
+TmfTimeGraphViewer_NextItemActionNameText=Next Item
+TmfTimeGraphViewer_NextItemActionToolTipText=Select Next Item
+TmfTimeGraphViewer_PreviousItemActionNameText=Previous Item
+TmfTimeGraphViewer_PreviousItemActionToolTipText=Select Previous Item
+TmfTimeGraphViewer_ZoomInActionNameText=Zoom In
+TmfTimeGraphViewer_ZoomInActionToolTipText=Zoom In
+TmfTimeGraphViewer_ZoomOutActionNameText=Zoom Out
+TmfTimeGraphViewer_ZoomOutActionToolTipText=Zoom Out
+
+# org.eclipse.linuxtools.tmf.ui.views.colors
+ColorsView_AddActionToolTipText=Insert new color setting
+ColorsView_BackgroundButtonText=BG
+ColorsView_BackgroundDialogText=Set background color
+ColorsView_DeleteActionToolTipText=Delete color setting
+ColorsView_ExportActionToolTipText=Export color settings
+ColorsView_FilterButtonText=Filter...
+ColorsView_ForegroundButtonText=FG
+ColorsView_ForegroundDialogText=Set foreground color
+ColorsView_ImportActionToolTipText=Import color settings
+ColorsView_ImportOverwriteDialogMessage1=Do you want to overwrite the current color settings?\n
+ColorsView_ImportOverwriteDialogMessage2=Answering No will insert the imported settings above the current selection.
+ColorsView_ImportOverwriteDialogTitle=Overwrite current settings
+ColorsView_MoveDownActionToolTipText=Decrease priority
+ColorsView_MoveUpActionToolTipText=Increase priority
+ColorsView_TickButtonText=Tick
+TickColorDialog_TickColorDialogTitle=Choose tick color
+
+# org.eclipse.linuxtools.tmf.ui.wizards
+CustomTxtParserInputWizardPage_addChildLine=Add child line
+CustomTxtParserInputWizardPage_addGroup=Add group
+CustomTxtParserInputWizardPage_addNextLine=Add next line
+CustomTxtParserInputWizardPage_append=Append
+CustomTxtParserInputWizardPage_appendWith=Append with |
+CustomTxtParserInputWizardPage_capturedGroup=Captured group
+CustomTxtParserInputWizardPage_cardinality=Cardinality:
+CustomTxtParserInputWizardPage_dateFormatHelp=Date Format Help
+CustomTxtParserInputWizardPage_desccriptionEdit=Edit an existing custom parser for text log files
+CustomTxtParserInputWizardPage_descriptionNew=Create a new custom parser for text log files
+CustomTxtParserInputWizardPage_format=format:
+CustomTxtParserInputWizardPage_group=Group 
+CustomTxtParserInputWizardPage_highlightAll=Highlight All
+CustomTxtParserInputWizardPage_logType=Log type:
+CustomTxtParserInputWizardPage_matchingLineRoot=Matching root line : 
+CustomTxtParserInputWizardPage_matchingOtherLine=Matching other line: 
+CustomTxtParserInputWizardPage_matchingRootLine=matchingRootLine
+CustomTxtParserInputWizardPage_max=max:
+CustomTxtParserInputWizardPage_min=min:
+CustomTxtParserInputWizardPage_moveDown=Move down
+CustomTxtParserInputWizardPage_moveUp=Move up
+CustomTxtParserInputWizardPage_name=name:
+CustomTxtParserInputWizardPage_newGroup=New group
+CustomTxtParserInputWizardPage_noMatch=*no match*
+CustomTxtParserInputWizardPage_noMatchingGroup=*no matching group*
+CustomTxtParserInputWizardPage_noMatchingLine=*no matching line*
+CustomTxtParserInputWizardPage_noMatchingTimestamp=*no matching timestamp*
+CustomTxtParserInputWizardPage_noMathcingLine=*no matching line*
+CustomTxtParserInputWizardPage_nonMatchingLine=Non-matching line\n
+CustomTxtParserInputWizardPage_noTimestampGroup=*no timestamp group*
+CustomTxtParserInputWizardPage_preview=Preview:
+CustomTxtParserInputWizardPage_previewInput=Preview input
+CustomTxtParserInputWizardPage_previewLegend=Preview Legend
+CustomTxtParserInputWizardPage_regularExpression=Regular expression:
+CustomTxtParserInputWizardPage_regularExpressionHelp=Regular Expression Help
+CustomTxtParserInputWizardPage_removeGroup=Remove group
+CustomTxtParserInputWizardPage_removeLine=Remove line
+CustomTxtParserInputWizardPage_set=Set
+CustomTxtParserInputWizardPage_timestampFormat=Time Stamp format:
+CustomTxtParserInputWizardPage_uncapturedText=Uncaptured text
+CustomTxtParserInputWizardPage_unidentifiedCaptureGroup=Unidentified captured group
+CustomTxtParserInputWizardPage_windowTitleEdit=Edit Custom Text Parser
+CustomTxtParserInputWizardPage_windowTitleNew=New Custom Text Parser
+CustomTxtParserOutputWizardPage_description=Customize the output of the parser
+CustomTxtParserOutputWizardPage_moveAfter=Move After
+CustomTxtParserOutputWizardPage_moveBefore=Move Before
+CustomTxtParserOutputWizardPage_visible=Visible
+CustomXmlParserInputWizardPage_emptyLogTypeError=Enter a name for the new log type. 
+CustomXmlParserInputWizardPage_duplicatelogTypeError=The log 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_invalidTimestampFmtError=Enter a valid output format for the Time Stamp field. 
+CustomXmlParserInputWizardPage_notimestamporAttributeError=*no time stamp element or attribute*
+CustomXmlParserInputWizardPage_missingDocumentElementError=Enter a name for the document element. 
+CustomXmlParserInputWizardPage_timestampElementPrompt=Element
+CustomXmlParserInputWizardPage_timestampFormatPrompt=Enter the input format for the Time Stamp
+CustomXmlParserInputWizardPage_missingInputElementNameError=Enter a name for the input
+CustomXmlParserInputWizardPage_attributePrompt=Attribute
+CustomXmlParserInputWizardPage_missingAttribute=Enter a name for the attribute
+CustomXmlParserInputWizardPage_duplicateAttributeError=Duplicate attribute names
+CustomXmlParserInputWizardPage_missingTimestampInFmtError=Enter the input format for the Time Stamp
+CustomXmlParserInputWizardPage_invalidTimestampInFmtError=Enter a valid input format for the Time Stamp
+CustomXmlParserInputWizardPage_missingDataGroupNameError=Enter a name for the data group
+CustomXmlParserInputWizardPage_missingElementNameError=Enter a name for the element
+CustomXmlParserInputWizardPage_duplicateElementNameError=Duplicate element names 
+CustomXmlParserInputWizardPage_addAttribute=Add attribute
+CustomXmlParserInputWizardPage_addChildElement=Add child element
+CustomXmlParserInputWizardPage_addDocumentEleemnt=Add document element
+CustomXmlParserInputWizardPage_addDocumentElement=Add document element
+CustomXmlParserInputWizardPage_addNextElement=Add next element
+CustomXmlParserInputWizardPage_append=Append
+CustomXmlParserInputWizardPage_appendWith=Append with |
+CustomXmlParserInputWizardPage_attibute=Attribute
+CustomXmlParserInputWizardPage_dateFormatHelp=Date Format Help
+CustomXmlParserInputWizardPage_descriptionEdit=Edit an existing custom parser for XML log files
+CustomXmlParserInputWizardPage_descriptionNew=Create a new custom parser for XML log files
+CustomXmlParserInputWizardPage_elementName=Element name:
+CustomXmlParserInputWizardPage_feelingLucky=Feeling lucky
+CustomXmlParserInputWizardPage_format=format:
+CustomXmlParserInputWizardPage_logEntry=Log Entry
+CustomXmlParserInputWizardPage_logType=Log type:
+CustomXmlParserInputWizardPage_moveDown=Move down
+CustomXmlParserInputWizardPage_moveUp=Move up
+CustomXmlParserInputWizardPage_name=name:
+CustomXmlParserInputWizardPage_newAttibute=New attribute
+CustomXmlParserInputWizardPage_noMatch=*no match*
+CustomXmlParserInputWizardPage_noMatchingAttribute=*no matching attribute*
+CustomXmlParserInputWizardPage_noMatchingElement=*no matching element*
+CustomXmlParserInputWizardPage_preview=Preview:
+CustomXmlParserInputWizardPage_previewInput=Preview input
+CustomXmlParserInputWizardPage_removeAttribute=Remove attribute
+CustomXmlParserInputWizardPage_removeElement=Remove element
+CustomXmlParserInputWizardPage_set=Set
+CustomXmlParserInputWizardPage_tagName=tag name:
+CustomXmlParserInputWizardPage_timestampFormat=Time Stamp format:
+CustomXmlParserInputWizardPage_titleEdit=Edit Custom XML Parser
+CustomXmlParserInputWizardPage_titleNew=New Custom XML Parser
+CustomXmlParserOutputWizardPage_description=Customize the output of the parser
+CustomXmlParserOutputWizardPage_moveAfter=Move After
+CustomXmlParserOutputWizardPage_moveBefore=Move Before
+CustomXmlParserOutputWizardPage_visible=Visible
+
+# org.eclipse.linuxtools.tmf.ui.views.filter
+FilterDialog_FilterDialogTitle=Edit filter
+FilterView_AddActionToolTipText=Add new filter
+FilterView_DeleteActionToolTipText=Delete filter node
+FilterView_ExportActionToolTipText=Export filters
+FilterView_FileDialogFilterName=TMF Filter files
+FilterView_ImportActionToolTipText=Import filters
+FilterView_SaveActionToolTipText=Save filters
+FilterViewer_EmptyTreeHintText=<Right-click to add filter node>
+FilterViewer_CommonCategory=[common]
+FilterViewer_AlphaButtonText=Alpha
+FilterViewer_DeleteActionText=Delete
+FilterViewer_FieldLabel=field:
+FilterViewer_FilterNameHint=type filter name
+FilterViewer_IgnoreCaseButtonText=ignore case
+FilterViewer_NameLabel=name:
+FilterViewer_NewPrefix=New
+FilterViewer_NotLabel=not:
+FilterViewer_NumButtonText=Num
+FilterViewer_RegexHint=type regular expression
+FilterViewer_RegexLabel=regex:
+FilterViewer_ResultLabel=result:
+FilterViewer_TimestampButtonText=Timestamp
+FilterViewer_TypeLabel=type:
+FilterViewer_ValueHint=type value
+FilterViewer_ValueLabel=value:
+
+TmfView_PinActionNameText=Pin View
+TmfView_PinActionToolTipText=Pin View
+
index 631003e0b8c711244074a4e466e5b8f72376ecab..6c70b15436c258ec32cb717d1ab32100dbd4f1b1 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Arrays;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-public class CustomEvent extends TmfEvent {\r
-\r
-    protected static final String TIMESTAMP_INPUT_FORMAT_KEY = "CE_TS_I_F"; //$NON-NLS-1$\r
-    protected static final String NO_MESSAGE = ""; //$NON-NLS-1$\r
-    public static final byte TIMESTAMP_SCALE = -3;\r
-    \r
-    protected CustomTraceDefinition fDefinition;\r
-    protected Map<String, String> fData;\r
-    private TmfEventField[] fColumnData;\r
-\r
-    public CustomEvent(CustomTraceDefinition definition) {\r
-        fDefinition = definition;\r
-        fData = new HashMap<String, String>();\r
-    }\r
-\r
-    public CustomEvent(CustomTraceDefinition definition, TmfEvent other) {\r
-        super(other);\r
-        fDefinition = definition;\r
-        fData = new HashMap<String, String>();\r
-    }\r
-\r
-    public CustomEvent(CustomTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {\r
-        super(parentTrace, timestamp, source, type, null, reference);\r
-        fDefinition = definition;\r
-        fData = new HashMap<String, String>();\r
-    }\r
-\r
-    @Override\r
-    public ITmfTimestamp getTimestamp() {\r
-        if (fData != null) processData();\r
-        return super.getTimestamp();\r
-    }\r
-\r
-    public TmfEventField[] extractItemFields() {\r
-        if (fData != null) processData();\r
-        return Arrays.copyOf(fColumnData, fColumnData.length);\r
-    }\r
-\r
-    private void processData() {\r
-        String timeStampString = fData.get(CustomTraceDefinition.TAG_TIMESTAMP);\r
-        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
-        Date date = null;\r
-        if (timeStampInputFormat != null && timeStampString != null) {\r
-            SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampInputFormat);\r
-            try {\r
-                date = dateFormat.parse(timeStampString);\r
-                setTimestamp(new TmfTimestamp(date.getTime(), TIMESTAMP_SCALE));\r
-            } catch (ParseException e) {\r
-                setTimestamp(TmfTimestamp.ZERO);\r
-            }\r
-        } else {\r
-            setTimestamp(TmfTimestamp.ZERO);\r
-        }\r
-        \r
-        int i = 0;\r
-        fColumnData = new TmfEventField[fDefinition.outputs.size()];\r
-        for (OutputColumn outputColumn : fDefinition.outputs) {\r
-            String value = fData.get(outputColumn.name);\r
-            if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) {\r
-                SimpleDateFormat dateFormat = new SimpleDateFormat(fDefinition.timeStampOutputFormat);\r
-                fColumnData[i++] = new TmfEventField(outputColumn.name, dateFormat.format(date));\r
-            } else {\r
-                fColumnData[i++] = new TmfEventField(outputColumn.name, (value != null ? value : "")); //$NON-NLS-1$\r
-            }\r
-        }\r
-        CustomEventContent content = (CustomEventContent) getContent();\r
-        content.setFields(fColumnData);\r
-        fData = null;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = super.hashCode();\r
-        result = prime * result + ((fDefinition == null) ? 0 : fDefinition.hashCode());\r
-        return result;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (!super.equals(obj)) {\r
-            return false;\r
-        }\r
-        if (!(obj instanceof CustomEvent)) {\r
-            return false;\r
-        }\r
-        CustomEvent other = (CustomEvent) obj;\r
-        if (fDefinition == null) {\r
-            if (other.fDefinition != null) {\r
-                return false;\r
-            }\r
-        } else if (!fDefinition.equals(other.fDefinition)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+public class CustomEvent extends TmfEvent {
+
+    protected static final String TIMESTAMP_INPUT_FORMAT_KEY = "CE_TS_I_F"; //$NON-NLS-1$
+    protected static final String NO_MESSAGE = ""; //$NON-NLS-1$
+    public static final byte TIMESTAMP_SCALE = -3;
+    
+    protected CustomTraceDefinition fDefinition;
+    protected Map<String, String> fData;
+    private TmfEventField[] fColumnData;
+
+    public CustomEvent(CustomTraceDefinition definition) {
+        fDefinition = definition;
+        fData = new HashMap<String, String>();
+    }
+
+    public CustomEvent(CustomTraceDefinition definition, TmfEvent other) {
+        super(other);
+        fDefinition = definition;
+        fData = new HashMap<String, String>();
+    }
+
+    public CustomEvent(CustomTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
+        super(parentTrace, timestamp, source, type, null, reference);
+        fDefinition = definition;
+        fData = new HashMap<String, String>();
+    }
+
+    @Override
+    public ITmfTimestamp getTimestamp() {
+        if (fData != null) processData();
+        return super.getTimestamp();
+    }
+
+    public TmfEventField[] extractItemFields() {
+        if (fData != null) processData();
+        return Arrays.copyOf(fColumnData, fColumnData.length);
+    }
+
+    private void processData() {
+        String timeStampString = fData.get(CustomTraceDefinition.TAG_TIMESTAMP);
+        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+        Date date = null;
+        if (timeStampInputFormat != null && timeStampString != null) {
+            SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampInputFormat);
+            try {
+                date = dateFormat.parse(timeStampString);
+                setTimestamp(new TmfTimestamp(date.getTime(), TIMESTAMP_SCALE));
+            } catch (ParseException e) {
+                setTimestamp(TmfTimestamp.ZERO);
+            }
+        } else {
+            setTimestamp(TmfTimestamp.ZERO);
+        }
+        
+        int i = 0;
+        fColumnData = new TmfEventField[fDefinition.outputs.size()];
+        for (OutputColumn outputColumn : fDefinition.outputs) {
+            String value = fData.get(outputColumn.name);
+            if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) {
+                SimpleDateFormat dateFormat = new SimpleDateFormat(fDefinition.timeStampOutputFormat);
+                fColumnData[i++] = new TmfEventField(outputColumn.name, dateFormat.format(date));
+            } else {
+                fColumnData[i++] = new TmfEventField(outputColumn.name, (value != null ? value : "")); //$NON-NLS-1$
+            }
+        }
+        CustomEventContent content = (CustomEventContent) getContent();
+        content.setFields(fColumnData);
+        fData = null;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((fDefinition == null) ? 0 : fDefinition.hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof CustomEvent)) {
+            return false;
+        }
+        CustomEvent other = (CustomEvent) obj;
+        if (fDefinition == null) {
+            if (other.fDefinition != null) {
+                return false;
+            }
+        } else if (!fDefinition.equals(other.fDefinition)) {
+            return false;
+        }
+        return true;
+    }
+
+}
index 9d21c3113a9ff1bce9b1b1be58c121434c1efd10..1b0c3ca72c77280da7481cfdd81872c4ed2538a5 100644 (file)
@@ -1,41 +1,41 @@
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r
-\r
-public class CustomEventContent extends TmfEventField {\r
-\r
-    public CustomEventContent(CustomEvent parent, StringBuffer content) {\r
-        super(ITmfEventField.ROOT_FIELD_ID, content);\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        return super.hashCode();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (!super.equals(obj)) {\r
-            return false;\r
-        }\r
-        if (!(obj instanceof CustomEventContent)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-    public void setFields(ITmfEventField[] fields) {\r
-        super.setValue(getValue(), fields);\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+
+public class CustomEventContent extends TmfEventField {
+
+    public CustomEventContent(CustomEvent parent, StringBuffer content) {
+        super(ITmfEventField.ROOT_FIELD_ID, content);
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof CustomEventContent)) {
+            return false;
+        }
+        return true;
+    }
+
+    public void setFields(ITmfEventField[] fields) {
+        super.setValue(getValue(), fields);
+    }
+
+}
index 4a5026b3808dcb4e95e8b0d5803179d416f61ed0..326a76d56802a8eb54c6965cfe23ca7a8576e98b 100644 (file)
@@ -1,24 +1,24 @@
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
-\r
-public abstract class CustomEventType extends TmfEventType {\r
-    \r
-    private static String CONTEXT_ID = "CustomEventType"; //$NON-NLS-1$\r
-    \r
-    public CustomEventType(CustomTraceDefinition definition) {\r
-        super(CONTEXT_ID, definition.definitionName, getRootField(definition));\r
-    }\r
-\r
-    private static ITmfEventField getRootField(CustomTraceDefinition definition) {\r
-        ITmfEventField[] fields = new ITmfEventField[definition.outputs.size()];\r
-        for (int i = 0; i < fields.length; i++) {\r
-            fields[i] = new TmfEventField(definition.outputs.get(i).name, null);\r
-        }\r
-        ITmfEventField rootField = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, fields);\r
-        return rootField;\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+
+public abstract class CustomEventType extends TmfEventType {
+    
+    private static String CONTEXT_ID = "CustomEventType"; //$NON-NLS-1$
+    
+    public CustomEventType(CustomTraceDefinition definition) {
+        super(CONTEXT_ID, definition.definitionName, getRootField(definition));
+    }
+
+    private 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);
+        }
+        ITmfEventField rootField = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, fields);
+        return rootField;
+    }
+
+}
index 19163e171859df6c6123d0e4beb5984030b40a5c..5b166fa209309da8833762f2763eb2bc3996b420 100644 (file)
@@ -1,60 +1,60 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-public class CustomEventsTable extends TmfEventsTable {\r
-\r
-    private final CustomTraceDefinition fDefinition;\r
-\r
-    public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) {\r
-        super(parent, cacheSize, new ColumnData[0]);\r
-        fDefinition = definition;\r
-        createColumnHeaders();\r
-    }\r
-\r
-    protected void createColumnHeaders() {\r
-               if (fDefinition == null) {\r
-            return;\r
-        }\r
-       List<ColumnData> columnData = new LinkedList<ColumnData>();\r
-               for (OutputColumn outputColumn : fDefinition.outputs) {\r
-                       ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT);\r
-                       columnData.add(column);\r
-               }\r
-       setColumnHeaders(columnData.toArray(new ColumnData[0]));\r
-    }\r
-\r
-    @Override\r
-    public TmfEventField[] extractItemFields(ITmfEvent event) {\r
-        if (event instanceof CustomEvent) {\r
-            TmfEventField[] fields = ((CustomEvent) event).extractItemFields();\r
-//            String[] labels = new String[fields.length];\r
-//            for (int i = 0; i < fields.length; i++) {\r
-//                labels[i] = (String) fields[i].getValue();\r
-//            }\r
-            return fields;\r
-        }\r
-        return new TmfEventField[0];\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
+import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class CustomEventsTable extends TmfEventsTable {
+
+    private final CustomTraceDefinition fDefinition;
+
+    public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) {
+        super(parent, cacheSize, new ColumnData[0]);
+        fDefinition = definition;
+        createColumnHeaders();
+    }
+
+    protected void createColumnHeaders() {
+               if (fDefinition == null) {
+            return;
+        }
+       List<ColumnData> columnData = new LinkedList<ColumnData>();
+               for (OutputColumn outputColumn : fDefinition.outputs) {
+                       ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT);
+                       columnData.add(column);
+               }
+       setColumnHeaders(columnData.toArray(new ColumnData[0]));
+    }
+
+    @Override
+    public TmfEventField[] extractItemFields(ITmfEvent event) {
+        if (event instanceof CustomEvent) {
+            TmfEventField[] fields = ((CustomEvent) event).extractItemFields();
+//            String[] labels = new String[fields.length];
+//            for (int i = 0; i < fields.length; i++) {
+//                labels[i] = (String) fields[i].getValue();
+//            }
+            return fields;
+        }
+        return new TmfEventField[0];
+    }
+}
index 539d0e1caa8d26b0a030e57e6c6571360aa084b3..ef947757581b31cfb8bbdd88f8936b952de2e47e 100644 (file)
@@ -1,58 +1,58 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.text.SimpleDateFormat;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-\r
-\r
-public abstract class CustomTraceDefinition {\r
-\r
-    public static final int ACTION_SET = 0;\r
-    public static final int ACTION_APPEND = 1;\r
-    public static final int ACTION_APPEND_WITH_SEPARATOR = 2;\r
-\r
-    public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag;\r
-    public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag;\r
-    public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;\r
-\r
-    public String definitionName;\r
-    public List<OutputColumn> outputs;\r
-    public String timeStampOutputFormat;\r
-\r
-    public static class OutputColumn {\r
-        public String name;\r
-\r
-        public OutputColumn() {}\r
-\r
-        public OutputColumn(String name) {\r
-            this.name = name;\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            return name;\r
-        }\r
-    }\r
-\r
-    public String formatTimeStamp(TmfTimestamp timestamp) {\r
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat);\r
-        return simpleDateFormat.format(timestamp.getValue());\r
-    }\r
-\r
-    public abstract void save();\r
-    public abstract void save(String path);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+
+
+public abstract class CustomTraceDefinition {
+
+    public static final int ACTION_SET = 0;
+    public static final int ACTION_APPEND = 1;
+    public static final int ACTION_APPEND_WITH_SEPARATOR = 2;
+
+    public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag;
+    public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag;
+    public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;
+
+    public String definitionName;
+    public List<OutputColumn> outputs;
+    public String timeStampOutputFormat;
+
+    public static class OutputColumn {
+        public String name;
+
+        public OutputColumn() {}
+
+        public OutputColumn(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+    public String formatTimeStamp(TmfTimestamp timestamp) {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat);
+        return simpleDateFormat.format(timestamp.getValue());
+    }
+
+    public abstract void save();
+    public abstract void save(String path);
+}
index 745a449266bfe49dae6b428ccdaf501010fe8a52..9f2012db56cc32a02888c51b961ab0cfa2441661 100644 (file)
@@ -1,97 +1,97 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.util.regex.Matcher;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-public class CustomTxtEvent extends CustomEvent {\r
-\r
-    public CustomTxtEvent(CustomTxtTraceDefinition definition) {\r
-        super(definition);\r
-        setType(new CustomTxtEventType(definition));\r
-    }\r
-\r
-    public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {\r
-        super(definition, other);\r
-    }\r
-\r
-    public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {\r
-        super(definition, parentTrace, timestamp, source, type, reference);\r
-    }\r
-\r
-    @Override\r
-    public void setContent(ITmfEventField content) {\r
-        super.setContent(content);\r
-    }\r
-\r
-    public void processGroups(InputLine input, Matcher matcher) {\r
-       if (input.columns == null) {\r
-               return;\r
-       }\r
-        for (int i = 0; i < input.columns.size(); i++) {\r
-            InputData column = input.columns.get(i);\r
-            if (i < matcher.groupCount() && matcher.group(i + 1) != null) {\r
-                String value = matcher.group(i + 1).trim();\r
-                if (value.length() == 0) {\r
-                    continue;\r
-                }\r
-                String name = column.name;\r
-                if (column.action == CustomTraceDefinition.ACTION_SET) {\r
-                    fData.put(name, value);\r
-                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
-                    }\r
-                } else if (column.action == CustomTraceDefinition.ACTION_APPEND) {\r
-                    String s = fData.get(name);\r
-                    if (s != null) {\r
-                        fData.put(name, s + value);\r
-                    } else {\r
-                        fData.put(name, value);\r
-                    }\r
-                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
-                        if (timeStampInputFormat != null) {\r
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format);\r
-                        } else {\r
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
-                        }\r
-                    }\r
-                } else if (column.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-                    String s = fData.get(name);\r
-                    if (s != null) {\r
-                        fData.put(name, s + " | " + value); //$NON-NLS-1$\r
-                    } else {\r
-                        fData.put(name, value);\r
-                    }\r
-                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
-                        if (timeStampInputFormat != null) {\r
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$\r
-                        } else {\r
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.util.regex.Matcher;
+
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+public class CustomTxtEvent extends CustomEvent {
+
+    public CustomTxtEvent(CustomTxtTraceDefinition definition) {
+        super(definition);
+        setType(new CustomTxtEventType(definition));
+    }
+
+    public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {
+        super(definition, other);
+    }
+
+    public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
+        super(definition, parentTrace, timestamp, source, type, reference);
+    }
+
+    @Override
+    public void setContent(ITmfEventField content) {
+        super.setContent(content);
+    }
+
+    public void processGroups(InputLine input, Matcher matcher) {
+       if (input.columns == null) {
+               return;
+       }
+        for (int i = 0; i < input.columns.size(); i++) {
+            InputData column = input.columns.get(i);
+            if (i < matcher.groupCount() && matcher.group(i + 1) != null) {
+                String value = matcher.group(i + 1).trim();
+                if (value.length() == 0) {
+                    continue;
+                }
+                String name = column.name;
+                if (column.action == CustomTraceDefinition.ACTION_SET) {
+                    fData.put(name, value);
+                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
+                    }
+                } else if (column.action == CustomTraceDefinition.ACTION_APPEND) {
+                    String s = fData.get(name);
+                    if (s != null) {
+                        fData.put(name, s + value);
+                    } else {
+                        fData.put(name, value);
+                    }
+                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+                        if (timeStampInputFormat != null) {
+                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format);
+                        } else {
+                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
+                        }
+                    }
+                } else if (column.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+                    String s = fData.get(name);
+                    if (s != null) {
+                        fData.put(name, s + " | " + value); //$NON-NLS-1$
+                    } else {
+                        fData.put(name, value);
+                    }
+                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+                        if (timeStampInputFormat != null) {
+                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$
+                        } else {
+                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+}
index 0615ba86210dac55335086e221243f4e28d02b45..b2b1eedc1006af7e34e4a533ff1753c594ca5b6f 100644 (file)
@@ -1,21 +1,21 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-public class CustomTxtEventType extends CustomEventType {\r
-\r
-       public CustomTxtEventType(CustomTxtTraceDefinition definition) {\r
-               super(definition);\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+public class CustomTxtEventType extends CustomEventType {
+
+       public CustomTxtEventType(CustomTxtTraceDefinition definition) {
+               super(definition);
+       }
+
+}
index c6e731fe1fb5adc7b65135204cd259a61f990e02..4f3ddcc67eefee222d7dbf7871a46c0426cbd66a 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map.Entry;\r
-import java.util.regex.Matcher;\r
-\r
-import org.eclipse.core.resources.IProject;\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
-import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
-\r
-public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> implements ITmfEventParser<CustomTxtEvent> {\r
-\r
-    private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
-    private static final int DEFAULT_CACHE_SIZE = 100;\r
-\r
-    private final CustomTxtTraceDefinition fDefinition;\r
-    private final CustomTxtEventType fEventType;\r
-    private BufferedRandomAccessFile fFile;\r
-\r
-    public CustomTxtTrace(final CustomTxtTraceDefinition definition) {\r
-        fDefinition = definition;\r
-        fEventType = new CustomTxtEventType(fDefinition);\r
-        setCacheSize(DEFAULT_CACHE_SIZE);\r
-    }\r
-\r
-    public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int cacheSize) throws TmfTraceException {\r
-        this(definition);\r
-        setCacheSize((cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE);\r
-        initTrace(resource, path, CustomTxtEvent.class);\r
-    }\r
-\r
-    @Override\r
-    public void initTrace(final IResource resource, final String path, final Class<CustomTxtEvent> eventType) throws TmfTraceException {\r
-        super.initTrace(resource, path, eventType);\r
-        try {\r
-            fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            throw new TmfTraceException(e.getMessage(), e);\r
-        }\r
-        indexTrace(false);\r
-    }\r
-\r
-    @Override\r
-    public synchronized void dispose() {\r
-        super.dispose();\r
-        if (fFile != null) {\r
-            try {\r
-                fFile.close();\r
-            } catch (IOException e) {\r
-            } finally {\r
-                fFile = null;\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {\r
-        final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
-        if (NULL_LOCATION.equals(location) || fFile == null) {\r
-            return context;\r
-        }\r
-        try {\r
-            if (location == null) {\r
-                fFile.seek(0);\r
-            } else if (location.getLocation() instanceof Long) {\r
-                fFile.seek((Long) location.getLocation());\r
-            }\r
-            String line;\r
-            long rawPos = fFile.getFilePointer();\r
-            while ((line = fFile.getNextLine()) != null) {\r
-                for (final InputLine input : getFirstLines()) {\r
-                    final Matcher matcher = input.getPattern().matcher(line);\r
-                    if (matcher.find()) {\r
-                        context.setLocation(new TmfLocation<Long>(rawPos));\r
-                        context.firstLineMatcher = matcher;\r
-                        context.firstLine = line;\r
-                        context.nextLineLocation = fFile.getFilePointer();\r
-                        context.inputLine = input;\r
-                        return context;\r
-                    }\r
-                }\r
-                rawPos = fFile.getFilePointer();\r
-            }\r
-            return context;\r
-        } catch (final FileNotFoundException e) {\r
-            Activator.getDefault().logError("Error seeking event. File not found: " + getPath(), e); //$NON-NLS-1$\r
-            return context;\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
-            return context;\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    public synchronized TmfContext seekEvent(final double ratio) {\r
-        if (fFile == null) {\r
-            return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
-        }\r
-        try {\r
-            long pos = (long) (ratio * fFile.length());\r
-            while (pos > 0) {\r
-                fFile.seek(pos - 1);\r
-                if (fFile.read() == '\n') {\r
-                    break;\r
-                }\r
-                pos--;\r
-            }\r
-            final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
-            final TmfContext context = seekEvent(location);\r
-            context.setRank(ITmfContext.UNKNOWN_RANK);\r
-            return context;\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
-            return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public synchronized double getLocationRatio(final ITmfLocation<?> location) {\r
-        if (fFile == null) {\r
-            return 0;\r
-        }\r
-        try {\r
-            if (location.getLocation() instanceof Long) {\r
-                return (double) ((Long) location.getLocation()) / fFile.length();\r
-            }\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
-        }\r
-        return 0;\r
-    }\r
-\r
-    @Override\r
-    public ITmfLocation<?> getCurrentLocation() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public synchronized CustomTxtEvent parseEvent(final ITmfContext tmfContext) {\r
-        ITmfContext context = seekEvent(tmfContext.getLocation());\r
-        return parse(context);\r
-    }\r
-\r
-    @Override\r
-    public synchronized CustomTxtEvent getNext(final ITmfContext context) {\r
-        final ITmfContext savedContext = context.clone();\r
-        final CustomTxtEvent event = parse(context);\r
-        if (event != null) {\r
-            updateAttributes(savedContext, event.getTimestamp());\r
-            context.increaseRank();\r
-        }\r
-        return event;\r
-    }\r
-\r
-    private synchronized CustomTxtEvent parse(final ITmfContext tmfContext) {\r
-        if (fFile == null) {\r
-            return null;\r
-        }\r
-        if (!(tmfContext instanceof CustomTxtTraceContext)) {\r
-            return null;\r
-        }\r
-\r
-        final CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext;\r
-        if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
-            return null;\r
-        }\r
-\r
-        CustomTxtEvent event = parseFirstLine(context);\r
-\r
-        final HashMap<InputLine, Integer> countMap = new HashMap<InputLine, Integer>();\r
-        InputLine currentInput = null;\r
-        if (context.inputLine.childrenInputs != null && context.inputLine.childrenInputs.size() > 0) {\r
-            currentInput = context.inputLine.childrenInputs.get(0);\r
-            countMap.put(currentInput, 0);\r
-        }\r
-\r
-        try {\r
-            if (fFile.getFilePointer() != context.nextLineLocation) {\r
-                fFile.seek(context.nextLineLocation);\r
-            }\r
-            String line;\r
-            long rawPos = fFile.getFilePointer();\r
-            while ((line = fFile.getNextLine()) != null) {\r
-                boolean processed = false;\r
-                if (currentInput == null) {\r
-                    for (final InputLine input : getFirstLines()) {\r
-                        final Matcher matcher = input.getPattern().matcher(line);\r
-                        if (matcher.find()) {\r
-                            context.setLocation(new TmfLocation<Long>(rawPos));\r
-                            context.firstLineMatcher = matcher;\r
-                            context.firstLine = line;\r
-                            context.nextLineLocation = fFile.getFilePointer();\r
-                            context.inputLine = input;\r
-                            return event;\r
-                        }\r
-                    }\r
-                } else {\r
-                    if (countMap.get(currentInput) >= currentInput.getMinCount()) {\r
-                        final List<InputLine> nextInputs = currentInput.getNextInputs(countMap);\r
-                        if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {\r
-                            for (final InputLine input : getFirstLines()) {\r
-                                final Matcher matcher = input.getPattern().matcher(line);\r
-                                if (matcher.find()) {\r
-                                    context.setLocation(new TmfLocation<Long>(rawPos));\r
-                                    context.firstLineMatcher = matcher;\r
-                                    context.firstLine = line;\r
-                                    context.nextLineLocation = fFile.getFilePointer();\r
-                                    context.inputLine = input;\r
-                                    return event;\r
-                                }\r
-                            }\r
-                        }\r
-                        for (final InputLine input : nextInputs) {\r
-                            final Matcher matcher = input.getPattern().matcher(line);\r
-                            if (matcher.find()) {\r
-                                event.processGroups(input, matcher);\r
-                                currentInput = input;\r
-                                if (countMap.get(currentInput) == null) {\r
-                                    countMap.put(currentInput, 1);\r
-                                } else {\r
-                                    countMap.put(currentInput, countMap.get(currentInput) + 1);\r
-                                }\r
-                                Iterator<InputLine> iter = countMap.keySet().iterator();\r
-                                while (iter.hasNext()) {\r
-                                    final InputLine inputLine = iter.next();\r
-                                    if (inputLine.level > currentInput.level) {\r
-                                        iter.remove();\r
-                                    }\r
-                                }\r
-                                if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {\r
-                                    currentInput = currentInput.childrenInputs.get(0);\r
-                                    countMap.put(currentInput, 0);\r
-                                } else if (countMap.get(currentInput) >= currentInput.getMaxCount()) {\r
-                                    if (currentInput.getNextInputs(countMap).size() > 0) {\r
-                                        currentInput = currentInput.getNextInputs(countMap).get(0);\r
-                                        if (countMap.get(currentInput) == null) {\r
-                                            countMap.put(currentInput, 0);\r
-                                        }\r
-                                        iter = countMap.keySet().iterator();\r
-                                        while (iter.hasNext()) {\r
-                                            final InputLine inputLine = iter.next();\r
-                                            if (inputLine.level > currentInput.level) {\r
-                                                iter.remove();\r
-                                            }\r
-                                        }\r
-                                    } else {\r
-                                        currentInput = null;\r
-                                    }\r
-                                }\r
-                                processed = true;\r
-                                break;\r
-                            }\r
-                        }\r
-                    }\r
-                    if (! processed) {\r
-                        final Matcher matcher = currentInput.getPattern().matcher(line);\r
-                        if (matcher.find()) {\r
-                            event.processGroups(currentInput, matcher);\r
-                            countMap.put(currentInput, countMap.get(currentInput) + 1);\r
-                            if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {\r
-                                currentInput = currentInput.childrenInputs.get(0);\r
-                                countMap.put(currentInput, 0);\r
-                            } else if (countMap.get(currentInput) >= currentInput.getMaxCount()) {\r
-                                if (currentInput.getNextInputs(countMap).size() > 0) {\r
-                                    currentInput = currentInput.getNextInputs(countMap).get(0);\r
-                                    if (countMap.get(currentInput) == null) {\r
-                                        countMap.put(currentInput, 0);\r
-                                    }\r
-                                    final Iterator<InputLine> iter = countMap.keySet().iterator();\r
-                                    while (iter.hasNext()) {\r
-                                        final InputLine inputLine = iter.next();\r
-                                        if (inputLine.level > currentInput.level) {\r
-                                            iter.remove();\r
-                                        }\r
-                                    }\r
-                                } else {\r
-                                    currentInput = null;\r
-                                }\r
-                            }\r
-                        }\r
-                        ((StringBuffer) event.getContent().getValue()).append("\n").append(line); //$NON-NLS-1$\r
-                    }\r
-                }\r
-                rawPos = fFile.getFilePointer();\r
-            }\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
-        }\r
-        for (final Entry<InputLine, Integer> entry : countMap.entrySet()) {\r
-            if (entry.getValue() < entry.getKey().getMinCount()) {\r
-                event = null;\r
-            }\r
-        }\r
-        context.setLocation(NULL_LOCATION);\r
-        return event;\r
-    }\r
-\r
-    public List<InputLine> getFirstLines() {\r
-        return fDefinition.inputs;\r
-    }\r
-\r
-    public CustomTxtEvent parseFirstLine(final CustomTxtTraceContext context) {\r
-        final CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.ZERO, "", fEventType, ""); //$NON-NLS-1$ //$NON-NLS-2$\r
-        event.processGroups(context.inputLine, context.firstLineMatcher);\r
-        event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine)));\r
-        return event;\r
-    }\r
-\r
-    public CustomTraceDefinition getDefinition() {\r
-        return fDefinition;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)\r
-     */\r
-    @Override\r
-    public boolean validate(IProject project, String path) {\r
-        return fileExists(path);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+
+public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> implements ITmfEventParser<CustomTxtEvent> {
+
+    private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);
+    private static final int DEFAULT_CACHE_SIZE = 100;
+
+    private final CustomTxtTraceDefinition fDefinition;
+    private final CustomTxtEventType fEventType;
+    private BufferedRandomAccessFile fFile;
+
+    public CustomTxtTrace(final CustomTxtTraceDefinition definition) {
+        fDefinition = definition;
+        fEventType = new CustomTxtEventType(fDefinition);
+        setCacheSize(DEFAULT_CACHE_SIZE);
+    }
+
+    public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int cacheSize) throws TmfTraceException {
+        this(definition);
+        setCacheSize((cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE);
+        initTrace(resource, path, CustomTxtEvent.class);
+    }
+
+    @Override
+    public void initTrace(final IResource resource, final String path, final Class<CustomTxtEvent> eventType) throws TmfTraceException {
+        super.initTrace(resource, path, eventType);
+        try {
+            fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$
+        } catch (IOException e) {
+            throw new TmfTraceException(e.getMessage(), e);
+        }
+        indexTrace(false);
+    }
+
+    @Override
+    public synchronized void dispose() {
+        super.dispose();
+        if (fFile != null) {
+            try {
+                fFile.close();
+            } catch (IOException e) {
+            } finally {
+                fFile = null;
+            }
+        }
+    }
+
+    @Override
+    public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {
+        final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
+        if (NULL_LOCATION.equals(location) || fFile == null) {
+            return context;
+        }
+        try {
+            if (location == null) {
+                fFile.seek(0);
+            } else if (location.getLocation() instanceof Long) {
+                fFile.seek((Long) location.getLocation());
+            }
+            String line;
+            long rawPos = fFile.getFilePointer();
+            while ((line = fFile.getNextLine()) != null) {
+                for (final InputLine input : getFirstLines()) {
+                    final Matcher matcher = input.getPattern().matcher(line);
+                    if (matcher.find()) {
+                        context.setLocation(new TmfLocation<Long>(rawPos));
+                        context.firstLineMatcher = matcher;
+                        context.firstLine = line;
+                        context.nextLineLocation = fFile.getFilePointer();
+                        context.inputLine = input;
+                        return context;
+                    }
+                }
+                rawPos = fFile.getFilePointer();
+            }
+            return context;
+        } catch (final FileNotFoundException e) {
+            Activator.getDefault().logError("Error seeking event. File not found: " + getPath(), e); //$NON-NLS-1$
+            return context;
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
+            return context;
+        }
+
+    }
+
+    @Override
+    public synchronized TmfContext seekEvent(final double ratio) {
+        if (fFile == null) {
+            return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
+        }
+        try {
+            long pos = (long) (ratio * fFile.length());
+            while (pos > 0) {
+                fFile.seek(pos - 1);
+                if (fFile.read() == '\n') {
+                    break;
+                }
+                pos--;
+            }
+            final ITmfLocation<?> location = new TmfLocation<Long>(pos);
+            final TmfContext context = seekEvent(location);
+            context.setRank(ITmfContext.UNKNOWN_RANK);
+            return context;
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
+            return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
+        }
+    }
+
+    @Override
+    public synchronized double getLocationRatio(final ITmfLocation<?> location) {
+        if (fFile == null) {
+            return 0;
+        }
+        try {
+            if (location.getLocation() instanceof Long) {
+                return (double) ((Long) location.getLocation()) / fFile.length();
+            }
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
+        }
+        return 0;
+    }
+
+    @Override
+    public ITmfLocation<?> getCurrentLocation() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public synchronized CustomTxtEvent parseEvent(final ITmfContext tmfContext) {
+        ITmfContext context = seekEvent(tmfContext.getLocation());
+        return parse(context);
+    }
+
+    @Override
+    public synchronized CustomTxtEvent getNext(final ITmfContext context) {
+        final ITmfContext savedContext = context.clone();
+        final CustomTxtEvent event = parse(context);
+        if (event != null) {
+            updateAttributes(savedContext, event.getTimestamp());
+            context.increaseRank();
+        }
+        return event;
+    }
+
+    private synchronized CustomTxtEvent parse(final ITmfContext tmfContext) {
+        if (fFile == null) {
+            return null;
+        }
+        if (!(tmfContext instanceof CustomTxtTraceContext)) {
+            return null;
+        }
+
+        final CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext;
+        if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {
+            return null;
+        }
+
+        CustomTxtEvent event = parseFirstLine(context);
+
+        final HashMap<InputLine, Integer> countMap = new HashMap<InputLine, Integer>();
+        InputLine currentInput = null;
+        if (context.inputLine.childrenInputs != null && context.inputLine.childrenInputs.size() > 0) {
+            currentInput = context.inputLine.childrenInputs.get(0);
+            countMap.put(currentInput, 0);
+        }
+
+        try {
+            if (fFile.getFilePointer() != context.nextLineLocation) {
+                fFile.seek(context.nextLineLocation);
+            }
+            String line;
+            long rawPos = fFile.getFilePointer();
+            while ((line = fFile.getNextLine()) != null) {
+                boolean processed = false;
+                if (currentInput == null) {
+                    for (final InputLine input : getFirstLines()) {
+                        final Matcher matcher = input.getPattern().matcher(line);
+                        if (matcher.find()) {
+                            context.setLocation(new TmfLocation<Long>(rawPos));
+                            context.firstLineMatcher = matcher;
+                            context.firstLine = line;
+                            context.nextLineLocation = fFile.getFilePointer();
+                            context.inputLine = input;
+                            return event;
+                        }
+                    }
+                } else {
+                    if (countMap.get(currentInput) >= currentInput.getMinCount()) {
+                        final List<InputLine> nextInputs = currentInput.getNextInputs(countMap);
+                        if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
+                            for (final InputLine input : getFirstLines()) {
+                                final Matcher matcher = input.getPattern().matcher(line);
+                                if (matcher.find()) {
+                                    context.setLocation(new TmfLocation<Long>(rawPos));
+                                    context.firstLineMatcher = matcher;
+                                    context.firstLine = line;
+                                    context.nextLineLocation = fFile.getFilePointer();
+                                    context.inputLine = input;
+                                    return event;
+                                }
+                            }
+                        }
+                        for (final InputLine input : nextInputs) {
+                            final Matcher matcher = input.getPattern().matcher(line);
+                            if (matcher.find()) {
+                                event.processGroups(input, matcher);
+                                currentInput = input;
+                                if (countMap.get(currentInput) == null) {
+                                    countMap.put(currentInput, 1);
+                                } else {
+                                    countMap.put(currentInput, countMap.get(currentInput) + 1);
+                                }
+                                Iterator<InputLine> iter = countMap.keySet().iterator();
+                                while (iter.hasNext()) {
+                                    final InputLine inputLine = iter.next();
+                                    if (inputLine.level > currentInput.level) {
+                                        iter.remove();
+                                    }
+                                }
+                                if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
+                                    currentInput = currentInput.childrenInputs.get(0);
+                                    countMap.put(currentInput, 0);
+                                } else if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+                                    if (currentInput.getNextInputs(countMap).size() > 0) {
+                                        currentInput = currentInput.getNextInputs(countMap).get(0);
+                                        if (countMap.get(currentInput) == null) {
+                                            countMap.put(currentInput, 0);
+                                        }
+                                        iter = countMap.keySet().iterator();
+                                        while (iter.hasNext()) {
+                                            final InputLine inputLine = iter.next();
+                                            if (inputLine.level > currentInput.level) {
+                                                iter.remove();
+                                            }
+                                        }
+                                    } else {
+                                        currentInput = null;
+                                    }
+                                }
+                                processed = true;
+                                break;
+                            }
+                        }
+                    }
+                    if (! processed) {
+                        final Matcher matcher = currentInput.getPattern().matcher(line);
+                        if (matcher.find()) {
+                            event.processGroups(currentInput, matcher);
+                            countMap.put(currentInput, countMap.get(currentInput) + 1);
+                            if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
+                                currentInput = currentInput.childrenInputs.get(0);
+                                countMap.put(currentInput, 0);
+                            } else if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+                                if (currentInput.getNextInputs(countMap).size() > 0) {
+                                    currentInput = currentInput.getNextInputs(countMap).get(0);
+                                    if (countMap.get(currentInput) == null) {
+                                        countMap.put(currentInput, 0);
+                                    }
+                                    final Iterator<InputLine> iter = countMap.keySet().iterator();
+                                    while (iter.hasNext()) {
+                                        final InputLine inputLine = iter.next();
+                                        if (inputLine.level > currentInput.level) {
+                                            iter.remove();
+                                        }
+                                    }
+                                } else {
+                                    currentInput = null;
+                                }
+                            }
+                        }
+                        ((StringBuffer) event.getContent().getValue()).append("\n").append(line); //$NON-NLS-1$
+                    }
+                }
+                rawPos = fFile.getFilePointer();
+            }
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
+        }
+        for (final Entry<InputLine, Integer> entry : countMap.entrySet()) {
+            if (entry.getValue() < entry.getKey().getMinCount()) {
+                event = null;
+            }
+        }
+        context.setLocation(NULL_LOCATION);
+        return event;
+    }
+
+    public List<InputLine> getFirstLines() {
+        return fDefinition.inputs;
+    }
+
+    public CustomTxtEvent parseFirstLine(final CustomTxtTraceContext context) {
+        final CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.ZERO, "", fEventType, ""); //$NON-NLS-1$ //$NON-NLS-2$
+        event.processGroups(context.inputLine, context.firstLineMatcher);
+        event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine)));
+        return event;
+    }
+
+    public CustomTraceDefinition getDefinition() {
+        return fDefinition;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
+     */
+    @Override
+    public boolean validate(IProject project, String path) {
+        return fileExists(path);
+    }
+}
index 89c17ce73e0ff3c493fb599e39963b4e5153e807..556bfbd650559daf50bda366fc3fed697f51cf24 100644 (file)
@@ -1,87 +1,87 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.util.regex.Matcher;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
-\r
-public class CustomTxtTraceContext extends TmfContext {\r
-    public Matcher firstLineMatcher;\r
-    public String firstLine;\r
-    public long nextLineLocation;\r
-    public InputLine inputLine;\r
-\r
-    public CustomTxtTraceContext(ITmfLocation<?> location, long rank) {\r
-        super(location, rank);\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = super.hashCode();\r
-        result = prime * result + ((firstLine == null) ? 0 : firstLine.hashCode());\r
-        result = prime * result + ((firstLineMatcher == null) ? 0 : firstLineMatcher.hashCode());\r
-        result = prime * result + ((inputLine == null) ? 0 : inputLine.hashCode());\r
-        result = prime * result + (int) (nextLineLocation ^ (nextLineLocation >>> 32));\r
-        return result;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (!super.equals(obj)) {\r
-            return false;\r
-        }\r
-        if (!(obj instanceof CustomTxtTraceContext)) {\r
-            return false;\r
-        }\r
-        CustomTxtTraceContext other = (CustomTxtTraceContext) obj;\r
-        if (firstLine == null) {\r
-            if (other.firstLine != null) {\r
-                return false;\r
-            }\r
-        } else if (!firstLine.equals(other.firstLine)) {\r
-            return false;\r
-        }\r
-        if (firstLineMatcher == null) {\r
-            if (other.firstLineMatcher != null) {\r
-                return false;\r
-            }\r
-        } else if (!firstLineMatcher.equals(other.firstLineMatcher)) {\r
-            return false;\r
-        }\r
-        if (inputLine == null) {\r
-            if (other.inputLine != null) {\r
-                return false;\r
-            }\r
-        } else if (!inputLine.equals(other.inputLine)) {\r
-            return false;\r
-        }\r
-        if (nextLineLocation != other.nextLineLocation) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.util.regex.Matcher;
+
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+
+public class CustomTxtTraceContext extends TmfContext {
+    public Matcher firstLineMatcher;
+    public String firstLine;
+    public long nextLineLocation;
+    public InputLine inputLine;
+
+    public CustomTxtTraceContext(ITmfLocation<?> location, long rank) {
+        super(location, rank);
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((firstLine == null) ? 0 : firstLine.hashCode());
+        result = prime * result + ((firstLineMatcher == null) ? 0 : firstLineMatcher.hashCode());
+        result = prime * result + ((inputLine == null) ? 0 : inputLine.hashCode());
+        result = prime * result + (int) (nextLineLocation ^ (nextLineLocation >>> 32));
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof CustomTxtTraceContext)) {
+            return false;
+        }
+        CustomTxtTraceContext other = (CustomTxtTraceContext) obj;
+        if (firstLine == null) {
+            if (other.firstLine != null) {
+                return false;
+            }
+        } else if (!firstLine.equals(other.firstLine)) {
+            return false;
+        }
+        if (firstLineMatcher == null) {
+            if (other.firstLineMatcher != null) {
+                return false;
+            }
+        } else if (!firstLineMatcher.equals(other.firstLineMatcher)) {
+            return false;
+        }
+        if (inputLine == null) {
+            if (other.inputLine != null) {
+                return false;
+            }
+        } else if (!inputLine.equals(other.inputLine)) {
+            return false;
+        }
+        if (nextLineLocation != other.nextLineLocation) {
+            return false;
+        }
+        return true;
+    }
+
 }
\ No newline at end of file
index 8c19d20fc8f69a3669f871501539832021313922..f353121d24978b28def91da37c092cd65d7b0402 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.io.StringWriter;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.regex.Pattern;\r
-import java.util.regex.PatternSyntaxException;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-import javax.xml.transform.OutputKeys;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerConfigurationException;\r
-import javax.xml.transform.TransformerException;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.TransformerFactoryConfigurationError;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.w3c.dom.Node;\r
-import org.w3c.dom.NodeList;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-public class CustomTxtTraceDefinition extends CustomTraceDefinition {\r
-\r
-    protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME = "custom_txt_parsers.xml"; //$NON-NLS-1$\r
-    protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME =\r
-        Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME).toString();\r
-\r
-    private static final String CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomTxtTraceDefinition_definitionRootElement;\r
-    private static final String DEFINITION_ELEMENT = Messages.CustomTxtTraceDefinition_definition;\r
-    private static final String NAME_ATTRIBUTE = Messages.CustomTxtTraceDefinition_name;\r
-    private static final String TIME_STAMP_OUTPUT_FORMAT_ELEMENT = Messages.CustomTxtTraceDefinition_timestampOutputFormat;\r
-    private static final String INPUT_LINE_ELEMENT = Messages.CustomTxtTraceDefinition_inputLine;\r
-    private static final String CARDINALITY_ELEMENT = Messages.CustomTxtTraceDefinition_cardinality;\r
-    private static final String MIN_ATTRIBUTE = Messages.CustomTxtTraceDefinition_min;\r
-    private static final String MAX_ATTRIBUTE = Messages.CustomTxtTraceDefinition_max;\r
-    private static final String REGEX_ELEMENT = Messages.CustomTxtTraceDefinition_regEx;\r
-    private static final String INPUT_DATA_ELEMENT = Messages.CustomTxtTraceDefinition_inputData;\r
-    private static final String ACTION_ATTRIBUTE = Messages.CustomTxtTraceDefinition_action;\r
-    private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format;\r
-    private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomTxtTraceDefinition_outputColumn;\r
-\r
-    public List<InputLine> inputs;\r
-\r
-    public CustomTxtTraceDefinition() {\r
-        this("", new ArrayList<InputLine>(0), new ArrayList<OutputColumn>(0), ""); //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-\r
-    public CustomTxtTraceDefinition(String logtype, List<InputLine> inputs, List<OutputColumn> outputs, String timeStampOutputFormat) {\r
-        this.definitionName = logtype;\r
-        this.inputs = inputs;\r
-        this.outputs = outputs;\r
-        this.timeStampOutputFormat = timeStampOutputFormat;\r
-    }\r
-\r
-    public static class InputLine {\r
-        public List<InputData> columns;\r
-        public Cardinality cardinality;\r
-        private String regex;\r
-        private Pattern pattern;\r
-        public InputLine parentInput;\r
-        public int level;\r
-        public InputLine nextInput;\r
-        public List<InputLine> childrenInputs;\r
-\r
-        public InputLine() {}\r
-\r
-        public InputLine(Cardinality cardinality, String regex, List<InputData> columns) {\r
-            this.cardinality = cardinality;\r
-            this.regex = regex;\r
-            this.columns = columns;\r
-        }\r
-\r
-        public void setRegex(String regex) {\r
-            this.regex = regex;\r
-            this.pattern = null;\r
-        }\r
-\r
-        public String getRegex() {\r
-            return regex;\r
-        }\r
-\r
-        public Pattern getPattern() throws PatternSyntaxException {\r
-            if (pattern == null) {\r
-                pattern = Pattern.compile(regex);\r
-            }\r
-            return pattern;\r
-        }\r
-\r
-        public void addChild(InputLine input) {\r
-            if (childrenInputs == null) {\r
-                childrenInputs = new ArrayList<InputLine>(1);\r
-            } else if (childrenInputs.size() > 0) {\r
-                InputLine last = childrenInputs.get(childrenInputs.size() - 1);\r
-                last.nextInput = input;\r
-            }\r
-            childrenInputs.add(input);\r
-            input.parentInput = this;\r
-            input.level = this.level + 1;\r
-        }\r
-\r
-        public void addNext(InputLine input) {\r
-            if (parentInput != null) {\r
-                int index = parentInput.childrenInputs.indexOf(this);\r
-                parentInput.childrenInputs.add(index + 1, input);\r
-                InputLine next = nextInput;\r
-                nextInput = input;\r
-                input.nextInput = next;\r
-            }\r
-            input.parentInput = this.parentInput;\r
-            input.level = this.level;\r
-        }\r
-\r
-        public void moveUp() {\r
-            if (parentInput != null) {\r
-                int index = parentInput.childrenInputs.indexOf(this);\r
-                if (index > 0) {\r
-                    parentInput.childrenInputs.add(index - 1 , parentInput.childrenInputs.remove(index));\r
-                    parentInput.childrenInputs.get(index).nextInput = nextInput;\r
-                    nextInput = parentInput.childrenInputs.get(index);\r
-                }\r
-            }\r
-        }\r
-\r
-        public void moveDown() {\r
-            if (parentInput != null) {\r
-                int index = parentInput.childrenInputs.indexOf(this);\r
-                if (index < parentInput.childrenInputs.size() - 1) {\r
-                    parentInput.childrenInputs.add(index + 1 , parentInput.childrenInputs.remove(index));\r
-                    nextInput = parentInput.childrenInputs.get(index).nextInput;\r
-                    parentInput.childrenInputs.get(index).nextInput = this;\r
-                }\r
-            }\r
-        }\r
-\r
-        public void addColumn(InputData column) {\r
-            if (columns == null) {\r
-                columns = new ArrayList<InputData>(1);\r
-            }\r
-            columns.add(column);\r
-        }\r
-\r
-        public List<InputLine> getNextInputs(Map<InputLine, Integer> countMap) {\r
-            List<InputLine> nextInputs = new ArrayList<InputLine>();\r
-            InputLine next = nextInput;\r
-            while (next != null) {\r
-                nextInputs.add(next);\r
-                if (next.cardinality.min > 0) {\r
-                    return nextInputs;\r
-                }\r
-                next = next.nextInput;\r
-            }\r
-            if (parentInput != null && parentInput.level > 0) {\r
-                int parentCount = countMap.get(parentInput);\r
-                if (parentCount < parentInput.getMaxCount()) {\r
-                    nextInputs.add(parentInput);\r
-                }\r
-                if (parentCount < parentInput.getMinCount()) {\r
-                    return nextInputs;\r
-                }\r
-                nextInputs.addAll(parentInput.getNextInputs(countMap));\r
-            }\r
-            return nextInputs;\r
-        }\r
-\r
-        public int getMinCount() {\r
-            return cardinality.min;\r
-        }\r
-\r
-        public int getMaxCount() {\r
-            return cardinality.max;\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            return regex + " " + cardinality; //$NON-NLS-1$\r
-        }\r
-\r
-    }\r
-\r
-    public static class InputData {\r
-        public String name;\r
-        public int action;\r
-        public String format;\r
-\r
-        public InputData() {}\r
-\r
-        public InputData(String name, int action, String format) {\r
-            this.name = name;\r
-            this.action = action;\r
-            this.format = format;\r
-        }\r
-\r
-        public InputData(String name, int action) {\r
-            this.name = name;\r
-            this.action = action;\r
-        }\r
-    }\r
-\r
-    public static class Cardinality {\r
-        public final static int INF = Integer.MAX_VALUE;\r
-        public final static Cardinality ONE = new Cardinality(1, 1);\r
-        public final static Cardinality ONE_OR_MORE = new Cardinality(1, INF);\r
-        public final static Cardinality ZERO_OR_ONE = new Cardinality(0, 1);\r
-        public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF);\r
-\r
-        private final int min;\r
-        private final int max;\r
-\r
-        public Cardinality(int min, int max) {\r
-            this.min = min;\r
-            this.max = max;\r
-        }\r
-\r
-               @Override\r
-        public String toString() {\r
-            return "(" + (min >= 0 ? min : "?") + "," + (max == INF ? "\u221E" : (max >= 0 ? max : "?")) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$\r
-        }\r
-\r
-        /* (non-Javadoc)\r
-         * @see java.lang.Object#hashCode()\r
-         */\r
-        @Override\r
-        public int hashCode() {\r
-            final int prime = 31;\r
-            int result = 1;\r
-            result = prime * result + max;\r
-            result = prime * result + min;\r
-            return result;\r
-        }\r
-\r
-        /* (non-Javadoc)\r
-         * @see java.lang.Object#equals(java.lang.Object)\r
-         */\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (!(obj instanceof Cardinality)) {\r
-                return false;\r
-            }\r
-            Cardinality other = (Cardinality) obj;\r
-            return (this.min == other.min && this.max == other.max);\r
-        }\r
-    }\r
-\r
-    @Override\r
-       public void save() {\r
-        save(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);\r
-    }\r
-\r
-    @Override\r
-       public void save(String path) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-               @Override\r
-                public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-               @Override\r
-                public void error(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            Document doc = null;\r
-            File file = new File(path);\r
-            if (file.canRead()) {\r
-                doc = db.parse(file);\r
-                if (! doc.getDocumentElement().getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                    return;\r
-                }\r
-            } else {\r
-                doc = db.newDocument();\r
-                Node node = doc.createElement(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT);\r
-                doc.appendChild(node);\r
-            }\r
-\r
-            Element root = doc.getDocumentElement();\r
-\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element &&\r
-                        node.getNodeName().equals(DEFINITION_ELEMENT) &&\r
-                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {\r
-                    root.removeChild(node);\r
-                }\r
-            }\r
-            Element definitionElement = doc.createElement(DEFINITION_ELEMENT);\r
-            root.appendChild(definitionElement);\r
-            definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);\r
-\r
-            Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);\r
-            definitionElement.appendChild(formatElement);\r
-            formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));\r
-\r
-            if (inputs != null) {\r
-                for (InputLine inputLine : inputs) {\r
-                    definitionElement.appendChild(createInputLineElement(inputLine, doc));\r
-                }\r
-            }\r
-\r
-            if (outputs != null) {\r
-                for (OutputColumn output : outputs) {\r
-                    Element outputColumnElement = doc.createElement(OUTPUT_COLUMN_ELEMENT);\r
-                    definitionElement.appendChild(outputColumnElement);\r
-                    outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name);\r
-                }\r
-            }\r
-\r
-            Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
-\r
-            //initialize StreamResult with File object to save to file\r
-            StreamResult result = new StreamResult(new StringWriter());\r
-            DOMSource source = new DOMSource(doc);\r
-            transformer.transform(source, result);\r
-            String xmlString = result.getWriter().toString();\r
-\r
-            FileWriter writer = new FileWriter(file);\r
-            writer.write(xmlString);\r
-            writer.close();\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (TransformerConfigurationException e) {\r
-            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (TransformerFactoryConfigurationError e) {\r
-            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (TransformerException e) {\r
-            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    private Element createInputLineElement(InputLine inputLine, Document doc) {\r
-        Element inputLineElement = doc.createElement(INPUT_LINE_ELEMENT);\r
-\r
-        Element cardinalityElement = doc.createElement(CARDINALITY_ELEMENT);\r
-        inputLineElement.appendChild(cardinalityElement);\r
-        cardinalityElement.setAttribute(MIN_ATTRIBUTE, Integer.toString(inputLine.cardinality.min));\r
-        cardinalityElement.setAttribute(MAX_ATTRIBUTE, Integer.toString(inputLine.cardinality.max));\r
-\r
-        Element regexElement = doc.createElement(REGEX_ELEMENT);\r
-        inputLineElement.appendChild(regexElement);\r
-        regexElement.appendChild(doc.createTextNode(inputLine.regex));\r
-\r
-        if (inputLine.columns != null) {\r
-            for (InputData inputData : inputLine.columns) {\r
-                Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);\r
-                inputLineElement.appendChild(inputDataElement);\r
-                inputDataElement.setAttribute(NAME_ATTRIBUTE, inputData.name);\r
-                inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputData.action));\r
-                if (inputData.format != null) {\r
-                    inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputData.format);\r
-                }\r
-            }\r
-        }\r
-\r
-        if (inputLine.childrenInputs != null) {\r
-            for (InputLine childInputLine : inputLine.childrenInputs) {\r
-                inputLineElement.appendChild(createInputLineElement(childInputLine, doc));\r
-            }\r
-        }\r
-\r
-        return inputLineElement;\r
-    }\r
-\r
-    public static CustomTxtTraceDefinition[] loadAll() {\r
-        return loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);\r
-    }\r
-\r
-    public static CustomTxtTraceDefinition[] loadAll(String path) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-               @Override\r
-                public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-               @Override\r
-                public void error(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            File file = new File(path);\r
-            if (!file.canRead()) {\r
-                return new CustomTxtTraceDefinition[0];\r
-            }\r
-            Document doc = db.parse(file);\r
-\r
-            Element root = doc.getDocumentElement();\r
-            if (! root.getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                return new CustomTxtTraceDefinition[0];\r
-            }\r
-\r
-            ArrayList<CustomTxtTraceDefinition> defList = new ArrayList<CustomTxtTraceDefinition>();\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element && node.getNodeName().equals(DEFINITION_ELEMENT)) {\r
-                    CustomTxtTraceDefinition def = extractDefinition((Element) node);\r
-                    if (def != null) {\r
-                        defList.add(def);\r
-                    }\r
-                }\r
-            }\r
-            return defList.toArray(new CustomTxtTraceDefinition[0]);\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error loading all in CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error loading all in CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error loading all in CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        }\r
-        return new CustomTxtTraceDefinition[0];\r
-    }\r
-\r
-    public static CustomTxtTraceDefinition load(String definitionName) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-               @Override\r
-                public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-               @Override\r
-                public void error(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            File file = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);\r
-            Document doc = db.parse(file);\r
-\r
-            Element root = doc.getDocumentElement();\r
-            if (! root.getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                return null;\r
-            }\r
-\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element &&\r
-                        node.getNodeName().equals(DEFINITION_ELEMENT) &&\r
-                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {\r
-                    return extractDefinition((Element) node);\r
-                }\r
-            }\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error loading CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error loading CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error loading CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public static CustomTxtTraceDefinition extractDefinition(Element definitionElement) {\r
-        CustomTxtTraceDefinition def = new CustomTxtTraceDefinition();\r
-\r
-        def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE);\r
-        if (def.definitionName == null) {\r
-            return null;\r
-        }\r
-\r
-        NodeList nodeList = definitionElement.getChildNodes();\r
-        for (int i = 0; i < nodeList.getLength(); i++) {\r
-            Node node = nodeList.item(i);\r
-            String nodeName = node.getNodeName();\r
-            if (nodeName.equals(TIME_STAMP_OUTPUT_FORMAT_ELEMENT)) {\r
-                Element formatElement = (Element) node;\r
-                def.timeStampOutputFormat = formatElement.getTextContent();\r
-            } else if (nodeName.equals(INPUT_LINE_ELEMENT)) {\r
-                InputLine inputLine = extractInputLine((Element) node);\r
-                if (inputLine != null) {\r
-                    def.inputs.add(inputLine);\r
-                }\r
-            } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) {\r
-                Element outputColumnElement = (Element) node;\r
-                OutputColumn outputColumn = new OutputColumn();\r
-                outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE);\r
-                def.outputs.add(outputColumn);\r
-            }\r
-        }\r
-        return def;\r
-    }\r
-\r
-    private static InputLine extractInputLine(Element inputLineElement) {\r
-        InputLine inputLine = new InputLine();\r
-        NodeList nodeList = inputLineElement.getChildNodes();\r
-        for (int i = 0; i < nodeList.getLength(); i++) {\r
-            Node node = nodeList.item(i);\r
-            String nodeName = node.getNodeName();\r
-            if (nodeName.equals(CARDINALITY_ELEMENT)) {\r
-                Element cardinalityElement = (Element) node;\r
-                try {\r
-                    int min = Integer.parseInt(cardinalityElement.getAttribute(MIN_ATTRIBUTE));\r
-                    int max = Integer.parseInt(cardinalityElement.getAttribute(MAX_ATTRIBUTE));\r
-                    inputLine.cardinality = new Cardinality(min, max);\r
-                } catch (NumberFormatException e) {\r
-                    return null;\r
-                }\r
-            } else if (nodeName.equals(REGEX_ELEMENT)) {\r
-                Element regexElement = (Element) node;\r
-                inputLine.regex = regexElement.getTextContent();\r
-            } else if (nodeName.equals(INPUT_DATA_ELEMENT)) {\r
-                Element inputDataElement = (Element) node;\r
-                InputData inputData = new InputData();\r
-                inputData.name = inputDataElement.getAttribute(NAME_ATTRIBUTE);\r
-                inputData.action = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));\r
-                inputData.format = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);\r
-                inputLine.addColumn(inputData);\r
-            } else if (nodeName.equals(INPUT_LINE_ELEMENT)) {\r
-                Element childInputLineElement = (Element) node;\r
-                InputLine childInputLine = extractInputLine(childInputLineElement);\r
-                if (childInputLine != null) {\r
-                    inputLine.addChild(childInputLine);\r
-                }\r
-            }\r
-        }\r
-        return inputLine;\r
-    }\r
-\r
-    public static void delete(String definitionName) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-               @Override\r
-                public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-               @Override\r
-                public void error(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-               @Override\r
-                public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            File file = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);\r
-            Document doc = db.parse(file);\r
-\r
-            Element root = doc.getDocumentElement();\r
-            if (! root.getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                return;\r
-            }\r
-\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element &&\r
-                        node.getNodeName().equals(DEFINITION_ELEMENT) &&\r
-                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {\r
-                    root.removeChild(node);\r
-                }\r
-            }\r
-\r
-            Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
-\r
-            //initialize StreamResult with File object to save to file\r
-            StreamResult result = new StreamResult(new StringWriter());\r
-            DOMSource source = new DOMSource(doc);\r
-            transformer.transform(source, result);\r
-            String xmlString = result.getWriter().toString();\r
-\r
-            FileWriter writer = new FileWriter(file);\r
-            writer.write(xmlString);\r
-            writer.close();\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$\r
-        } catch (TransformerConfigurationException e) {\r
-            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$\r
-        } catch (TransformerFactoryConfigurationError e) {\r
-            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$\r
-        } catch (TransformerException e) {\r
-            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class CustomTxtTraceDefinition extends CustomTraceDefinition {
+
+    protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME = "custom_txt_parsers.xml"; //$NON-NLS-1$
+    protected static final String CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME =
+        Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_TXT_TRACE_DEFINITIONS_FILE_NAME).toString();
+
+    private static final String CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomTxtTraceDefinition_definitionRootElement;
+    private static final String DEFINITION_ELEMENT = Messages.CustomTxtTraceDefinition_definition;
+    private static final String NAME_ATTRIBUTE = Messages.CustomTxtTraceDefinition_name;
+    private static final String TIME_STAMP_OUTPUT_FORMAT_ELEMENT = Messages.CustomTxtTraceDefinition_timestampOutputFormat;
+    private static final String INPUT_LINE_ELEMENT = Messages.CustomTxtTraceDefinition_inputLine;
+    private static final String CARDINALITY_ELEMENT = Messages.CustomTxtTraceDefinition_cardinality;
+    private static final String MIN_ATTRIBUTE = Messages.CustomTxtTraceDefinition_min;
+    private static final String MAX_ATTRIBUTE = Messages.CustomTxtTraceDefinition_max;
+    private static final String REGEX_ELEMENT = Messages.CustomTxtTraceDefinition_regEx;
+    private static final String INPUT_DATA_ELEMENT = Messages.CustomTxtTraceDefinition_inputData;
+    private static final String ACTION_ATTRIBUTE = Messages.CustomTxtTraceDefinition_action;
+    private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format;
+    private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomTxtTraceDefinition_outputColumn;
+
+    public List<InputLine> inputs;
+
+    public CustomTxtTraceDefinition() {
+        this("", new ArrayList<InputLine>(0), new ArrayList<OutputColumn>(0), ""); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    public CustomTxtTraceDefinition(String logtype, List<InputLine> inputs, List<OutputColumn> outputs, String timeStampOutputFormat) {
+        this.definitionName = logtype;
+        this.inputs = inputs;
+        this.outputs = outputs;
+        this.timeStampOutputFormat = timeStampOutputFormat;
+    }
+
+    public static class InputLine {
+        public List<InputData> columns;
+        public Cardinality cardinality;
+        private String regex;
+        private Pattern pattern;
+        public InputLine parentInput;
+        public int level;
+        public InputLine nextInput;
+        public List<InputLine> childrenInputs;
+
+        public InputLine() {}
+
+        public InputLine(Cardinality cardinality, String regex, List<InputData> columns) {
+            this.cardinality = cardinality;
+            this.regex = regex;
+            this.columns = columns;
+        }
+
+        public void setRegex(String regex) {
+            this.regex = regex;
+            this.pattern = null;
+        }
+
+        public String getRegex() {
+            return regex;
+        }
+
+        public Pattern getPattern() throws PatternSyntaxException {
+            if (pattern == null) {
+                pattern = Pattern.compile(regex);
+            }
+            return pattern;
+        }
+
+        public void addChild(InputLine input) {
+            if (childrenInputs == null) {
+                childrenInputs = new ArrayList<InputLine>(1);
+            } else if (childrenInputs.size() > 0) {
+                InputLine last = childrenInputs.get(childrenInputs.size() - 1);
+                last.nextInput = input;
+            }
+            childrenInputs.add(input);
+            input.parentInput = this;
+            input.level = this.level + 1;
+        }
+
+        public void addNext(InputLine input) {
+            if (parentInput != null) {
+                int index = parentInput.childrenInputs.indexOf(this);
+                parentInput.childrenInputs.add(index + 1, input);
+                InputLine next = nextInput;
+                nextInput = input;
+                input.nextInput = next;
+            }
+            input.parentInput = this.parentInput;
+            input.level = this.level;
+        }
+
+        public void moveUp() {
+            if (parentInput != null) {
+                int index = parentInput.childrenInputs.indexOf(this);
+                if (index > 0) {
+                    parentInput.childrenInputs.add(index - 1 , parentInput.childrenInputs.remove(index));
+                    parentInput.childrenInputs.get(index).nextInput = nextInput;
+                    nextInput = parentInput.childrenInputs.get(index);
+                }
+            }
+        }
+
+        public void moveDown() {
+            if (parentInput != null) {
+                int index = parentInput.childrenInputs.indexOf(this);
+                if (index < parentInput.childrenInputs.size() - 1) {
+                    parentInput.childrenInputs.add(index + 1 , parentInput.childrenInputs.remove(index));
+                    nextInput = parentInput.childrenInputs.get(index).nextInput;
+                    parentInput.childrenInputs.get(index).nextInput = this;
+                }
+            }
+        }
+
+        public void addColumn(InputData column) {
+            if (columns == null) {
+                columns = new ArrayList<InputData>(1);
+            }
+            columns.add(column);
+        }
+
+        public List<InputLine> getNextInputs(Map<InputLine, Integer> countMap) {
+            List<InputLine> nextInputs = new ArrayList<InputLine>();
+            InputLine next = nextInput;
+            while (next != null) {
+                nextInputs.add(next);
+                if (next.cardinality.min > 0) {
+                    return nextInputs;
+                }
+                next = next.nextInput;
+            }
+            if (parentInput != null && parentInput.level > 0) {
+                int parentCount = countMap.get(parentInput);
+                if (parentCount < parentInput.getMaxCount()) {
+                    nextInputs.add(parentInput);
+                }
+                if (parentCount < parentInput.getMinCount()) {
+                    return nextInputs;
+                }
+                nextInputs.addAll(parentInput.getNextInputs(countMap));
+            }
+            return nextInputs;
+        }
+
+        public int getMinCount() {
+            return cardinality.min;
+        }
+
+        public int getMaxCount() {
+            return cardinality.max;
+        }
+
+        @Override
+        public String toString() {
+            return regex + " " + cardinality; //$NON-NLS-1$
+        }
+
+    }
+
+    public static class InputData {
+        public String name;
+        public int action;
+        public String format;
+
+        public InputData() {}
+
+        public InputData(String name, int action, String format) {
+            this.name = name;
+            this.action = action;
+            this.format = format;
+        }
+
+        public InputData(String name, int action) {
+            this.name = name;
+            this.action = action;
+        }
+    }
+
+    public static class Cardinality {
+        public final static int INF = Integer.MAX_VALUE;
+        public final static Cardinality ONE = new Cardinality(1, 1);
+        public final static Cardinality ONE_OR_MORE = new Cardinality(1, INF);
+        public final static Cardinality ZERO_OR_ONE = new Cardinality(0, 1);
+        public final static Cardinality ZERO_OR_MORE = new Cardinality(0, INF);
+
+        private final int min;
+        private final int max;
+
+        public Cardinality(int min, int max) {
+            this.min = min;
+            this.max = max;
+        }
+
+               @Override
+        public String toString() {
+            return "(" + (min >= 0 ? min : "?") + "," + (max == INF ? "\u221E" : (max >= 0 ? max : "?")) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+        }
+
+        /* (non-Javadoc)
+         * @see java.lang.Object#hashCode()
+         */
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + max;
+            result = prime * result + min;
+            return result;
+        }
+
+        /* (non-Javadoc)
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof Cardinality)) {
+                return false;
+            }
+            Cardinality other = (Cardinality) obj;
+            return (this.min == other.min && this.max == other.max);
+        }
+    }
+
+    @Override
+       public void save() {
+        save(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
+    }
+
+    @Override
+       public void save(String path) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+               @Override
+                public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+               @Override
+                public void error(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void warning(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            Document doc = null;
+            File file = new File(path);
+            if (file.canRead()) {
+                doc = db.parse(file);
+                if (! doc.getDocumentElement().getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                    return;
+                }
+            } else {
+                doc = db.newDocument();
+                Node node = doc.createElement(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT);
+                doc.appendChild(node);
+            }
+
+            Element root = doc.getDocumentElement();
+
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element &&
+                        node.getNodeName().equals(DEFINITION_ELEMENT) &&
+                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {
+                    root.removeChild(node);
+                }
+            }
+            Element definitionElement = doc.createElement(DEFINITION_ELEMENT);
+            root.appendChild(definitionElement);
+            definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);
+
+            Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);
+            definitionElement.appendChild(formatElement);
+            formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));
+
+            if (inputs != null) {
+                for (InputLine inputLine : inputs) {
+                    definitionElement.appendChild(createInputLineElement(inputLine, doc));
+                }
+            }
+
+            if (outputs != null) {
+                for (OutputColumn output : outputs) {
+                    Element outputColumnElement = doc.createElement(OUTPUT_COLUMN_ELEMENT);
+                    definitionElement.appendChild(outputColumnElement);
+                    outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name);
+                }
+            }
+
+            Transformer transformer = TransformerFactory.newInstance().newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+            //initialize StreamResult with File object to save to file
+            StreamResult result = new StreamResult(new StringWriter());
+            DOMSource source = new DOMSource(doc);
+            transformer.transform(source, result);
+            String xmlString = result.getWriter().toString();
+
+            FileWriter writer = new FileWriter(file);
+            writer.write(xmlString);
+            writer.close();
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (TransformerConfigurationException e) {
+            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (TransformerFactoryConfigurationError e) {
+            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (TransformerException e) {
+            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error saving CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        }
+    }
+
+    private Element createInputLineElement(InputLine inputLine, Document doc) {
+        Element inputLineElement = doc.createElement(INPUT_LINE_ELEMENT);
+
+        Element cardinalityElement = doc.createElement(CARDINALITY_ELEMENT);
+        inputLineElement.appendChild(cardinalityElement);
+        cardinalityElement.setAttribute(MIN_ATTRIBUTE, Integer.toString(inputLine.cardinality.min));
+        cardinalityElement.setAttribute(MAX_ATTRIBUTE, Integer.toString(inputLine.cardinality.max));
+
+        Element regexElement = doc.createElement(REGEX_ELEMENT);
+        inputLineElement.appendChild(regexElement);
+        regexElement.appendChild(doc.createTextNode(inputLine.regex));
+
+        if (inputLine.columns != null) {
+            for (InputData inputData : inputLine.columns) {
+                Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
+                inputLineElement.appendChild(inputDataElement);
+                inputDataElement.setAttribute(NAME_ATTRIBUTE, inputData.name);
+                inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputData.action));
+                if (inputData.format != null) {
+                    inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputData.format);
+                }
+            }
+        }
+
+        if (inputLine.childrenInputs != null) {
+            for (InputLine childInputLine : inputLine.childrenInputs) {
+                inputLineElement.appendChild(createInputLineElement(childInputLine, doc));
+            }
+        }
+
+        return inputLineElement;
+    }
+
+    public static CustomTxtTraceDefinition[] loadAll() {
+        return loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
+    }
+
+    public static CustomTxtTraceDefinition[] loadAll(String path) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+               @Override
+                public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+               @Override
+                public void error(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void warning(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            File file = new File(path);
+            if (!file.canRead()) {
+                return new CustomTxtTraceDefinition[0];
+            }
+            Document doc = db.parse(file);
+
+            Element root = doc.getDocumentElement();
+            if (! root.getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                return new CustomTxtTraceDefinition[0];
+            }
+
+            ArrayList<CustomTxtTraceDefinition> defList = new ArrayList<CustomTxtTraceDefinition>();
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element && node.getNodeName().equals(DEFINITION_ELEMENT)) {
+                    CustomTxtTraceDefinition def = extractDefinition((Element) node);
+                    if (def != null) {
+                        defList.add(def);
+                    }
+                }
+            }
+            return defList.toArray(new CustomTxtTraceDefinition[0]);
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error loading all in CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error loading all in CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error loading all in CustomTxtTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        }
+        return new CustomTxtTraceDefinition[0];
+    }
+
+    public static CustomTxtTraceDefinition load(String definitionName) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+               @Override
+                public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+               @Override
+                public void error(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void warning(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            File file = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
+            Document doc = db.parse(file);
+
+            Element root = doc.getDocumentElement();
+            if (! root.getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                return null;
+            }
+
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element &&
+                        node.getNodeName().equals(DEFINITION_ELEMENT) &&
+                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {
+                    return extractDefinition((Element) node);
+                }
+            }
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error loading CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error loading CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error loading CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        }
+        return null;
+    }
+
+    public static CustomTxtTraceDefinition extractDefinition(Element definitionElement) {
+        CustomTxtTraceDefinition def = new CustomTxtTraceDefinition();
+
+        def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE);
+        if (def.definitionName == null) {
+            return null;
+        }
+
+        NodeList nodeList = definitionElement.getChildNodes();
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            Node node = nodeList.item(i);
+            String nodeName = node.getNodeName();
+            if (nodeName.equals(TIME_STAMP_OUTPUT_FORMAT_ELEMENT)) {
+                Element formatElement = (Element) node;
+                def.timeStampOutputFormat = formatElement.getTextContent();
+            } else if (nodeName.equals(INPUT_LINE_ELEMENT)) {
+                InputLine inputLine = extractInputLine((Element) node);
+                if (inputLine != null) {
+                    def.inputs.add(inputLine);
+                }
+            } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) {
+                Element outputColumnElement = (Element) node;
+                OutputColumn outputColumn = new OutputColumn();
+                outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE);
+                def.outputs.add(outputColumn);
+            }
+        }
+        return def;
+    }
+
+    private static InputLine extractInputLine(Element inputLineElement) {
+        InputLine inputLine = new InputLine();
+        NodeList nodeList = inputLineElement.getChildNodes();
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            Node node = nodeList.item(i);
+            String nodeName = node.getNodeName();
+            if (nodeName.equals(CARDINALITY_ELEMENT)) {
+                Element cardinalityElement = (Element) node;
+                try {
+                    int min = Integer.parseInt(cardinalityElement.getAttribute(MIN_ATTRIBUTE));
+                    int max = Integer.parseInt(cardinalityElement.getAttribute(MAX_ATTRIBUTE));
+                    inputLine.cardinality = new Cardinality(min, max);
+                } catch (NumberFormatException e) {
+                    return null;
+                }
+            } else if (nodeName.equals(REGEX_ELEMENT)) {
+                Element regexElement = (Element) node;
+                inputLine.regex = regexElement.getTextContent();
+            } else if (nodeName.equals(INPUT_DATA_ELEMENT)) {
+                Element inputDataElement = (Element) node;
+                InputData inputData = new InputData();
+                inputData.name = inputDataElement.getAttribute(NAME_ATTRIBUTE);
+                inputData.action = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));
+                inputData.format = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);
+                inputLine.addColumn(inputData);
+            } else if (nodeName.equals(INPUT_LINE_ELEMENT)) {
+                Element childInputLineElement = (Element) node;
+                InputLine childInputLine = extractInputLine(childInputLineElement);
+                if (childInputLine != null) {
+                    inputLine.addChild(childInputLine);
+                }
+            }
+        }
+        return inputLine;
+    }
+
+    public static void delete(String definitionName) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+               @Override
+                public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+               @Override
+                public void error(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void warning(SAXParseException saxparseexception) throws SAXException {}
+               @Override
+                public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            File file = new File(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME);
+            Document doc = db.parse(file);
+
+            Element root = doc.getDocumentElement();
+            if (! root.getNodeName().equals(CUSTOM_TXT_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                return;
+            }
+
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element &&
+                        node.getNodeName().equals(DEFINITION_ELEMENT) &&
+                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {
+                    root.removeChild(node);
+                }
+            }
+
+            Transformer transformer = TransformerFactory.newInstance().newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+            //initialize StreamResult with File object to save to file
+            StreamResult result = new StreamResult(new StringWriter());
+            DOMSource source = new DOMSource(doc);
+            transformer.transform(source, result);
+            String xmlString = result.getWriter().toString();
+
+            FileWriter writer = new FileWriter(file);
+            writer.write(xmlString);
+            writer.close();
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$
+        } catch (TransformerConfigurationException e) {
+            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$
+        } catch (TransformerFactoryConfigurationError e) {
+            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$
+        } catch (TransformerException e) {
+            Activator.getDefault().logError("Error deleting CustomTxtTraceDefinition: definitionName= " + definitionName, e); //$NON-NLS-1$
+        }
+    }
+}
index 04704d64d8a760c4e137729009659eb12b7c487b..ac9eb0ce6dac808564a76ee02367cd593bad1bac 100644 (file)
@@ -1,83 +1,83 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-public class CustomXmlEvent extends CustomEvent {\r
-\r
-    public CustomXmlEvent(CustomXmlTraceDefinition definition) {\r
-        super(definition);\r
-        setType(new CustomXmlEventType(definition));\r
-    }\r
-\r
-    public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {\r
-        super(definition, other);\r
-    }\r
-\r
-    public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {\r
-        super(definition, parentTrace, timestamp, source, type, reference);\r
-    }\r
-\r
-    @Override\r
-    public void setContent(ITmfEventField content) {\r
-        super.setContent(content);\r
-    }\r
-\r
-    public void parseInput(String value, String name, int inputAction, String inputFormat) {\r
-        if (value.length() == 0) {\r
-            return;\r
-        }\r
-        if (inputAction == CustomTraceDefinition.ACTION_SET) {\r
-            fData.put(name, value);\r
-            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);\r
-            }\r
-        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {\r
-            String s = fData.get(name);\r
-            if (s != null) {\r
-                fData.put(name, s + value);\r
-            } else {\r
-                fData.put(name, value);\r
-            }\r
-            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
-                if (timeStampInputFormat != null) {\r
-                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + inputFormat);\r
-                } else {\r
-                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);\r
-                }\r
-            }\r
-        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-            String s = fData.get(name);\r
-            if (s != null) {\r
-                fData.put(name, s + " | " + value); //$NON-NLS-1$\r
-            } else {\r
-                fData.put(name, value);\r
-            }\r
-            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
-                if (timeStampInputFormat != null) {\r
-                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + inputFormat); //$NON-NLS-1$\r
-                } else {\r
-                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+public class CustomXmlEvent extends CustomEvent {
+
+    public CustomXmlEvent(CustomXmlTraceDefinition definition) {
+        super(definition);
+        setType(new CustomXmlEventType(definition));
+    }
+
+    public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {
+        super(definition, other);
+    }
+
+    public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
+        super(definition, parentTrace, timestamp, source, type, reference);
+    }
+
+    @Override
+    public void setContent(ITmfEventField content) {
+        super.setContent(content);
+    }
+
+    public void parseInput(String value, String name, int inputAction, String inputFormat) {
+        if (value.length() == 0) {
+            return;
+        }
+        if (inputAction == CustomTraceDefinition.ACTION_SET) {
+            fData.put(name, value);
+            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
+            }
+        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {
+            String s = fData.get(name);
+            if (s != null) {
+                fData.put(name, s + value);
+            } else {
+                fData.put(name, value);
+            }
+            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+                if (timeStampInputFormat != null) {
+                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + inputFormat);
+                } else {
+                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
+                }
+            }
+        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+            String s = fData.get(name);
+            if (s != null) {
+                fData.put(name, s + " | " + value); //$NON-NLS-1$
+            } else {
+                fData.put(name, value);
+            }
+            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+                if (timeStampInputFormat != null) {
+                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + inputFormat); //$NON-NLS-1$
+                } else {
+                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
+                }
+            }
+        }
+    }
+
+}
index d4e8b6636d86230a6cd815ecb22e4179f7f04dc2..5c86752decd5dd46c0c88334af7457dec4a86129 100644 (file)
@@ -1,21 +1,21 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-public class CustomXmlEventType extends CustomEventType {\r
-\r
-       public CustomXmlEventType(CustomXmlTraceDefinition definition) {\r
-               super(definition);\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+public class CustomXmlEventType extends CustomEventType {
+
+       public CustomXmlEventType(CustomXmlTraceDefinition definition) {
+               super(definition);
+       }
+
+}
index fb13a4c0cf707143a6a2f29fc7651a04db3f1c33..418487c308ee4be11f77bcabff4a00e4c708892c 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.IOException;\r
-import java.io.RandomAccessFile;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-\r
-import org.eclipse.core.resources.IProject;\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
-import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.w3c.dom.Node;\r
-import org.w3c.dom.NodeList;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> implements ITmfEventParser<CustomXmlEvent> {\r
-\r
-    private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
-    private static final int DEFAULT_CACHE_SIZE = 100;\r
-\r
-    private final CustomXmlTraceDefinition fDefinition;\r
-    private final CustomXmlEventType fEventType;\r
-    private final InputElement fRecordInputElement;\r
-    private BufferedRandomAccessFile fFile;\r
-\r
-    public CustomXmlTrace(final CustomXmlTraceDefinition definition) {\r
-        fDefinition = definition;\r
-        fEventType = new CustomXmlEventType(fDefinition);\r
-        fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement);\r
-        setCacheSize(DEFAULT_CACHE_SIZE);\r
-    }\r
-\r
-    public CustomXmlTrace(final IResource resource, final CustomXmlTraceDefinition definition, final String path, final int pageSize) throws TmfTraceException {\r
-        this(definition);\r
-        setCacheSize((pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE);\r
-        initTrace(resource, path, CustomXmlEvent.class);\r
-    }\r
-\r
-    @Override\r
-    public void initTrace(final IResource resource, final String path, final Class<CustomXmlEvent> eventType) throws TmfTraceException {\r
-        super.initTrace(resource, path, eventType);\r
-        try {\r
-            fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            throw new TmfTraceException(e.getMessage(), e);\r
-        }\r
-        indexTrace(false);\r
-    }\r
-\r
-    @Override\r
-    public synchronized void dispose() {\r
-        super.dispose();\r
-        if (fFile != null) {\r
-            try {\r
-                fFile.close();\r
-            } catch (IOException e) {\r
-            } finally {\r
-                fFile = null;\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {\r
-        final CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
-        if (NULL_LOCATION.equals(location) || fFile == null) {\r
-            return context;\r
-        }\r
-        try {\r
-            if (location == null) {\r
-                fFile.seek(0);\r
-            } else if (location.getLocation() instanceof Long) {\r
-                fFile.seek((Long) location.getLocation());\r
-            }\r
-            String line;\r
-            final String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$\r
-            long rawPos = fFile.getFilePointer();\r
-\r
-            while ((line = fFile.getNextLine()) != null) {\r
-                final int idx = line.indexOf(recordElementStart);\r
-                if (idx != -1) {\r
-                    context.setLocation(new TmfLocation<Long>(rawPos + idx));\r
-                    return context;\r
-                }\r
-                rawPos = fFile.getFilePointer();\r
-            }\r
-            return context;\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
-            return context;\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    public synchronized TmfContext seekEvent(final double ratio) {\r
-        if (fFile == null) {\r
-            return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
-        }\r
-        try {\r
-            long pos = (long) (ratio * fFile.length());\r
-            while (pos > 0) {\r
-                fFile.seek(pos - 1);\r
-                if (fFile.read() == '\n') {\r
-                    break;\r
-                }\r
-                pos--;\r
-            }\r
-            final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
-            final TmfContext context = seekEvent(location);\r
-            context.setRank(ITmfContext.UNKNOWN_RANK);\r
-            return context;\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
-            return new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public synchronized double getLocationRatio(final ITmfLocation<?> location) {\r
-        if (fFile == null) {\r
-            return 0;\r
-        }\r
-        try {\r
-            if (location.getLocation() instanceof Long) {\r
-                return (double) ((Long) location.getLocation()) / fFile.length();\r
-            }\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error getting location ration. File: " + getPath(), e); //$NON-NLS-1$\r
-        }\r
-        return 0;\r
-    }\r
-\r
-    @Override\r
-    public ITmfLocation<?> getCurrentLocation() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public synchronized CustomXmlEvent parseEvent(final ITmfContext tmfContext) {\r
-        ITmfContext context = seekEvent(tmfContext.getLocation());\r
-        return parse(context);\r
-    }\r
-\r
-    @Override\r
-    public synchronized CustomXmlEvent getNext(final ITmfContext context) {\r
-        final ITmfContext savedContext = context.clone();\r
-        final CustomXmlEvent event = parse(context);\r
-        if (event != null) {\r
-            updateAttributes(savedContext, event.getTimestamp());\r
-            context.increaseRank();\r
-        }\r
-        return event;\r
-    }\r
-\r
-    private synchronized CustomXmlEvent parse(final ITmfContext tmfContext) {\r
-        if (fFile == null) {\r
-            return null;\r
-        }\r
-        if (!(tmfContext instanceof CustomXmlTraceContext)) {\r
-            return null;\r
-        }\r
-\r
-        final CustomXmlTraceContext context = (CustomXmlTraceContext) tmfContext;\r
-        if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
-            return null;\r
-        }\r
-\r
-        CustomXmlEvent event = null;\r
-        try {\r
-            if (fFile.getFilePointer() != (Long)context.getLocation().getLocation() + 1)\r
-            {\r
-                fFile.seek((Long)context.getLocation().getLocation() + 1); // +1 is for the <\r
-            }\r
-            final StringBuffer elementBuffer = new StringBuffer("<"); //$NON-NLS-1$\r
-            readElement(elementBuffer, fFile);\r
-            final Element element = parseElementBuffer(elementBuffer);\r
-\r
-            event = extractEvent(element, fRecordInputElement);\r
-            ((StringBuffer) event.getContent().getValue()).append(elementBuffer);\r
-\r
-            String line;\r
-            final String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$\r
-            long rawPos = fFile.getFilePointer();\r
-\r
-            while ((line = fFile.getNextLine()) != null) {\r
-                final int idx = line.indexOf(recordElementStart);\r
-                if (idx != -1) {\r
-                    context.setLocation(new TmfLocation<Long>(rawPos + idx));\r
-                    return event;\r
-                }\r
-                rawPos = fFile.getFilePointer();\r
-            }\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error parsing event. File: " + getPath(), e); //$NON-NLS-1$\r
-\r
-        }\r
-        context.setLocation(NULL_LOCATION);\r
-        return event;\r
-    }\r
-\r
-    private Element parseElementBuffer(final StringBuffer elementBuffer) {\r
-        try {\r
-            final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            final DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            final EntityResolver resolver = new EntityResolver () {\r
-                @Override\r
-                public InputSource resolveEntity (final String publicId, final String systemId) {\r
-                    final String empty = ""; //$NON-NLS-1$\r
-                    final ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-                @Override\r
-                public void error(final SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                public void warning(final SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                public void fatalError(final SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            final Document doc = db.parse(new ByteArrayInputStream(elementBuffer.toString().getBytes()));\r
-            return doc.getDocumentElement();\r
-        } catch (final ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error parsing element buffer. File:" + getPath(), e); //$NON-NLS-1$\r
-        } catch (final SAXException e) {\r
-            Activator.getDefault().logError("Error parsing element buffer. File:" + getPath(), e); //$NON-NLS-1$\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error parsing element buffer. File: " + getPath(), e); //$NON-NLS-1$\r
-        }\r
-        return null;\r
-    }\r
-\r
-    private void readElement(final StringBuffer buffer, final RandomAccessFile raFile) {\r
-        try {\r
-            int numRead = 0;\r
-            boolean startTagClosed = false;\r
-            int i;\r
-            while ((i = raFile.read()) != -1) {\r
-                numRead++;\r
-                final char c = (char)i;\r
-                buffer.append(c);\r
-                if (c == '"') {\r
-                    readQuote(buffer, raFile, '"');\r
-                } else if (c == '\'') {\r
-                    readQuote(buffer, raFile, '\'');\r
-                } else if (c == '<') {\r
-                    readElement(buffer, raFile);\r
-                } else if (c == '/' && numRead == 1) {\r
-                    break; // found "</"\r
-                } else if (c == '-' && numRead == 3 && buffer.substring(buffer.length() - 3, buffer.length() - 1).equals("!-")) { //$NON-NLS-1$\r
-                    readComment(buffer, raFile); // found "<!--"\r
-                } else if (i == '>') {\r
-                    if (buffer.charAt(buffer.length() - 2) == '/') {\r
-                        break; // found "/>"\r
-                    } else if (startTagClosed) {\r
-                        break; // found "<...>...</...>"\r
-                    }\r
-                    else {\r
-                        startTagClosed = true; // found "<...>"\r
-                    }\r
-                }\r
-            }\r
-            return;\r
-        } catch (final IOException e) {\r
-            return;\r
-        }\r
-    }\r
-\r
-    private static void readQuote(final StringBuffer buffer,\r
-            final RandomAccessFile raFile, final char eq) {\r
-        try {\r
-            int i;\r
-            while ((i = raFile.read()) != -1) {\r
-                final char c = (char)i;\r
-                buffer.append(c);\r
-                if (c == eq)\r
-                {\r
-                    break; // found matching end-quote\r
-                }\r
-            }\r
-            return;\r
-        } catch (final IOException e) {\r
-            return;\r
-        }\r
-    }\r
-\r
-    private static void readComment(final StringBuffer buffer,\r
-            final RandomAccessFile raFile) {\r
-        try {\r
-            int numRead = 0;\r
-            int i;\r
-            while ((i = raFile.read()) != -1) {\r
-                numRead++;\r
-                final char c = (char)i;\r
-                buffer.append(c);\r
-                if (c == '>' && numRead >= 2 && buffer.substring(buffer.length() - 3, buffer.length() - 1).equals("--")) //$NON-NLS-1$\r
-                {\r
-                    break; // found "-->"\r
-                }\r
-            }\r
-            return;\r
-        } catch (final IOException e) {\r
-            return;\r
-        }\r
-    }\r
-\r
-    public static StringBuffer parseElement(final Element parentElement, final StringBuffer buffer) {\r
-        final NodeList nodeList = parentElement.getChildNodes();\r
-        String separator = null;\r
-        for (int i = 0; i < nodeList.getLength(); i++) {\r
-            final Node node = nodeList.item(i);\r
-            if (node.getNodeType() == Node.ELEMENT_NODE) {\r
-                if (separator == null) {\r
-                    separator = " | "; //$NON-NLS-1$\r
-                } else {\r
-                    buffer.append(separator);\r
-                }\r
-                final Element element = (Element) node;\r
-                if (!element.hasChildNodes()) {\r
-                    buffer.append(element.getNodeName());\r
-                } else if (element.getChildNodes().getLength() == 1 && element.getFirstChild().getNodeType() == Node.TEXT_NODE) {\r
-                    buffer.append(element.getNodeName() + ":" + element.getFirstChild().getNodeValue().trim()); //$NON-NLS-1$\r
-                } else {\r
-                    buffer.append(element.getNodeName());\r
-                    buffer.append(" [ "); //$NON-NLS-1$\r
-                    parseElement(element, buffer);\r
-                    buffer.append(" ]"); //$NON-NLS-1$\r
-                }\r
-            } else if (node.getNodeType() == Node.TEXT_NODE) {\r
-                if (node.getNodeValue().trim().length() != 0) {\r
-                    buffer.append(node.getNodeValue().trim());\r
-                }\r
-            }\r
-        }\r
-        return buffer;\r
-    }\r
-\r
-    public InputElement getRecordInputElement(final InputElement inputElement) {\r
-        if (inputElement.logEntry) {\r
-            return inputElement;\r
-        } else if (inputElement.childElements != null) {\r
-            for (final InputElement childInputElement : inputElement.childElements) {\r
-                final InputElement recordInputElement = getRecordInputElement(childInputElement);\r
-                if (recordInputElement != null) {\r
-                    return recordInputElement;\r
-                }\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public CustomXmlEvent extractEvent(final Element element, final InputElement inputElement) {\r
-        final CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.ZERO, "", fEventType,""); //$NON-NLS-1$ //$NON-NLS-2$\r
-        event.setContent(new CustomEventContent(event, new StringBuffer()));\r
-        parseElement(element, event, inputElement);\r
-        return event;\r
-    }\r
-\r
-    private void parseElement(final Element element, final CustomXmlEvent event, final InputElement inputElement) {\r
-        if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {\r
-            event.parseInput(parseElement(element, new StringBuffer()).toString(), inputElement.inputName, inputElement.inputAction, inputElement.inputFormat);\r
-        }\r
-        if (inputElement.attributes != null) {\r
-            for (final InputAttribute attribute : inputElement.attributes) {\r
-                event.parseInput(element.getAttribute(attribute.attributeName), attribute.inputName, attribute.inputAction, attribute.inputFormat);\r
-            }\r
-        }\r
-        final NodeList childNodes = element.getChildNodes();\r
-        if (inputElement.childElements != null) {\r
-            for (int i = 0; i < childNodes.getLength(); i++) {\r
-                final Node node = childNodes.item(i);\r
-                if (node instanceof Element) {\r
-                    for (final InputElement child : inputElement.childElements) {\r
-                        if (node.getNodeName().equals(child.elementName)) {\r
-                            parseElement((Element) node, event, child);\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return;\r
-    }\r
-\r
-    public CustomTraceDefinition getDefinition() {\r
-        return fDefinition;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)\r
-     */\r
-    @Override\r
-    public boolean validate(IProject project, String path) {\r
-        return fileExists(path);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> implements ITmfEventParser<CustomXmlEvent> {
+
+    private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);
+    private static final int DEFAULT_CACHE_SIZE = 100;
+
+    private final CustomXmlTraceDefinition fDefinition;
+    private final CustomXmlEventType fEventType;
+    private final InputElement fRecordInputElement;
+    private BufferedRandomAccessFile fFile;
+
+    public CustomXmlTrace(final CustomXmlTraceDefinition definition) {
+        fDefinition = definition;
+        fEventType = new CustomXmlEventType(fDefinition);
+        fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement);
+        setCacheSize(DEFAULT_CACHE_SIZE);
+    }
+
+    public CustomXmlTrace(final IResource resource, final CustomXmlTraceDefinition definition, final String path, final int pageSize) throws TmfTraceException {
+        this(definition);
+        setCacheSize((pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE);
+        initTrace(resource, path, CustomXmlEvent.class);
+    }
+
+    @Override
+    public void initTrace(final IResource resource, final String path, final Class<CustomXmlEvent> eventType) throws TmfTraceException {
+        super.initTrace(resource, path, eventType);
+        try {
+            fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$
+        } catch (IOException e) {
+            throw new TmfTraceException(e.getMessage(), e);
+        }
+        indexTrace(false);
+    }
+
+    @Override
+    public synchronized void dispose() {
+        super.dispose();
+        if (fFile != null) {
+            try {
+                fFile.close();
+            } catch (IOException e) {
+            } finally {
+                fFile = null;
+            }
+        }
+    }
+
+    @Override
+    public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {
+        final CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
+        if (NULL_LOCATION.equals(location) || fFile == null) {
+            return context;
+        }
+        try {
+            if (location == null) {
+                fFile.seek(0);
+            } else if (location.getLocation() instanceof Long) {
+                fFile.seek((Long) location.getLocation());
+            }
+            String line;
+            final String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$
+            long rawPos = fFile.getFilePointer();
+
+            while ((line = fFile.getNextLine()) != null) {
+                final int idx = line.indexOf(recordElementStart);
+                if (idx != -1) {
+                    context.setLocation(new TmfLocation<Long>(rawPos + idx));
+                    return context;
+                }
+                rawPos = fFile.getFilePointer();
+            }
+            return context;
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
+            return context;
+        }
+
+    }
+
+    @Override
+    public synchronized TmfContext seekEvent(final double ratio) {
+        if (fFile == null) {
+            return new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
+        }
+        try {
+            long pos = (long) (ratio * fFile.length());
+            while (pos > 0) {
+                fFile.seek(pos - 1);
+                if (fFile.read() == '\n') {
+                    break;
+                }
+                pos--;
+            }
+            final ITmfLocation<?> location = new TmfLocation<Long>(pos);
+            final TmfContext context = seekEvent(location);
+            context.setRank(ITmfContext.UNKNOWN_RANK);
+            return context;
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$
+            return new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
+        }
+    }
+
+    @Override
+    public synchronized double getLocationRatio(final ITmfLocation<?> location) {
+        if (fFile == null) {
+            return 0;
+        }
+        try {
+            if (location.getLocation() instanceof Long) {
+                return (double) ((Long) location.getLocation()) / fFile.length();
+            }
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error getting location ration. File: " + getPath(), e); //$NON-NLS-1$
+        }
+        return 0;
+    }
+
+    @Override
+    public ITmfLocation<?> getCurrentLocation() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public synchronized CustomXmlEvent parseEvent(final ITmfContext tmfContext) {
+        ITmfContext context = seekEvent(tmfContext.getLocation());
+        return parse(context);
+    }
+
+    @Override
+    public synchronized CustomXmlEvent getNext(final ITmfContext context) {
+        final ITmfContext savedContext = context.clone();
+        final CustomXmlEvent event = parse(context);
+        if (event != null) {
+            updateAttributes(savedContext, event.getTimestamp());
+            context.increaseRank();
+        }
+        return event;
+    }
+
+    private synchronized CustomXmlEvent parse(final ITmfContext tmfContext) {
+        if (fFile == null) {
+            return null;
+        }
+        if (!(tmfContext instanceof CustomXmlTraceContext)) {
+            return null;
+        }
+
+        final CustomXmlTraceContext context = (CustomXmlTraceContext) tmfContext;
+        if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {
+            return null;
+        }
+
+        CustomXmlEvent event = null;
+        try {
+            if (fFile.getFilePointer() != (Long)context.getLocation().getLocation() + 1)
+            {
+                fFile.seek((Long)context.getLocation().getLocation() + 1); // +1 is for the <
+            }
+            final StringBuffer elementBuffer = new StringBuffer("<"); //$NON-NLS-1$
+            readElement(elementBuffer, fFile);
+            final Element element = parseElementBuffer(elementBuffer);
+
+            event = extractEvent(element, fRecordInputElement);
+            ((StringBuffer) event.getContent().getValue()).append(elementBuffer);
+
+            String line;
+            final String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$
+            long rawPos = fFile.getFilePointer();
+
+            while ((line = fFile.getNextLine()) != null) {
+                final int idx = line.indexOf(recordElementStart);
+                if (idx != -1) {
+                    context.setLocation(new TmfLocation<Long>(rawPos + idx));
+                    return event;
+                }
+                rawPos = fFile.getFilePointer();
+            }
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error parsing event. File: " + getPath(), e); //$NON-NLS-1$
+
+        }
+        context.setLocation(NULL_LOCATION);
+        return event;
+    }
+
+    private Element parseElementBuffer(final StringBuffer elementBuffer) {
+        try {
+            final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            final DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            final EntityResolver resolver = new EntityResolver () {
+                @Override
+                public InputSource resolveEntity (final String publicId, final String systemId) {
+                    final String empty = ""; //$NON-NLS-1$
+                    final ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+                @Override
+                public void error(final SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                public void warning(final SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                public void fatalError(final SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            final Document doc = db.parse(new ByteArrayInputStream(elementBuffer.toString().getBytes()));
+            return doc.getDocumentElement();
+        } catch (final ParserConfigurationException e) {
+            Activator.getDefault().logError("Error parsing element buffer. File:" + getPath(), e); //$NON-NLS-1$
+        } catch (final SAXException e) {
+            Activator.getDefault().logError("Error parsing element buffer. File:" + getPath(), e); //$NON-NLS-1$
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error parsing element buffer. File: " + getPath(), e); //$NON-NLS-1$
+        }
+        return null;
+    }
+
+    private void readElement(final StringBuffer buffer, final RandomAccessFile raFile) {
+        try {
+            int numRead = 0;
+            boolean startTagClosed = false;
+            int i;
+            while ((i = raFile.read()) != -1) {
+                numRead++;
+                final char c = (char)i;
+                buffer.append(c);
+                if (c == '"') {
+                    readQuote(buffer, raFile, '"');
+                } else if (c == '\'') {
+                    readQuote(buffer, raFile, '\'');
+                } else if (c == '<') {
+                    readElement(buffer, raFile);
+                } else if (c == '/' && numRead == 1) {
+                    break; // found "</"
+                } else if (c == '-' && numRead == 3 && buffer.substring(buffer.length() - 3, buffer.length() - 1).equals("!-")) { //$NON-NLS-1$
+                    readComment(buffer, raFile); // found "<!--"
+                } else if (i == '>') {
+                    if (buffer.charAt(buffer.length() - 2) == '/') {
+                        break; // found "/>"
+                    } else if (startTagClosed) {
+                        break; // found "<...>...</...>"
+                    }
+                    else {
+                        startTagClosed = true; // found "<...>"
+                    }
+                }
+            }
+            return;
+        } catch (final IOException e) {
+            return;
+        }
+    }
+
+    private static void readQuote(final StringBuffer buffer,
+            final RandomAccessFile raFile, final char eq) {
+        try {
+            int i;
+            while ((i = raFile.read()) != -1) {
+                final char c = (char)i;
+                buffer.append(c);
+                if (c == eq)
+                {
+                    break; // found matching end-quote
+                }
+            }
+            return;
+        } catch (final IOException e) {
+            return;
+        }
+    }
+
+    private static void readComment(final StringBuffer buffer,
+            final RandomAccessFile raFile) {
+        try {
+            int numRead = 0;
+            int i;
+            while ((i = raFile.read()) != -1) {
+                numRead++;
+                final char c = (char)i;
+                buffer.append(c);
+                if (c == '>' && numRead >= 2 && buffer.substring(buffer.length() - 3, buffer.length() - 1).equals("--")) //$NON-NLS-1$
+                {
+                    break; // found "-->"
+                }
+            }
+            return;
+        } catch (final IOException e) {
+            return;
+        }
+    }
+
+    public static StringBuffer parseElement(final Element parentElement, final StringBuffer buffer) {
+        final NodeList nodeList = parentElement.getChildNodes();
+        String separator = null;
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            final Node node = nodeList.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                if (separator == null) {
+                    separator = " | "; //$NON-NLS-1$
+                } else {
+                    buffer.append(separator);
+                }
+                final Element element = (Element) node;
+                if (!element.hasChildNodes()) {
+                    buffer.append(element.getNodeName());
+                } else if (element.getChildNodes().getLength() == 1 && element.getFirstChild().getNodeType() == Node.TEXT_NODE) {
+                    buffer.append(element.getNodeName() + ":" + element.getFirstChild().getNodeValue().trim()); //$NON-NLS-1$
+                } else {
+                    buffer.append(element.getNodeName());
+                    buffer.append(" [ "); //$NON-NLS-1$
+                    parseElement(element, buffer);
+                    buffer.append(" ]"); //$NON-NLS-1$
+                }
+            } else if (node.getNodeType() == Node.TEXT_NODE) {
+                if (node.getNodeValue().trim().length() != 0) {
+                    buffer.append(node.getNodeValue().trim());
+                }
+            }
+        }
+        return buffer;
+    }
+
+    public InputElement getRecordInputElement(final InputElement inputElement) {
+        if (inputElement.logEntry) {
+            return inputElement;
+        } else if (inputElement.childElements != null) {
+            for (final InputElement childInputElement : inputElement.childElements) {
+                final InputElement recordInputElement = getRecordInputElement(childInputElement);
+                if (recordInputElement != null) {
+                    return recordInputElement;
+                }
+            }
+        }
+        return null;
+    }
+
+    public CustomXmlEvent extractEvent(final Element element, final InputElement inputElement) {
+        final CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.ZERO, "", fEventType,""); //$NON-NLS-1$ //$NON-NLS-2$
+        event.setContent(new CustomEventContent(event, new StringBuffer()));
+        parseElement(element, event, inputElement);
+        return event;
+    }
+
+    private void parseElement(final Element element, final CustomXmlEvent event, final InputElement inputElement) {
+        if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+            event.parseInput(parseElement(element, new StringBuffer()).toString(), inputElement.inputName, inputElement.inputAction, inputElement.inputFormat);
+        }
+        if (inputElement.attributes != null) {
+            for (final InputAttribute attribute : inputElement.attributes) {
+                event.parseInput(element.getAttribute(attribute.attributeName), attribute.inputName, attribute.inputAction, attribute.inputFormat);
+            }
+        }
+        final NodeList childNodes = element.getChildNodes();
+        if (inputElement.childElements != null) {
+            for (int i = 0; i < childNodes.getLength(); i++) {
+                final Node node = childNodes.item(i);
+                if (node instanceof Element) {
+                    for (final InputElement child : inputElement.childElements) {
+                        if (node.getNodeName().equals(child.elementName)) {
+                            parseElement((Element) node, event, child);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        return;
+    }
+
+    public CustomTraceDefinition getDefinition() {
+        return fDefinition;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
+     */
+    @Override
+    public boolean validate(IProject project, String path) {
+        return fileExists(path);
+    }
+}
index 19c91f43236d764f0bcea87ec84fea410b17ab2b..42c69591b6b3bd6143a371e9e9350816728cb473 100644 (file)
@@ -1,49 +1,49 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
-\r
-public class CustomXmlTraceContext extends TmfContext {\r
-\r
-    public CustomXmlTraceContext(ITmfLocation<?> location, long rank) {\r
-        super(location, rank);\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        return super.hashCode();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (!super.equals(obj)) {\r
-            return false;\r
-        }\r
-        if (!(obj instanceof CustomXmlTraceContext)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+
+public class CustomXmlTraceContext extends TmfContext {
+
+    public CustomXmlTraceContext(ITmfLocation<?> location, long rank) {
+        super(location, rank);
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof CustomXmlTraceContext)) {
+            return false;
+        }
+        return true;
+    }
+
 }
\ No newline at end of file
index aa22b3ec33a022c552c0479862bfb31705be4933..6b49db56d8dd0379584a869a395bb63bddc9d235 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.io.StringWriter;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-import javax.xml.transform.OutputKeys;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerConfigurationException;\r
-import javax.xml.transform.TransformerException;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.TransformerFactoryConfigurationError;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.w3c.dom.Node;\r
-import org.w3c.dom.NodeList;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-public class CustomXmlTraceDefinition extends CustomTraceDefinition {\r
-\r
-    protected static final String CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME = "custom_xml_parsers.xml"; //$NON-NLS-1$\r
-    protected static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME =\r
-        Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME).toString();\r
-\r
-    public static final String TAG_IGNORE = Messages.CustomXmlTraceDefinition_ignoreTag;\r
-\r
-    private static final String CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomXmlTraceDefinition_definitionRootElement;\r
-    private static final String DEFINITION_ELEMENT = Messages.CustomXmlTraceDefinition_definition;\r
-    private static final String NAME_ATTRIBUTE = Messages.CustomXmlTraceDefinition_name;\r
-    private static final String LOG_ENTRY_ATTRIBUTE = Messages.CustomXmlTraceDefinition_logEntry;\r
-    private static final String TIME_STAMP_OUTPUT_FORMAT_ELEMENT = Messages.CustomXmlTraceDefinition_timestampOutputFormat;\r
-    private static final String INPUT_ELEMENT_ELEMENT = Messages.CustomXmlTraceDefinition_inputElement;\r
-    private static final String ATTRIBUTE_ELEMENT = Messages.CustomXmlTraceDefinition_attribute;\r
-    private static final String INPUT_DATA_ELEMENT = Messages.CustomXmlTraceDefinition_inputData;\r
-    private static final String ACTION_ATTRIBUTE = Messages.CustomXmlTraceDefinition_action;\r
-    private static final String FORMAT_ATTRIBUTE = Messages.CustomXmlTraceDefinition_format;\r
-    private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn;\r
-\r
-    public InputElement rootInputElement;\r
-\r
-    public CustomXmlTraceDefinition() {\r
-        this("", null, new ArrayList<OutputColumn>(), ""); //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-\r
-    public CustomXmlTraceDefinition(String logtype, InputElement rootElement, List<OutputColumn> outputs, String timeStampOutputFormat) {\r
-        this.definitionName = logtype;\r
-        this.rootInputElement = rootElement;\r
-        this.outputs = outputs;\r
-        this.timeStampOutputFormat = timeStampOutputFormat;\r
-    }\r
-\r
-    public static class InputElement {\r
-        public String elementName;\r
-        public boolean logEntry;\r
-        public String inputName;\r
-        public int inputAction;\r
-        public String inputFormat;\r
-        public List<InputAttribute> attributes;\r
-        public InputElement parentElement;\r
-        public InputElement nextElement;\r
-        public List<InputElement> childElements;\r
-\r
-        public InputElement() {}\r
-\r
-        public InputElement(String elementName, boolean logEntry, String inputName, int inputAction, String inputFormat, List<InputAttribute> attributes) {\r
-            this.elementName = elementName;\r
-            this.logEntry = logEntry;\r
-            this.inputName = inputName;\r
-            this.inputAction = inputAction;\r
-            this.inputFormat = inputFormat;\r
-            this.attributes = attributes;\r
-        }\r
-\r
-        public void addAttribute(InputAttribute attribute) {\r
-            if (attributes == null) {\r
-                attributes = new ArrayList<InputAttribute>(1);\r
-            }\r
-            attributes.add(attribute);\r
-        }\r
-\r
-        public void addChild(InputElement input) {\r
-            if (childElements == null) {\r
-                childElements = new ArrayList<InputElement>(1);\r
-            } else if (childElements.size() > 0) {\r
-                InputElement last = childElements.get(childElements.size() - 1);\r
-                last.nextElement = input;\r
-            }\r
-            childElements.add(input);\r
-            input.parentElement = this;\r
-        }\r
-\r
-        public void addNext(InputElement input) {\r
-            if (parentElement != null) {\r
-                int index = parentElement.childElements.indexOf(this);\r
-                parentElement.childElements.add(index + 1, input);\r
-                InputElement next = nextElement;\r
-                nextElement = input;\r
-                input.nextElement = next;\r
-            }\r
-            input.parentElement = this.parentElement;\r
-        }\r
-\r
-        public void moveUp() {\r
-            if (parentElement != null) {\r
-                int index = parentElement.childElements.indexOf(this);\r
-                if (index > 0) {\r
-                    parentElement.childElements.add(index - 1 , parentElement.childElements.remove(index));\r
-                    parentElement.childElements.get(index).nextElement = nextElement;\r
-                    nextElement = parentElement.childElements.get(index);\r
-                }\r
-            }\r
-        }\r
-\r
-        public void moveDown() {\r
-            if (parentElement != null) {\r
-                int index = parentElement.childElements.indexOf(this);\r
-                if (index < parentElement.childElements.size() - 1) {\r
-                    parentElement.childElements.add(index + 1 , parentElement.childElements.remove(index));\r
-                    nextElement = parentElement.childElements.get(index).nextElement;\r
-                    parentElement.childElements.get(index).nextElement = this;\r
-                }\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    public static class InputAttribute {\r
-        public String attributeName;\r
-        public String inputName;\r
-        public int inputAction;\r
-        public String inputFormat;\r
-\r
-        public InputAttribute() {}\r
-\r
-        public InputAttribute(String attributeName, String inputName, int inputAction, String inputFormat) {\r
-            this.attributeName = attributeName;\r
-            this.inputName = inputName;\r
-            this.inputAction = inputAction;\r
-            this.inputFormat = inputFormat;\r
-        }\r
-    }\r
-\r
-       @Override\r
-    public void save() {\r
-        save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);\r
-    }\r
-\r
-       @Override\r
-    public void save(String path) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-                @Override\r
-                               public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-                @Override\r
-                               public void error(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            Document doc = null;\r
-            File file = new File(path);\r
-            if (file.canRead()) {\r
-                doc = db.parse(file);\r
-                if (! doc.getDocumentElement().getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                    return;\r
-                }\r
-            } else {\r
-                doc = db.newDocument();\r
-                Node node = doc.createElement(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT);\r
-                doc.appendChild(node);\r
-            }\r
-\r
-            Element root = doc.getDocumentElement();\r
-\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element &&\r
-                        node.getNodeName().equals(DEFINITION_ELEMENT) &&\r
-                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {\r
-                    root.removeChild(node);\r
-                }\r
-            }\r
-            Element definitionElement = doc.createElement(DEFINITION_ELEMENT);\r
-            root.appendChild(definitionElement);\r
-            definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);\r
-\r
-            Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT);\r
-            definitionElement.appendChild(formatElement);\r
-            formatElement.appendChild(doc.createTextNode(timeStampOutputFormat));\r
-\r
-            if (rootInputElement != null) {\r
-                definitionElement.appendChild(createInputElementElement(rootInputElement, doc));\r
-            }\r
-\r
-            if (outputs != null) {\r
-                for (OutputColumn output : outputs) {\r
-                    Element outputColumnElement = doc.createElement(OUTPUT_COLUMN_ELEMENT);\r
-                    definitionElement.appendChild(outputColumnElement);\r
-                    outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name);\r
-                }\r
-            }\r
-\r
-            Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
-\r
-            //initialize StreamResult with File object to save to file\r
-            StreamResult result = new StreamResult(new StringWriter());\r
-            DOMSource source = new DOMSource(doc);\r
-            transformer.transform(source, result);\r
-            String xmlString = result.getWriter().toString();\r
-\r
-            FileWriter writer = new FileWriter(file);\r
-            writer.write(xmlString);\r
-            writer.close();\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (TransformerConfigurationException e) {\r
-            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (TransformerFactoryConfigurationError e) {\r
-            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (TransformerException e) {\r
-            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    private Element createInputElementElement(InputElement inputElement, Document doc) {\r
-        Element inputElementElement = doc.createElement(INPUT_ELEMENT_ELEMENT);\r
-        inputElementElement.setAttribute(NAME_ATTRIBUTE, inputElement.elementName);\r
-\r
-        if (inputElement.logEntry) {\r
-            inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.logEntry));\r
-        }\r
-\r
-        if (inputElement.parentElement != null) {\r
-            Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);\r
-            inputElementElement.appendChild(inputDataElement);\r
-            inputDataElement.setAttribute(NAME_ATTRIBUTE, inputElement.inputName);\r
-            inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputElement.inputAction));\r
-            if (inputElement.inputFormat != null) {\r
-                inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputElement.inputFormat);\r
-            }\r
-        }\r
-\r
-        if (inputElement.attributes != null) {\r
-            for (InputAttribute attribute : inputElement.attributes) {\r
-                Element inputAttributeElement = doc.createElement(ATTRIBUTE_ELEMENT);\r
-                inputElementElement.appendChild(inputAttributeElement);\r
-                inputAttributeElement.setAttribute(NAME_ATTRIBUTE, attribute.attributeName);\r
-                Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);\r
-                inputAttributeElement.appendChild(inputDataElement);\r
-                inputDataElement.setAttribute(NAME_ATTRIBUTE, attribute.inputName);\r
-                inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(attribute.inputAction));\r
-                if (attribute.inputFormat != null) {\r
-                    inputDataElement.setAttribute(FORMAT_ATTRIBUTE, attribute.inputFormat);\r
-                }\r
-            }\r
-        }\r
-\r
-        if (inputElement.childElements != null) {\r
-            for (InputElement childInputElement : inputElement.childElements) {\r
-                inputElementElement.appendChild(createInputElementElement(childInputElement, doc));\r
-            }\r
-        }\r
-\r
-        return inputElementElement;\r
-    }\r
-\r
-    public static CustomXmlTraceDefinition[] loadAll() {\r
-        return loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);\r
-    }\r
-\r
-    public static CustomXmlTraceDefinition[] loadAll(String path) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-                @Override\r
-                               public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-                @Override\r
-                               public void error(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            File file = new File(path);\r
-            if (!file.canRead()) {\r
-                return new CustomXmlTraceDefinition[0];\r
-            }\r
-            Document doc = db.parse(file);\r
-\r
-            Element root = doc.getDocumentElement();\r
-            if (! root.getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                return new CustomXmlTraceDefinition[0];\r
-            }\r
-\r
-            ArrayList<CustomXmlTraceDefinition> defList = new ArrayList<CustomXmlTraceDefinition>();\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element && node.getNodeName().equals(DEFINITION_ELEMENT)) {\r
-                    CustomXmlTraceDefinition def = extractDefinition((Element) node);\r
-                    if (def != null) {\r
-                        defList.add(def);\r
-                    }\r
-                }\r
-            }\r
-            return defList.toArray(new CustomXmlTraceDefinition[0]);\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$\r
-        }\r
-        return new CustomXmlTraceDefinition[0];\r
-    }\r
-\r
-    public static CustomXmlTraceDefinition load(String definitionName) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-                @Override\r
-                               public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-                @Override\r
-                               public void error(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            File file = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);\r
-            Document doc = db.parse(file);\r
-\r
-            Element root = doc.getDocumentElement();\r
-            if (! root.getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                return null;\r
-            }\r
-\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element &&\r
-                        node.getNodeName().equals(DEFINITION_ELEMENT) &&\r
-                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {\r
-                    return extractDefinition((Element) node);\r
-                }\r
-            }\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public static CustomXmlTraceDefinition extractDefinition(Element definitionElement) {\r
-        CustomXmlTraceDefinition def = new CustomXmlTraceDefinition();\r
-\r
-        def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE);\r
-        if (def.definitionName == null) {\r
-            return null;\r
-        }\r
-\r
-        NodeList nodeList = definitionElement.getChildNodes();\r
-        for (int i = 0; i < nodeList.getLength(); i++) {\r
-            Node node = nodeList.item(i);\r
-            String nodeName = node.getNodeName();\r
-            if (nodeName.equals(TIME_STAMP_OUTPUT_FORMAT_ELEMENT)) {\r
-                Element formatElement = (Element) node;\r
-                def.timeStampOutputFormat = formatElement.getTextContent();\r
-            } else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) {\r
-                InputElement inputElement = extractInputElement((Element) node);\r
-                if (inputElement != null) {\r
-                    if (def.rootInputElement == null) {\r
-                        def.rootInputElement = inputElement;\r
-                    } else {\r
-                        return null;\r
-                    }\r
-                }\r
-            } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) {\r
-                Element outputColumnElement = (Element) node;\r
-                OutputColumn outputColumn = new OutputColumn();\r
-                outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE);\r
-                def.outputs.add(outputColumn);\r
-            }\r
-        }\r
-        return def;\r
-    }\r
-\r
-    private static InputElement extractInputElement(Element inputElementElement) {\r
-        InputElement inputElement = new InputElement();\r
-        inputElement.elementName = inputElementElement.getAttribute(NAME_ATTRIBUTE);\r
-        inputElement.logEntry = (Boolean.toString(true).equals(inputElementElement.getAttribute(LOG_ENTRY_ATTRIBUTE))) ? true : false;\r
-        NodeList nodeList = inputElementElement.getChildNodes();\r
-        for (int i = 0; i < nodeList.getLength(); i++) {\r
-            Node node = nodeList.item(i);\r
-            String nodeName = node.getNodeName();\r
-            if (nodeName.equals(INPUT_DATA_ELEMENT)) {\r
-                Element inputDataElement = (Element) node;\r
-                inputElement.inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);\r
-                inputElement.inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));\r
-                inputElement.inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);\r
-            } else if (nodeName.equals(ATTRIBUTE_ELEMENT)) {\r
-                Element attributeElement = (Element) node;\r
-                InputAttribute attribute = new InputAttribute();\r
-                attribute.attributeName = attributeElement.getAttribute(NAME_ATTRIBUTE);\r
-                NodeList attributeNodeList = attributeElement.getChildNodes();\r
-                for (int j = 0; j < attributeNodeList.getLength(); j++) {\r
-                    Node attributeNode = attributeNodeList.item(j);\r
-                    String attributeNodeName = attributeNode.getNodeName();\r
-                    if (attributeNodeName.equals(INPUT_DATA_ELEMENT)) {\r
-                        Element inputDataElement = (Element) attributeNode;\r
-                        attribute.inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);\r
-                        attribute.inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));\r
-                        attribute.inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);\r
-                    }\r
-                }\r
-                inputElement.addAttribute(attribute);\r
-            } else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) {\r
-                Element childInputElementElement = (Element) node;\r
-                InputElement childInputElement = extractInputElement(childInputElementElement);\r
-                if (childInputElement != null) {\r
-                    inputElement.addChild(childInputElement);\r
-                }\r
-            }\r
-        }\r
-        return inputElement;\r
-    }\r
-\r
-    public static void delete(String definitionName) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver () {\r
-                @Override\r
-                               public InputSource resolveEntity (String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler(){\r
-                @Override\r
-                               public void error(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void warning(SAXParseException saxparseexception) throws SAXException {}\r
-                @Override\r
-                               public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    throw saxparseexception;\r
-                }});\r
-\r
-            File file = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);\r
-            Document doc = db.parse(file);\r
-\r
-            Element root = doc.getDocumentElement();\r
-            if (! root.getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {\r
-                return;\r
-            }\r
-\r
-            NodeList nodeList = root.getChildNodes();\r
-            for (int i = 0; i < nodeList.getLength(); i++) {\r
-                Node node = nodeList.item(i);\r
-                if (node instanceof Element &&\r
-                        node.getNodeName().equals(DEFINITION_ELEMENT) &&\r
-                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {\r
-                    root.removeChild(node);\r
-                }\r
-            }\r
-\r
-            Transformer transformer = TransformerFactory.newInstance().newTransformer();\r
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$\r
-\r
-            //initialize StreamResult with File object to save to file\r
-            StreamResult result = new StreamResult(new StringWriter());\r
-            DOMSource source = new DOMSource(doc);\r
-            transformer.transform(source, result);\r
-            String xmlString = result.getWriter().toString();\r
-\r
-            FileWriter writer = new FileWriter(file);\r
-            writer.write(xmlString);\r
-            writer.close();\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (TransformerConfigurationException e) {\r
-            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (TransformerFactoryConfigurationError e) {\r
-            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        } catch (TransformerException e) {\r
-            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class CustomXmlTraceDefinition extends CustomTraceDefinition {
+
+    protected static final String CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME = "custom_xml_parsers.xml"; //$NON-NLS-1$
+    protected static final String CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME =
+        Activator.getDefault().getStateLocation().addTrailingSeparator().append(CUSTOM_XML_TRACE_DEFINITIONS_FILE_NAME).toString();
+
+    public static final String TAG_IGNORE = Messages.CustomXmlTraceDefinition_ignoreTag;
+
+    private static final String CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomXmlTraceDefinition_definitionRootElement;
+    private static final String DEFINITION_ELEMENT = Messages.CustomXmlTraceDefinition_definition;
+    private static final String NAME_ATTRIBUTE = Messages.CustomXmlTraceDefinition_name;
+    private static final String LOG_ENTRY_ATTRIBUTE = Messages.CustomXmlTraceDefinition_logEntry;
+    private static final String TIME_STAMP_OUTPUT_FORMAT_ELEMENT = Messages.CustomXmlTraceDefinition_timestampOutputFormat;
+    private static final String INPUT_ELEMENT_ELEMENT = Messages.CustomXmlTraceDefinition_inputElement;
+    private static final String ATTRIBUTE_ELEMENT = Messages.CustomXmlTraceDefinition_attribute;
+    private static final String INPUT_DATA_ELEMENT = Messages.CustomXmlTraceDefinition_inputData;
+    private static final String ACTION_ATTRIBUTE = Messages.CustomXmlTraceDefinition_action;
+    private static final String FORMAT_ATTRIBUTE = Messages.CustomXmlTraceDefinition_format;
+    private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn;
+
+    public InputElement rootInputElement;
+
+    public CustomXmlTraceDefinition() {
+        this("", null, new ArrayList<OutputColumn>(), ""); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    public CustomXmlTraceDefinition(String logtype, InputElement rootElement, List<OutputColumn> outputs, String timeStampOutputFormat) {
+        this.definitionName = logtype;
+        this.rootInputElement = rootElement;
+        this.outputs = outputs;
+        this.timeStampOutputFormat = timeStampOutputFormat;
+    }
+
+    public static class InputElement {
+        public String elementName;
+        public boolean logEntry;
+        public String inputName;
+        public int inputAction;
+        public String inputFormat;
+        public List<InputAttribute> attributes;
+        public InputElement parentElement;
+        public InputElement nextElement;
+        public List<InputElement> childElements;
+
+        public InputElement() {}
+
+        public InputElement(String elementName, boolean logEntry, String inputName, int inputAction, String inputFormat, List<InputAttribute> attributes) {
+            this.elementName = elementName;
+            this.logEntry = logEntry;
+            this.inputName = inputName;
+            this.inputAction = inputAction;
+            this.inputFormat = inputFormat;
+            this.attributes = attributes;
+        }
+
+        public void addAttribute(InputAttribute attribute) {
+            if (attributes == null) {
+                attributes = new ArrayList<InputAttribute>(1);
+            }
+            attributes.add(attribute);
+        }
+
+        public void addChild(InputElement input) {
+            if (childElements == null) {
+                childElements = new ArrayList<InputElement>(1);
+            } else if (childElements.size() > 0) {
+                InputElement last = childElements.get(childElements.size() - 1);
+                last.nextElement = input;
+            }
+            childElements.add(input);
+            input.parentElement = this;
+        }
+
+        public void addNext(InputElement input) {
+            if (parentElement != null) {
+                int index = parentElement.childElements.indexOf(this);
+                parentElement.childElements.add(index + 1, input);
+                InputElement next = nextElement;
+                nextElement = input;
+                input.nextElement = next;
+            }
+            input.parentElement = this.parentElement;
+        }
+
+        public void moveUp() {
+            if (parentElement != null) {
+                int index = parentElement.childElements.indexOf(this);
+                if (index > 0) {
+                    parentElement.childElements.add(index - 1 , parentElement.childElements.remove(index));
+                    parentElement.childElements.get(index).nextElement = nextElement;
+                    nextElement = parentElement.childElements.get(index);
+                }
+            }
+        }
+
+        public void moveDown() {
+            if (parentElement != null) {
+                int index = parentElement.childElements.indexOf(this);
+                if (index < parentElement.childElements.size() - 1) {
+                    parentElement.childElements.add(index + 1 , parentElement.childElements.remove(index));
+                    nextElement = parentElement.childElements.get(index).nextElement;
+                    parentElement.childElements.get(index).nextElement = this;
+                }
+            }
+        }
+
+    }
+
+    public static class InputAttribute {
+        public String attributeName;
+        public String inputName;
+        public int inputAction;
+        public String inputFormat;
+
+        public InputAttribute() {}
+
+        public InputAttribute(String attributeName, String inputName, int inputAction, String inputFormat) {
+            this.attributeName = attributeName;
+            this.inputName = inputName;
+            this.inputAction = inputAction;
+            this.inputFormat = inputFormat;
+        }
+    }
+
+       @Override
+    public void save() {
+        save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
+    }
+
+       @Override
+    public void save(String path) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+                @Override
+                               public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+                @Override
+                               public void error(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void warning(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            Document doc = null;
+            File file = new File(path);
+            if (file.canRead()) {
+                doc = db.parse(file);
+                if (! doc.getDocumentElement().getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                    return;
+                }
+            } else {
+                doc = db.newDocument();
+                Node node = doc.createElement(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT);
+                doc.appendChild(node);
+            }
+
+            Element root = doc.getDocumentElement();
+
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element &&
+                        node.getNodeName().equals(DEFINITION_ELEMENT) &&
+                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {
+                    root.removeChild(node);
+                }
+            }
+            Element definitionElement = doc.createElement(DEFINITION_ELEMENT);
+            root.appendChild(definitionElement);
+            definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName);
+
+            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));
+            }
+
+            if (outputs != null) {
+                for (OutputColumn output : outputs) {
+                    Element outputColumnElement = doc.createElement(OUTPUT_COLUMN_ELEMENT);
+                    definitionElement.appendChild(outputColumnElement);
+                    outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name);
+                }
+            }
+
+            Transformer transformer = TransformerFactory.newInstance().newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+            //initialize StreamResult with File object to save to file
+            StreamResult result = new StreamResult(new StringWriter());
+            DOMSource source = new DOMSource(doc);
+            transformer.transform(source, result);
+            String xmlString = result.getWriter().toString();
+
+            FileWriter writer = new FileWriter(file);
+            writer.write(xmlString);
+            writer.close();
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (TransformerConfigurationException e) {
+            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (TransformerFactoryConfigurationError e) {
+            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (TransformerException e) {
+            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error saving CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        }
+    }
+
+    private Element createInputElementElement(InputElement inputElement, Document doc) {
+        Element inputElementElement = doc.createElement(INPUT_ELEMENT_ELEMENT);
+        inputElementElement.setAttribute(NAME_ATTRIBUTE, inputElement.elementName);
+
+        if (inputElement.logEntry) {
+            inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.logEntry));
+        }
+
+        if (inputElement.parentElement != null) {
+            Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
+            inputElementElement.appendChild(inputDataElement);
+            inputDataElement.setAttribute(NAME_ATTRIBUTE, inputElement.inputName);
+            inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputElement.inputAction));
+            if (inputElement.inputFormat != null) {
+                inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputElement.inputFormat);
+            }
+        }
+
+        if (inputElement.attributes != null) {
+            for (InputAttribute attribute : inputElement.attributes) {
+                Element inputAttributeElement = doc.createElement(ATTRIBUTE_ELEMENT);
+                inputElementElement.appendChild(inputAttributeElement);
+                inputAttributeElement.setAttribute(NAME_ATTRIBUTE, attribute.attributeName);
+                Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
+                inputAttributeElement.appendChild(inputDataElement);
+                inputDataElement.setAttribute(NAME_ATTRIBUTE, attribute.inputName);
+                inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(attribute.inputAction));
+                if (attribute.inputFormat != null) {
+                    inputDataElement.setAttribute(FORMAT_ATTRIBUTE, attribute.inputFormat);
+                }
+            }
+        }
+
+        if (inputElement.childElements != null) {
+            for (InputElement childInputElement : inputElement.childElements) {
+                inputElementElement.appendChild(createInputElementElement(childInputElement, doc));
+            }
+        }
+
+        return inputElementElement;
+    }
+
+    public static CustomXmlTraceDefinition[] loadAll() {
+        return loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
+    }
+
+    public static CustomXmlTraceDefinition[] loadAll(String path) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+                @Override
+                               public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+                @Override
+                               public void error(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void warning(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            File file = new File(path);
+            if (!file.canRead()) {
+                return new CustomXmlTraceDefinition[0];
+            }
+            Document doc = db.parse(file);
+
+            Element root = doc.getDocumentElement();
+            if (! root.getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                return new CustomXmlTraceDefinition[0];
+            }
+
+            ArrayList<CustomXmlTraceDefinition> defList = new ArrayList<CustomXmlTraceDefinition>();
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element && node.getNodeName().equals(DEFINITION_ELEMENT)) {
+                    CustomXmlTraceDefinition def = extractDefinition((Element) node);
+                    if (def != null) {
+                        defList.add(def);
+                    }
+                }
+            }
+            return defList.toArray(new CustomXmlTraceDefinition[0]);
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error loading all in CustomXmlTraceDefinition: path=" + path, e); //$NON-NLS-1$
+        }
+        return new CustomXmlTraceDefinition[0];
+    }
+
+    public static CustomXmlTraceDefinition load(String definitionName) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+                @Override
+                               public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+                @Override
+                               public void error(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void warning(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            File file = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
+            Document doc = db.parse(file);
+
+            Element root = doc.getDocumentElement();
+            if (! root.getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                return null;
+            }
+
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element &&
+                        node.getNodeName().equals(DEFINITION_ELEMENT) &&
+                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {
+                    return extractDefinition((Element) node);
+                }
+            }
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error loading CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        }
+        return null;
+    }
+
+    public static CustomXmlTraceDefinition extractDefinition(Element definitionElement) {
+        CustomXmlTraceDefinition def = new CustomXmlTraceDefinition();
+
+        def.definitionName = definitionElement.getAttribute(NAME_ATTRIBUTE);
+        if (def.definitionName == null) {
+            return null;
+        }
+
+        NodeList nodeList = definitionElement.getChildNodes();
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            Node node = nodeList.item(i);
+            String nodeName = node.getNodeName();
+            if (nodeName.equals(TIME_STAMP_OUTPUT_FORMAT_ELEMENT)) {
+                Element formatElement = (Element) node;
+                def.timeStampOutputFormat = formatElement.getTextContent();
+            } else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) {
+                InputElement inputElement = extractInputElement((Element) node);
+                if (inputElement != null) {
+                    if (def.rootInputElement == null) {
+                        def.rootInputElement = inputElement;
+                    } else {
+                        return null;
+                    }
+                }
+            } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) {
+                Element outputColumnElement = (Element) node;
+                OutputColumn outputColumn = new OutputColumn();
+                outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE);
+                def.outputs.add(outputColumn);
+            }
+        }
+        return def;
+    }
+
+    private static InputElement extractInputElement(Element inputElementElement) {
+        InputElement inputElement = new InputElement();
+        inputElement.elementName = inputElementElement.getAttribute(NAME_ATTRIBUTE);
+        inputElement.logEntry = (Boolean.toString(true).equals(inputElementElement.getAttribute(LOG_ENTRY_ATTRIBUTE))) ? true : false;
+        NodeList nodeList = inputElementElement.getChildNodes();
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            Node node = nodeList.item(i);
+            String nodeName = node.getNodeName();
+            if (nodeName.equals(INPUT_DATA_ELEMENT)) {
+                Element inputDataElement = (Element) node;
+                inputElement.inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);
+                inputElement.inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));
+                inputElement.inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);
+            } else if (nodeName.equals(ATTRIBUTE_ELEMENT)) {
+                Element attributeElement = (Element) node;
+                InputAttribute attribute = new InputAttribute();
+                attribute.attributeName = attributeElement.getAttribute(NAME_ATTRIBUTE);
+                NodeList attributeNodeList = attributeElement.getChildNodes();
+                for (int j = 0; j < attributeNodeList.getLength(); j++) {
+                    Node attributeNode = attributeNodeList.item(j);
+                    String attributeNodeName = attributeNode.getNodeName();
+                    if (attributeNodeName.equals(INPUT_DATA_ELEMENT)) {
+                        Element inputDataElement = (Element) attributeNode;
+                        attribute.inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);
+                        attribute.inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));
+                        attribute.inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);
+                    }
+                }
+                inputElement.addAttribute(attribute);
+            } else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) {
+                Element childInputElementElement = (Element) node;
+                InputElement childInputElement = extractInputElement(childInputElementElement);
+                if (childInputElement != null) {
+                    inputElement.addChild(childInputElement);
+                }
+            }
+        }
+        return inputElement;
+    }
+
+    public static void delete(String definitionName) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver () {
+                @Override
+                               public InputSource resolveEntity (String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler(){
+                @Override
+                               public void error(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void warning(SAXParseException saxparseexception) throws SAXException {}
+                @Override
+                               public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    throw saxparseexception;
+                }});
+
+            File file = new File(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
+            Document doc = db.parse(file);
+
+            Element root = doc.getDocumentElement();
+            if (! root.getNodeName().equals(CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT)) {
+                return;
+            }
+
+            NodeList nodeList = root.getChildNodes();
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                if (node instanceof Element &&
+                        node.getNodeName().equals(DEFINITION_ELEMENT) &&
+                        definitionName.equals(((Element) node).getAttribute(NAME_ATTRIBUTE))) {
+                    root.removeChild(node);
+                }
+            }
+
+            Transformer transformer = TransformerFactory.newInstance().newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+            //initialize StreamResult with File object to save to file
+            StreamResult result = new StreamResult(new StringWriter());
+            DOMSource source = new DOMSource(doc);
+            transformer.transform(source, result);
+            String xmlString = result.getWriter().toString();
+
+            FileWriter writer = new FileWriter(file);
+            writer.write(xmlString);
+            writer.close();
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (TransformerConfigurationException e) {
+            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (TransformerFactoryConfigurationError e) {
+            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        } catch (TransformerException e) {
+            Activator.getDefault().logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
+        }
+    }
+}
index e84e37d4caa8df0dba30ef7609c9668a7dab89c3..541746556b1431d99a071dfe8e848e4b7c0412d4 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.IOException;\r
-import java.io.InputStreamReader;\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Scanner;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-import java.util.regex.PatternSyntaxException;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.jface.viewers.ColumnLabelProvider;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.jface.viewers.TreeViewer;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.Cardinality;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.browser.Browser;\r
-import org.eclipse.swt.browser.TitleEvent;\r
-import org.eclipse.swt.browser.TitleListener;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.custom.StyleRange;\r
-import org.eclipse.swt.custom.StyledText;\r
-import org.eclipse.swt.events.ModifyEvent;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.events.VerifyEvent;\r
-import org.eclipse.swt.events.VerifyListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Combo;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Group;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Text;\r
-\r
-public class CustomTxtParserInputWizardPage extends WizardPage {\r
-\r
-    private static final String DEFAULT_REGEX = "\\s*(.*\\S)"; //$NON-NLS-1$\r
-    private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$\r
-    private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$\r
-    private static final String PATTERN_URL = "http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html#sum"; //$NON-NLS-1$\r
-    private static final Image lineImage = Activator.getDefault().getImageFromPath("/icons/elcl16/line_icon.gif"); //$NON-NLS-1$\r
-    private static final Image addImage = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$\r
-    private static final Image addNextImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$\r
-    private static final Image addChildImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$\r
-    private static final Image deleteImage = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$\r
-    private static final Image moveUpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$\r
-    private static final Image moveDownImage = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$\r
-    private static final Image helpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$\r
-    private static final Color COLOR_BLACK = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);\r
-    private static final Color COLOR_LIGHT_GREEN = new Color(Display.getDefault(), 192, 255, 192);\r
-    private static final Color COLOR_GREEN = Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);\r
-    private static final Color COLOR_LIGHT_YELLOW = new Color(Display.getDefault(), 255, 255, 192);\r
-    private static final Color COLOR_YELLOW = Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW);\r
-    private static final Color COLOR_LIGHT_MAGENTA = new Color(Display.getDefault(), 255, 192, 255);\r
-    private static final Color COLOR_MAGENTA = Display.getCurrent().getSystemColor(SWT.COLOR_MAGENTA);\r
-    private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);\r
-    private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);\r
-    private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);\r
-\r
-    private final ISelection selection;\r
-    private CustomTxtTraceDefinition definition;\r
-    private String editDefinitionName;\r
-    private String defaultDescription;\r
-    private Line selectedLine;\r
-    private Composite container;\r
-    private Text logtypeText;\r
-    private Text timestampOutputFormatText;\r
-    private Text timestampPreviewText;\r
-    private ScrolledComposite treeScrolledComposite;\r
-    private ScrolledComposite lineScrolledComposite;\r
-    private TreeViewer treeViewer;\r
-    private Composite treeContainer;\r
-    private Composite lineContainer;\r
-    private StyledText inputText;\r
-    private Font fixedFont;\r
-    private UpdateListener updateListener;\r
-    private Browser helpBrowser;\r
-\r
-    // variables used recursively through line traversal\r
-    private String timeStampFormat;\r
-    private boolean timestampFound;\r
-\r
-    protected CustomTxtParserInputWizardPage(ISelection selection, CustomTxtTraceDefinition definition) {\r
-        super("CustomParserWizardPage"); //$NON-NLS-1$\r
-        if (definition == null) {\r
-            setTitle(Messages.CustomTxtParserInputWizardPage_windowTitleNew);\r
-            defaultDescription = Messages.CustomTxtParserInputWizardPage_descriptionNew;\r
-        } else {\r
-            setTitle(Messages.CustomTxtParserInputWizardPage_windowTitleEdit);\r
-            defaultDescription = Messages.CustomTxtParserInputWizardPage_desccriptionEdit;\r
-        }\r
-        setDescription(defaultDescription);\r
-        this.selection = selection;\r
-        this.definition = definition;\r
-        if (definition != null) {\r
-            this.editDefinitionName = definition.definitionName;\r
-        }\r
-    }\r
-\r
-       @Override\r
-    public void createControl(Composite parent) {\r
-        container = new Composite(parent, SWT.NULL);\r
-        container.setLayout(new GridLayout());\r
-\r
-        updateListener = new UpdateListener();\r
-\r
-        Composite headerComposite = new Composite(container, SWT.FILL);\r
-        GridLayout headerLayout = new GridLayout(5, false);\r
-        headerLayout.marginHeight = 0;\r
-        headerLayout.marginWidth = 0;\r
-        headerComposite.setLayout(headerLayout);\r
-        headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-        Label logtypeLabel = new Label(headerComposite, SWT.NULL);\r
-        logtypeLabel.setText(Messages.CustomTxtParserInputWizardPage_logType);\r
-\r
-        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
-        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));\r
-\r
-        Label timestampFormatLabel = new Label(headerComposite, SWT.NULL);\r
-        timestampFormatLabel.setText(Messages.CustomTxtParserInputWizardPage_timestampFormat);\r
-\r
-        timestampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
-        timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-        timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);\r
-\r
-        Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);\r
-        dateFormatHelpButton.setImage(helpImage);\r
-        dateFormatHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_dateFormatHelp);\r
-        dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                openHelpShell(SIMPLE_DATE_FORMAT_URL);\r
-            }\r
-        });\r
-\r
-        Label timestampPreviewLabel = new Label(headerComposite, SWT.NULL);\r
-        timestampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));\r
-        timestampPreviewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);\r
-\r
-        timestampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-        timestampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));\r
-        timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp);\r
-\r
-        Composite buttonBar = new Composite(container, SWT.NONE);\r
-        GridLayout buttonBarLayout = new GridLayout(5, false);\r
-        buttonBarLayout.marginHeight = 0;\r
-        buttonBarLayout.marginWidth = 0;\r
-        buttonBar.setLayout(buttonBarLayout);\r
-\r
-        Button removeButton = new Button(buttonBar, SWT.PUSH);\r
-        removeButton.setImage(deleteImage);\r
-        removeButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeLine);\r
-        removeButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty() || selectedLine == null) {\r
-                    return;\r
-                }\r
-                removeLine();\r
-                InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputLine.parentInput == null) {\r
-                    definition.inputs.remove(inputLine);\r
-                } else {\r
-                    inputLine.parentInput.childrenInputs.remove(inputLine);\r
-                }\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-        Button addNextButton = new Button(buttonBar, SWT.PUSH);\r
-        addNextButton.setImage(addNextImage);\r
-        addNextButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addNextLine);\r
-        addNextButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); //$NON-NLS-1$\r
-                if (((List<?>) treeViewer.getInput()).size() == 0) {\r
-                    definition.inputs.add(inputLine);\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    InputLine previousInputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    if (previousInputLine.parentInput == null) {\r
-                        for (int i = 0; i < definition.inputs.size(); i++) {\r
-                            if (definition.inputs.get(i).equals(previousInputLine)) {\r
-                                definition.inputs.add(i + 1, inputLine);\r
-                            }\r
-                        }\r
-                    } else {\r
-                        previousInputLine.addNext(inputLine);\r
-                    }\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputLine), true);\r
-            }\r
-        });\r
-        Button addChildButton = new Button(buttonBar, SWT.PUSH);\r
-        addChildButton.setImage(addChildImage);\r
-        addChildButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addChildLine);\r
-        addChildButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-               public void widgetSelected(SelectionEvent e) {\r
-                InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); //$NON-NLS-1$\r
-                if (((List<?>) treeViewer.getInput()).size() == 0) {\r
-                    definition.inputs.add(inputLine);\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    InputLine parentInputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    parentInputLine.addChild(inputLine);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputLine), true);\r
-            }\r
-        });\r
-        Button moveUpButton = new Button(buttonBar, SWT.PUSH);\r
-        moveUpButton.setImage(moveUpImage);\r
-        moveUpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_moveUp);\r
-        moveUpButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                }\r
-                InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputLine.parentInput == null) {\r
-                    for (int i = 1; i < definition.inputs.size(); i++) {\r
-                        if (definition.inputs.get(i).equals(inputLine)) {\r
-                            definition.inputs.add(i - 1 , definition.inputs.remove(i));\r
-                            break;\r
-                        }\r
-                    }\r
-                } else {\r
-                    inputLine.moveUp();\r
-                }\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-        Button moveDownButton = new Button(buttonBar, SWT.PUSH);\r
-        moveDownButton.setImage(moveDownImage);\r
-        moveDownButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_moveDown);\r
-        moveDownButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                }\r
-                InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputLine.parentInput == null) {\r
-                    for (int i = 0; i < definition.inputs.size() - 1; i++) {\r
-                        if (definition.inputs.get(i).equals(inputLine)) {\r
-                            definition.inputs.add(i + 1 , definition.inputs.remove(i));\r
-                            break;\r
-                        }\r
-                    }\r
-                } else {\r
-                    inputLine.moveDown();\r
-                }\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-\r
-        SashForm vSash = new SashForm(container, SWT.VERTICAL);\r
-        vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
-\r
-        SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);\r
-        hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-\r
-        treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-        gd.heightHint = 200;\r
-        gd.widthHint = 200;\r
-        treeScrolledComposite.setLayoutData(gd);\r
-        treeContainer = new Composite(treeScrolledComposite, SWT.NONE);\r
-        treeContainer.setLayout(new FillLayout());\r
-        treeScrolledComposite.setContent(treeContainer);\r
-        treeScrolledComposite.setExpandHorizontal(true);\r
-        treeScrolledComposite.setExpandVertical(true);\r
-\r
-        treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);\r
-        treeViewer.setContentProvider(new InputLineTreeNodeContentProvider());\r
-        treeViewer.setLabelProvider(new InputLineTreeLabelProvider());\r
-        treeViewer.addSelectionChangedListener(new InputLineTreeSelectionChangedListener());\r
-        treeContainer.layout();\r
-\r
-        treeScrolledComposite.setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);\r
-\r
-        lineScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);\r
-        lineScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        lineContainer = new Composite(lineScrolledComposite, SWT.NONE);\r
-        GridLayout linesLayout = new GridLayout();\r
-        linesLayout.marginHeight = 1;\r
-        linesLayout.marginWidth = 0;\r
-        lineContainer.setLayout(linesLayout);\r
-        lineScrolledComposite.setContent(lineContainer);\r
-        lineScrolledComposite.setExpandHorizontal(true);\r
-        lineScrolledComposite.setExpandVertical(true);\r
-\r
-        if (definition == null) {\r
-            definition = new CustomTxtTraceDefinition();\r
-            definition.inputs.add(new InputLine(Cardinality.ZERO_OR_MORE, DEFAULT_REGEX,\r
-                    Arrays.asList(new InputData(CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.ACTION_SET))));\r
-        }\r
-        loadDefinition(definition);\r
-        treeViewer.expandAll();\r
-        lineContainer.layout();\r
-\r
-        logtypeText.addModifyListener(updateListener);\r
-        timestampOutputFormatText.addModifyListener(updateListener);\r
-\r
-        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);\r
-\r
-        hSash.setWeights(new int[] {1, 2});\r
-\r
-        Composite sashBottom = new Composite(vSash, SWT.NONE);\r
-        GridLayout sashBottomLayout = new GridLayout(3, false);\r
-        sashBottomLayout.marginHeight = 0;\r
-        sashBottomLayout.marginWidth = 0;\r
-        sashBottom.setLayout(sashBottomLayout);\r
-\r
-        Label previewLabel = new Label(sashBottom, SWT.NULL);\r
-        previewLabel.setText(Messages.CustomTxtParserInputWizardPage_previewInput);\r
-        previewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-        Button highlightAllButton = new Button(sashBottom, SWT.PUSH);\r
-        highlightAllButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-        highlightAllButton.setText(Messages.CustomTxtParserInputWizardPage_highlightAll);\r
-        highlightAllButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                updatePreviews(true);\r
-            }\r
-        });\r
-\r
-        Button legendButton = new Button(sashBottom, SWT.PUSH);\r
-        legendButton.setImage(helpImage);\r
-        legendButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_previewLegend);\r
-        legendButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-        legendButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                openLegend();\r
-            }\r
-        });\r
-\r
-        inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);\r
-        if (fixedFont == null) {\r
-            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$  //$NON-NLS-2$\r
-                fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            } else {\r
-                fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            }\r
-        }\r
-        inputText.setFont(fixedFont);\r
-        gd = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);\r
-        gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;\r
-        gd.widthHint = 800;\r
-        inputText.setLayoutData(gd);\r
-        inputText.setText(getSelectionText());\r
-        inputText.addModifyListener(updateListener);\r
-\r
-        vSash.setWeights(new int[] {hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});\r
-\r
-        setControl(container);\r
-\r
-        validate();\r
-        updatePreviews();\r
-    }\r
-\r
-    private static class InputLineTreeNodeContentProvider implements ITreeContentProvider {\r
-\r
-       @Override\r
-        public Object[] getElements(Object inputElement) {\r
-            return ((List<?>) inputElement).toArray();\r
-        }\r
-\r
-       @Override\r
-        public Object[] getChildren(Object parentElement) {\r
-            InputLine inputLine = (InputLine) parentElement;\r
-            if (inputLine.childrenInputs == null) {\r
-                return new InputLine[0];\r
-            }\r
-            return inputLine.childrenInputs.toArray();\r
-        }\r
-\r
-       @Override\r
-        public boolean hasChildren(Object element) {\r
-            InputLine inputLine = (InputLine) element;\r
-            return (inputLine.childrenInputs != null && inputLine.childrenInputs.size() > 0);\r
-        }\r
-\r
-       @Override\r
-        public void dispose() {\r
-        }\r
-\r
-       @Override\r
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-        }\r
-\r
-       @Override\r
-        public Object getParent(Object element) {\r
-            InputLine inputLine = (InputLine) element;\r
-            return inputLine.parentInput;\r
-        }\r
-    }\r
-\r
-    private class InputLineTreeLabelProvider extends ColumnLabelProvider {\r
-\r
-        @Override\r
-        public Image getImage(Object element) {\r
-            return lineImage;\r
-        }\r
-\r
-        @Override\r
-        public String getText(Object element) {\r
-            InputLine inputLine = (InputLine) element;\r
-            if (inputLine.parentInput == null) {\r
-                return "Root Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-            }\r
-            return "Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-        }\r
-    }\r
-\r
-    private class InputLineTreeSelectionChangedListener implements ISelectionChangedListener {\r
-       @Override\r
-        public void selectionChanged(SelectionChangedEvent event) {\r
-            if (selectedLine != null) {\r
-                selectedLine.dispose();\r
-            }\r
-            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {\r
-                IStructuredSelection selection = (IStructuredSelection) event.getSelection();\r
-                InputLine inputLine = (InputLine) selection.getFirstElement();\r
-                selectedLine = new Line(lineContainer, getName(inputLine), inputLine);\r
-                lineContainer.layout();\r
-                lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);\r
-                container.layout();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        }\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.DialogPage#dispose()\r
-     */\r
-    @Override\r
-    public void dispose() {\r
-        if (fixedFont != null) {\r
-            fixedFont.dispose();\r
-            fixedFont = null;\r
-        }\r
-        super.dispose();\r
-    }\r
-\r
-    private void loadDefinition(CustomTxtTraceDefinition def) {\r
-        logtypeText.setText(def.definitionName);\r
-        timestampOutputFormatText.setText(def.timeStampOutputFormat);\r
-        treeViewer.setInput(def.inputs);\r
-        if (def.inputs.size() > 0) {\r
-            InputLine inputLine = def.inputs.get(0);\r
-            treeViewer.setSelection(new StructuredSelection(inputLine));\r
-        }\r
-    }\r
-\r
-    private String getName(InputLine inputLine) {\r
-        if (inputLine.parentInput == null) {\r
-            return Integer.toString(definition.inputs.indexOf(inputLine)+1);\r
-        }\r
-        return getName(inputLine.parentInput) + "." + Integer.toString(inputLine.parentInput.childrenInputs.indexOf(inputLine)+1); //$NON-NLS-1$\r
-    }\r
-\r
-    public List<String> getInputNames() {\r
-        List<String> inputs = new ArrayList<String>();\r
-        for (InputLine inputLine : definition.inputs) {\r
-            for (String inputName : getInputNames(inputLine)) {\r
-                if (!inputs.contains(inputName)) {\r
-                    inputs.add(inputName);\r
-                }\r
-            }\r
-        }\r
-        return inputs;\r
-    }\r
-\r
-    public List<String> getInputNames(InputLine inputLine) {\r
-        List<String> inputs = new ArrayList<String>();\r
-        if (inputLine.columns != null) {\r
-            for (InputData inputData : inputLine.columns) {\r
-                String inputName = inputData.name;\r
-                if (!inputs.contains(inputName)) {\r
-                    inputs.add(inputName);\r
-                }\r
-            }\r
-        }\r
-        if (inputLine.childrenInputs != null) {\r
-            for (InputLine childInputLine : inputLine.childrenInputs) {\r
-                for (String inputName : getInputNames(childInputLine)) {\r
-                    if (!inputs.contains(inputName)) {\r
-                        inputs.add(inputName);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return inputs;\r
-    }\r
-\r
-    private void removeLine() {\r
-        selectedLine.dispose();\r
-        selectedLine = null;\r
-        lineContainer.layout();\r
-        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);\r
-        container.layout();\r
-    }\r
-\r
-    private String getSelectionText() {\r
-        if (this.selection instanceof IStructuredSelection) {\r
-            Object selection = ((IStructuredSelection)this.selection).getFirstElement();\r
-            if (selection instanceof IFile) {\r
-                IFile file = (IFile)selection;\r
-                BufferedReader reader = null;\r
-                try {\r
-                    reader = new BufferedReader(new InputStreamReader(file.getContents()));\r
-                    StringBuilder sb = new StringBuilder();\r
-                    String line = null;\r
-                    while ((line = reader.readLine()) != null) {\r
-                        sb.append(line + "\n"); //$NON-NLS-1$\r
-                    }\r
-                    return sb.toString();\r
-                } catch (CoreException e) {\r
-                    return ""; //$NON-NLS-1$\r
-                } catch (IOException e) {\r
-                    return ""; //$NON-NLS-1$\r
-                } finally {\r
-                    if (reader != null) {\r
-                        try {\r
-                            reader.close();\r
-                        } catch (IOException e) {\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private void updatePreviews() {\r
-        updatePreviews(false);\r
-    }\r
-\r
-    private void updatePreviews(boolean updateAll) {\r
-        if (inputText == null) {\r
-            // early update during construction\r
-            return;\r
-        }\r
-        inputText.setStyleRanges(new StyleRange[] {});\r
-\r
-        Scanner scanner = new Scanner(inputText.getText());\r
-        scanner.useDelimiter("\n"); //$NON-NLS-1$\r
-        int rawPos = 0;\r
-        String skip; // skip starting delimiters\r
-        if ((skip = scanner.findWithinHorizon("\\A\n+", 0)) != null) { //$NON-NLS-1$\r
-            rawPos += skip.length();\r
-        }\r
-\r
-        timeStampFormat = null;\r
-        if (selectedLine != null) {\r
-            for (InputGroup input : selectedLine.inputs) {\r
-                input.previewText.setText(Messages.CustomTxtParserInputWizardPage_noMathcingLine);\r
-            }\r
-        }\r
-\r
-        Map<String, String> data = new HashMap<String, String>();\r
-        int rootLineMatches = 0;\r
-        String firstEntryTimeStamp = null;\r
-        String firstEntryTimeStampInputFormat = null;\r
-        String log = null;\r
-    event:\r
-        while (scanner.hasNext()) {\r
-            if (rootLineMatches > 0 && !updateAll) {\r
-                break;\r
-            }\r
-            if (log == null) {\r
-                log = scanner.next();\r
-            }\r
-            int length = log.length();\r
-            for (InputLine rootInputLine : definition.inputs) {\r
-                Pattern pattern;\r
-                try {\r
-                    pattern = rootInputLine.getPattern();\r
-                } catch (PatternSyntaxException e) {\r
-                    continue;\r
-                }\r
-                Matcher matcher = pattern.matcher(log);\r
-                if (matcher.find()) {\r
-                    rootLineMatches++;\r
-                    inputText.setStyleRange(new StyleRange(rawPos, length,\r
-                            COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));\r
-                    data = new HashMap<String, String>();\r
-                    timeStampFormat = null;\r
-                    updatePreviewLine(rootInputLine, matcher, data, rawPos, rootLineMatches);\r
-                    if (rootLineMatches == 1) {\r
-                        firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP);\r
-                        firstEntryTimeStampInputFormat = timeStampFormat;\r
-                    }\r
-                    HashMap<InputLine, Integer> countMap = new HashMap<InputLine, Integer>();\r
-                    InputLine currentInput = null;\r
-                    if (rootInputLine.childrenInputs != null && rootInputLine.childrenInputs.size() > 0) {\r
-                        currentInput = rootInputLine.childrenInputs.get(0);\r
-                        countMap.put(currentInput, 0);\r
-                    }\r
-                    rawPos += length + 1; // +1 for \n\r
-                    while (scanner.hasNext()) {\r
-                        log = scanner.next();\r
-                        length = log.length();\r
-                        boolean processed = false;\r
-                        if (currentInput == null) {\r
-                            for (InputLine input : definition.inputs) {\r
-                                matcher = input.getPattern().matcher(log);\r
-                                if (matcher.find()) {\r
-                                    continue event;\r
-                                }\r
-                            }\r
-                        } else {\r
-                            if (countMap.get(currentInput) >= currentInput.getMinCount()) {\r
-                                List<InputLine> nextInputs = currentInput.getNextInputs(countMap);\r
-                                if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {\r
-                                    for (InputLine input : definition.inputs) {\r
-                                        matcher = input.getPattern().matcher(log);\r
-                                        if (matcher.find()) {\r
-                                            continue event;\r
-                                        }\r
-                                    }\r
-                                }\r
-                                for (InputLine input : nextInputs) {\r
-                                    matcher = input.getPattern().matcher(log);\r
-                                    if (matcher.find()) {\r
-                                        inputText.setStyleRange(new StyleRange(rawPos, length,\r
-                                                COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));\r
-                                        currentInput = input;\r
-                                        updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);\r
-                                        if (countMap.get(currentInput) == null) {\r
-                                            countMap.put(currentInput, 1);\r
-                                        } else {\r
-                                            countMap.put(currentInput, countMap.get(currentInput) + 1);\r
-                                        }\r
-                                        Iterator<InputLine> iter = countMap.keySet().iterator();\r
-                                        while (iter.hasNext()) {\r
-                                            InputLine inputLine = iter.next();\r
-                                            if (inputLine.level > currentInput.level) {\r
-                                                iter.remove();\r
-                                            }\r
-                                        }\r
-                                        if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {\r
-                                            currentInput = currentInput.childrenInputs.get(0);\r
-                                            countMap.put(currentInput, 0);\r
-                                        } else {\r
-                                            if (countMap.get(currentInput) >= currentInput.getMaxCount()) {\r
-                                                if (currentInput.getNextInputs(countMap).size() > 0) {\r
-                                                    currentInput = currentInput.getNextInputs(countMap).get(0);\r
-                                                    if (countMap.get(currentInput) == null) {\r
-                                                        countMap.put(currentInput, 0);\r
-                                                    }\r
-                                                    iter = countMap.keySet().iterator();\r
-                                                    while (iter.hasNext()) {\r
-                                                        InputLine inputLine = iter.next();\r
-                                                        if (inputLine.level > currentInput.level) {\r
-                                                            iter.remove();\r
-                                                        }\r
-                                                    }\r
-                                                } else {\r
-                                                    currentInput = null;\r
-                                                }\r
-                                            }\r
-                                        }\r
-                                        processed = true;\r
-                                        break;\r
-                                    }\r
-                                }\r
-                            }\r
-                            if (! processed) {\r
-                                matcher = currentInput.getPattern().matcher(log);\r
-                                if (matcher.find()) {\r
-                                    inputText.setStyleRange(new StyleRange(rawPos, length,\r
-                                            COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));\r
-                                    updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);\r
-                                    countMap.put(currentInput, countMap.get(currentInput) + 1);\r
-                                    if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {\r
-                                        currentInput = currentInput.childrenInputs.get(0);\r
-                                        countMap.put(currentInput, 0);\r
-                                    } else {\r
-                                        if (countMap.get(currentInput) >= currentInput.getMaxCount()) {\r
-                                            if (currentInput.getNextInputs(countMap).size() > 0) {\r
-                                                currentInput = currentInput.getNextInputs(countMap).get(0);\r
-                                                if (countMap.get(currentInput) == null) {\r
-                                                    countMap.put(currentInput, 0);\r
-                                                }\r
-                                                Iterator<InputLine> iter = countMap.keySet().iterator();\r
-                                                while (iter.hasNext()) {\r
-                                                    InputLine inputLine = iter.next();\r
-                                                    if (inputLine.level > currentInput.level) {\r
-                                                        iter.remove();\r
-                                                    }\r
-                                                }\r
-                                            } else {\r
-                                                currentInput = null;\r
-                                            }\r
-                                        }\r
-                                    }\r
-                                }\r
-                            }\r
-                        }\r
-                        rawPos += length + 1; // +1 for \n\r
-                    }\r
-\r
-                    break;\r
-                }\r
-            }\r
-            rawPos += length + 1; // +1 for \n\r
-            log = null;\r
-        }\r
-        scanner.close();\r
-        if (rootLineMatches == 1) {\r
-            firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP);\r
-            firstEntryTimeStampInputFormat = timeStampFormat;\r
-        }\r
-        if (firstEntryTimeStamp == null) {\r
-            timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noTimestampGroup);\r
-            if (selectedLine != null) {\r
-                for (InputGroup group : selectedLine.inputs) {\r
-                    if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp);\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        } else {\r
-            try {\r
-                SimpleDateFormat dateFormat = new SimpleDateFormat(firstEntryTimeStampInputFormat);\r
-                Date date = dateFormat.parse(firstEntryTimeStamp);\r
-                dateFormat = new SimpleDateFormat(timestampOutputFormatText.getText().trim());\r
-                timestampPreviewText.setText(dateFormat.format(date));\r
-            } catch (ParseException e) {\r
-                timestampPreviewText.setText("*parse exception* [" + firstEntryTimeStamp + "] <> [" + firstEntryTimeStampInputFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-            } catch (IllegalArgumentException e) {\r
-                timestampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$\r
-            }\r
-\r
-        }\r
-    }\r
-\r
-    private void updatePreviewLine(InputLine line, Matcher matcher, Map<String, String> data, int rawPos, int rootLineMatches) {\r
-        for (int i = 0; i < line.columns.size(); i++) {\r
-            InputData input = line.columns.get(i);\r
-            if (i < matcher.groupCount() && matcher.group(i+1) != null) {\r
-                if (line.parentInput == null) {\r
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),\r
-                            COLOR_BLACK, COLOR_GREEN, SWT.BOLD));\r
-                } else {\r
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),\r
-                            COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));\r
-                }\r
-                String value = matcher.group(i+1).trim();\r
-                if (selectedLine != null && selectedLine.inputLine.equals(line) && rootLineMatches == 1) {\r
-                    if (selectedLine.inputs.get(i).previewText.getText().equals(Messages.CustomTxtParserInputWizardPage_noMatchingLine)) {\r
-                        selectedLine.inputs.get(i).previewText.setText(value);\r
-                    }\r
-                }\r
-                if (value.length() == 0) {\r
-                    continue;\r
-                }\r
-                if (input.action == CustomTraceDefinition.ACTION_SET) {\r
-                    data.put(input.name, value);\r
-                    if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        timeStampFormat = input.format;\r
-                    }\r
-                } else if (input.action == CustomTraceDefinition.ACTION_APPEND) {\r
-                    String s = data.get(input.name);\r
-                    if (s != null) {\r
-                        data.put(input.name, s + value);\r
-                    } else {\r
-                        data.put(input.name, value);\r
-                    }\r
-                    if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        if (timeStampFormat != null) {\r
-                            timeStampFormat += input.format;\r
-                        } else {\r
-                            timeStampFormat = input.format;\r
-                        }\r
-                    }\r
-                } else if (input.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-                    String s = data.get(input.name);\r
-                    if (s != null) {\r
-                        data.put(input.name, s + " | " + value); //$NON-NLS-1$\r
-                    } else {\r
-                        data.put(input.name, value);\r
-                    }\r
-                    if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        if (timeStampFormat != null) {\r
-                            timeStampFormat += " | " + input.format; //$NON-NLS-1$\r
-                        } else {\r
-                            timeStampFormat = input.format;\r
-                        }\r
-                    }\r
-                }\r
-            } else {\r
-                if (selectedLine != null && selectedLine.inputLine.equals(line) && rootLineMatches == 1) {\r
-                    if (selectedLine.inputs.get(i).previewText.getText().equals(Messages.CustomTxtParserInputWizardPage_noMatchingLine)) {\r
-                        selectedLine.inputs.get(i).previewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingGroup);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        // highlight the matching groups that have no corresponponding input\r
-        for (int i = line.columns.size(); i < matcher.groupCount(); i++) {\r
-            if (matcher.group(i+1) != null) {\r
-                if (line.parentInput == null) {\r
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),\r
-                            COLOR_BLACK, COLOR_MAGENTA));\r
-                } else {\r
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),\r
-                            COLOR_BLACK, COLOR_LIGHT_MAGENTA));\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private void openHelpShell(String url) {\r
-        if (helpBrowser != null && !helpBrowser.isDisposed()) {\r
-            helpBrowser.getShell().setActive();\r
-            if (!helpBrowser.getUrl().equals(url)) {\r
-                helpBrowser.setUrl(url);\r
-            }\r
-            return;\r
-        }\r
-        final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);\r
-        helpShell.setLayout(new FillLayout());\r
-        helpBrowser = new Browser(helpShell, SWT.NONE);\r
-        helpBrowser.addTitleListener(new TitleListener() {\r
-               @Override\r
-           public void changed(TitleEvent event) {\r
-               helpShell.setText(event.title);\r
-           }\r
-        });\r
-        helpBrowser.setBounds(0,0,600,400);\r
-        helpShell.pack();\r
-        helpShell.open();\r
-        helpBrowser.setUrl(url);\r
-    }\r
-\r
-    private void openLegend() {\r
-        final String CG = Messages.CustomTxtParserInputWizardPage_capturedGroup;\r
-        final String UCG = Messages.CustomTxtParserInputWizardPage_unidentifiedCaptureGroup;\r
-        final String UT = Messages.CustomTxtParserInputWizardPage_uncapturedText;\r
-        int line1start = 0;\r
-        String line1 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;\r
-        int line2start = line1start + line1.length();\r
-        String line2 = Messages.CustomTxtParserInputWizardPage_matchingLineRoot + CG + " " + UCG + " " + UT + " \n";  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-        int line3start = line2start + line2.length();\r
-        String line3 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-        int line4start = line3start + line3.length();\r
-        String line4 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-        int line5start = line4start + line4.length();\r
-        String line5 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;\r
-        int line6start = line5start + line5.length();\r
-        String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-\r
-        final Shell legendShell = new Shell(getShell(), SWT.DIALOG_TRIM);\r
-        legendShell.setLayout(new FillLayout());\r
-        StyledText legendText = new StyledText(legendShell, SWT.MULTI);\r
-        legendText.setFont(fixedFont);\r
-        legendText.setText(line1 + line2 + line3 + line4 + line5 + line6);\r
-        legendText.setStyleRange(new StyleRange(line2start, line2.length(), COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));\r
-        legendText.setStyleRange(new StyleRange(line3start, line3.length(), COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));\r
-        legendText.setStyleRange(new StyleRange(line4start, line4.length(), COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));\r
-        legendText.setStyleRange(new StyleRange(line6start, line6.length(), COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));\r
-        legendText.setStyleRange(new StyleRange(line2start + line2.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_GREEN, SWT.BOLD));\r
-        legendText.setStyleRange(new StyleRange(line2start + line2.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_MAGENTA));\r
-        legendText.setStyleRange(new StyleRange(line3start + line3.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));\r
-        legendText.setStyleRange(new StyleRange(line3start + line3.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_LIGHT_MAGENTA));\r
-        legendText.setStyleRange(new StyleRange(line4start + line4.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));\r
-        legendText.setStyleRange(new StyleRange(line4start + line4.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_LIGHT_MAGENTA));\r
-        legendText.setStyleRange(new StyleRange(line6start + line6.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_GREEN, SWT.BOLD));\r
-        legendText.setStyleRange(new StyleRange(line6start + line6.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_MAGENTA));\r
-        legendShell.setText(Messages.CustomTxtParserInputWizardPage_previewLegend);\r
-        legendShell.pack();\r
-        legendShell.open();\r
-    }\r
-\r
-    private class UpdateListener implements ModifyListener, SelectionListener {\r
-\r
-       @Override\r
-        public void modifyText(ModifyEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-       @Override\r
-        public void widgetDefaultSelected(SelectionEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-       @Override\r
-        public void widgetSelected(SelectionEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-    }\r
-\r
-    private class Line {\r
-        private static final String INFINITY_STRING = "\u221E"; //$NON-NLS-1$\r
-        InputLine inputLine;\r
-        Group group;\r
-        Composite labelComposite;\r
-        Text regexText;\r
-        Composite cardinalityContainer;\r
-        Combo cardinalityCombo;\r
-        Label cardinalityMinLabel;\r
-        Text cardinalityMinText;\r
-        Label cardinalityMaxLabel;\r
-        Text cardinalityMaxText;\r
-        Button infiniteButton;\r
-        List<InputGroup> inputs = new ArrayList<InputGroup>();\r
-        Button addGroupButton;\r
-        Label addGroupLabel;\r
-\r
-        public Line(Composite parent, String name, InputLine inputLine) {\r
-            this.inputLine = inputLine;\r
-\r
-            group = new Group(parent, SWT.NONE);\r
-            group.setText(name);\r
-            group.setLayout(new GridLayout(2, false));\r
-            group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            labelComposite = new Composite(group, SWT.FILL);\r
-            GridLayout labelLayout = new GridLayout(1, false);\r
-            labelLayout.marginWidth = 0;\r
-            labelLayout.marginHeight = 0;\r
-            labelComposite.setLayout(labelLayout);\r
-            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            Label label = new Label(labelComposite, SWT.NULL);\r
-            label.setText(Messages.CustomTxtParserInputWizardPage_regularExpression);\r
-\r
-            Composite regexContainer = new Composite(group, SWT.NONE);\r
-            GridLayout regexLayout = new GridLayout(2, false);\r
-            regexLayout.marginHeight = 0;\r
-            regexLayout.marginWidth = 0;\r
-            regexContainer.setLayout(regexLayout);\r
-            regexContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            regexText = new Text(regexContainer, SWT.BORDER | SWT.SINGLE);\r
-            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            regexText.setLayoutData(gd);\r
-            regexText.setText(inputLine.getRegex());\r
-            regexText.addModifyListener(updateListener);\r
-\r
-            Button regexHelpButton = new Button(regexContainer, SWT.PUSH);\r
-            regexHelpButton.setImage(helpImage);\r
-            regexHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_regularExpressionHelp);\r
-            regexHelpButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-               public void widgetSelected(SelectionEvent e) {\r
-                    openHelpShell(PATTERN_URL);\r
-                }\r
-            });\r
-\r
-            label = new Label(group, SWT.NONE);\r
-            label.setText(Messages.CustomTxtParserInputWizardPage_cardinality);\r
-            label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            cardinalityContainer = new Composite(group, SWT.NONE);\r
-            GridLayout cardinalityLayout = new GridLayout(6, false);\r
-            cardinalityLayout.marginHeight = 0;\r
-            cardinalityLayout.marginWidth = 0;\r
-            cardinalityContainer.setLayout(cardinalityLayout);\r
-            cardinalityContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            cardinalityCombo = new Combo(cardinalityContainer, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            cardinalityCombo.setItems(new String[] {\r
-                    Cardinality.ZERO_OR_MORE.toString(),\r
-                    Cardinality.ONE_OR_MORE.toString(),\r
-                    Cardinality.ZERO_OR_ONE.toString(),\r
-                    Cardinality.ONE.toString(),\r
-                    "(?,?)"}); //$NON-NLS-1$\r
-            cardinalityCombo.addSelectionListener(new SelectionListener(){\r
-               @Override\r
-                public void widgetDefaultSelected(SelectionEvent e) {}\r
-               @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    switch (cardinalityCombo.getSelectionIndex()) {\r
-                    case 4: //(?,?)\r
-                        cardinalityMinLabel.setVisible(true);\r
-                        cardinalityMinText.setVisible(true);\r
-                        cardinalityMaxLabel.setVisible(true);\r
-                        cardinalityMaxText.setVisible(true);\r
-                        infiniteButton.setVisible(true);\r
-                        break;\r
-                    default:\r
-                        cardinalityMinLabel.setVisible(false);\r
-                        cardinalityMinText.setVisible(false);\r
-                        cardinalityMaxLabel.setVisible(false);\r
-                        cardinalityMaxText.setVisible(false);\r
-                        infiniteButton.setVisible(false);\r
-                        break;\r
-                    }\r
-                    cardinalityContainer.layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }});\r
-\r
-            cardinalityMinLabel = new Label(cardinalityContainer, SWT.NONE);\r
-            cardinalityMinLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            cardinalityMinLabel.setText(Messages.CustomTxtParserInputWizardPage_min);\r
-            cardinalityMinLabel.setVisible(false);\r
-\r
-            cardinalityMinText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE);\r
-            gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);\r
-            gd.widthHint = 20;\r
-            cardinalityMinText.setLayoutData(gd);\r
-            cardinalityMinText.setVisible(false);\r
-\r
-            cardinalityMaxLabel = new Label(cardinalityContainer, SWT.NONE);\r
-            cardinalityMaxLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            cardinalityMaxLabel.setText(Messages.CustomTxtParserInputWizardPage_max);\r
-            cardinalityMaxLabel.setVisible(false);\r
-\r
-            cardinalityMaxText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE);\r
-            gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);\r
-            gd.widthHint = 20;\r
-            cardinalityMaxText.setLayoutData(gd);\r
-            cardinalityMaxText.setVisible(false);\r
-\r
-            infiniteButton = new Button(cardinalityContainer, SWT.PUSH);\r
-            infiniteButton.setText(INFINITY_STRING);\r
-            infiniteButton.setVisible(false);\r
-            infiniteButton.addSelectionListener(new SelectionAdapter(){\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    cardinalityMaxText.setText(INFINITY_STRING);\r
-                }});\r
-\r
-            if (inputLine.cardinality.equals(Cardinality.ZERO_OR_MORE)) {\r
-                cardinalityCombo.select(0);\r
-            } else if (inputLine.cardinality.equals(Cardinality.ONE_OR_MORE)) {\r
-                cardinalityCombo.select(1);\r
-            } else if (inputLine.cardinality.equals(Cardinality.ZERO_OR_ONE)) {\r
-                cardinalityCombo.select(2);\r
-            } else if (inputLine.cardinality.equals(Cardinality.ONE)) {\r
-                cardinalityCombo.select(3);\r
-            } else {\r
-                cardinalityCombo.select(4);\r
-                cardinalityMinLabel.setVisible(true);\r
-                cardinalityMinText.setVisible(true);\r
-                if (inputLine.getMinCount() >= 0) {\r
-                    cardinalityMinText.setText(Integer.toString(inputLine.getMinCount()));\r
-                }\r
-                cardinalityMaxLabel.setVisible(true);\r
-                cardinalityMaxText.setVisible(true);\r
-                if (inputLine.getMaxCount() == Cardinality.INF) {\r
-                    cardinalityMaxText.setText(INFINITY_STRING);\r
-                } else if (inputLine.getMaxCount() >= 0) {\r
-                    cardinalityMaxText.setText(Integer.toString(inputLine.getMaxCount()));\r
-                }\r
-                infiniteButton.setVisible(true);\r
-            }\r
-\r
-            VerifyListener digitsListener = new VerifyListener() {\r
-               @Override\r
-                public void verifyText(VerifyEvent e) {\r
-                    if (e.text.equals(INFINITY_STRING)) {\r
-                        e.doit = e.widget == cardinalityMaxText && e.start == 0 && e.end == ((Text) e.widget).getText().length();\r
-                    } else {\r
-                        if (((Text) e.widget).getText().equals(INFINITY_STRING)) {\r
-                            e.doit = e.start == 0 && e.end == ((Text) e.widget).getText().length();\r
-                        }\r
-                        for (int i = 0; i < e.text.length(); i++) {\r
-                            if (!Character.isDigit(e.text.charAt(i))) {\r
-                                e.doit = false;\r
-                                break;\r
-                            }\r
-                        }\r
-                    }\r
-                }};\r
-\r
-            cardinalityMinText.addModifyListener(updateListener);\r
-            cardinalityMaxText.addModifyListener(updateListener);\r
-            cardinalityMinText.addVerifyListener(digitsListener);\r
-            cardinalityMaxText.addVerifyListener(digitsListener);\r
-\r
-            if (inputLine.columns != null) {\r
-                for (InputData inputData : inputLine.columns) {\r
-                    InputGroup inputGroup = new InputGroup(group, this, inputs.size()+1);\r
-                    if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        inputGroup.tagCombo.select(0);\r
-                        inputGroup.tagText.setText(inputData.format);\r
-                        inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format);\r
-                        inputGroup.tagLabel.setVisible(true);\r
-                        inputGroup.tagText.setVisible(true);\r
-                        inputGroup.tagText.addModifyListener(updateListener);\r
-                    } else if (inputData.name.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
-                        inputGroup.tagCombo.select(1);\r
-                    } else {\r
-                        inputGroup.tagCombo.select(2);\r
-                        inputGroup.tagText.setText(inputData.name);\r
-                        inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_name);\r
-                        inputGroup.tagLabel.setVisible(true);\r
-                        inputGroup.tagText.setVisible(true);\r
-                        inputGroup.tagText.addModifyListener(updateListener);\r
-                    }\r
-                    inputGroup.actionCombo.select(inputData.action);\r
-                    inputs.add(inputGroup);\r
-                }\r
-            }\r
-\r
-            createAddGroupButton();\r
-        }\r
-\r
-        private void createAddGroupButton() {\r
-            addGroupButton = new Button(group, SWT.PUSH);\r
-            addGroupButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            addGroupButton.setImage(addImage);\r
-            addGroupButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addGroup);\r
-            addGroupButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    removeAddGroupButton();\r
-                    inputs.add(new InputGroup(group, Line.this, inputs.size()+1));\r
-                    createAddGroupButton();\r
-                    lineContainer.layout();\r
-                    lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);\r
-                    group.getParent().layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            addGroupLabel = new Label(group, SWT.NULL);\r
-            addGroupLabel.setText(Messages.CustomTxtParserInputWizardPage_newGroup);\r
-        }\r
-\r
-        private void removeAddGroupButton() {\r
-            addGroupButton.dispose();\r
-            addGroupLabel.dispose();\r
-        }\r
-\r
-        private void removeInput(int inputNumber) {\r
-            if (--inputNumber < inputs.size()) {\r
-                inputs.remove(inputNumber).dispose();\r
-                for (int i = inputNumber; i < inputs.size(); i++) {\r
-                    inputs.get(i).setInputNumber(i+1);\r
-                }\r
-                lineContainer.layout();\r
-                lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);\r
-                group.getParent().layout();\r
-            }\r
-        }\r
-\r
-//        private void setName(String name) {\r
-//            this.name = name;\r
-//            group.setText("Line " + name);\r
-//        }\r
-\r
-        private void dispose() {\r
-            group.dispose();\r
-        }\r
-\r
-        private void extractInputs() {\r
-            inputLine.setRegex(selectedLine.regexText.getText());\r
-            switch (cardinalityCombo.getSelectionIndex()) {\r
-            case 0:\r
-                inputLine.cardinality = Cardinality.ZERO_OR_MORE;\r
-                break;\r
-            case 1:\r
-                inputLine.cardinality = Cardinality.ONE_OR_MORE;\r
-                break;\r
-            case 2:\r
-                inputLine.cardinality = Cardinality.ZERO_OR_ONE;\r
-                break;\r
-            case 3:\r
-                inputLine.cardinality = Cardinality.ONE;\r
-                break;\r
-            case 4: //(?,?)\r
-                int min, max;\r
-                try {\r
-                    min = Integer.parseInt(cardinalityMinText.getText());\r
-                } catch (NumberFormatException e) {\r
-                    min = -1;\r
-                }\r
-                try {\r
-                    if (cardinalityMaxText.getText().equals(INFINITY_STRING)) {\r
-                        max = Cardinality.INF;\r
-                    } else {\r
-                        max = Integer.parseInt(cardinalityMaxText.getText());\r
-                    }\r
-                } catch (NumberFormatException e) {\r
-                    max = -1;\r
-                }\r
-                inputLine.cardinality = new Cardinality(min, max);\r
-                break;\r
-            default:\r
-                inputLine.cardinality = Cardinality.ZERO_OR_MORE;\r
-                break;\r
-            }\r
-            inputLine.columns = new ArrayList<InputData>(inputs.size());\r
-            for (int i = 0; i < inputs.size(); i++) {\r
-                InputGroup group = inputs.get(i);\r
-                InputData inputData = new InputData();\r
-                if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
-                    inputData.name = group.tagText.getText().trim();\r
-                } else {\r
-                    inputData.name = group.tagCombo.getText();\r
-                    if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        inputData.format = group.tagText.getText().trim();\r
-                    }\r
-                }\r
-                inputData.action = group.actionCombo.getSelectionIndex();\r
-                inputLine.columns.add(inputData);\r
-            }\r
-        }\r
-    }\r
-\r
-    private class InputGroup {\r
-        Line line;\r
-        int inputNumber;\r
-\r
-        // children of parent (must be disposed)\r
-        Composite labelComposite;\r
-        Composite tagComposite;\r
-        Label previewLabel;\r
-        Text previewText;\r
-\r
-        // children of labelComposite\r
-        Label inputLabel;\r
-\r
-        // children of tagComposite\r
-        Combo tagCombo;\r
-        Label tagLabel;\r
-        Text tagText;\r
-        Combo actionCombo;\r
-\r
-        public InputGroup(Composite parent, Line line, int inputNumber) {\r
-            this.line = line;\r
-            this.inputNumber = inputNumber;\r
-\r
-            labelComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout labelLayout = new GridLayout(2, false);\r
-            labelLayout.marginWidth = 0;\r
-            labelLayout.marginHeight = 0;\r
-            labelComposite.setLayout(labelLayout);\r
-            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            Button deleteButton = new Button(labelComposite, SWT.PUSH);\r
-            deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            deleteButton.setImage(deleteImage);\r
-            deleteButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeGroup);\r
-            deleteButton.addSelectionListener(new SelectionAdapter() {\r
-               @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    InputGroup.this.line.removeInput(InputGroup.this.inputNumber);\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            inputLabel = new Label(labelComposite, SWT.NULL);\r
-            inputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$\r
-\r
-            tagComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout tagLayout = new GridLayout(4, false);\r
-            tagLayout.marginWidth = 0;\r
-            tagLayout.marginHeight = 0;\r
-            tagComposite.setLayout(tagLayout);\r
-            tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            tagCombo.setItems(new String[] {CustomTraceDefinition.TAG_TIMESTAMP,\r
-                                            CustomTraceDefinition.TAG_MESSAGE,\r
-                                            CustomTraceDefinition.TAG_OTHER});\r
-            tagCombo.select(1);\r
-            tagCombo.addSelectionListener(new SelectionListener(){\r
-               @Override\r
-                public void widgetDefaultSelected(SelectionEvent e) {}\r
-               @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    tagText.removeModifyListener(updateListener);\r
-                    switch (tagCombo.getSelectionIndex()) {\r
-                    case 0: //Time Stamp\r
-                        tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format);\r
-                        tagLabel.setVisible(true);\r
-                        tagText.setVisible(true);\r
-                        tagText.addModifyListener(updateListener);\r
-                        break;\r
-                    case 1: //Message\r
-                        tagLabel.setVisible(false);\r
-                        tagText.setVisible(false);\r
-                        break;\r
-                    case 2: //Other\r
-                        tagLabel.setText(Messages.CustomTxtParserInputWizardPage_name);\r
-                        tagLabel.setVisible(true);\r
-                        tagText.setVisible(true);\r
-                        tagText.addModifyListener(updateListener);\r
-                        break;\r
-                    case 3: //Continue\r
-                        tagLabel.setVisible(false);\r
-                        tagText.setVisible(false);\r
-                        break;\r
-                    default:\r
-                        break;\r
-                    }\r
-                    tagComposite.layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }});\r
-\r
-            tagLabel = new Label(tagComposite, SWT.NULL);\r
-            tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            tagLabel.setVisible(false);\r
-\r
-            tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);\r
-            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            tagText.setLayoutData(gd);\r
-            tagText.setVisible(false);\r
-\r
-            actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            actionCombo.setItems(new String[] {Messages.CustomTxtParserInputWizardPage_set, Messages.CustomTxtParserInputWizardPage_append, Messages.CustomTxtParserInputWizardPage_appendWith});\r
-            actionCombo.select(0);\r
-            actionCombo.addSelectionListener(updateListener);\r
-\r
-            previewLabel = new Label(parent, SWT.NULL);\r
-            previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            previewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);\r
-\r
-            previewText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-            gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            previewText.setLayoutData(gd);\r
-            previewText.setText(Messages.CustomTxtParserInputWizardPage_noMatch);\r
-            previewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-        }\r
-\r
-        private void dispose() {\r
-            labelComposite.dispose();\r
-            tagComposite.dispose();\r
-            previewLabel.dispose();\r
-            previewText.dispose();\r
-        }\r
-\r
-        private void setInputNumber(int inputNumber) {\r
-            this.inputNumber = inputNumber;\r
-            inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$\r
-            labelComposite.layout();\r
-        }\r
-    }\r
-\r
-    private void validate() {\r
-\r
-        definition.definitionName = logtypeText.getText().trim();\r
-        definition.timeStampOutputFormat = timestampOutputFormatText.getText().trim();\r
-\r
-        if (selectedLine != null) {\r
-            selectedLine.extractInputs();\r
-            treeViewer.refresh();\r
-        }\r
-\r
-        StringBuffer errors = new StringBuffer();\r
-\r
-        if (definition.definitionName.length() == 0) {\r
-            errors.append("Enter a name for the new log type. "); //$NON-NLS-1$\r
-            logtypeText.setBackground(COLOR_LIGHT_RED);\r
-        } else {\r
-            logtypeText.setBackground(COLOR_TEXT_BACKGROUND);\r
-            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                if (definition.definitionName.equals(def.definitionName)) {\r
-                    if (editDefinitionName == null || ! editDefinitionName.equals(definition.definitionName)) {\r
-                        errors.append("The log type name already exists. "); //$NON-NLS-1$\r
-                        logtypeText.setBackground(COLOR_LIGHT_RED);\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        timestampFound = false;\r
-        for (int i = 0; i < definition.inputs.size(); i++) {\r
-\r
-            InputLine inputLine = definition.inputs.get(i);\r
-            String name = Integer.toString(i+1);\r
-            errors.append(validateLine(inputLine, name));\r
-        }\r
-        if (timestampFound) {\r
-            if (definition.timeStampOutputFormat.length() == 0) {\r
-                errors.append("Enter the output format for the Time Stamp field. "); //$NON-NLS-1$\r
-                timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
-            } else {\r
-                try {\r
-                    new SimpleDateFormat(definition.timeStampOutputFormat);\r
-                    timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                } catch (IllegalArgumentException e) {\r
-                    errors.append("Enter a valid output format for the Time Stamp field. "); //$NON-NLS-1$\r
-                    timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
-                }\r
-            }\r
-\r
-        } else {\r
-            timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);\r
-//            timestampPreviewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-//            errors.append("Identify a Time Stamp group (Line "+name+"). ");\r
-//            timestampPreviewText.setText("*no timestamp group*");\r
-//            timestampPreviewText.setBackground(COLOR_LIGHT_RED);\r
-        }\r
-\r
-        if (errors.length() == 0) {\r
-            setDescription(defaultDescription);\r
-            setPageComplete(true);\r
-        } else {\r
-            setDescription(errors.toString());\r
-            setPageComplete(false);\r
-        }\r
-    }\r
-\r
-    public StringBuffer validateLine(InputLine inputLine, String name) {\r
-        StringBuffer errors = new StringBuffer();\r
-        Line line = null;\r
-        if (selectedLine != null && selectedLine.inputLine.equals(inputLine)) {\r
-            line = selectedLine;\r
-        }\r
-        try {\r
-            Pattern.compile(inputLine.getRegex());\r
-            if (line != null) {\r
-                line.regexText.setBackground(COLOR_TEXT_BACKGROUND);\r
-            }\r
-        } catch (PatternSyntaxException e) {\r
-            errors.append("Enter a valid regular expression (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
-            if (line != null) {\r
-                line.regexText.setBackground(COLOR_LIGHT_RED);\r
-            }\r
-        }\r
-        if (inputLine.getMinCount() == -1) {\r
-            errors.append("Enter a minimum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
-            if (line != null) {\r
-                line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);\r
-            }\r
-        } else {\r
-            if (line != null) {\r
-                line.cardinalityMinText.setBackground(COLOR_TEXT_BACKGROUND);\r
-            }\r
-        }\r
-        if (inputLine.getMaxCount() == -1) {\r
-            errors.append("Enter a maximum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
-            if (line != null) {\r
-                line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);\r
-            }\r
-        } else if (inputLine.getMinCount() > inputLine.getMaxCount()) {\r
-            errors.append("Enter correct (min <= max) values for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$\r
-            if (line != null) {\r
-                line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);\r
-            }\r
-            if (line != null) {\r
-                line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);\r
-            }\r
-        } else {\r
-            if (line != null) {\r
-                line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND);\r
-            }\r
-        }\r
-        for (int i = 0; inputLine.columns != null && i < inputLine.columns.size(); i++) {\r
-            InputData inputData = inputLine.columns.get(i);\r
-            InputGroup group = null;\r
-            if (line != null) {\r
-                group = line.inputs.get(i);\r
-            }\r
-            if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                timestampFound = true;\r
-                if (inputData.format.length() == 0) {\r
-                    errors.append("Enter the input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (group != null) {\r
-                        group.tagText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    try {\r
-                        new SimpleDateFormat(inputData.format);\r
-                        if (group != null) {\r
-                            group.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                        }\r
-                    } catch (IllegalArgumentException e) {\r
-                        errors.append("Enter a valid input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (group != null) {\r
-                            group.tagText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-            } else if (inputData.name.length() == 0) {\r
-                errors.append("Enter a name for the data group (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                if (group != null) {\r
-                    group.tagText.setBackground(COLOR_LIGHT_RED);\r
-                }\r
-            } else {\r
-                if (group != null) {\r
-                    group.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-        }\r
-        for (int i = 0; inputLine.childrenInputs != null && i < inputLine.childrenInputs.size(); i++) {\r
-            errors.append(validateLine(inputLine.childrenInputs.get(i), name+"."+(i+1))); //$NON-NLS-1$\r
-        }\r
-        return errors;\r
-    }\r
-\r
-    public CustomTxtTraceDefinition getDefinition() {\r
-        return definition;\r
-    }\r
-\r
-    public char[] getInputText() {\r
-        return inputText.getText().toCharArray();\r
-    }\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.Cardinality;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.TitleEvent;
+import org.eclipse.swt.browser.TitleListener;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class CustomTxtParserInputWizardPage extends WizardPage {
+
+    private static final String DEFAULT_REGEX = "\\s*(.*\\S)"; //$NON-NLS-1$
+    private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
+    private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$
+    private static final String PATTERN_URL = "http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html#sum"; //$NON-NLS-1$
+    private static final Image lineImage = Activator.getDefault().getImageFromPath("/icons/elcl16/line_icon.gif"); //$NON-NLS-1$
+    private static final Image addImage = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
+    private static final Image addNextImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
+    private static final Image addChildImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
+    private static final Image deleteImage = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
+    private static final Image moveUpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
+    private static final Image moveDownImage = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
+    private static final Image helpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
+    private static final Color COLOR_BLACK = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
+    private static final Color COLOR_LIGHT_GREEN = new Color(Display.getDefault(), 192, 255, 192);
+    private static final Color COLOR_GREEN = Display.getCurrent().getSystemColor(SWT.COLOR_GREEN);
+    private static final Color COLOR_LIGHT_YELLOW = new Color(Display.getDefault(), 255, 255, 192);
+    private static final Color COLOR_YELLOW = Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW);
+    private static final Color COLOR_LIGHT_MAGENTA = new Color(Display.getDefault(), 255, 192, 255);
+    private static final Color COLOR_MAGENTA = Display.getCurrent().getSystemColor(SWT.COLOR_MAGENTA);
+    private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);
+    private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
+    private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+
+    private final ISelection selection;
+    private CustomTxtTraceDefinition definition;
+    private String editDefinitionName;
+    private String defaultDescription;
+    private Line selectedLine;
+    private Composite container;
+    private Text logtypeText;
+    private Text timestampOutputFormatText;
+    private Text timestampPreviewText;
+    private ScrolledComposite treeScrolledComposite;
+    private ScrolledComposite lineScrolledComposite;
+    private TreeViewer treeViewer;
+    private Composite treeContainer;
+    private Composite lineContainer;
+    private StyledText inputText;
+    private Font fixedFont;
+    private UpdateListener updateListener;
+    private Browser helpBrowser;
+
+    // variables used recursively through line traversal
+    private String timeStampFormat;
+    private boolean timestampFound;
+
+    protected CustomTxtParserInputWizardPage(ISelection selection, CustomTxtTraceDefinition definition) {
+        super("CustomParserWizardPage"); //$NON-NLS-1$
+        if (definition == null) {
+            setTitle(Messages.CustomTxtParserInputWizardPage_windowTitleNew);
+            defaultDescription = Messages.CustomTxtParserInputWizardPage_descriptionNew;
+        } else {
+            setTitle(Messages.CustomTxtParserInputWizardPage_windowTitleEdit);
+            defaultDescription = Messages.CustomTxtParserInputWizardPage_desccriptionEdit;
+        }
+        setDescription(defaultDescription);
+        this.selection = selection;
+        this.definition = definition;
+        if (definition != null) {
+            this.editDefinitionName = definition.definitionName;
+        }
+    }
+
+       @Override
+    public void createControl(Composite parent) {
+        container = new Composite(parent, SWT.NULL);
+        container.setLayout(new GridLayout());
+
+        updateListener = new UpdateListener();
+
+        Composite headerComposite = new Composite(container, SWT.FILL);
+        GridLayout headerLayout = new GridLayout(5, false);
+        headerLayout.marginHeight = 0;
+        headerLayout.marginWidth = 0;
+        headerComposite.setLayout(headerLayout);
+        headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+        Label logtypeLabel = new Label(headerComposite, SWT.NULL);
+        logtypeLabel.setText(Messages.CustomTxtParserInputWizardPage_logType);
+
+        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));
+
+        Label timestampFormatLabel = new Label(headerComposite, SWT.NULL);
+        timestampFormatLabel.setText(Messages.CustomTxtParserInputWizardPage_timestampFormat);
+
+        timestampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
+
+        Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);
+        dateFormatHelpButton.setImage(helpImage);
+        dateFormatHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_dateFormatHelp);
+        dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                openHelpShell(SIMPLE_DATE_FORMAT_URL);
+            }
+        });
+
+        Label timestampPreviewLabel = new Label(headerComposite, SWT.NULL);
+        timestampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
+        timestampPreviewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);
+
+        timestampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+        timestampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+        timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp);
+
+        Composite buttonBar = new Composite(container, SWT.NONE);
+        GridLayout buttonBarLayout = new GridLayout(5, false);
+        buttonBarLayout.marginHeight = 0;
+        buttonBarLayout.marginWidth = 0;
+        buttonBar.setLayout(buttonBarLayout);
+
+        Button removeButton = new Button(buttonBar, SWT.PUSH);
+        removeButton.setImage(deleteImage);
+        removeButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeLine);
+        removeButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty() || selectedLine == null) {
+                    return;
+                }
+                removeLine();
+                InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputLine.parentInput == null) {
+                    definition.inputs.remove(inputLine);
+                } else {
+                    inputLine.parentInput.childrenInputs.remove(inputLine);
+                }
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+        Button addNextButton = new Button(buttonBar, SWT.PUSH);
+        addNextButton.setImage(addNextImage);
+        addNextButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addNextLine);
+        addNextButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); //$NON-NLS-1$
+                if (((List<?>) treeViewer.getInput()).size() == 0) {
+                    definition.inputs.add(inputLine);
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    InputLine previousInputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    if (previousInputLine.parentInput == null) {
+                        for (int i = 0; i < definition.inputs.size(); i++) {
+                            if (definition.inputs.get(i).equals(previousInputLine)) {
+                                definition.inputs.add(i + 1, inputLine);
+                            }
+                        }
+                    } else {
+                        previousInputLine.addNext(inputLine);
+                    }
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputLine), true);
+            }
+        });
+        Button addChildButton = new Button(buttonBar, SWT.PUSH);
+        addChildButton.setImage(addChildImage);
+        addChildButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addChildLine);
+        addChildButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); //$NON-NLS-1$
+                if (((List<?>) treeViewer.getInput()).size() == 0) {
+                    definition.inputs.add(inputLine);
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    InputLine parentInputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    parentInputLine.addChild(inputLine);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputLine), true);
+            }
+        });
+        Button moveUpButton = new Button(buttonBar, SWT.PUSH);
+        moveUpButton.setImage(moveUpImage);
+        moveUpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_moveUp);
+        moveUpButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                }
+                InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputLine.parentInput == null) {
+                    for (int i = 1; i < definition.inputs.size(); i++) {
+                        if (definition.inputs.get(i).equals(inputLine)) {
+                            definition.inputs.add(i - 1 , definition.inputs.remove(i));
+                            break;
+                        }
+                    }
+                } else {
+                    inputLine.moveUp();
+                }
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+        Button moveDownButton = new Button(buttonBar, SWT.PUSH);
+        moveDownButton.setImage(moveDownImage);
+        moveDownButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_moveDown);
+        moveDownButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                }
+                InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputLine.parentInput == null) {
+                    for (int i = 0; i < definition.inputs.size() - 1; i++) {
+                        if (definition.inputs.get(i).equals(inputLine)) {
+                            definition.inputs.add(i + 1 , definition.inputs.remove(i));
+                            break;
+                        }
+                    }
+                } else {
+                    inputLine.moveDown();
+                }
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+
+        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));
+
+        SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);
+        hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        gd.heightHint = 200;
+        gd.widthHint = 200;
+        treeScrolledComposite.setLayoutData(gd);
+        treeContainer = new Composite(treeScrolledComposite, SWT.NONE);
+        treeContainer.setLayout(new FillLayout());
+        treeScrolledComposite.setContent(treeContainer);
+        treeScrolledComposite.setExpandHorizontal(true);
+        treeScrolledComposite.setExpandVertical(true);
+
+        treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);
+        treeViewer.setContentProvider(new InputLineTreeNodeContentProvider());
+        treeViewer.setLabelProvider(new InputLineTreeLabelProvider());
+        treeViewer.addSelectionChangedListener(new InputLineTreeSelectionChangedListener());
+        treeContainer.layout();
+
+        treeScrolledComposite.setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+
+        lineScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);
+        lineScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        lineContainer = new Composite(lineScrolledComposite, SWT.NONE);
+        GridLayout linesLayout = new GridLayout();
+        linesLayout.marginHeight = 1;
+        linesLayout.marginWidth = 0;
+        lineContainer.setLayout(linesLayout);
+        lineScrolledComposite.setContent(lineContainer);
+        lineScrolledComposite.setExpandHorizontal(true);
+        lineScrolledComposite.setExpandVertical(true);
+
+        if (definition == null) {
+            definition = new CustomTxtTraceDefinition();
+            definition.inputs.add(new InputLine(Cardinality.ZERO_OR_MORE, DEFAULT_REGEX,
+                    Arrays.asList(new InputData(CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.ACTION_SET))));
+        }
+        loadDefinition(definition);
+        treeViewer.expandAll();
+        lineContainer.layout();
+
+        logtypeText.addModifyListener(updateListener);
+        timestampOutputFormatText.addModifyListener(updateListener);
+
+        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+
+        hSash.setWeights(new int[] {1, 2});
+
+        Composite sashBottom = new Composite(vSash, SWT.NONE);
+        GridLayout sashBottomLayout = new GridLayout(3, false);
+        sashBottomLayout.marginHeight = 0;
+        sashBottomLayout.marginWidth = 0;
+        sashBottom.setLayout(sashBottomLayout);
+
+        Label previewLabel = new Label(sashBottom, SWT.NULL);
+        previewLabel.setText(Messages.CustomTxtParserInputWizardPage_previewInput);
+        previewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+        Button highlightAllButton = new Button(sashBottom, SWT.PUSH);
+        highlightAllButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+        highlightAllButton.setText(Messages.CustomTxtParserInputWizardPage_highlightAll);
+        highlightAllButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+            public void widgetSelected(SelectionEvent e) {
+                updatePreviews(true);
+            }
+        });
+
+        Button legendButton = new Button(sashBottom, SWT.PUSH);
+        legendButton.setImage(helpImage);
+        legendButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_previewLegend);
+        legendButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+        legendButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+            public void widgetSelected(SelectionEvent e) {
+                openLegend();
+            }
+        });
+
+        inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
+        if (fixedFont == null) {
+            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$  //$NON-NLS-2$
+                fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$
+            } else {
+                fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$
+            }
+        }
+        inputText.setFont(fixedFont);
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
+        gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;
+        gd.widthHint = 800;
+        inputText.setLayoutData(gd);
+        inputText.setText(getSelectionText());
+        inputText.addModifyListener(updateListener);
+
+        vSash.setWeights(new int[] {hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});
+
+        setControl(container);
+
+        validate();
+        updatePreviews();
+    }
+
+    private static class InputLineTreeNodeContentProvider implements ITreeContentProvider {
+
+       @Override
+        public Object[] getElements(Object inputElement) {
+            return ((List<?>) inputElement).toArray();
+        }
+
+       @Override
+        public Object[] getChildren(Object parentElement) {
+            InputLine inputLine = (InputLine) parentElement;
+            if (inputLine.childrenInputs == null) {
+                return new InputLine[0];
+            }
+            return inputLine.childrenInputs.toArray();
+        }
+
+       @Override
+        public boolean hasChildren(Object element) {
+            InputLine inputLine = (InputLine) element;
+            return (inputLine.childrenInputs != null && inputLine.childrenInputs.size() > 0);
+        }
+
+       @Override
+        public void dispose() {
+        }
+
+       @Override
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        }
+
+       @Override
+        public Object getParent(Object element) {
+            InputLine inputLine = (InputLine) element;
+            return inputLine.parentInput;
+        }
+    }
+
+    private class InputLineTreeLabelProvider extends ColumnLabelProvider {
+
+        @Override
+        public Image getImage(Object element) {
+            return lineImage;
+        }
+
+        @Override
+        public String getText(Object element) {
+            InputLine inputLine = (InputLine) element;
+            if (inputLine.parentInput == null) {
+                return "Root Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            }
+            return "Line " + getName(inputLine) + " " + inputLine.cardinality.toString() + " : " + inputLine.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        }
+    }
+
+    private class InputLineTreeSelectionChangedListener implements ISelectionChangedListener {
+       @Override
+        public void selectionChanged(SelectionChangedEvent event) {
+            if (selectedLine != null) {
+                selectedLine.dispose();
+            }
+            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
+                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+                InputLine inputLine = (InputLine) selection.getFirstElement();
+                selectedLine = new Line(lineContainer, getName(inputLine), inputLine);
+                lineContainer.layout();
+                lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+                container.layout();
+                validate();
+                updatePreviews();
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+     */
+    @Override
+    public void dispose() {
+        if (fixedFont != null) {
+            fixedFont.dispose();
+            fixedFont = null;
+        }
+        super.dispose();
+    }
+
+    private void loadDefinition(CustomTxtTraceDefinition def) {
+        logtypeText.setText(def.definitionName);
+        timestampOutputFormatText.setText(def.timeStampOutputFormat);
+        treeViewer.setInput(def.inputs);
+        if (def.inputs.size() > 0) {
+            InputLine inputLine = def.inputs.get(0);
+            treeViewer.setSelection(new StructuredSelection(inputLine));
+        }
+    }
+
+    private String getName(InputLine inputLine) {
+        if (inputLine.parentInput == null) {
+            return Integer.toString(definition.inputs.indexOf(inputLine)+1);
+        }
+        return getName(inputLine.parentInput) + "." + Integer.toString(inputLine.parentInput.childrenInputs.indexOf(inputLine)+1); //$NON-NLS-1$
+    }
+
+    public List<String> getInputNames() {
+        List<String> inputs = new ArrayList<String>();
+        for (InputLine inputLine : definition.inputs) {
+            for (String inputName : getInputNames(inputLine)) {
+                if (!inputs.contains(inputName)) {
+                    inputs.add(inputName);
+                }
+            }
+        }
+        return inputs;
+    }
+
+    public List<String> getInputNames(InputLine inputLine) {
+        List<String> inputs = new ArrayList<String>();
+        if (inputLine.columns != null) {
+            for (InputData inputData : inputLine.columns) {
+                String inputName = inputData.name;
+                if (!inputs.contains(inputName)) {
+                    inputs.add(inputName);
+                }
+            }
+        }
+        if (inputLine.childrenInputs != null) {
+            for (InputLine childInputLine : inputLine.childrenInputs) {
+                for (String inputName : getInputNames(childInputLine)) {
+                    if (!inputs.contains(inputName)) {
+                        inputs.add(inputName);
+                    }
+                }
+            }
+        }
+        return inputs;
+    }
+
+    private void removeLine() {
+        selectedLine.dispose();
+        selectedLine = null;
+        lineContainer.layout();
+        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+        container.layout();
+    }
+
+    private String getSelectionText() {
+        if (this.selection instanceof IStructuredSelection) {
+            Object selection = ((IStructuredSelection)this.selection).getFirstElement();
+            if (selection instanceof IFile) {
+                IFile file = (IFile)selection;
+                BufferedReader reader = null;
+                try {
+                    reader = new BufferedReader(new InputStreamReader(file.getContents()));
+                    StringBuilder sb = new StringBuilder();
+                    String line = null;
+                    while ((line = reader.readLine()) != null) {
+                        sb.append(line + "\n"); //$NON-NLS-1$
+                    }
+                    return sb.toString();
+                } catch (CoreException e) {
+                    return ""; //$NON-NLS-1$
+                } catch (IOException e) {
+                    return ""; //$NON-NLS-1$
+                } finally {
+                    if (reader != null) {
+                        try {
+                            reader.close();
+                        } catch (IOException e) {
+                        }
+                    }
+                }
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private void updatePreviews() {
+        updatePreviews(false);
+    }
+
+    private void updatePreviews(boolean updateAll) {
+        if (inputText == null) {
+            // early update during construction
+            return;
+        }
+        inputText.setStyleRanges(new StyleRange[] {});
+
+        Scanner scanner = new Scanner(inputText.getText());
+        scanner.useDelimiter("\n"); //$NON-NLS-1$
+        int rawPos = 0;
+        String skip; // skip starting delimiters
+        if ((skip = scanner.findWithinHorizon("\\A\n+", 0)) != null) { //$NON-NLS-1$
+            rawPos += skip.length();
+        }
+
+        timeStampFormat = null;
+        if (selectedLine != null) {
+            for (InputGroup input : selectedLine.inputs) {
+                input.previewText.setText(Messages.CustomTxtParserInputWizardPage_noMathcingLine);
+            }
+        }
+
+        Map<String, String> data = new HashMap<String, String>();
+        int rootLineMatches = 0;
+        String firstEntryTimeStamp = null;
+        String firstEntryTimeStampInputFormat = null;
+        String log = null;
+    event:
+        while (scanner.hasNext()) {
+            if (rootLineMatches > 0 && !updateAll) {
+                break;
+            }
+            if (log == null) {
+                log = scanner.next();
+            }
+            int length = log.length();
+            for (InputLine rootInputLine : definition.inputs) {
+                Pattern pattern;
+                try {
+                    pattern = rootInputLine.getPattern();
+                } catch (PatternSyntaxException e) {
+                    continue;
+                }
+                Matcher matcher = pattern.matcher(log);
+                if (matcher.find()) {
+                    rootLineMatches++;
+                    inputText.setStyleRange(new StyleRange(rawPos, length,
+                            COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
+                    data = new HashMap<String, String>();
+                    timeStampFormat = null;
+                    updatePreviewLine(rootInputLine, matcher, data, rawPos, rootLineMatches);
+                    if (rootLineMatches == 1) {
+                        firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP);
+                        firstEntryTimeStampInputFormat = timeStampFormat;
+                    }
+                    HashMap<InputLine, Integer> countMap = new HashMap<InputLine, Integer>();
+                    InputLine currentInput = null;
+                    if (rootInputLine.childrenInputs != null && rootInputLine.childrenInputs.size() > 0) {
+                        currentInput = rootInputLine.childrenInputs.get(0);
+                        countMap.put(currentInput, 0);
+                    }
+                    rawPos += length + 1; // +1 for \n
+                    while (scanner.hasNext()) {
+                        log = scanner.next();
+                        length = log.length();
+                        boolean processed = false;
+                        if (currentInput == null) {
+                            for (InputLine input : definition.inputs) {
+                                matcher = input.getPattern().matcher(log);
+                                if (matcher.find()) {
+                                    continue event;
+                                }
+                            }
+                        } else {
+                            if (countMap.get(currentInput) >= currentInput.getMinCount()) {
+                                List<InputLine> nextInputs = currentInput.getNextInputs(countMap);
+                                if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
+                                    for (InputLine input : definition.inputs) {
+                                        matcher = input.getPattern().matcher(log);
+                                        if (matcher.find()) {
+                                            continue event;
+                                        }
+                                    }
+                                }
+                                for (InputLine input : nextInputs) {
+                                    matcher = input.getPattern().matcher(log);
+                                    if (matcher.find()) {
+                                        inputText.setStyleRange(new StyleRange(rawPos, length,
+                                                COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
+                                        currentInput = input;
+                                        updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);
+                                        if (countMap.get(currentInput) == null) {
+                                            countMap.put(currentInput, 1);
+                                        } else {
+                                            countMap.put(currentInput, countMap.get(currentInput) + 1);
+                                        }
+                                        Iterator<InputLine> iter = countMap.keySet().iterator();
+                                        while (iter.hasNext()) {
+                                            InputLine inputLine = iter.next();
+                                            if (inputLine.level > currentInput.level) {
+                                                iter.remove();
+                                            }
+                                        }
+                                        if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
+                                            currentInput = currentInput.childrenInputs.get(0);
+                                            countMap.put(currentInput, 0);
+                                        } else {
+                                            if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+                                                if (currentInput.getNextInputs(countMap).size() > 0) {
+                                                    currentInput = currentInput.getNextInputs(countMap).get(0);
+                                                    if (countMap.get(currentInput) == null) {
+                                                        countMap.put(currentInput, 0);
+                                                    }
+                                                    iter = countMap.keySet().iterator();
+                                                    while (iter.hasNext()) {
+                                                        InputLine inputLine = iter.next();
+                                                        if (inputLine.level > currentInput.level) {
+                                                            iter.remove();
+                                                        }
+                                                    }
+                                                } else {
+                                                    currentInput = null;
+                                                }
+                                            }
+                                        }
+                                        processed = true;
+                                        break;
+                                    }
+                                }
+                            }
+                            if (! processed) {
+                                matcher = currentInput.getPattern().matcher(log);
+                                if (matcher.find()) {
+                                    inputText.setStyleRange(new StyleRange(rawPos, length,
+                                            COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
+                                    updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);
+                                    countMap.put(currentInput, countMap.get(currentInput) + 1);
+                                    if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
+                                        currentInput = currentInput.childrenInputs.get(0);
+                                        countMap.put(currentInput, 0);
+                                    } else {
+                                        if (countMap.get(currentInput) >= currentInput.getMaxCount()) {
+                                            if (currentInput.getNextInputs(countMap).size() > 0) {
+                                                currentInput = currentInput.getNextInputs(countMap).get(0);
+                                                if (countMap.get(currentInput) == null) {
+                                                    countMap.put(currentInput, 0);
+                                                }
+                                                Iterator<InputLine> iter = countMap.keySet().iterator();
+                                                while (iter.hasNext()) {
+                                                    InputLine inputLine = iter.next();
+                                                    if (inputLine.level > currentInput.level) {
+                                                        iter.remove();
+                                                    }
+                                                }
+                                            } else {
+                                                currentInput = null;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        rawPos += length + 1; // +1 for \n
+                    }
+
+                    break;
+                }
+            }
+            rawPos += length + 1; // +1 for \n
+            log = null;
+        }
+        scanner.close();
+        if (rootLineMatches == 1) {
+            firstEntryTimeStamp = data.get(CustomTraceDefinition.TAG_TIMESTAMP);
+            firstEntryTimeStampInputFormat = timeStampFormat;
+        }
+        if (firstEntryTimeStamp == null) {
+            timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noTimestampGroup);
+            if (selectedLine != null) {
+                for (InputGroup group : selectedLine.inputs) {
+                    if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        timestampPreviewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingTimestamp);
+                        break;
+                    }
+                }
+            }
+        } else {
+            try {
+                SimpleDateFormat dateFormat = new SimpleDateFormat(firstEntryTimeStampInputFormat);
+                Date date = dateFormat.parse(firstEntryTimeStamp);
+                dateFormat = new SimpleDateFormat(timestampOutputFormatText.getText().trim());
+                timestampPreviewText.setText(dateFormat.format(date));
+            } catch (ParseException e) {
+                timestampPreviewText.setText("*parse exception* [" + firstEntryTimeStamp + "] <> [" + firstEntryTimeStampInputFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            } catch (IllegalArgumentException e) {
+                timestampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$
+            }
+
+        }
+    }
+
+    private void updatePreviewLine(InputLine line, Matcher matcher, Map<String, String> data, int rawPos, int rootLineMatches) {
+        for (int i = 0; i < line.columns.size(); i++) {
+            InputData input = line.columns.get(i);
+            if (i < matcher.groupCount() && matcher.group(i+1) != null) {
+                if (line.parentInput == null) {
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                            COLOR_BLACK, COLOR_GREEN, SWT.BOLD));
+                } else {
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                            COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));
+                }
+                String value = matcher.group(i+1).trim();
+                if (selectedLine != null && selectedLine.inputLine.equals(line) && rootLineMatches == 1) {
+                    if (selectedLine.inputs.get(i).previewText.getText().equals(Messages.CustomTxtParserInputWizardPage_noMatchingLine)) {
+                        selectedLine.inputs.get(i).previewText.setText(value);
+                    }
+                }
+                if (value.length() == 0) {
+                    continue;
+                }
+                if (input.action == CustomTraceDefinition.ACTION_SET) {
+                    data.put(input.name, value);
+                    if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        timeStampFormat = input.format;
+                    }
+                } else if (input.action == CustomTraceDefinition.ACTION_APPEND) {
+                    String s = data.get(input.name);
+                    if (s != null) {
+                        data.put(input.name, s + value);
+                    } else {
+                        data.put(input.name, value);
+                    }
+                    if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        if (timeStampFormat != null) {
+                            timeStampFormat += input.format;
+                        } else {
+                            timeStampFormat = input.format;
+                        }
+                    }
+                } else if (input.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+                    String s = data.get(input.name);
+                    if (s != null) {
+                        data.put(input.name, s + " | " + value); //$NON-NLS-1$
+                    } else {
+                        data.put(input.name, value);
+                    }
+                    if (input.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        if (timeStampFormat != null) {
+                            timeStampFormat += " | " + input.format; //$NON-NLS-1$
+                        } else {
+                            timeStampFormat = input.format;
+                        }
+                    }
+                }
+            } else {
+                if (selectedLine != null && selectedLine.inputLine.equals(line) && rootLineMatches == 1) {
+                    if (selectedLine.inputs.get(i).previewText.getText().equals(Messages.CustomTxtParserInputWizardPage_noMatchingLine)) {
+                        selectedLine.inputs.get(i).previewText.setText(Messages.CustomTxtParserInputWizardPage_noMatchingGroup);
+                    }
+                }
+            }
+        }
+        // highlight the matching groups that have no corresponponding input
+        for (int i = line.columns.size(); i < matcher.groupCount(); i++) {
+            if (matcher.group(i+1) != null) {
+                if (line.parentInput == null) {
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                            COLOR_BLACK, COLOR_MAGENTA));
+                } else {
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                            COLOR_BLACK, COLOR_LIGHT_MAGENTA));
+                }
+            }
+        }
+    }
+
+    private void openHelpShell(String url) {
+        if (helpBrowser != null && !helpBrowser.isDisposed()) {
+            helpBrowser.getShell().setActive();
+            if (!helpBrowser.getUrl().equals(url)) {
+                helpBrowser.setUrl(url);
+            }
+            return;
+        }
+        final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);
+        helpShell.setLayout(new FillLayout());
+        helpBrowser = new Browser(helpShell, SWT.NONE);
+        helpBrowser.addTitleListener(new TitleListener() {
+               @Override
+           public void changed(TitleEvent event) {
+               helpShell.setText(event.title);
+           }
+        });
+        helpBrowser.setBounds(0,0,600,400);
+        helpShell.pack();
+        helpShell.open();
+        helpBrowser.setUrl(url);
+    }
+
+    private void openLegend() {
+        final String CG = Messages.CustomTxtParserInputWizardPage_capturedGroup;
+        final String UCG = Messages.CustomTxtParserInputWizardPage_unidentifiedCaptureGroup;
+        final String UT = Messages.CustomTxtParserInputWizardPage_uncapturedText;
+        int line1start = 0;
+        String line1 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;
+        int line2start = line1start + line1.length();
+        String line2 = Messages.CustomTxtParserInputWizardPage_matchingLineRoot + CG + " " + UCG + " " + UT + " \n";  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        int line3start = line2start + line2.length();
+        String line3 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        int line4start = line3start + line3.length();
+        String line4 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        int line5start = line4start + line4.length();
+        String line5 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;
+        int line6start = line5start + line5.length();
+        String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + CG + " " + UCG + " " + UT + " \n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+        final Shell legendShell = new Shell(getShell(), SWT.DIALOG_TRIM);
+        legendShell.setLayout(new FillLayout());
+        StyledText legendText = new StyledText(legendShell, SWT.MULTI);
+        legendText.setFont(fixedFont);
+        legendText.setText(line1 + line2 + line3 + line4 + line5 + line6);
+        legendText.setStyleRange(new StyleRange(line2start, line2.length(), COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
+        legendText.setStyleRange(new StyleRange(line3start, line3.length(), COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
+        legendText.setStyleRange(new StyleRange(line4start, line4.length(), COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
+        legendText.setStyleRange(new StyleRange(line6start, line6.length(), COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
+        legendText.setStyleRange(new StyleRange(line2start + line2.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_GREEN, SWT.BOLD));
+        legendText.setStyleRange(new StyleRange(line2start + line2.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_MAGENTA));
+        legendText.setStyleRange(new StyleRange(line3start + line3.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));
+        legendText.setStyleRange(new StyleRange(line3start + line3.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_LIGHT_MAGENTA));
+        legendText.setStyleRange(new StyleRange(line4start + line4.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));
+        legendText.setStyleRange(new StyleRange(line4start + line4.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_LIGHT_MAGENTA));
+        legendText.setStyleRange(new StyleRange(line6start + line6.indexOf(CG), CG.length(), COLOR_BLACK, COLOR_GREEN, SWT.BOLD));
+        legendText.setStyleRange(new StyleRange(line6start + line6.indexOf(UCG), UCG.length(), COLOR_BLACK, COLOR_MAGENTA));
+        legendShell.setText(Messages.CustomTxtParserInputWizardPage_previewLegend);
+        legendShell.pack();
+        legendShell.open();
+    }
+
+    private class UpdateListener implements ModifyListener, SelectionListener {
+
+       @Override
+        public void modifyText(ModifyEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+       @Override
+        public void widgetDefaultSelected(SelectionEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+       @Override
+        public void widgetSelected(SelectionEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+    }
+
+    private class Line {
+        private static final String INFINITY_STRING = "\u221E"; //$NON-NLS-1$
+        InputLine inputLine;
+        Group group;
+        Composite labelComposite;
+        Text regexText;
+        Composite cardinalityContainer;
+        Combo cardinalityCombo;
+        Label cardinalityMinLabel;
+        Text cardinalityMinText;
+        Label cardinalityMaxLabel;
+        Text cardinalityMaxText;
+        Button infiniteButton;
+        List<InputGroup> inputs = new ArrayList<InputGroup>();
+        Button addGroupButton;
+        Label addGroupLabel;
+
+        public Line(Composite parent, String name, InputLine inputLine) {
+            this.inputLine = inputLine;
+
+            group = new Group(parent, SWT.NONE);
+            group.setText(name);
+            group.setLayout(new GridLayout(2, false));
+            group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            labelComposite = new Composite(group, SWT.FILL);
+            GridLayout labelLayout = new GridLayout(1, false);
+            labelLayout.marginWidth = 0;
+            labelLayout.marginHeight = 0;
+            labelComposite.setLayout(labelLayout);
+            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            Label label = new Label(labelComposite, SWT.NULL);
+            label.setText(Messages.CustomTxtParserInputWizardPage_regularExpression);
+
+            Composite regexContainer = new Composite(group, SWT.NONE);
+            GridLayout regexLayout = new GridLayout(2, false);
+            regexLayout.marginHeight = 0;
+            regexLayout.marginWidth = 0;
+            regexContainer.setLayout(regexLayout);
+            regexContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            regexText = new Text(regexContainer, SWT.BORDER | SWT.SINGLE);
+            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            regexText.setLayoutData(gd);
+            regexText.setText(inputLine.getRegex());
+            regexText.addModifyListener(updateListener);
+
+            Button regexHelpButton = new Button(regexContainer, SWT.PUSH);
+            regexHelpButton.setImage(helpImage);
+            regexHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_regularExpressionHelp);
+            regexHelpButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                    openHelpShell(PATTERN_URL);
+                }
+            });
+
+            label = new Label(group, SWT.NONE);
+            label.setText(Messages.CustomTxtParserInputWizardPage_cardinality);
+            label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            cardinalityContainer = new Composite(group, SWT.NONE);
+            GridLayout cardinalityLayout = new GridLayout(6, false);
+            cardinalityLayout.marginHeight = 0;
+            cardinalityLayout.marginWidth = 0;
+            cardinalityContainer.setLayout(cardinalityLayout);
+            cardinalityContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            cardinalityCombo = new Combo(cardinalityContainer, SWT.DROP_DOWN | SWT.READ_ONLY);
+            cardinalityCombo.setItems(new String[] {
+                    Cardinality.ZERO_OR_MORE.toString(),
+                    Cardinality.ONE_OR_MORE.toString(),
+                    Cardinality.ZERO_OR_ONE.toString(),
+                    Cardinality.ONE.toString(),
+                    "(?,?)"}); //$NON-NLS-1$
+            cardinalityCombo.addSelectionListener(new SelectionListener(){
+               @Override
+                public void widgetDefaultSelected(SelectionEvent e) {}
+               @Override
+                public void widgetSelected(SelectionEvent e) {
+                    switch (cardinalityCombo.getSelectionIndex()) {
+                    case 4: //(?,?)
+                        cardinalityMinLabel.setVisible(true);
+                        cardinalityMinText.setVisible(true);
+                        cardinalityMaxLabel.setVisible(true);
+                        cardinalityMaxText.setVisible(true);
+                        infiniteButton.setVisible(true);
+                        break;
+                    default:
+                        cardinalityMinLabel.setVisible(false);
+                        cardinalityMinText.setVisible(false);
+                        cardinalityMaxLabel.setVisible(false);
+                        cardinalityMaxText.setVisible(false);
+                        infiniteButton.setVisible(false);
+                        break;
+                    }
+                    cardinalityContainer.layout();
+                    validate();
+                    updatePreviews();
+                }});
+
+            cardinalityMinLabel = new Label(cardinalityContainer, SWT.NONE);
+            cardinalityMinLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            cardinalityMinLabel.setText(Messages.CustomTxtParserInputWizardPage_min);
+            cardinalityMinLabel.setVisible(false);
+
+            cardinalityMinText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE);
+            gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+            gd.widthHint = 20;
+            cardinalityMinText.setLayoutData(gd);
+            cardinalityMinText.setVisible(false);
+
+            cardinalityMaxLabel = new Label(cardinalityContainer, SWT.NONE);
+            cardinalityMaxLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            cardinalityMaxLabel.setText(Messages.CustomTxtParserInputWizardPage_max);
+            cardinalityMaxLabel.setVisible(false);
+
+            cardinalityMaxText = new Text(cardinalityContainer, SWT.BORDER | SWT.SINGLE);
+            gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
+            gd.widthHint = 20;
+            cardinalityMaxText.setLayoutData(gd);
+            cardinalityMaxText.setVisible(false);
+
+            infiniteButton = new Button(cardinalityContainer, SWT.PUSH);
+            infiniteButton.setText(INFINITY_STRING);
+            infiniteButton.setVisible(false);
+            infiniteButton.addSelectionListener(new SelectionAdapter(){
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    cardinalityMaxText.setText(INFINITY_STRING);
+                }});
+
+            if (inputLine.cardinality.equals(Cardinality.ZERO_OR_MORE)) {
+                cardinalityCombo.select(0);
+            } else if (inputLine.cardinality.equals(Cardinality.ONE_OR_MORE)) {
+                cardinalityCombo.select(1);
+            } else if (inputLine.cardinality.equals(Cardinality.ZERO_OR_ONE)) {
+                cardinalityCombo.select(2);
+            } else if (inputLine.cardinality.equals(Cardinality.ONE)) {
+                cardinalityCombo.select(3);
+            } else {
+                cardinalityCombo.select(4);
+                cardinalityMinLabel.setVisible(true);
+                cardinalityMinText.setVisible(true);
+                if (inputLine.getMinCount() >= 0) {
+                    cardinalityMinText.setText(Integer.toString(inputLine.getMinCount()));
+                }
+                cardinalityMaxLabel.setVisible(true);
+                cardinalityMaxText.setVisible(true);
+                if (inputLine.getMaxCount() == Cardinality.INF) {
+                    cardinalityMaxText.setText(INFINITY_STRING);
+                } else if (inputLine.getMaxCount() >= 0) {
+                    cardinalityMaxText.setText(Integer.toString(inputLine.getMaxCount()));
+                }
+                infiniteButton.setVisible(true);
+            }
+
+            VerifyListener digitsListener = new VerifyListener() {
+               @Override
+                public void verifyText(VerifyEvent e) {
+                    if (e.text.equals(INFINITY_STRING)) {
+                        e.doit = e.widget == cardinalityMaxText && e.start == 0 && e.end == ((Text) e.widget).getText().length();
+                    } else {
+                        if (((Text) e.widget).getText().equals(INFINITY_STRING)) {
+                            e.doit = e.start == 0 && e.end == ((Text) e.widget).getText().length();
+                        }
+                        for (int i = 0; i < e.text.length(); i++) {
+                            if (!Character.isDigit(e.text.charAt(i))) {
+                                e.doit = false;
+                                break;
+                            }
+                        }
+                    }
+                }};
+
+            cardinalityMinText.addModifyListener(updateListener);
+            cardinalityMaxText.addModifyListener(updateListener);
+            cardinalityMinText.addVerifyListener(digitsListener);
+            cardinalityMaxText.addVerifyListener(digitsListener);
+
+            if (inputLine.columns != null) {
+                for (InputData inputData : inputLine.columns) {
+                    InputGroup inputGroup = new InputGroup(group, this, inputs.size()+1);
+                    if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        inputGroup.tagCombo.select(0);
+                        inputGroup.tagText.setText(inputData.format);
+                        inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format);
+                        inputGroup.tagLabel.setVisible(true);
+                        inputGroup.tagText.setVisible(true);
+                        inputGroup.tagText.addModifyListener(updateListener);
+                    } else if (inputData.name.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                        inputGroup.tagCombo.select(1);
+                    } else {
+                        inputGroup.tagCombo.select(2);
+                        inputGroup.tagText.setText(inputData.name);
+                        inputGroup.tagLabel.setText(Messages.CustomTxtParserInputWizardPage_name);
+                        inputGroup.tagLabel.setVisible(true);
+                        inputGroup.tagText.setVisible(true);
+                        inputGroup.tagText.addModifyListener(updateListener);
+                    }
+                    inputGroup.actionCombo.select(inputData.action);
+                    inputs.add(inputGroup);
+                }
+            }
+
+            createAddGroupButton();
+        }
+
+        private void createAddGroupButton() {
+            addGroupButton = new Button(group, SWT.PUSH);
+            addGroupButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            addGroupButton.setImage(addImage);
+            addGroupButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addGroup);
+            addGroupButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+                public void widgetSelected(SelectionEvent e) {
+                    removeAddGroupButton();
+                    inputs.add(new InputGroup(group, Line.this, inputs.size()+1));
+                    createAddGroupButton();
+                    lineContainer.layout();
+                    lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+                    group.getParent().layout();
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            addGroupLabel = new Label(group, SWT.NULL);
+            addGroupLabel.setText(Messages.CustomTxtParserInputWizardPage_newGroup);
+        }
+
+        private void removeAddGroupButton() {
+            addGroupButton.dispose();
+            addGroupLabel.dispose();
+        }
+
+        private void removeInput(int inputNumber) {
+            if (--inputNumber < inputs.size()) {
+                inputs.remove(inputNumber).dispose();
+                for (int i = inputNumber; i < inputs.size(); i++) {
+                    inputs.get(i).setInputNumber(i+1);
+                }
+                lineContainer.layout();
+                lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+                group.getParent().layout();
+            }
+        }
+
+//        private void setName(String name) {
+//            this.name = name;
+//            group.setText("Line " + name);
+//        }
+
+        private void dispose() {
+            group.dispose();
+        }
+
+        private void extractInputs() {
+            inputLine.setRegex(selectedLine.regexText.getText());
+            switch (cardinalityCombo.getSelectionIndex()) {
+            case 0:
+                inputLine.cardinality = Cardinality.ZERO_OR_MORE;
+                break;
+            case 1:
+                inputLine.cardinality = Cardinality.ONE_OR_MORE;
+                break;
+            case 2:
+                inputLine.cardinality = Cardinality.ZERO_OR_ONE;
+                break;
+            case 3:
+                inputLine.cardinality = Cardinality.ONE;
+                break;
+            case 4: //(?,?)
+                int min, max;
+                try {
+                    min = Integer.parseInt(cardinalityMinText.getText());
+                } catch (NumberFormatException e) {
+                    min = -1;
+                }
+                try {
+                    if (cardinalityMaxText.getText().equals(INFINITY_STRING)) {
+                        max = Cardinality.INF;
+                    } else {
+                        max = Integer.parseInt(cardinalityMaxText.getText());
+                    }
+                } catch (NumberFormatException e) {
+                    max = -1;
+                }
+                inputLine.cardinality = new Cardinality(min, max);
+                break;
+            default:
+                inputLine.cardinality = Cardinality.ZERO_OR_MORE;
+                break;
+            }
+            inputLine.columns = new ArrayList<InputData>(inputs.size());
+            for (int i = 0; i < inputs.size(); i++) {
+                InputGroup group = inputs.get(i);
+                InputData inputData = new InputData();
+                if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                    inputData.name = group.tagText.getText().trim();
+                } else {
+                    inputData.name = group.tagCombo.getText();
+                    if (group.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        inputData.format = group.tagText.getText().trim();
+                    }
+                }
+                inputData.action = group.actionCombo.getSelectionIndex();
+                inputLine.columns.add(inputData);
+            }
+        }
+    }
+
+    private class InputGroup {
+        Line line;
+        int inputNumber;
+
+        // children of parent (must be disposed)
+        Composite labelComposite;
+        Composite tagComposite;
+        Label previewLabel;
+        Text previewText;
+
+        // children of labelComposite
+        Label inputLabel;
+
+        // children of tagComposite
+        Combo tagCombo;
+        Label tagLabel;
+        Text tagText;
+        Combo actionCombo;
+
+        public InputGroup(Composite parent, Line line, int inputNumber) {
+            this.line = line;
+            this.inputNumber = inputNumber;
+
+            labelComposite = new Composite(parent, SWT.FILL);
+            GridLayout labelLayout = new GridLayout(2, false);
+            labelLayout.marginWidth = 0;
+            labelLayout.marginHeight = 0;
+            labelComposite.setLayout(labelLayout);
+            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            Button deleteButton = new Button(labelComposite, SWT.PUSH);
+            deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            deleteButton.setImage(deleteImage);
+            deleteButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeGroup);
+            deleteButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+                public void widgetSelected(SelectionEvent e) {
+                    InputGroup.this.line.removeInput(InputGroup.this.inputNumber);
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            inputLabel = new Label(labelComposite, SWT.NULL);
+            inputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$
+
+            tagComposite = new Composite(parent, SWT.FILL);
+            GridLayout tagLayout = new GridLayout(4, false);
+            tagLayout.marginWidth = 0;
+            tagLayout.marginHeight = 0;
+            tagComposite.setLayout(tagLayout);
+            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(1);
+            tagCombo.addSelectionListener(new SelectionListener(){
+               @Override
+                public void widgetDefaultSelected(SelectionEvent e) {}
+               @Override
+                public void widgetSelected(SelectionEvent e) {
+                    tagText.removeModifyListener(updateListener);
+                    switch (tagCombo.getSelectionIndex()) {
+                    case 0: //Time Stamp
+                        tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format);
+                        tagLabel.setVisible(true);
+                        tagText.setVisible(true);
+                        tagText.addModifyListener(updateListener);
+                        break;
+                    case 1: //Message
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        break;
+                    case 2: //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;
+                    }
+                    tagComposite.layout();
+                    validate();
+                    updatePreviews();
+                }});
+
+            tagLabel = new Label(tagComposite, SWT.NULL);
+            tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            tagLabel.setVisible(false);
+
+            tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
+            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            tagText.setLayoutData(gd);
+            tagText.setVisible(false);
+
+            actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+            actionCombo.setItems(new String[] {Messages.CustomTxtParserInputWizardPage_set, Messages.CustomTxtParserInputWizardPage_append, Messages.CustomTxtParserInputWizardPage_appendWith});
+            actionCombo.select(0);
+            actionCombo.addSelectionListener(updateListener);
+
+            previewLabel = new Label(parent, SWT.NULL);
+            previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            previewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);
+
+            previewText = new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+            gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            previewText.setLayoutData(gd);
+            previewText.setText(Messages.CustomTxtParserInputWizardPage_noMatch);
+            previewText.setBackground(COLOR_WIDGET_BACKGROUND);
+        }
+
+        private void dispose() {
+            labelComposite.dispose();
+            tagComposite.dispose();
+            previewLabel.dispose();
+            previewText.dispose();
+        }
+
+        private void setInputNumber(int inputNumber) {
+            this.inputNumber = inputNumber;
+            inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$
+            labelComposite.layout();
+        }
+    }
+
+    private void validate() {
+
+        definition.definitionName = logtypeText.getText().trim();
+        definition.timeStampOutputFormat = timestampOutputFormatText.getText().trim();
+
+        if (selectedLine != null) {
+            selectedLine.extractInputs();
+            treeViewer.refresh();
+        }
+
+        StringBuffer errors = new StringBuffer();
+
+        if (definition.definitionName.length() == 0) {
+            errors.append("Enter a name for the new log type. "); //$NON-NLS-1$
+            logtypeText.setBackground(COLOR_LIGHT_RED);
+        } else {
+            logtypeText.setBackground(COLOR_TEXT_BACKGROUND);
+            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+                if (definition.definitionName.equals(def.definitionName)) {
+                    if (editDefinitionName == null || ! editDefinitionName.equals(definition.definitionName)) {
+                        errors.append("The log type name already exists. "); //$NON-NLS-1$
+                        logtypeText.setBackground(COLOR_LIGHT_RED);
+                        break;
+                    }
+                }
+            }
+        }
+
+        timestampFound = false;
+        for (int i = 0; i < definition.inputs.size(); i++) {
+
+            InputLine inputLine = definition.inputs.get(i);
+            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$
+                timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);
+            } else {
+                try {
+                    new SimpleDateFormat(definition.timeStampOutputFormat);
+                    timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+                } catch (IllegalArgumentException e) {
+                    errors.append("Enter a valid output format for the Time Stamp field. "); //$NON-NLS-1$
+                    timestampOutputFormatText.setBackground(COLOR_LIGHT_RED);
+                }
+            }
+
+        } else {
+            timestampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+//            timestampPreviewText.setBackground(COLOR_WIDGET_BACKGROUND);
+//            errors.append("Identify a Time Stamp group (Line "+name+"). ");
+//            timestampPreviewText.setText("*no timestamp group*");
+//            timestampPreviewText.setBackground(COLOR_LIGHT_RED);
+        }
+
+        if (errors.length() == 0) {
+            setDescription(defaultDescription);
+            setPageComplete(true);
+        } else {
+            setDescription(errors.toString());
+            setPageComplete(false);
+        }
+    }
+
+    public StringBuffer validateLine(InputLine inputLine, String name) {
+        StringBuffer errors = new StringBuffer();
+        Line line = null;
+        if (selectedLine != null && selectedLine.inputLine.equals(inputLine)) {
+            line = selectedLine;
+        }
+        try {
+            Pattern.compile(inputLine.getRegex());
+            if (line != null) {
+                line.regexText.setBackground(COLOR_TEXT_BACKGROUND);
+            }
+        } catch (PatternSyntaxException e) {
+            errors.append("Enter a valid regular expression (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            if (line != null) {
+                line.regexText.setBackground(COLOR_LIGHT_RED);
+            }
+        }
+        if (inputLine.getMinCount() == -1) {
+            errors.append("Enter a minimum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            if (line != null) {
+                line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);
+            }
+        } else {
+            if (line != null) {
+                line.cardinalityMinText.setBackground(COLOR_TEXT_BACKGROUND);
+            }
+        }
+        if (inputLine.getMaxCount() == -1) {
+            errors.append("Enter a maximum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            if (line != null) {
+                line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);
+            }
+        } else if (inputLine.getMinCount() > inputLine.getMaxCount()) {
+            errors.append("Enter correct (min <= max) values for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            if (line != null) {
+                line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);
+            }
+            if (line != null) {
+                line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);
+            }
+        } else {
+            if (line != null) {
+                line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND);
+            }
+        }
+        for (int i = 0; inputLine.columns != null && i < inputLine.columns.size(); i++) {
+            InputData inputData = inputLine.columns.get(i);
+            InputGroup group = null;
+            if (line != null) {
+                group = line.inputs.get(i);
+            }
+            if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                timestampFound = true;
+                if (inputData.format.length() == 0) {
+                    errors.append("Enter the input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (group != null) {
+                        group.tagText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else {
+                    try {
+                        new SimpleDateFormat(inputData.format);
+                        if (group != null) {
+                            group.tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                        }
+                    } catch (IllegalArgumentException e) {
+                        errors.append("Enter a valid input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (group != null) {
+                            group.tagText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+            } else if (inputData.name.length() == 0) {
+                errors.append("Enter a name for the data group (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                if (group != null) {
+                    group.tagText.setBackground(COLOR_LIGHT_RED);
+                }
+            } else {
+                if (group != null) {
+                    group.tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+        }
+        for (int i = 0; inputLine.childrenInputs != null && i < inputLine.childrenInputs.size(); i++) {
+            errors.append(validateLine(inputLine.childrenInputs.get(i), name+"."+(i+1))); //$NON-NLS-1$
+        }
+        return errors;
+    }
+
+    public CustomTxtTraceDefinition getDefinition() {
+        return definition;
+    }
+
+    public char[] getInputText() {
+        return inputText.getText().toCharArray();
+    }
+}
index ed3f3fa46eea8094ba573970e2fe1673c262e70f..6ba1886686bd0a53c80a32de6efe3db840f69ed6 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Text;\r
-\r
-public class CustomTxtParserOutputWizardPage extends WizardPage {\r
-\r
-    private static final Image upImage = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$\r
-    private static final Image downImage = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$\r
-    private final CustomTxtParserWizard wizard;\r
-    private CustomTxtTraceDefinition definition;\r
-    List<Output> outputs = new ArrayList<Output>();\r
-    //    Output messageOutput;\r
-    Composite container;\r
-    SashForm sash;\r
-    //    Text timestampFormatText;\r
-    //    Text timestampPreviewText;\r
-    ScrolledComposite outputsScrolledComposite;\r
-    Composite outputsContainer;\r
-    //    ScrolledComposite inputScrolledComposite;\r
-    Composite tableContainer;\r
-    CustomEventsTable previewTable;\r
-    File tmpFile;\r
-\r
-    protected CustomTxtParserOutputWizardPage(final CustomTxtParserWizard wizard) {\r
-        super("CustomParserOutputWizardPage"); //$NON-NLS-1$\r
-        setTitle(wizard.inputPage.getTitle());\r
-        setDescription(Messages.CustomTxtParserOutputWizardPage_description);\r
-        this.wizard = wizard;\r
-        setPageComplete(false);\r
-    }\r
-\r
-    @Override\r
-    public void createControl(final Composite parent) {\r
-        container = new Composite(parent, SWT.NULL);\r
-        container.setLayout(new GridLayout());\r
-\r
-        sash = new SashForm(container, SWT.VERTICAL);\r
-        sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
-\r
-        outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);\r
-        outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);\r
-        final GridLayout outputsLayout = new GridLayout(4, false);\r
-        outputsLayout.marginHeight = 10;\r
-        outputsLayout.marginWidth = 0;\r
-        outputsContainer.setLayout(outputsLayout);\r
-        outputsScrolledComposite.setContent(outputsContainer);\r
-        outputsScrolledComposite.setExpandHorizontal(true);\r
-        outputsScrolledComposite.setExpandVertical(true);\r
-\r
-        outputsContainer.layout();\r
-\r
-        outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-\r
-        tableContainer = new Composite(sash, SWT.NONE);\r
-        final GridLayout tableLayout = new GridLayout();\r
-        tableLayout.marginHeight = 0;\r
-        tableLayout.marginWidth = 0;\r
-        tableContainer.setLayout(tableLayout);\r
-        previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0);\r
-        previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-\r
-        if (wizard.definition != null)\r
-            loadDefinition(wizard.definition);\r
-        setControl(container);\r
-\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        previewTable.dispose();\r
-        super.dispose();\r
-    }\r
-\r
-    private void loadDefinition(final CustomTxtTraceDefinition definition) {\r
-        for (final OutputColumn outputColumn : definition.outputs) {\r
-            final Output output = new Output(outputsContainer, outputColumn.name);\r
-            outputs.add(output);\r
-        }\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)\r
-     */\r
-    @Override\r
-    public void setVisible(final boolean visible) {\r
-        if (visible) {\r
-            this.definition = wizard.inputPage.getDefinition();\r
-            final List<String> outputNames = wizard.inputPage.getInputNames();\r
-\r
-            // dispose outputs that have been removed in the input page\r
-            final Iterator<Output> iter = outputs.iterator();\r
-            while (iter.hasNext()) {\r
-                final Output output = iter.next();\r
-                boolean found = false;\r
-                for (final String name : outputNames)\r
-                    if (output.name.equals(name)) {\r
-                        found = true;\r
-                        break;\r
-                    }\r
-                if (!found) {\r
-                    output.dispose();\r
-                    iter.remove();\r
-                }\r
-            }\r
-\r
-            // create outputs that have been added in the input page\r
-            for (final String name : outputNames) {\r
-                boolean found = false;\r
-                for (final Output output : outputs)\r
-                    if (output.name.equals(name)) {\r
-                        found = true;\r
-                        break;\r
-                    }\r
-                if (!found)\r
-                    outputs.add(new Output(outputsContainer, name));\r
-            }\r
-\r
-            outputsContainer.layout();\r
-            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-            updatePreviewTable();\r
-            if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight())\r
-                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});\r
-            else\r
-                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});\r
-            setPageComplete(true);\r
-        } else\r
-            setPageComplete(false);\r
-        super.setVisible(visible);\r
-    }\r
-\r
-    private void moveBefore(final Output moved) {\r
-        final int i = outputs.indexOf(moved);\r
-        if (i > 0) {\r
-            final Output previous = outputs.get(i-1);\r
-            moved.enabledButton.moveAbove(previous.enabledButton);\r
-            moved.nameLabel.moveBelow(moved.enabledButton);\r
-            moved.upButton.moveBelow(moved.nameLabel);\r
-            moved.downButton.moveBelow(moved.upButton);\r
-            outputs.add(i-1, outputs.remove(i));\r
-            outputsContainer.layout();\r
-            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-            container.layout();\r
-            updatePreviewTable();\r
-        }\r
-    }\r
-\r
-    private void moveAfter(final Output moved) {\r
-        final int i = outputs.indexOf(moved);\r
-        if (i+1 < outputs.size()) {\r
-            final Output next = outputs.get(i+1);\r
-            moved.enabledButton.moveBelow(next.downButton);\r
-            moved.nameLabel.moveBelow(moved.enabledButton);\r
-            moved.upButton.moveBelow(moved.nameLabel);\r
-            moved.downButton.moveBelow(moved.upButton);\r
-            outputs.add(i+1, outputs.remove(i));\r
-            outputsContainer.layout();\r
-            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-            container.layout();\r
-            updatePreviewTable();\r
-        }\r
-    }\r
-\r
-    private void updatePreviewTable() {\r
-        final int CACHE_SIZE = 50;\r
-        definition.outputs = extractOutputs();\r
-\r
-        try {\r
-            tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$\r
-            final FileWriter writer = new FileWriter(tmpFile);\r
-            writer.write(wizard.inputPage.getInputText());\r
-            writer.close();\r
-\r
-            final ITmfTrace<?> trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);\r
-            previewTable.dispose();\r
-            previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);\r
-            previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-            previewTable.setTrace(trace, true);\r
-        } catch (final TmfTraceException e) {\r
-            Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$\r
-        }\r
-\r
-        tableContainer.layout();\r
-        container.layout();\r
-    }\r
-\r
-    public List<OutputColumn> extractOutputs() {\r
-        int numColumns = 0;\r
-        for (int i = 0; i < outputs.size(); i++)\r
-            if (outputs.get(i).enabledButton.getSelection())\r
-                numColumns++;\r
-        final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);\r
-        numColumns = 0;\r
-        for (int i = 0; i < outputs.size(); i++) {\r
-            final Output output = outputs.get(i);\r
-            if (output.enabledButton.getSelection()) {\r
-                final OutputColumn column = new OutputColumn();\r
-                column.name = output.nameLabel.getText();\r
-                outputColumns.add(column);\r
-            }\r
-        }\r
-        return outputColumns;\r
-    }\r
-\r
-    private class Output {\r
-        String name;\r
-        Button enabledButton;\r
-        Text nameLabel;\r
-        Button upButton;\r
-        Button downButton;\r
-\r
-        public Output(final Composite parent, final String name) {\r
-            this.name = name;\r
-\r
-            enabledButton = new Button(parent, SWT.CHECK);\r
-            enabledButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_visible);\r
-            enabledButton.setSelection(true);\r
-            enabledButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(final SelectionEvent e) {\r
-                    updatePreviewTable();\r
-                }\r
-            });\r
-            //            if (messageOutput != null) {\r
-            //                enabledButton.moveAbove(messageOutput.enabledButton);\r
-            //            }\r
-\r
-            nameLabel = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);\r
-            nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-            nameLabel.setText(name);\r
-            nameLabel.moveBelow(enabledButton);\r
-\r
-            upButton = new Button(parent, SWT.PUSH);\r
-            upButton.setImage(upImage);\r
-            upButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveBefore);\r
-            upButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(final SelectionEvent e) {\r
-                    moveBefore(Output.this);\r
-                }\r
-            });\r
-            upButton.moveBelow(nameLabel);\r
-\r
-            downButton = new Button(parent, SWT.PUSH);\r
-            downButton.setImage(downImage);\r
-            downButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveAfter);\r
-            downButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(final SelectionEvent e) {\r
-                    moveAfter(Output.this);\r
-                }\r
-            });\r
-            downButton.moveBelow(upButton);\r
-        }\r
-\r
-        private void dispose() {\r
-            enabledButton.dispose();\r
-            nameLabel.dispose();\r
-            upButton.dispose();\r
-            downButton.dispose();\r
-        }\r
-    }\r
-\r
-    public CustomTxtTraceDefinition getDefinition() {\r
-        return definition;\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class CustomTxtParserOutputWizardPage extends WizardPage {
+
+    private static final Image upImage = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$
+    private static final Image downImage = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$
+    private final CustomTxtParserWizard wizard;
+    private CustomTxtTraceDefinition definition;
+    List<Output> outputs = new ArrayList<Output>();
+    //    Output messageOutput;
+    Composite container;
+    SashForm sash;
+    //    Text timestampFormatText;
+    //    Text timestampPreviewText;
+    ScrolledComposite outputsScrolledComposite;
+    Composite outputsContainer;
+    //    ScrolledComposite inputScrolledComposite;
+    Composite tableContainer;
+    CustomEventsTable previewTable;
+    File tmpFile;
+
+    protected CustomTxtParserOutputWizardPage(final CustomTxtParserWizard wizard) {
+        super("CustomParserOutputWizardPage"); //$NON-NLS-1$
+        setTitle(wizard.inputPage.getTitle());
+        setDescription(Messages.CustomTxtParserOutputWizardPage_description);
+        this.wizard = wizard;
+        setPageComplete(false);
+    }
+
+    @Override
+    public void createControl(final Composite parent) {
+        container = new Composite(parent, SWT.NULL);
+        container.setLayout(new GridLayout());
+
+        sash = new SashForm(container, SWT.VERTICAL);
+        sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+
+        outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
+        outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
+        final GridLayout outputsLayout = new GridLayout(4, false);
+        outputsLayout.marginHeight = 10;
+        outputsLayout.marginWidth = 0;
+        outputsContainer.setLayout(outputsLayout);
+        outputsScrolledComposite.setContent(outputsContainer);
+        outputsScrolledComposite.setExpandHorizontal(true);
+        outputsScrolledComposite.setExpandVertical(true);
+
+        outputsContainer.layout();
+
+        outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+
+        tableContainer = new Composite(sash, SWT.NONE);
+        final GridLayout tableLayout = new GridLayout();
+        tableLayout.marginHeight = 0;
+        tableLayout.marginWidth = 0;
+        tableContainer.setLayout(tableLayout);
+        previewTable = new CustomEventsTable(new CustomTxtTraceDefinition(), tableContainer, 0);
+        previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        if (wizard.definition != null)
+            loadDefinition(wizard.definition);
+        setControl(container);
+
+    }
+
+    @Override
+    public void dispose() {
+        previewTable.dispose();
+        super.dispose();
+    }
+
+    private void loadDefinition(final CustomTxtTraceDefinition definition) {
+        for (final OutputColumn outputColumn : definition.outputs) {
+            final Output output = new Output(outputsContainer, outputColumn.name);
+            outputs.add(output);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    @Override
+    public void setVisible(final boolean visible) {
+        if (visible) {
+            this.definition = wizard.inputPage.getDefinition();
+            final List<String> outputNames = wizard.inputPage.getInputNames();
+
+            // dispose outputs that have been removed in the input page
+            final Iterator<Output> iter = outputs.iterator();
+            while (iter.hasNext()) {
+                final Output output = iter.next();
+                boolean found = false;
+                for (final String name : outputNames)
+                    if (output.name.equals(name)) {
+                        found = true;
+                        break;
+                    }
+                if (!found) {
+                    output.dispose();
+                    iter.remove();
+                }
+            }
+
+            // create outputs that have been added in the input page
+            for (final String name : outputNames) {
+                boolean found = false;
+                for (final Output output : outputs)
+                    if (output.name.equals(name)) {
+                        found = true;
+                        break;
+                    }
+                if (!found)
+                    outputs.add(new Output(outputsContainer, name));
+            }
+
+            outputsContainer.layout();
+            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+            updatePreviewTable();
+            if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight())
+                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});
+            else
+                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});
+            setPageComplete(true);
+        } else
+            setPageComplete(false);
+        super.setVisible(visible);
+    }
+
+    private void moveBefore(final Output moved) {
+        final int i = outputs.indexOf(moved);
+        if (i > 0) {
+            final Output previous = outputs.get(i-1);
+            moved.enabledButton.moveAbove(previous.enabledButton);
+            moved.nameLabel.moveBelow(moved.enabledButton);
+            moved.upButton.moveBelow(moved.nameLabel);
+            moved.downButton.moveBelow(moved.upButton);
+            outputs.add(i-1, outputs.remove(i));
+            outputsContainer.layout();
+            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+            container.layout();
+            updatePreviewTable();
+        }
+    }
+
+    private void moveAfter(final Output moved) {
+        final int i = outputs.indexOf(moved);
+        if (i+1 < outputs.size()) {
+            final Output next = outputs.get(i+1);
+            moved.enabledButton.moveBelow(next.downButton);
+            moved.nameLabel.moveBelow(moved.enabledButton);
+            moved.upButton.moveBelow(moved.nameLabel);
+            moved.downButton.moveBelow(moved.upButton);
+            outputs.add(i+1, outputs.remove(i));
+            outputsContainer.layout();
+            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+            container.layout();
+            updatePreviewTable();
+        }
+    }
+
+    private void updatePreviewTable() {
+        final int CACHE_SIZE = 50;
+        definition.outputs = extractOutputs();
+
+        try {
+            tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$
+            final FileWriter writer = new FileWriter(tmpFile);
+            writer.write(wizard.inputPage.getInputText());
+            writer.close();
+
+            final ITmfTrace<?> trace = new CustomTxtTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);
+            previewTable.dispose();
+            previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);
+            previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+            previewTable.setTrace(trace, true);
+        } catch (final TmfTraceException e) {
+            Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error creating CustomTxtTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
+        }
+
+        tableContainer.layout();
+        container.layout();
+    }
+
+    public List<OutputColumn> extractOutputs() {
+        int numColumns = 0;
+        for (int i = 0; i < outputs.size(); i++)
+            if (outputs.get(i).enabledButton.getSelection())
+                numColumns++;
+        final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);
+        numColumns = 0;
+        for (int i = 0; i < outputs.size(); i++) {
+            final Output output = outputs.get(i);
+            if (output.enabledButton.getSelection()) {
+                final OutputColumn column = new OutputColumn();
+                column.name = output.nameLabel.getText();
+                outputColumns.add(column);
+            }
+        }
+        return outputColumns;
+    }
+
+    private class Output {
+        String name;
+        Button enabledButton;
+        Text nameLabel;
+        Button upButton;
+        Button downButton;
+
+        public Output(final Composite parent, final String name) {
+            this.name = name;
+
+            enabledButton = new Button(parent, SWT.CHECK);
+            enabledButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_visible);
+            enabledButton.setSelection(true);
+            enabledButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(final SelectionEvent e) {
+                    updatePreviewTable();
+                }
+            });
+            //            if (messageOutput != null) {
+            //                enabledButton.moveAbove(messageOutput.enabledButton);
+            //            }
+
+            nameLabel = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);
+            nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+            nameLabel.setText(name);
+            nameLabel.moveBelow(enabledButton);
+
+            upButton = new Button(parent, SWT.PUSH);
+            upButton.setImage(upImage);
+            upButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveBefore);
+            upButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(final SelectionEvent e) {
+                    moveBefore(Output.this);
+                }
+            });
+            upButton.moveBelow(nameLabel);
+
+            downButton = new Button(parent, SWT.PUSH);
+            downButton.setImage(downImage);
+            downButton.setToolTipText(Messages.CustomTxtParserOutputWizardPage_moveAfter);
+            downButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(final SelectionEvent e) {
+                    moveAfter(Output.this);
+                }
+            });
+            downButton.moveBelow(upButton);
+        }
+
+        private void dispose() {
+            enabledButton.dispose();
+            nameLabel.dispose();
+            upButton.dispose();
+            downButton.dispose();
+        }
+    }
+
+    public CustomTxtTraceDefinition getDefinition() {
+        return definition;
+    }
+
+}
index be8babca93c849d382c142df94165782542f100c..78d1fea2bb2341a87f054941acbdef937d038f19 100644 (file)
@@ -1,53 +1,53 @@
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.wizard.Wizard;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.ui.INewWizard;\r
-import org.eclipse.ui.IWorkbench;\r
-\r
-public class CustomTxtParserWizard extends Wizard implements INewWizard {\r
-\r
-    CustomTxtParserInputWizardPage inputPage;\r
-    CustomTxtParserOutputWizardPage outputPage;\r
-    private ISelection selection;\r
-    CustomTxtTraceDefinition definition;\r
-\r
-    public CustomTxtParserWizard() {\r
-        super();\r
-    }\r
-\r
-    public CustomTxtParserWizard(CustomTxtTraceDefinition definition) {\r
-        super();\r
-        this.definition = definition;\r
-    }\r
-\r
-    @Override\r
-    public boolean performFinish() {\r
-        CustomTxtTraceDefinition def = outputPage.getDefinition();\r
-        if (definition != null && !definition.definitionName.equals(def.definitionName)) {\r
-            CustomTxtTraceDefinition.delete(definition.definitionName);\r
-        }\r
-        def.save();\r
-        return true;\r
-    }\r
-\r
-    /**\r
-     * Adding the page to the wizard.\r
-     */\r
-\r
-    @Override\r
-       public void addPages() {\r
-        inputPage = new CustomTxtParserInputWizardPage(selection, definition);\r
-        addPage(inputPage);\r
-        outputPage = new CustomTxtParserOutputWizardPage(this);\r
-        addPage(outputPage);\r
-    }\r
-\r
-       @Override\r
-    public void init(IWorkbench workbench, IStructuredSelection selection) {\r
-        this.selection = selection;\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class CustomTxtParserWizard extends Wizard implements INewWizard {
+
+    CustomTxtParserInputWizardPage inputPage;
+    CustomTxtParserOutputWizardPage outputPage;
+    private ISelection selection;
+    CustomTxtTraceDefinition definition;
+
+    public CustomTxtParserWizard() {
+        super();
+    }
+
+    public CustomTxtParserWizard(CustomTxtTraceDefinition definition) {
+        super();
+        this.definition = definition;
+    }
+
+    @Override
+    public boolean performFinish() {
+        CustomTxtTraceDefinition def = outputPage.getDefinition();
+        if (definition != null && !definition.definitionName.equals(def.definitionName)) {
+            CustomTxtTraceDefinition.delete(definition.definitionName);
+        }
+        def.save();
+        return true;
+    }
+
+    /**
+     * Adding the page to the wizard.
+     */
+
+    @Override
+       public void addPages() {
+        inputPage = new CustomTxtParserInputWizardPage(selection, definition);
+        addPage(inputPage);
+        outputPage = new CustomTxtParserOutputWizardPage(this);
+        addPage(outputPage);
+    }
+
+       @Override
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.selection = selection;
+    }
+
+}
index 11c6eb1c19629800b7620e5d8aaa57bd2731f584..58aa11eebcb433b72238160efcdd04790ff2711f 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.ByteArrayInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.InputStreamReader;\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.jface.viewers.AbstractTreeViewer;\r
-import org.eclipse.jface.viewers.ColumnLabelProvider;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.jface.viewers.TreeViewer;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.browser.Browser;\r
-import org.eclipse.swt.browser.TitleEvent;\r
-import org.eclipse.swt.browser.TitleListener;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.custom.StyleRange;\r
-import org.eclipse.swt.custom.StyledText;\r
-import org.eclipse.swt.events.ModifyEvent;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Combo;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Group;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.w3c.dom.NamedNodeMap;\r
-import org.w3c.dom.Node;\r
-import org.w3c.dom.NodeList;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-public class CustomXmlParserInputWizardPage extends WizardPage {\r
-\r
-    private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$\r
-    private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$\r
-    private static final Image elementImage = Activator.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$\r
-    private static final Image addImage = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$\r
-    private static final Image addNextImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$\r
-    private static final Image addChildImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$\r
-    private static final Image addManyImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$\r
-    private static final Image deleteImage = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$\r
-    private static final Image moveUpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$\r
-    private static final Image moveDownImage = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$\r
-    private static final Image helpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$\r
-    private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);\r
-    private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);\r
-    private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);\r
-\r
-    private final ISelection selection;\r
-    private CustomXmlTraceDefinition definition;\r
-    private String editDefinitionName;\r
-    private String defaultDescription;\r
-    private ElementNode selectedElement;\r
-    private Composite container;\r
-    private Text logtypeText;\r
-    private Text timeStampOutputFormatText;\r
-    private Text timeStampPreviewText;\r
-    private Button removeButton;\r
-    private Button addChildButton;\r
-    private Button addNextButton;\r
-    private Button moveUpButton;\r
-    private Button moveDownButton;\r
-    private Button feelingLuckyButton;\r
-    private ScrolledComposite treeScrolledComposite;\r
-    private ScrolledComposite elementScrolledComposite;\r
-    private TreeViewer treeViewer;\r
-    private Composite treeContainer;\r
-    private Composite elementContainer;\r
-    private Text errorText;\r
-    private StyledText inputText;\r
-    private Font fixedFont;\r
-    private UpdateListener updateListener;\r
-    private Browser helpBrowser;\r
-    private Element documentElement;\r
-\r
-    // variables used recursively through element traversal\r
-    private String timeStampValue;\r
-    private String timeStampFormat;\r
-    private boolean timeStampFound;\r
-    private int logEntriesCount;\r
-    private boolean logEntryFound;\r
-\r
-    protected CustomXmlParserInputWizardPage(ISelection selection, CustomXmlTraceDefinition definition) {\r
-        super("CustomXmlParserWizardPage"); //$NON-NLS-1$\r
-        if (definition == null) {\r
-            setTitle(Messages.CustomXmlParserInputWizardPage_titleNew);\r
-            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionNew;\r
-        } else {\r
-            setTitle(Messages.CustomXmlParserInputWizardPage_titleEdit);\r
-            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionEdit;\r
-        }\r
-        setDescription(defaultDescription);\r
-        this.selection = selection;\r
-        this.definition = definition;\r
-        if (definition != null) {\r
-            this.editDefinitionName = definition.definitionName;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void createControl(Composite parent) {\r
-        container = new Composite(parent, SWT.NULL);\r
-        container.setLayout(new GridLayout());\r
-\r
-        updateListener = new UpdateListener();\r
-\r
-        Composite headerComposite = new Composite(container, SWT.FILL);\r
-        GridLayout headerLayout = new GridLayout(5, false);\r
-        headerLayout.marginHeight = 0;\r
-        headerLayout.marginWidth = 0;\r
-        headerComposite.setLayout(headerLayout);\r
-        headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-        Label logtypeLabel = new Label(headerComposite, SWT.NULL);\r
-        logtypeLabel.setText(Messages.CustomXmlParserInputWizardPage_logType);\r
-\r
-        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
-        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));\r
-\r
-        Label timeStampFormatLabel = new Label(headerComposite, SWT.NULL);\r
-        timeStampFormatLabel.setText(Messages.CustomXmlParserInputWizardPage_timestampFormat);\r
-\r
-        timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
-        timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-        timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);\r
-\r
-        Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);\r
-        dateFormatHelpButton.setImage(helpImage);\r
-        dateFormatHelpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_dateFormatHelp);\r
-        dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                openHelpShell(SIMPLE_DATE_FORMAT_URL);\r
-            }\r
-        });\r
-\r
-        Label timeStampPreviewLabel = new Label(headerComposite, SWT.NULL);\r
-        timeStampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));\r
-        timeStampPreviewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);\r
-\r
-        timeStampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-        timeStampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));\r
-        timeStampPreviewText.setText("*no time stamp element or attribute*"); //$NON-NLS-1$\r
-\r
-        createButtonBar();\r
-\r
-        SashForm vSash = new SashForm(container, SWT.VERTICAL);\r
-        vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
-\r
-        SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);\r
-        hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-\r
-        treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);\r
-        treeScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        treeContainer = new Composite(treeScrolledComposite, SWT.NONE);\r
-        treeContainer.setLayout(new FillLayout());\r
-        treeScrolledComposite.setContent(treeContainer);\r
-        treeScrolledComposite.setExpandHorizontal(true);\r
-        treeScrolledComposite.setExpandVertical(true);\r
-\r
-        treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);\r
-        treeViewer.setContentProvider(new InputElementTreeNodeContentProvider());\r
-        treeViewer.setLabelProvider(new InputElementTreeLabelProvider());\r
-        treeViewer.addSelectionChangedListener(new InputElementTreeSelectionChangedListener());\r
-        treeContainer.layout();\r
-\r
-        treeScrolledComposite\r
-                .setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);\r
-\r
-        elementScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);\r
-        elementScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        elementContainer = new Composite(elementScrolledComposite, SWT.NONE);\r
-        GridLayout gl = new GridLayout();\r
-        gl.marginHeight = 1;\r
-        gl.marginWidth = 0;\r
-        elementContainer.setLayout(gl);\r
-        elementScrolledComposite.setContent(elementContainer);\r
-        elementScrolledComposite.setExpandHorizontal(true);\r
-        elementScrolledComposite.setExpandVertical(true);\r
-\r
-        if (definition == null) {\r
-            definition = new CustomXmlTraceDefinition();\r
-        }\r
-        loadDefinition(definition);\r
-        treeViewer.expandAll();\r
-        elementContainer.layout();\r
-\r
-        logtypeText.addModifyListener(updateListener);\r
-        timeStampOutputFormatText.addModifyListener(updateListener);\r
-\r
-        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-\r
-        hSash.setWeights(new int[] { 1, 2 });\r
-\r
-        if (definition.rootInputElement == null) {\r
-            removeButton.setEnabled(false);\r
-            addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);\r
-            addNextButton.setEnabled(false);\r
-            moveUpButton.setEnabled(false);\r
-            moveDownButton.setEnabled(false);\r
-        } else { // root is selected\r
-            addNextButton.setEnabled(false);\r
-        }\r
-\r
-        Composite sashBottom = new Composite(vSash, SWT.NONE);\r
-        GridLayout sashBottomLayout = new GridLayout(2, false);\r
-        sashBottomLayout.marginHeight = 0;\r
-        sashBottomLayout.marginWidth = 0;\r
-        sashBottom.setLayout(sashBottomLayout);\r
-\r
-        Label previewLabel = new Label(sashBottom, SWT.NULL);\r
-        previewLabel.setText(Messages.CustomXmlParserInputWizardPage_previewInput);\r
-\r
-        errorText = new Text(sashBottom, SWT.SINGLE | SWT.READ_ONLY);\r
-        errorText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-        errorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-        errorText.setVisible(false);\r
-\r
-        inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);\r
-        if (fixedFont == null) {\r
-            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$\r
-                fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            } else {\r
-                fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            }\r
-        }\r
-        inputText.setFont(fixedFont);\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);\r
-        gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;\r
-        gd.widthHint = 800;\r
-        inputText.setLayoutData(gd);\r
-        inputText.setText(getSelectionText());\r
-        inputText.addModifyListener(new ModifyListener() {\r
-            @Override\r
-            public void modifyText(ModifyEvent e) {\r
-                parseXmlInput(inputText.getText());\r
-            }\r
-        });\r
-        inputText.addModifyListener(updateListener);\r
-\r
-        vSash.setWeights(new int[] { hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y });\r
-\r
-        setControl(container);\r
-    }\r
-\r
-    private void createButtonBar() {\r
-        Composite buttonBar = new Composite(container, SWT.NONE);\r
-        GridLayout buttonBarLayout = new GridLayout(6, false);\r
-        buttonBarLayout.marginHeight = 0;\r
-        buttonBarLayout.marginWidth = 0;\r
-        buttonBar.setLayout(buttonBarLayout);\r
-\r
-        removeButton = new Button(buttonBar, SWT.PUSH);\r
-        removeButton.setImage(deleteImage);\r
-        removeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeElement);\r
-        removeButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty() || selectedElement == null) {\r
-                    return;\r
-                }\r
-                removeElement();\r
-                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputElement == definition.rootInputElement) {\r
-                    definition.rootInputElement = null;\r
-                } else {\r
-                    inputElement.parentElement.childElements.remove(inputElement);\r
-                }\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-                removeButton.setEnabled(false);\r
-                if (definition.rootInputElement == null) {\r
-                    addChildButton.setEnabled(true);\r
-                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentEleemnt);\r
-                } else {\r
-                    addChildButton.setEnabled(false);\r
-                }\r
-                addNextButton.setEnabled(false);\r
-                moveUpButton.setEnabled(false);\r
-                moveDownButton.setEnabled(false);\r
-            }\r
-        });\r
-\r
-        addChildButton = new Button(buttonBar, SWT.PUSH);\r
-        addChildButton.setImage(addChildImage);\r
-        addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);\r
-        addChildButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$\r
-                if (definition.rootInputElement == null) {\r
-                    definition.rootInputElement = inputElement;\r
-                    inputElement.elementName = getChildNameSuggestion(null);\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    InputElement parentInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    parentInputElement.addChild(inputElement);\r
-                    inputElement.elementName = getChildNameSuggestion(parentInputElement);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
-            }\r
-        });\r
-\r
-        addNextButton = new Button(buttonBar, SWT.PUSH);\r
-        addNextButton.setImage(addNextImage);\r
-        addNextButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addNextElement);\r
-        addNextButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$\r
-                if (definition.rootInputElement == null) {\r
-                    definition.rootInputElement = inputElement;\r
-                    inputElement.elementName = getChildNameSuggestion(null);\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    if (previousInputElement == definition.rootInputElement) {\r
-                        return;\r
-                    }\r
-                    previousInputElement.addNext(inputElement);\r
-                    inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
-            }\r
-        });\r
-\r
-        feelingLuckyButton = new Button(buttonBar, SWT.PUSH);\r
-        feelingLuckyButton.setImage(addManyImage);\r
-        feelingLuckyButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_feelingLucky);\r
-        feelingLuckyButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputElement inputElement = null;\r
-                if (definition.rootInputElement == null) {\r
-                    if (getChildNameSuggestion(null).length() != 0) {\r
-                        inputElement = new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$\r
-                        definition.rootInputElement = inputElement;\r
-                        feelingLucky(inputElement);\r
-                    } else {\r
-                        return;\r
-                    }\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    feelingLucky(inputElement);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
-                treeViewer.expandToLevel(inputElement, AbstractTreeViewer.ALL_LEVELS);\r
-            }\r
-        });\r
-\r
-        moveUpButton = new Button(buttonBar, SWT.PUSH);\r
-        moveUpButton.setImage(moveUpImage);\r
-        moveUpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveUp);\r
-        moveUpButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                }\r
-                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputElement == definition.rootInputElement) {\r
-                    return;\r
-                }\r
-                inputElement.moveUp();\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-\r
-        moveDownButton = new Button(buttonBar, SWT.PUSH);\r
-        moveDownButton.setImage(moveDownImage);\r
-        moveDownButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveDown);\r
-        moveDownButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                }\r
-                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputElement == definition.rootInputElement) {\r
-                    return;\r
-                }\r
-                inputElement.moveDown();\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-    }\r
-\r
-    private void feelingLucky(InputElement inputElement) {\r
-        while (true) {\r
-            String attributeName = getAttributeNameSuggestion(inputElement);\r
-            if (attributeName.length() == 0) {\r
-                break;\r
-            }\r
-            InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$\r
-            inputElement.addAttribute(attribute);\r
-        }\r
-        while (true) {\r
-            String childName = getChildNameSuggestion(inputElement);\r
-            if (childName.length() == 0) {\r
-                break;\r
-            }\r
-            InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$\r
-            inputElement.addChild(childElement);\r
-            feelingLucky(childElement);\r
-        }\r
-    }\r
-\r
-    private static class InputElementTreeNodeContentProvider implements ITreeContentProvider {\r
-\r
-        @Override\r
-        public Object[] getElements(Object inputElement) {\r
-            CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement;\r
-            if (def.rootInputElement != null) {\r
-                return new Object[] { def.rootInputElement };\r
-            }\r
-            return new Object[0];\r
-        }\r
-\r
-        @Override\r
-        public Object[] getChildren(Object parentElement) {\r
-            InputElement inputElement = (InputElement) parentElement;\r
-            if (inputElement.childElements == null) {\r
-                return new InputElement[0];\r
-            }\r
-            return inputElement.childElements.toArray();\r
-        }\r
-\r
-        @Override\r
-        public boolean hasChildren(Object element) {\r
-            InputElement inputElement = (InputElement) element;\r
-            return (inputElement.childElements != null && inputElement.childElements.size() > 0);\r
-        }\r
-\r
-        @Override\r
-        public void dispose() {\r
-        }\r
-\r
-        @Override\r
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-        }\r
-\r
-        @Override\r
-        public Object getParent(Object element) {\r
-            InputElement inputElement = (InputElement) element;\r
-            return inputElement.parentElement;\r
-        }\r
-    }\r
-\r
-    private static class InputElementTreeLabelProvider extends ColumnLabelProvider {\r
-\r
-        @Override\r
-        public Image getImage(Object element) {\r
-            return elementImage;\r
-        }\r
-\r
-        @Override\r
-        public String getText(Object element) {\r
-            InputElement inputElement = (InputElement) element;\r
-            return (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName; //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    private class InputElementTreeSelectionChangedListener implements ISelectionChangedListener {\r
-        @Override\r
-        public void selectionChanged(SelectionChangedEvent event) {\r
-            if (selectedElement != null) {\r
-                selectedElement.dispose();\r
-            }\r
-            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {\r
-                IStructuredSelection selection = (IStructuredSelection) event.getSelection();\r
-                InputElement inputElement = (InputElement) selection.getFirstElement();\r
-                selectedElement = new ElementNode(elementContainer, inputElement);\r
-                elementContainer.layout();\r
-                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-                container.layout();\r
-                validate();\r
-                updatePreviews();\r
-                removeButton.setEnabled(true);\r
-                addChildButton.setEnabled(true);\r
-                addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);\r
-                if (definition.rootInputElement == inputElement) {\r
-                    addNextButton.setEnabled(false);\r
-                } else {\r
-                    addNextButton.setEnabled(true);\r
-                }\r
-                moveUpButton.setEnabled(true);\r
-                moveDownButton.setEnabled(true);\r
-            } else {\r
-                removeButton.setEnabled(false);\r
-                if (definition.rootInputElement == null) {\r
-                    addChildButton.setEnabled(true);\r
-                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);\r
-                } else {\r
-                    addChildButton.setEnabled(false);\r
-                }\r
-                addNextButton.setEnabled(false);\r
-                moveUpButton.setEnabled(false);\r
-                moveDownButton.setEnabled(false);\r
-            }\r
-        }\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.eclipse.jface.dialogs.DialogPage#dispose()\r
-     */\r
-    @Override\r
-    public void dispose() {\r
-        if (fixedFont != null) {\r
-            fixedFont.dispose();\r
-            fixedFont = null;\r
-        }\r
-        super.dispose();\r
-    }\r
-\r
-    private void loadDefinition(CustomXmlTraceDefinition def) {\r
-        logtypeText.setText(def.definitionName);\r
-        timeStampOutputFormatText.setText(def.timeStampOutputFormat);\r
-        treeViewer.setInput(def);\r
-\r
-        if (def.rootInputElement != null) {\r
-            treeViewer.setSelection(new StructuredSelection(def.rootInputElement));\r
-        }\r
-    }\r
-\r
-    private String getName(InputElement inputElement) {\r
-        String name = (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName.trim(); //$NON-NLS-1$\r
-        if (inputElement.parentElement == null) {\r
-            return name;\r
-        }\r
-        return getName(inputElement.parentElement) + " : " + name; //$NON-NLS-1$\r
-    }\r
-\r
-    private String getName(InputAttribute inputAttribute, InputElement inputElement) {\r
-        String name = (inputAttribute.attributeName.trim().length() == 0) ? "?" : inputAttribute.attributeName.trim(); //$NON-NLS-1$\r
-        return getName(inputElement) + " : " + name; //$NON-NLS-1$\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)\r
-     */\r
-    @Override\r
-    public void setVisible(boolean visible) {\r
-        if (visible) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-        super.setVisible(visible);\r
-    }\r
-\r
-    public List<String> getInputNames() {\r
-        return getInputNames(definition.rootInputElement);\r
-    }\r
-\r
-    public List<String> getInputNames(InputElement inputElement) {\r
-        List<String> inputs = new ArrayList<String>();\r
-        if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {\r
-            String inputName = inputElement.inputName;\r
-            if (!inputs.contains(inputName)) {\r
-                inputs.add(inputName);\r
-            }\r
-        }\r
-        if (inputElement.attributes != null) {\r
-            for (InputAttribute attribute : inputElement.attributes) {\r
-                String inputName = attribute.inputName;\r
-                if (!inputs.contains(inputName)) {\r
-                    inputs.add(inputName);\r
-                }\r
-            }\r
-        }\r
-        if (inputElement.childElements != null) {\r
-            for (InputElement childInputElement : inputElement.childElements) {\r
-                for (String inputName : getInputNames(childInputElement)) {\r
-                    if (!inputs.contains(inputName)) {\r
-                        inputs.add(inputName);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return inputs;\r
-    }\r
-\r
-    private void removeElement() {\r
-        selectedElement.dispose();\r
-        selectedElement = null;\r
-        elementContainer.layout();\r
-        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-        container.layout();\r
-    }\r
-\r
-    private String getSelectionText() {\r
-        InputStream inputStream = null;\r
-        if (this.selection instanceof IStructuredSelection) {\r
-            Object selection = ((IStructuredSelection) this.selection).getFirstElement();\r
-            if (selection instanceof IFile) {\r
-                IFile file = (IFile) selection;\r
-                try {\r
-                    inputStream = file.getContents();\r
-                } catch (CoreException e) {\r
-                    return ""; //$NON-NLS-1$\r
-                }\r
-            }\r
-        }\r
-        if (inputStream != null) {\r
-            BufferedReader reader = null;\r
-            try {\r
-                reader = new BufferedReader(new InputStreamReader(inputStream));\r
-                StringBuilder sb = new StringBuilder();\r
-                String line = null;\r
-                while ((line = reader.readLine()) != null) {\r
-                    sb.append(line + "\n"); //$NON-NLS-1$\r
-                }\r
-                parseXmlInput(sb.toString());\r
-                reader.close();\r
-                return sb.toString();\r
-            } catch (IOException e) {\r
-                return ""; //$NON-NLS-1$\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private void parseXmlInput(final String string) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver() {\r
-                @Override\r
-                public InputSource resolveEntity(String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler() {\r
-                @Override\r
-                public void error(SAXParseException saxparseexception) throws SAXException {\r
-                }\r
-\r
-                @Override\r
-                public void warning(SAXParseException saxparseexception) throws SAXException {\r
-                }\r
-\r
-                @Override\r
-                public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    if (string.trim().length() != 0) {\r
-                        errorText.setText(saxparseexception.getMessage());\r
-                        errorText.setBackground(COLOR_LIGHT_RED);\r
-                        errorText.setVisible(true);\r
-                    }\r
-                    throw saxparseexception;\r
-                }\r
-            });\r
-\r
-            errorText.setVisible(false);\r
-            Document doc = null;\r
-            doc = db.parse(new ByteArrayInputStream(string.getBytes()));\r
-            documentElement = doc.getDocumentElement();\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$\r
-            documentElement = null;\r
-        } catch (SAXException e) {\r
-            documentElement = null;\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$\r
-            documentElement = null;\r
-        }\r
-    }\r
-\r
-    private void updatePreviews() {\r
-        updatePreviews(false);\r
-    }\r
-\r
-    private void initValues() {\r
-        timeStampValue = null;\r
-        timeStampFormat = null;\r
-        logEntriesCount = 0;\r
-        logEntryFound = false;\r
-    }\r
-\r
-    private void updatePreviews(boolean updateAll) {\r
-        if (inputText == null) {\r
-            // early update during construction\r
-            return;\r
-        }\r
-        inputText.setStyleRanges(new StyleRange[] {});\r
-        if (selectedElement == null) {\r
-            return;\r
-        }\r
-\r
-        initValues();\r
-\r
-        selectedElement.updatePreview();\r
-\r
-        if (timeStampValue != null && timeStampFormat != null) {\r
-            try {\r
-                SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampFormat);\r
-                Date date = dateFormat.parse(timeStampValue);\r
-                dateFormat = new SimpleDateFormat(timeStampOutputFormatText.getText().trim());\r
-                timeStampPreviewText.setText(dateFormat.format(date));\r
-            } catch (ParseException e) {\r
-                timeStampPreviewText.setText("*parse exception* [" + timeStampValue + "] <> [" + timeStampFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-            } catch (IllegalArgumentException e) {\r
-                timeStampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$\r
-            }\r
-        } else {\r
-            timeStampPreviewText.setText("*no matching time stamp*"); //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    private void openHelpShell(String url) {\r
-        if (helpBrowser != null && !helpBrowser.isDisposed()) {\r
-            helpBrowser.getShell().setActive();\r
-            if (!helpBrowser.getUrl().equals(url)) {\r
-                helpBrowser.setUrl(url);\r
-            }\r
-            return;\r
-        }\r
-        final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);\r
-        helpShell.setLayout(new FillLayout());\r
-        helpBrowser = new Browser(helpShell, SWT.NONE);\r
-        helpBrowser.addTitleListener(new TitleListener() {\r
-            @Override\r
-            public void changed(TitleEvent event) {\r
-                helpShell.setText(event.title);\r
-            }\r
-        });\r
-        helpBrowser.setBounds(0, 0, 600, 400);\r
-        helpShell.pack();\r
-        helpShell.open();\r
-        helpBrowser.setUrl(url);\r
-    }\r
-\r
-    private class UpdateListener implements ModifyListener, SelectionListener {\r
-\r
-        @Override\r
-        public void modifyText(ModifyEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-        @Override\r
-        public void widgetDefaultSelected(SelectionEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-        @Override\r
-        public void widgetSelected(SelectionEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-    }\r
-\r
-    private class ElementNode {\r
-        final InputElement inputElement;\r
-        final Group group;\r
-        List<Attribute> attributes = new ArrayList<Attribute>();\r
-        List<ElementNode> childElements = new ArrayList<ElementNode>();\r
-        Text elementNameText;\r
-        Composite tagComposite;\r
-        Combo tagCombo;\r
-        Label tagLabel;\r
-        Text tagText;\r
-        Combo actionCombo;\r
-        Label previewLabel;\r
-        Text previewText;\r
-        Button logEntryButton;\r
-        Label fillerLabel;\r
-        Composite addAttributeComposite;\r
-        Button addAttributeButton;\r
-        Label addAttributeLabel;\r
-\r
-        public ElementNode(Composite parent, InputElement inputElement) {\r
-            this.inputElement = inputElement;\r
-\r
-            group = new Group(parent, SWT.NONE);\r
-            GridLayout gl = new GridLayout(2, false);\r
-            gl.marginHeight = 0;\r
-            group.setLayout(gl);\r
-            group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            group.setText(getName(inputElement));\r
-\r
-            Label label = new Label(group, SWT.NULL);\r
-            label.setText(Messages.CustomXmlParserInputWizardPage_elementName);\r
-            label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            elementNameText = new Text(group, SWT.BORDER | SWT.SINGLE);\r
-            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            elementNameText.setLayoutData(gd);\r
-            elementNameText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    ElementNode.this.inputElement.elementName = elementNameText.getText().trim();\r
-                    group.setText(getName(ElementNode.this.inputElement));\r
-                }\r
-            });\r
-            elementNameText.setText(inputElement.elementName);\r
-            elementNameText.addModifyListener(updateListener);\r
-\r
-            if (inputElement.parentElement != null) {\r
-                previewLabel = new Label(group, SWT.NULL);\r
-                previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-                previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);\r
-\r
-                previewText = new Text(group, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-                gd.widthHint = 0;\r
-                previewText.setLayoutData(gd);\r
-                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);\r
-                previewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-\r
-                logEntryButton = new Button(group, SWT.CHECK);\r
-                logEntryButton.setText(Messages.CustomXmlParserInputWizardPage_logEntry);\r
-                logEntryButton.setSelection(inputElement.logEntry);\r
-                logEntryButton.addSelectionListener(new SelectionListener() {\r
-                    @Override\r
-                    public void widgetDefaultSelected(SelectionEvent e) {\r
-                    }\r
-\r
-                    @Override\r
-                    public void widgetSelected(SelectionEvent e) {\r
-                        InputElement parent = ElementNode.this.inputElement.parentElement;\r
-                        while (parent != null) {\r
-                            parent.logEntry = false;\r
-                            parent = parent.parentElement;\r
-                        }\r
-                    }\r
-                });\r
-                logEntryButton.addSelectionListener(updateListener);\r
-\r
-                tagComposite = new Composite(group, SWT.FILL);\r
-                GridLayout tagLayout = new GridLayout(4, false);\r
-                tagLayout.marginWidth = 0;\r
-                tagLayout.marginHeight = 0;\r
-                tagComposite.setLayout(tagLayout);\r
-                tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-                tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-                tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomTraceDefinition.TAG_TIMESTAMP,\r
-                        CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });\r
-                tagCombo.setVisibleItemCount(tagCombo.getItemCount());\r
-                tagCombo.addSelectionListener(new SelectionListener() {\r
-                    @Override\r
-                    public void widgetDefaultSelected(SelectionEvent e) {\r
-                    }\r
-\r
-                    @Override\r
-                    public void widgetSelected(SelectionEvent e) {\r
-                        tagText.removeModifyListener(updateListener);\r
-                        switch (tagCombo.getSelectionIndex()) {\r
-                        case 0: // Ignore\r
-                            tagLabel.setVisible(false);\r
-                            tagText.setVisible(false);\r
-                            actionCombo.setVisible(false);\r
-                            break;\r
-                        case 1: // Time Stamp\r
-                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                            tagLabel.setVisible(true);\r
-                            tagText.setVisible(true);\r
-                            tagText.addModifyListener(updateListener);\r
-                            actionCombo.setVisible(true);\r
-                            break;\r
-                        case 2: // Message\r
-                            tagLabel.setVisible(false);\r
-                            tagText.setVisible(false);\r
-                            actionCombo.setVisible(true);\r
-                            break;\r
-                        case 3: // Other\r
-                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                            tagLabel.setVisible(true);\r
-                            if (tagText.getText().trim().length() == 0) {\r
-                                tagText.setText(elementNameText.getText().trim());\r
-                            }\r
-                            tagText.setVisible(true);\r
-                            tagText.addModifyListener(updateListener);\r
-                            actionCombo.setVisible(true);\r
-                            break;\r
-                        default:\r
-                            break;\r
-                        }\r
-                        tagComposite.layout();\r
-                        validate();\r
-                        updatePreviews();\r
-                    }\r
-                });\r
-\r
-                tagLabel = new Label(tagComposite, SWT.NULL);\r
-                tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-                tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);\r
-                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-                gd.widthHint = 0;\r
-                tagText.setLayoutData(gd);\r
-\r
-                actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-                actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,\r
-                        Messages.CustomXmlParserInputWizardPage_appendWith });\r
-                actionCombo.select(inputElement.inputAction);\r
-                actionCombo.addSelectionListener(updateListener);\r
-\r
-                if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {\r
-                    tagCombo.select(0);\r
-                    tagLabel.setVisible(false);\r
-                    tagText.setVisible(false);\r
-                    actionCombo.setVisible(false);\r
-                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                    tagCombo.select(1);\r
-                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                    tagText.setText(inputElement.inputFormat);\r
-                    tagText.addModifyListener(updateListener);\r
-                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
-                    tagCombo.select(2);\r
-                    tagLabel.setVisible(false);\r
-                    tagText.setVisible(false);\r
-                } else {\r
-                    tagCombo.select(3);\r
-                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                    tagText.setText(inputElement.inputName);\r
-                    tagText.addModifyListener(updateListener);\r
-                }\r
-            }\r
-\r
-            if (inputElement.attributes != null) {\r
-                for (InputAttribute inputAttribute : inputElement.attributes) {\r
-                    Attribute attribute = new Attribute(group, this, inputAttribute, attributes.size() + 1);\r
-                    attributes.add(attribute);\r
-                }\r
-            }\r
-\r
-            createAddButton();\r
-        }\r
-\r
-        private void updatePreview() {\r
-            Element element = getPreviewElement(inputElement);\r
-            if (inputElement.parentElement != null) { // no preview text for\r
-                                                      // document element\r
-                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);\r
-                if (element != null) {\r
-                    previewText.setText(CustomXmlTrace.parseElement(element, new StringBuffer()).toString());\r
-                    if (logEntryButton.getSelection()) {\r
-                        if (!logEntryFound) {\r
-                            logEntryFound = true;\r
-                            logEntriesCount++;\r
-                        } else {\r
-                            logEntryButton.setSelection(false); // remove nested\r
-                                                                // log entry\r
-                        }\r
-                    }\r
-                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
-                        String value = previewText.getText().trim();\r
-                        if (value.length() != 0) {\r
-                            if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {\r
-                                timeStampValue = value;\r
-                                timeStampFormat = tagText.getText().trim();\r
-                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += value;\r
-                                    timeStampFormat += tagText.getText().trim();\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = tagText.getText().trim();\r
-                                }\r
-                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += " | " + value; //$NON-NLS-1$\r
-                                    timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = tagText.getText().trim();\r
-                                }\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            for (Attribute attribute : attributes) {\r
-                if (element != null) {\r
-                    String value = element.getAttribute(attribute.attributeNameText.getText().trim());\r
-                    if (value.length() != 0) {\r
-                        attribute.previewText.setText(value);\r
-                        if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
-                            if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {\r
-                                timeStampValue = value;\r
-                                timeStampFormat = attribute.tagText.getText().trim();\r
-                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += value;\r
-                                    timeStampFormat += attribute.tagText.getText().trim();\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = attribute.tagText.getText().trim();\r
-                                }\r
-                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += " | " + value; //$NON-NLS-1$\r
-                                    timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = attribute.tagText.getText().trim();\r
-                                }\r
-                            }\r
-                        }\r
-                    } else {\r
-                        attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingAttribute);\r
-                    }\r
-                } else {\r
-                    attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);\r
-                }\r
-            }\r
-            for (ElementNode child : childElements) {\r
-                child.updatePreview();\r
-            }\r
-            if (logEntryButton != null && logEntryButton.getSelection()) {\r
-                logEntryFound = false;\r
-            }\r
-        }\r
-\r
-        private void createAddButton() {\r
-            fillerLabel = new Label(group, SWT.NONE);\r
-\r
-            addAttributeComposite = new Composite(group, SWT.NONE);\r
-            addAttributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            GridLayout addAttributeLayout = new GridLayout(2, false);\r
-            addAttributeLayout.marginHeight = 0;\r
-            addAttributeLayout.marginWidth = 0;\r
-            addAttributeComposite.setLayout(addAttributeLayout);\r
-\r
-            addAttributeButton = new Button(addAttributeComposite, SWT.PUSH);\r
-            addAttributeButton.setImage(addImage);\r
-            addAttributeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addAttribute);\r
-            addAttributeButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    removeAddButton();\r
-                    String attributeName = getAttributeNameSuggestion(inputElement);\r
-                    InputAttribute inputAttribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$\r
-                    attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));\r
-                    createAddButton();\r
-                    elementContainer.layout();\r
-                    elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                            elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-                    group.getParent().layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            addAttributeLabel = new Label(addAttributeComposite, SWT.NULL);\r
-            addAttributeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            addAttributeLabel.setText(Messages.CustomXmlParserInputWizardPage_newAttibute);\r
-        }\r
-\r
-        private void removeAddButton() {\r
-            fillerLabel.dispose();\r
-            addAttributeComposite.dispose();\r
-        }\r
-\r
-        private void removeAttribute(int attributeNumber) {\r
-            if (--attributeNumber < attributes.size()) {\r
-                attributes.remove(attributeNumber).dispose();\r
-                for (int i = attributeNumber; i < attributes.size(); i++) {\r
-                    attributes.get(i).setAttributeNumber(i + 1);\r
-                }\r
-                elementContainer.layout();\r
-                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-                group.getParent().layout();\r
-            }\r
-        }\r
-\r
-        private void dispose() {\r
-            group.dispose();\r
-        }\r
-\r
-        private void extractInputs() {\r
-            inputElement.elementName = elementNameText.getText().trim();\r
-            if (inputElement.parentElement != null) {\r
-                inputElement.logEntry = logEntryButton.getSelection();\r
-                if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
-                    inputElement.inputName = tagText.getText().trim();\r
-                } else {\r
-                    inputElement.inputName = tagCombo.getText();\r
-                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        inputElement.inputFormat = tagText.getText().trim();\r
-                    }\r
-                }\r
-                inputElement.inputAction = actionCombo.getSelectionIndex();\r
-            }\r
-            inputElement.attributes = new ArrayList<InputAttribute>(attributes.size());\r
-            for (int i = 0; i < attributes.size(); i++) {\r
-                Attribute attribute = attributes.get(i);\r
-                InputAttribute inputAttribute = new InputAttribute();\r
-                inputAttribute.attributeName = attribute.attributeNameText.getText().trim();\r
-                if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
-                    inputAttribute.inputName = attribute.tagText.getText().trim();\r
-                } else {\r
-                    inputAttribute.inputName = attribute.tagCombo.getText();\r
-                    if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        inputAttribute.inputFormat = attribute.tagText.getText().trim();\r
-                    }\r
-                }\r
-                inputAttribute.inputAction = attribute.actionCombo.getSelectionIndex();\r
-                inputElement.addAttribute(inputAttribute);\r
-            }\r
-        }\r
-    }\r
-\r
-    private class Attribute {\r
-        ElementNode element;\r
-        int attributeNumber;\r
-\r
-        // children of parent (must be disposed)\r
-        Composite labelComposite;\r
-        Composite attributeComposite;\r
-        Label filler;\r
-        Composite tagComposite;\r
-\r
-        // children of labelComposite\r
-        Label attributeLabel;\r
-\r
-        // children of attributeComposite\r
-        Text attributeNameText;\r
-        Text previewText;\r
-\r
-        // children of tagComposite\r
-        Combo tagCombo;\r
-        Label tagLabel;\r
-        Text tagText;\r
-        Combo actionCombo;\r
-\r
-        public Attribute(Composite parent, ElementNode element, InputAttribute inputAttribute, int attributeNumber) {\r
-            this.element = element;\r
-            this.attributeNumber = attributeNumber;\r
-\r
-            labelComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout labelLayout = new GridLayout(2, false);\r
-            labelLayout.marginWidth = 0;\r
-            labelLayout.marginHeight = 0;\r
-            labelComposite.setLayout(labelLayout);\r
-            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            Button deleteButton = new Button(labelComposite, SWT.PUSH);\r
-            deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            deleteButton.setImage(deleteImage);\r
-            deleteButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeAttribute);\r
-            deleteButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    Attribute.this.element.removeAttribute(Attribute.this.attributeNumber);\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            attributeLabel = new Label(labelComposite, SWT.NULL);\r
-            attributeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            attributeLabel.setText(Messages.CustomXmlParserInputWizardPage_attibute);\r
-\r
-            attributeComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout attributeLayout = new GridLayout(4, false);\r
-            attributeLayout.marginWidth = 0;\r
-            attributeLayout.marginHeight = 0;\r
-            attributeComposite.setLayout(attributeLayout);\r
-            attributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            Label nameLabel = new Label(attributeComposite, SWT.NONE);\r
-            nameLabel.setText(Messages.CustomXmlParserInputWizardPage_name);\r
-\r
-            attributeNameText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE);\r
-            attributeNameText.setLayoutData(new GridData(120, SWT.DEFAULT));\r
-            attributeNameText.setText(inputAttribute.attributeName);\r
-            attributeNameText.addModifyListener(updateListener);\r
-\r
-            Label previewLabel = new Label(attributeComposite, SWT.NONE);\r
-            previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);\r
-\r
-            previewText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            previewText.setLayoutData(gd);\r
-            previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatch);\r
-            previewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-\r
-            filler = new Label(parent, SWT.NULL);\r
-\r
-            tagComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout tagLayout = new GridLayout(4, false);\r
-            tagLayout.marginWidth = 0;\r
-            tagLayout.marginHeight = 0;\r
-            tagComposite.setLayout(tagLayout);\r
-            tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_MESSAGE,\r
-                    CustomTraceDefinition.TAG_OTHER });\r
-            tagCombo.select(2); // Other\r
-            tagCombo.addSelectionListener(new SelectionListener() {\r
-                @Override\r
-                public void widgetDefaultSelected(SelectionEvent e) {\r
-                }\r
-\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    tagText.removeModifyListener(updateListener);\r
-                    switch (tagCombo.getSelectionIndex()) {\r
-                    case 0: // Time Stamp\r
-                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                        tagLabel.setVisible(true);\r
-                        tagText.setVisible(true);\r
-                        tagText.addModifyListener(updateListener);\r
-                        break;\r
-                    case 1: // Message\r
-                        tagLabel.setVisible(false);\r
-                        tagText.setVisible(false);\r
-                        break;\r
-                    case 2: // Other\r
-                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                        tagLabel.setVisible(true);\r
-                        if (tagText.getText().trim().length() == 0) {\r
-                            tagText.setText(attributeNameText.getText().trim());\r
-                        }\r
-                        tagText.setVisible(true);\r
-                        tagText.addModifyListener(updateListener);\r
-                        break;\r
-                    default:\r
-                        break;\r
-                    }\r
-                    tagComposite.layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            tagLabel = new Label(tagComposite, SWT.NULL);\r
-            tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);\r
-            gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            tagText.setLayoutData(gd);\r
-            tagText.setText(attributeNameText.getText());\r
-\r
-            actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,\r
-                    Messages.CustomXmlParserInputWizardPage_appendWith });\r
-            actionCombo.select(inputAttribute.inputAction);\r
-            actionCombo.addSelectionListener(updateListener);\r
-\r
-            if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                tagCombo.select(0);\r
-                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                tagText.setText(inputAttribute.inputFormat);\r
-                tagText.addModifyListener(updateListener);\r
-            } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
-                tagCombo.select(1);\r
-                tagLabel.setVisible(false);\r
-                tagText.setVisible(false);\r
-            } else {\r
-                tagCombo.select(2);\r
-                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                tagText.setText(inputAttribute.inputName);\r
-                tagText.addModifyListener(updateListener);\r
-            }\r
-        }\r
-\r
-        private void dispose() {\r
-            labelComposite.dispose();\r
-            attributeComposite.dispose();\r
-            filler.dispose();\r
-            tagComposite.dispose();\r
-        }\r
-\r
-        private void setAttributeNumber(int attributeNumber) {\r
-            this.attributeNumber = attributeNumber;\r
-            labelComposite.layout();\r
-        }\r
-    }\r
-\r
-    private Element getPreviewElement(InputElement inputElement) {\r
-        Element element = documentElement;\r
-        if (element != null) {\r
-            if (!documentElement.getNodeName().equals(definition.rootInputElement.elementName)) {\r
-                return null;\r
-            }\r
-            ArrayList<String> elementNames = new ArrayList<String>();\r
-            while (inputElement != null) {\r
-                elementNames.add(inputElement.elementName);\r
-                inputElement = inputElement.parentElement;\r
-            }\r
-            for (int i = elementNames.size() - 1; --i >= 0;) {\r
-                NodeList childList = element.getChildNodes();\r
-                element = null;\r
-                for (int j = 0; j < childList.getLength(); j++) {\r
-                    Node child = childList.item(j);\r
-                    if (child instanceof Element && child.getNodeName().equals(elementNames.get(i))) {\r
-                        element = (Element) child;\r
-                        break;\r
-                    }\r
-                }\r
-                if (element == null) {\r
-                    break;\r
-                }\r
-            }\r
-            if (element != null) {\r
-                return element;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    private String getChildNameSuggestion(InputElement inputElement) {\r
-        if (inputElement == null) {\r
-            if (documentElement != null) {\r
-                return documentElement.getNodeName();\r
-            }\r
-        } else {\r
-            Element element = getPreviewElement(inputElement);\r
-            if (element != null) {\r
-                NodeList childNodes = element.getChildNodes();\r
-                for (int i = 0; i < childNodes.getLength(); i++) {\r
-                    Node node = childNodes.item(i);\r
-                    if (node instanceof Element) {\r
-                        boolean unused = true;\r
-                        if (inputElement.childElements != null) {\r
-                            for (InputElement child : inputElement.childElements) {\r
-                                if (child.elementName.equals(node.getNodeName())) {\r
-                                    unused = false;\r
-                                    break;\r
-                                }\r
-                            }\r
-                        }\r
-                        if (unused) {\r
-                            return node.getNodeName();\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private String getAttributeNameSuggestion(InputElement inputElement) {\r
-        Element element = getPreviewElement(inputElement);\r
-        if (element != null) {\r
-            NamedNodeMap attributeMap = element.getAttributes();\r
-            for (int i = 0; i < attributeMap.getLength(); i++) {\r
-                Node node = attributeMap.item(i);\r
-                boolean unused = true;\r
-                if (inputElement.attributes != null) {\r
-                    for (InputAttribute attribute : inputElement.attributes) {\r
-                        if (attribute.attributeName.equals(node.getNodeName())) {\r
-                            unused = false;\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-                if (unused) {\r
-                    return node.getNodeName();\r
-                }\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private void validate() {\r
-        definition.definitionName = logtypeText.getText().trim();\r
-        definition.timeStampOutputFormat = timeStampOutputFormatText.getText().trim();\r
-\r
-        if (selectedElement != null) {\r
-            selectedElement.extractInputs();\r
-            treeViewer.refresh();\r
-        }\r
-\r
-        StringBuffer errors = new StringBuffer();\r
-\r
-        if (definition.definitionName.length() == 0) {\r
-            errors.append(Messages.CustomXmlParserInputWizardPage_emptyLogTypeError);\r
-            logtypeText.setBackground(COLOR_LIGHT_RED);\r
-        } else {\r
-            logtypeText.setBackground(COLOR_TEXT_BACKGROUND);\r
-            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                if (definition.definitionName.equals(def.definitionName)) {\r
-                    if (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName)) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicatelogTypeError);\r
-                        logtypeText.setBackground(COLOR_LIGHT_RED);\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        if (definition.rootInputElement == null) {\r
-            errors.append(Messages.CustomXmlParserInputWizardPage_noDocumentError);\r
-        }\r
-\r
-        if (definition.rootInputElement != null) {\r
-            logEntryFound = false;\r
-            timeStampFound = false;\r
-\r
-            errors.append(validateElement(definition.rootInputElement));\r
-\r
-            if ((definition.rootInputElement.attributes != null && definition.rootInputElement.attributes.size() != 0)\r
-                    || (definition.rootInputElement.childElements != null && definition.rootInputElement.childElements.size() != 0)\r
-                    || errors.length() == 0) {\r
-                if (!logEntryFound) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);\r
-                }\r
-\r
-                if (timeStampFound) {\r
-                    if (timeStampOutputFormatText.getText().trim().length() == 0) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampFmtError);\r
-                        timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
-                    } else {\r
-                        try {\r
-                            new SimpleDateFormat(timeStampOutputFormatText.getText().trim());\r
-                            timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                        } catch (IllegalArgumentException e) {\r
-                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError);\r
-                            timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                } else {\r
-                    timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);\r
-                }\r
-            }\r
-        } else {\r
-            timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);\r
-        }\r
-\r
-        if (errors.length() == 0) {\r
-            setDescription(defaultDescription);\r
-            setPageComplete(true);\r
-        } else {\r
-            setDescription(errors.toString());\r
-            setPageComplete(false);\r
-        }\r
-    }\r
-\r
-    public StringBuffer validateElement(InputElement inputElement) {\r
-        StringBuffer errors = new StringBuffer();\r
-        ElementNode elementNode = null;\r
-        if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) {\r
-            elementNode = selectedElement;\r
-        }\r
-        if (inputElement == definition.rootInputElement) {\r
-            if (inputElement.elementName.length() == 0) {\r
-                errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);\r
-                if (elementNode != null) {\r
-                    elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                }\r
-            } else {\r
-                if (elementNode != null) {\r
-                    elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-        }\r
-        if (inputElement != definition.rootInputElement) {\r
-            if (inputElement.logEntry) {\r
-                logEntryFound = true;\r
-            }\r
-            if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                timeStampFound = true;\r
-                if (inputElement.inputFormat.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    try {\r
-                        new SimpleDateFormat(inputElement.inputFormat);\r
-                        if (elementNode != null) {\r
-                            elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                        }\r
-                    } catch (IllegalArgumentException e) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError\r
-                                + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (elementNode != null) {\r
-                            elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-            } else if (inputElement.inputName.length() == 0) {\r
-                errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError);\r
-                if (elementNode != null) {\r
-                    elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
-                }\r
-            } else {\r
-                if (elementNode != null) {\r
-                    elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-        }\r
-        if (inputElement.attributes != null) {\r
-            if (elementNode != null) {\r
-                for (Attribute attribute : elementNode.attributes) {\r
-                    attribute.attributeNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-            for (int i = 0; i < inputElement.attributes.size(); i++) {\r
-                InputAttribute attribute = inputElement.attributes.get(i);\r
-                boolean duplicate = false;\r
-                for (int j = i + 1; j < inputElement.attributes.size(); j++) {\r
-                    InputAttribute otherAttribute = inputElement.attributes.get(j);\r
-                    if (otherAttribute.attributeName.equals(attribute.attributeName)) {\r
-                        duplicate = true;\r
-                        if (elementNode != null) {\r
-                            elementNode.attributes.get(j).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-                if (attribute.attributeName.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else if (duplicate) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                }\r
-                if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                    timeStampFound = true;\r
-                    if (attribute.inputFormat.length() == 0) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError\r
-                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (elementNode != null) {\r
-                            elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    } else {\r
-                        try {\r
-                            new SimpleDateFormat(attribute.inputFormat);\r
-                            if (elementNode != null) {\r
-                                elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                            }\r
-                        } catch (IllegalArgumentException e) {\r
-                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError\r
-                                    + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                            if (elementNode != null) {\r
-                                elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
-                            }\r
-                        }\r
-                    }\r
-                } else if (attribute.inputName.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        if (inputElement.childElements != null) {\r
-            for (InputElement child : inputElement.childElements) {\r
-                ElementNode childElementNode = null;\r
-                if (selectedElement != null && selectedElement.inputElement.equals(child)) {\r
-                    childElementNode = selectedElement;\r
-                }\r
-                if (childElementNode != null) {\r
-                    childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-            for (int i = 0; i < inputElement.childElements.size(); i++) {\r
-                InputElement child = inputElement.childElements.get(i);\r
-                ElementNode childElementNode = null;\r
-                if (selectedElement != null && selectedElement.inputElement.equals(child)) {\r
-                    childElementNode = selectedElement;\r
-                }\r
-                if (child.elementName.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (childElementNode != null) {\r
-                        childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    boolean duplicate = false;\r
-                    for (int j = i + 1; j < inputElement.childElements.size(); j++) {\r
-                        InputElement otherChild = inputElement.childElements.get(j);\r
-                        if (otherChild.elementName.equals(child.elementName)) {\r
-                            duplicate = true;\r
-                            ElementNode otherChildElementNode = null;\r
-                            if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) {\r
-                                otherChildElementNode = selectedElement;\r
-                            }\r
-                            if (otherChildElementNode != null) {\r
-                                otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                            }\r
-                        }\r
-                    }\r
-                    if (duplicate) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError\r
-                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (childElementNode != null) {\r
-                            childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-\r
-                errors.append(validateElement(child));\r
-            }\r
-        }\r
-        return errors;\r
-    }\r
-\r
-    public CustomXmlTraceDefinition getDefinition() {\r
-        return definition;\r
-    }\r
-\r
-    public char[] getInputText() {\r
-        return inputText.getText().toCharArray();\r
-    }\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.TitleEvent;
+import org.eclipse.swt.browser.TitleListener;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class CustomXmlParserInputWizardPage extends WizardPage {
+
+    private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
+    private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$
+    private static final Image elementImage = Activator.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$
+    private static final Image addImage = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
+    private static final Image addNextImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
+    private static final Image addChildImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
+    private static final Image addManyImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$
+    private static final Image deleteImage = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
+    private static final Image moveUpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
+    private static final Image moveDownImage = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
+    private static final Image helpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
+    private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);
+    private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
+    private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+
+    private final ISelection selection;
+    private CustomXmlTraceDefinition definition;
+    private String editDefinitionName;
+    private String defaultDescription;
+    private ElementNode selectedElement;
+    private Composite container;
+    private Text logtypeText;
+    private Text timeStampOutputFormatText;
+    private Text timeStampPreviewText;
+    private Button removeButton;
+    private Button addChildButton;
+    private Button addNextButton;
+    private Button moveUpButton;
+    private Button moveDownButton;
+    private Button feelingLuckyButton;
+    private ScrolledComposite treeScrolledComposite;
+    private ScrolledComposite elementScrolledComposite;
+    private TreeViewer treeViewer;
+    private Composite treeContainer;
+    private Composite elementContainer;
+    private Text errorText;
+    private StyledText inputText;
+    private Font fixedFont;
+    private UpdateListener updateListener;
+    private Browser helpBrowser;
+    private Element documentElement;
+
+    // variables used recursively through element traversal
+    private String timeStampValue;
+    private String timeStampFormat;
+    private boolean timeStampFound;
+    private int logEntriesCount;
+    private boolean logEntryFound;
+
+    protected CustomXmlParserInputWizardPage(ISelection selection, CustomXmlTraceDefinition definition) {
+        super("CustomXmlParserWizardPage"); //$NON-NLS-1$
+        if (definition == null) {
+            setTitle(Messages.CustomXmlParserInputWizardPage_titleNew);
+            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionNew;
+        } else {
+            setTitle(Messages.CustomXmlParserInputWizardPage_titleEdit);
+            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionEdit;
+        }
+        setDescription(defaultDescription);
+        this.selection = selection;
+        this.definition = definition;
+        if (definition != null) {
+            this.editDefinitionName = definition.definitionName;
+        }
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        container = new Composite(parent, SWT.NULL);
+        container.setLayout(new GridLayout());
+
+        updateListener = new UpdateListener();
+
+        Composite headerComposite = new Composite(container, SWT.FILL);
+        GridLayout headerLayout = new GridLayout(5, false);
+        headerLayout.marginHeight = 0;
+        headerLayout.marginWidth = 0;
+        headerComposite.setLayout(headerLayout);
+        headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+        Label logtypeLabel = new Label(headerComposite, SWT.NULL);
+        logtypeLabel.setText(Messages.CustomXmlParserInputWizardPage_logType);
+
+        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));
+
+        Label timeStampFormatLabel = new Label(headerComposite, SWT.NULL);
+        timeStampFormatLabel.setText(Messages.CustomXmlParserInputWizardPage_timestampFormat);
+
+        timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
+
+        Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);
+        dateFormatHelpButton.setImage(helpImage);
+        dateFormatHelpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_dateFormatHelp);
+        dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                openHelpShell(SIMPLE_DATE_FORMAT_URL);
+            }
+        });
+
+        Label timeStampPreviewLabel = new Label(headerComposite, SWT.NULL);
+        timeStampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
+        timeStampPreviewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
+
+        timeStampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+        timeStampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+        timeStampPreviewText.setText("*no time stamp element or attribute*"); //$NON-NLS-1$
+
+        createButtonBar();
+
+        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));
+
+        SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);
+        hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);
+        treeScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        treeContainer = new Composite(treeScrolledComposite, SWT.NONE);
+        treeContainer.setLayout(new FillLayout());
+        treeScrolledComposite.setContent(treeContainer);
+        treeScrolledComposite.setExpandHorizontal(true);
+        treeScrolledComposite.setExpandVertical(true);
+
+        treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);
+        treeViewer.setContentProvider(new InputElementTreeNodeContentProvider());
+        treeViewer.setLabelProvider(new InputElementTreeLabelProvider());
+        treeViewer.addSelectionChangedListener(new InputElementTreeSelectionChangedListener());
+        treeContainer.layout();
+
+        treeScrolledComposite
+                .setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+
+        elementScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);
+        elementScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        elementContainer = new Composite(elementScrolledComposite, SWT.NONE);
+        GridLayout gl = new GridLayout();
+        gl.marginHeight = 1;
+        gl.marginWidth = 0;
+        elementContainer.setLayout(gl);
+        elementScrolledComposite.setContent(elementContainer);
+        elementScrolledComposite.setExpandHorizontal(true);
+        elementScrolledComposite.setExpandVertical(true);
+
+        if (definition == null) {
+            definition = new CustomXmlTraceDefinition();
+        }
+        loadDefinition(definition);
+        treeViewer.expandAll();
+        elementContainer.layout();
+
+        logtypeText.addModifyListener(updateListener);
+        timeStampOutputFormatText.addModifyListener(updateListener);
+
+        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+
+        hSash.setWeights(new int[] { 1, 2 });
+
+        if (definition.rootInputElement == null) {
+            removeButton.setEnabled(false);
+            addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);
+            addNextButton.setEnabled(false);
+            moveUpButton.setEnabled(false);
+            moveDownButton.setEnabled(false);
+        } else { // root is selected
+            addNextButton.setEnabled(false);
+        }
+
+        Composite sashBottom = new Composite(vSash, SWT.NONE);
+        GridLayout sashBottomLayout = new GridLayout(2, false);
+        sashBottomLayout.marginHeight = 0;
+        sashBottomLayout.marginWidth = 0;
+        sashBottom.setLayout(sashBottomLayout);
+
+        Label previewLabel = new Label(sashBottom, SWT.NULL);
+        previewLabel.setText(Messages.CustomXmlParserInputWizardPage_previewInput);
+
+        errorText = new Text(sashBottom, SWT.SINGLE | SWT.READ_ONLY);
+        errorText.setBackground(COLOR_WIDGET_BACKGROUND);
+        errorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        errorText.setVisible(false);
+
+        inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
+        if (fixedFont == null) {
+            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
+                fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$
+            } else {
+                fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$
+            }
+        }
+        inputText.setFont(fixedFont);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
+        gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;
+        gd.widthHint = 800;
+        inputText.setLayoutData(gd);
+        inputText.setText(getSelectionText());
+        inputText.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                parseXmlInput(inputText.getText());
+            }
+        });
+        inputText.addModifyListener(updateListener);
+
+        vSash.setWeights(new int[] { hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y });
+
+        setControl(container);
+    }
+
+    private void createButtonBar() {
+        Composite buttonBar = new Composite(container, SWT.NONE);
+        GridLayout buttonBarLayout = new GridLayout(6, false);
+        buttonBarLayout.marginHeight = 0;
+        buttonBarLayout.marginWidth = 0;
+        buttonBar.setLayout(buttonBarLayout);
+
+        removeButton = new Button(buttonBar, SWT.PUSH);
+        removeButton.setImage(deleteImage);
+        removeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeElement);
+        removeButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty() || selectedElement == null) {
+                    return;
+                }
+                removeElement();
+                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputElement == definition.rootInputElement) {
+                    definition.rootInputElement = null;
+                } else {
+                    inputElement.parentElement.childElements.remove(inputElement);
+                }
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+                removeButton.setEnabled(false);
+                if (definition.rootInputElement == null) {
+                    addChildButton.setEnabled(true);
+                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentEleemnt);
+                } else {
+                    addChildButton.setEnabled(false);
+                }
+                addNextButton.setEnabled(false);
+                moveUpButton.setEnabled(false);
+                moveDownButton.setEnabled(false);
+            }
+        });
+
+        addChildButton = new Button(buttonBar, SWT.PUSH);
+        addChildButton.setImage(addChildImage);
+        addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);
+        addChildButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+                if (definition.rootInputElement == null) {
+                    definition.rootInputElement = inputElement;
+                    inputElement.elementName = getChildNameSuggestion(null);
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    InputElement parentInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    parentInputElement.addChild(inputElement);
+                    inputElement.elementName = getChildNameSuggestion(parentInputElement);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputElement), true);
+            }
+        });
+
+        addNextButton = new Button(buttonBar, SWT.PUSH);
+        addNextButton.setImage(addNextImage);
+        addNextButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addNextElement);
+        addNextButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+                if (definition.rootInputElement == null) {
+                    definition.rootInputElement = inputElement;
+                    inputElement.elementName = getChildNameSuggestion(null);
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    if (previousInputElement == definition.rootInputElement) {
+                        return;
+                    }
+                    previousInputElement.addNext(inputElement);
+                    inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputElement), true);
+            }
+        });
+
+        feelingLuckyButton = new Button(buttonBar, SWT.PUSH);
+        feelingLuckyButton.setImage(addManyImage);
+        feelingLuckyButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_feelingLucky);
+        feelingLuckyButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputElement inputElement = null;
+                if (definition.rootInputElement == null) {
+                    if (getChildNameSuggestion(null).length() != 0) {
+                        inputElement = new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+                        definition.rootInputElement = inputElement;
+                        feelingLucky(inputElement);
+                    } else {
+                        return;
+                    }
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    feelingLucky(inputElement);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputElement), true);
+                treeViewer.expandToLevel(inputElement, AbstractTreeViewer.ALL_LEVELS);
+            }
+        });
+
+        moveUpButton = new Button(buttonBar, SWT.PUSH);
+        moveUpButton.setImage(moveUpImage);
+        moveUpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveUp);
+        moveUpButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                }
+                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputElement == definition.rootInputElement) {
+                    return;
+                }
+                inputElement.moveUp();
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+
+        moveDownButton = new Button(buttonBar, SWT.PUSH);
+        moveDownButton.setImage(moveDownImage);
+        moveDownButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveDown);
+        moveDownButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                }
+                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputElement == definition.rootInputElement) {
+                    return;
+                }
+                inputElement.moveDown();
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+    }
+
+    private void feelingLucky(InputElement inputElement) {
+        while (true) {
+            String attributeName = getAttributeNameSuggestion(inputElement);
+            if (attributeName.length() == 0) {
+                break;
+            }
+            InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+            inputElement.addAttribute(attribute);
+        }
+        while (true) {
+            String childName = getChildNameSuggestion(inputElement);
+            if (childName.length() == 0) {
+                break;
+            }
+            InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+            inputElement.addChild(childElement);
+            feelingLucky(childElement);
+        }
+    }
+
+    private static class InputElementTreeNodeContentProvider implements ITreeContentProvider {
+
+        @Override
+        public Object[] getElements(Object inputElement) {
+            CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement;
+            if (def.rootInputElement != null) {
+                return new Object[] { def.rootInputElement };
+            }
+            return new Object[0];
+        }
+
+        @Override
+        public Object[] getChildren(Object parentElement) {
+            InputElement inputElement = (InputElement) parentElement;
+            if (inputElement.childElements == null) {
+                return new InputElement[0];
+            }
+            return inputElement.childElements.toArray();
+        }
+
+        @Override
+        public boolean hasChildren(Object element) {
+            InputElement inputElement = (InputElement) element;
+            return (inputElement.childElements != null && inputElement.childElements.size() > 0);
+        }
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        }
+
+        @Override
+        public Object getParent(Object element) {
+            InputElement inputElement = (InputElement) element;
+            return inputElement.parentElement;
+        }
+    }
+
+    private static class InputElementTreeLabelProvider extends ColumnLabelProvider {
+
+        @Override
+        public Image getImage(Object element) {
+            return elementImage;
+        }
+
+        @Override
+        public String getText(Object element) {
+            InputElement inputElement = (InputElement) element;
+            return (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName; //$NON-NLS-1$
+        }
+    }
+
+    private class InputElementTreeSelectionChangedListener implements ISelectionChangedListener {
+        @Override
+        public void selectionChanged(SelectionChangedEvent event) {
+            if (selectedElement != null) {
+                selectedElement.dispose();
+            }
+            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
+                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+                InputElement inputElement = (InputElement) selection.getFirstElement();
+                selectedElement = new ElementNode(elementContainer, inputElement);
+                elementContainer.layout();
+                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+                container.layout();
+                validate();
+                updatePreviews();
+                removeButton.setEnabled(true);
+                addChildButton.setEnabled(true);
+                addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);
+                if (definition.rootInputElement == inputElement) {
+                    addNextButton.setEnabled(false);
+                } else {
+                    addNextButton.setEnabled(true);
+                }
+                moveUpButton.setEnabled(true);
+                moveDownButton.setEnabled(true);
+            } else {
+                removeButton.setEnabled(false);
+                if (definition.rootInputElement == null) {
+                    addChildButton.setEnabled(true);
+                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);
+                } else {
+                    addChildButton.setEnabled(false);
+                }
+                addNextButton.setEnabled(false);
+                moveUpButton.setEnabled(false);
+                moveDownButton.setEnabled(false);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+     */
+    @Override
+    public void dispose() {
+        if (fixedFont != null) {
+            fixedFont.dispose();
+            fixedFont = null;
+        }
+        super.dispose();
+    }
+
+    private void loadDefinition(CustomXmlTraceDefinition def) {
+        logtypeText.setText(def.definitionName);
+        timeStampOutputFormatText.setText(def.timeStampOutputFormat);
+        treeViewer.setInput(def);
+
+        if (def.rootInputElement != null) {
+            treeViewer.setSelection(new StructuredSelection(def.rootInputElement));
+        }
+    }
+
+    private String getName(InputElement inputElement) {
+        String name = (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName.trim(); //$NON-NLS-1$
+        if (inputElement.parentElement == null) {
+            return name;
+        }
+        return getName(inputElement.parentElement) + " : " + name; //$NON-NLS-1$
+    }
+
+    private String getName(InputAttribute inputAttribute, InputElement inputElement) {
+        String name = (inputAttribute.attributeName.trim().length() == 0) ? "?" : inputAttribute.attributeName.trim(); //$NON-NLS-1$
+        return getName(inputElement) + " : " + name; //$NON-NLS-1$
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    @Override
+    public void setVisible(boolean visible) {
+        if (visible) {
+            validate();
+            updatePreviews();
+        }
+        super.setVisible(visible);
+    }
+
+    public List<String> getInputNames() {
+        return getInputNames(definition.rootInputElement);
+    }
+
+    public List<String> getInputNames(InputElement inputElement) {
+        List<String> inputs = new ArrayList<String>();
+        if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+            String inputName = inputElement.inputName;
+            if (!inputs.contains(inputName)) {
+                inputs.add(inputName);
+            }
+        }
+        if (inputElement.attributes != null) {
+            for (InputAttribute attribute : inputElement.attributes) {
+                String inputName = attribute.inputName;
+                if (!inputs.contains(inputName)) {
+                    inputs.add(inputName);
+                }
+            }
+        }
+        if (inputElement.childElements != null) {
+            for (InputElement childInputElement : inputElement.childElements) {
+                for (String inputName : getInputNames(childInputElement)) {
+                    if (!inputs.contains(inputName)) {
+                        inputs.add(inputName);
+                    }
+                }
+            }
+        }
+        return inputs;
+    }
+
+    private void removeElement() {
+        selectedElement.dispose();
+        selectedElement = null;
+        elementContainer.layout();
+        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+        container.layout();
+    }
+
+    private String getSelectionText() {
+        InputStream inputStream = null;
+        if (this.selection instanceof IStructuredSelection) {
+            Object selection = ((IStructuredSelection) this.selection).getFirstElement();
+            if (selection instanceof IFile) {
+                IFile file = (IFile) selection;
+                try {
+                    inputStream = file.getContents();
+                } catch (CoreException e) {
+                    return ""; //$NON-NLS-1$
+                }
+            }
+        }
+        if (inputStream != null) {
+            BufferedReader reader = null;
+            try {
+                reader = new BufferedReader(new InputStreamReader(inputStream));
+                StringBuilder sb = new StringBuilder();
+                String line = null;
+                while ((line = reader.readLine()) != null) {
+                    sb.append(line + "\n"); //$NON-NLS-1$
+                }
+                parseXmlInput(sb.toString());
+                reader.close();
+                return sb.toString();
+            } catch (IOException e) {
+                return ""; //$NON-NLS-1$
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private void parseXmlInput(final String string) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver() {
+                @Override
+                public InputSource resolveEntity(String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler() {
+                @Override
+                public void error(SAXParseException saxparseexception) throws SAXException {
+                }
+
+                @Override
+                public void warning(SAXParseException saxparseexception) throws SAXException {
+                }
+
+                @Override
+                public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    if (string.trim().length() != 0) {
+                        errorText.setText(saxparseexception.getMessage());
+                        errorText.setBackground(COLOR_LIGHT_RED);
+                        errorText.setVisible(true);
+                    }
+                    throw saxparseexception;
+                }
+            });
+
+            errorText.setVisible(false);
+            Document doc = null;
+            doc = db.parse(new ByteArrayInputStream(string.getBytes()));
+            documentElement = doc.getDocumentElement();
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$
+            documentElement = null;
+        } catch (SAXException e) {
+            documentElement = null;
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$
+            documentElement = null;
+        }
+    }
+
+    private void updatePreviews() {
+        updatePreviews(false);
+    }
+
+    private void initValues() {
+        timeStampValue = null;
+        timeStampFormat = null;
+        logEntriesCount = 0;
+        logEntryFound = false;
+    }
+
+    private void updatePreviews(boolean updateAll) {
+        if (inputText == null) {
+            // early update during construction
+            return;
+        }
+        inputText.setStyleRanges(new StyleRange[] {});
+        if (selectedElement == null) {
+            return;
+        }
+
+        initValues();
+
+        selectedElement.updatePreview();
+
+        if (timeStampValue != null && timeStampFormat != null) {
+            try {
+                SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampFormat);
+                Date date = dateFormat.parse(timeStampValue);
+                dateFormat = new SimpleDateFormat(timeStampOutputFormatText.getText().trim());
+                timeStampPreviewText.setText(dateFormat.format(date));
+            } catch (ParseException e) {
+                timeStampPreviewText.setText("*parse exception* [" + timeStampValue + "] <> [" + timeStampFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            } catch (IllegalArgumentException e) {
+                timeStampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$
+            }
+        } else {
+            timeStampPreviewText.setText("*no matching time stamp*"); //$NON-NLS-1$
+        }
+    }
+
+    private void openHelpShell(String url) {
+        if (helpBrowser != null && !helpBrowser.isDisposed()) {
+            helpBrowser.getShell().setActive();
+            if (!helpBrowser.getUrl().equals(url)) {
+                helpBrowser.setUrl(url);
+            }
+            return;
+        }
+        final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);
+        helpShell.setLayout(new FillLayout());
+        helpBrowser = new Browser(helpShell, SWT.NONE);
+        helpBrowser.addTitleListener(new TitleListener() {
+            @Override
+            public void changed(TitleEvent event) {
+                helpShell.setText(event.title);
+            }
+        });
+        helpBrowser.setBounds(0, 0, 600, 400);
+        helpShell.pack();
+        helpShell.open();
+        helpBrowser.setUrl(url);
+    }
+
+    private class UpdateListener implements ModifyListener, SelectionListener {
+
+        @Override
+        public void modifyText(ModifyEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+        @Override
+        public void widgetDefaultSelected(SelectionEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+        @Override
+        public void widgetSelected(SelectionEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+    }
+
+    private class ElementNode {
+        final InputElement inputElement;
+        final Group group;
+        List<Attribute> attributes = new ArrayList<Attribute>();
+        List<ElementNode> childElements = new ArrayList<ElementNode>();
+        Text elementNameText;
+        Composite tagComposite;
+        Combo tagCombo;
+        Label tagLabel;
+        Text tagText;
+        Combo actionCombo;
+        Label previewLabel;
+        Text previewText;
+        Button logEntryButton;
+        Label fillerLabel;
+        Composite addAttributeComposite;
+        Button addAttributeButton;
+        Label addAttributeLabel;
+
+        public ElementNode(Composite parent, InputElement inputElement) {
+            this.inputElement = inputElement;
+
+            group = new Group(parent, SWT.NONE);
+            GridLayout gl = new GridLayout(2, false);
+            gl.marginHeight = 0;
+            group.setLayout(gl);
+            group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            group.setText(getName(inputElement));
+
+            Label label = new Label(group, SWT.NULL);
+            label.setText(Messages.CustomXmlParserInputWizardPage_elementName);
+            label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            elementNameText = new Text(group, SWT.BORDER | SWT.SINGLE);
+            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            elementNameText.setLayoutData(gd);
+            elementNameText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    ElementNode.this.inputElement.elementName = elementNameText.getText().trim();
+                    group.setText(getName(ElementNode.this.inputElement));
+                }
+            });
+            elementNameText.setText(inputElement.elementName);
+            elementNameText.addModifyListener(updateListener);
+
+            if (inputElement.parentElement != null) {
+                previewLabel = new Label(group, SWT.NULL);
+                previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+                previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
+
+                previewText = new Text(group, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+                gd.widthHint = 0;
+                previewText.setLayoutData(gd);
+                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
+                previewText.setBackground(COLOR_WIDGET_BACKGROUND);
+
+                logEntryButton = new Button(group, SWT.CHECK);
+                logEntryButton.setText(Messages.CustomXmlParserInputWizardPage_logEntry);
+                logEntryButton.setSelection(inputElement.logEntry);
+                logEntryButton.addSelectionListener(new SelectionListener() {
+                    @Override
+                    public void widgetDefaultSelected(SelectionEvent e) {
+                    }
+
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        InputElement parent = ElementNode.this.inputElement.parentElement;
+                        while (parent != null) {
+                            parent.logEntry = false;
+                            parent = parent.parentElement;
+                        }
+                    }
+                });
+                logEntryButton.addSelectionListener(updateListener);
+
+                tagComposite = new Composite(group, SWT.FILL);
+                GridLayout tagLayout = new GridLayout(4, false);
+                tagLayout.marginWidth = 0;
+                tagLayout.marginHeight = 0;
+                tagComposite.setLayout(tagLayout);
+                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.setVisibleItemCount(tagCombo.getItemCount());
+                tagCombo.addSelectionListener(new SelectionListener() {
+                    @Override
+                    public void widgetDefaultSelected(SelectionEvent e) {
+                    }
+
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        tagText.removeModifyListener(updateListener);
+                        switch (tagCombo.getSelectionIndex()) {
+                        case 0: // Ignore
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(false);
+                            break;
+                        case 1: // Time Stamp
+                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                            tagLabel.setVisible(true);
+                            tagText.setVisible(true);
+                            tagText.addModifyListener(updateListener);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 2: // Message
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 3: // Other
+                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                            tagLabel.setVisible(true);
+                            if (tagText.getText().trim().length() == 0) {
+                                tagText.setText(elementNameText.getText().trim());
+                            }
+                            tagText.setVisible(true);
+                            tagText.addModifyListener(updateListener);
+                            actionCombo.setVisible(true);
+                            break;
+                        default:
+                            break;
+                        }
+                        tagComposite.layout();
+                        validate();
+                        updatePreviews();
+                    }
+                });
+
+                tagLabel = new Label(tagComposite, SWT.NULL);
+                tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+                tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
+                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+                gd.widthHint = 0;
+                tagText.setLayoutData(gd);
+
+                actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+                actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
+                        Messages.CustomXmlParserInputWizardPage_appendWith });
+                actionCombo.select(inputElement.inputAction);
+                actionCombo.addSelectionListener(updateListener);
+
+                if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+                    tagCombo.select(0);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                    actionCombo.setVisible(false);
+                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                    tagCombo.select(1);
+                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                    tagText.setText(inputElement.inputFormat);
+                    tagText.addModifyListener(updateListener);
+                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                    tagCombo.select(2);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                } else {
+                    tagCombo.select(3);
+                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                    tagText.setText(inputElement.inputName);
+                    tagText.addModifyListener(updateListener);
+                }
+            }
+
+            if (inputElement.attributes != null) {
+                for (InputAttribute inputAttribute : inputElement.attributes) {
+                    Attribute attribute = new Attribute(group, this, inputAttribute, attributes.size() + 1);
+                    attributes.add(attribute);
+                }
+            }
+
+            createAddButton();
+        }
+
+        private void updatePreview() {
+            Element element = getPreviewElement(inputElement);
+            if (inputElement.parentElement != null) { // no preview text for
+                                                      // document element
+                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
+                if (element != null) {
+                    previewText.setText(CustomXmlTrace.parseElement(element, new StringBuffer()).toString());
+                    if (logEntryButton.getSelection()) {
+                        if (!logEntryFound) {
+                            logEntryFound = true;
+                            logEntriesCount++;
+                        } else {
+                            logEntryButton.setSelection(false); // remove nested
+                                                                // log entry
+                        }
+                    }
+                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
+                        String value = previewText.getText().trim();
+                        if (value.length() != 0) {
+                            if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {
+                                timeStampValue = value;
+                                timeStampFormat = tagText.getText().trim();
+                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += value;
+                                    timeStampFormat += tagText.getText().trim();
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = tagText.getText().trim();
+                                }
+                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += " | " + value; //$NON-NLS-1$
+                                    timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = tagText.getText().trim();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            for (Attribute attribute : attributes) {
+                if (element != null) {
+                    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.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {
+                                timeStampValue = value;
+                                timeStampFormat = attribute.tagText.getText().trim();
+                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += value;
+                                    timeStampFormat += attribute.tagText.getText().trim();
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = attribute.tagText.getText().trim();
+                                }
+                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += " | " + value; //$NON-NLS-1$
+                                    timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = attribute.tagText.getText().trim();
+                                }
+                            }
+                        }
+                    } else {
+                        attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingAttribute);
+                    }
+                } else {
+                    attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
+                }
+            }
+            for (ElementNode child : childElements) {
+                child.updatePreview();
+            }
+            if (logEntryButton != null && logEntryButton.getSelection()) {
+                logEntryFound = false;
+            }
+        }
+
+        private void createAddButton() {
+            fillerLabel = new Label(group, SWT.NONE);
+
+            addAttributeComposite = new Composite(group, SWT.NONE);
+            addAttributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            GridLayout addAttributeLayout = new GridLayout(2, false);
+            addAttributeLayout.marginHeight = 0;
+            addAttributeLayout.marginWidth = 0;
+            addAttributeComposite.setLayout(addAttributeLayout);
+
+            addAttributeButton = new Button(addAttributeComposite, SWT.PUSH);
+            addAttributeButton.setImage(addImage);
+            addAttributeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addAttribute);
+            addAttributeButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    removeAddButton();
+                    String attributeName = getAttributeNameSuggestion(inputElement);
+                    InputAttribute inputAttribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+                    attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));
+                    createAddButton();
+                    elementContainer.layout();
+                    elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                            elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+                    group.getParent().layout();
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            addAttributeLabel = new Label(addAttributeComposite, SWT.NULL);
+            addAttributeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            addAttributeLabel.setText(Messages.CustomXmlParserInputWizardPage_newAttibute);
+        }
+
+        private void removeAddButton() {
+            fillerLabel.dispose();
+            addAttributeComposite.dispose();
+        }
+
+        private void removeAttribute(int attributeNumber) {
+            if (--attributeNumber < attributes.size()) {
+                attributes.remove(attributeNumber).dispose();
+                for (int i = attributeNumber; i < attributes.size(); i++) {
+                    attributes.get(i).setAttributeNumber(i + 1);
+                }
+                elementContainer.layout();
+                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+                group.getParent().layout();
+            }
+        }
+
+        private void dispose() {
+            group.dispose();
+        }
+
+        private void extractInputs() {
+            inputElement.elementName = elementNameText.getText().trim();
+            if (inputElement.parentElement != null) {
+                inputElement.logEntry = logEntryButton.getSelection();
+                if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                    inputElement.inputName = tagText.getText().trim();
+                } else {
+                    inputElement.inputName = tagCombo.getText();
+                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        inputElement.inputFormat = tagText.getText().trim();
+                    }
+                }
+                inputElement.inputAction = actionCombo.getSelectionIndex();
+            }
+            inputElement.attributes = new ArrayList<InputAttribute>(attributes.size());
+            for (int i = 0; i < attributes.size(); i++) {
+                Attribute attribute = attributes.get(i);
+                InputAttribute inputAttribute = new InputAttribute();
+                inputAttribute.attributeName = attribute.attributeNameText.getText().trim();
+                if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                    inputAttribute.inputName = attribute.tagText.getText().trim();
+                } else {
+                    inputAttribute.inputName = attribute.tagCombo.getText();
+                    if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        inputAttribute.inputFormat = attribute.tagText.getText().trim();
+                    }
+                }
+                inputAttribute.inputAction = attribute.actionCombo.getSelectionIndex();
+                inputElement.addAttribute(inputAttribute);
+            }
+        }
+    }
+
+    private class Attribute {
+        ElementNode element;
+        int attributeNumber;
+
+        // children of parent (must be disposed)
+        Composite labelComposite;
+        Composite attributeComposite;
+        Label filler;
+        Composite tagComposite;
+
+        // children of labelComposite
+        Label attributeLabel;
+
+        // children of attributeComposite
+        Text attributeNameText;
+        Text previewText;
+
+        // children of tagComposite
+        Combo tagCombo;
+        Label tagLabel;
+        Text tagText;
+        Combo actionCombo;
+
+        public Attribute(Composite parent, ElementNode element, InputAttribute inputAttribute, int attributeNumber) {
+            this.element = element;
+            this.attributeNumber = attributeNumber;
+
+            labelComposite = new Composite(parent, SWT.FILL);
+            GridLayout labelLayout = new GridLayout(2, false);
+            labelLayout.marginWidth = 0;
+            labelLayout.marginHeight = 0;
+            labelComposite.setLayout(labelLayout);
+            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            Button deleteButton = new Button(labelComposite, SWT.PUSH);
+            deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            deleteButton.setImage(deleteImage);
+            deleteButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeAttribute);
+            deleteButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    Attribute.this.element.removeAttribute(Attribute.this.attributeNumber);
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            attributeLabel = new Label(labelComposite, SWT.NULL);
+            attributeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            attributeLabel.setText(Messages.CustomXmlParserInputWizardPage_attibute);
+
+            attributeComposite = new Composite(parent, SWT.FILL);
+            GridLayout attributeLayout = new GridLayout(4, false);
+            attributeLayout.marginWidth = 0;
+            attributeLayout.marginHeight = 0;
+            attributeComposite.setLayout(attributeLayout);
+            attributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            Label nameLabel = new Label(attributeComposite, SWT.NONE);
+            nameLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
+
+            attributeNameText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE);
+            attributeNameText.setLayoutData(new GridData(120, SWT.DEFAULT));
+            attributeNameText.setText(inputAttribute.attributeName);
+            attributeNameText.addModifyListener(updateListener);
+
+            Label previewLabel = new Label(attributeComposite, SWT.NONE);
+            previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
+
+            previewText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            previewText.setLayoutData(gd);
+            previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatch);
+            previewText.setBackground(COLOR_WIDGET_BACKGROUND);
+
+            filler = new Label(parent, SWT.NULL);
+
+            tagComposite = new Composite(parent, SWT.FILL);
+            GridLayout tagLayout = new GridLayout(4, false);
+            tagLayout.marginWidth = 0;
+            tagLayout.marginHeight = 0;
+            tagComposite.setLayout(tagLayout);
+            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.addSelectionListener(new SelectionListener() {
+                @Override
+                public void widgetDefaultSelected(SelectionEvent e) {
+                }
+
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    tagText.removeModifyListener(updateListener);
+                    switch (tagCombo.getSelectionIndex()) {
+                    case 0: // Time Stamp
+                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                        tagLabel.setVisible(true);
+                        tagText.setVisible(true);
+                        tagText.addModifyListener(updateListener);
+                        break;
+                    case 1: // Message
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        break;
+                    case 2: // Other
+                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                        tagLabel.setVisible(true);
+                        if (tagText.getText().trim().length() == 0) {
+                            tagText.setText(attributeNameText.getText().trim());
+                        }
+                        tagText.setVisible(true);
+                        tagText.addModifyListener(updateListener);
+                        break;
+                    default:
+                        break;
+                    }
+                    tagComposite.layout();
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            tagLabel = new Label(tagComposite, SWT.NULL);
+            tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
+            gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            tagText.setLayoutData(gd);
+            tagText.setText(attributeNameText.getText());
+
+            actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+            actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
+                    Messages.CustomXmlParserInputWizardPage_appendWith });
+            actionCombo.select(inputAttribute.inputAction);
+            actionCombo.addSelectionListener(updateListener);
+
+            if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                tagCombo.select(0);
+                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                tagText.setText(inputAttribute.inputFormat);
+                tagText.addModifyListener(updateListener);
+            } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                tagCombo.select(1);
+                tagLabel.setVisible(false);
+                tagText.setVisible(false);
+            } else {
+                tagCombo.select(2);
+                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                tagText.setText(inputAttribute.inputName);
+                tagText.addModifyListener(updateListener);
+            }
+        }
+
+        private void dispose() {
+            labelComposite.dispose();
+            attributeComposite.dispose();
+            filler.dispose();
+            tagComposite.dispose();
+        }
+
+        private void setAttributeNumber(int attributeNumber) {
+            this.attributeNumber = attributeNumber;
+            labelComposite.layout();
+        }
+    }
+
+    private Element getPreviewElement(InputElement inputElement) {
+        Element element = documentElement;
+        if (element != null) {
+            if (!documentElement.getNodeName().equals(definition.rootInputElement.elementName)) {
+                return null;
+            }
+            ArrayList<String> elementNames = new ArrayList<String>();
+            while (inputElement != null) {
+                elementNames.add(inputElement.elementName);
+                inputElement = inputElement.parentElement;
+            }
+            for (int i = elementNames.size() - 1; --i >= 0;) {
+                NodeList childList = element.getChildNodes();
+                element = null;
+                for (int j = 0; j < childList.getLength(); j++) {
+                    Node child = childList.item(j);
+                    if (child instanceof Element && child.getNodeName().equals(elementNames.get(i))) {
+                        element = (Element) child;
+                        break;
+                    }
+                }
+                if (element == null) {
+                    break;
+                }
+            }
+            if (element != null) {
+                return element;
+            }
+        }
+        return null;
+    }
+
+    private String getChildNameSuggestion(InputElement inputElement) {
+        if (inputElement == null) {
+            if (documentElement != null) {
+                return documentElement.getNodeName();
+            }
+        } else {
+            Element element = getPreviewElement(inputElement);
+            if (element != null) {
+                NodeList childNodes = element.getChildNodes();
+                for (int i = 0; i < childNodes.getLength(); i++) {
+                    Node node = childNodes.item(i);
+                    if (node instanceof Element) {
+                        boolean unused = true;
+                        if (inputElement.childElements != null) {
+                            for (InputElement child : inputElement.childElements) {
+                                if (child.elementName.equals(node.getNodeName())) {
+                                    unused = false;
+                                    break;
+                                }
+                            }
+                        }
+                        if (unused) {
+                            return node.getNodeName();
+                        }
+                    }
+                }
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private String getAttributeNameSuggestion(InputElement inputElement) {
+        Element element = getPreviewElement(inputElement);
+        if (element != null) {
+            NamedNodeMap attributeMap = element.getAttributes();
+            for (int i = 0; i < attributeMap.getLength(); i++) {
+                Node node = attributeMap.item(i);
+                boolean unused = true;
+                if (inputElement.attributes != null) {
+                    for (InputAttribute attribute : inputElement.attributes) {
+                        if (attribute.attributeName.equals(node.getNodeName())) {
+                            unused = false;
+                            break;
+                        }
+                    }
+                }
+                if (unused) {
+                    return node.getNodeName();
+                }
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private void validate() {
+        definition.definitionName = logtypeText.getText().trim();
+        definition.timeStampOutputFormat = timeStampOutputFormatText.getText().trim();
+
+        if (selectedElement != null) {
+            selectedElement.extractInputs();
+            treeViewer.refresh();
+        }
+
+        StringBuffer errors = new StringBuffer();
+
+        if (definition.definitionName.length() == 0) {
+            errors.append(Messages.CustomXmlParserInputWizardPage_emptyLogTypeError);
+            logtypeText.setBackground(COLOR_LIGHT_RED);
+        } else {
+            logtypeText.setBackground(COLOR_TEXT_BACKGROUND);
+            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                if (definition.definitionName.equals(def.definitionName)) {
+                    if (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName)) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicatelogTypeError);
+                        logtypeText.setBackground(COLOR_LIGHT_RED);
+                        break;
+                    }
+                }
+            }
+        }
+
+        if (definition.rootInputElement == null) {
+            errors.append(Messages.CustomXmlParserInputWizardPage_noDocumentError);
+        }
+
+        if (definition.rootInputElement != null) {
+            logEntryFound = false;
+            timeStampFound = false;
+
+            errors.append(validateElement(definition.rootInputElement));
+
+            if ((definition.rootInputElement.attributes != null && definition.rootInputElement.attributes.size() != 0)
+                    || (definition.rootInputElement.childElements != null && definition.rootInputElement.childElements.size() != 0)
+                    || errors.length() == 0) {
+                if (!logEntryFound) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);
+                }
+
+                if (timeStampFound) {
+                    if (timeStampOutputFormatText.getText().trim().length() == 0) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampFmtError);
+                        timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
+                    } else {
+                        try {
+                            new SimpleDateFormat(timeStampOutputFormatText.getText().trim());
+                            timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+                        } catch (IllegalArgumentException e) {
+                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError);
+                            timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                } else {
+                    timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);
+                }
+            }
+        } else {
+            timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);
+        }
+
+        if (errors.length() == 0) {
+            setDescription(defaultDescription);
+            setPageComplete(true);
+        } else {
+            setDescription(errors.toString());
+            setPageComplete(false);
+        }
+    }
+
+    public StringBuffer validateElement(InputElement inputElement) {
+        StringBuffer errors = new StringBuffer();
+        ElementNode elementNode = null;
+        if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) {
+            elementNode = selectedElement;
+        }
+        if (inputElement == definition.rootInputElement) {
+            if (inputElement.elementName.length() == 0) {
+                errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);
+                if (elementNode != null) {
+                    elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                }
+            } else {
+                if (elementNode != null) {
+                    elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+        }
+        if (inputElement != definition.rootInputElement) {
+            if (inputElement.logEntry) {
+                logEntryFound = true;
+            }
+            if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                timeStampFound = true;
+                if (inputElement.inputFormat.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt
+                            + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else {
+                    try {
+                        new SimpleDateFormat(inputElement.inputFormat);
+                        if (elementNode != null) {
+                            elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                        }
+                    } catch (IllegalArgumentException e) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError
+                                + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (elementNode != null) {
+                            elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+            } else if (inputElement.inputName.length() == 0) {
+                errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError);
+                if (elementNode != null) {
+                    elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                }
+            } else {
+                if (elementNode != null) {
+                    elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+        }
+        if (inputElement.attributes != null) {
+            if (elementNode != null) {
+                for (Attribute attribute : elementNode.attributes) {
+                    attribute.attributeNameText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+            for (int i = 0; i < inputElement.attributes.size(); i++) {
+                InputAttribute attribute = inputElement.attributes.get(i);
+                boolean duplicate = false;
+                for (int j = i + 1; j < inputElement.attributes.size(); j++) {
+                    InputAttribute otherAttribute = inputElement.attributes.get(j);
+                    if (otherAttribute.attributeName.equals(attribute.attributeName)) {
+                        duplicate = true;
+                        if (elementNode != null) {
+                            elementNode.attributes.get(j).attributeNameText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+                if (attribute.attributeName.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else if (duplicate) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
+                    }
+                }
+                if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                    timeStampFound = true;
+                    if (attribute.inputFormat.length() == 0) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError
+                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (elementNode != null) {
+                            elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    } else {
+                        try {
+                            new SimpleDateFormat(attribute.inputFormat);
+                            if (elementNode != null) {
+                                elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                            }
+                        } catch (IllegalArgumentException e) {
+                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError
+                                    + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                            if (elementNode != null) {
+                                elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
+                            }
+                        }
+                    }
+                } else if (attribute.inputName.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    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);
+                    }
+                }
+            }
+        }
+        if (inputElement.childElements != null) {
+            for (InputElement child : inputElement.childElements) {
+                ElementNode childElementNode = null;
+                if (selectedElement != null && selectedElement.inputElement.equals(child)) {
+                    childElementNode = selectedElement;
+                }
+                if (childElementNode != null) {
+                    childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+            for (int i = 0; i < inputElement.childElements.size(); i++) {
+                InputElement child = inputElement.childElements.get(i);
+                ElementNode childElementNode = null;
+                if (selectedElement != null && selectedElement.inputElement.equals(child)) {
+                    childElementNode = selectedElement;
+                }
+                if (child.elementName.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (childElementNode != null) {
+                        childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else {
+                    boolean duplicate = false;
+                    for (int j = i + 1; j < inputElement.childElements.size(); j++) {
+                        InputElement otherChild = inputElement.childElements.get(j);
+                        if (otherChild.elementName.equals(child.elementName)) {
+                            duplicate = true;
+                            ElementNode otherChildElementNode = null;
+                            if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) {
+                                otherChildElementNode = selectedElement;
+                            }
+                            if (otherChildElementNode != null) {
+                                otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                            }
+                        }
+                    }
+                    if (duplicate) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError
+                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (childElementNode != null) {
+                            childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+
+                errors.append(validateElement(child));
+            }
+        }
+        return errors;
+    }
+
+    public CustomXmlTraceDefinition getDefinition() {
+        return definition;
+    }
+
+    public char[] getInputText() {
+        return inputText.getText().toCharArray();
+    }
+}
index c17e4f099ea8ff4dd264676080fcd2da30deac50..398ad3a60a2f29515cf9ce58c39c776f3cca7d5d 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Text;\r
-\r
-public class CustomXmlParserOutputWizardPage extends WizardPage {\r
-\r
-    private static final Image upImage = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$\r
-    private static final Image downImage = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$\r
-    private final CustomXmlParserWizard wizard;\r
-    private CustomXmlTraceDefinition definition;\r
-    List<Output> outputs = new ArrayList<Output>();\r
-    //    Output messageOutput;\r
-    Composite container;\r
-    SashForm sash;\r
-    //    Text timestampFormatText;\r
-    //    Text timestampPreviewText;\r
-    ScrolledComposite outputsScrolledComposite;\r
-    Composite outputsContainer;\r
-    //    ScrolledComposite inputScrolledComposite;\r
-    Composite tableContainer;\r
-    CustomEventsTable previewTable;\r
-    File tmpFile;\r
-\r
-    protected CustomXmlParserOutputWizardPage(final CustomXmlParserWizard wizard) {\r
-        super("CustomParserOutputWizardPage"); //$NON-NLS-1$\r
-        setTitle(wizard.inputPage.getTitle());\r
-        setDescription(Messages.CustomXmlParserOutputWizardPage_description);\r
-        this.wizard = wizard;\r
-        setPageComplete(false);\r
-    }\r
-\r
-    @Override\r
-    public void createControl(final Composite parent) {\r
-        container = new Composite(parent, SWT.NULL);\r
-        container.setLayout(new GridLayout());\r
-\r
-        sash = new SashForm(container, SWT.VERTICAL);\r
-        sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
-\r
-        outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);\r
-        outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);\r
-        final GridLayout outputsLayout = new GridLayout(4, false);\r
-        outputsLayout.marginHeight = 10;\r
-        outputsLayout.marginWidth = 0;\r
-        outputsContainer.setLayout(outputsLayout);\r
-        outputsScrolledComposite.setContent(outputsContainer);\r
-        outputsScrolledComposite.setExpandHorizontal(true);\r
-        outputsScrolledComposite.setExpandVertical(true);\r
-\r
-        outputsContainer.layout();\r
-\r
-        outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-\r
-        tableContainer = new Composite(sash, SWT.NONE);\r
-        final GridLayout tableLayout = new GridLayout();\r
-        tableLayout.marginHeight = 0;\r
-        tableLayout.marginWidth = 0;\r
-        tableContainer.setLayout(tableLayout);\r
-        previewTable = new CustomEventsTable(new CustomXmlTraceDefinition(), tableContainer, 0);\r
-        previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-\r
-        if (wizard.definition != null)\r
-            loadDefinition(wizard.definition);\r
-        setControl(container);\r
-\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        previewTable.dispose();\r
-        super.dispose();\r
-    }\r
-\r
-    private void loadDefinition(final CustomTraceDefinition definition) {\r
-        for (final OutputColumn outputColumn : definition.outputs) {\r
-            final Output output = new Output(outputsContainer, outputColumn.name);\r
-            outputs.add(output);\r
-        }\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)\r
-     */\r
-    @Override\r
-    public void setVisible(final boolean visible) {\r
-        if (visible) {\r
-            this.definition = wizard.inputPage.getDefinition();\r
-            final List<String> outputNames = wizard.inputPage.getInputNames();\r
-\r
-            // dispose outputs that have been removed in the input page\r
-            final Iterator<Output> iter = outputs.iterator();\r
-            while (iter.hasNext()) {\r
-                final Output output = iter.next();\r
-                boolean found = false;\r
-                for (final String name : outputNames)\r
-                    if (output.name.equals(name)) {\r
-                        found = true;\r
-                        break;\r
-                    }\r
-                if (!found) {\r
-                    output.dispose();\r
-                    iter.remove();\r
-                }\r
-            }\r
-\r
-            // create outputs that have been added in the input page\r
-            for (final String name : outputNames) {\r
-                boolean found = false;\r
-                for (final Output output : outputs)\r
-                    if (output.name.equals(name)) {\r
-                        found = true;\r
-                        break;\r
-                    }\r
-                if (!found)\r
-                    outputs.add(new Output(outputsContainer, name));\r
-            }\r
-\r
-            outputsContainer.layout();\r
-            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-            updatePreviewTable();\r
-            if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight())\r
-                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});\r
-            else\r
-                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});\r
-            setPageComplete(true);\r
-        } else\r
-            setPageComplete(false);\r
-        super.setVisible(visible);\r
-    }\r
-\r
-    private void moveBefore(final Output moved) {\r
-        final int i = outputs.indexOf(moved);\r
-        if (i > 0) {\r
-            final Output previous = outputs.get(i-1);\r
-            moved.enabledButton.moveAbove(previous.enabledButton);\r
-            moved.nameLabel.moveBelow(moved.enabledButton);\r
-            moved.upButton.moveBelow(moved.nameLabel);\r
-            moved.downButton.moveBelow(moved.upButton);\r
-            outputs.add(i-1, outputs.remove(i));\r
-            outputsContainer.layout();\r
-            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-            container.layout();\r
-            updatePreviewTable();\r
-        }\r
-    }\r
-\r
-    private void moveAfter(final Output moved) {\r
-        final int i = outputs.indexOf(moved);\r
-        if (i+1 < outputs.size()) {\r
-            final Output next = outputs.get(i+1);\r
-            moved.enabledButton.moveBelow(next.downButton);\r
-            moved.nameLabel.moveBelow(moved.enabledButton);\r
-            moved.upButton.moveBelow(moved.nameLabel);\r
-            moved.downButton.moveBelow(moved.upButton);\r
-            outputs.add(i+1, outputs.remove(i));\r
-            outputsContainer.layout();\r
-            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);\r
-            container.layout();\r
-            updatePreviewTable();\r
-        }\r
-    }\r
-\r
-    private void updatePreviewTable() {\r
-        final int CACHE_SIZE = 50;\r
-        definition.outputs = extractOutputs();\r
-\r
-        try {\r
-            tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$\r
-            final FileWriter writer = new FileWriter(tmpFile);\r
-            writer.write(wizard.inputPage.getInputText());\r
-            writer.close();\r
-\r
-            final ITmfTrace<?> trace = new CustomXmlTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);\r
-            previewTable.dispose();\r
-            previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);\r
-            previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-            previewTable.setTrace(trace, true);\r
-        } catch (final TmfTraceException e) {\r
-            Activator.getDefault().logError("Error creating CustomXmlTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$\r
-        } catch (final IOException e) {\r
-            Activator.getDefault().logError("Error creating CustomXmlTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$\r
-        }\r
-\r
-        tableContainer.layout();\r
-        container.layout();\r
-    }\r
-\r
-    public List<OutputColumn> extractOutputs() {\r
-        int numColumns = 0;\r
-        for (int i = 0; i < outputs.size(); i++)\r
-            if (outputs.get(i).enabledButton.getSelection())\r
-                numColumns++;\r
-        final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);\r
-        numColumns = 0;\r
-        for (int i = 0; i < outputs.size(); i++) {\r
-            final Output output = outputs.get(i);\r
-            if (output.enabledButton.getSelection()) {\r
-                final OutputColumn column = new OutputColumn();\r
-                column.name = output.nameLabel.getText();\r
-                outputColumns.add(column);\r
-            }\r
-        }\r
-        return outputColumns;\r
-    }\r
-\r
-    private class Output {\r
-        String name;\r
-        Button enabledButton;\r
-        Text nameLabel;\r
-        Button upButton;\r
-        Button downButton;\r
-\r
-        public Output(final Composite parent, final String name) {\r
-            this.name = name;\r
-\r
-            enabledButton = new Button(parent, SWT.CHECK);\r
-            enabledButton.setToolTipText(Messages.CustomXmlParserOutputWizardPage_visible);\r
-            enabledButton.setSelection(true);\r
-            enabledButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(final SelectionEvent e) {\r
-                    updatePreviewTable();\r
-                }\r
-            });\r
-            //            if (messageOutput != null) {\r
-            //                enabledButton.moveAbove(messageOutput.enabledButton);\r
-            //            }\r
-\r
-            nameLabel = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);\r
-            nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-            nameLabel.setText(name);\r
-            nameLabel.moveBelow(enabledButton);\r
-\r
-            upButton = new Button(parent, SWT.PUSH);\r
-            upButton.setImage(upImage);\r
-            upButton.setToolTipText(Messages.CustomXmlParserOutputWizardPage_moveBefore);\r
-            upButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(final SelectionEvent e) {\r
-                    moveBefore(Output.this);\r
-                }\r
-            });\r
-            upButton.moveBelow(nameLabel);\r
-\r
-            downButton = new Button(parent, SWT.PUSH);\r
-            downButton.setImage(downImage);\r
-            downButton.setToolTipText(Messages.CustomXmlParserOutputWizardPage_moveAfter);\r
-            downButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(final SelectionEvent e) {\r
-                    moveAfter(Output.this);\r
-                }\r
-            });\r
-            downButton.moveBelow(upButton);\r
-        }\r
-\r
-        private void dispose() {\r
-            enabledButton.dispose();\r
-            nameLabel.dispose();\r
-            upButton.dispose();\r
-            downButton.dispose();\r
-        }\r
-    }\r
-\r
-    public CustomXmlTraceDefinition getDefinition() {\r
-        return definition;\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class CustomXmlParserOutputWizardPage extends WizardPage {
+
+    private static final Image upImage = Activator.getDefault().getImageFromPath("/icons/elcl16/up_button.gif"); //$NON-NLS-1$
+    private static final Image downImage = Activator.getDefault().getImageFromPath("/icons/elcl16/down_button.gif"); //$NON-NLS-1$
+    private final CustomXmlParserWizard wizard;
+    private CustomXmlTraceDefinition definition;
+    List<Output> outputs = new ArrayList<Output>();
+    //    Output messageOutput;
+    Composite container;
+    SashForm sash;
+    //    Text timestampFormatText;
+    //    Text timestampPreviewText;
+    ScrolledComposite outputsScrolledComposite;
+    Composite outputsContainer;
+    //    ScrolledComposite inputScrolledComposite;
+    Composite tableContainer;
+    CustomEventsTable previewTable;
+    File tmpFile;
+
+    protected CustomXmlParserOutputWizardPage(final CustomXmlParserWizard wizard) {
+        super("CustomParserOutputWizardPage"); //$NON-NLS-1$
+        setTitle(wizard.inputPage.getTitle());
+        setDescription(Messages.CustomXmlParserOutputWizardPage_description);
+        this.wizard = wizard;
+        setPageComplete(false);
+    }
+
+    @Override
+    public void createControl(final Composite parent) {
+        container = new Composite(parent, SWT.NULL);
+        container.setLayout(new GridLayout());
+
+        sash = new SashForm(container, SWT.VERTICAL);
+        sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+
+        outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
+        outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
+        final GridLayout outputsLayout = new GridLayout(4, false);
+        outputsLayout.marginHeight = 10;
+        outputsLayout.marginWidth = 0;
+        outputsContainer.setLayout(outputsLayout);
+        outputsScrolledComposite.setContent(outputsContainer);
+        outputsScrolledComposite.setExpandHorizontal(true);
+        outputsScrolledComposite.setExpandVertical(true);
+
+        outputsContainer.layout();
+
+        outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+
+        tableContainer = new Composite(sash, SWT.NONE);
+        final GridLayout tableLayout = new GridLayout();
+        tableLayout.marginHeight = 0;
+        tableLayout.marginWidth = 0;
+        tableContainer.setLayout(tableLayout);
+        previewTable = new CustomEventsTable(new CustomXmlTraceDefinition(), tableContainer, 0);
+        previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        if (wizard.definition != null)
+            loadDefinition(wizard.definition);
+        setControl(container);
+
+    }
+
+    @Override
+    public void dispose() {
+        previewTable.dispose();
+        super.dispose();
+    }
+
+    private void loadDefinition(final CustomTraceDefinition definition) {
+        for (final OutputColumn outputColumn : definition.outputs) {
+            final Output output = new Output(outputsContainer, outputColumn.name);
+            outputs.add(output);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    @Override
+    public void setVisible(final boolean visible) {
+        if (visible) {
+            this.definition = wizard.inputPage.getDefinition();
+            final List<String> outputNames = wizard.inputPage.getInputNames();
+
+            // dispose outputs that have been removed in the input page
+            final Iterator<Output> iter = outputs.iterator();
+            while (iter.hasNext()) {
+                final Output output = iter.next();
+                boolean found = false;
+                for (final String name : outputNames)
+                    if (output.name.equals(name)) {
+                        found = true;
+                        break;
+                    }
+                if (!found) {
+                    output.dispose();
+                    iter.remove();
+                }
+            }
+
+            // create outputs that have been added in the input page
+            for (final String name : outputNames) {
+                boolean found = false;
+                for (final Output output : outputs)
+                    if (output.name.equals(name)) {
+                        found = true;
+                        break;
+                    }
+                if (!found)
+                    outputs.add(new Output(outputsContainer, name));
+            }
+
+            outputsContainer.layout();
+            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+            updatePreviewTable();
+            if (sash.getSize().y > outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + previewTable.getTable().getItemHeight())
+                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sash.getSize().y - outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});
+            else
+                sash.setWeights(new int[] {outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, previewTable.getTable().getItemHeight()});
+            setPageComplete(true);
+        } else
+            setPageComplete(false);
+        super.setVisible(visible);
+    }
+
+    private void moveBefore(final Output moved) {
+        final int i = outputs.indexOf(moved);
+        if (i > 0) {
+            final Output previous = outputs.get(i-1);
+            moved.enabledButton.moveAbove(previous.enabledButton);
+            moved.nameLabel.moveBelow(moved.enabledButton);
+            moved.upButton.moveBelow(moved.nameLabel);
+            moved.downButton.moveBelow(moved.upButton);
+            outputs.add(i-1, outputs.remove(i));
+            outputsContainer.layout();
+            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+            container.layout();
+            updatePreviewTable();
+        }
+    }
+
+    private void moveAfter(final Output moved) {
+        final int i = outputs.indexOf(moved);
+        if (i+1 < outputs.size()) {
+            final Output next = outputs.get(i+1);
+            moved.enabledButton.moveBelow(next.downButton);
+            moved.nameLabel.moveBelow(moved.enabledButton);
+            moved.upButton.moveBelow(moved.nameLabel);
+            moved.downButton.moveBelow(moved.upButton);
+            outputs.add(i+1, outputs.remove(i));
+            outputsContainer.layout();
+            outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);
+            container.layout();
+            updatePreviewTable();
+        }
+    }
+
+    private void updatePreviewTable() {
+        final int CACHE_SIZE = 50;
+        definition.outputs = extractOutputs();
+
+        try {
+            tmpFile = Activator.getDefault().getStateLocation().addTrailingSeparator().append("customwizard.tmp").toFile(); //$NON-NLS-1$
+            final FileWriter writer = new FileWriter(tmpFile);
+            writer.write(wizard.inputPage.getInputText());
+            writer.close();
+
+            final ITmfTrace<?> trace = new CustomXmlTrace(null, definition, tmpFile.getAbsolutePath(), CACHE_SIZE);
+            previewTable.dispose();
+            previewTable = new CustomEventsTable(definition, tableContainer, CACHE_SIZE);
+            previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+            previewTable.setTrace(trace, true);
+        } catch (final TmfTraceException e) {
+            Activator.getDefault().logError("Error creating CustomXmlTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
+        } catch (final IOException e) {
+            Activator.getDefault().logError("Error creating CustomXmlTrace. File:" + tmpFile.getAbsolutePath(), e); //$NON-NLS-1$
+        }
+
+        tableContainer.layout();
+        container.layout();
+    }
+
+    public List<OutputColumn> extractOutputs() {
+        int numColumns = 0;
+        for (int i = 0; i < outputs.size(); i++)
+            if (outputs.get(i).enabledButton.getSelection())
+                numColumns++;
+        final List<OutputColumn> outputColumns = new ArrayList<OutputColumn>(numColumns);
+        numColumns = 0;
+        for (int i = 0; i < outputs.size(); i++) {
+            final Output output = outputs.get(i);
+            if (output.enabledButton.getSelection()) {
+                final OutputColumn column = new OutputColumn();
+                column.name = output.nameLabel.getText();
+                outputColumns.add(column);
+            }
+        }
+        return outputColumns;
+    }
+
+    private class Output {
+        String name;
+        Button enabledButton;
+        Text nameLabel;
+        Button upButton;
+        Button downButton;
+
+        public Output(final Composite parent, final String name) {
+            this.name = name;
+
+            enabledButton = new Button(parent, SWT.CHECK);
+            enabledButton.setToolTipText(Messages.CustomXmlParserOutputWizardPage_visible);
+            enabledButton.setSelection(true);
+            enabledButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(final SelectionEvent e) {
+                    updatePreviewTable();
+                }
+            });
+            //            if (messageOutput != null) {
+            //                enabledButton.moveAbove(messageOutput.enabledButton);
+            //            }
+
+            nameLabel = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);
+            nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+            nameLabel.setText(name);
+            nameLabel.moveBelow(enabledButton);
+
+            upButton = new Button(parent, SWT.PUSH);
+            upButton.setImage(upImage);
+            upButton.setToolTipText(Messages.CustomXmlParserOutputWizardPage_moveBefore);
+            upButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(final SelectionEvent e) {
+                    moveBefore(Output.this);
+                }
+            });
+            upButton.moveBelow(nameLabel);
+
+            downButton = new Button(parent, SWT.PUSH);
+            downButton.setImage(downImage);
+            downButton.setToolTipText(Messages.CustomXmlParserOutputWizardPage_moveAfter);
+            downButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(final SelectionEvent e) {
+                    moveAfter(Output.this);
+                }
+            });
+            downButton.moveBelow(upButton);
+        }
+
+        private void dispose() {
+            enabledButton.dispose();
+            nameLabel.dispose();
+            upButton.dispose();
+            downButton.dispose();
+        }
+    }
+
+    public CustomXmlTraceDefinition getDefinition() {
+        return definition;
+    }
+
+}
index 235877f6eb49d27f32b3a4ac1b66bb502c41f420..d51b9e1c28db5eb26e80f6e6b5a1e781713b7b3c 100644 (file)
@@ -1,53 +1,53 @@
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.wizard.Wizard;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.ui.INewWizard;\r
-import org.eclipse.ui.IWorkbench;\r
-\r
-public class CustomXmlParserWizard extends Wizard implements INewWizard {\r
-\r
-    CustomXmlParserInputWizardPage inputPage;\r
-    CustomXmlParserOutputWizardPage outputPage;\r
-    private ISelection selection;\r
-    CustomXmlTraceDefinition definition;\r
-\r
-    public CustomXmlParserWizard() {\r
-        super();\r
-    }\r
-\r
-    public CustomXmlParserWizard(CustomXmlTraceDefinition definition) {\r
-        super();\r
-        this.definition = definition;\r
-    }\r
-\r
-    @Override\r
-    public boolean performFinish() {\r
-        CustomXmlTraceDefinition def = outputPage.getDefinition();\r
-        if (definition != null && !definition.definitionName.equals(def.definitionName)) {\r
-            CustomXmlTraceDefinition.delete(definition.definitionName);\r
-        }\r
-        def.save();\r
-        return true;\r
-    }\r
-\r
-    /**\r
-     * Adding the page to the wizard.\r
-     */\r
-\r
-    @Override\r
-       public void addPages() {\r
-        inputPage = new CustomXmlParserInputWizardPage(selection, definition);\r
-        addPage(inputPage);\r
-        outputPage = new CustomXmlParserOutputWizardPage(this);\r
-        addPage(outputPage);\r
-    }\r
-\r
-    @Override\r
-       public void init(IWorkbench workbench, IStructuredSelection selection) {\r
-        this.selection = selection;\r
-    }\r
-\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class CustomXmlParserWizard extends Wizard implements INewWizard {
+
+    CustomXmlParserInputWizardPage inputPage;
+    CustomXmlParserOutputWizardPage outputPage;
+    private ISelection selection;
+    CustomXmlTraceDefinition definition;
+
+    public CustomXmlParserWizard() {
+        super();
+    }
+
+    public CustomXmlParserWizard(CustomXmlTraceDefinition definition) {
+        super();
+        this.definition = definition;
+    }
+
+    @Override
+    public boolean performFinish() {
+        CustomXmlTraceDefinition def = outputPage.getDefinition();
+        if (definition != null && !definition.definitionName.equals(def.definitionName)) {
+            CustomXmlTraceDefinition.delete(definition.definitionName);
+        }
+        def.save();
+        return true;
+    }
+
+    /**
+     * Adding the page to the wizard.
+     */
+
+    @Override
+       public void addPages() {
+        inputPage = new CustomXmlParserInputWizardPage(selection, definition);
+        addPage(inputPage);
+        outputPage = new CustomXmlParserOutputWizardPage(this);
+        addPage(outputPage);
+    }
+
+    @Override
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.selection = selection;
+    }
+
+}
index 39f2bca7a4b8a37ab88d42de0498cdf162cbb256..0b86a99383cc8f8c7975c25de824e236e07c0922 100644 (file)
@@ -1,41 +1,41 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.signal;\r
-\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-/**\r
- * Signal that a trace was closed\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceClosedSignal extends TmfSignal {\r
-\r
-    private final ITmfTrace<?> fTrace;\r
-    \r
-    public TmfTraceClosedSignal(Object source, ITmfTrace<?> trace) {\r
-        super(source);\r
-        fTrace = trace;\r
-    }\r
-\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceClosedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.signal;
+
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Signal that a trace was closed
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceClosedSignal extends TmfSignal {
+
+    private final ITmfTrace<?> fTrace;
+    
+    public TmfTraceClosedSignal(Object source, ITmfTrace<?> trace) {
+        super(source);
+        fTrace = trace;
+    }
+
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceClosedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index e507897e7eb9e87c664cf08abf00562305f96237..66ee704562f40f9c99d47fb90f897500de44e4dc 100644 (file)
@@ -1,55 +1,55 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.signal;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;\r
-\r
-/**\r
- * Signal that a trace was opened\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceOpenedSignal extends TmfSignal {\r
-\r
-    private final ITmfTrace<?> fTrace;\r
-    private final IFile fBookmarksFile;\r
-    private final ITmfEventsFilterProvider fEventsFilterProvider;\r
-    \r
-    public TmfTraceOpenedSignal(Object source, ITmfTrace<?> trace, IFile bookmarksFile, ITmfEventsFilterProvider eventsFilterProvider) {\r
-        super(source);\r
-        fTrace = trace;\r
-        fBookmarksFile = bookmarksFile;\r
-        fEventsFilterProvider = eventsFilterProvider;\r
-    }\r
-\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    public IFile getBookmarksFile() {\r
-        return fBookmarksFile;\r
-    }\r
-\r
-    public ITmfEventsFilterProvider getEventsFilterProvider() {\r
-        return fEventsFilterProvider;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceOpenedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.signal;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;
+
+/**
+ * Signal that a trace was opened
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceOpenedSignal extends TmfSignal {
+
+    private final ITmfTrace<?> fTrace;
+    private final IFile fBookmarksFile;
+    private final ITmfEventsFilterProvider fEventsFilterProvider;
+    
+    public TmfTraceOpenedSignal(Object source, ITmfTrace<?> trace, IFile bookmarksFile, ITmfEventsFilterProvider eventsFilterProvider) {
+        super(source);
+        fTrace = trace;
+        fBookmarksFile = bookmarksFile;
+        fEventsFilterProvider = eventsFilterProvider;
+    }
+
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    public IFile getBookmarksFile() {
+        return fBookmarksFile;
+    }
+
+    public ITmfEventsFilterProvider getEventsFilterProvider() {
+        return fEventsFilterProvider;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceOpenedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index 521574860d544c1a849ca32e5538065a9040ea2a..05736c9fbf1e28a33e615d3b28cc37d263a4bcf2 100644 (file)
@@ -1,41 +1,41 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.signal;\r
-\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-\r
-/**\r
- * Signal that a trace parser was updated\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceParserUpdatedSignal extends TmfSignal {\r
-\r
-    private final IResource fTraceResource;\r
-    \r
-    public TmfTraceParserUpdatedSignal(Object source, IResource traceResource) {\r
-        super(source);\r
-        fTraceResource = traceResource;\r
-    }\r
-\r
-    public IResource getTraceResource() {\r
-        return fTraceResource;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceParserUpdatedSignal (" + fTraceResource.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.signal;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+
+/**
+ * Signal that a trace parser was updated
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceParserUpdatedSignal extends TmfSignal {
+
+    private final IResource fTraceResource;
+    
+    public TmfTraceParserUpdatedSignal(Object source, IResource traceResource) {
+        super(source);
+        fTraceResource = traceResource;
+    }
+
+    public IResource getTraceResource() {
+        return fTraceResource;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceParserUpdatedSignal (" + fTraceResource.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index 7ab06752741140a1d637cc5ce9c113bfa038821c..43359bf745800240dacdff870f9d0841f2ef83d5 100644 (file)
@@ -1,39 +1,39 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.editors;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-/**\r
- * The trace editor interface\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITmfTraceEditor {\r
-\r
-    /**\r
-     * Get the trace to which this editor is assigned\r
-     *\r
-     * @return The trace\r
-     */\r
-    public ITmfTrace<?> getTrace();\r
-\r
-    /**\r
-     * Get the bookmark file associated to this trace\r
-     *\r
-     * @return The IFile object pointing to the bookmark file\r
-     */\r
-    public IFile getBookmarksFile();\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.editors;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * The trace editor interface
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITmfTraceEditor {
+
+    /**
+     * Get the trace to which this editor is assigned
+     *
+     * @return The trace
+     */
+    public ITmfTrace<?> getTrace();
+
+    /**
+     * Get the bookmark file associated to this trace
+     *
+     * @return The IFile object pointing to the bookmark file
+     */
+    public IFile getBookmarksFile();
+}
index e5bfbf3af389831d02430706174d12ea8403e26f..f7fe0fef781f89ecda4ec5927420aab9108b175d 100644 (file)
@@ -1,62 +1,62 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.editors;\r
-\r
-import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;\r
-import org.eclipse.ui.part.EditorPart;\r
-\r
-/**\r
- * The main editor abstract class for use in TMF.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public abstract class TmfEditor extends EditorPart implements ITmfComponent {\r
-\r
-    private final String fName;\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructor\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Default constructor\r
-     */\r
-    public TmfEditor() {\r
-        super();\r
-        fName = "TmfEditor"; //$NON-NLS-1$\r
-        TmfSignalManager.register(this);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        TmfSignalManager.deregister(this);\r
-        super.dispose();\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // ITmfComponent\r
-    // ------------------------------------------------------------------------\r
-\r
-    @Override\r
-       public String getName() {\r
-        return fName;\r
-    }\r
-\r
-    @Override\r
-       public void broadcast(TmfSignal signal) {\r
-        TmfSignalManager.dispatchSignal(signal);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.editors;
+
+import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.ui.part.EditorPart;
+
+/**
+ * The main editor abstract class for use in TMF.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public abstract class TmfEditor extends EditorPart implements ITmfComponent {
+
+    private final String fName;
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     * Default constructor
+     */
+    public TmfEditor() {
+        super();
+        fName = "TmfEditor"; //$NON-NLS-1$
+        TmfSignalManager.register(this);
+    }
+
+    @Override
+    public void dispose() {
+        TmfSignalManager.deregister(this);
+        super.dispose();
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfComponent
+    // ------------------------------------------------------------------------
+
+    @Override
+       public String getName() {
+        return fName;
+    }
+
+    @Override
+       public void broadcast(TmfSignal signal) {
+        TmfSignalManager.dispatchSignal(signal);
+    }
+}
index d16a26ce62c0a268dcf87e063232a2663b38b84f..14667634c8388c1aa8487877642c7444617f5b61 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.editors;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.runtime.content.IContentType;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IPersistableElement;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.ide.IDE;\r
-\r
-/**\r
- * The input interface for TMF editors.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfEditorInput implements IEditorInput {\r
-\r
-    private final IFile fFile;\r
-    private final ITmfTrace<?> fTrace;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param file The IFile pointer\r
-     * @param trace Reference to the trace\r
-     */\r
-    public TmfEditorInput(IFile file, ITmfTrace<?> trace) {\r
-        fFile = file;\r
-        fTrace = trace;\r
-    }\r
-\r
-    @Override\r
-       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-       public boolean exists() {\r
-        return fFile.exists();\r
-    }\r
-\r
-    @Override\r
-       public ImageDescriptor getImageDescriptor() {\r
-        IContentType contentType = IDE.getContentType(fFile);\r
-        return PlatformUI.getWorkbench().getEditorRegistry()\r
-                .getImageDescriptor(fFile.getName(), contentType);\r
-    }\r
-\r
-    @Override\r
-       public String getName() {\r
-        return fTrace.getName();\r
-    }\r
-\r
-    @Override\r
-       public IPersistableElement getPersistable() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-       public String getToolTipText() {\r
-        return fFile.getFullPath().makeRelative().toString();\r
-    }\r
-\r
-    /**\r
-     * Get this editor input's file object\r
-     *\r
-     * @return The IFile\r
-     */\r
-    public IFile getFile() {\r
-        return fFile;\r
-    }\r
-\r
-    /**\r
-     * Get this editor input's trace\r
-     *\r
-     * @return The trace\r
-     */\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + ((fFile == null) ? 0 : fFile.getLocation().hashCode());\r
-        result = prime * result + ((fTrace == null) ? 0 : fTrace.getName().hashCode());\r
-        return result;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj == null) {\r
-            return false;\r
-        }\r
-        if (getClass() != obj.getClass()) {\r
-            return false;\r
-        }\r
-        TmfEditorInput other = (TmfEditorInput) obj;\r
-        if (fFile == null) {\r
-            if (other.fFile != null) {\r
-                return false;\r
-            }\r
-        } else if (!fFile.getLocation().equals(other.fFile.getLocation())) {\r
-            return false;\r
-        }\r
-        if (fTrace == null) {\r
-            if (other.fTrace != null) {\r
-                return false;\r
-            }\r
-        } else if (!fTrace.getName().equals(other.fTrace.getName())) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.editors;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * The input interface for TMF editors.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfEditorInput implements IEditorInput {
+
+    private final IFile fFile;
+    private final ITmfTrace<?> fTrace;
+
+    /**
+     * Standard constructor
+     *
+     * @param file The IFile pointer
+     * @param trace Reference to the trace
+     */
+    public TmfEditorInput(IFile file, ITmfTrace<?> trace) {
+        fFile = file;
+        fTrace = trace;
+    }
+
+    @Override
+       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+        return null;
+    }
+
+    @Override
+       public boolean exists() {
+        return fFile.exists();
+    }
+
+    @Override
+       public ImageDescriptor getImageDescriptor() {
+        IContentType contentType = IDE.getContentType(fFile);
+        return PlatformUI.getWorkbench().getEditorRegistry()
+                .getImageDescriptor(fFile.getName(), contentType);
+    }
+
+    @Override
+       public String getName() {
+        return fTrace.getName();
+    }
+
+    @Override
+       public IPersistableElement getPersistable() {
+        return null;
+    }
+
+    @Override
+       public String getToolTipText() {
+        return fFile.getFullPath().makeRelative().toString();
+    }
+
+    /**
+     * Get this editor input's file object
+     *
+     * @return The IFile
+     */
+    public IFile getFile() {
+        return fFile;
+    }
+
+    /**
+     * Get this editor input's trace
+     *
+     * @return The trace
+     */
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((fFile == null) ? 0 : fFile.getLocation().hashCode());
+        result = prime * result + ((fTrace == null) ? 0 : fTrace.getName().hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        TmfEditorInput other = (TmfEditorInput) obj;
+        if (fFile == null) {
+            if (other.fFile != null) {
+                return false;
+            }
+        } else if (!fFile.getLocation().equals(other.fFile.getLocation())) {
+            return false;
+        }
+        if (fTrace == null) {
+            if (other.fTrace != null) {
+                return false;
+            }
+        } else if (!fTrace.getName().equals(other.fTrace.getName())) {
+            return false;
+        }
+        return true;
+    }
+
+}
index c0567eab38e4dd547d706e8b005e18505fcace7d..c62463ae1dbb8c41cc36f49fc3b711d7400bb860 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.editors;\r
-\r
-import java.lang.reflect.Constructor;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.util.List;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.resources.IMarker;\r
-import org.eclipse.core.resources.IMarkerDelta;\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.core.resources.IResourceChangeEvent;\r
-import org.eclipse.core.resources.IResourceChangeListener;\r
-import org.eclipse.core.resources.IResourceDelta;\r
-import org.eclipse.core.resources.ResourcesPlugin;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.core.runtime.IConfigurationElement;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.InvalidRegistryObjectException;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.project.handlers.Messages;\r
-import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;\r
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;\r
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;\r
-import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal;\r
-import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal;\r
-import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.IEditorSite;\r
-import org.eclipse.ui.IFileEditorInput;\r
-import org.eclipse.ui.IPropertyListener;\r
-import org.eclipse.ui.IReusableEditor;\r
-import org.eclipse.ui.PartInitException;\r
-import org.eclipse.ui.ide.IGotoMarker;\r
-import org.eclipse.ui.part.FileEditorInput;\r
-import org.osgi.framework.Bundle;\r
-\r
-/**\r
- * Editor for TMF events\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReusableEditor, IPropertyListener, IResourceChangeListener {\r
-\r
-    /** ID for this class */\r
-    public static final String ID = "org.eclipse.linuxtools.tmf.ui.editors.events"; //$NON-NLS-1$\r
-\r
-    private TmfEventsTable fEventsTable;\r
-    private IFile fFile;\r
-    @SuppressWarnings("rawtypes")\r
-    private ITmfTrace fTrace;\r
-    private Composite fParent;\r
-\r
-    @Override\r
-    public void doSave(final IProgressMonitor monitor) {\r
-    }\r
-\r
-    @Override\r
-    public void doSaveAs() {\r
-    }\r
-\r
-    @SuppressWarnings({ "unchecked", "rawtypes" })\r
-    @Override\r
-    public void init(final IEditorSite site, IEditorInput input) throws PartInitException {\r
-        if (input instanceof TmfEditorInput) {\r
-            fFile = ((TmfEditorInput) input).getFile();\r
-            fTrace = ((TmfEditorInput) input).getTrace();\r
-            input = new FileEditorInput(fFile);\r
-        } else if (input instanceof IFileEditorInput) {\r
-            fFile = ((IFileEditorInput) input).getFile();\r
-            if (fFile == null)\r
-             {\r
-                throw new PartInitException("Invalid IFileEditorInput: " + input); //$NON-NLS-1$\r
-            }\r
-            try {\r
-                final String traceTypeId = fFile.getPersistentProperty(TmfCommonConstants.TRACETYPE);\r
-                if (traceTypeId == null) {\r
-                    throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);\r
-                }\r
-                if (traceTypeId.equals(TmfExperiment.class.getCanonicalName())) {\r
-                    // Special case: experiment bookmark resource\r
-                    final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();\r
-                    ncp.getChildren(fFile.getProject()); // force the model to be populated\r
-                    final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());\r
-                    if (project == null) {\r
-                        throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType);\r
-                    }\r
-                    for (final ITmfProjectModelElement projectElement : project.getExperimentsFolder().getChildren()) {\r
-                        final String traceName = fFile.getParent().getName();\r
-                        if (projectElement.getName().equals(traceName)) {\r
-                            final TmfExperimentElement experimentElement = (TmfExperimentElement) projectElement;\r
-                            // Instantiate the experiment's traces\r
-                            final List<TmfTraceElement> traceEntries = experimentElement.getTraces();\r
-                            final int nbTraces = traceEntries.size();\r
-                            int cacheSize = Integer.MAX_VALUE;\r
-                            final ITmfTrace<?>[] traces = new ITmfTrace[nbTraces];\r
-                            for (int i = 0; i < nbTraces; i++) {\r
-                                final TmfTraceElement traceElement = traceEntries.get(i);\r
-                                final ITmfTrace trace = traceElement.instantiateTrace();\r
-                                final ITmfEvent traceEvent = traceElement.instantiateEvent();\r
-                                if ((trace == null) || (traceEvent == null)) {\r
-                                    for (int j = 0; j < i; j++) {\r
-                                        traces[j].dispose();\r
-                                    }\r
-                                    throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType);\r
-                                }\r
-                                try {\r
-                                    trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());\r
-                                } catch (final TmfTraceException e) {\r
-                                }\r
-                                cacheSize = Math.min(cacheSize, trace.getCacheSize());\r
-                                traces[i] = trace;\r
-                            }\r
-                            final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize) {\r
-                                @Override\r
-                                public void initTrace(IResource resource, String path, Class type) {\r
-                                    super.initTrace(resource, path, type);\r
-                                    getIndexer().buildIndex(getNbEvents(), TmfTimeRange.ETERNITY, false);\r
-                                }\r
-                            };\r
-                            experiment.setBookmarksFile(fFile);\r
-                            fTrace = experiment;\r
-                            experiment.initTrace(null, null, null);\r
-                            break;\r
-                        }\r
-                    }\r
-                } else if (traceTypeId.equals(TmfTrace.class.getCanonicalName())) {\r
-                    // Special case: trace bookmark resource\r
-                    final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();\r
-                    ncp.getChildren(fFile.getProject()); // force the model to be populated\r
-                    final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());\r
-                    for (final ITmfProjectModelElement projectElement : project.getTracesFolder().getChildren()) {\r
-                        final String traceName = fFile.getParent().getName();\r
-                        if (projectElement.getName().equals(traceName)) {\r
-                            final TmfTraceElement traceElement = (TmfTraceElement) projectElement;\r
-                            // Instantiate the trace\r
-                            final ITmfTrace trace = traceElement.instantiateTrace();\r
-                            final ITmfEvent traceEvent = traceElement.instantiateEvent();\r
-                            if ((trace == null) || (traceEvent == null)) {\r
-                                throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);\r
-                            }\r
-                            try {\r
-                                trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());\r
-                            } catch (final TmfTraceException e) {\r
-                            }\r
-                            fTrace = trace;\r
-                            break;\r
-                        }\r
-                    }\r
-                } else {\r
-                    final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();\r
-                    ncp.getChildren(fFile.getProject()); // force the model to be populated\r
-                    final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());\r
-                    for (final ITmfProjectModelElement projectElement : project.getTracesFolder().getChildren()) {\r
-                        if (projectElement.getResource().equals(fFile)) {\r
-                            final TmfTraceElement traceElement = (TmfTraceElement) projectElement;\r
-                            // Instantiate the trace\r
-                            final ITmfTrace trace = traceElement.instantiateTrace();\r
-                            final ITmfEvent traceEvent = traceElement.instantiateEvent();\r
-                            if ((trace == null) || (traceEvent == null)) {\r
-                                throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);\r
-                            }\r
-                            try {\r
-                                trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());\r
-                            } catch (final TmfTraceException e) {\r
-                            }\r
-                            fTrace = trace;\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-            } catch (final InvalidRegistryObjectException e) {\r
-                Activator.getDefault().logError("Error initializing TmfEventsEditor", e); //$NON-NLS-1$\r
-            } catch (final CoreException e) {\r
-                Activator.getDefault().logError("Error initializing TmfEventsEditor", e); //$NON-NLS-1$\r
-            }\r
-        }\r
-        else {\r
-            throw new PartInitException("Invalid IEditorInput: " + input.getClass()); //$NON-NLS-1$\r
-        }\r
-        if (fTrace == null)\r
-         {\r
-            throw new PartInitException("Invalid IEditorInput: " + fFile.getName()); //$NON-NLS-1$\r
-        }\r
-        super.setSite(site);\r
-        super.setInput(input);\r
-    }\r
-\r
-    @Override\r
-    public boolean isDirty() {\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public boolean isSaveAsAllowed() {\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public void setInput(final IEditorInput input) {\r
-        super.setInput(input);\r
-        firePropertyChange(IEditorPart.PROP_INPUT);\r
-    }\r
-\r
-    @Override\r
-    public void propertyChanged(final Object source, final int propId) {\r
-        if (propId == IEditorPart.PROP_INPUT) {\r
-            broadcast(new TmfTraceClosedSignal(this, fTrace));\r
-            fFile = ((TmfEditorInput) getEditorInput()).getFile();\r
-            fTrace = ((TmfEditorInput) getEditorInput()).getTrace();\r
-            super.setInput(new FileEditorInput(fFile));\r
-            fEventsTable.dispose();\r
-            if (fTrace != null) {\r
-                fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());\r
-                fEventsTable.setTrace(fTrace, true);\r
-                fEventsTable.refreshBookmarks(fFile);\r
-                broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable));\r
-            } else {\r
-                fEventsTable = new TmfEventsTable(fParent, 0);\r
-            }\r
-            fParent.layout();\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void createPartControl(final Composite parent) {\r
-        fParent = parent;\r
-        if (fTrace != null) {\r
-            setPartName(fTrace.getName());\r
-            fEventsTable = createEventsTable(parent, fTrace.getCacheSize());\r
-            fEventsTable.setTrace(fTrace, true);\r
-            fEventsTable.refreshBookmarks(fFile);\r
-            broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable));\r
-        } else {\r
-            setPartName(getEditorInput().getName());\r
-            fEventsTable = new TmfEventsTable(parent, 0);\r
-        }\r
-        addPropertyListener(this);\r
-        ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);\r
-        removePropertyListener(this);\r
-        if (fTrace != null) {\r
-            broadcast(new TmfTraceClosedSignal(this, fTrace));\r
-        }\r
-        if (fEventsTable != null) {\r
-            fEventsTable.dispose();\r
-        }\r
-        super.dispose();\r
-    }\r
-\r
-    protected TmfEventsTable createEventsTable(final Composite parent, final int cacheSize) {\r
-        TmfEventsTable eventsTable = getEventsTable(parent, cacheSize);\r
-        if (eventsTable == null) {\r
-            eventsTable = new TmfEventsTable(parent, cacheSize);\r
-        }\r
-        return eventsTable;\r
-    }\r
-\r
-    private TmfEventsTable getEventsTable(final Composite parent, final int cacheSize) {\r
-        if (fTrace instanceof TmfExperiment) {\r
-            return getExperimentEventsTable((TmfExperiment<?>) fTrace, parent, cacheSize);\r
-        }\r
-        TmfEventsTable eventsTable = null;\r
-        try {\r
-            if (fTrace.getResource() == null) {\r
-                return null;\r
-            }\r
-            final String traceType = fTrace.getResource().getPersistentProperty(TmfCommonConstants.TRACETYPE);\r
-            if (traceType == null) {\r
-                return null;\r
-            }\r
-            if (traceType.startsWith(CustomTxtTrace.class.getCanonicalName())) {\r
-                return new CustomEventsTable(((CustomTxtTrace) fTrace).getDefinition(), parent, cacheSize);\r
-            }\r
-            if (traceType.startsWith(CustomXmlTrace.class.getCanonicalName())) {\r
-                return new CustomEventsTable(((CustomXmlTrace) fTrace).getDefinition(), parent, cacheSize);\r
-            }\r
-            for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
-                if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) {\r
-                    final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM);\r
-                    if (eventsTableTypeCE.length != 1) {\r
-                        break;\r
-                    }\r
-                    final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR);\r
-                    if ((eventsTableType == null) || (eventsTableType.length() == 0)) {\r
-                        break;\r
-                    }\r
-                    final Bundle bundle = Platform.getBundle(ce.getContributor().getName());\r
-                    final Class<?> c = bundle.loadClass(eventsTableType);\r
-                    final Class<?>[] constructorArgs = new Class[] { Composite.class, int.class };\r
-                    final Constructor<?> constructor = c.getConstructor(constructorArgs);\r
-                    final Object[] args = new Object[] { parent, cacheSize };\r
-                    eventsTable = (TmfEventsTable) constructor.newInstance(args);\r
-                    break;\r
-                }\r
-            }\r
-        } catch (final InvalidRegistryObjectException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final CoreException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final ClassNotFoundException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final SecurityException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final NoSuchMethodException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final IllegalArgumentException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final InstantiationException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final IllegalAccessException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        } catch (final InvocationTargetException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$\r
-        }\r
-        return eventsTable;\r
-    }\r
-\r
-    /**\r
-     * Get the events table for an experiment. If all traces in the experiment\r
-     * are of the same type, use the extension point specified event table\r
-     *\r
-     * @param experiment\r
-     *            the experiment\r
-     * @param parent\r
-     *            the parent Composite\r
-     * @param cacheSize\r
-     *            the event table cache size\r
-     * @return an events table of the appropriate type\r
-     */\r
-    private static TmfEventsTable getExperimentEventsTable(\r
-            final TmfExperiment<?> experiment, final Composite parent,\r
-            final int cacheSize) {\r
-        TmfEventsTable eventsTable = null;\r
-        String commonTraceType = null;\r
-        try {\r
-            for (final ITmfTrace<?> trace : experiment.getTraces()) {\r
-                final IResource resource = trace.getResource();\r
-                if (resource == null) {\r
-                    return null;\r
-                }\r
-                final String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE);\r
-                if ((commonTraceType != null) && !commonTraceType.equals(traceType)) {\r
-                    return null;\r
-                }\r
-                commonTraceType = traceType;\r
-            }\r
-            if (commonTraceType == null) {\r
-                return null;\r
-            }\r
-            if (commonTraceType.startsWith(CustomTxtTrace.class.getCanonicalName())) {\r
-                return new CustomEventsTable(((CustomTxtTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize);\r
-            }\r
-            if (commonTraceType.startsWith(CustomXmlTrace.class.getCanonicalName())) {\r
-                return new CustomEventsTable(((CustomXmlTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize);\r
-            }\r
-            for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
-                if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(commonTraceType)) {\r
-                    final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM);\r
-                    if (eventsTableTypeCE.length != 1) {\r
-                        break;\r
-                    }\r
-                    final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR);\r
-                    if ((eventsTableType == null) || (eventsTableType.length() == 0)) {\r
-                        break;\r
-                    }\r
-                    final Bundle bundle = Platform.getBundle(ce.getContributor().getName());\r
-                    final Class<?> c = bundle.loadClass(eventsTableType);\r
-                    final Class<?>[] constructorArgs = new Class[] { Composite.class, int.class };\r
-                    final Constructor<?> constructor = c.getConstructor(constructorArgs);\r
-                    final Object[] args = new Object[] { parent, cacheSize };\r
-                    eventsTable = (TmfEventsTable) constructor.newInstance(args);\r
-                    break;\r
-                }\r
-            }\r
-        } catch (final CoreException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final InvalidRegistryObjectException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final SecurityException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final IllegalArgumentException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final ClassNotFoundException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final NoSuchMethodException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final InstantiationException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final IllegalAccessException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        } catch (final InvocationTargetException e) {\r
-            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$\r
-        }\r
-        return eventsTable;\r
-    }\r
-\r
-    @Override\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    @Override\r
-    public IFile getBookmarksFile() {\r
-        return fFile;\r
-    }\r
-\r
-    @Override\r
-    public void setFocus() {\r
-        fEventsTable.setFocus();\r
-        if (fTrace != null) {\r
-            broadcast(new TmfTraceSelectedSignal(this, fTrace));\r
-        }\r
-    }\r
-\r
-    @Override\r
-    @SuppressWarnings("rawtypes")\r
-    public Object getAdapter(final Class adapter) {\r
-        if (IGotoMarker.class.equals(adapter)) {\r
-            return fEventsTable;\r
-        }\r
-        return super.getAdapter(adapter);\r
-    }\r
-\r
-    @Override\r
-    public void resourceChanged(final IResourceChangeEvent event) {\r
-        for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {\r
-            if (delta.getResource().equals(fFile)) {\r
-                if (delta.getKind() == IResourceDelta.REMOVED) {\r
-                    final IMarker bookmark = delta.getMarker();\r
-                    Display.getDefault().asyncExec(new Runnable() {\r
-                        @Override\r
-                        public void run() {\r
-                            fEventsTable.removeBookmark(bookmark);\r
-                        }\r
-                    });\r
-                } else if (delta.getKind() == IResourceDelta.CHANGED) {\r
-                    Display.getDefault().asyncExec(new Runnable() {\r
-                        @Override\r
-                        public void run() {\r
-                            fEventsTable.getTable().refresh();\r
-                        }\r
-                    });\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Global commands\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Add a bookmark\r
-     */\r
-    public void addBookmark() {\r
-        fEventsTable.addBookmark(fFile);\r
-    }\r
-\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Signal handlers\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Handler for the Trace Parser Updated signal\r
-     *\r
-     * @param signal The incoming signal\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    @TmfSignalHandler\r
-    public void traceParserUpdated(final TmfTraceParserUpdatedSignal signal) {\r
-        if (signal.getTraceResource().equals(fFile)) {\r
-            broadcast(new TmfTraceClosedSignal(this, fTrace));\r
-            try {\r
-                fTrace.getName();\r
-                fTrace = null;\r
-                final String traceTypeId = fFile.getPersistentProperty(TmfCommonConstants.TRACETYPE);\r
-                if (traceTypeId != null) {\r
-                    for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
-                        if (traceTypeId.equals(ce.getAttribute(TmfTraceType.ID_ATTR))) {\r
-                            fTrace = (ITmfTrace<?>) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);\r
-                            final ITmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);\r
-                            final String path = fFile.getLocationURI().getPath();\r
-                            fTrace.initTrace(null, path, event.getClass());\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-            } catch (final InvalidRegistryObjectException e) {\r
-                Activator.getDefault().logError("Error handling signal TmfTraceParserUpdatedSignal", e); //$NON-NLS-1$\r
-            } catch (final TmfTraceException e) {\r
-                Activator.getDefault().logError("Error handling signal TmfTraceParserUpdatedSignal", e); //$NON-NLS-1$\r
-            } catch (final CoreException e) {\r
-                Activator.getDefault().logError("Error handling signal TmfTraceParserUpdatedSignal", e); //$NON-NLS-1$\r
-            }\r
-            fEventsTable.dispose();\r
-            if (fTrace != null) {\r
-                fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());\r
-                fEventsTable.setTrace(fTrace, true);\r
-                broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable));\r
-            } else {\r
-                fEventsTable = new TmfEventsTable(fParent, 0);\r
-            }\r
-            fParent.layout();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Handler for the Trace Selected signal\r
-     *\r
-     * @param signal The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void traceSelected(final TmfTraceSelectedSignal signal) {\r
-        if ((signal.getSource() != this) && signal.getTrace().equals(fTrace)) {\r
-            getSite().getPage().bringToTop(this);\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.editors;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomEventsTable;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.project.handlers.Messages;
+import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal;
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal;
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.part.FileEditorInput;
+import org.osgi.framework.Bundle;
+
+/**
+ * Editor for TMF events
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReusableEditor, IPropertyListener, IResourceChangeListener {
+
+    /** ID for this class */
+    public static final String ID = "org.eclipse.linuxtools.tmf.ui.editors.events"; //$NON-NLS-1$
+
+    private TmfEventsTable fEventsTable;
+    private IFile fFile;
+    @SuppressWarnings("rawtypes")
+    private ITmfTrace fTrace;
+    private Composite fParent;
+
+    @Override
+    public void doSave(final IProgressMonitor monitor) {
+    }
+
+    @Override
+    public void doSaveAs() {
+    }
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @Override
+    public void init(final IEditorSite site, IEditorInput input) throws PartInitException {
+        if (input instanceof TmfEditorInput) {
+            fFile = ((TmfEditorInput) input).getFile();
+            fTrace = ((TmfEditorInput) input).getTrace();
+            input = new FileEditorInput(fFile);
+        } else if (input instanceof IFileEditorInput) {
+            fFile = ((IFileEditorInput) input).getFile();
+            if (fFile == null)
+             {
+                throw new PartInitException("Invalid IFileEditorInput: " + input); //$NON-NLS-1$
+            }
+            try {
+                final String traceTypeId = fFile.getPersistentProperty(TmfCommonConstants.TRACETYPE);
+                if (traceTypeId == null) {
+                    throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);
+                }
+                if (traceTypeId.equals(TmfExperiment.class.getCanonicalName())) {
+                    // Special case: experiment bookmark resource
+                    final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();
+                    ncp.getChildren(fFile.getProject()); // force the model to be populated
+                    final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());
+                    if (project == null) {
+                        throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType);
+                    }
+                    for (final ITmfProjectModelElement projectElement : project.getExperimentsFolder().getChildren()) {
+                        final String traceName = fFile.getParent().getName();
+                        if (projectElement.getName().equals(traceName)) {
+                            final TmfExperimentElement experimentElement = (TmfExperimentElement) projectElement;
+                            // Instantiate the experiment's traces
+                            final List<TmfTraceElement> traceEntries = experimentElement.getTraces();
+                            final int nbTraces = traceEntries.size();
+                            int cacheSize = Integer.MAX_VALUE;
+                            final ITmfTrace<?>[] traces = new ITmfTrace[nbTraces];
+                            for (int i = 0; i < nbTraces; i++) {
+                                final TmfTraceElement traceElement = traceEntries.get(i);
+                                final ITmfTrace trace = traceElement.instantiateTrace();
+                                final ITmfEvent traceEvent = traceElement.instantiateEvent();
+                                if ((trace == null) || (traceEvent == null)) {
+                                    for (int j = 0; j < i; j++) {
+                                        traces[j].dispose();
+                                    }
+                                    throw new PartInitException(Messages.OpenExperimentHandler_NoTraceType);
+                                }
+                                try {
+                                    trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());
+                                } catch (final TmfTraceException e) {
+                                }
+                                cacheSize = Math.min(cacheSize, trace.getCacheSize());
+                                traces[i] = trace;
+                            }
+                            final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize) {
+                                @Override
+                                public void initTrace(IResource resource, String path, Class type) {
+                                    super.initTrace(resource, path, type);
+                                    getIndexer().buildIndex(getNbEvents(), TmfTimeRange.ETERNITY, false);
+                                }
+                            };
+                            experiment.setBookmarksFile(fFile);
+                            fTrace = experiment;
+                            experiment.initTrace(null, null, null);
+                            break;
+                        }
+                    }
+                } else if (traceTypeId.equals(TmfTrace.class.getCanonicalName())) {
+                    // Special case: trace bookmark resource
+                    final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();
+                    ncp.getChildren(fFile.getProject()); // force the model to be populated
+                    final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());
+                    for (final ITmfProjectModelElement projectElement : project.getTracesFolder().getChildren()) {
+                        final String traceName = fFile.getParent().getName();
+                        if (projectElement.getName().equals(traceName)) {
+                            final TmfTraceElement traceElement = (TmfTraceElement) projectElement;
+                            // Instantiate the trace
+                            final ITmfTrace trace = traceElement.instantiateTrace();
+                            final ITmfEvent traceEvent = traceElement.instantiateEvent();
+                            if ((trace == null) || (traceEvent == null)) {
+                                throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);
+                            }
+                            try {
+                                trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());
+                            } catch (final TmfTraceException e) {
+                            }
+                            fTrace = trace;
+                            break;
+                        }
+                    }
+                } else {
+                    final TmfNavigatorContentProvider ncp = new TmfNavigatorContentProvider();
+                    ncp.getChildren(fFile.getProject()); // force the model to be populated
+                    final TmfProjectElement project = TmfProjectRegistry.getProject(fFile.getProject());
+                    for (final ITmfProjectModelElement projectElement : project.getTracesFolder().getChildren()) {
+                        if (projectElement.getResource().equals(fFile)) {
+                            final TmfTraceElement traceElement = (TmfTraceElement) projectElement;
+                            // Instantiate the trace
+                            final ITmfTrace trace = traceElement.instantiateTrace();
+                            final ITmfEvent traceEvent = traceElement.instantiateEvent();
+                            if ((trace == null) || (traceEvent == null)) {
+                                throw new PartInitException(Messages.OpenTraceHandler_NoTraceType);
+                            }
+                            try {
+                                trace.initTrace(traceElement.getResource(), traceElement.getLocation().getPath(), traceEvent.getClass());
+                            } catch (final TmfTraceException e) {
+                            }
+                            fTrace = trace;
+                            break;
+                        }
+                    }
+                }
+            } catch (final InvalidRegistryObjectException e) {
+                Activator.getDefault().logError("Error initializing TmfEventsEditor", e); //$NON-NLS-1$
+            } catch (final CoreException e) {
+                Activator.getDefault().logError("Error initializing TmfEventsEditor", e); //$NON-NLS-1$
+            }
+        }
+        else {
+            throw new PartInitException("Invalid IEditorInput: " + input.getClass()); //$NON-NLS-1$
+        }
+        if (fTrace == null)
+         {
+            throw new PartInitException("Invalid IEditorInput: " + fFile.getName()); //$NON-NLS-1$
+        }
+        super.setSite(site);
+        super.setInput(input);
+    }
+
+    @Override
+    public boolean isDirty() {
+        return false;
+    }
+
+    @Override
+    public boolean isSaveAsAllowed() {
+        return false;
+    }
+
+    @Override
+    public void setInput(final IEditorInput input) {
+        super.setInput(input);
+        firePropertyChange(IEditorPart.PROP_INPUT);
+    }
+
+    @Override
+    public void propertyChanged(final Object source, final int propId) {
+        if (propId == IEditorPart.PROP_INPUT) {
+            broadcast(new TmfTraceClosedSignal(this, fTrace));
+            fFile = ((TmfEditorInput) getEditorInput()).getFile();
+            fTrace = ((TmfEditorInput) getEditorInput()).getTrace();
+            super.setInput(new FileEditorInput(fFile));
+            fEventsTable.dispose();
+            if (fTrace != null) {
+                fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());
+                fEventsTable.setTrace(fTrace, true);
+                fEventsTable.refreshBookmarks(fFile);
+                broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable));
+            } else {
+                fEventsTable = new TmfEventsTable(fParent, 0);
+            }
+            fParent.layout();
+        }
+    }
+
+    @Override
+    public void createPartControl(final Composite parent) {
+        fParent = parent;
+        if (fTrace != null) {
+            setPartName(fTrace.getName());
+            fEventsTable = createEventsTable(parent, fTrace.getCacheSize());
+            fEventsTable.setTrace(fTrace, true);
+            fEventsTable.refreshBookmarks(fFile);
+            broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable));
+        } else {
+            setPartName(getEditorInput().getName());
+            fEventsTable = new TmfEventsTable(parent, 0);
+        }
+        addPropertyListener(this);
+        ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+    }
+
+    @Override
+    public void dispose() {
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+        removePropertyListener(this);
+        if (fTrace != null) {
+            broadcast(new TmfTraceClosedSignal(this, fTrace));
+        }
+        if (fEventsTable != null) {
+            fEventsTable.dispose();
+        }
+        super.dispose();
+    }
+
+    protected TmfEventsTable createEventsTable(final Composite parent, final int cacheSize) {
+        TmfEventsTable eventsTable = getEventsTable(parent, cacheSize);
+        if (eventsTable == null) {
+            eventsTable = new TmfEventsTable(parent, cacheSize);
+        }
+        return eventsTable;
+    }
+
+    private TmfEventsTable getEventsTable(final Composite parent, final int cacheSize) {
+        if (fTrace instanceof TmfExperiment) {
+            return getExperimentEventsTable((TmfExperiment<?>) fTrace, parent, cacheSize);
+        }
+        TmfEventsTable eventsTable = null;
+        try {
+            if (fTrace.getResource() == null) {
+                return null;
+            }
+            final String traceType = fTrace.getResource().getPersistentProperty(TmfCommonConstants.TRACETYPE);
+            if (traceType == null) {
+                return null;
+            }
+            if (traceType.startsWith(CustomTxtTrace.class.getCanonicalName())) {
+                return new CustomEventsTable(((CustomTxtTrace) fTrace).getDefinition(), parent, cacheSize);
+            }
+            if (traceType.startsWith(CustomXmlTrace.class.getCanonicalName())) {
+                return new CustomEventsTable(((CustomXmlTrace) fTrace).getDefinition(), parent, cacheSize);
+            }
+            for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) {
+                if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) {
+                    final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM);
+                    if (eventsTableTypeCE.length != 1) {
+                        break;
+                    }
+                    final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR);
+                    if ((eventsTableType == null) || (eventsTableType.length() == 0)) {
+                        break;
+                    }
+                    final Bundle bundle = Platform.getBundle(ce.getContributor().getName());
+                    final Class<?> c = bundle.loadClass(eventsTableType);
+                    final Class<?>[] constructorArgs = new Class[] { Composite.class, int.class };
+                    final Constructor<?> constructor = c.getConstructor(constructorArgs);
+                    final Object[] args = new Object[] { parent, cacheSize };
+                    eventsTable = (TmfEventsTable) constructor.newInstance(args);
+                    break;
+                }
+            }
+        } catch (final InvalidRegistryObjectException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final CoreException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final ClassNotFoundException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final SecurityException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final NoSuchMethodException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final IllegalArgumentException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final InstantiationException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final IllegalAccessException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        } catch (final InvocationTargetException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable", e); //$NON-NLS-1$
+        }
+        return eventsTable;
+    }
+
+    /**
+     * Get the events table for an experiment. If all traces in the experiment
+     * are of the same type, use the extension point specified event table
+     *
+     * @param experiment
+     *            the experiment
+     * @param parent
+     *            the parent Composite
+     * @param cacheSize
+     *            the event table cache size
+     * @return an events table of the appropriate type
+     */
+    private static TmfEventsTable getExperimentEventsTable(
+            final TmfExperiment<?> experiment, final Composite parent,
+            final int cacheSize) {
+        TmfEventsTable eventsTable = null;
+        String commonTraceType = null;
+        try {
+            for (final ITmfTrace<?> trace : experiment.getTraces()) {
+                final IResource resource = trace.getResource();
+                if (resource == null) {
+                    return null;
+                }
+                final String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE);
+                if ((commonTraceType != null) && !commonTraceType.equals(traceType)) {
+                    return null;
+                }
+                commonTraceType = traceType;
+            }
+            if (commonTraceType == null) {
+                return null;
+            }
+            if (commonTraceType.startsWith(CustomTxtTrace.class.getCanonicalName())) {
+                return new CustomEventsTable(((CustomTxtTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize);
+            }
+            if (commonTraceType.startsWith(CustomXmlTrace.class.getCanonicalName())) {
+                return new CustomEventsTable(((CustomXmlTrace) experiment.getTraces()[0]).getDefinition(), parent, cacheSize);
+            }
+            for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) {
+                if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(commonTraceType)) {
+                    final IConfigurationElement[] eventsTableTypeCE = ce.getChildren(TmfTraceType.EVENTS_TABLE_TYPE_ELEM);
+                    if (eventsTableTypeCE.length != 1) {
+                        break;
+                    }
+                    final String eventsTableType = eventsTableTypeCE[0].getAttribute(TmfTraceType.CLASS_ATTR);
+                    if ((eventsTableType == null) || (eventsTableType.length() == 0)) {
+                        break;
+                    }
+                    final Bundle bundle = Platform.getBundle(ce.getContributor().getName());
+                    final Class<?> c = bundle.loadClass(eventsTableType);
+                    final Class<?>[] constructorArgs = new Class[] { Composite.class, int.class };
+                    final Constructor<?> constructor = c.getConstructor(constructorArgs);
+                    final Object[] args = new Object[] { parent, cacheSize };
+                    eventsTable = (TmfEventsTable) constructor.newInstance(args);
+                    break;
+                }
+            }
+        } catch (final CoreException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final InvalidRegistryObjectException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final SecurityException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final IllegalArgumentException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final ClassNotFoundException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final NoSuchMethodException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final InstantiationException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final IllegalAccessException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        } catch (final InvocationTargetException e) {
+            Activator.getDefault().logError("Error getting TmfEventsTable for experiment", e); //$NON-NLS-1$
+        }
+        return eventsTable;
+    }
+
+    @Override
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    @Override
+    public IFile getBookmarksFile() {
+        return fFile;
+    }
+
+    @Override
+    public void setFocus() {
+        fEventsTable.setFocus();
+        if (fTrace != null) {
+            broadcast(new TmfTraceSelectedSignal(this, fTrace));
+        }
+    }
+
+    @Override
+    @SuppressWarnings("rawtypes")
+    public Object getAdapter(final Class adapter) {
+        if (IGotoMarker.class.equals(adapter)) {
+            return fEventsTable;
+        }
+        return super.getAdapter(adapter);
+    }
+
+    @Override
+    public void resourceChanged(final IResourceChangeEvent event) {
+        for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
+            if (delta.getResource().equals(fFile)) {
+                if (delta.getKind() == IResourceDelta.REMOVED) {
+                    final IMarker bookmark = delta.getMarker();
+                    Display.getDefault().asyncExec(new Runnable() {
+                        @Override
+                        public void run() {
+                            fEventsTable.removeBookmark(bookmark);
+                        }
+                    });
+                } else if (delta.getKind() == IResourceDelta.CHANGED) {
+                    Display.getDefault().asyncExec(new Runnable() {
+                        @Override
+                        public void run() {
+                            fEventsTable.getTable().refresh();
+                        }
+                    });
+                }
+            }
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Global commands
+    // ------------------------------------------------------------------------
+
+    /**
+     * Add a bookmark
+     */
+    public void addBookmark() {
+        fEventsTable.addBookmark(fFile);
+    }
+
+
+    // ------------------------------------------------------------------------
+    // Signal handlers
+    // ------------------------------------------------------------------------
+
+    /**
+     * Handler for the Trace Parser Updated signal
+     *
+     * @param signal The incoming signal
+     */
+    @SuppressWarnings("unchecked")
+    @TmfSignalHandler
+    public void traceParserUpdated(final TmfTraceParserUpdatedSignal signal) {
+        if (signal.getTraceResource().equals(fFile)) {
+            broadcast(new TmfTraceClosedSignal(this, fTrace));
+            try {
+                fTrace.getName();
+                fTrace = null;
+                final String traceTypeId = fFile.getPersistentProperty(TmfCommonConstants.TRACETYPE);
+                if (traceTypeId != null) {
+                    for (final IConfigurationElement ce : TmfTraceType.getTypeElements()) {
+                        if (traceTypeId.equals(ce.getAttribute(TmfTraceType.ID_ATTR))) {
+                            fTrace = (ITmfTrace<?>) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
+                            final ITmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);
+                            final String path = fFile.getLocationURI().getPath();
+                            fTrace.initTrace(null, path, event.getClass());
+                            break;
+                        }
+                    }
+                }
+            } catch (final InvalidRegistryObjectException e) {
+                Activator.getDefault().logError("Error handling signal TmfTraceParserUpdatedSignal", e); //$NON-NLS-1$
+            } catch (final TmfTraceException e) {
+                Activator.getDefault().logError("Error handling signal TmfTraceParserUpdatedSignal", e); //$NON-NLS-1$
+            } catch (final CoreException e) {
+                Activator.getDefault().logError("Error handling signal TmfTraceParserUpdatedSignal", e); //$NON-NLS-1$
+            }
+            fEventsTable.dispose();
+            if (fTrace != null) {
+                fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());
+                fEventsTable.setTrace(fTrace, true);
+                broadcast(new TmfTraceOpenedSignal(this, fTrace, fFile, fEventsTable));
+            } else {
+                fEventsTable = new TmfEventsTable(fParent, 0);
+            }
+            fParent.layout();
+        }
+    }
+
+    /**
+     * Handler for the Trace Selected signal
+     *
+     * @param signal The incoming signal
+     */
+    @TmfSignalHandler
+    public void traceSelected(final TmfTraceSelectedSignal signal) {
+        if ((signal.getSource() != this) && signal.getTrace().equals(fTrace)) {
+            getSite().getPage().bringToTop(this);
+        }
+    }
+
+}
index 81c914e1ec9a781d17d99efbe35cb272f92c4498..264f1f032a633a70718f086320be1da51a626554 100644 (file)
@@ -1,62 +1,62 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.editors;\r
-\r
-import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;\r
-import org.eclipse.ui.part.MultiPageEditorPart;\r
-\r
-/**\r
- * Multi-page editor part abstract class for use in TMF.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public abstract class TmfMultiPageEditorPart extends MultiPageEditorPart implements ITmfComponent {\r
-\r
-    private final String fName;\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructor\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Default constructor\r
-     */\r
-    public TmfMultiPageEditorPart() {\r
-        super();\r
-        fName = "TmfMultiPageEditorPart"; //$NON-NLS-1$\r
-        TmfSignalManager.register(this);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        TmfSignalManager.deregister(this);\r
-        super.dispose();\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // ITmfComponent\r
-    // ------------------------------------------------------------------------\r
-\r
-    @Override\r
-       public String getName() {\r
-        return fName;\r
-    }\r
-\r
-    @Override\r
-       public void broadcast(TmfSignal signal) {\r
-        TmfSignalManager.dispatchSignal(signal);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.editors;
+
+import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.ui.part.MultiPageEditorPart;
+
+/**
+ * Multi-page editor part abstract class for use in TMF.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public abstract class TmfMultiPageEditorPart extends MultiPageEditorPart implements ITmfComponent {
+
+    private final String fName;
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     * Default constructor
+     */
+    public TmfMultiPageEditorPart() {
+        super();
+        fName = "TmfMultiPageEditorPart"; //$NON-NLS-1$
+        TmfSignalManager.register(this);
+    }
+
+    @Override
+    public void dispose() {
+        TmfSignalManager.deregister(this);
+        super.dispose();
+    }
+
+    // ------------------------------------------------------------------------
+    // ITmfComponent
+    // ------------------------------------------------------------------------
+
+    @Override
+       public String getName() {
+        return fName;
+    }
+
+    @Override
+       public void broadcast(TmfSignal signal) {
+        TmfSignalManager.dispatchSignal(signal);
+    }
+}
index 52a83b54ff1869450131d9797c62e64a92b486d9..50caab24dbb3963d3bda1b5c5265657d1b1a3bd0 100644 (file)
@@ -102,33 +102,73 @@ public class TmfExperimentFolder extends TmfProjectModelElement implements IProp
     }
 
     // ------------------------------------------------------------------------
-    // IPropertySource2\r    // ------------------------------------------------------------------------\r
+    // IPropertySource2
+    // ------------------------------------------------------------------------
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
-     */\r    @Override\r    public Object getEditableValue() {\r        return null;\r    }\r
+     */
+    @Override
+    public Object getEditableValue() {
+        return null;
+    }
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
-     */\r    @Override\r    public IPropertyDescriptor[] getPropertyDescriptors() {\r        return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null;\r    }\r    
+     */
+    @Override
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null;
+    }
+    
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
-     */\r    @Override\r    public Object getPropertyValue(Object id) {\r\r        if (sfName.equals(id))\r            return getName();\r\r        if (sfPath.equals(id))\r            return getPath().toString();\r\r        if (sfLocation.equals(id))\r            return getLocation().toString();\r\r        return null;\r    }\r    /*
+     */
+    @Override
+    public Object getPropertyValue(Object id) {
+
+        if (sfName.equals(id))
+            return getName();
+
+        if (sfPath.equals(id))
+            return getPath().toString();
+
+        if (sfLocation.equals(id))
+            return getLocation().toString();
+
+        return null;
+    }
+    /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
-     */\r    @Override\r    public void resetPropertyValue(Object id) {\r    }\r
+     */
+    @Override
+    public void resetPropertyValue(Object id) {
+    }
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
-     */\r    @Override\r    public void setPropertyValue(Object id, Object value) {\r    }\r
+     */
+    @Override
+    public void setPropertyValue(Object id, Object value) {
+    }
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
-     */\r    @Override\r    public boolean isPropertyResettable(Object id) {\r        return false;\r    }\r
+     */
+    @Override
+    public boolean isPropertyResettable(Object id) {
+        return false;
+    }
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
-     */\r    @Override\r    public boolean isPropertySet(Object id) {\r        return false;\r    }
+     */
+    @Override
+    public boolean isPropertySet(Object id) {
+        return false;
+    }
+
+}
 
-}\r\r
\ No newline at end of file
index 0214cf307de35aef297661ec521c328d7be5aedb..9b744b849589bd2e366aece10c7b850586bea47b 100644 (file)
@@ -1,54 +1,54 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.signal;\r
-\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-/**\r
- * Signal indicating a trace is now closed\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceClosedSignal extends TmfSignal {\r
-\r
-    private final ITmfTrace<?> fTrace;\r
-\r
-    /**\r
-     * Constructor for a new signal\r
-     *\r
-     * @param source\r
-     *            The object sending this signal\r
-     * @param trace\r
-     *            The trace being closed\r
-     */\r
-    public TmfTraceClosedSignal(Object source, ITmfTrace<?> trace) {\r
-        super(source);\r
-        fTrace = trace;\r
-    }\r
-\r
-    /**\r
-     * Get a reference to the trace being closed\r
-     *\r
-     * @return The trace object\r
-     */\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceClosedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.signal;
+
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Signal indicating a trace is now closed
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceClosedSignal extends TmfSignal {
+
+    private final ITmfTrace<?> fTrace;
+
+    /**
+     * Constructor for a new signal
+     *
+     * @param source
+     *            The object sending this signal
+     * @param trace
+     *            The trace being closed
+     */
+    public TmfTraceClosedSignal(Object source, ITmfTrace<?> trace) {
+        super(source);
+        fTrace = trace;
+    }
+
+    /**
+     * Get a reference to the trace being closed
+     *
+     * @return The trace object
+     */
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceClosedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index 5a3d6182d9a2ee6b2957d4b6f31bafdd11f614ad..0323c46e653c1386831c34f8789fd2766270f1ae 100644 (file)
@@ -1,83 +1,83 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.signal;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;\r
-\r
-/**\r
- * Signal indicating a trace has been opened.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceOpenedSignal extends TmfSignal {\r
-\r
-    private final ITmfTrace<?> fTrace;\r
-    private final IFile fBookmarksFile;\r
-    private final ITmfEventsFilterProvider fEventsFilterProvider;\r
-\r
-    /**\r
-     * Constructor for a new signal.\r
-     *\r
-     * @param source\r
-     *            The object sending this signal\r
-     * @param trace\r
-     *            The trace that has been opened\r
-     * @param bookmarksFile\r
-     *            Pointer to the bookmark file\r
-     * @param eventsFilterProvider\r
-     *            Provider for the event filter in use\r
-     */\r
-    public TmfTraceOpenedSignal(Object source, ITmfTrace<?> trace,\r
-            IFile bookmarksFile, ITmfEventsFilterProvider eventsFilterProvider) {\r
-        super(source);\r
-        fTrace = trace;\r
-        fBookmarksFile = bookmarksFile;\r
-        fEventsFilterProvider = eventsFilterProvider;\r
-    }\r
-\r
-    /**\r
-     * Get the trace object concerning this signal\r
-     *\r
-     * @return The trace\r
-     */\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    /**\r
-     * Get a pointer to the bookmark file of this trace\r
-     *\r
-     * @return The IFile object\r
-     */\r
-    public IFile getBookmarksFile() {\r
-        return fBookmarksFile;\r
-    }\r
-\r
-    /**\r
-     * Get the events filter provider of this trace\r
-     *\r
-     * @return The EventsFilterProvider\r
-     */\r
-    public ITmfEventsFilterProvider getEventsFilterProvider() {\r
-        return fEventsFilterProvider;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceOpenedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.signal;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;
+
+/**
+ * Signal indicating a trace has been opened.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceOpenedSignal extends TmfSignal {
+
+    private final ITmfTrace<?> fTrace;
+    private final IFile fBookmarksFile;
+    private final ITmfEventsFilterProvider fEventsFilterProvider;
+
+    /**
+     * Constructor for a new signal.
+     *
+     * @param source
+     *            The object sending this signal
+     * @param trace
+     *            The trace that has been opened
+     * @param bookmarksFile
+     *            Pointer to the bookmark file
+     * @param eventsFilterProvider
+     *            Provider for the event filter in use
+     */
+    public TmfTraceOpenedSignal(Object source, ITmfTrace<?> trace,
+            IFile bookmarksFile, ITmfEventsFilterProvider eventsFilterProvider) {
+        super(source);
+        fTrace = trace;
+        fBookmarksFile = bookmarksFile;
+        fEventsFilterProvider = eventsFilterProvider;
+    }
+
+    /**
+     * Get the trace object concerning this signal
+     *
+     * @return The trace
+     */
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    /**
+     * Get a pointer to the bookmark file of this trace
+     *
+     * @return The IFile object
+     */
+    public IFile getBookmarksFile() {
+        return fBookmarksFile;
+    }
+
+    /**
+     * Get the events filter provider of this trace
+     *
+     * @return The EventsFilterProvider
+     */
+    public ITmfEventsFilterProvider getEventsFilterProvider() {
+        return fEventsFilterProvider;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceOpenedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index f0bb232a97c9d1af6206b93f30ba9e9338a920ae..bec4fb76179143b8bce41203f20f93d5e49406a2 100644 (file)
@@ -1,53 +1,53 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.signal;\r
-\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;\r
-\r
-/**\r
- * Signal indicating the trace parser has finished reading a chunk, so the\r
- * parsing has been updated.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfTraceParserUpdatedSignal extends TmfSignal {\r
-\r
-    private final IResource fTraceResource;\r
-\r
-    /**\r
-     * Constructor for the signal.\r
-     *\r
-     * @param source The object sending this signal\r
-     * @param traceResource The trace resource concerning this signal\r
-     */\r
-    public TmfTraceParserUpdatedSignal(Object source, IResource traceResource) {\r
-        super(source);\r
-        fTraceResource = traceResource;\r
-    }\r
-\r
-    /**\r
-     * Get the trace resource object of this signal.\r
-     *\r
-     * @return The trace resource.\r
-     */\r
-    public IResource getTraceResource() {\r
-        return fTraceResource;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "[TmfTraceParserUpdatedSignal (" + fTraceResource.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.signal;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
+
+/**
+ * Signal indicating the trace parser has finished reading a chunk, so the
+ * parsing has been updated.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfTraceParserUpdatedSignal extends TmfSignal {
+
+    private final IResource fTraceResource;
+
+    /**
+     * Constructor for the signal.
+     *
+     * @param source The object sending this signal
+     * @param traceResource The trace resource concerning this signal
+     */
+    public TmfTraceParserUpdatedSignal(Object source, IResource traceResource) {
+        super(source);
+        fTraceResource = traceResource;
+    }
+
+    /**
+     * Get the trace resource object of this signal.
+     *
+     * @return The trace resource.
+     */
+    public IResource getTraceResource() {
+        return fTraceResource;
+    }
+
+    @Override
+    public String toString() {
+        return "[TmfTraceParserUpdatedSignal (" + fTraceResource.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
index 82046ce4e3150079a7b5e6c2d60db259aff66057..9b5322d8bcd786747bea8534a1962110442b4b8d 100644 (file)
@@ -1,46 +1,46 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.events;\r
-\r
-import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-/**\r
- * A filter/search event listener\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITmfEventsFilterListener {\r
-\r
-           /**\r
-     * Notify this listener that a filter has been applied.\r
-     *\r
-     * @param filter\r
-     *            The filter that was applied\r
-     * @param trace\r
-     *            The trace on which this filter is applied\r
-     */\r
-       public void filterApplied(ITmfFilter filter, ITmfTrace<?> trace);\r
-\r
-    /**\r
-     * Notify this listener that a new search has been run.\r
-     *\r
-     * @param filter\r
-     *            The filter that was applied\r
-     * @param trace\r
-     *            The trace on which this filter is applied\r
-     */\r
-       public void searchApplied(ITmfFilter filter, ITmfTrace<?> trace);\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.events;
+
+import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * A filter/search event listener
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITmfEventsFilterListener {
+
+           /**
+     * Notify this listener that a filter has been applied.
+     *
+     * @param filter
+     *            The filter that was applied
+     * @param trace
+     *            The trace on which this filter is applied
+     */
+       public void filterApplied(ITmfFilter filter, ITmfTrace<?> trace);
+
+    /**
+     * Notify this listener that a new search has been run.
+     *
+     * @param filter
+     *            The filter that was applied
+     * @param trace
+     *            The trace on which this filter is applied
+     */
+       public void searchApplied(ITmfFilter filter, ITmfTrace<?> trace);
+
+}
index 57914093856836ff1d0f3ef0e9a6f8df487d49fc..2aa788d374160641ba536ec5d0a1165d27d18a57 100644 (file)
@@ -1,39 +1,39 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.events;\r
-\r
-/**\r
- * A filter/search event provider\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITmfEventsFilterProvider {\r
-\r
-    /**\r
-     * Add a listener to this provider.\r
-     *\r
-     * @param listener\r
-     *            The listener to add\r
-     */\r
-    public void addEventsFilterListener(ITmfEventsFilterListener listener);\r
-\r
-    /**\r
-     * Remove a listener from this provider.\r
-     *\r
-     * @param listener\r
-     *            The listener to remove\r
-     */\r
-       public void removeEventsFilterListener (ITmfEventsFilterListener listener);\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.events;
+
+/**
+ * A filter/search event provider
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITmfEventsFilterProvider {
+
+    /**
+     * Add a listener to this provider.
+     *
+     * @param listener
+     *            The listener to add
+     */
+    public void addEventsFilterListener(ITmfEventsFilterListener listener);
+
+    /**
+     * Remove a listener from this provider.
+     *
+     * @param listener
+     *            The listener to remove
+     */
+       public void removeEventsFilterListener (ITmfEventsFilterListener listener);
+
+}
index 37c08cc0d2b422e3e65d57014247e169ed19e1c7..176d10779df3b3ad2240c91679df8540199d1d22 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *   Bernd Hufmann - Updated to use RGB for the tick color\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.colors;\r
-\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.themes.ColorUtil;\r
-\r
-/**\r
- * Class for storing color settings of a TMF filter.\r
- *\r
- * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system\r
- * resources managed by each instance when those instances are no longer required.\r
- *\r
- *  @version 1.0\r
- *  @author Patrick Tasse\r
- */\r
-public class ColorSetting {\r
-\r
-       private RGB fForegroundRGB;\r
-       private RGB fBackgroundRGB;\r
-       private RGB fTickColorRGB;\r
-       private Color fForegroundColor;\r
-       private Color fBackgroundColor;\r
-       private Color fDimmedForegroundColor;\r
-       private Color fDimmedBackgroundColor;\r
-       private Color fTickColor;\r
-       private ITmfFilterTreeNode fFilter;\r
-\r
-           /**\r
-     * Constructor\r
-     *\r
-     * You must dispose the color setting when it is no longer required.\r
-     *\r
-     * @param foreground\r
-     *            The foreground color\r
-     * @param background\r
-     *            The background color\r
-     * @param tickColorRGB\r
-     *            The color for the checkbox ticks\r
-     * @param filter\r
-     *            The filter tree node\r
-     */\r
-       public ColorSetting(RGB foreground, RGB background, RGB tickColorRGB, ITmfFilterTreeNode filter) {\r
-               fForegroundRGB = foreground;\r
-               fBackgroundRGB = background;\r
-               fTickColorRGB = tickColorRGB;\r
-               fFilter = filter;\r
-               Display display = Display.getDefault();\r
-               fForegroundColor = new Color(display, fForegroundRGB);\r
-               fBackgroundColor = new Color(display, fBackgroundRGB);\r
-               fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r
-                               fForegroundRGB, fBackgroundRGB));\r
-               fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r
-                               fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r
-               fTickColor = new Color(display, fTickColorRGB);\r
-       }\r
-\r
-       /**\r
-        * Dispose the color setting resources\r
-        */\r
-       public void dispose() {\r
-               fForegroundColor.dispose();\r
-               fBackgroundColor.dispose();\r
-               fDimmedForegroundColor.dispose();\r
-               fDimmedBackgroundColor.dispose();\r
-               fTickColor.dispose();\r
-       }\r
-\r
-       /**\r
-        * Returns foreground RGB value.\r
-        *\r
-        * @return the foreground RGB\r
-        */\r
-       public RGB getForegroundRGB() {\r
-               return fForegroundRGB;\r
-       }\r
-\r
-       /**\r
-        * Sets the foreground RGB value\r
-        *\r
-        * @param foreground the foreground to set\r
-        */\r
-       public void setForegroundRGB(RGB foreground) {\r
-               fForegroundRGB = foreground;\r
-               fForegroundColor.dispose();\r
-               fDimmedForegroundColor.dispose();\r
-               Display display = Display.getDefault();\r
-               fForegroundColor = new Color(display, fForegroundRGB);\r
-               fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r
-                               fForegroundRGB, fBackgroundRGB));\r
-       }\r
-\r
-       /**\r
-        * Returns the background RGB value.\r
-        *\r
-        * @return the background RGB\r
-        */\r
-       public RGB getBackgroundRGB() {\r
-               return fBackgroundRGB;\r
-       }\r
-\r
-       /**\r
-        * Sets the background RGB value.\r
-        *\r
-        * @param background the background to set\r
-        */\r
-       public void setBackgroundRGB(RGB background) {\r
-               fBackgroundRGB = background;\r
-               fBackgroundColor.dispose();\r
-               fDimmedBackgroundColor.dispose();\r
-               Display display = Display.getDefault();\r
-               fBackgroundColor = new Color(display, fBackgroundRGB);\r
-               fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r
-                               fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r
-       }\r
-\r
-       /**\r
-        * Returns the RGB of the tick color\r
-        *\r
-        * @return the RGB of the tick color\r
-        */\r
-       public RGB getTickColorRGB() {\r
-               return fTickColorRGB;\r
-       }\r
-\r
-       /**\r
-        * Sets the RGB of the tick color\r
-        *\r
-        * @param tickColorRGB the tick color TGB\r
-        */\r
-       public void setTickColorRGB(RGB tickColorRGB) {\r
-              fTickColorRGB = tickColorRGB;\r
-              fTickColor.dispose();\r
-           Display display = Display.getDefault();\r
-           fTickColor = new Color(display, fTickColorRGB);\r
-       }\r
-\r
-       /**\r
-        * Returns the filter implementation.\r
-        * @return the filter\r
-        */\r
-       public ITmfFilterTreeNode getFilter() {\r
-               return fFilter;\r
-       }\r
-\r
-       /**\r
-        * Sets the filter implementation.\r
-        *\r
-        * @param filter the filter to set\r
-        */\r
-       public void setFilter(ITmfFilterTreeNode filter) {\r
-               fFilter = filter;\r
-       }\r
-\r
-       /**\r
-        * Returns the foreground color.\r
-        *\r
-        * @return the foreground color\r
-        */\r
-       public Color getForegroundColor() {\r
-               return fForegroundColor;\r
-       }\r
-\r
-       /**\r
-        * Returns the background color.\r
-        *\r
-        * @return the background color\r
-        */\r
-       public Color getBackgroundColor() {\r
-               return fBackgroundColor;\r
-       }\r
-\r
-       /**\r
-        * Returns the dimmed foreground color.\r
-        *\r
-        * @return the dimmed foreground color\r
-        */\r
-       public Color getDimmedForegroundColor() {\r
-               return fDimmedForegroundColor;\r
-       }\r
-\r
-       /**\r
-        * Returns the dimmed background color.\r
-        *\r
-        * @return the dimmed background color\r
-        */\r
-       public Color getDimmedBackgroundColor() {\r
-               return fDimmedBackgroundColor;\r
-       }\r
-\r
-       /**\r
-        * Returns the tick color.\r
-        *\r
-        * @return the tick color\r
-        */\r
-       public Color getTickColor() {\r
-        return fTickColor;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *   Bernd Hufmann - Updated to use RGB for the tick color
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.colors;
+
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.themes.ColorUtil;
+
+/**
+ * Class for storing color settings of a TMF filter.
+ *
+ * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system
+ * resources managed by each instance when those instances are no longer required.
+ *
+ *  @version 1.0
+ *  @author Patrick Tasse
+ */
+public class ColorSetting {
+
+       private RGB fForegroundRGB;
+       private RGB fBackgroundRGB;
+       private RGB fTickColorRGB;
+       private Color fForegroundColor;
+       private Color fBackgroundColor;
+       private Color fDimmedForegroundColor;
+       private Color fDimmedBackgroundColor;
+       private Color fTickColor;
+       private ITmfFilterTreeNode fFilter;
+
+           /**
+     * Constructor
+     *
+     * You must dispose the color setting when it is no longer required.
+     *
+     * @param foreground
+     *            The foreground color
+     * @param background
+     *            The background color
+     * @param tickColorRGB
+     *            The color for the checkbox ticks
+     * @param filter
+     *            The filter tree node
+     */
+       public ColorSetting(RGB foreground, RGB background, RGB tickColorRGB, ITmfFilterTreeNode filter) {
+               fForegroundRGB = foreground;
+               fBackgroundRGB = background;
+               fTickColorRGB = tickColorRGB;
+               fFilter = filter;
+               Display display = Display.getDefault();
+               fForegroundColor = new Color(display, fForegroundRGB);
+               fBackgroundColor = new Color(display, fBackgroundRGB);
+               fDimmedForegroundColor = new Color(display, ColorUtil.blend(
+                               fForegroundRGB, fBackgroundRGB));
+               fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
+                               fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
+               fTickColor = new Color(display, fTickColorRGB);
+       }
+
+       /**
+        * Dispose the color setting resources
+        */
+       public void dispose() {
+               fForegroundColor.dispose();
+               fBackgroundColor.dispose();
+               fDimmedForegroundColor.dispose();
+               fDimmedBackgroundColor.dispose();
+               fTickColor.dispose();
+       }
+
+       /**
+        * Returns foreground RGB value.
+        *
+        * @return the foreground RGB
+        */
+       public RGB getForegroundRGB() {
+               return fForegroundRGB;
+       }
+
+       /**
+        * Sets the foreground RGB value
+        *
+        * @param foreground the foreground to set
+        */
+       public void setForegroundRGB(RGB foreground) {
+               fForegroundRGB = foreground;
+               fForegroundColor.dispose();
+               fDimmedForegroundColor.dispose();
+               Display display = Display.getDefault();
+               fForegroundColor = new Color(display, fForegroundRGB);
+               fDimmedForegroundColor = new Color(display, ColorUtil.blend(
+                               fForegroundRGB, fBackgroundRGB));
+       }
+
+       /**
+        * Returns the background RGB value.
+        *
+        * @return the background RGB
+        */
+       public RGB getBackgroundRGB() {
+               return fBackgroundRGB;
+       }
+
+       /**
+        * Sets the background RGB value.
+        *
+        * @param background the background to set
+        */
+       public void setBackgroundRGB(RGB background) {
+               fBackgroundRGB = background;
+               fBackgroundColor.dispose();
+               fDimmedBackgroundColor.dispose();
+               Display display = Display.getDefault();
+               fBackgroundColor = new Color(display, fBackgroundRGB);
+               fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
+                               fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
+       }
+
+       /**
+        * Returns the RGB of the tick color
+        *
+        * @return the RGB of the tick color
+        */
+       public RGB getTickColorRGB() {
+               return fTickColorRGB;
+       }
+
+       /**
+        * Sets the RGB of the tick color
+        *
+        * @param tickColorRGB the tick color TGB
+        */
+       public void setTickColorRGB(RGB tickColorRGB) {
+              fTickColorRGB = tickColorRGB;
+              fTickColor.dispose();
+           Display display = Display.getDefault();
+           fTickColor = new Color(display, fTickColorRGB);
+       }
+
+       /**
+        * Returns the filter implementation.
+        * @return the filter
+        */
+       public ITmfFilterTreeNode getFilter() {
+               return fFilter;
+       }
+
+       /**
+        * Sets the filter implementation.
+        *
+        * @param filter the filter to set
+        */
+       public void setFilter(ITmfFilterTreeNode filter) {
+               fFilter = filter;
+       }
+
+       /**
+        * Returns the foreground color.
+        *
+        * @return the foreground color
+        */
+       public Color getForegroundColor() {
+               return fForegroundColor;
+       }
+
+       /**
+        * Returns the background color.
+        *
+        * @return the background color
+        */
+       public Color getBackgroundColor() {
+               return fBackgroundColor;
+       }
+
+       /**
+        * Returns the dimmed foreground color.
+        *
+        * @return the dimmed foreground color
+        */
+       public Color getDimmedForegroundColor() {
+               return fDimmedForegroundColor;
+       }
+
+       /**
+        * Returns the dimmed background color.
+        *
+        * @return the dimmed background color
+        */
+       public Color getDimmedBackgroundColor() {
+               return fDimmedBackgroundColor;
+       }
+
+       /**
+        * Returns the tick color.
+        *
+        * @return the tick color
+        */
+       public Color getTickColor() {
+        return fTickColor;
+    }
+}
index b1de6acaebff60334428cab7c7eae932d1d80130..c654ee17f4a14746b0d10b4e5b30dd67ad66418b 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *   Bernd Hufmann - Updated to use RGB for the tick color\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.colors;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-/**\r
- * Static class for managing color settings.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- *\r
- */\r
-public class ColorSettingsManager {\r
-\r
-    // The color settings file name\r
-       private static final String COLOR_SETTINGS_FILE_NAME = "color_settings.xml"; //$NON-NLS-1$\r
-\r
-       // The path for the color settings file\r
-       private static final String COLOR_SETTINGS_PATH_NAME =\r
-        Activator.getDefault().getStateLocation().addTrailingSeparator().append(COLOR_SETTINGS_FILE_NAME).toString();\r
-\r
-       // The default color setting\r
-       private static final ColorSetting DEFAULT_COLOR_SETTING = new ColorSetting(\r
-                       Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),\r
-                       Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(),\r
-                       Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),\r
-                       null);\r
-\r
-       /**\r
-        * Special value for priority if unknown.\r
-        */\r
-       public static final int PRIORITY_NONE = Integer.MAX_VALUE;\r
-\r
-       // The stored color settings\r
-       private static ColorSetting[] fColorSettings = ColorSettingsXML.load(COLOR_SETTINGS_PATH_NAME);\r
-\r
-       // The listener list\r
-       private static List<IColorSettingsListener> fListeners = new ArrayList<IColorSettingsListener>();\r
-\r
-       /**\r
-        * Returns an array of color settings.\r
-        *\r
-        * @return an array of color settings.\r
-        */\r
-       public static ColorSetting[] getColorSettings() {\r
-               return (fColorSettings != null) ? Arrays.copyOf(fColorSettings, fColorSettings.length) : null;\r
-       }\r
-\r
-       /**\r
-        * Sets the array of color settings.\r
-        *\r
-        * @param colorSettings A array of color settings to set\r
-        */\r
-       public static void setColorSettings(ColorSetting[] colorSettings) {\r
-               fColorSettings = (colorSettings != null) ? Arrays.copyOf(colorSettings, colorSettings.length) : null;\r
-               ColorSettingsXML.save(COLOR_SETTINGS_PATH_NAME, fColorSettings);\r
-               fireColorSettingsChanged();\r
-       }\r
-\r
-           /**\r
-     * Gets the color settings that matches the filter for given event.\r
-     *\r
-     * @param event\r
-     *            The event to check\r
-     *\r
-     * @return color settings defined for filter if found else default color\r
-     *         settings\r
-     */\r
-       public static ColorSetting getColorSetting(ITmfEvent event) {\r
-        for (int i = 0; i < fColorSettings.length; i++) {\r
-               ColorSetting colorSetting = fColorSettings[i];\r
-               if (colorSetting.getFilter() != null && colorSetting.getFilter().matches(event)) {\r
-                       return colorSetting;\r
-               }\r
-        }\r
-        return DEFAULT_COLOR_SETTING;\r
-       }\r
-\r
-       /**\r
-        * Gets the color settings priority for the given event.\r
-        *\r
-        * @param event A event the event to check\r
-        * @return the priority defined for the filter else PRIORITY_NONE\r
-        */\r
-       public static int getColorSettingPriority(ITmfEvent event) {\r
-        for (int i = 0; i < fColorSettings.length; i++) {\r
-               ColorSetting colorSetting = fColorSettings[i];\r
-               if (colorSetting.getFilter() != null && colorSetting.getFilter().matches(event)) {\r
-                       return i;\r
-               }\r
-        }\r
-        return PRIORITY_NONE;\r
-       }\r
-\r
-       /**\r
-        * Returns the color settings based the priority.\r
-        *\r
-        * @param priority A priority (index) of color settings\r
-        * @return the color settings defined for the priority else default color settings\r
-        */\r
-       public static ColorSetting getColorSetting(int priority) {\r
-               if (priority < fColorSettings.length) {\r
-                       return fColorSettings[priority];\r
-               }\r
-               return DEFAULT_COLOR_SETTING;\r
-       }\r
-\r
-       /**\r
-        * Adds a color settings listener.\r
-        *\r
-        * @param listener A listener to add.\r
-        */\r
-       public static void addColorSettingsListener(IColorSettingsListener listener) {\r
-               if (! fListeners.contains(listener)) {\r
-                       fListeners.add(listener);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Removes a color settings listener.\r
-        *\r
-        * @param listener A listener to remove.\r
-        */\r
-       public static void removeColorSettingsListener(IColorSettingsListener listener) {\r
-               fListeners.remove(listener);\r
-       }\r
-\r
-       // Notify listeners\r
-       private static void fireColorSettingsChanged() {\r
-               for (IColorSettingsListener listener : fListeners) {\r
-                       listener.colorSettingsChanged(fColorSettings);\r
-               }\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *   Bernd Hufmann - Updated to use RGB for the tick color
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.colors;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Static class for managing color settings.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ *
+ */
+public class ColorSettingsManager {
+
+    // The color settings file name
+       private static final String COLOR_SETTINGS_FILE_NAME = "color_settings.xml"; //$NON-NLS-1$
+
+       // The path for the color settings file
+       private static final String COLOR_SETTINGS_PATH_NAME =
+        Activator.getDefault().getStateLocation().addTrailingSeparator().append(COLOR_SETTINGS_FILE_NAME).toString();
+
+       // The default color setting
+       private static final ColorSetting DEFAULT_COLOR_SETTING = new ColorSetting(
+                       Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),
+                       Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(),
+                       Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),
+                       null);
+
+       /**
+        * Special value for priority if unknown.
+        */
+       public static final int PRIORITY_NONE = Integer.MAX_VALUE;
+
+       // The stored color settings
+       private static ColorSetting[] fColorSettings = ColorSettingsXML.load(COLOR_SETTINGS_PATH_NAME);
+
+       // The listener list
+       private static List<IColorSettingsListener> fListeners = new ArrayList<IColorSettingsListener>();
+
+       /**
+        * Returns an array of color settings.
+        *
+        * @return an array of color settings.
+        */
+       public static ColorSetting[] getColorSettings() {
+               return (fColorSettings != null) ? Arrays.copyOf(fColorSettings, fColorSettings.length) : null;
+       }
+
+       /**
+        * Sets the array of color settings.
+        *
+        * @param colorSettings A array of color settings to set
+        */
+       public static void setColorSettings(ColorSetting[] colorSettings) {
+               fColorSettings = (colorSettings != null) ? Arrays.copyOf(colorSettings, colorSettings.length) : null;
+               ColorSettingsXML.save(COLOR_SETTINGS_PATH_NAME, fColorSettings);
+               fireColorSettingsChanged();
+       }
+
+           /**
+     * Gets the color settings that matches the filter for given event.
+     *
+     * @param event
+     *            The event to check
+     *
+     * @return color settings defined for filter if found else default color
+     *         settings
+     */
+       public static ColorSetting getColorSetting(ITmfEvent event) {
+        for (int i = 0; i < fColorSettings.length; i++) {
+               ColorSetting colorSetting = fColorSettings[i];
+               if (colorSetting.getFilter() != null && colorSetting.getFilter().matches(event)) {
+                       return colorSetting;
+               }
+        }
+        return DEFAULT_COLOR_SETTING;
+       }
+
+       /**
+        * Gets the color settings priority for the given event.
+        *
+        * @param event A event the event to check
+        * @return the priority defined for the filter else PRIORITY_NONE
+        */
+       public static int getColorSettingPriority(ITmfEvent event) {
+        for (int i = 0; i < fColorSettings.length; i++) {
+               ColorSetting colorSetting = fColorSettings[i];
+               if (colorSetting.getFilter() != null && colorSetting.getFilter().matches(event)) {
+                       return i;
+               }
+        }
+        return PRIORITY_NONE;
+       }
+
+       /**
+        * Returns the color settings based the priority.
+        *
+        * @param priority A priority (index) of color settings
+        * @return the color settings defined for the priority else default color settings
+        */
+       public static ColorSetting getColorSetting(int priority) {
+               if (priority < fColorSettings.length) {
+                       return fColorSettings[priority];
+               }
+               return DEFAULT_COLOR_SETTING;
+       }
+
+       /**
+        * Adds a color settings listener.
+        *
+        * @param listener A listener to add.
+        */
+       public static void addColorSettingsListener(IColorSettingsListener listener) {
+               if (! fListeners.contains(listener)) {
+                       fListeners.add(listener);
+               }
+       }
+
+       /**
+        * Removes a color settings listener.
+        *
+        * @param listener A listener to remove.
+        */
+       public static void removeColorSettingsListener(IColorSettingsListener listener) {
+               fListeners.remove(listener);
+       }
+
+       // Notify listeners
+       private static void fireColorSettingsChanged() {
+               for (IColorSettingsListener listener : fListeners) {
+                       listener.colorSettingsChanged(fColorSettings);
+               }
+       }
+}
index c7b017ebe2cfed3247b0e2e59f716d168672d84c..44d0d04a5b445221999e999752a6bb8176738fd3 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *   Bernd Hufmann - Updated to use RGB for the tick color\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.colors;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-import javax.xml.parsers.SAXParserFactory;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerConfigurationException;\r
-import javax.xml.transform.TransformerException;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterContentHandler;\r
-import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLWriter;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.XMLReader;\r
-import org.xml.sax.helpers.DefaultHandler;\r
-\r
-/**\r
- * Class for saving and loading of color settings to/from file.\r
- * \r
- * @version 1.0\r
- * @author Patrick Tasse\r
- *\r
- */\r
-public class ColorSettingsXML {\r
-\r
-    // XML Tags and attributes\r
-       private static final String COLOR_SETTINGS_TAG = "COLOR_SETTINGS"; //$NON-NLS-1$\r
-       private static final String COLOR_SETTING_TAG = "COLOR_SETTING"; //$NON-NLS-1$\r
-       private static final String FG_TAG = "FG"; //$NON-NLS-1$\r
-       private static final String BG_TAG = "BG"; //$NON-NLS-1$\r
-       private static final String R_ATTR = "R"; //$NON-NLS-1$\r
-       private static final String G_ATTR = "G"; //$NON-NLS-1$\r
-       private static final String B_ATTR = "B"; //$NON-NLS-1$\r
-       private static final String TICK_TAG = "TICK"; //$NON-NLS-1$\r
-       private static final String FILTER_TAG = "FILTER"; //$NON-NLS-1$\r
-\r
-       /**\r
-        * Saves the given color settings to file.\r
-        * \r
-        * @param pathName A file name with path \r
-        * @param colorSettings -An array of color settings to save.\r
-        */\r
-       public static void save(String pathName, ColorSetting[] colorSettings) {\r
-               try {\r
-                       DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();\r
-                       DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();\r
-                       Document document = documentBuilder.newDocument();\r
-                       \r
-                       Element rootElement = document.createElement(COLOR_SETTINGS_TAG);\r
-                       document.appendChild(rootElement);\r
-       \r
-                       for (ColorSetting colorSetting : colorSettings) {\r
-                               Element colorSettingElement = document.createElement(COLOR_SETTING_TAG);\r
-                               rootElement.appendChild(colorSettingElement);\r
-                               \r
-                               Element fgElement = document.createElement(FG_TAG);\r
-                               colorSettingElement.appendChild(fgElement);\r
-                               RGB foreground = colorSetting.getForegroundRGB();\r
-                               fgElement.setAttribute(R_ATTR, Integer.toString(foreground.red));\r
-                               fgElement.setAttribute(G_ATTR, Integer.toString(foreground.green));\r
-                               fgElement.setAttribute(B_ATTR, Integer.toString(foreground.blue));\r
-                               \r
-                               Element bgElement = document.createElement(BG_TAG);\r
-                               colorSettingElement.appendChild(bgElement);\r
-                               RGB background = colorSetting.getBackgroundRGB();\r
-                               bgElement.setAttribute(R_ATTR, Integer.toString(background.red));\r
-                               bgElement.setAttribute(G_ATTR, Integer.toString(background.green));\r
-                               bgElement.setAttribute(B_ATTR, Integer.toString(background.blue));\r
-                               \r
-                               Element tickColorElement = document.createElement(TICK_TAG);\r
-                               colorSettingElement.appendChild(tickColorElement);\r
-                RGB tickColor = colorSetting.getTickColorRGB();\r
-                tickColorElement.setAttribute(R_ATTR, Integer.toString(tickColor.red));\r
-                tickColorElement.setAttribute(G_ATTR, Integer.toString(tickColor.green));\r
-                tickColorElement.setAttribute(B_ATTR, Integer.toString(tickColor.blue));\r
-\r
-                               if (colorSetting.getFilter() != null) {\r
-                                       Element filterElement = document.createElement(FILTER_TAG);\r
-                                       colorSettingElement.appendChild(filterElement);\r
-                                       TmfFilterXMLWriter.buildXMLTree(document, colorSetting.getFilter(), filterElement);\r
-                               }\r
-                       }\r
-       \r
-                       TransformerFactory transformerFactory = TransformerFactory.newInstance();\r
-               \r
-                       Transformer transformer = transformerFactory.newTransformer();\r
-               DOMSource source = new DOMSource(document);\r
-               StreamResult result =  new StreamResult(new File(pathName));\r
-                       transformer.transform(source, result);\r
-               } catch (ParserConfigurationException e) {\r
-                   Activator.getDefault().logError("Error saving color xml file: " + pathName, e); //$NON-NLS-1$\r
-               } catch (TransformerConfigurationException e) {\r
-                   Activator.getDefault().logError("Error saving color xml file: " + pathName, e); //$NON-NLS-1$\r
-               } catch (TransformerException e) {\r
-                   Activator.getDefault().logError("Error saving color xml file: " + pathName, e); //$NON-NLS-1$\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Loads color settings from file and returns it in an array.\r
-        * \r
-        * @param pathName A file name with path\r
-        * \r
-        * @return the color settings array loaded from file\r
-        */\r
-       public static ColorSetting[] load(String pathName) {\r
-               if (! new File(pathName).canRead()) {\r
-                       return new ColorSetting[0];\r
-               }\r
-               SAXParserFactory parserFactory = SAXParserFactory.newInstance(); \r
-        parserFactory.setNamespaceAware(true); \r
-\r
-        ColorSettingsContentHandler handler = new ColorSettingsContentHandler();\r
-               try {\r
-                       XMLReader saxReader = parserFactory.newSAXParser().getXMLReader();\r
-               saxReader.setContentHandler(handler);\r
-               saxReader.parse(pathName);\r
-               return handler.colorSettings.toArray(new ColorSetting[0]);\r
-               } catch (ParserConfigurationException e) {\r
-                   Activator.getDefault().logError("Error loading color xml file: " + pathName, e); //$NON-NLS-1$\r
-               } catch (SAXException e) {\r
-                   Activator.getDefault().logError("Error loading color xml file: " + pathName, e); //$NON-NLS-1$\r
-               } catch (IOException e) {\r
-                   Activator.getDefault().logError("Error loading color xml file: " + pathName, e); //$NON-NLS-1$\r
-               }\r
-               // In case of error, dispose the partial list of color settings\r
-               for (ColorSetting colorSetting : handler.colorSettings) {\r
-                       colorSetting.dispose();\r
-               }\r
-               return new ColorSetting[0];\r
-       }\r
-       \r
-       // Helper class\r
-       private static class ColorSettingsContentHandler extends DefaultHandler {\r
-\r
-               private List<ColorSetting> colorSettings = new ArrayList<ColorSetting>(0);\r
-               private RGB fg = new RGB(0, 0, 0);\r
-               private RGB bg = new RGB(255, 255, 255);\r
-               private RGB tickColor = new RGB(0, 0, 0);\r
-               private ITmfFilterTreeNode filter;\r
-               private TmfFilterContentHandler filterContentHandler;\r
-               \r
-               /* (non-Javadoc)\r
-                * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)\r
-                */\r
-               @Override\r
-               public void startElement(String uri, String localName, String qName, Attributes attributes)\r
-                               throws SAXException {\r
-                       if (localName.equals(COLOR_SETTINGS_TAG)) {\r
-                               colorSettings = new ArrayList<ColorSetting>();\r
-                       } else if (localName.equals(COLOR_SETTING_TAG)) {\r
-                               fg = null;\r
-                               bg = null;\r
-                               filter = null;\r
-                       } else if (localName.equals(FG_TAG)) {\r
-                               int r = Integer.valueOf(attributes.getValue(R_ATTR));\r
-                               int g = Integer.valueOf(attributes.getValue(G_ATTR));\r
-                               int b = Integer.valueOf(attributes.getValue(B_ATTR));\r
-                               fg = new RGB(r, g, b);\r
-                       } else if (localName.equals(BG_TAG)) {\r
-                               int r = Integer.valueOf(attributes.getValue(R_ATTR));\r
-                               int g = Integer.valueOf(attributes.getValue(G_ATTR));\r
-                               int b = Integer.valueOf(attributes.getValue(B_ATTR));\r
-                               bg = new RGB(r, g, b);\r
-            } else if (localName.equals(TICK_TAG)) {\r
-                int r = Integer.valueOf(attributes.getValue(R_ATTR));\r
-                int g = Integer.valueOf(attributes.getValue(G_ATTR));\r
-                int b = Integer.valueOf(attributes.getValue(B_ATTR));\r
-                tickColor = new RGB(r, g, b);\r
-                       } else if (localName.equals(FILTER_TAG)) {\r
-                               filterContentHandler = new TmfFilterContentHandler();\r
-                       } else if (filterContentHandler != null) {\r
-                               filterContentHandler.startElement(uri, localName, qName, attributes);\r
-                       }\r
-               }\r
-\r
-               /* (non-Javadoc)\r
-                * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)\r
-                */\r
-               @Override\r
-               public void endElement(String uri, String localName, String qName)\r
-                               throws SAXException {\r
-                       if (localName.equals(COLOR_SETTINGS_TAG)) {\r
-                           // Nothing to do\r
-                       } else if (localName.equals(COLOR_SETTING_TAG)) {\r
-                               ColorSetting colorSetting = new ColorSetting(fg, bg, tickColor, filter);\r
-                               colorSettings.add(colorSetting);\r
-                       } else if (localName.equals(FILTER_TAG)) {\r
-                               filter = filterContentHandler.getTree();\r
-                               filterContentHandler = null;\r
-                       } else if (filterContentHandler != null) {\r
-                               filterContentHandler.endElement(uri, localName, qName);\r
-                       }\r
-               }\r
-\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *   Bernd Hufmann - Updated to use RGB for the tick color
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.colors;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterContentHandler;
+import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLWriter;
+import org.eclipse.swt.graphics.RGB;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Class for saving and loading of color settings to/from file.
+ * 
+ * @version 1.0
+ * @author Patrick Tasse
+ *
+ */
+public class ColorSettingsXML {
+
+    // XML Tags and attributes
+       private static final String COLOR_SETTINGS_TAG = "COLOR_SETTINGS"; //$NON-NLS-1$
+       private static final String COLOR_SETTING_TAG = "COLOR_SETTING"; //$NON-NLS-1$
+       private static final String FG_TAG = "FG"; //$NON-NLS-1$
+       private static final String BG_TAG = "BG"; //$NON-NLS-1$
+       private static final String R_ATTR = "R"; //$NON-NLS-1$
+       private static final String G_ATTR = "G"; //$NON-NLS-1$
+       private static final String B_ATTR = "B"; //$NON-NLS-1$
+       private static final String TICK_TAG = "TICK"; //$NON-NLS-1$
+       private static final String FILTER_TAG = "FILTER"; //$NON-NLS-1$
+
+       /**
+        * Saves the given color settings to file.
+        * 
+        * @param pathName A file name with path 
+        * @param colorSettings -An array of color settings to save.
+        */
+       public static void save(String pathName, ColorSetting[] colorSettings) {
+               try {
+                       DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+                       DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+                       Document document = documentBuilder.newDocument();
+                       
+                       Element rootElement = document.createElement(COLOR_SETTINGS_TAG);
+                       document.appendChild(rootElement);
+       
+                       for (ColorSetting colorSetting : colorSettings) {
+                               Element colorSettingElement = document.createElement(COLOR_SETTING_TAG);
+                               rootElement.appendChild(colorSettingElement);
+                               
+                               Element fgElement = document.createElement(FG_TAG);
+                               colorSettingElement.appendChild(fgElement);
+                               RGB foreground = colorSetting.getForegroundRGB();
+                               fgElement.setAttribute(R_ATTR, Integer.toString(foreground.red));
+                               fgElement.setAttribute(G_ATTR, Integer.toString(foreground.green));
+                               fgElement.setAttribute(B_ATTR, Integer.toString(foreground.blue));
+                               
+                               Element bgElement = document.createElement(BG_TAG);
+                               colorSettingElement.appendChild(bgElement);
+                               RGB background = colorSetting.getBackgroundRGB();
+                               bgElement.setAttribute(R_ATTR, Integer.toString(background.red));
+                               bgElement.setAttribute(G_ATTR, Integer.toString(background.green));
+                               bgElement.setAttribute(B_ATTR, Integer.toString(background.blue));
+                               
+                               Element tickColorElement = document.createElement(TICK_TAG);
+                               colorSettingElement.appendChild(tickColorElement);
+                RGB tickColor = colorSetting.getTickColorRGB();
+                tickColorElement.setAttribute(R_ATTR, Integer.toString(tickColor.red));
+                tickColorElement.setAttribute(G_ATTR, Integer.toString(tickColor.green));
+                tickColorElement.setAttribute(B_ATTR, Integer.toString(tickColor.blue));
+
+                               if (colorSetting.getFilter() != null) {
+                                       Element filterElement = document.createElement(FILTER_TAG);
+                                       colorSettingElement.appendChild(filterElement);
+                                       TmfFilterXMLWriter.buildXMLTree(document, colorSetting.getFilter(), filterElement);
+                               }
+                       }
+       
+                       TransformerFactory transformerFactory = TransformerFactory.newInstance();
+               
+                       Transformer transformer = transformerFactory.newTransformer();
+               DOMSource source = new DOMSource(document);
+               StreamResult result =  new StreamResult(new File(pathName));
+                       transformer.transform(source, result);
+               } catch (ParserConfigurationException e) {
+                   Activator.getDefault().logError("Error saving color xml file: " + pathName, e); //$NON-NLS-1$
+               } catch (TransformerConfigurationException e) {
+                   Activator.getDefault().logError("Error saving color xml file: " + pathName, e); //$NON-NLS-1$
+               } catch (TransformerException e) {
+                   Activator.getDefault().logError("Error saving color xml file: " + pathName, e); //$NON-NLS-1$
+               }
+       }
+       
+       /**
+        * Loads color settings from file and returns it in an array.
+        * 
+        * @param pathName A file name with path
+        * 
+        * @return the color settings array loaded from file
+        */
+       public static ColorSetting[] load(String pathName) {
+               if (! new File(pathName).canRead()) {
+                       return new ColorSetting[0];
+               }
+               SAXParserFactory parserFactory = SAXParserFactory.newInstance(); 
+        parserFactory.setNamespaceAware(true); 
+
+        ColorSettingsContentHandler handler = new ColorSettingsContentHandler();
+               try {
+                       XMLReader saxReader = parserFactory.newSAXParser().getXMLReader();
+               saxReader.setContentHandler(handler);
+               saxReader.parse(pathName);
+               return handler.colorSettings.toArray(new ColorSetting[0]);
+               } catch (ParserConfigurationException e) {
+                   Activator.getDefault().logError("Error loading color xml file: " + pathName, e); //$NON-NLS-1$
+               } catch (SAXException e) {
+                   Activator.getDefault().logError("Error loading color xml file: " + pathName, e); //$NON-NLS-1$
+               } catch (IOException e) {
+                   Activator.getDefault().logError("Error loading color xml file: " + pathName, e); //$NON-NLS-1$
+               }
+               // In case of error, dispose the partial list of color settings
+               for (ColorSetting colorSetting : handler.colorSettings) {
+                       colorSetting.dispose();
+               }
+               return new ColorSetting[0];
+       }
+       
+       // Helper class
+       private static class ColorSettingsContentHandler extends DefaultHandler {
+
+               private List<ColorSetting> colorSettings = new ArrayList<ColorSetting>(0);
+               private RGB fg = new RGB(0, 0, 0);
+               private RGB bg = new RGB(255, 255, 255);
+               private RGB tickColor = new RGB(0, 0, 0);
+               private ITmfFilterTreeNode filter;
+               private TmfFilterContentHandler filterContentHandler;
+               
+               /* (non-Javadoc)
+                * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+                */
+               @Override
+               public void startElement(String uri, String localName, String qName, Attributes attributes)
+                               throws SAXException {
+                       if (localName.equals(COLOR_SETTINGS_TAG)) {
+                               colorSettings = new ArrayList<ColorSetting>();
+                       } else if (localName.equals(COLOR_SETTING_TAG)) {
+                               fg = null;
+                               bg = null;
+                               filter = null;
+                       } else if (localName.equals(FG_TAG)) {
+                               int r = Integer.valueOf(attributes.getValue(R_ATTR));
+                               int g = Integer.valueOf(attributes.getValue(G_ATTR));
+                               int b = Integer.valueOf(attributes.getValue(B_ATTR));
+                               fg = new RGB(r, g, b);
+                       } else if (localName.equals(BG_TAG)) {
+                               int r = Integer.valueOf(attributes.getValue(R_ATTR));
+                               int g = Integer.valueOf(attributes.getValue(G_ATTR));
+                               int b = Integer.valueOf(attributes.getValue(B_ATTR));
+                               bg = new RGB(r, g, b);
+            } else if (localName.equals(TICK_TAG)) {
+                int r = Integer.valueOf(attributes.getValue(R_ATTR));
+                int g = Integer.valueOf(attributes.getValue(G_ATTR));
+                int b = Integer.valueOf(attributes.getValue(B_ATTR));
+                tickColor = new RGB(r, g, b);
+                       } else if (localName.equals(FILTER_TAG)) {
+                               filterContentHandler = new TmfFilterContentHandler();
+                       } else if (filterContentHandler != null) {
+                               filterContentHandler.startElement(uri, localName, qName, attributes);
+                       }
+               }
+
+               /* (non-Javadoc)
+                * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+                */
+               @Override
+               public void endElement(String uri, String localName, String qName)
+                               throws SAXException {
+                       if (localName.equals(COLOR_SETTINGS_TAG)) {
+                           // Nothing to do
+                       } else if (localName.equals(COLOR_SETTING_TAG)) {
+                               ColorSetting colorSetting = new ColorSetting(fg, bg, tickColor, filter);
+                               colorSettings.add(colorSetting);
+                       } else if (localName.equals(FILTER_TAG)) {
+                               filter = filterContentHandler.getTree();
+                               filterContentHandler = null;
+                       } else if (filterContentHandler != null) {
+                               filterContentHandler.endElement(uri, localName, qName);
+                       }
+               }
+
+       }
+}
index 59d936f4483f190254eb66e006ce30de7270a282..6f52b3a00b0136a9dd5a5016c1c5ff45f104a79a 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *   Bernd Hufmann - Updated to use RGB for the tick color\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.colors;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.IToolBarManager;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
-import org.eclipse.linuxtools.tmf.ui.views.filter.FilterDialog;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.events.MouseAdapter;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseListener;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.ColorDialog;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IActionBars;\r
-\r
-/**\r
- * Color view implementation. This view provides support for managing color settings for filters.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- *\r
- */\r
-public class ColorsView extends TmfView {\r
-\r
-    /** ID for the color view */\r
-    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.colors"; //$NON-NLS-1$\r
-\r
-    private static final Image ADD_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$\r
-    private static final Image DELETE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$\r
-    private static final Image MOVE_UP_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$\r
-    private static final Image MOVE_DOWN_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$\r
-    private static final Image IMPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/import_button.gif"); //$NON-NLS-1$\r
-    private static final Image EXPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/export_button.gif"); //$NON-NLS-1$\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Main data structures\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * The composite shell.\r
-     */\r
-    protected Shell fShell;\r
-    /**\r
-     * The main composite (scrolled composite)\r
-     */\r
-    protected ScrolledComposite fScrolledComposite;\r
-    /**\r
-     * The list composite.\r
-     */\r
-    protected Composite fListComposite;\r
-    /**\r
-     * The filler composite.\r
-     */\r
-    protected Composite fFillerComposite;\r
-    /**\r
-     *  The selected color settings row\r
-     */\r
-    protected ColorSettingRow fSelectedRow = null;\r
-    /**\r
-     *  The color scheme instance for managing colors\r
-     */\r
-    protected TimeGraphColorScheme traceColorScheme = new TimeGraphColorScheme();\r
-    /**\r
-     * An action to add a color settings row\r
-     */\r
-    protected Action fAddAction;\r
-    /**\r
-     * An action to delete a color settings row\r
-     */\r
-    protected Action fDeleteAction;\r
-    /**\r
-     * An action to move up a color settings row in the list.\r
-     */\r
-    protected Action fMoveUpAction;\r
-    /**\r
-     * An action to move down a color settings row in the list.\r
-     */\r
-    protected Action fMoveDownAction;\r
-    /**\r
-     * An action to import color settings from file.\r
-     */\r
-    protected Action fImportAction;\r
-    /**\r
-     * An action to export color settings from file.\r
-     */\r
-    protected Action fExportAction;\r
-    /**\r
-     * The list of existing color settings\r
-     */\r
-    protected List<ColorSetting> fColorSettings;\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructor\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     *  Default Constructor\r
-     */\r
-    public ColorsView() {\r
-        super("Colors"); //$NON-NLS-1$\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(Composite)\r
-     */\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        fShell = parent.getShell();\r
-\r
-        fScrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);\r
-        fScrolledComposite.setExpandHorizontal(true);\r
-        fScrolledComposite.setExpandVertical(true);\r
-        fListComposite = new Composite(fScrolledComposite, SWT.NONE);\r
-        fScrolledComposite.setContent(fListComposite);\r
-\r
-        GridLayout gl = new GridLayout();\r
-        gl.marginHeight = 0;\r
-        gl.marginWidth = 0;\r
-        gl.verticalSpacing = 1;\r
-        fListComposite.setLayout(gl);\r
-\r
-        fColorSettings = new ArrayList<ColorSetting>(Arrays.asList(ColorSettingsManager.getColorSettings()));\r
-        for (ColorSetting colorSetting : fColorSettings) {\r
-            new ColorSettingRow(fListComposite, colorSetting);\r
-        }\r
-\r
-        fFillerComposite = new Composite(fListComposite, SWT.NONE);\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-        gd.heightHint = 0;\r
-        fFillerComposite.setLayoutData(gd);\r
-        gl = new GridLayout();\r
-        gl.marginHeight = 1;\r
-        gl.marginWidth = 1;\r
-        fFillerComposite.setLayout(gl);\r
-        Label fillerLabel = new Label(fFillerComposite, SWT.NONE);\r
-        fillerLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        fillerLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-\r
-        fFillerComposite.addPaintListener(new PaintListener() {\r
-            @Override\r
-            public void paintControl(PaintEvent e) {\r
-                if (fSelectedRow == null) {\r
-                    Color lineColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);\r
-                    Point p = fFillerComposite.getSize();\r
-                    GC gc = e.gc;\r
-                    gc.setForeground(lineColor);\r
-                    gc.drawLine(0, 0, p.x - 1, 0);\r
-                }\r
-            }\r
-        });\r
-\r
-        MouseListener mouseListener = new MouseAdapter() {\r
-            @Override\r
-            public void mouseDown(MouseEvent e) {\r
-                fSelectedRow = null;\r
-                refresh();\r
-            }\r
-        };\r
-        fillerLabel.addMouseListener(mouseListener);\r
-\r
-        fScrolledComposite.setMinSize(fListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-\r
-        fillToolBar();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\r
-     */\r
-    @Override\r
-    public void setFocus() {\r
-        fScrolledComposite.setFocus();\r
-    }\r
-\r
-    /**\r
-     * Refreshes the view display and updates the view actions enablements.\r
-     */\r
-    public void refresh() {\r
-        fListComposite.layout();\r
-        fScrolledComposite.setMinSize(fListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-        fListComposite.redraw(0, 0, fListComposite.getBounds().width, fListComposite.getBounds().height, true);\r
-        if (fSelectedRow == null) {\r
-            fDeleteAction.setEnabled(false);\r
-            fMoveUpAction.setEnabled(false);\r
-            fMoveDownAction.setEnabled(false);\r
-        } else {\r
-            fDeleteAction.setEnabled(true);\r
-            fMoveUpAction.setEnabled(true);\r
-            fMoveDownAction.setEnabled(true);\r
-        }\r
-    }\r
-\r
-    private void fillToolBar() {\r
-\r
-        fAddAction = new AddAction();\r
-        fAddAction.setImageDescriptor(ImageDescriptor.createFromImage(ADD_IMAGE));\r
-        fAddAction.setToolTipText(Messages.ColorsView_AddActionToolTipText);\r
-\r
-        fDeleteAction = new DeleteAction();\r
-        fDeleteAction.setImageDescriptor(ImageDescriptor.createFromImage(DELETE_IMAGE));\r
-        fDeleteAction.setToolTipText(Messages.ColorsView_DeleteActionToolTipText);\r
-        fDeleteAction.setEnabled(false);\r
-\r
-        fMoveUpAction = new MoveUpAction();\r
-        fMoveUpAction.setImageDescriptor(ImageDescriptor.createFromImage(MOVE_UP_IMAGE));\r
-        fMoveUpAction.setToolTipText(Messages.ColorsView_MoveUpActionToolTipText);\r
-        fMoveUpAction.setEnabled(false);\r
-\r
-        fMoveDownAction = new MoveDownAction();\r
-        fMoveDownAction.setImageDescriptor(ImageDescriptor.createFromImage(MOVE_DOWN_IMAGE));\r
-        fMoveDownAction.setToolTipText(Messages.ColorsView_MoveDownActionToolTipText);\r
-        fMoveDownAction.setEnabled(false);\r
-\r
-        fExportAction = new ExportAction();\r
-        fExportAction.setImageDescriptor(ImageDescriptor.createFromImage(EXPORT_IMAGE));\r
-        fExportAction.setToolTipText(Messages.ColorsView_ExportActionToolTipText);\r
-\r
-        fImportAction = new ImportAction();\r
-        fImportAction.setImageDescriptor(ImageDescriptor.createFromImage(IMPORT_IMAGE));\r
-        fImportAction.setToolTipText(Messages.ColorsView_ImportActionToolTipText);\r
-\r
-        IActionBars bars = getViewSite().getActionBars();\r
-        IToolBarManager manager = bars.getToolBarManager();\r
-        manager.add(fAddAction);\r
-        manager.add(fDeleteAction);\r
-        manager.add(fMoveUpAction);\r
-        manager.add(fMoveDownAction);\r
-        manager.add(new Separator());\r
-        manager.add(fExportAction);\r
-        manager.add(fImportAction);\r
-    }\r
-\r
-    private class AddAction extends Action {\r
-        @Override\r
-        public void run() {\r
-            ColorSetting colorSetting = new ColorSetting(\r
-                    Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),\r
-                    Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(),\r
-                    Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),\r
-                    null);\r
-            ColorSettingRow row = new ColorSettingRow(fListComposite, colorSetting);\r
-            if (fSelectedRow == null) {\r
-                fColorSettings.add(colorSetting);\r
-                row.moveAbove(fFillerComposite);\r
-            } else {\r
-                fColorSettings.add(fColorSettings.indexOf(fSelectedRow.getColorSetting()), colorSetting);\r
-                row.moveAbove(fSelectedRow);\r
-            }\r
-            fSelectedRow = row;\r
-            refresh();\r
-            ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-        }\r
-    }\r
-\r
-    private class DeleteAction extends Action {\r
-\r
-        @Override\r
-        public void run() {\r
-            if (fSelectedRow != null) {\r
-                int index = fColorSettings.indexOf(fSelectedRow.getColorSetting());\r
-                fColorSettings.remove(index);\r
-                fSelectedRow.fColorSetting.dispose();\r
-                fSelectedRow.dispose();\r
-                if (index < fColorSettings.size()) {\r
-                    fSelectedRow = (ColorSettingRow) fListComposite.getChildren()[index];\r
-                } else {\r
-                    fSelectedRow = null;\r
-                }\r
-                refresh();\r
-                ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-            }\r
-        }\r
-    }\r
-\r
-    private class MoveUpAction extends Action {\r
-        @Override\r
-        public void run() {\r
-            if (fSelectedRow != null) {\r
-                int index = fColorSettings.indexOf(fSelectedRow.getColorSetting());\r
-                if (index > 0) {\r
-                    fColorSettings.add(index - 1, fColorSettings.remove(index));\r
-                    fSelectedRow.moveAbove(fListComposite.getChildren()[index - 1]);\r
-                    refresh();\r
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private class MoveDownAction extends Action {\r
-        @Override\r
-        public void run() {\r
-            if (fSelectedRow != null) {\r
-                int index = fColorSettings.indexOf(fSelectedRow.getColorSetting());\r
-                if (index < fColorSettings.size() - 1) {\r
-                    fColorSettings.add(index + 1, fColorSettings.remove(index));\r
-\r
-                    fSelectedRow.moveBelow(fListComposite.getChildren()[index + 1]);\r
-                    refresh();\r
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private class ExportAction extends Action {\r
-        @Override\r
-        public void run() {\r
-            FileDialog fileDialog = new FileDialog(fShell, SWT.SAVE);\r
-            fileDialog.setFilterExtensions(new String[] {"*.xml"}); //$NON-NLS-1$\r
-            fileDialog.setOverwrite(true);\r
-            String pathName = fileDialog.open();\r
-            if (pathName != null) {\r
-                ColorSettingsXML.save(pathName, fColorSettings.toArray(new ColorSetting[0]));\r
-            }\r
-        }\r
-    }\r
-\r
-    private class ImportAction extends Action {\r
-        @Override\r
-        public void run() {\r
-            FileDialog fileDialog = new FileDialog(fShell, SWT.OPEN);\r
-            fileDialog.setFilterExtensions(new String[] {"*.xml"}); //$NON-NLS-1$\r
-            String pathName = fileDialog.open();\r
-            if (pathName != null) {\r
-                ColorSetting[] colorSettings = ColorSettingsXML.load(pathName);\r
-                if (colorSettings.length > 0) {\r
-                    if (fColorSettings.size() > 0) {\r
-                        boolean overwrite = MessageDialog.openQuestion(fShell,\r
-                                Messages.ColorsView_ImportOverwriteDialogTitle,\r
-                                Messages.ColorsView_ImportOverwriteDialogMessage1 +\r
-                                Messages.ColorsView_ImportOverwriteDialogMessage2);\r
-                        if (overwrite) {\r
-                            for (Control control : fListComposite.getChildren()) {\r
-                                if (control instanceof ColorSettingRow) {\r
-                                    ((ColorSettingRow) control).fColorSetting.dispose();\r
-                                    control.dispose();\r
-                                }\r
-                            }\r
-                            fColorSettings = new ArrayList<ColorSetting>();\r
-                            fSelectedRow = null;\r
-                        }\r
-                    }\r
-                    for (ColorSetting colorSetting : colorSettings) {\r
-                        ColorSettingRow row = new ColorSettingRow(fListComposite, colorSetting);\r
-                        if (fSelectedRow == null) {\r
-                            fColorSettings.add(colorSetting);\r
-                            row.moveAbove(fFillerComposite);\r
-                        } else {\r
-                            fColorSettings.add(fColorSettings.indexOf(fSelectedRow.getColorSetting()), colorSetting);\r
-                            row.moveAbove(fSelectedRow);\r
-                        }\r
-                    }\r
-                    refresh();\r
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private class ColorSettingRow extends Composite {\r
-\r
-        ColorSetting fColorSetting;\r
-\r
-        public ColorSettingRow(final Composite parent, final ColorSetting colorSetting) {\r
-            super(parent, SWT.NONE);\r
-            fColorSetting = colorSetting;\r
-\r
-            setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-\r
-            setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            GridLayout gl = new GridLayout(7, false);\r
-            gl.marginHeight = 1;\r
-            gl.marginWidth = 1;\r
-            gl.horizontalSpacing = 1;\r
-            gl.verticalSpacing = 0;\r
-            setLayout(gl);\r
-\r
-            final Button fgButton = new Button(this, SWT.PUSH);\r
-            fgButton.setText(Messages.ColorsView_ForegroundButtonText);\r
-            fgButton.setSize(fgButton.computeSize(SWT.DEFAULT, 19));\r
-            fgButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-\r
-            final Button bgButton = new Button(this, SWT.PUSH);\r
-            bgButton.setText(Messages.ColorsView_BackgroundButtonText);\r
-            bgButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-\r
-            final Composite labelComposite = new Composite(this, SWT.NONE);\r
-            labelComposite.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false));\r
-            gl = new GridLayout();\r
-            gl.marginHeight = 0;\r
-            gl.marginWidth = 0;\r
-            labelComposite.setLayout(gl);\r
-            labelComposite.setBackground(colorSetting.getBackgroundColor());\r
-\r
-            final Label label = new Label(labelComposite, SWT.NONE);\r
-            label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true));\r
-            label.setText(" Text "); //$NON-NLS-1$\r
-            label.setForeground(colorSetting.getForegroundColor());\r
-            label.setBackground(colorSetting.getBackgroundColor());\r
-\r
-            fgButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fSelectedRow = ColorSettingRow.this;\r
-                    refresh();\r
-                    ColorDialog dialog = new ColorDialog(fShell);\r
-                    dialog.setRGB(colorSetting.getForegroundRGB());\r
-                    dialog.setText(Messages.ColorsView_ForegroundDialogText);\r
-                    dialog.open();\r
-                    colorSetting.setForegroundRGB(dialog.getRGB());\r
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                    label.setForeground(colorSetting.getForegroundColor());\r
-                }});\r
-\r
-            bgButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fSelectedRow = ColorSettingRow.this;\r
-                    refresh();\r
-                    ColorDialog dialog = new ColorDialog(fShell);\r
-                    dialog.setRGB(colorSetting.getBackgroundRGB());\r
-                    dialog.setText(Messages.ColorsView_BackgroundDialogText);\r
-                    dialog.open();\r
-                    colorSetting.setBackgroundRGB(dialog.getRGB());\r
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                    labelComposite.setBackground(colorSetting.getBackgroundColor());\r
-                    label.setBackground(colorSetting.getBackgroundColor());\r
-                }});\r
-\r
-            final Button tickButton = new Button(this, SWT.PUSH);\r
-            tickButton.setText(Messages.ColorsView_TickButtonText);\r
-            tickButton.setSize(tickButton.computeSize(SWT.DEFAULT, 19));\r
-            tickButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-\r
-            final Canvas tickCanvas = new Canvas(this, SWT.NONE);\r
-            GridData gd = new GridData(SWT.CENTER, SWT.FILL, false, false);\r
-            gd.widthHint = 12;\r
-            gd.heightHint = bgButton.getSize().y;\r
-            tickCanvas.setLayoutData(gd);\r
-            tickCanvas.setBackground(traceColorScheme.getBkColor(false, false, false));\r
-            tickCanvas.addPaintListener(new PaintListener() {\r
-                @Override\r
-                public void paintControl(PaintEvent e) {\r
-                    Rectangle bounds = tickCanvas.getBounds();\r
-                    e.gc.setForeground(traceColorScheme.getColor(TimeGraphColorScheme.MID_LINE));\r
-                    int midy = bounds.y + bounds.height / 2 - 1;\r
-                    //int midy = e.y + e.height / 2;\r
-                    e.gc.drawLine(e.x, midy, e.x + e.width, midy);\r
-                    Rectangle rect = new Rectangle(e.x + 1, bounds.y + 2, 0, bounds.height - 6);\r
-                    for (int i = 1; i <= 3; i++) {\r
-                        rect.x += i;\r
-                        rect.width = i;\r
-                        e.gc.setBackground(fColorSetting.getTickColor());\r
-                        e.gc.fillRectangle(rect);\r
-                    }\r
-                }});\r
-\r
-            tickButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fSelectedRow = ColorSettingRow.this;\r
-                    ColorDialog dialog = new ColorDialog(fShell);\r
-                    dialog.setRGB(colorSetting.getTickColorRGB());\r
-                    dialog.setText(Messages.TickColorDialog_TickColorDialogTitle);\r
-                    dialog.open();\r
-                    colorSetting.setTickColorRGB(dialog.getRGB());\r
-                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                    refresh();\r
-                }});\r
-\r
-            final Button filterButton = new Button(this, SWT.PUSH);\r
-            filterButton.setText(Messages.ColorsView_FilterButtonText);\r
-            filterButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-\r
-            final Label filterText = new Label(this, SWT.NONE);\r
-            if (colorSetting.getFilter() != null) {\r
-                filterText.setText(colorSetting.getFilter().toString());\r
-                filterText.setToolTipText(colorSetting.getFilter().toString());\r
-            }\r
-            filterText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));\r
-            filterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            filterButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fSelectedRow = ColorSettingRow.this;\r
-                    refresh();\r
-                    FilterDialog dialog = new FilterDialog(fShell);\r
-                    dialog.setFilter(colorSetting.getFilter());\r
-                    dialog.open();\r
-                    if (dialog.getReturnCode() == Window.OK) {\r
-                        if (dialog.getFilter() != null) {\r
-                            colorSetting.setFilter(dialog.getFilter());\r
-                            filterText.setText(dialog.getFilter().toString());\r
-                            filterText.setToolTipText(dialog.getFilter().toString());\r
-                        } else {\r
-                            colorSetting.setFilter(null);\r
-                            filterText.setText(""); //$NON-NLS-1$\r
-                            filterText.setToolTipText(""); //$NON-NLS-1$\r
-                        }\r
-                        ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));\r
-                        refresh();\r
-                    }\r
-                }});\r
-\r
-            addPaintListener(new PaintListener() {\r
-                @Override\r
-                public void paintControl(PaintEvent e) {\r
-                    if (fSelectedRow == ColorSettingRow.this) {\r
-                        Color borderColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);\r
-                        Point p = ColorSettingRow.this.getSize();\r
-                        Rectangle rect = new Rectangle(0, 0, p.x - 1, p.y - 1);\r
-                        GC gc = e.gc;\r
-                        gc.setForeground(borderColor);\r
-                        gc.drawRectangle(rect);\r
-                    }\r
-                }\r
-            });\r
-\r
-            MouseListener mouseListener = new MouseAdapter() {\r
-                @Override\r
-                public void mouseDown(MouseEvent e) {\r
-                    fSelectedRow = ColorSettingRow.this;\r
-                    refresh();\r
-                }\r
-            };\r
-            addMouseListener(mouseListener);\r
-            label.addMouseListener(mouseListener);\r
-            tickCanvas.addMouseListener(mouseListener);\r
-            filterText.addMouseListener(mouseListener);\r
-        }\r
-\r
-        /**\r
-         * @return the ColorSetting\r
-         */\r
-        public ColorSetting getColorSetting() {\r
-            return fColorSetting;\r
-        }\r
-\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *   Bernd Hufmann - Updated to use RGB for the tick color
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.colors;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.linuxtools.tmf.ui.views.filter.FilterDialog;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+
+/**
+ * Color view implementation. This view provides support for managing color settings for filters.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ *
+ */
+public class ColorsView extends TmfView {
+
+    /** ID for the color view */
+    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.colors"; //$NON-NLS-1$
+
+    private static final Image ADD_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
+    private static final Image DELETE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
+    private static final Image MOVE_UP_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
+    private static final Image MOVE_DOWN_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
+    private static final Image IMPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/import_button.gif"); //$NON-NLS-1$
+    private static final Image EXPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/export_button.gif"); //$NON-NLS-1$
+
+    // ------------------------------------------------------------------------
+    // Main data structures
+    // ------------------------------------------------------------------------
+
+    /**
+     * The composite shell.
+     */
+    protected Shell fShell;
+    /**
+     * The main composite (scrolled composite)
+     */
+    protected ScrolledComposite fScrolledComposite;
+    /**
+     * The list composite.
+     */
+    protected Composite fListComposite;
+    /**
+     * The filler composite.
+     */
+    protected Composite fFillerComposite;
+    /**
+     *  The selected color settings row
+     */
+    protected ColorSettingRow fSelectedRow = null;
+    /**
+     *  The color scheme instance for managing colors
+     */
+    protected TimeGraphColorScheme traceColorScheme = new TimeGraphColorScheme();
+    /**
+     * An action to add a color settings row
+     */
+    protected Action fAddAction;
+    /**
+     * An action to delete a color settings row
+     */
+    protected Action fDeleteAction;
+    /**
+     * An action to move up a color settings row in the list.
+     */
+    protected Action fMoveUpAction;
+    /**
+     * An action to move down a color settings row in the list.
+     */
+    protected Action fMoveDownAction;
+    /**
+     * An action to import color settings from file.
+     */
+    protected Action fImportAction;
+    /**
+     * An action to export color settings from file.
+     */
+    protected Action fExportAction;
+    /**
+     * The list of existing color settings
+     */
+    protected List<ColorSetting> fColorSettings;
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     *  Default Constructor
+     */
+    public ColorsView() {
+        super("Colors"); //$NON-NLS-1$
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(Composite)
+     */
+    @Override
+    public void createPartControl(Composite parent) {
+        fShell = parent.getShell();
+
+        fScrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
+        fScrolledComposite.setExpandHorizontal(true);
+        fScrolledComposite.setExpandVertical(true);
+        fListComposite = new Composite(fScrolledComposite, SWT.NONE);
+        fScrolledComposite.setContent(fListComposite);
+
+        GridLayout gl = new GridLayout();
+        gl.marginHeight = 0;
+        gl.marginWidth = 0;
+        gl.verticalSpacing = 1;
+        fListComposite.setLayout(gl);
+
+        fColorSettings = new ArrayList<ColorSetting>(Arrays.asList(ColorSettingsManager.getColorSettings()));
+        for (ColorSetting colorSetting : fColorSettings) {
+            new ColorSettingRow(fListComposite, colorSetting);
+        }
+
+        fFillerComposite = new Composite(fListComposite, SWT.NONE);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        gd.heightHint = 0;
+        fFillerComposite.setLayoutData(gd);
+        gl = new GridLayout();
+        gl.marginHeight = 1;
+        gl.marginWidth = 1;
+        fFillerComposite.setLayout(gl);
+        Label fillerLabel = new Label(fFillerComposite, SWT.NONE);
+        fillerLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        fillerLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+
+        fFillerComposite.addPaintListener(new PaintListener() {
+            @Override
+            public void paintControl(PaintEvent e) {
+                if (fSelectedRow == null) {
+                    Color lineColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
+                    Point p = fFillerComposite.getSize();
+                    GC gc = e.gc;
+                    gc.setForeground(lineColor);
+                    gc.drawLine(0, 0, p.x - 1, 0);
+                }
+            }
+        });
+
+        MouseListener mouseListener = new MouseAdapter() {
+            @Override
+            public void mouseDown(MouseEvent e) {
+                fSelectedRow = null;
+                refresh();
+            }
+        };
+        fillerLabel.addMouseListener(mouseListener);
+
+        fScrolledComposite.setMinSize(fListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+        fillToolBar();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+     */
+    @Override
+    public void setFocus() {
+        fScrolledComposite.setFocus();
+    }
+
+    /**
+     * Refreshes the view display and updates the view actions enablements.
+     */
+    public void refresh() {
+        fListComposite.layout();
+        fScrolledComposite.setMinSize(fListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+        fListComposite.redraw(0, 0, fListComposite.getBounds().width, fListComposite.getBounds().height, true);
+        if (fSelectedRow == null) {
+            fDeleteAction.setEnabled(false);
+            fMoveUpAction.setEnabled(false);
+            fMoveDownAction.setEnabled(false);
+        } else {
+            fDeleteAction.setEnabled(true);
+            fMoveUpAction.setEnabled(true);
+            fMoveDownAction.setEnabled(true);
+        }
+    }
+
+    private void fillToolBar() {
+
+        fAddAction = new AddAction();
+        fAddAction.setImageDescriptor(ImageDescriptor.createFromImage(ADD_IMAGE));
+        fAddAction.setToolTipText(Messages.ColorsView_AddActionToolTipText);
+
+        fDeleteAction = new DeleteAction();
+        fDeleteAction.setImageDescriptor(ImageDescriptor.createFromImage(DELETE_IMAGE));
+        fDeleteAction.setToolTipText(Messages.ColorsView_DeleteActionToolTipText);
+        fDeleteAction.setEnabled(false);
+
+        fMoveUpAction = new MoveUpAction();
+        fMoveUpAction.setImageDescriptor(ImageDescriptor.createFromImage(MOVE_UP_IMAGE));
+        fMoveUpAction.setToolTipText(Messages.ColorsView_MoveUpActionToolTipText);
+        fMoveUpAction.setEnabled(false);
+
+        fMoveDownAction = new MoveDownAction();
+        fMoveDownAction.setImageDescriptor(ImageDescriptor.createFromImage(MOVE_DOWN_IMAGE));
+        fMoveDownAction.setToolTipText(Messages.ColorsView_MoveDownActionToolTipText);
+        fMoveDownAction.setEnabled(false);
+
+        fExportAction = new ExportAction();
+        fExportAction.setImageDescriptor(ImageDescriptor.createFromImage(EXPORT_IMAGE));
+        fExportAction.setToolTipText(Messages.ColorsView_ExportActionToolTipText);
+
+        fImportAction = new ImportAction();
+        fImportAction.setImageDescriptor(ImageDescriptor.createFromImage(IMPORT_IMAGE));
+        fImportAction.setToolTipText(Messages.ColorsView_ImportActionToolTipText);
+
+        IActionBars bars = getViewSite().getActionBars();
+        IToolBarManager manager = bars.getToolBarManager();
+        manager.add(fAddAction);
+        manager.add(fDeleteAction);
+        manager.add(fMoveUpAction);
+        manager.add(fMoveDownAction);
+        manager.add(new Separator());
+        manager.add(fExportAction);
+        manager.add(fImportAction);
+    }
+
+    private class AddAction extends Action {
+        @Override
+        public void run() {
+            ColorSetting colorSetting = new ColorSetting(
+                    Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),
+                    Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(),
+                    Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(),
+                    null);
+            ColorSettingRow row = new ColorSettingRow(fListComposite, colorSetting);
+            if (fSelectedRow == null) {
+                fColorSettings.add(colorSetting);
+                row.moveAbove(fFillerComposite);
+            } else {
+                fColorSettings.add(fColorSettings.indexOf(fSelectedRow.getColorSetting()), colorSetting);
+                row.moveAbove(fSelectedRow);
+            }
+            fSelectedRow = row;
+            refresh();
+            ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+        }
+    }
+
+    private class DeleteAction extends Action {
+
+        @Override
+        public void run() {
+            if (fSelectedRow != null) {
+                int index = fColorSettings.indexOf(fSelectedRow.getColorSetting());
+                fColorSettings.remove(index);
+                fSelectedRow.fColorSetting.dispose();
+                fSelectedRow.dispose();
+                if (index < fColorSettings.size()) {
+                    fSelectedRow = (ColorSettingRow) fListComposite.getChildren()[index];
+                } else {
+                    fSelectedRow = null;
+                }
+                refresh();
+                ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+            }
+        }
+    }
+
+    private class MoveUpAction extends Action {
+        @Override
+        public void run() {
+            if (fSelectedRow != null) {
+                int index = fColorSettings.indexOf(fSelectedRow.getColorSetting());
+                if (index > 0) {
+                    fColorSettings.add(index - 1, fColorSettings.remove(index));
+                    fSelectedRow.moveAbove(fListComposite.getChildren()[index - 1]);
+                    refresh();
+                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                }
+            }
+        }
+    }
+
+    private class MoveDownAction extends Action {
+        @Override
+        public void run() {
+            if (fSelectedRow != null) {
+                int index = fColorSettings.indexOf(fSelectedRow.getColorSetting());
+                if (index < fColorSettings.size() - 1) {
+                    fColorSettings.add(index + 1, fColorSettings.remove(index));
+
+                    fSelectedRow.moveBelow(fListComposite.getChildren()[index + 1]);
+                    refresh();
+                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                }
+            }
+        }
+    }
+
+    private class ExportAction extends Action {
+        @Override
+        public void run() {
+            FileDialog fileDialog = new FileDialog(fShell, SWT.SAVE);
+            fileDialog.setFilterExtensions(new String[] {"*.xml"}); //$NON-NLS-1$
+            fileDialog.setOverwrite(true);
+            String pathName = fileDialog.open();
+            if (pathName != null) {
+                ColorSettingsXML.save(pathName, fColorSettings.toArray(new ColorSetting[0]));
+            }
+        }
+    }
+
+    private class ImportAction extends Action {
+        @Override
+        public void run() {
+            FileDialog fileDialog = new FileDialog(fShell, SWT.OPEN);
+            fileDialog.setFilterExtensions(new String[] {"*.xml"}); //$NON-NLS-1$
+            String pathName = fileDialog.open();
+            if (pathName != null) {
+                ColorSetting[] colorSettings = ColorSettingsXML.load(pathName);
+                if (colorSettings.length > 0) {
+                    if (fColorSettings.size() > 0) {
+                        boolean overwrite = MessageDialog.openQuestion(fShell,
+                                Messages.ColorsView_ImportOverwriteDialogTitle,
+                                Messages.ColorsView_ImportOverwriteDialogMessage1 +
+                                Messages.ColorsView_ImportOverwriteDialogMessage2);
+                        if (overwrite) {
+                            for (Control control : fListComposite.getChildren()) {
+                                if (control instanceof ColorSettingRow) {
+                                    ((ColorSettingRow) control).fColorSetting.dispose();
+                                    control.dispose();
+                                }
+                            }
+                            fColorSettings = new ArrayList<ColorSetting>();
+                            fSelectedRow = null;
+                        }
+                    }
+                    for (ColorSetting colorSetting : colorSettings) {
+                        ColorSettingRow row = new ColorSettingRow(fListComposite, colorSetting);
+                        if (fSelectedRow == null) {
+                            fColorSettings.add(colorSetting);
+                            row.moveAbove(fFillerComposite);
+                        } else {
+                            fColorSettings.add(fColorSettings.indexOf(fSelectedRow.getColorSetting()), colorSetting);
+                            row.moveAbove(fSelectedRow);
+                        }
+                    }
+                    refresh();
+                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                }
+            }
+        }
+    }
+
+    private class ColorSettingRow extends Composite {
+
+        ColorSetting fColorSetting;
+
+        public ColorSettingRow(final Composite parent, final ColorSetting colorSetting) {
+            super(parent, SWT.NONE);
+            fColorSetting = colorSetting;
+
+            setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+
+            setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            GridLayout gl = new GridLayout(7, false);
+            gl.marginHeight = 1;
+            gl.marginWidth = 1;
+            gl.horizontalSpacing = 1;
+            gl.verticalSpacing = 0;
+            setLayout(gl);
+
+            final Button fgButton = new Button(this, SWT.PUSH);
+            fgButton.setText(Messages.ColorsView_ForegroundButtonText);
+            fgButton.setSize(fgButton.computeSize(SWT.DEFAULT, 19));
+            fgButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+
+            final Button bgButton = new Button(this, SWT.PUSH);
+            bgButton.setText(Messages.ColorsView_BackgroundButtonText);
+            bgButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+
+            final Composite labelComposite = new Composite(this, SWT.NONE);
+            labelComposite.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false));
+            gl = new GridLayout();
+            gl.marginHeight = 0;
+            gl.marginWidth = 0;
+            labelComposite.setLayout(gl);
+            labelComposite.setBackground(colorSetting.getBackgroundColor());
+
+            final Label label = new Label(labelComposite, SWT.NONE);
+            label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, true));
+            label.setText(" Text "); //$NON-NLS-1$
+            label.setForeground(colorSetting.getForegroundColor());
+            label.setBackground(colorSetting.getBackgroundColor());
+
+            fgButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fSelectedRow = ColorSettingRow.this;
+                    refresh();
+                    ColorDialog dialog = new ColorDialog(fShell);
+                    dialog.setRGB(colorSetting.getForegroundRGB());
+                    dialog.setText(Messages.ColorsView_ForegroundDialogText);
+                    dialog.open();
+                    colorSetting.setForegroundRGB(dialog.getRGB());
+                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                    label.setForeground(colorSetting.getForegroundColor());
+                }});
+
+            bgButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fSelectedRow = ColorSettingRow.this;
+                    refresh();
+                    ColorDialog dialog = new ColorDialog(fShell);
+                    dialog.setRGB(colorSetting.getBackgroundRGB());
+                    dialog.setText(Messages.ColorsView_BackgroundDialogText);
+                    dialog.open();
+                    colorSetting.setBackgroundRGB(dialog.getRGB());
+                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                    labelComposite.setBackground(colorSetting.getBackgroundColor());
+                    label.setBackground(colorSetting.getBackgroundColor());
+                }});
+
+            final Button tickButton = new Button(this, SWT.PUSH);
+            tickButton.setText(Messages.ColorsView_TickButtonText);
+            tickButton.setSize(tickButton.computeSize(SWT.DEFAULT, 19));
+            tickButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+
+            final Canvas tickCanvas = new Canvas(this, SWT.NONE);
+            GridData gd = new GridData(SWT.CENTER, SWT.FILL, false, false);
+            gd.widthHint = 12;
+            gd.heightHint = bgButton.getSize().y;
+            tickCanvas.setLayoutData(gd);
+            tickCanvas.setBackground(traceColorScheme.getBkColor(false, false, false));
+            tickCanvas.addPaintListener(new PaintListener() {
+                @Override
+                public void paintControl(PaintEvent e) {
+                    Rectangle bounds = tickCanvas.getBounds();
+                    e.gc.setForeground(traceColorScheme.getColor(TimeGraphColorScheme.MID_LINE));
+                    int midy = bounds.y + bounds.height / 2 - 1;
+                    //int midy = e.y + e.height / 2;
+                    e.gc.drawLine(e.x, midy, e.x + e.width, midy);
+                    Rectangle rect = new Rectangle(e.x + 1, bounds.y + 2, 0, bounds.height - 6);
+                    for (int i = 1; i <= 3; i++) {
+                        rect.x += i;
+                        rect.width = i;
+                        e.gc.setBackground(fColorSetting.getTickColor());
+                        e.gc.fillRectangle(rect);
+                    }
+                }});
+
+            tickButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fSelectedRow = ColorSettingRow.this;
+                    ColorDialog dialog = new ColorDialog(fShell);
+                    dialog.setRGB(colorSetting.getTickColorRGB());
+                    dialog.setText(Messages.TickColorDialog_TickColorDialogTitle);
+                    dialog.open();
+                    colorSetting.setTickColorRGB(dialog.getRGB());
+                    ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                    refresh();
+                }});
+
+            final Button filterButton = new Button(this, SWT.PUSH);
+            filterButton.setText(Messages.ColorsView_FilterButtonText);
+            filterButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+
+            final Label filterText = new Label(this, SWT.NONE);
+            if (colorSetting.getFilter() != null) {
+                filterText.setText(colorSetting.getFilter().toString());
+                filterText.setToolTipText(colorSetting.getFilter().toString());
+            }
+            filterText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+            filterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            filterButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fSelectedRow = ColorSettingRow.this;
+                    refresh();
+                    FilterDialog dialog = new FilterDialog(fShell);
+                    dialog.setFilter(colorSetting.getFilter());
+                    dialog.open();
+                    if (dialog.getReturnCode() == Window.OK) {
+                        if (dialog.getFilter() != null) {
+                            colorSetting.setFilter(dialog.getFilter());
+                            filterText.setText(dialog.getFilter().toString());
+                            filterText.setToolTipText(dialog.getFilter().toString());
+                        } else {
+                            colorSetting.setFilter(null);
+                            filterText.setText(""); //$NON-NLS-1$
+                            filterText.setToolTipText(""); //$NON-NLS-1$
+                        }
+                        ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0]));
+                        refresh();
+                    }
+                }});
+
+            addPaintListener(new PaintListener() {
+                @Override
+                public void paintControl(PaintEvent e) {
+                    if (fSelectedRow == ColorSettingRow.this) {
+                        Color borderColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
+                        Point p = ColorSettingRow.this.getSize();
+                        Rectangle rect = new Rectangle(0, 0, p.x - 1, p.y - 1);
+                        GC gc = e.gc;
+                        gc.setForeground(borderColor);
+                        gc.drawRectangle(rect);
+                    }
+                }
+            });
+
+            MouseListener mouseListener = new MouseAdapter() {
+                @Override
+                public void mouseDown(MouseEvent e) {
+                    fSelectedRow = ColorSettingRow.this;
+                    refresh();
+                }
+            };
+            addMouseListener(mouseListener);
+            label.addMouseListener(mouseListener);
+            tickCanvas.addMouseListener(mouseListener);
+            filterText.addMouseListener(mouseListener);
+        }
+
+        /**
+         * @return the ColorSetting
+         */
+        public ColorSetting getColorSetting() {
+            return fColorSetting;
+        }
+
+    }
+}
index 45da242e4d1a6e2b8994b189ba10b70bd9d7efe1..897d0ddda3173ff7f87a4b256549111628a1245f 100644 (file)
@@ -1,30 +1,30 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.colors;\r
-\r
-/**\r
- * A color change listener\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface IColorSettingsListener {\r
-\r
-    /**\r
-     * Notify the listener that the color settings have changed.\r
-     *\r
-     * @param colorSettings\r
-     *            The new color settings\r
-     */\r
-    public void colorSettingsChanged(ColorSetting[] colorSettings);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.colors;
+
+/**
+ * A color change listener
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface IColorSettingsListener {
+
+    /**
+     * Notify the listener that the color settings have changed.
+     *
+     * @param colorSettings
+     *            The new color settings
+     */
+    public void colorSettingsChanged(ColorSetting[] colorSettings);
+}
index 5e83e058fef4ce61f75752cb069b8dc29233f386..4dcfb2c5063b710141368e387cb03936e2c4e739 100644 (file)
@@ -1,83 +1,83 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.filter;\r
-\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Shell;\r
-\r
-/**\r
- * The dialog for user-defined filters.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class FilterDialog extends Dialog {\r
-\r
-       TmfFilterNode fRoot;\r
-       FilterViewer fViewer;\r
-\r
-    /**\r
-     * Constructor.\r
-     *\r
-     * @param shell\r
-     *            The shell to which this dialog is attached\r
-     */\r
-       public FilterDialog(Shell shell) {\r
-               super(shell);\r
-               setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\r
-        */\r
-       @Override\r
-       protected Control createDialogArea(Composite parent) {\r
-        getShell().setText(Messages.FilterDialog_FilterDialogTitle);\r
-               getShell().setMinimumSize(getShell().computeSize(500, 200));\r
-        Composite composite = (Composite) super.createDialogArea(parent);\r
-\r
-        fViewer = new FilterViewer(composite, SWT.BORDER);\r
-        fViewer.setInput(fRoot);\r
-        return composite;\r
-       }\r
-\r
-       /**\r
-        * @param filter the filter to set\r
-        */\r
-       public void setFilter(ITmfFilterTreeNode filter) {\r
-               fRoot = new TmfFilterNode(null);\r
-               if (filter != null) {\r
-                       fRoot.addChild(filter.clone());\r
-               }\r
-               if (fViewer != null) {\r
-                       fViewer.setInput(fRoot);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * @return the filter\r
-        */\r
-       public ITmfFilterTreeNode getFilter() {\r
-               if (fRoot != null && fRoot.hasChildren()) {\r
-                       return fRoot.getChild(0).clone();\r
-               }\r
-               return null;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.filter;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * The dialog for user-defined filters.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class FilterDialog extends Dialog {
+
+       TmfFilterNode fRoot;
+       FilterViewer fViewer;
+
+    /**
+     * Constructor.
+     *
+     * @param shell
+     *            The shell to which this dialog is attached
+     */
+       public FilterDialog(Shell shell) {
+               super(shell);
+               setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+        getShell().setText(Messages.FilterDialog_FilterDialogTitle);
+               getShell().setMinimumSize(getShell().computeSize(500, 200));
+        Composite composite = (Composite) super.createDialogArea(parent);
+
+        fViewer = new FilterViewer(composite, SWT.BORDER);
+        fViewer.setInput(fRoot);
+        return composite;
+       }
+
+       /**
+        * @param filter the filter to set
+        */
+       public void setFilter(ITmfFilterTreeNode filter) {
+               fRoot = new TmfFilterNode(null);
+               if (filter != null) {
+                       fRoot.addChild(filter.clone());
+               }
+               if (fViewer != null) {
+                       fViewer.setInput(fRoot);
+               }
+       }
+
+       /**
+        * @return the filter
+        */
+       public ITmfFilterTreeNode getFilter() {
+               if (fRoot != null && fRoot.hasChildren()) {
+                       return fRoot.getChild(0).clone();
+               }
+               return null;
+       }
+
+}
index 3356882ea2487ccc81a85228a718a42b9528e371..427e8fff7c73ee324cd0c647a52cc4809d0590ae 100644 (file)
@@ -1,78 +1,78 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.filter;\r
-\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-\r
-import javax.xml.parsers.ParserConfigurationException;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLParser;\r
-import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLWriter;\r
-import org.xml.sax.SAXException;\r
-\r
-/**\r
- * Central filter manager\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class FilterManager {\r
-\r
-       private static final String SAVED_FILTERS_FILE_NAME = "saved_filters.xml"; //$NON-NLS-1$\r
-       private static final String SAVED_FILTERS_PATH_NAME =\r
-        Activator.getDefault().getStateLocation().addTrailingSeparator().append(SAVED_FILTERS_FILE_NAME).toString();\r
-\r
-    private static ITmfFilterTreeNode fRoot = new TmfFilterRootNode();\r
-    static {\r
-       try {\r
-               fRoot = new TmfFilterXMLParser(SAVED_FILTERS_PATH_NAME).getTree();\r
-        } catch (FileNotFoundException e) {\r
-        } catch (SAXException e) {\r
-            Activator.getDefault().logError("Error parsing saved filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error parsing saved filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the currently saved filters\r
-     *\r
-     * @return The array of filters\r
-     */\r
-    public static ITmfFilterTreeNode[] getSavedFilters() {\r
-       return fRoot.clone().getChildren();\r
-    }\r
-\r
-    /**\r
-     * Set the passed filters as the currently saved ones.\r
-     *\r
-     * @param filters\r
-     *            The filters to save\r
-     */\r
-    public static void setSavedFilters(ITmfFilterTreeNode[] filters) {\r
-       fRoot = new TmfFilterRootNode();\r
-       for (ITmfFilterTreeNode filter : filters) {\r
-               fRoot.addChild(filter.clone());\r
-       }\r
-               try {\r
-               TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);\r
-               writerXML.saveTree(SAVED_FILTERS_PATH_NAME);\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error saving filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.filter;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;
+import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLParser;
+import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * Central filter manager
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class FilterManager {
+
+       private static final String SAVED_FILTERS_FILE_NAME = "saved_filters.xml"; //$NON-NLS-1$
+       private static final String SAVED_FILTERS_PATH_NAME =
+        Activator.getDefault().getStateLocation().addTrailingSeparator().append(SAVED_FILTERS_FILE_NAME).toString();
+
+    private static ITmfFilterTreeNode fRoot = new TmfFilterRootNode();
+    static {
+       try {
+               fRoot = new TmfFilterXMLParser(SAVED_FILTERS_PATH_NAME).getTree();
+        } catch (FileNotFoundException e) {
+        } catch (SAXException e) {
+            Activator.getDefault().logError("Error parsing saved filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error parsing saved filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Retrieve the currently saved filters
+     *
+     * @return The array of filters
+     */
+    public static ITmfFilterTreeNode[] getSavedFilters() {
+       return fRoot.clone().getChildren();
+    }
+
+    /**
+     * Set the passed filters as the currently saved ones.
+     *
+     * @param filters
+     *            The filters to save
+     */
+    public static void setSavedFilters(ITmfFilterTreeNode[] filters) {
+       fRoot = new TmfFilterRootNode();
+       for (ITmfFilterTreeNode filter : filters) {
+               fRoot.addChild(filter.clone());
+       }
+               try {
+               TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);
+               writerXML.saveTree(SAVED_FILTERS_PATH_NAME);
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error saving filter xml file: " + SAVED_FILTERS_PATH_NAME, e); //$NON-NLS-1$
+        }
+    }
+}
index 73c758448e39c654cb437c4872dcd51865830aec..99076119317902327aeacb4a88b5b22e7e7b6dd3 100644 (file)
@@ -1,95 +1,95 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Yuriy Vashchuk - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.filter;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-\r
-/**\r
- * This is the Content Provider of our tree\r
- *\r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- */\r
-public class FilterTreeContentProvider implements ITreeContentProvider {\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.IContentProvider#dispose()\r
-        */\r
-       @Override\r
-    public void dispose() {\r
-               // TODO Auto-generated method stub\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)\r
-        */\r
-       @Override\r
-    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-               // TODO Auto-generated method stub\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)\r
-        */\r
-       @Override\r
-    public Object[] getElements(Object inputElement) {\r
-               if (inputElement instanceof ITmfFilterTreeNode) {\r
-                       ArrayList<ITmfFilterTreeNode> result = new ArrayList<ITmfFilterTreeNode>();\r
-                       for(int i = 0; i < ((ITmfFilterTreeNode)inputElement).getChildrenCount(); i++) {\r
-                               result.add(((ITmfFilterTreeNode)inputElement).getChild(i));\r
-                       }\r
-\r
-                       return result.toArray();\r
-               }\r
-        return null;\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)\r
-        */\r
-       @Override\r
-    public Object[] getChildren(Object parentElement) {\r
-               ArrayList<ITmfFilterTreeNode> result = new ArrayList<ITmfFilterTreeNode>();\r
-               for(int i = 0; i < ((ITmfFilterTreeNode)parentElement).getChildrenCount(); i++) {\r
-                       result.add(((ITmfFilterTreeNode)parentElement).getChild(i));\r
-               }\r
-               return result.toArray();\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)\r
-        */\r
-       @Override\r
-    public Object getParent(Object element) {\r
-               return ((ITmfFilterTreeNode) element).getParent();\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)\r
-        */\r
-       @Override\r
-    public boolean hasChildren(Object element) {\r
-               return ((ITmfFilterTreeNode) element).hasChildren();\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Yuriy Vashchuk - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.filter;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+
+/**
+ * This is the Content Provider of our tree
+ *
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ */
+public class FilterTreeContentProvider implements ITreeContentProvider {
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+        */
+       @Override
+    public void dispose() {
+               // TODO Auto-generated method stub
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       @Override
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               // TODO Auto-generated method stub
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
+        */
+       @Override
+    public Object[] getElements(Object inputElement) {
+               if (inputElement instanceof ITmfFilterTreeNode) {
+                       ArrayList<ITmfFilterTreeNode> result = new ArrayList<ITmfFilterTreeNode>();
+                       for(int i = 0; i < ((ITmfFilterTreeNode)inputElement).getChildrenCount(); i++) {
+                               result.add(((ITmfFilterTreeNode)inputElement).getChild(i));
+                       }
+
+                       return result.toArray();
+               }
+        return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+        */
+       @Override
+    public Object[] getChildren(Object parentElement) {
+               ArrayList<ITmfFilterTreeNode> result = new ArrayList<ITmfFilterTreeNode>();
+               for(int i = 0; i < ((ITmfFilterTreeNode)parentElement).getChildrenCount(); i++) {
+                       result.add(((ITmfFilterTreeNode)parentElement).getChild(i));
+               }
+               return result.toArray();
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+        */
+       @Override
+    public Object getParent(Object element) {
+               return ((ITmfFilterTreeNode) element).getParent();
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+        */
+       @Override
+    public boolean hasChildren(Object element) {
+               return ((ITmfFilterTreeNode) element).hasChildren();
+       }
+
+}
index 2d4095b1f3a64d9e72751ccfdd37cb928443d12c..e4d60a55745c66513e34e1c706e520806a7c4014 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Yuriy Vashchuk - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.filter;\r
-\r
-import org.eclipse.jface.viewers.ILabelProvider;\r
-import org.eclipse.jface.viewers.ILabelProviderListener;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;\r
-import org.eclipse.swt.graphics.Image;\r
-\r
-/**\r
- * This is the Label Provider for our Filter Tree\r
- *\r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- */\r
-public class FilterTreeLabelProvider implements ILabelProvider {\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)\r
-        */\r
-       @Override\r
-    public void addListener(ILabelProviderListener listener) {\r
-               // TODO Auto-generated method stub\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()\r
-        */\r
-       @Override\r
-    public void dispose() {\r
-               // TODO Auto-generated method stub\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)\r
-        */\r
-       @Override\r
-    public boolean isLabelProperty(Object element, String property) {\r
-               // TODO Auto-generated method stub\r
-               return false;\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)\r
-        */\r
-       @Override\r
-    public void removeListener(ILabelProviderListener listener) {\r
-               // TODO Auto-generated method stub\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)\r
-        */\r
-       @Override\r
-    public Image getImage(Object element) {\r
-               // TODO Auto-generated method stub\r
-               return null;\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)\r
-        */\r
-       @Override\r
-    public String getText(Object element) {\r
-               String label = null;\r
-\r
-               if (element instanceof TmfFilterNode) {\r
-\r
-                       TmfFilterNode node = (TmfFilterNode) element;\r
-                       label = node.getNodeName() + " " + node.getFilterName(); //$NON-NLS-1$\r
-\r
-               } else if (element instanceof TmfFilterEventTypeNode) {\r
-\r
-                       TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) element;\r
-                       label = "WITH " + node.getNodeName() + (node.getName() != null ? " " + node.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-\r
-               } else if (element instanceof TmfFilterAndNode) {\r
-\r
-                       TmfFilterAndNode node = (TmfFilterAndNode) element;\r
-                       label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$\r
-\r
-               } else if (element instanceof TmfFilterOrNode) {\r
-\r
-                       TmfFilterOrNode node = (TmfFilterOrNode) element;\r
-                       label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$\r
-\r
-               } else if (element instanceof TmfFilterContainsNode) {\r
-\r
-                       TmfFilterContainsNode node = (TmfFilterContainsNode) element;\r
-                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       node.getNodeName() +\r
-                                       (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-\r
-               } else if (element instanceof TmfFilterEqualsNode) {\r
-\r
-                       TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;\r
-                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       node.getNodeName() +\r
-                                       (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-\r
-               } else if (element instanceof TmfFilterMatchesNode) {\r
-\r
-                       TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;\r
-                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       node.getNodeName() +\r
-                                       (node.getRegex() != null && node.getRegex().length() > 0 ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-\r
-               } else if (element instanceof TmfFilterCompareNode) {\r
-\r
-                       TmfFilterCompareNode node = (TmfFilterCompareNode) element;\r
-                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$\r
-                                       (node.getResult() < 0 ? "<" : (node.getResult() > 0 ? ">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                                       (node.getValue() != null && node.getValue().length() > 0 ?\r
-                                                       (node.getType() == Type.ALPHA ? " \"" + node.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$\r
-                                                       (node.getType() == Type.TIMESTAMP ? " [" + node.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$\r
-                                                               " " + node.getValue())) : "");  //$NON-NLS-1$//$NON-NLS-2$\r
-\r
-               }\r
-               return label;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Yuriy Vashchuk - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.filter;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is the Label Provider for our Filter Tree
+ *
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ */
+public class FilterTreeLabelProvider implements ILabelProvider {
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+        */
+       @Override
+    public void addListener(ILabelProviderListener listener) {
+               // TODO Auto-generated method stub
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+        */
+       @Override
+    public void dispose() {
+               // TODO Auto-generated method stub
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
+        */
+       @Override
+    public boolean isLabelProperty(Object element, String property) {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+        */
+       @Override
+    public void removeListener(ILabelProviderListener listener) {
+               // TODO Auto-generated method stub
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+        */
+       @Override
+    public Image getImage(Object element) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+        */
+       @Override
+    public String getText(Object element) {
+               String label = null;
+
+               if (element instanceof TmfFilterNode) {
+
+                       TmfFilterNode node = (TmfFilterNode) element;
+                       label = node.getNodeName() + " " + node.getFilterName(); //$NON-NLS-1$
+
+               } else if (element instanceof TmfFilterEventTypeNode) {
+
+                       TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) element;
+                       label = "WITH " + node.getNodeName() + (node.getName() != null ? " " + node.getName() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+               } else if (element instanceof TmfFilterAndNode) {
+
+                       TmfFilterAndNode node = (TmfFilterAndNode) element;
+                       label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
+
+               } else if (element instanceof TmfFilterOrNode) {
+
+                       TmfFilterOrNode node = (TmfFilterOrNode) element;
+                       label = (node.isNot() ? "NOT " : "") + node.getNodeName(); //$NON-NLS-1$ //$NON-NLS-2$
+
+               } else if (element instanceof TmfFilterContainsNode) {
+
+                       TmfFilterContainsNode node = (TmfFilterContainsNode) element;
+                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       node.getNodeName() +
+                                       (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+               } else if (element instanceof TmfFilterEqualsNode) {
+
+                       TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;
+                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       node.getNodeName() +
+                                       (node.getValue() != null && node.getValue().length() > 0 ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+               } else if (element instanceof TmfFilterMatchesNode) {
+
+                       TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;
+                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       node.getNodeName() +
+                                       (node.getRegex() != null && node.getRegex().length() > 0 ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+               } else if (element instanceof TmfFilterCompareNode) {
+
+                       TmfFilterCompareNode node = (TmfFilterCompareNode) element;
+                       label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       (node.getField() != null ? node.getField() + " " : "") + //$NON-NLS-1$ //$NON-NLS-2$
+                                       (node.getResult() < 0 ? "<" : (node.getResult() > 0 ? ">" : "=")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                                       (node.getValue() != null && node.getValue().length() > 0 ?
+                                                       (node.getType() == Type.ALPHA ? " \"" + node.getValue() + "\"" : //$NON-NLS-1$ //$NON-NLS-2$
+                                                       (node.getType() == Type.TIMESTAMP ? " [" + node.getValue() + "]" : //$NON-NLS-1$ //$NON-NLS-2$
+                                                               " " + node.getValue())) : "");  //$NON-NLS-1$//$NON-NLS-2$
+
+               }
+               return label;
+       }
+
+}
index 73fcb6be3db272cf635e52e6571d75e87f0ccdfa..f66a817a3b2898dada70af177ea4fd02897dc4fa 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Yuriy Vashchuk - Initial API and implementation\r
- *   based on Francois Chouinard ProjectView code.\r
- */\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.filter;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.xml.parsers.ParserConfigurationException;\r
-\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.core.resources.IWorkspace;\r
-import org.eclipse.core.resources.ResourcesPlugin;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.IToolBarManager;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLParser;\r
-import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLWriter;\r
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IActionBars;\r
-import org.xml.sax.SAXException;\r
-\r
-/**\r
- * View that contain UI to the TMF filter.\r
- *\r
- * @version 1.0\r
- * @author Yuriy Vashchuk\r
- */\r
-public class FilterView extends TmfView {\r
-\r
-    /** ID for the Filter view */\r
-    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.filter"; //$NON-NLS-1$\r
-\r
-    private static final Image SAVE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/save_button.gif"); //$NON-NLS-1$\r
-    private static final Image ADD_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$\r
-    private static final Image DELETE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$\r
-    private static final Image IMPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/import_button.gif"); //$NON-NLS-1$\r
-    private static final Image EXPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/export_button.gif"); //$NON-NLS-1$\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Main data structures\r
-    // ------------------------------------------------------------------------\r
-\r
-    private FilterViewer fViewer;\r
-    private final ITmfFilterTreeNode fRoot;\r
-\r
-    private final IWorkspace fWorkspace;\r
-\r
-    private SaveAction fSaveAction;\r
-    private AddAction fAddAction;\r
-    private DeleteAction fDeleteAction;\r
-    private ExportAction fExportAction;\r
-    private ImportAction fImportAction;\r
-\r
-    /**\r
-     * Getter for the Filter Tree Root\r
-     *\r
-     * @return The root of builded tree\r
-     */\r
-    public ITmfFilterTreeNode getFilterRoot() {\r
-       return fRoot;\r
-    }\r
-\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructor\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Default Constructor\r
-     */\r
-    public FilterView() {\r
-        super("Filter"); //$NON-NLS-1$\r
-\r
-        fWorkspace = ResourcesPlugin.getWorkspace();\r
-        try {\r
-            fWorkspace.getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);\r
-        } catch (CoreException e) {\r
-            Activator.getDefault().logError("Error refreshing workspace", e); //$NON-NLS-1$\r
-        }\r
-\r
-        fRoot = new TmfFilterRootNode();\r
-        for (ITmfFilterTreeNode node : FilterManager.getSavedFilters()) {\r
-               fRoot.addChild(node);\r
-        }\r
-       }\r
-\r
-\r
-       /**\r
-        * Refresh the tree widget\r
-        */\r
-       public void refresh() {\r
-               fViewer.refresh();\r
-       }\r
-\r
-       /**\r
-        * Setter for selection\r
-        *\r
-        * @param node The node to select\r
-        */\r
-       public void setSelection(ITmfFilterTreeNode node) {\r
-               fViewer.setSelection(node, true);\r
-       }\r
-\r
-       // ------------------------------------------------------------------------\r
-       // ViewPart\r
-       // ------------------------------------------------------------------------\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(Composite)\r
-     */\r
-       @Override\r
-       public void createPartControl(Composite parent) {\r
-\r
-               fViewer = new FilterViewer(parent, SWT.NONE);\r
-               fViewer.setInput(fRoot);\r
-\r
-               contributeToActionBars();\r
-\r
-               fViewer.addSelectionChangedListener(new ISelectionChangedListener() {\r
-                       @Override\r
-                       public void selectionChanged(SelectionChangedEvent event) {\r
-                               if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {\r
-                                       fDeleteAction.setEnabled(true);\r
-                                       fExportAction.setEnabled(true);\r
-                               } else {\r
-                                       fDeleteAction.setEnabled(false);\r
-                                       fExportAction.setEnabled(false);\r
-                               }\r
-                       }\r
-               });\r
-       }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\r
-     */\r
-    @Override\r
-    public void setFocus() {\r
-        fViewer.setFocus();\r
-    }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * @see java.lang.Object#toString()\r
-        */\r
-       @Override\r
-       public String toString() {\r
-               return "[FilterView]"; //$NON-NLS-1$\r
-       }\r
-\r
-\r
-    /**\r
-     * Builds the menu toolbar\r
-     */\r
-       private void contributeToActionBars() {\r
-               IActionBars bars = getViewSite().getActionBars();\r
-               //fillLocalPullDown(bars.getMenuManager());\r
-               fillLocalToolBar(bars.getToolBarManager());\r
-       }\r
-\r
-\r
-       /**\r
-        * Build the popup menu\r
-        *\r
-        * @param manager The manager to build\r
-        */\r
-       private void fillLocalToolBar(IToolBarManager manager) {\r
-\r
-               fSaveAction = new SaveAction();\r
-               fSaveAction.setImageDescriptor(ImageDescriptor.createFromImage(SAVE_IMAGE));\r
-               fSaveAction.setToolTipText(Messages.FilterView_SaveActionToolTipText);\r
-\r
-               fAddAction = new AddAction();\r
-               fAddAction.setImageDescriptor(ImageDescriptor.createFromImage(ADD_IMAGE));\r
-               fAddAction.setToolTipText(Messages.FilterView_AddActionToolTipText);\r
-\r
-               fDeleteAction = new DeleteAction();\r
-               fDeleteAction.setImageDescriptor(ImageDescriptor.createFromImage(DELETE_IMAGE));\r
-               fDeleteAction.setToolTipText(Messages.FilterView_DeleteActionToolTipText);\r
-               fDeleteAction.setEnabled(false);\r
-\r
-               fExportAction = new ExportAction();\r
-               fExportAction.setImageDescriptor(ImageDescriptor.createFromImage(EXPORT_IMAGE));\r
-               fExportAction.setToolTipText(Messages.FilterView_ExportActionToolTipText);\r
-\r
-               fImportAction = new ImportAction();\r
-               fImportAction.setImageDescriptor(ImageDescriptor.createFromImage(IMPORT_IMAGE));\r
-               fImportAction.setToolTipText(Messages.FilterView_ImportActionToolTipText);\r
-\r
-               manager.add(fSaveAction);\r
-               manager.add(new Separator());\r
-               manager.add(fAddAction);\r
-               manager.add(fDeleteAction);\r
-               manager.add(new Separator());\r
-               manager.add(fExportAction);\r
-               manager.add(fImportAction);\r
-       }\r
-\r
-       private class SaveAction extends Action {\r
-               @Override\r
-               public void run() {\r
-                       FilterManager.setSavedFilters(fRoot.getChildren());\r
-               }\r
-       }\r
-\r
-       private class AddAction extends Action {\r
-               @Override\r
-               public void run() {\r
-\r
-                       TmfFilterNode newNode = new TmfFilterNode(fRoot, ""); //$NON-NLS-1$\r
-                       refresh();\r
-                       setSelection(newNode);\r
-               }\r
-       }\r
-\r
-       private class DeleteAction extends Action {\r
-               @Override\r
-               public void run() {\r
-                       ITmfFilterTreeNode node = fViewer.getSelection();\r
-                       if (node != null) {\r
-                               node.remove();\r
-                       }\r
-                       refresh();\r
-               }\r
-       }\r
-\r
-       private class ExportAction extends Action {\r
-               @Override\r
-               public void run() {\r
-                       try {\r
-                               FileDialog dlg = new FileDialog(new Shell(), SWT.SAVE);\r
-                               dlg.setFilterNames(new String[] {Messages.FilterView_FileDialogFilterName + " (*.filter.xml)"}); //$NON-NLS-1$\r
-                               dlg.setFilterExtensions(new String[] {"*.filter.xml"}); //$NON-NLS-1$\r
-\r
-                               String fn = dlg.open();\r
-                       if (fn != null) {\r
-                                       TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);\r
-                                       writerXML.saveTree(fn);\r
-                       }\r
-\r
-                       } catch (ParserConfigurationException e) {\r
-                           Activator.getDefault().logError("Error parsing filter xml file", e); //$NON-NLS-1$\r
-                       }\r
-               }\r
-       }\r
-\r
-       private class ImportAction extends Action {\r
-               @Override\r
-               public void run() {\r
-                       if (fViewer != null) {\r
-                               ITmfFilterTreeNode root = null;\r
-                               try {\r
-                                       FileDialog dlg = new FileDialog(new Shell(), SWT.OPEN);\r
-                                       dlg.setFilterNames(new String[] {Messages.FilterView_FileDialogFilterName + " (*.filter.xml)"}); //$NON-NLS-1$\r
-                                       dlg.setFilterExtensions(new String[] {"*.filter.xml"}); //$NON-NLS-1$\r
-\r
-                                       TmfFilterXMLParser parserXML = null;\r
-                                       String fn = dlg.open();\r
-                               if (fn != null) {\r
-                                       parserXML = new TmfFilterXMLParser(fn);\r
-                                               root = parserXML.getTree();\r
-                               }\r
-\r
-                               } catch (SAXException e) {\r
-                                   Activator.getDefault().logError("Error importing filter xml file", e); //$NON-NLS-1$\r
-                               } catch (IOException e) {\r
-                                   Activator.getDefault().logError("Error importing filter xml file", e); //$NON-NLS-1$\r
-                               }\r
-\r
-                               if (root != null) {\r
-                               for (ITmfFilterTreeNode node : root.getChildren()) {\r
-                                       if (node instanceof TmfFilterNode) {\r
-                                               fRoot.addChild(node);\r
-                                               refresh();\r
-                                               fViewer.setSelection(node);\r
-                                       }\r
-                               }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Yuriy Vashchuk - Initial API and implementation
+ *   based on Francois Chouinard ProjectView code.
+ */
+
+package org.eclipse.linuxtools.tmf.ui.views.filter;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;
+import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLParser;
+import org.eclipse.linuxtools.tmf.core.filter.xml.TmfFilterXMLWriter;
+import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.xml.sax.SAXException;
+
+/**
+ * View that contain UI to the TMF filter.
+ *
+ * @version 1.0
+ * @author Yuriy Vashchuk
+ */
+public class FilterView extends TmfView {
+
+    /** ID for the Filter view */
+    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.filter"; //$NON-NLS-1$
+
+    private static final Image SAVE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/save_button.gif"); //$NON-NLS-1$
+    private static final Image ADD_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
+    private static final Image DELETE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
+    private static final Image IMPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/import_button.gif"); //$NON-NLS-1$
+    private static final Image EXPORT_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/export_button.gif"); //$NON-NLS-1$
+
+    // ------------------------------------------------------------------------
+    // Main data structures
+    // ------------------------------------------------------------------------
+
+    private FilterViewer fViewer;
+    private final ITmfFilterTreeNode fRoot;
+
+    private final IWorkspace fWorkspace;
+
+    private SaveAction fSaveAction;
+    private AddAction fAddAction;
+    private DeleteAction fDeleteAction;
+    private ExportAction fExportAction;
+    private ImportAction fImportAction;
+
+    /**
+     * Getter for the Filter Tree Root
+     *
+     * @return The root of builded tree
+     */
+    public ITmfFilterTreeNode getFilterRoot() {
+       return fRoot;
+    }
+
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     * Default Constructor
+     */
+    public FilterView() {
+        super("Filter"); //$NON-NLS-1$
+
+        fWorkspace = ResourcesPlugin.getWorkspace();
+        try {
+            fWorkspace.getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
+        } catch (CoreException e) {
+            Activator.getDefault().logError("Error refreshing workspace", e); //$NON-NLS-1$
+        }
+
+        fRoot = new TmfFilterRootNode();
+        for (ITmfFilterTreeNode node : FilterManager.getSavedFilters()) {
+               fRoot.addChild(node);
+        }
+       }
+
+
+       /**
+        * Refresh the tree widget
+        */
+       public void refresh() {
+               fViewer.refresh();
+       }
+
+       /**
+        * Setter for selection
+        *
+        * @param node The node to select
+        */
+       public void setSelection(ITmfFilterTreeNode node) {
+               fViewer.setSelection(node, true);
+       }
+
+       // ------------------------------------------------------------------------
+       // ViewPart
+       // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(Composite)
+     */
+       @Override
+       public void createPartControl(Composite parent) {
+
+               fViewer = new FilterViewer(parent, SWT.NONE);
+               fViewer.setInput(fRoot);
+
+               contributeToActionBars();
+
+               fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       @Override
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
+                                       fDeleteAction.setEnabled(true);
+                                       fExportAction.setEnabled(true);
+                               } else {
+                                       fDeleteAction.setEnabled(false);
+                                       fExportAction.setEnabled(false);
+                               }
+                       }
+               });
+       }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+     */
+    @Override
+    public void setFocus() {
+        fViewer.setFocus();
+    }
+
+       /*
+        * (non-Javadoc)
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               return "[FilterView]"; //$NON-NLS-1$
+       }
+
+
+    /**
+     * Builds the menu toolbar
+     */
+       private void contributeToActionBars() {
+               IActionBars bars = getViewSite().getActionBars();
+               //fillLocalPullDown(bars.getMenuManager());
+               fillLocalToolBar(bars.getToolBarManager());
+       }
+
+
+       /**
+        * Build the popup menu
+        *
+        * @param manager The manager to build
+        */
+       private void fillLocalToolBar(IToolBarManager manager) {
+
+               fSaveAction = new SaveAction();
+               fSaveAction.setImageDescriptor(ImageDescriptor.createFromImage(SAVE_IMAGE));
+               fSaveAction.setToolTipText(Messages.FilterView_SaveActionToolTipText);
+
+               fAddAction = new AddAction();
+               fAddAction.setImageDescriptor(ImageDescriptor.createFromImage(ADD_IMAGE));
+               fAddAction.setToolTipText(Messages.FilterView_AddActionToolTipText);
+
+               fDeleteAction = new DeleteAction();
+               fDeleteAction.setImageDescriptor(ImageDescriptor.createFromImage(DELETE_IMAGE));
+               fDeleteAction.setToolTipText(Messages.FilterView_DeleteActionToolTipText);
+               fDeleteAction.setEnabled(false);
+
+               fExportAction = new ExportAction();
+               fExportAction.setImageDescriptor(ImageDescriptor.createFromImage(EXPORT_IMAGE));
+               fExportAction.setToolTipText(Messages.FilterView_ExportActionToolTipText);
+
+               fImportAction = new ImportAction();
+               fImportAction.setImageDescriptor(ImageDescriptor.createFromImage(IMPORT_IMAGE));
+               fImportAction.setToolTipText(Messages.FilterView_ImportActionToolTipText);
+
+               manager.add(fSaveAction);
+               manager.add(new Separator());
+               manager.add(fAddAction);
+               manager.add(fDeleteAction);
+               manager.add(new Separator());
+               manager.add(fExportAction);
+               manager.add(fImportAction);
+       }
+
+       private class SaveAction extends Action {
+               @Override
+               public void run() {
+                       FilterManager.setSavedFilters(fRoot.getChildren());
+               }
+       }
+
+       private class AddAction extends Action {
+               @Override
+               public void run() {
+
+                       TmfFilterNode newNode = new TmfFilterNode(fRoot, ""); //$NON-NLS-1$
+                       refresh();
+                       setSelection(newNode);
+               }
+       }
+
+       private class DeleteAction extends Action {
+               @Override
+               public void run() {
+                       ITmfFilterTreeNode node = fViewer.getSelection();
+                       if (node != null) {
+                               node.remove();
+                       }
+                       refresh();
+               }
+       }
+
+       private class ExportAction extends Action {
+               @Override
+               public void run() {
+                       try {
+                               FileDialog dlg = new FileDialog(new Shell(), SWT.SAVE);
+                               dlg.setFilterNames(new String[] {Messages.FilterView_FileDialogFilterName + " (*.filter.xml)"}); //$NON-NLS-1$
+                               dlg.setFilterExtensions(new String[] {"*.filter.xml"}); //$NON-NLS-1$
+
+                               String fn = dlg.open();
+                       if (fn != null) {
+                                       TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);
+                                       writerXML.saveTree(fn);
+                       }
+
+                       } catch (ParserConfigurationException e) {
+                           Activator.getDefault().logError("Error parsing filter xml file", e); //$NON-NLS-1$
+                       }
+               }
+       }
+
+       private class ImportAction extends Action {
+               @Override
+               public void run() {
+                       if (fViewer != null) {
+                               ITmfFilterTreeNode root = null;
+                               try {
+                                       FileDialog dlg = new FileDialog(new Shell(), SWT.OPEN);
+                                       dlg.setFilterNames(new String[] {Messages.FilterView_FileDialogFilterName + " (*.filter.xml)"}); //$NON-NLS-1$
+                                       dlg.setFilterExtensions(new String[] {"*.filter.xml"}); //$NON-NLS-1$
+
+                                       TmfFilterXMLParser parserXML = null;
+                                       String fn = dlg.open();
+                               if (fn != null) {
+                                       parserXML = new TmfFilterXMLParser(fn);
+                                               root = parserXML.getTree();
+                               }
+
+                               } catch (SAXException e) {
+                                   Activator.getDefault().logError("Error importing filter xml file", e); //$NON-NLS-1$
+                               } catch (IOException e) {
+                                   Activator.getDefault().logError("Error importing filter xml file", e); //$NON-NLS-1$
+                               }
+
+                               if (root != null) {
+                               for (ITmfFilterTreeNode node : root.getChildren()) {
+                                       if (node instanceof TmfFilterNode) {
+                                               fRoot.addChild(node);
+                                               refresh();
+                                               fViewer.setSelection(node);
+                                       }
+                               }
+                               }
+                       }
+               }
+       }
+
 }
\ No newline at end of file
index 7fb527de7d79214be80c7394b49ef38ffbcc7979..84908aec3cd399fa3f98782ee0da72379a849789 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.filter;\r
-\r
-import java.util.ArrayList;\r
-import java.util.LinkedHashMap;\r
-import java.util.Map;\r
-import java.util.Map.Entry;\r
-\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.core.runtime.IConfigurationElement;\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.IMenuListener;\r
-import org.eclipse.jface.action.IMenuManager;\r
-import org.eclipse.jface.action.MenuManager;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.jface.viewers.TreeViewer;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtEvent;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlEvent;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;\r
-import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterTreeNode;\r
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.events.FocusEvent;\r
-import org.eclipse.swt.events.FocusListener;\r
-import org.eclipse.swt.events.ModifyEvent;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Combo;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Menu;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.eclipse.swt.widgets.TreeItem;\r
-\r
-class FilterViewer extends Composite {\r
-\r
-    private static final String CUSTOM_TXT_CATEGORY = "Custom Text"; //$NON-NLS-1$\r
-    private static final String CUSTOM_XML_CATEGORY = "Custom XML"; //$NON-NLS-1$\r
-\r
-    private TreeViewer fViewer;\r
-    private Composite fComposite;\r
-    \r
-    public FilterViewer(Composite parent, int style) {\r
-        super(parent, style);\r
-\r
-        setLayout(new FillLayout());\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-        setLayoutData(gd);\r
-        \r
-        final SashForm sash = new SashForm(this, SWT.HORIZONTAL);\r
-\r
-        // Create the tree viewer to display the filter tree\r
-        fViewer = new TreeViewer(sash, SWT.NONE);\r
-        fViewer.setContentProvider(new FilterTreeContentProvider());\r
-        fViewer.setLabelProvider(new FilterTreeLabelProvider());\r
-        fViewer.setInput(new TmfFilterRootNode());\r
-        \r
-        // Create the empty filter node properties panel\r
-        fComposite = new Composite(sash, SWT.NONE);\r
-        GridLayout gl = new GridLayout();\r
-        gl.marginHeight = 0;\r
-        gl.marginWidth = 0;\r
-        fComposite.setLayout(gl);\r
-\r
-        createContextMenu();\r
-        \r
-        fViewer.addSelectionChangedListener(new ISelectionChangedListener() {\r
-            @Override\r
-            public void selectionChanged(SelectionChangedEvent event) {\r
-                if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {\r
-                    // Update the filter node properties panel to the selection\r
-                    IStructuredSelection selection = (IStructuredSelection) event.getSelection();\r
-                    ITmfFilterTreeNode node = (ITmfFilterTreeNode) selection.getFirstElement();\r
-                    updateFilterNodeComposite(node);\r
-                    // Highlight the selection's children\r
-                    highlightTreeItems(fViewer.getTree().getSelection()[0].getItems());\r
-                } else {\r
-                    updateFilterNodeComposite(null);\r
-                }\r
-            }\r
-        });\r
-\r
-        fViewer.getTree().addPaintListener(new PaintListener() {\r
-            @Override\r
-            public void paintControl(PaintEvent e) {\r
-                TmfFilterTreeNode root = (TmfFilterTreeNode) fViewer.getInput();\r
-                if (root == null || root.getChildrenCount() == 0) {\r
-                    e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));\r
-                    e.gc.drawText(Messages.FilterViewer_EmptyTreeHintText, 5, 0);\r
-                }\r
-            }\r
-        });\r
-    }\r
-    \r
-    /**\r
-     * Create the context menu for the tree viewer\r
-     */\r
-    private void createContextMenu() {\r
-        // Adds root context menu\r
-        MenuManager menuManager = new MenuManager();\r
-        menuManager.setRemoveAllWhenShown(true);\r
-        menuManager.addMenuListener(new IMenuListener() {\r
-            @Override\r
-            public void menuAboutToShow(IMenuManager manager) {\r
-                fillContextMenu(manager);\r
-            }\r
-        });\r
-\r
-        // Context\r
-        Menu contextMenu = menuManager.createContextMenu(fViewer.getTree());\r
-\r
-        // Publish it\r
-        fViewer.getTree().setMenu(contextMenu);\r
-    }\r
-    \r
-    /**\r
-     * Fill the context menu for the tree viewer\r
-     */\r
-    protected void fillContextMenu(IMenuManager manager) {\r
-        final ISelection selection = fViewer.getSelection();\r
-        ITmfFilterTreeNode filterTreeNode = null;\r
-        if (selection instanceof StructuredSelection) {\r
-            Object element = ((StructuredSelection) selection).getFirstElement();\r
-            if (element instanceof ITmfFilterTreeNode) {\r
-                filterTreeNode = (ITmfFilterTreeNode) element;\r
-            }\r
-        }\r
-\r
-        final ITmfFilterTreeNode selectedNode = filterTreeNode;\r
-        \r
-        if (selectedNode != null) {\r
-            \r
-            fillContextMenuForNode(selectedNode, manager);\r
-            \r
-            if (selectedNode.getValidChildren().size() > 0) {\r
-                manager.add(new Separator());\r
-            }\r
-\r
-            Action deleteAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    selectedNode.remove();\r
-                    fViewer.refresh();\r
-                }\r
-            };\r
-            deleteAction.setText(Messages.FilterViewer_DeleteActionText);\r
-            manager.add(deleteAction);\r
-            \r
-            manager.add(new Separator());\r
-        }\r
-\r
-        if (fViewer.getInput() instanceof TmfFilterRootNode || selectedNode == null) {\r
-            final ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();\r
-            \r
-            fillContextMenuForNode(root, manager);\r
-        }\r
-    }\r
-    \r
-    /**\r
-     * Fill the context menu with the valid children of the provided node\r
-     */\r
-    protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) {\r
-        for (final String child : node.getValidChildren()) {\r
-            final Action action = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    ITmfFilterTreeNode newNode = null;\r
-                    if (TmfFilterNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterNode(node, ""); //$NON-NLS-1$\r
-                    } else if (TmfFilterEventTypeNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterEventTypeNode(node);\r
-                    } else if (TmfFilterAndNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterAndNode(node);\r
-                    } else if (TmfFilterOrNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterOrNode(node);\r
-                    } else if (TmfFilterContainsNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterContainsNode(node);\r
-                    } else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterEqualsNode(node);\r
-                    } else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterMatchesNode(node);\r
-                    } else if (TmfFilterCompareNode.NODE_NAME.equals(child)) {\r
-                        newNode = new TmfFilterCompareNode(node);\r
-                    }\r
-                    if (newNode != null) {\r
-                        fViewer.refresh();\r
-                        fViewer.setSelection(new StructuredSelection(newNode), true);\r
-                    }\r
-                }\r
-            };\r
-            if (TmfFilterNode.NODE_NAME.equals(child)) {\r
-                action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$\r
-            } else {\r
-                action.setText(child);\r
-            }\r
-            manager.add(action);\r
-        }\r
-    }\r
-    \r
-    /**\r
-     * Create the appropriate filter node properties composite\r
-     */\r
-    private void updateFilterNodeComposite(ITmfFilterTreeNode node) {\r
-        for (Control control : fComposite.getChildren()) {\r
-            control.dispose();\r
-        }\r
-        \r
-        if (node instanceof TmfFilterNode) {\r
-            new FilterNodeComposite(fComposite, (TmfFilterNode) node);\r
-        } else if (node instanceof TmfFilterEventTypeNode) {\r
-            new FilterEventTypeNodeComposite(fComposite, (TmfFilterEventTypeNode) node);\r
-        } else if (node instanceof TmfFilterAndNode) {\r
-            new FilterAndNodeComposite(fComposite, (TmfFilterAndNode) node);\r
-        } else if (node instanceof TmfFilterOrNode) {\r
-            new FilterOrNodeComposite(fComposite, (TmfFilterOrNode) node);\r
-        } else if (node instanceof TmfFilterContainsNode) {\r
-            new FilterContainsNodeComposite(fComposite, (TmfFilterContainsNode) node);\r
-        } else if (node instanceof TmfFilterEqualsNode) {\r
-            new FilterEqualsNodeComposite(fComposite, (TmfFilterEqualsNode) node);\r
-        } else if (node instanceof TmfFilterMatchesNode) {\r
-            new FilterMatchesNodeComposite(fComposite, (TmfFilterMatchesNode) node);\r
-        } else if (node instanceof TmfFilterCompareNode) {\r
-            new FilterCompareNodeComposite(fComposite, (TmfFilterCompareNode) node);\r
-        } else {\r
-            new FilterBaseNodeComposite(fComposite);\r
-        }\r
-        fComposite.layout();\r
-    }\r
-    \r
-    /**\r
-     * Highlight the provided tree items\r
-     */\r
-    private void highlightTreeItems(TreeItem[] items) {\r
-        resetTreeItems(fViewer.getTree().getItems());\r
-        for (TreeItem item : items) {\r
-            item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));\r
-        }\r
-\r
-    }\r
-    \r
-    /**\r
-     * Reset the provided tree items (remove highlight)\r
-     */\r
-    private void resetTreeItems(TreeItem[] items) {\r
-        for (TreeItem item : items) {\r
-            item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r
-            resetTreeItems(item.getItems());\r
-        }\r
-    }\r
-    \r
-    public void setInput(ITmfFilterTreeNode root) {\r
-        fViewer.setInput(root);\r
-        fViewer.expandAll();\r
-        \r
-        updateFilterNodeComposite(null);\r
-    }\r
-    \r
-    public ITmfFilterTreeNode getInput() {\r
-        return (ITmfFilterTreeNode) fViewer.getInput();\r
-    }\r
-    \r
-    public void refresh() {\r
-        fViewer.refresh();\r
-    }\r
-\r
-    public void setSelection(ITmfFilterTreeNode node, boolean reveal) {\r
-        fViewer.setSelection(new StructuredSelection(node), reveal);\r
-    }\r
-\r
-    public void setSelection(ITmfFilterTreeNode node) {\r
-        fViewer.setSelection(new StructuredSelection(node));\r
-    }\r
-    \r
-    public ITmfFilterTreeNode getSelection() {\r
-        final ISelection selection = fViewer.getSelection();\r
-        ITmfFilterTreeNode filterTreeNode = null;\r
-        if (selection instanceof StructuredSelection) {\r
-            Object element = ((StructuredSelection) selection).getFirstElement();\r
-            if (element instanceof ITmfFilterTreeNode) {\r
-                filterTreeNode = (ITmfFilterTreeNode) element;\r
-            }\r
-        }\r
-\r
-        final ITmfFilterTreeNode selectedNode = filterTreeNode;\r
-        return selectedNode;\r
-    }\r
-    \r
-    public void addSelectionChangedListener(ISelectionChangedListener listener) {\r
-        fViewer.addSelectionChangedListener(listener);\r
-    }\r
-    \r
-    public void removeSelectionChangedListener(ISelectionChangedListener listener) {\r
-        fViewer.removeSelectionChangedListener(listener);\r
-    }\r
-    \r
-    private class FilterBaseNodeComposite extends Composite {\r
-        \r
-        FilterBaseNodeComposite(Composite parent) {\r
-            super(parent, SWT.NONE);\r
-            setLayout(new GridLayout(2, false));\r
-            setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-            setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-        }\r
-        \r
-        protected String[] getFieldsList(ITmfFilterTreeNode node) {\r
-            ArrayList<String> fieldsList = new ArrayList<String>();\r
-            while (node != null) {\r
-                if (node instanceof TmfFilterEventTypeNode) {\r
-                    TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) node;\r
-                    for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
-                        if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(eventTypeNode.getEventType())) {\r
-                            try {\r
-                                ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);\r
-                                ITmfEventType eventType = event.getType();\r
-                                if (eventType != null) {\r
-                                    for (String field : eventType.getRootField().getFieldNames()) {\r
-                                        fieldsList.add(field);\r
-                                    }\r
-                                }\r
-                            } catch (CoreException e) {\r
-                            }\r
-                            if (fieldsList.size() == 0) {\r
-                                fieldsList.add(ITmfEvent.EVENT_FIELD_TIMESTAMP);\r
-                                fieldsList.add(ITmfEvent.EVENT_FIELD_SOURCE);\r
-                                fieldsList.add(ITmfEvent.EVENT_FIELD_TYPE);\r
-                                fieldsList.add(ITmfEvent.EVENT_FIELD_REFERENCE);\r
-                                fieldsList.add(ITmfEvent.EVENT_FIELD_CONTENT);\r
-                            }\r
-                            return fieldsList.toArray(new String[0]);\r
-                        }\r
-                    }\r
-                    if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) {\r
-                        for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                            if (eventTypeNode.getEventType().equals(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$\r
-                                for (OutputColumn output : def.outputs) {\r
-                                    fieldsList.add(output.name);\r
-                                }\r
-                                return fieldsList.toArray(new String[0]);\r
-                            }\r
-                        }\r
-                    }\r
-                    if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) {\r
-                        for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                            if (eventTypeNode.getEventType().equals(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$\r
-                                for (OutputColumn output : def.outputs) {\r
-                                    fieldsList.add(output.name);\r
-                                }\r
-                                return fieldsList.toArray(new String[0]);\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-                node = node.getParent();\r
-            }\r
-\r
-            fieldsList.add(Messages.FilterViewer_CommonCategory);\r
-            fieldsList.add(ITmfEvent.EVENT_FIELD_TIMESTAMP);\r
-            fieldsList.add(ITmfEvent.EVENT_FIELD_SOURCE);\r
-            fieldsList.add(ITmfEvent.EVENT_FIELD_TYPE);\r
-            fieldsList.add(ITmfEvent.EVENT_FIELD_REFERENCE);\r
-            fieldsList.add(ITmfEvent.EVENT_FIELD_CONTENT);\r
-            fieldsList.add(""); //$NON-NLS-1$\r
-\r
-            for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
-                try {\r
-                    ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);\r
-                    ITmfEventType eventType = event.getType();\r
-                    if (eventType != null && eventType.getFieldNames().length > 0) {\r
-                        fieldsList.add("[" + TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)) + //$NON-NLS-1$\r
-                                " : " + ce.getAttribute(TmfTraceType.NAME_ATTR) + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
-                        for (String field : eventType.getFieldNames()) {\r
-                            fieldsList.add(field);\r
-                        }\r
-                        fieldsList.add(""); //$NON-NLS-1$\r
-                    }\r
-                } catch (CoreException e) {\r
-                }\r
-            }\r
-            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                if (def.outputs.size() > 0) {\r
-                    fieldsList.add("[" + CUSTOM_TXT_CATEGORY + //$NON-NLS-1$\r
-                            " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
-                    for (OutputColumn output : def.outputs) {\r
-                        fieldsList.add(output.name);\r
-                    }\r
-                    fieldsList.add(""); //$NON-NLS-1$\r
-                }\r
-            }\r
-            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                if (def.outputs.size() > 0) {\r
-                    fieldsList.add("[" + CUSTOM_XML_CATEGORY + //$NON-NLS-1$\r
-                            " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
-                    for (OutputColumn output : def.outputs) {\r
-                        fieldsList.add(output.name);\r
-                    }\r
-                    fieldsList.add(""); //$NON-NLS-1$\r
-                }\r
-            }\r
-            return fieldsList.toArray(new String[0]);\r
-        }\r
-    }\r
-\r
-    private class FilterNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterNode fNode;\r
-        Text fNameText;\r
-        \r
-        FilterNodeComposite(Composite parent, TmfFilterNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NameLabel);\r
-            \r
-            fNameText = new Text(this, SWT.BORDER);\r
-            fNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            if (node.getFilterName() != null && node.getFilterName().length() > 0) {\r
-                fNameText.setText(node.getFilterName());\r
-            } else {\r
-                fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                fNameText.setText(Messages.FilterViewer_FilterNameHint);\r
-            }\r
-            fNameText.addFocusListener(new FocusListener() {\r
-                @Override\r
-                public void focusLost(FocusEvent e) {\r
-                    if (fNode.getFilterName() == null || fNode.getFilterName().length() == 0) {\r
-                        fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                        fNameText.setText(Messages.FilterViewer_FilterNameHint);\r
-                    }\r
-                }\r
-                @Override\r
-                public void focusGained(FocusEvent e) {\r
-                    if (fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fNameText.setText(""); //$NON-NLS-1$\r
-                    }\r
-                    fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r
-                }\r
-            });\r
-            fNameText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    if (! fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fNode.setFilterName(fNameText.getText());\r
-                        fViewer.refresh(fNode);\r
-                    }\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-    private class FilterEventTypeNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterEventTypeNode fNode;\r
-        Combo fTypeCombo;\r
-        Map<String, Object> fEventsTypeMap;\r
-        \r
-        FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            fEventsTypeMap = getEventsTypeMap();\r
-\r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_TypeLabel);\r
-            \r
-            fTypeCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            fTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            fTypeCombo.setItems(fEventsTypeMap.keySet().toArray(new String[0]));\r
-            if (fNode.getEventType() != null) {\r
-                for (Entry <String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) {\r
-                    Object value = eventTypeEntry.getValue();\r
-                    if (value instanceof IConfigurationElement) {\r
-                        IConfigurationElement ce = (IConfigurationElement) value;\r
-                        if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(fNode.getEventType())) {\r
-                            fTypeCombo.setText(eventTypeEntry.getKey());\r
-                        }\r
-                    } else if (value instanceof CustomTxtTraceDefinition) {\r
-                        CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value;\r
-                        String eventType = CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$\r
-                        if (eventType.equals(fNode.getEventType())) {\r
-                            fTypeCombo.setText(eventTypeEntry.getKey());\r
-                        }\r
-                    } else if (value instanceof CustomXmlTraceDefinition) {\r
-                        CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value;\r
-                        String eventType = CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$\r
-                        if (eventType.equals(fNode.getEventType())) {\r
-                            fTypeCombo.setText(eventTypeEntry.getKey());\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            fTypeCombo.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    for (Entry <String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) {\r
-                        if (eventTypeEntry.getKey().equals(fTypeCombo.getText())) {\r
-                            Object value = eventTypeEntry.getValue();\r
-                            if (value instanceof IConfigurationElement) {\r
-                                IConfigurationElement ce = (IConfigurationElement) value;\r
-                                fNode.setEventType(ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR));\r
-                                fNode.setName(ce.getAttribute(TmfTraceType.NAME_ATTR));\r
-                            } else if (value instanceof CustomTxtTraceDefinition) {\r
-                                CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value;\r
-                                fNode.setEventType(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$\r
-                                fNode.setName(def.definitionName);\r
-                            } else if (value instanceof CustomXmlTraceDefinition) {\r
-                                CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value;\r
-                                fNode.setEventType(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$\r
-                                fNode.setName(def.definitionName);\r
-                            }\r
-                            fViewer.refresh(fNode);\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-            });\r
-        }\r
-\r
-        protected Map<String, Object> getEventsTypeMap() {\r
-            Map<String, Object> eventsTypeMap = new LinkedHashMap<String, Object>();\r
-            for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
-                String categoryName = TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR));\r
-                String text = categoryName + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR); //$NON-NLS-1$\r
-                eventsTypeMap.put(text, ce);\r
-            }\r
-            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                String text = CUSTOM_TXT_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$\r
-                eventsTypeMap.put(text, def);\r
-            }\r
-            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                String text = CUSTOM_XML_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$\r
-                eventsTypeMap.put(text, def);\r
-            }\r
-            return eventsTypeMap;\r
-        }\r
-    }\r
-    \r
-    private class FilterAndNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterAndNode fNode;\r
-        Button fNotButton;\r
-        \r
-        FilterAndNodeComposite(Composite parent, TmfFilterAndNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NotLabel);\r
-            \r
-            fNotButton = new Button(this, SWT.CHECK);\r
-            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNotButton.setSelection(fNode.isNot());\r
-            fNotButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setNot(fNotButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-    private class FilterOrNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterOrNode fNode;\r
-        Button fNotButton;\r
-        \r
-        FilterOrNodeComposite(Composite parent, TmfFilterOrNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NotLabel);\r
-            \r
-            fNotButton = new Button(this, SWT.CHECK);\r
-            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNotButton.setSelection(fNode.isNot());\r
-            fNotButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setNot(fNotButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-        }\r
-    }\r
-    \r
-    private class FilterContainsNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterContainsNode fNode;\r
-        Button fNotButton;\r
-        Combo fFieldCombo;\r
-        Text fValueText;\r
-        Button fIgnoreCaseButton;\r
-        \r
-        FilterContainsNodeComposite(Composite parent, TmfFilterContainsNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NotLabel);\r
-            \r
-            fNotButton = new Button(this, SWT.CHECK);\r
-            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNotButton.setSelection(fNode.isNot());\r
-            fNotButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setNot(fNotButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_FieldLabel);\r
-            \r
-            fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r
-            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            fFieldCombo.setItems(getFieldsList(fNode));\r
-            if (fNode.getField() != null) {\r
-                fFieldCombo.setText(fNode.getField());\r
-            }\r
-            fFieldCombo.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    fNode.setField(fFieldCombo.getText());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_ValueLabel);\r
-            \r
-            fValueText = new Text(this, SWT.BORDER);\r
-            fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            if (node.getValue() != null && node.getValue().length() > 0) {\r
-                fValueText.setText(node.getValue());\r
-            } else {\r
-                fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                fValueText.setText(Messages.FilterViewer_ValueHint);\r
-            }\r
-            fValueText.addFocusListener(new FocusListener() {\r
-                @Override\r
-                public void focusLost(FocusEvent e) {\r
-                    if (fNode.getValue() == null || fNode.getValue().length() == 0) {\r
-                        fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                        fValueText.setText(Messages.FilterViewer_ValueHint);\r
-                    }\r
-                }\r
-                @Override\r
-                public void focusGained(FocusEvent e) {\r
-                    if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fValueText.setText(""); //$NON-NLS-1$\r
-                    }\r
-                    fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r
-                }\r
-            });\r
-            fValueText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fNode.setValue(fValueText.getText());\r
-                        fViewer.refresh(fNode);\r
-                    }\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            \r
-            fIgnoreCaseButton = new Button(this, SWT.CHECK);\r
-            fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());\r
-            fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);\r
-            fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setIgnoreCase(fIgnoreCaseButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-    private class FilterEqualsNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterEqualsNode fNode;\r
-        Button fNotButton;\r
-        Combo fFieldCombo;\r
-        Text fValueText;\r
-        Button fIgnoreCaseButton;\r
-        \r
-        FilterEqualsNodeComposite(Composite parent, TmfFilterEqualsNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NotLabel);\r
-            \r
-            fNotButton = new Button(this, SWT.CHECK);\r
-            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNotButton.setSelection(fNode.isNot());\r
-            fNotButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setNot(fNotButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_FieldLabel);\r
-            \r
-            fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r
-            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            fFieldCombo.setItems(getFieldsList(fNode));\r
-            if (fNode.getField() != null) {\r
-                fFieldCombo.setText(fNode.getField());\r
-            }\r
-            fFieldCombo.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    fNode.setField(fFieldCombo.getText());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_ValueLabel);\r
-            \r
-            fValueText = new Text(this, SWT.BORDER);\r
-            fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            if (node.getValue() != null && node.getValue().length() > 0) {\r
-                fValueText.setText(node.getValue());\r
-            } else {\r
-                fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                fValueText.setText(Messages.FilterViewer_ValueHint);\r
-            }\r
-            fValueText.addFocusListener(new FocusListener() {\r
-                @Override\r
-                public void focusLost(FocusEvent e) {\r
-                    if (fNode.getValue() == null || fNode.getValue().length() == 0) {\r
-                        fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                        fValueText.setText(Messages.FilterViewer_ValueHint);\r
-                    }\r
-                }\r
-                @Override\r
-                public void focusGained(FocusEvent e) {\r
-                    if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fValueText.setText(""); //$NON-NLS-1$\r
-                    }\r
-                    fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r
-                }\r
-            });\r
-            fValueText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fNode.setValue(fValueText.getText());\r
-                        fViewer.refresh(fNode);\r
-                    }\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            \r
-            fIgnoreCaseButton = new Button(this, SWT.CHECK);\r
-            fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());\r
-            fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);\r
-            fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setIgnoreCase(fIgnoreCaseButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-    private class FilterMatchesNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterMatchesNode fNode;\r
-        Button fNotButton;\r
-        Combo fFieldCombo;\r
-        Text fRegexText;\r
-        \r
-        FilterMatchesNodeComposite(Composite parent, TmfFilterMatchesNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NotLabel);\r
-            \r
-            fNotButton = new Button(this, SWT.CHECK);\r
-            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNotButton.setSelection(fNode.isNot());\r
-            fNotButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setNot(fNotButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_FieldLabel);\r
-            \r
-            fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r
-            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            fFieldCombo.setItems(getFieldsList(fNode));\r
-            if (fNode.getField() != null) {\r
-                fFieldCombo.setText(fNode.getField());\r
-            }\r
-            fFieldCombo.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    fNode.setField(fFieldCombo.getText());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_RegexLabel);\r
-            \r
-            fRegexText = new Text(this, SWT.BORDER);\r
-            fRegexText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            if (node.getRegex() != null && node.getRegex().length() > 0) {\r
-                fRegexText.setText(node.getRegex());\r
-            } else {\r
-                fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                fRegexText.setText(Messages.FilterViewer_RegexHint);\r
-            }\r
-            fRegexText.addFocusListener(new FocusListener() {\r
-                @Override\r
-                public void focusLost(FocusEvent e) {\r
-                    if (fNode.getRegex() == null || fNode.getRegex().length() == 0) {\r
-                        fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                        fRegexText.setText(Messages.FilterViewer_RegexHint);\r
-                    }\r
-                }\r
-                @Override\r
-                public void focusGained(FocusEvent e) {\r
-                    if (fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fRegexText.setText(""); //$NON-NLS-1$\r
-                    }\r
-                    fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r
-                }\r
-            });\r
-            fRegexText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    if (! fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fNode.setRegex(fRegexText.getText());\r
-                        fViewer.refresh(fNode);\r
-                    }\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-    private class FilterCompareNodeComposite extends FilterBaseNodeComposite {\r
-        TmfFilterCompareNode fNode;\r
-        Button fNotButton;\r
-        Combo fFieldCombo;\r
-        Text fValueText;\r
-        Button fLTButton;\r
-        Button fEQButton;\r
-        Button fGTButton;\r
-        Button fNumButton;\r
-        Button fAlphaButton;\r
-        Button fTimestampButton;\r
-        \r
-        FilterCompareNodeComposite(Composite parent, TmfFilterCompareNode node) {\r
-            super(parent);\r
-            fNode = node;\r
-            \r
-            Label label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_NotLabel);\r
-            \r
-            fNotButton = new Button(this, SWT.CHECK);\r
-            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNotButton.setSelection(fNode.isNot());\r
-            fNotButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    fNode.setNot(fNotButton.getSelection());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_FieldLabel);\r
-            \r
-            fFieldCombo = new Combo(this, SWT.DROP_DOWN);\r
-            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            fFieldCombo.setItems(getFieldsList(fNode));\r
-            if (fNode.getField() != null) {\r
-                fFieldCombo.setText(fNode.getField());\r
-            }\r
-            fFieldCombo.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    fNode.setField(fFieldCombo.getText());\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_ResultLabel);\r
-            \r
-            Composite resultGroup = new Composite(this, SWT.NONE);\r
-            GridLayout rggl = new GridLayout(3, true);\r
-            rggl.marginHeight = 0;\r
-            rggl.marginWidth = 0;\r
-            resultGroup.setLayout(rggl);\r
-            resultGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            \r
-            fLTButton = new Button(resultGroup, SWT.RADIO);\r
-            fLTButton.setSelection(fNode.getResult() < 0);\r
-            fLTButton.setText("<"); //$NON-NLS-1$\r
-            fLTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fLTButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    if (fLTButton.getSelection()) {\r
-                        fNode.setResult(-1);\r
-                    }\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            fEQButton = new Button(resultGroup, SWT.RADIO);\r
-            fEQButton.setSelection(fNode.getResult() == 0);\r
-            fEQButton.setText("="); //$NON-NLS-1$\r
-            fEQButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fEQButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    if (fEQButton.getSelection()) {\r
-                        fNode.setResult(0);\r
-                    }\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            fGTButton = new Button(resultGroup, SWT.RADIO);\r
-            fGTButton.setSelection(fNode.getResult() > 0);\r
-            fGTButton.setText(">"); //$NON-NLS-1$\r
-            fGTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fGTButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    if (fGTButton.getSelection()) {\r
-                        fNode.setResult(1);\r
-                    }\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_TypeLabel);\r
-            \r
-            Composite typeGroup = new Composite(this, SWT.NONE);\r
-            GridLayout tggl = new GridLayout(3, false);\r
-            tggl.marginHeight = 0;\r
-            tggl.marginWidth = 0;\r
-            typeGroup.setLayout(tggl);\r
-            typeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            \r
-            fNumButton = new Button(typeGroup, SWT.RADIO);\r
-            fNumButton.setSelection(fNode.getType() == Type.NUM);\r
-            fNumButton.setText(Messages.FilterViewer_NumButtonText);\r
-            fNumButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fNumButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    if (fNumButton.getSelection()) {\r
-                        fNode.setType(Type.NUM);\r
-                    }\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            fAlphaButton = new Button(typeGroup, SWT.RADIO);\r
-            fAlphaButton.setSelection(fNode.getType() == Type.ALPHA);\r
-            fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText);\r
-            fAlphaButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fAlphaButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    if (fAlphaButton.getSelection()) {\r
-                        fNode.setType(Type.ALPHA);\r
-                    }\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            fTimestampButton = new Button(typeGroup, SWT.RADIO);\r
-            fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP);\r
-            fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText);\r
-            fTimestampButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            fTimestampButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    if (fTimestampButton.getSelection()) {\r
-                        fNode.setType(Type.TIMESTAMP);\r
-                    }\r
-                    fViewer.refresh(fNode);\r
-                }\r
-            });\r
-            \r
-            label = new Label(this, SWT.NONE);\r
-            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\r
-            label.setText(Messages.FilterViewer_ValueLabel);\r
-            \r
-            fValueText = new Text(this, SWT.BORDER);\r
-            fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            if (node.getValue() != null && node.getValue().length() > 0) {\r
-                fValueText.setText(node.getValue());\r
-            } else {\r
-                fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                fValueText.setText(Messages.FilterViewer_ValueHint);\r
-            }\r
-            fValueText.addFocusListener(new FocusListener() {\r
-                @Override\r
-                public void focusLost(FocusEvent e) {\r
-                    if (fNode.getValue() == null || fNode.getValue().length() == 0) {\r
-                        fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));\r
-                        fValueText.setText(Messages.FilterViewer_ValueHint);\r
-                    }\r
-                }\r
-                @Override\r
-                public void focusGained(FocusEvent e) {\r
-                    if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fValueText.setText(""); //$NON-NLS-1$\r
-                    }\r
-                    fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));\r
-                }\r
-            });\r
-            fValueText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {\r
-                        fNode.setValue(fValueText.getText());\r
-                        fViewer.refresh(fNode);\r
-                    }\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.filter;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtEvent;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlEvent;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterCompareNode.Type;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterContainsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEqualsNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterEventTypeNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TreeItem;
+
+class FilterViewer extends Composite {
+
+    private static final String CUSTOM_TXT_CATEGORY = "Custom Text"; //$NON-NLS-1$
+    private static final String CUSTOM_XML_CATEGORY = "Custom XML"; //$NON-NLS-1$
+
+    private TreeViewer fViewer;
+    private Composite fComposite;
+    
+    public FilterViewer(Composite parent, int style) {
+        super(parent, style);
+
+        setLayout(new FillLayout());
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        setLayoutData(gd);
+        
+        final SashForm sash = new SashForm(this, SWT.HORIZONTAL);
+
+        // Create the tree viewer to display the filter tree
+        fViewer = new TreeViewer(sash, SWT.NONE);
+        fViewer.setContentProvider(new FilterTreeContentProvider());
+        fViewer.setLabelProvider(new FilterTreeLabelProvider());
+        fViewer.setInput(new TmfFilterRootNode());
+        
+        // Create the empty filter node properties panel
+        fComposite = new Composite(sash, SWT.NONE);
+        GridLayout gl = new GridLayout();
+        gl.marginHeight = 0;
+        gl.marginWidth = 0;
+        fComposite.setLayout(gl);
+
+        createContextMenu();
+        
+        fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+            @Override
+            public void selectionChanged(SelectionChangedEvent event) {
+                if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
+                    // Update the filter node properties panel to the selection
+                    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+                    ITmfFilterTreeNode node = (ITmfFilterTreeNode) selection.getFirstElement();
+                    updateFilterNodeComposite(node);
+                    // Highlight the selection's children
+                    highlightTreeItems(fViewer.getTree().getSelection()[0].getItems());
+                } else {
+                    updateFilterNodeComposite(null);
+                }
+            }
+        });
+
+        fViewer.getTree().addPaintListener(new PaintListener() {
+            @Override
+            public void paintControl(PaintEvent e) {
+                TmfFilterTreeNode root = (TmfFilterTreeNode) fViewer.getInput();
+                if (root == null || root.getChildrenCount() == 0) {
+                    e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
+                    e.gc.drawText(Messages.FilterViewer_EmptyTreeHintText, 5, 0);
+                }
+            }
+        });
+    }
+    
+    /**
+     * Create the context menu for the tree viewer
+     */
+    private void createContextMenu() {
+        // Adds root context menu
+        MenuManager menuManager = new MenuManager();
+        menuManager.setRemoveAllWhenShown(true);
+        menuManager.addMenuListener(new IMenuListener() {
+            @Override
+            public void menuAboutToShow(IMenuManager manager) {
+                fillContextMenu(manager);
+            }
+        });
+
+        // Context
+        Menu contextMenu = menuManager.createContextMenu(fViewer.getTree());
+
+        // Publish it
+        fViewer.getTree().setMenu(contextMenu);
+    }
+    
+    /**
+     * Fill the context menu for the tree viewer
+     */
+    protected void fillContextMenu(IMenuManager manager) {
+        final ISelection selection = fViewer.getSelection();
+        ITmfFilterTreeNode filterTreeNode = null;
+        if (selection instanceof StructuredSelection) {
+            Object element = ((StructuredSelection) selection).getFirstElement();
+            if (element instanceof ITmfFilterTreeNode) {
+                filterTreeNode = (ITmfFilterTreeNode) element;
+            }
+        }
+
+        final ITmfFilterTreeNode selectedNode = filterTreeNode;
+        
+        if (selectedNode != null) {
+            
+            fillContextMenuForNode(selectedNode, manager);
+            
+            if (selectedNode.getValidChildren().size() > 0) {
+                manager.add(new Separator());
+            }
+
+            Action deleteAction = new Action() {
+                @Override
+                public void run() {
+                    selectedNode.remove();
+                    fViewer.refresh();
+                }
+            };
+            deleteAction.setText(Messages.FilterViewer_DeleteActionText);
+            manager.add(deleteAction);
+            
+            manager.add(new Separator());
+        }
+
+        if (fViewer.getInput() instanceof TmfFilterRootNode || selectedNode == null) {
+            final ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput();
+            
+            fillContextMenuForNode(root, manager);
+        }
+    }
+    
+    /**
+     * Fill the context menu with the valid children of the provided node
+     */
+    protected void fillContextMenuForNode(final ITmfFilterTreeNode node, IMenuManager manager) {
+        for (final String child : node.getValidChildren()) {
+            final Action action = new Action() {
+                @Override
+                public void run() {
+                    ITmfFilterTreeNode newNode = null;
+                    if (TmfFilterNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterNode(node, ""); //$NON-NLS-1$
+                    } else if (TmfFilterEventTypeNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterEventTypeNode(node);
+                    } else if (TmfFilterAndNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterAndNode(node);
+                    } else if (TmfFilterOrNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterOrNode(node);
+                    } else if (TmfFilterContainsNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterContainsNode(node);
+                    } else if (TmfFilterEqualsNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterEqualsNode(node);
+                    } else if (TmfFilterMatchesNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterMatchesNode(node);
+                    } else if (TmfFilterCompareNode.NODE_NAME.equals(child)) {
+                        newNode = new TmfFilterCompareNode(node);
+                    }
+                    if (newNode != null) {
+                        fViewer.refresh();
+                        fViewer.setSelection(new StructuredSelection(newNode), true);
+                    }
+                }
+            };
+            if (TmfFilterNode.NODE_NAME.equals(child)) {
+                action.setText(Messages.FilterViewer_NewPrefix + " " + child); //$NON-NLS-1$
+            } else {
+                action.setText(child);
+            }
+            manager.add(action);
+        }
+    }
+    
+    /**
+     * Create the appropriate filter node properties composite
+     */
+    private void updateFilterNodeComposite(ITmfFilterTreeNode node) {
+        for (Control control : fComposite.getChildren()) {
+            control.dispose();
+        }
+        
+        if (node instanceof TmfFilterNode) {
+            new FilterNodeComposite(fComposite, (TmfFilterNode) node);
+        } else if (node instanceof TmfFilterEventTypeNode) {
+            new FilterEventTypeNodeComposite(fComposite, (TmfFilterEventTypeNode) node);
+        } else if (node instanceof TmfFilterAndNode) {
+            new FilterAndNodeComposite(fComposite, (TmfFilterAndNode) node);
+        } else if (node instanceof TmfFilterOrNode) {
+            new FilterOrNodeComposite(fComposite, (TmfFilterOrNode) node);
+        } else if (node instanceof TmfFilterContainsNode) {
+            new FilterContainsNodeComposite(fComposite, (TmfFilterContainsNode) node);
+        } else if (node instanceof TmfFilterEqualsNode) {
+            new FilterEqualsNodeComposite(fComposite, (TmfFilterEqualsNode) node);
+        } else if (node instanceof TmfFilterMatchesNode) {
+            new FilterMatchesNodeComposite(fComposite, (TmfFilterMatchesNode) node);
+        } else if (node instanceof TmfFilterCompareNode) {
+            new FilterCompareNodeComposite(fComposite, (TmfFilterCompareNode) node);
+        } else {
+            new FilterBaseNodeComposite(fComposite);
+        }
+        fComposite.layout();
+    }
+    
+    /**
+     * Highlight the provided tree items
+     */
+    private void highlightTreeItems(TreeItem[] items) {
+        resetTreeItems(fViewer.getTree().getItems());
+        for (TreeItem item : items) {
+            item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
+        }
+
+    }
+    
+    /**
+     * Reset the provided tree items (remove highlight)
+     */
+    private void resetTreeItems(TreeItem[] items) {
+        for (TreeItem item : items) {
+            item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+            resetTreeItems(item.getItems());
+        }
+    }
+    
+    public void setInput(ITmfFilterTreeNode root) {
+        fViewer.setInput(root);
+        fViewer.expandAll();
+        
+        updateFilterNodeComposite(null);
+    }
+    
+    public ITmfFilterTreeNode getInput() {
+        return (ITmfFilterTreeNode) fViewer.getInput();
+    }
+    
+    public void refresh() {
+        fViewer.refresh();
+    }
+
+    public void setSelection(ITmfFilterTreeNode node, boolean reveal) {
+        fViewer.setSelection(new StructuredSelection(node), reveal);
+    }
+
+    public void setSelection(ITmfFilterTreeNode node) {
+        fViewer.setSelection(new StructuredSelection(node));
+    }
+    
+    public ITmfFilterTreeNode getSelection() {
+        final ISelection selection = fViewer.getSelection();
+        ITmfFilterTreeNode filterTreeNode = null;
+        if (selection instanceof StructuredSelection) {
+            Object element = ((StructuredSelection) selection).getFirstElement();
+            if (element instanceof ITmfFilterTreeNode) {
+                filterTreeNode = (ITmfFilterTreeNode) element;
+            }
+        }
+
+        final ITmfFilterTreeNode selectedNode = filterTreeNode;
+        return selectedNode;
+    }
+    
+    public void addSelectionChangedListener(ISelectionChangedListener listener) {
+        fViewer.addSelectionChangedListener(listener);
+    }
+    
+    public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+        fViewer.removeSelectionChangedListener(listener);
+    }
+    
+    private class FilterBaseNodeComposite extends Composite {
+        
+        FilterBaseNodeComposite(Composite parent) {
+            super(parent, SWT.NONE);
+            setLayout(new GridLayout(2, false));
+            setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+            setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+        }
+        
+        protected String[] getFieldsList(ITmfFilterTreeNode node) {
+            ArrayList<String> fieldsList = new ArrayList<String>();
+            while (node != null) {
+                if (node instanceof TmfFilterEventTypeNode) {
+                    TmfFilterEventTypeNode eventTypeNode = (TmfFilterEventTypeNode) node;
+                    for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {
+                        if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(eventTypeNode.getEventType())) {
+                            try {
+                                ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);
+                                ITmfEventType eventType = event.getType();
+                                if (eventType != null) {
+                                    for (String field : eventType.getRootField().getFieldNames()) {
+                                        fieldsList.add(field);
+                                    }
+                                }
+                            } catch (CoreException e) {
+                            }
+                            if (fieldsList.size() == 0) {
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_TIMESTAMP);
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_SOURCE);
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_TYPE);
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_REFERENCE);
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_CONTENT);
+                            }
+                            return fieldsList.toArray(new String[0]);
+                        }
+                    }
+                    if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) {
+                        for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+                            if (eventTypeNode.getEventType().equals(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$
+                                for (OutputColumn output : def.outputs) {
+                                    fieldsList.add(output.name);
+                                }
+                                return fieldsList.toArray(new String[0]);
+                            }
+                        }
+                    }
+                    if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) {
+                        for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                            if (eventTypeNode.getEventType().equals(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$
+                                for (OutputColumn output : def.outputs) {
+                                    fieldsList.add(output.name);
+                                }
+                                return fieldsList.toArray(new String[0]);
+                            }
+                        }
+                    }
+                }
+                node = node.getParent();
+            }
+
+            fieldsList.add(Messages.FilterViewer_CommonCategory);
+            fieldsList.add(ITmfEvent.EVENT_FIELD_TIMESTAMP);
+            fieldsList.add(ITmfEvent.EVENT_FIELD_SOURCE);
+            fieldsList.add(ITmfEvent.EVENT_FIELD_TYPE);
+            fieldsList.add(ITmfEvent.EVENT_FIELD_REFERENCE);
+            fieldsList.add(ITmfEvent.EVENT_FIELD_CONTENT);
+            fieldsList.add(""); //$NON-NLS-1$
+
+            for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {
+                try {
+                    ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);
+                    ITmfEventType eventType = event.getType();
+                    if (eventType != null && eventType.getFieldNames().length > 0) {
+                        fieldsList.add("[" + TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)) + //$NON-NLS-1$
+                                " : " + ce.getAttribute(TmfTraceType.NAME_ATTR) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                        for (String field : eventType.getFieldNames()) {
+                            fieldsList.add(field);
+                        }
+                        fieldsList.add(""); //$NON-NLS-1$
+                    }
+                } catch (CoreException e) {
+                }
+            }
+            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+                if (def.outputs.size() > 0) {
+                    fieldsList.add("[" + CUSTOM_TXT_CATEGORY + //$NON-NLS-1$
+                            " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                    for (OutputColumn output : def.outputs) {
+                        fieldsList.add(output.name);
+                    }
+                    fieldsList.add(""); //$NON-NLS-1$
+                }
+            }
+            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                if (def.outputs.size() > 0) {
+                    fieldsList.add("[" + CUSTOM_XML_CATEGORY + //$NON-NLS-1$
+                            " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                    for (OutputColumn output : def.outputs) {
+                        fieldsList.add(output.name);
+                    }
+                    fieldsList.add(""); //$NON-NLS-1$
+                }
+            }
+            return fieldsList.toArray(new String[0]);
+        }
+    }
+
+    private class FilterNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterNode fNode;
+        Text fNameText;
+        
+        FilterNodeComposite(Composite parent, TmfFilterNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NameLabel);
+            
+            fNameText = new Text(this, SWT.BORDER);
+            fNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            if (node.getFilterName() != null && node.getFilterName().length() > 0) {
+                fNameText.setText(node.getFilterName());
+            } else {
+                fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                fNameText.setText(Messages.FilterViewer_FilterNameHint);
+            }
+            fNameText.addFocusListener(new FocusListener() {
+                @Override
+                public void focusLost(FocusEvent e) {
+                    if (fNode.getFilterName() == null || fNode.getFilterName().length() == 0) {
+                        fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                        fNameText.setText(Messages.FilterViewer_FilterNameHint);
+                    }
+                }
+                @Override
+                public void focusGained(FocusEvent e) {
+                    if (fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fNameText.setText(""); //$NON-NLS-1$
+                    }
+                    fNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+                }
+            });
+            fNameText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    if (! fNameText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fNode.setFilterName(fNameText.getText());
+                        fViewer.refresh(fNode);
+                    }
+                }
+            });
+        }
+    }
+
+    private class FilterEventTypeNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterEventTypeNode fNode;
+        Combo fTypeCombo;
+        Map<String, Object> fEventsTypeMap;
+        
+        FilterEventTypeNodeComposite(Composite parent, TmfFilterEventTypeNode node) {
+            super(parent);
+            fNode = node;
+            fEventsTypeMap = getEventsTypeMap();
+
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_TypeLabel);
+            
+            fTypeCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
+            fTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            fTypeCombo.setItems(fEventsTypeMap.keySet().toArray(new String[0]));
+            if (fNode.getEventType() != null) {
+                for (Entry <String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) {
+                    Object value = eventTypeEntry.getValue();
+                    if (value instanceof IConfigurationElement) {
+                        IConfigurationElement ce = (IConfigurationElement) value;
+                        if (ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR).equals(fNode.getEventType())) {
+                            fTypeCombo.setText(eventTypeEntry.getKey());
+                        }
+                    } else if (value instanceof CustomTxtTraceDefinition) {
+                        CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value;
+                        String eventType = CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
+                        if (eventType.equals(fNode.getEventType())) {
+                            fTypeCombo.setText(eventTypeEntry.getKey());
+                        }
+                    } else if (value instanceof CustomXmlTraceDefinition) {
+                        CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value;
+                        String eventType = CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
+                        if (eventType.equals(fNode.getEventType())) {
+                            fTypeCombo.setText(eventTypeEntry.getKey());
+                        }
+                    }
+                }
+            }
+            fTypeCombo.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    for (Entry <String, Object> eventTypeEntry : fEventsTypeMap.entrySet()) {
+                        if (eventTypeEntry.getKey().equals(fTypeCombo.getText())) {
+                            Object value = eventTypeEntry.getValue();
+                            if (value instanceof IConfigurationElement) {
+                                IConfigurationElement ce = (IConfigurationElement) value;
+                                fNode.setEventType(ce.getAttribute(TmfTraceType.EVENT_TYPE_ATTR));
+                                fNode.setName(ce.getAttribute(TmfTraceType.NAME_ATTR));
+                            } else if (value instanceof CustomTxtTraceDefinition) {
+                                CustomTxtTraceDefinition def = (CustomTxtTraceDefinition) value;
+                                fNode.setEventType(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$
+                                fNode.setName(def.definitionName);
+                            } else if (value instanceof CustomXmlTraceDefinition) {
+                                CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) value;
+                                fNode.setEventType(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName); //$NON-NLS-1$
+                                fNode.setName(def.definitionName);
+                            }
+                            fViewer.refresh(fNode);
+                            break;
+                        }
+                    }
+                }
+            });
+        }
+
+        protected Map<String, Object> getEventsTypeMap() {
+            Map<String, Object> eventsTypeMap = new LinkedHashMap<String, Object>();
+            for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {
+                String categoryName = TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR));
+                String text = categoryName + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR); //$NON-NLS-1$
+                eventsTypeMap.put(text, ce);
+            }
+            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+                String text = CUSTOM_TXT_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$
+                eventsTypeMap.put(text, def);
+            }
+            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                String text = CUSTOM_XML_CATEGORY + " : " + def.definitionName; //$NON-NLS-1$
+                eventsTypeMap.put(text, def);
+            }
+            return eventsTypeMap;
+        }
+    }
+    
+    private class FilterAndNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterAndNode fNode;
+        Button fNotButton;
+        
+        FilterAndNodeComposite(Composite parent, TmfFilterAndNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NotLabel);
+            
+            fNotButton = new Button(this, SWT.CHECK);
+            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNotButton.setSelection(fNode.isNot());
+            fNotButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setNot(fNotButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+        }
+    }
+
+    private class FilterOrNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterOrNode fNode;
+        Button fNotButton;
+        
+        FilterOrNodeComposite(Composite parent, TmfFilterOrNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NotLabel);
+            
+            fNotButton = new Button(this, SWT.CHECK);
+            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNotButton.setSelection(fNode.isNot());
+            fNotButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setNot(fNotButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+        }
+    }
+    
+    private class FilterContainsNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterContainsNode fNode;
+        Button fNotButton;
+        Combo fFieldCombo;
+        Text fValueText;
+        Button fIgnoreCaseButton;
+        
+        FilterContainsNodeComposite(Composite parent, TmfFilterContainsNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NotLabel);
+            
+            fNotButton = new Button(this, SWT.CHECK);
+            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNotButton.setSelection(fNode.isNot());
+            fNotButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setNot(fNotButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_FieldLabel);
+            
+            fFieldCombo = new Combo(this, SWT.DROP_DOWN);
+            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            fFieldCombo.setItems(getFieldsList(fNode));
+            if (fNode.getField() != null) {
+                fFieldCombo.setText(fNode.getField());
+            }
+            fFieldCombo.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    fNode.setField(fFieldCombo.getText());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_ValueLabel);
+            
+            fValueText = new Text(this, SWT.BORDER);
+            fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            if (node.getValue() != null && node.getValue().length() > 0) {
+                fValueText.setText(node.getValue());
+            } else {
+                fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                fValueText.setText(Messages.FilterViewer_ValueHint);
+            }
+            fValueText.addFocusListener(new FocusListener() {
+                @Override
+                public void focusLost(FocusEvent e) {
+                    if (fNode.getValue() == null || fNode.getValue().length() == 0) {
+                        fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                        fValueText.setText(Messages.FilterViewer_ValueHint);
+                    }
+                }
+                @Override
+                public void focusGained(FocusEvent e) {
+                    if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fValueText.setText(""); //$NON-NLS-1$
+                    }
+                    fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+                }
+            });
+            fValueText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fNode.setValue(fValueText.getText());
+                        fViewer.refresh(fNode);
+                    }
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            
+            fIgnoreCaseButton = new Button(this, SWT.CHECK);
+            fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());
+            fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);
+            fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setIgnoreCase(fIgnoreCaseButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+        }
+    }
+
+    private class FilterEqualsNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterEqualsNode fNode;
+        Button fNotButton;
+        Combo fFieldCombo;
+        Text fValueText;
+        Button fIgnoreCaseButton;
+        
+        FilterEqualsNodeComposite(Composite parent, TmfFilterEqualsNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NotLabel);
+            
+            fNotButton = new Button(this, SWT.CHECK);
+            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNotButton.setSelection(fNode.isNot());
+            fNotButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setNot(fNotButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_FieldLabel);
+            
+            fFieldCombo = new Combo(this, SWT.DROP_DOWN);
+            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            fFieldCombo.setItems(getFieldsList(fNode));
+            if (fNode.getField() != null) {
+                fFieldCombo.setText(fNode.getField());
+            }
+            fFieldCombo.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    fNode.setField(fFieldCombo.getText());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_ValueLabel);
+            
+            fValueText = new Text(this, SWT.BORDER);
+            fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            if (node.getValue() != null && node.getValue().length() > 0) {
+                fValueText.setText(node.getValue());
+            } else {
+                fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                fValueText.setText(Messages.FilterViewer_ValueHint);
+            }
+            fValueText.addFocusListener(new FocusListener() {
+                @Override
+                public void focusLost(FocusEvent e) {
+                    if (fNode.getValue() == null || fNode.getValue().length() == 0) {
+                        fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                        fValueText.setText(Messages.FilterViewer_ValueHint);
+                    }
+                }
+                @Override
+                public void focusGained(FocusEvent e) {
+                    if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fValueText.setText(""); //$NON-NLS-1$
+                    }
+                    fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+                }
+            });
+            fValueText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fNode.setValue(fValueText.getText());
+                        fViewer.refresh(fNode);
+                    }
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            
+            fIgnoreCaseButton = new Button(this, SWT.CHECK);
+            fIgnoreCaseButton.setSelection(fNode.isIgnoreCase());
+            fIgnoreCaseButton.setText(Messages.FilterViewer_IgnoreCaseButtonText);
+            fIgnoreCaseButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fIgnoreCaseButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setIgnoreCase(fIgnoreCaseButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+        }
+    }
+
+    private class FilterMatchesNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterMatchesNode fNode;
+        Button fNotButton;
+        Combo fFieldCombo;
+        Text fRegexText;
+        
+        FilterMatchesNodeComposite(Composite parent, TmfFilterMatchesNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NotLabel);
+            
+            fNotButton = new Button(this, SWT.CHECK);
+            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNotButton.setSelection(fNode.isNot());
+            fNotButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setNot(fNotButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_FieldLabel);
+            
+            fFieldCombo = new Combo(this, SWT.DROP_DOWN);
+            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            fFieldCombo.setItems(getFieldsList(fNode));
+            if (fNode.getField() != null) {
+                fFieldCombo.setText(fNode.getField());
+            }
+            fFieldCombo.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    fNode.setField(fFieldCombo.getText());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_RegexLabel);
+            
+            fRegexText = new Text(this, SWT.BORDER);
+            fRegexText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            if (node.getRegex() != null && node.getRegex().length() > 0) {
+                fRegexText.setText(node.getRegex());
+            } else {
+                fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                fRegexText.setText(Messages.FilterViewer_RegexHint);
+            }
+            fRegexText.addFocusListener(new FocusListener() {
+                @Override
+                public void focusLost(FocusEvent e) {
+                    if (fNode.getRegex() == null || fNode.getRegex().length() == 0) {
+                        fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                        fRegexText.setText(Messages.FilterViewer_RegexHint);
+                    }
+                }
+                @Override
+                public void focusGained(FocusEvent e) {
+                    if (fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fRegexText.setText(""); //$NON-NLS-1$
+                    }
+                    fRegexText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+                }
+            });
+            fRegexText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    if (! fRegexText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fNode.setRegex(fRegexText.getText());
+                        fViewer.refresh(fNode);
+                    }
+                }
+            });
+        }
+    }
+
+    private class FilterCompareNodeComposite extends FilterBaseNodeComposite {
+        TmfFilterCompareNode fNode;
+        Button fNotButton;
+        Combo fFieldCombo;
+        Text fValueText;
+        Button fLTButton;
+        Button fEQButton;
+        Button fGTButton;
+        Button fNumButton;
+        Button fAlphaButton;
+        Button fTimestampButton;
+        
+        FilterCompareNodeComposite(Composite parent, TmfFilterCompareNode node) {
+            super(parent);
+            fNode = node;
+            
+            Label label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_NotLabel);
+            
+            fNotButton = new Button(this, SWT.CHECK);
+            fNotButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNotButton.setSelection(fNode.isNot());
+            fNotButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    fNode.setNot(fNotButton.getSelection());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_FieldLabel);
+            
+            fFieldCombo = new Combo(this, SWT.DROP_DOWN);
+            fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            fFieldCombo.setItems(getFieldsList(fNode));
+            if (fNode.getField() != null) {
+                fFieldCombo.setText(fNode.getField());
+            }
+            fFieldCombo.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    fNode.setField(fFieldCombo.getText());
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_ResultLabel);
+            
+            Composite resultGroup = new Composite(this, SWT.NONE);
+            GridLayout rggl = new GridLayout(3, true);
+            rggl.marginHeight = 0;
+            rggl.marginWidth = 0;
+            resultGroup.setLayout(rggl);
+            resultGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            
+            fLTButton = new Button(resultGroup, SWT.RADIO);
+            fLTButton.setSelection(fNode.getResult() < 0);
+            fLTButton.setText("<"); //$NON-NLS-1$
+            fLTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fLTButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    if (fLTButton.getSelection()) {
+                        fNode.setResult(-1);
+                    }
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            fEQButton = new Button(resultGroup, SWT.RADIO);
+            fEQButton.setSelection(fNode.getResult() == 0);
+            fEQButton.setText("="); //$NON-NLS-1$
+            fEQButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fEQButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    if (fEQButton.getSelection()) {
+                        fNode.setResult(0);
+                    }
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            fGTButton = new Button(resultGroup, SWT.RADIO);
+            fGTButton.setSelection(fNode.getResult() > 0);
+            fGTButton.setText(">"); //$NON-NLS-1$
+            fGTButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fGTButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    if (fGTButton.getSelection()) {
+                        fNode.setResult(1);
+                    }
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_TypeLabel);
+            
+            Composite typeGroup = new Composite(this, SWT.NONE);
+            GridLayout tggl = new GridLayout(3, false);
+            tggl.marginHeight = 0;
+            tggl.marginWidth = 0;
+            typeGroup.setLayout(tggl);
+            typeGroup.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            
+            fNumButton = new Button(typeGroup, SWT.RADIO);
+            fNumButton.setSelection(fNode.getType() == Type.NUM);
+            fNumButton.setText(Messages.FilterViewer_NumButtonText);
+            fNumButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fNumButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    if (fNumButton.getSelection()) {
+                        fNode.setType(Type.NUM);
+                    }
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            fAlphaButton = new Button(typeGroup, SWT.RADIO);
+            fAlphaButton.setSelection(fNode.getType() == Type.ALPHA);
+            fAlphaButton.setText(Messages.FilterViewer_AlphaButtonText);
+            fAlphaButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fAlphaButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    if (fAlphaButton.getSelection()) {
+                        fNode.setType(Type.ALPHA);
+                    }
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            fTimestampButton = new Button(typeGroup, SWT.RADIO);
+            fTimestampButton.setSelection(fNode.getType() == Type.TIMESTAMP);
+            fTimestampButton.setText(Messages.FilterViewer_TimestampButtonText);
+            fTimestampButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            fTimestampButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    if (fTimestampButton.getSelection()) {
+                        fNode.setType(Type.TIMESTAMP);
+                    }
+                    fViewer.refresh(fNode);
+                }
+            });
+            
+            label = new Label(this, SWT.NONE);
+            label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+            label.setText(Messages.FilterViewer_ValueLabel);
+            
+            fValueText = new Text(this, SWT.BORDER);
+            fValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            if (node.getValue() != null && node.getValue().length() > 0) {
+                fValueText.setText(node.getValue());
+            } else {
+                fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                fValueText.setText(Messages.FilterViewer_ValueHint);
+            }
+            fValueText.addFocusListener(new FocusListener() {
+                @Override
+                public void focusLost(FocusEvent e) {
+                    if (fNode.getValue() == null || fNode.getValue().length() == 0) {
+                        fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+                        fValueText.setText(Messages.FilterViewer_ValueHint);
+                    }
+                }
+                @Override
+                public void focusGained(FocusEvent e) {
+                    if (fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fValueText.setText(""); //$NON-NLS-1$
+                    }
+                    fValueText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+                }
+            });
+            fValueText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    if (! fValueText.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY))) {
+                        fNode.setValue(fValueText.getText());
+                        fViewer.refresh(fNode);
+                    }
+                }
+            });
+        }
+    }
+
+}
index b6559c5b3df9655b89cd257540dc70b393a85831..d7f05ea435fdda8a4007b6a9c7cb3e7a0344d798 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import java.util.Iterator;\r
-import java.util.NoSuchElementException;\r
-import java.util.Vector;\r
-\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * An entry (row) in the time chart analysis view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeChartAnalysisEntry implements ITimeGraphEntry {\r
-\r
-    private final ITmfTrace<?> fTrace;\r
-    private final Vector<TimeChartEvent> fTraceEvents;\r
-    private int fPower = 0; // 2^fPower nanoseconds per vector position\r
-    private long fReferenceTime = -1; // time corresponding to beginning of index 0\r
-    private long fStartTime = -1; // time of first event\r
-    private long fStopTime = -1; // time of last event\r
-    private long fLastRank = -1; // rank of last processed trace event\r
-\r
-    TimeChartAnalysisEntry(ITmfTrace<?> trace, int modelSize) {\r
-        fTrace = trace;\r
-        fTraceEvents = new Vector<TimeChartEvent>(modelSize);\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry[] getChildren() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry getParent() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasChildren() {\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return fTrace.getName();\r
-    }\r
-\r
-    @Override\r
-    public long getStartTime() {\r
-        return fStartTime;\r
-    }\r
-\r
-    @Override\r
-    public long getEndTime() {\r
-        return fStopTime;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasTimeEvents() {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator() {\r
-        return new EntryIterator(0, Long.MAX_VALUE, 0);\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long maxDuration) {\r
-        return new EntryIterator(startTime, stopTime, maxDuration);\r
-    }\r
-\r
-    private class EntryIterator implements Iterator<ITimeEvent> {\r
-        private final long fIteratorStartTime;\r
-        private final long fIteratorStopTime;\r
-        private final long fIteratorMaxDuration;\r
-        private long lastTime = -1;\r
-        private TimeChartEvent next = null;\r
-        private Iterator<ITimeEvent> nestedIterator = null;\r
-\r
-        public EntryIterator(long startTime, long stopTime, long maxDuration) {\r
-            fIteratorStartTime = startTime;\r
-            fIteratorStopTime = stopTime;\r
-            fIteratorMaxDuration = maxDuration;\r
-        }\r
-\r
-        @Override\r
-        public boolean hasNext() {\r
-            synchronized (fTraceEvents) {\r
-                if (next != null) {\r
-                    return true;\r
-                }\r
-                if (nestedIterator != null) {\r
-                    if (nestedIterator.hasNext()) {\r
-                        return true;\r
-                    }\r
-                    nestedIterator = null;\r
-                }\r
-                long time = (lastTime == -1) ? fStartTime : lastTime;\r
-                int index = (fReferenceTime == -1) ? 0 : (int) ((time - fReferenceTime) >> fPower);\r
-                while (index < fTraceEvents.size()) {\r
-                    TimeChartEvent event = fTraceEvents.get(index++);\r
-                    if (event != null && (lastTime == -1 || event.getTime() > time)) {\r
-                        if (event.getTime() + event.getDuration() >= fIteratorStartTime && event.getTime() <= fIteratorStopTime) {\r
-                            if (event.getItemizedEntry() == null || event.getDuration() <= fIteratorMaxDuration) {\r
-                                lastTime = event.getTime() + event.getDuration();\r
-                                next = event;\r
-                                return true;\r
-                            }\r
-                            nestedIterator = event.getItemizedEntry().getTimeEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration);\r
-                            return nestedIterator.hasNext();\r
-                        }\r
-                    }\r
-                }\r
-                return false;\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public TimeChartEvent next() {\r
-            synchronized (fTraceEvents) {\r
-                if (nestedIterator != null) {\r
-                    TimeChartEvent event = (TimeChartEvent) nestedIterator.next();\r
-                    lastTime = event.getTime() + event.getDuration();\r
-                    return event;\r
-                }\r
-                if (hasNext()) {\r
-                    TimeChartEvent event = next;\r
-                    next = null;\r
-                    return event;\r
-                }\r
-                throw new NoSuchElementException();\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public void remove() {\r
-            throw new UnsupportedOperationException();\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * Add a time event to the time chart entry\r
-     *\r
-     * @param timeEvent\r
-     *            The event to add\r
-     */\r
-    public void addTraceEvent(ITimeEvent timeEvent) {\r
-        long time = timeEvent.getTime();\r
-        synchronized (fTraceEvents) {\r
-            long index = (fReferenceTime == -1) ? 0 : (time - fReferenceTime) >> fPower;\r
-            if (index < 0) {\r
-                if (fTraceEvents.capacity() - fTraceEvents.size() < -index) {\r
-                    int powershift = (-index + fTraceEvents.size() <= 2 * fTraceEvents.capacity()) ? 1 :\r
-                        (int) Math.ceil(Math.log((double) (-index + fTraceEvents.size()) / fTraceEvents.capacity()) / Math.log(2));\r
-                    merge(powershift);\r
-                    index = (int) ((time - fReferenceTime) >> fPower);\r
-                }\r
-                shift((int) -index);\r
-                index = 0;\r
-                fTraceEvents.set(0, (TimeChartEvent) timeEvent);\r
-            } else if (index < fTraceEvents.capacity()) {\r
-                if (index >= fTraceEvents.size()) {\r
-                    fTraceEvents.setSize((int) index + 1);\r
-                }\r
-            } else {\r
-                int powershift = (index < 2 * fTraceEvents.capacity()) ? 1 :\r
-                    (int) Math.ceil(Math.log((double) (index + 1) / fTraceEvents.capacity()) / Math.log(2));\r
-                merge(powershift);\r
-                index = (int) ((time - fReferenceTime) >> fPower);\r
-                fTraceEvents.setSize((int) index + 1);\r
-            }\r
-            TimeChartEvent event = fTraceEvents.get((int) index);\r
-            if (event == null) {\r
-                fTraceEvents.set((int) index, (TimeChartEvent) timeEvent);\r
-            } else {\r
-                if (event.getItemizedEntry() == null) {\r
-                    event.merge((TimeChartEvent) timeEvent);\r
-                } else {\r
-                       event.mergeDecorations((TimeChartEvent) timeEvent);\r
-                    event.getItemizedEntry().addTraceEvent(timeEvent);\r
-                }\r
-            }\r
-            if (fReferenceTime == -1 || time < fReferenceTime) {\r
-                fReferenceTime = (time >> fPower) << fPower;\r
-            }\r
-            if (fStartTime == -1 || time < fStartTime) {\r
-                fStartTime = time;\r
-            }\r
-            if (fStopTime == -1 || time > fStopTime) {\r
-                fStopTime = time;\r
-            }\r
-        }\r
-    }\r
-\r
-    private void merge(int powershift) {\r
-        fPower += powershift;\r
-        fReferenceTime = (fReferenceTime >> fPower) << fPower;\r
-        int index = 0;\r
-        for (int i = 0; i < fTraceEvents.size(); i++) {\r
-            TimeChartEvent event = fTraceEvents.get(i);\r
-            if (event != null) {\r
-                index = (int) ((event.getTime() - fReferenceTime) >> fPower);\r
-                TimeChartEvent mergedEvent = fTraceEvents.get(index);\r
-                if (mergedEvent == null) {\r
-                    fTraceEvents.set(index, event);\r
-                } else {\r
-                    mergedEvent.merge(event);\r
-                }\r
-                if (i != index) {\r
-                    fTraceEvents.set(i, null);\r
-                }\r
-            }\r
-        }\r
-        fTraceEvents.setSize(index + 1);\r
-    }\r
-\r
-    private void shift(int indexshift) {\r
-        int oldSize = fTraceEvents.size();\r
-        fTraceEvents.setSize(oldSize + indexshift);\r
-        for (int i = oldSize - 1; i >= 0; i--) {\r
-            fTraceEvents.set(i + indexshift, fTraceEvents.get(i));\r
-        }\r
-        for (int i = 0; i < indexshift; i++) {\r
-            fTraceEvents.set(i, null);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the trace associated with this entry\r
-     *\r
-     * @return The trace object\r
-     */\r
-    public ITmfTrace<?> getTrace() {\r
-        return fTrace;\r
-    }\r
-\r
-    /**\r
-     * Set the last rank of the entry\r
-     *\r
-     * @param rank\r
-     *            The rank to set\r
-     */\r
-    public void setLastRank(long rank) {\r
-        fLastRank = rank;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the last rank of the entry\r
-     *\r
-     * @return The last rank\r
-     */\r
-    public long getLastRank() {\r
-        return fLastRank;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Vector;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * An entry (row) in the time chart analysis view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartAnalysisEntry implements ITimeGraphEntry {
+
+    private final ITmfTrace<?> fTrace;
+    private final Vector<TimeChartEvent> fTraceEvents;
+    private int fPower = 0; // 2^fPower nanoseconds per vector position
+    private long fReferenceTime = -1; // time corresponding to beginning of index 0
+    private long fStartTime = -1; // time of first event
+    private long fStopTime = -1; // time of last event
+    private long fLastRank = -1; // rank of last processed trace event
+
+    TimeChartAnalysisEntry(ITmfTrace<?> trace, int modelSize) {
+        fTrace = trace;
+        fTraceEvents = new Vector<TimeChartEvent>(modelSize);
+    }
+
+    @Override
+    public ITimeGraphEntry[] getChildren() {
+        return null;
+    }
+
+    @Override
+    public ITimeGraphEntry getParent() {
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren() {
+        return false;
+    }
+
+    @Override
+    public String getName() {
+        return fTrace.getName();
+    }
+
+    @Override
+    public long getStartTime() {
+        return fStartTime;
+    }
+
+    @Override
+    public long getEndTime() {
+        return fStopTime;
+    }
+
+    @Override
+    public boolean hasTimeEvents() {
+        return true;
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator() {
+        return new EntryIterator(0, Long.MAX_VALUE, 0);
+    }
+
+    @Override
+    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long maxDuration) {
+        return new EntryIterator(startTime, stopTime, maxDuration);
+    }
+
+    private class EntryIterator implements Iterator<ITimeEvent> {
+        private final long fIteratorStartTime;
+        private final long fIteratorStopTime;
+        private final long fIteratorMaxDuration;
+        private long lastTime = -1;
+        private TimeChartEvent next = null;
+        private Iterator<ITimeEvent> nestedIterator = null;
+
+        public EntryIterator(long startTime, long stopTime, long maxDuration) {
+            fIteratorStartTime = startTime;
+            fIteratorStopTime = stopTime;
+            fIteratorMaxDuration = maxDuration;
+        }
+
+        @Override
+        public boolean hasNext() {
+            synchronized (fTraceEvents) {
+                if (next != null) {
+                    return true;
+                }
+                if (nestedIterator != null) {
+                    if (nestedIterator.hasNext()) {
+                        return true;
+                    }
+                    nestedIterator = null;
+                }
+                long time = (lastTime == -1) ? fStartTime : lastTime;
+                int index = (fReferenceTime == -1) ? 0 : (int) ((time - fReferenceTime) >> fPower);
+                while (index < fTraceEvents.size()) {
+                    TimeChartEvent event = fTraceEvents.get(index++);
+                    if (event != null && (lastTime == -1 || event.getTime() > time)) {
+                        if (event.getTime() + event.getDuration() >= fIteratorStartTime && event.getTime() <= fIteratorStopTime) {
+                            if (event.getItemizedEntry() == null || event.getDuration() <= fIteratorMaxDuration) {
+                                lastTime = event.getTime() + event.getDuration();
+                                next = event;
+                                return true;
+                            }
+                            nestedIterator = event.getItemizedEntry().getTimeEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration);
+                            return nestedIterator.hasNext();
+                        }
+                    }
+                }
+                return false;
+            }
+        }
+
+        @Override
+        public TimeChartEvent next() {
+            synchronized (fTraceEvents) {
+                if (nestedIterator != null) {
+                    TimeChartEvent event = (TimeChartEvent) nestedIterator.next();
+                    lastTime = event.getTime() + event.getDuration();
+                    return event;
+                }
+                if (hasNext()) {
+                    TimeChartEvent event = next;
+                    next = null;
+                    return event;
+                }
+                throw new NoSuchElementException();
+            }
+        }
+
+        @Override
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    /**
+     * Add a time event to the time chart entry
+     *
+     * @param timeEvent
+     *            The event to add
+     */
+    public void addTraceEvent(ITimeEvent timeEvent) {
+        long time = timeEvent.getTime();
+        synchronized (fTraceEvents) {
+            long index = (fReferenceTime == -1) ? 0 : (time - fReferenceTime) >> fPower;
+            if (index < 0) {
+                if (fTraceEvents.capacity() - fTraceEvents.size() < -index) {
+                    int powershift = (-index + fTraceEvents.size() <= 2 * fTraceEvents.capacity()) ? 1 :
+                        (int) Math.ceil(Math.log((double) (-index + fTraceEvents.size()) / fTraceEvents.capacity()) / Math.log(2));
+                    merge(powershift);
+                    index = (int) ((time - fReferenceTime) >> fPower);
+                }
+                shift((int) -index);
+                index = 0;
+                fTraceEvents.set(0, (TimeChartEvent) timeEvent);
+            } else if (index < fTraceEvents.capacity()) {
+                if (index >= fTraceEvents.size()) {
+                    fTraceEvents.setSize((int) index + 1);
+                }
+            } else {
+                int powershift = (index < 2 * fTraceEvents.capacity()) ? 1 :
+                    (int) Math.ceil(Math.log((double) (index + 1) / fTraceEvents.capacity()) / Math.log(2));
+                merge(powershift);
+                index = (int) ((time - fReferenceTime) >> fPower);
+                fTraceEvents.setSize((int) index + 1);
+            }
+            TimeChartEvent event = fTraceEvents.get((int) index);
+            if (event == null) {
+                fTraceEvents.set((int) index, (TimeChartEvent) timeEvent);
+            } else {
+                if (event.getItemizedEntry() == null) {
+                    event.merge((TimeChartEvent) timeEvent);
+                } else {
+                       event.mergeDecorations((TimeChartEvent) timeEvent);
+                    event.getItemizedEntry().addTraceEvent(timeEvent);
+                }
+            }
+            if (fReferenceTime == -1 || time < fReferenceTime) {
+                fReferenceTime = (time >> fPower) << fPower;
+            }
+            if (fStartTime == -1 || time < fStartTime) {
+                fStartTime = time;
+            }
+            if (fStopTime == -1 || time > fStopTime) {
+                fStopTime = time;
+            }
+        }
+    }
+
+    private void merge(int powershift) {
+        fPower += powershift;
+        fReferenceTime = (fReferenceTime >> fPower) << fPower;
+        int index = 0;
+        for (int i = 0; i < fTraceEvents.size(); i++) {
+            TimeChartEvent event = fTraceEvents.get(i);
+            if (event != null) {
+                index = (int) ((event.getTime() - fReferenceTime) >> fPower);
+                TimeChartEvent mergedEvent = fTraceEvents.get(index);
+                if (mergedEvent == null) {
+                    fTraceEvents.set(index, event);
+                } else {
+                    mergedEvent.merge(event);
+                }
+                if (i != index) {
+                    fTraceEvents.set(i, null);
+                }
+            }
+        }
+        fTraceEvents.setSize(index + 1);
+    }
+
+    private void shift(int indexshift) {
+        int oldSize = fTraceEvents.size();
+        fTraceEvents.setSize(oldSize + indexshift);
+        for (int i = oldSize - 1; i >= 0; i--) {
+            fTraceEvents.set(i + indexshift, fTraceEvents.get(i));
+        }
+        for (int i = 0; i < indexshift; i++) {
+            fTraceEvents.set(i, null);
+        }
+    }
+
+    /**
+     * Retrieve the trace associated with this entry
+     *
+     * @return The trace object
+     */
+    public ITmfTrace<?> getTrace() {
+        return fTrace;
+    }
+
+    /**
+     * Set the last rank of the entry
+     *
+     * @param rank
+     *            The rank to set
+     */
+    public void setLastRank(long rank) {
+        fLastRank = rank;
+    }
+
+    /**
+     * Retrieve the last rank of the entry
+     *
+     * @return The last rank
+     */
+    public long getLastRank() {
+        return fLastRank;
+    }
+}
index 2af8116ebeaa2060f2a84713ae712e36127bb1c5..6c69dabfc70954d92b80d2c17e629f4009dcca44 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-/**\r
- * Provider for a time chart analysis view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {\r
-\r
-    private static final Color BOOKMARK_INNER_COLOR = new Color(Display.getDefault(), 115, 165, 224);\r
-    private static final Color BOOKMARK_OUTER_COLOR = new Color(Display.getDefault(), 2, 70, 140);\r
-    private static final Color SEARCH_MATCH_COLOR = new Color(Display.getDefault(), 177, 118, 14);\r
-\r
-    private int lastX = Integer.MIN_VALUE;\r
-    private int currX = Integer.MIN_VALUE;\r
-    private int lastPriority;\r
-    private int lastBookmarkX = Integer.MIN_VALUE;\r
-\r
-    @Override\r
-    public StateItem[] getStateTable() {\r
-\r
-        ColorSetting[] settings = ColorSettingsManager.getColorSettings();\r
-        StateItem[] stateItems = new StateItem[settings.length];\r
-        for (int i = 0; i < settings.length; i++) {\r
-            stateItems[i] = new StateItem(settings[i].getTickColorRGB());\r
-        }\r
-        return stateItems;\r
-    }\r
-\r
-    @Override\r
-    public int getStateTableIndex(ITimeEvent event) {\r
-        int priority = ((TimeChartEvent) event).getColorSettingPriority();\r
-        if (currX == lastX) {\r
-            priority = Math.min(priority, lastPriority);\r
-        }\r
-        lastPriority = priority;\r
-        return priority;\r
-    }\r
-\r
-    @Override\r
-    public void postDrawEvent(ITimeEvent event, Rectangle rect, GC gc) {\r
-        if (! ((TimeChartEvent) event).isVisible()) {\r
-            return;\r
-        }\r
-        lastX = currX;\r
-        currX = rect.x;\r
-        if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {\r
-            drawBookmark(rect, gc);\r
-            lastBookmarkX = rect.x;\r
-        } else if (lastBookmarkX == rect.x - 1) {\r
-            Rectangle r = new Rectangle(lastBookmarkX, rect.y, rect.width, rect.height);\r
-            drawBookmark(r, gc);\r
-        } else {\r
-            lastBookmarkX = Integer.MIN_VALUE;\r
-        }\r
-        if (((TimeChartEvent) event).isSearchMatch()) {\r
-            drawSearchMatch(rect, gc);\r
-        }\r
-    }\r
-\r
-    private static void drawBookmark(Rectangle r, GC gc) {\r
-        gc.setForeground(BOOKMARK_OUTER_COLOR);\r
-        gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);\r
-        gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);\r
-        gc.drawPoint(r.x, r.y - 2);\r
-        gc.setForeground(BOOKMARK_INNER_COLOR);\r
-        gc.drawLine(r.x, r.y - 1, r.x, r.y + 1);\r
-        gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));\r
-        gc.drawPoint(r.x - 1, r.y + 3);\r
-        gc.drawPoint(r.x, r.y + 2);\r
-        gc.drawPoint(r.x + 1, r.y + 3);\r
-    }\r
-\r
-    private static void drawSearchMatch(Rectangle r, GC gc) {\r
-        gc.setForeground(SEARCH_MATCH_COLOR);\r
-        gc.drawPoint(r.x, r.y + r.height);\r
-        gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);\r
-        gc.drawLine(r.x - 2, r.y + r.height + 2, r.x + 2, r.y + r.height + 2);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Provider for a time chart analysis view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {
+
+    private static final Color BOOKMARK_INNER_COLOR = new Color(Display.getDefault(), 115, 165, 224);
+    private static final Color BOOKMARK_OUTER_COLOR = new Color(Display.getDefault(), 2, 70, 140);
+    private static final Color SEARCH_MATCH_COLOR = new Color(Display.getDefault(), 177, 118, 14);
+
+    private int lastX = Integer.MIN_VALUE;
+    private int currX = Integer.MIN_VALUE;
+    private int lastPriority;
+    private int lastBookmarkX = Integer.MIN_VALUE;
+
+    @Override
+    public StateItem[] getStateTable() {
+
+        ColorSetting[] settings = ColorSettingsManager.getColorSettings();
+        StateItem[] stateItems = new StateItem[settings.length];
+        for (int i = 0; i < settings.length; i++) {
+            stateItems[i] = new StateItem(settings[i].getTickColorRGB());
+        }
+        return stateItems;
+    }
+
+    @Override
+    public int getStateTableIndex(ITimeEvent event) {
+        int priority = ((TimeChartEvent) event).getColorSettingPriority();
+        if (currX == lastX) {
+            priority = Math.min(priority, lastPriority);
+        }
+        lastPriority = priority;
+        return priority;
+    }
+
+    @Override
+    public void postDrawEvent(ITimeEvent event, Rectangle rect, GC gc) {
+        if (! ((TimeChartEvent) event).isVisible()) {
+            return;
+        }
+        lastX = currX;
+        currX = rect.x;
+        if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {
+            drawBookmark(rect, gc);
+            lastBookmarkX = rect.x;
+        } else if (lastBookmarkX == rect.x - 1) {
+            Rectangle r = new Rectangle(lastBookmarkX, rect.y, rect.width, rect.height);
+            drawBookmark(r, gc);
+        } else {
+            lastBookmarkX = Integer.MIN_VALUE;
+        }
+        if (((TimeChartEvent) event).isSearchMatch()) {
+            drawSearchMatch(rect, gc);
+        }
+    }
+
+    private static void drawBookmark(Rectangle r, GC gc) {
+        gc.setForeground(BOOKMARK_OUTER_COLOR);
+        gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);
+        gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);
+        gc.drawPoint(r.x, r.y - 2);
+        gc.setForeground(BOOKMARK_INNER_COLOR);
+        gc.drawLine(r.x, r.y - 1, r.x, r.y + 1);
+        gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+        gc.drawPoint(r.x - 1, r.y + 3);
+        gc.drawPoint(r.x, r.y + 2);
+        gc.drawPoint(r.x + 1, r.y + 3);
+    }
+
+    private static void drawSearchMatch(Rectangle r, GC gc) {
+        gc.setForeground(SEARCH_MATCH_COLOR);
+        gc.drawPoint(r.x, r.y + r.height);
+        gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);
+        gc.drawLine(r.x - 2, r.y + r.height + 2, r.x + 2, r.y + r.height + 2);
+    }
+}
index 7ff3d589566241a329095417f7f198f677fad6d9..7c2c9e391e4c3ebc226fde6c744cb1f361b5257c 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.resources.IMarker;\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;\r
-\r
-/**\r
- * Provider for decorations in the time chart view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeChartDecorationProvider {\r
-\r
-       private final IFile fBookmarksFile;\r
-    private final Set<Long> fBookmarksSet = new HashSet<Long>();\r
-    private ITmfFilter fFilterFilter;\r
-    private ITmfFilter fSearchFilter;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param bookmarksFile\r
-     *            Bookmark file associated with the trace\r
-     */\r
-    public TimeChartDecorationProvider(IFile bookmarksFile) {\r
-        fBookmarksFile = bookmarksFile;\r
-        refreshBookmarks();\r
-    }\r
-\r
-    /**\r
-     * Retrieve the bookmark file that was assigned to this provider\r
-     *\r
-     * @return The bookmark file\r
-     */\r
-    public IFile getBookmarksFile() {\r
-        return fBookmarksFile;\r
-    }\r
-\r
-    /**\r
-     * Verify if the selected rank has a bookmark assigned to it.\r
-     *\r
-     * @param rank\r
-     *            The rank to check for\r
-     * @return If there is a bookmark there\r
-     */\r
-    public boolean isBookmark(long rank) {\r
-        return fBookmarksSet.contains(rank);\r
-    }\r
-\r
-    /**\r
-     * Refresh the bookmark display.\r
-     */\r
-    public void refreshBookmarks() {\r
-        try {\r
-            fBookmarksSet.clear();\r
-            for (IMarker bookmark : fBookmarksFile.findMarkers(\r
-                    IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {\r
-                int location = bookmark.getAttribute(IMarker.LOCATION, -1);\r
-                if (location != -1) {\r
-                    Long rank = (long) location;\r
-                    fBookmarksSet.add(rank);\r
-                }\r
-            }\r
-        } catch (CoreException e) {\r
-            Activator.getDefault().logError("Error refreshing bookmarks", e); //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Notify that a filter is now applied on the view.\r
-     *\r
-     * @param filter\r
-     *            The filter that was applied\r
-     */\r
-    public void filterApplied(ITmfFilter filter) {\r
-        fFilterFilter = filter;\r
-    }\r
-\r
-    /**\r
-     * Check if an event is currently visible in the view or not.\r
-     *\r
-     * @param event\r
-     *            The event to check for\r
-     * @return If the event is visible or not\r
-     */\r
-    public boolean isVisible(ITmfEvent event) {\r
-        if (fFilterFilter != null) {\r
-            return fFilterFilter.matches(event);\r
-        }\r
-        return true;\r
-    }\r
-\r
-    /**\r
-     * Notify that a search is applied on the view.\r
-     *\r
-     * @param filter\r
-     *            The search filter that was applied\r
-     */\r
-    public void searchApplied(ITmfFilter filter) {\r
-        fSearchFilter = filter;\r
-    }\r
-\r
-    /**\r
-     * Verify if the currently active search filter applies to the given event\r
-     * or not.\r
-     *\r
-     * @param event\r
-     *            The event to check for\r
-     * @return If the event matches\r
-     */\r
-    public boolean isSearchMatch(ITmfEvent event) {\r
-        if (fSearchFilter != null) {\r
-            return fSearchFilter.matches(event);\r
-        }\r
-        return false;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
+
+/**
+ * Provider for decorations in the time chart view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartDecorationProvider {
+
+       private final IFile fBookmarksFile;
+    private final Set<Long> fBookmarksSet = new HashSet<Long>();
+    private ITmfFilter fFilterFilter;
+    private ITmfFilter fSearchFilter;
+
+    /**
+     * Constructor
+     *
+     * @param bookmarksFile
+     *            Bookmark file associated with the trace
+     */
+    public TimeChartDecorationProvider(IFile bookmarksFile) {
+        fBookmarksFile = bookmarksFile;
+        refreshBookmarks();
+    }
+
+    /**
+     * Retrieve the bookmark file that was assigned to this provider
+     *
+     * @return The bookmark file
+     */
+    public IFile getBookmarksFile() {
+        return fBookmarksFile;
+    }
+
+    /**
+     * Verify if the selected rank has a bookmark assigned to it.
+     *
+     * @param rank
+     *            The rank to check for
+     * @return If there is a bookmark there
+     */
+    public boolean isBookmark(long rank) {
+        return fBookmarksSet.contains(rank);
+    }
+
+    /**
+     * Refresh the bookmark display.
+     */
+    public void refreshBookmarks() {
+        try {
+            fBookmarksSet.clear();
+            for (IMarker bookmark : fBookmarksFile.findMarkers(
+                    IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) {
+                int location = bookmark.getAttribute(IMarker.LOCATION, -1);
+                if (location != -1) {
+                    Long rank = (long) location;
+                    fBookmarksSet.add(rank);
+                }
+            }
+        } catch (CoreException e) {
+            Activator.getDefault().logError("Error refreshing bookmarks", e); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Notify that a filter is now applied on the view.
+     *
+     * @param filter
+     *            The filter that was applied
+     */
+    public void filterApplied(ITmfFilter filter) {
+        fFilterFilter = filter;
+    }
+
+    /**
+     * Check if an event is currently visible in the view or not.
+     *
+     * @param event
+     *            The event to check for
+     * @return If the event is visible or not
+     */
+    public boolean isVisible(ITmfEvent event) {
+        if (fFilterFilter != null) {
+            return fFilterFilter.matches(event);
+        }
+        return true;
+    }
+
+    /**
+     * Notify that a search is applied on the view.
+     *
+     * @param filter
+     *            The search filter that was applied
+     */
+    public void searchApplied(ITmfFilter filter) {
+        fSearchFilter = filter;
+    }
+
+    /**
+     * Verify if the currently active search filter applies to the given event
+     * or not.
+     *
+     * @param event
+     *            The event to check for
+     * @return If the event matches
+     */
+    public boolean isSearchMatch(ITmfEvent event) {
+        if (fSearchFilter != null) {
+            return fSearchFilter.matches(event);
+        }
+        return false;
+    }
+
+}
index 86a92a8772b93b0a51fa6ebfc1fc3b656011a7cd..3b4385dc2a0162b6e0256df8115084d26c5e30b0 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * Event in the time chart view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeChartEvent implements ITimeEvent {\r
-\r
-    private static final byte TIMESTAMP_SCALE = -9;\r
-\r
-    private final TimeChartAnalysisEntry fParentEntry;\r
-    private long fTime;\r
-    private long fDuration;\r
-    private long fFirstRank;\r
-    private long fLastRank;\r
-    private final RankRangeList fRankRangeList;\r
-    private long fNbEvents;\r
-    private int fColorSettingPriority;\r
-    private boolean fIsBookmark;\r
-    private boolean fIsVisible;\r
-    private boolean fIsSearchMatch;\r
-    private TimeChartAnalysisEntry fItemizedEntry;\r
-    private boolean fItemizing;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param parentEntry\r
-     *            The parent entry\r
-     * @param event\r
-     *            The event from which this time chart event originates\r
-     * @param rank\r
-     *            The rank of the event in the trace\r
-     * @param decorationProvider\r
-     *            The decoration provider to use\r
-     */\r
-    public TimeChartEvent(TimeChartAnalysisEntry parentEntry, ITmfEvent event,\r
-            long rank, TimeChartDecorationProvider decorationProvider) {\r
-        fParentEntry = parentEntry;\r
-        fTime = event.getTimestamp().normalize(0, TIMESTAMP_SCALE).getValue();\r
-        fDuration = 0;\r
-        fFirstRank = fLastRank = rank;\r
-        fRankRangeList = new RankRangeList(rank);\r
-        fNbEvents = 1;\r
-        fColorSettingPriority = ColorSettingsManager.getColorSettingPriority(event);\r
-        fIsBookmark = decorationProvider.isBookmark(rank);\r
-        fIsVisible = decorationProvider.isVisible(event);\r
-        fIsSearchMatch = decorationProvider.isSearchMatch(event);\r
-    }\r
-\r
-       @Override\r
-    public ITimeGraphEntry getEntry() {\r
-        return fParentEntry;\r
-    }\r
-\r
-    @Override\r
-    public long getTime() {\r
-        return fTime;\r
-    }\r
-\r
-    @Override\r
-    public long getDuration() {\r
-        return fDuration;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the rank of the trace event which started this time event.\r
-     *\r
-     * @return The rank of the beginning\r
-     */\r
-    public long getFirstRank() {\r
-        return fFirstRank;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the rank of the trace event which *finished* this time event.\r
-     *\r
-     * @return The rank of the end\r
-     */\r
-    public long getLastRank() {\r
-        return fLastRank;\r
-    }\r
-\r
-    /**\r
-     * Get the list of rank ranges corresponding to this time event.\r
-     *\r
-     * @return The rank range list\r
-     */\r
-    public RankRangeList getRankRangeList() {\r
-        return fRankRangeList;\r
-    }\r
-\r
-    /**\r
-     * Merge another time event with this one.\r
-     *\r
-     * @param event\r
-     *            The other event\r
-     */\r
-    public void merge(TimeChartEvent event) {\r
-       mergeDecorations(event);\r
-        if (fTime == event.getTime() && fDuration == event.getDuration()) {\r
-            return;\r
-        }\r
-        long endTime = Math.max(fTime + fDuration, event.getTime() + event.getDuration());\r
-        fTime = Math.min(fTime, event.getTime());\r
-        fDuration = endTime - fTime;\r
-        fFirstRank = Math.min(fFirstRank, event.fFirstRank);\r
-        fLastRank = Math.max(fLastRank, event.fLastRank);\r
-        fNbEvents += event.fNbEvents;\r
-        fItemizedEntry = null;\r
-        synchronized (fRankRangeList) {\r
-               fRankRangeList.merge(event.getRankRangeList());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Merge the decorations of another time event with the decorations of this\r
-     * one.\r
-     *\r
-     * @param event\r
-     *            The other event\r
-     */\r
-    public void mergeDecorations(TimeChartEvent event) {\r
-        fColorSettingPriority = Math.min(fColorSettingPriority, event.getColorSettingPriority());\r
-        fIsBookmark |= event.fIsBookmark;\r
-       fIsVisible |= event.fIsVisible;\r
-       fIsSearchMatch |= event.fIsSearchMatch;\r
-    }\r
-\r
-    /**\r
-     * Get the number of time events that have been merged with this one (starts\r
-     * counting at 1 if no merge happened).\r
-     *\r
-     * @return The current number of events in the bath\r
-     */\r
-    public long getNbEvents() {\r
-        return fNbEvents;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the color setting priority.\r
-     *\r
-     * @return The priority\r
-     */\r
-    public int getColorSettingPriority() {\r
-       return fColorSettingPriority;\r
-    }\r
-\r
-    /**\r
-     * Set the color setting priority.\r
-     *\r
-     * @param priority\r
-     *            The priority to set\r
-     */\r
-    public void setColorSettingPriority(int priority) {\r
-       fColorSettingPriority = priority;\r
-    }\r
-\r
-    /**\r
-     * Check if this time event is bookmarked\r
-     *\r
-     * @return Y/N\r
-     */\r
-    public boolean isBookmarked() {\r
-       return fIsBookmark;\r
-    }\r
-\r
-    /**\r
-     * Set this time event to be bookmarked or not.\r
-     *\r
-     * @param isBookmarked\r
-     *            Should time time event become a bookmark, or not\r
-     */\r
-    public void setIsBookmarked(boolean isBookmarked) {\r
-       fIsBookmark = isBookmarked;\r
-    }\r
-\r
-    /**\r
-     * Check if this time is currently visible or not.\r
-     *\r
-     * @return If the event is visible\r
-     */\r
-    public boolean isVisible() {\r
-       return fIsVisible;\r
-    }\r
-\r
-    /**\r
-     * Set this time event to visible (or to non-visible).\r
-     *\r
-     * @param isVisible The new status\r
-     */\r
-    public void setIsVisible(boolean isVisible) {\r
-       fIsVisible = isVisible;\r
-    }\r
-\r
-    /**\r
-     * Check if the time event matches the current search.\r
-     *\r
-     * @return If it matches, Y/N\r
-     */\r
-    public boolean isSearchMatch() {\r
-       return fIsSearchMatch;\r
-    }\r
-\r
-    /**\r
-     * Mark this event as matching (or non-matching) the current search.\r
-     *\r
-     * @param isSearchMatch\r
-     *            The new matching status\r
-     */\r
-    public void setIsSearchMatch(boolean isSearchMatch) {\r
-       fIsSearchMatch = isSearchMatch;\r
-    }\r
-\r
-    /**\r
-     * Set this event's itemized entry.\r
-     *\r
-     * @param timeAnalysisEntry\r
-     *            The entry to set\r
-     */\r
-    public void setItemizedEntry(TimeChartAnalysisEntry timeAnalysisEntry) {\r
-        fItemizedEntry = timeAnalysisEntry;\r
-    }\r
-\r
-    /**\r
-     * Retrieve this event's itemized entry.\r
-     *\r
-     * @return The itemized entry that was previously set\r
-     */\r
-    public TimeChartAnalysisEntry getItemizedEntry() {\r
-        return fItemizedEntry;\r
-    }\r
-\r
-    /**\r
-     * @return Has this time event been set to itemizing?\r
-     */\r
-    public boolean isItemizing() {\r
-        return fItemizing;\r
-    }\r
-\r
-    /**\r
-     * Set this event's itemizing flag to true or false.\r
-     *\r
-     * @param itemizing\r
-     *            The new value\r
-     */\r
-    public void setItemizing(boolean itemizing) {\r
-        fItemizing = itemizing;\r
-    }\r
-\r
-    /**\r
-     * Inner class to define a range in terms of ranks in the trace.\r
-     *\r
-     * @version 1.0\r
-     * @author Patrick Tasse\r
-     */\r
-    public class RankRange {\r
-        private long firstRank;\r
-        private long lastRank;\r
-\r
-        /**\r
-         * Standard constructor\r
-         *\r
-         * @param firstRank\r
-         *            The first (earliest) rank of the range\r
-         * @param lastRank\r
-         *            The last (latest) rank of the range\r
-         */\r
-        public RankRange(long firstRank, long lastRank) {\r
-            this.firstRank = firstRank;\r
-            this.lastRank = lastRank;\r
-        }\r
-\r
-        /**\r
-         * Retrieve the start rank of this range.\r
-         *\r
-         * @return The first rank\r
-         */\r
-        public long getFirstRank() {\r
-            return firstRank;\r
-        }\r
-\r
-        /**\r
-         * Retrieve the end rank of this range\r
-         *\r
-         * @return The end rank\r
-         */\r
-        public long getLastRank() {\r
-            return lastRank;\r
-        }\r
-\r
-        /**\r
-         * Calculate the minimal distance between two RankRange's\r
-         *\r
-         * @param range\r
-         *            The other range\r
-         * @return The distance, in "number of events" between the two ranges\r
-         */\r
-        public long distanceFrom(RankRange range) {\r
-            if (range.lastRank < fFirstRank) {\r
-                return fFirstRank - range.lastRank;\r
-            } else if (range.firstRank > fLastRank) {\r
-                return range.firstRank - fLastRank;\r
-            } else {\r
-                return 0;\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            return "["+firstRank+","+lastRank+"]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-        }\r
-    }\r
-\r
-    private class RankRangeList extends ArrayList<RankRange> {\r
-\r
-        private static final long serialVersionUID = 6060485531208535986L;\r
-\r
-        public RankRangeList(long rank) {\r
-            super(1);\r
-            add(new RankRange(rank, rank));\r
-        }\r
-\r
-        public void merge(RankRangeList rankRangeList) {\r
-            long threshold = fParentEntry.getTrace().getCacheSize();\r
-            for (RankRange newRange : rankRangeList) {\r
-                boolean merged = false;\r
-                for (RankRange oldRange : fRankRangeList) {\r
-                    if (newRange.distanceFrom(oldRange) <= threshold) {\r
-                        oldRange.firstRank = Math.min(oldRange.firstRank, newRange.firstRank);\r
-                        oldRange.lastRank = Math.max(oldRange.lastRank, newRange.lastRank);\r
-                        merged = true;\r
-                        break;\r
-                    }\r
-                }\r
-                if (!merged) {\r
-                    add(newRange);\r
-                }\r
-            }\r
-            Iterator<RankRange> iterator = fRankRangeList.iterator();\r
-            RankRange previous = null;\r
-            while (iterator.hasNext()) {\r
-                RankRange range = iterator.next();\r
-                if (previous != null && range.distanceFrom(previous) <= threshold) {\r
-                    previous.firstRank = Math.min(previous.firstRank, range.firstRank);\r
-                    previous.lastRank = Math.max(previous.lastRank, range.lastRank);\r
-                    iterator.remove();\r
-                }\r
-                previous = range;\r
-            }\r
-        }\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * Event in the time chart view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartEvent implements ITimeEvent {
+
+    private static final byte TIMESTAMP_SCALE = -9;
+
+    private final TimeChartAnalysisEntry fParentEntry;
+    private long fTime;
+    private long fDuration;
+    private long fFirstRank;
+    private long fLastRank;
+    private final RankRangeList fRankRangeList;
+    private long fNbEvents;
+    private int fColorSettingPriority;
+    private boolean fIsBookmark;
+    private boolean fIsVisible;
+    private boolean fIsSearchMatch;
+    private TimeChartAnalysisEntry fItemizedEntry;
+    private boolean fItemizing;
+
+    /**
+     * Standard constructor
+     *
+     * @param parentEntry
+     *            The parent entry
+     * @param event
+     *            The event from which this time chart event originates
+     * @param rank
+     *            The rank of the event in the trace
+     * @param decorationProvider
+     *            The decoration provider to use
+     */
+    public TimeChartEvent(TimeChartAnalysisEntry parentEntry, ITmfEvent event,
+            long rank, TimeChartDecorationProvider decorationProvider) {
+        fParentEntry = parentEntry;
+        fTime = event.getTimestamp().normalize(0, TIMESTAMP_SCALE).getValue();
+        fDuration = 0;
+        fFirstRank = fLastRank = rank;
+        fRankRangeList = new RankRangeList(rank);
+        fNbEvents = 1;
+        fColorSettingPriority = ColorSettingsManager.getColorSettingPriority(event);
+        fIsBookmark = decorationProvider.isBookmark(rank);
+        fIsVisible = decorationProvider.isVisible(event);
+        fIsSearchMatch = decorationProvider.isSearchMatch(event);
+    }
+
+       @Override
+    public ITimeGraphEntry getEntry() {
+        return fParentEntry;
+    }
+
+    @Override
+    public long getTime() {
+        return fTime;
+    }
+
+    @Override
+    public long getDuration() {
+        return fDuration;
+    }
+
+    /**
+     * Retrieve the rank of the trace event which started this time event.
+     *
+     * @return The rank of the beginning
+     */
+    public long getFirstRank() {
+        return fFirstRank;
+    }
+
+    /**
+     * Retrieve the rank of the trace event which *finished* this time event.
+     *
+     * @return The rank of the end
+     */
+    public long getLastRank() {
+        return fLastRank;
+    }
+
+    /**
+     * Get the list of rank ranges corresponding to this time event.
+     *
+     * @return The rank range list
+     */
+    public RankRangeList getRankRangeList() {
+        return fRankRangeList;
+    }
+
+    /**
+     * Merge another time event with this one.
+     *
+     * @param event
+     *            The other event
+     */
+    public void merge(TimeChartEvent event) {
+       mergeDecorations(event);
+        if (fTime == event.getTime() && fDuration == event.getDuration()) {
+            return;
+        }
+        long endTime = Math.max(fTime + fDuration, event.getTime() + event.getDuration());
+        fTime = Math.min(fTime, event.getTime());
+        fDuration = endTime - fTime;
+        fFirstRank = Math.min(fFirstRank, event.fFirstRank);
+        fLastRank = Math.max(fLastRank, event.fLastRank);
+        fNbEvents += event.fNbEvents;
+        fItemizedEntry = null;
+        synchronized (fRankRangeList) {
+               fRankRangeList.merge(event.getRankRangeList());
+        }
+    }
+
+    /**
+     * Merge the decorations of another time event with the decorations of this
+     * one.
+     *
+     * @param event
+     *            The other event
+     */
+    public void mergeDecorations(TimeChartEvent event) {
+        fColorSettingPriority = Math.min(fColorSettingPriority, event.getColorSettingPriority());
+        fIsBookmark |= event.fIsBookmark;
+       fIsVisible |= event.fIsVisible;
+       fIsSearchMatch |= event.fIsSearchMatch;
+    }
+
+    /**
+     * Get the number of time events that have been merged with this one (starts
+     * counting at 1 if no merge happened).
+     *
+     * @return The current number of events in the bath
+     */
+    public long getNbEvents() {
+        return fNbEvents;
+    }
+
+    /**
+     * Retrieve the color setting priority.
+     *
+     * @return The priority
+     */
+    public int getColorSettingPriority() {
+       return fColorSettingPriority;
+    }
+
+    /**
+     * Set the color setting priority.
+     *
+     * @param priority
+     *            The priority to set
+     */
+    public void setColorSettingPriority(int priority) {
+       fColorSettingPriority = priority;
+    }
+
+    /**
+     * Check if this time event is bookmarked
+     *
+     * @return Y/N
+     */
+    public boolean isBookmarked() {
+       return fIsBookmark;
+    }
+
+    /**
+     * Set this time event to be bookmarked or not.
+     *
+     * @param isBookmarked
+     *            Should time time event become a bookmark, or not
+     */
+    public void setIsBookmarked(boolean isBookmarked) {
+       fIsBookmark = isBookmarked;
+    }
+
+    /**
+     * Check if this time is currently visible or not.
+     *
+     * @return If the event is visible
+     */
+    public boolean isVisible() {
+       return fIsVisible;
+    }
+
+    /**
+     * Set this time event to visible (or to non-visible).
+     *
+     * @param isVisible The new status
+     */
+    public void setIsVisible(boolean isVisible) {
+       fIsVisible = isVisible;
+    }
+
+    /**
+     * Check if the time event matches the current search.
+     *
+     * @return If it matches, Y/N
+     */
+    public boolean isSearchMatch() {
+       return fIsSearchMatch;
+    }
+
+    /**
+     * Mark this event as matching (or non-matching) the current search.
+     *
+     * @param isSearchMatch
+     *            The new matching status
+     */
+    public void setIsSearchMatch(boolean isSearchMatch) {
+       fIsSearchMatch = isSearchMatch;
+    }
+
+    /**
+     * Set this event's itemized entry.
+     *
+     * @param timeAnalysisEntry
+     *            The entry to set
+     */
+    public void setItemizedEntry(TimeChartAnalysisEntry timeAnalysisEntry) {
+        fItemizedEntry = timeAnalysisEntry;
+    }
+
+    /**
+     * Retrieve this event's itemized entry.
+     *
+     * @return The itemized entry that was previously set
+     */
+    public TimeChartAnalysisEntry getItemizedEntry() {
+        return fItemizedEntry;
+    }
+
+    /**
+     * @return Has this time event been set to itemizing?
+     */
+    public boolean isItemizing() {
+        return fItemizing;
+    }
+
+    /**
+     * Set this event's itemizing flag to true or false.
+     *
+     * @param itemizing
+     *            The new value
+     */
+    public void setItemizing(boolean itemizing) {
+        fItemizing = itemizing;
+    }
+
+    /**
+     * Inner class to define a range in terms of ranks in the trace.
+     *
+     * @version 1.0
+     * @author Patrick Tasse
+     */
+    public class RankRange {
+        private long firstRank;
+        private long lastRank;
+
+        /**
+         * Standard constructor
+         *
+         * @param firstRank
+         *            The first (earliest) rank of the range
+         * @param lastRank
+         *            The last (latest) rank of the range
+         */
+        public RankRange(long firstRank, long lastRank) {
+            this.firstRank = firstRank;
+            this.lastRank = lastRank;
+        }
+
+        /**
+         * Retrieve the start rank of this range.
+         *
+         * @return The first rank
+         */
+        public long getFirstRank() {
+            return firstRank;
+        }
+
+        /**
+         * Retrieve the end rank of this range
+         *
+         * @return The end rank
+         */
+        public long getLastRank() {
+            return lastRank;
+        }
+
+        /**
+         * Calculate the minimal distance between two RankRange's
+         *
+         * @param range
+         *            The other range
+         * @return The distance, in "number of events" between the two ranges
+         */
+        public long distanceFrom(RankRange range) {
+            if (range.lastRank < fFirstRank) {
+                return fFirstRank - range.lastRank;
+            } else if (range.firstRank > fLastRank) {
+                return range.firstRank - fLastRank;
+            } else {
+                return 0;
+            }
+        }
+
+        @Override
+        public String toString() {
+            return "["+firstRank+","+lastRank+"]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        }
+    }
+
+    private class RankRangeList extends ArrayList<RankRange> {
+
+        private static final long serialVersionUID = 6060485531208535986L;
+
+        public RankRangeList(long rank) {
+            super(1);
+            add(new RankRange(rank, rank));
+        }
+
+        public void merge(RankRangeList rankRangeList) {
+            long threshold = fParentEntry.getTrace().getCacheSize();
+            for (RankRange newRange : rankRangeList) {
+                boolean merged = false;
+                for (RankRange oldRange : fRankRangeList) {
+                    if (newRange.distanceFrom(oldRange) <= threshold) {
+                        oldRange.firstRank = Math.min(oldRange.firstRank, newRange.firstRank);
+                        oldRange.lastRank = Math.max(oldRange.lastRank, newRange.lastRank);
+                        merged = true;
+                        break;
+                    }
+                }
+                if (!merged) {
+                    add(newRange);
+                }
+            }
+            Iterator<RankRange> iterator = fRankRangeList.iterator();
+            RankRange previous = null;
+            while (iterator.hasNext()) {
+                RankRange range = iterator.next();
+                if (previous != null && range.distanceFrom(previous) <= threshold) {
+                    previous.firstRank = Math.min(previous.firstRank, range.firstRank);
+                    previous.lastRank = Math.max(previous.lastRank, range.lastRank);
+                    iterator.remove();
+                }
+                previous = range;
+            }
+        }
+    }
+}
index 69e2899bd18a5c11e507e8badb3ce0b6b726afd5..1b4423ebdd605418f353cd5204bd3bcd6c9900f6 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.resources.IMarker;\r
-import org.eclipse.core.resources.IMarkerDelta;\r
-import org.eclipse.core.resources.IResourceChangeEvent;\r
-import org.eclipse.core.resources.IResourceChangeListener;\r
-import org.eclipse.core.resources.IResourceDelta;\r
-import org.eclipse.core.resources.ResourcesPlugin;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;\r
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;\r
-import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal;\r
-import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterListener;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;\r
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.IColorSettingsListener;\r
-import org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartEvent.RankRange;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphSelectionEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.IEditorReference;\r
-\r
-/**\r
- * Generic Time Chart view, which is similar to a Gantt chart for trace analysis\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeChartView extends TmfView implements ITimeGraphRangeListener,\r
-        ITimeGraphSelectionListener, ITimeGraphTimeListener,\r
-        IColorSettingsListener, IResourceChangeListener,\r
-        ITmfEventsFilterListener {\r
-\r
-    /** TimeChartView's ID */\r
-    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$\r
-\r
-    private static final int TIMESTAMP_SCALE = -9;\r
-\r
-    private final int fDisplayWidth;\r
-    private TimeGraphViewer fViewer;\r
-    private final ArrayList<TimeChartAnalysisEntry> fTimeAnalysisEntries = new ArrayList<TimeChartAnalysisEntry>();\r
-    private final Map<ITmfTrace<?>, TimeChartDecorationProvider> fDecorationProviders = new HashMap<ITmfTrace<?>, TimeChartDecorationProvider>();\r
-    private ArrayList<DecorateThread> fDecorateThreads;\r
-    private long fStartTime = 0;\r
-    private long fStopTime = Long.MAX_VALUE;\r
-    private boolean fRefreshBusy = false;\r
-    private boolean fRefreshPending = false;\r
-    private boolean fRedrawBusy = false;\r
-    private boolean fRedrawPending = false;\r
-    private final Object fSyncObj = new Object();\r
-    private ITimeGraphPresentationProvider fPresentationProvider;\r
-\r
-    /**\r
-     * Default constructor\r
-     */\r
-    public TimeChartView() {\r
-        super("Time Chart"); //$NON-NLS-1$\r
-        fDisplayWidth = Display.getDefault().getBounds().width;\r
-    }\r
-\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        fViewer = new TimeGraphViewer(parent, SWT.NONE);\r
-        fPresentationProvider = new TimeChartAnalysisProvider();\r
-        fViewer.setTimeGraphProvider(fPresentationProvider);\r
-        fViewer.setTimeCalendarFormat(true);\r
-        fViewer.addTimeListener(this);\r
-        fViewer.addRangeListener(this);\r
-        fViewer.addSelectionListener(this);\r
-        fViewer.setMinimumItemWidth(1);\r
-\r
-        IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();\r
-        for (IEditorReference editorReference : editorReferences) {\r
-            IEditorPart editor = editorReference.getEditor(false);\r
-            if (editor instanceof ITmfTraceEditor) {\r
-                ITmfTrace<?> trace = ((ITmfTraceEditor) editor).getTrace();\r
-                if (trace != null) {\r
-                    IFile bookmarksFile = ((ITmfTraceEditor) editor).getBookmarksFile();\r
-                    TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);\r
-                    fTimeAnalysisEntries.add(timeAnalysisEntry);\r
-                    fDecorationProviders.put(trace, new TimeChartDecorationProvider(bookmarksFile));\r
-                    Thread thread = new ProcessTraceThread(timeAnalysisEntry);\r
-                    thread.start();\r
-                }\r
-            }\r
-        }\r
-        fViewer.setInput(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));\r
-\r
-        fDecorateThreads = new ArrayList<DecorateThread>();\r
-        ColorSettingsManager.addColorSettingsListener(this);\r
-        ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);\r
-        for (DecorateThread thread : fDecorateThreads) {\r
-            thread.cancel();\r
-        }\r
-        ColorSettingsManager.removeColorSettingsListener(this);\r
-        super.dispose();\r
-    }\r
-\r
-    @Override\r
-    public void setFocus() {\r
-        fViewer.setFocus();\r
-    }\r
-\r
-    private class ProcessTraceThread extends Thread {\r
-\r
-        private final TimeChartAnalysisEntry fTimeAnalysisEntry;\r
-\r
-        public ProcessTraceThread(TimeChartAnalysisEntry timeAnalysisEntry) {\r
-            super("ProcessTraceJob:" + timeAnalysisEntry.getName()); //$NON-NLS-1$\r
-            fTimeAnalysisEntry = timeAnalysisEntry;\r
-        }\r
-\r
-        @Override\r
-        public void run() {\r
-            updateTraceEntry(fTimeAnalysisEntry, Long.MAX_VALUE, 0, Long.MAX_VALUE);\r
-        }\r
-    }\r
-\r
-    private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, long stopRank, long startTime, long stopTime) {\r
-        ITmfTrace<?> trace = timeAnalysisEntry.getTrace();\r
-        TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
-        if (decorationProvider == null) {\r
-            return; // the trace has been closed\r
-        }\r
-        ITmfContext context = null;\r
-        // TmfTimestamp lastTimestamp = null;\r
-        boolean done = false;\r
-        while (!done) {\r
-            synchronized (timeAnalysisEntry) {\r
-                if (timeAnalysisEntry.getLastRank() >= trace.getNbEvents()) {\r
-                    done = true;\r
-                    break;\r
-                }\r
-                if (context == null || context.getRank() != timeAnalysisEntry.getLastRank()) {\r
-                    if (context != null) {\r
-                        context.dispose();\r
-                    }\r
-                    if (timeAnalysisEntry.getLastRank() != -1) {\r
-                        context = trace.seekEvent(timeAnalysisEntry.getLastRank());\r
-                    } else {\r
-                        // context = trace.seekLocation(null);\r
-                        context = trace.seekEvent(0);\r
-                    }\r
-                }\r
-                while (true) {\r
-                    long rank = context.getRank();\r
-                    ITmfEvent event = trace.getNext(context);\r
-                    if (event == null) {\r
-                        done = true;\r
-                        break;\r
-                    }\r
-                    // if (!event.getTimestamp().equals(lastTimestamp)) {\r
-                    TimeChartEvent timeEvent = new TimeChartEvent(timeAnalysisEntry, event, rank, decorationProvider);\r
-                    if (timeEvent.getTime() >= startTime && timeEvent.getTime() <= stopTime) {\r
-                        timeAnalysisEntry.addTraceEvent(timeEvent);\r
-                    }\r
-                    // lastTimestamp = event.getTimestamp();\r
-                    // } *** commented out so that color setting priority gets\r
-                    // set even if the event has same time\r
-                    if (context.getRank() == trace.getNbEvents() || context.getRank() == stopRank) {\r
-                        done = true;\r
-                        break;\r
-                    }\r
-                    if (context.getRank() % trace.getCacheSize() == 1) {\r
-                        // break for UI refresh\r
-                        break;\r
-                    }\r
-                }\r
-                // timeAnalysisEntry.setLastRank(Math.min(trace.getNbEvents(),\r
-                // stopRank));\r
-                timeAnalysisEntry.setLastRank(context.getRank());\r
-            }\r
-            redrawViewer(true);\r
-        }\r
-        if (context != null) {\r
-            context.dispose();\r
-        }\r
-    }\r
-\r
-    private void refreshViewer() {\r
-        synchronized (fSyncObj) {\r
-            if (fRefreshBusy) {\r
-                fRefreshPending = true;\r
-                return;\r
-            }\r
-            fRefreshBusy = true;\r
-        }\r
-        // Perform the refresh on the UI thread\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fViewer.getControl().isDisposed()) {\r
-                    return;\r
-                }\r
-                fViewer.setInput(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));\r
-                fViewer.resetStartFinishTime();\r
-                synchronized (fSyncObj) {\r
-                    fRefreshBusy = false;\r
-                    if (fRefreshPending) {\r
-                        fRefreshPending = false;\r
-                        refreshViewer();\r
-                    }\r
-                }\r
-            }\r
-        });\r
-    }\r
-\r
-    private void redrawViewer(boolean resetTimeIntervals) {\r
-        synchronized (fSyncObj) {\r
-            if (fRedrawBusy) {\r
-                fRedrawPending = true;\r
-                return;\r
-            }\r
-            fRedrawBusy = true;\r
-        }\r
-        final boolean reset = resetTimeIntervals;\r
-        // Perform the refresh on the UI thread\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                if (fViewer.getControl().isDisposed()) {\r
-                    return;\r
-                }\r
-                if (reset) {\r
-                    fViewer.setTimeRange(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));\r
-                    fViewer.setTimeBounds();\r
-                }\r
-                fViewer.getControl().redraw();\r
-                fViewer.getControl().update();\r
-                synchronized (fSyncObj) {\r
-                    fRedrawBusy = false;\r
-                    if (fRedrawPending) {\r
-                        fRedrawPending = false;\r
-                        redrawViewer(reset);\r
-                    }\r
-                }\r
-            }\r
-        });\r
-    }\r
-\r
-    private void itemize(long startTime, long stopTime) {\r
-        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
-            Thread thread = new ItemizeThread(fTimeAnalysisEntries.get(i), startTime, stopTime);\r
-            thread.start();\r
-        }\r
-    }\r
-\r
-    private class ItemizeThread extends Thread {\r
-\r
-        private final TimeChartAnalysisEntry fTimeAnalysisEntry;\r
-        private final long fStartTime;\r
-        private final long fStopTime;\r
-        private final long fMaxDuration;\r
-\r
-        private ItemizeThread(TimeChartAnalysisEntry timeAnalysisEntry, long startTime, long stopTime) {\r
-            super("Itemize Thread:" + timeAnalysisEntry.getName()); //$NON-NLS-1$\r
-            fTimeAnalysisEntry = timeAnalysisEntry;\r
-            fStartTime = startTime;\r
-            fStopTime = stopTime;\r
-            fMaxDuration = 3 * (fStopTime - fStartTime) / fDisplayWidth;\r
-        }\r
-\r
-        @Override\r
-        public void run() {\r
-            itemizeTraceEntry(fTimeAnalysisEntry);\r
-        }\r
-\r
-        public void itemizeTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry) {\r
-            Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTimeEventsIterator();\r
-            TimeChartEvent event = null;\r
-            boolean hasNext = true;\r
-            while (hasNext) {\r
-                synchronized (timeAnalysisEntry) {\r
-                    while (hasNext = iterator.hasNext()) {\r
-                        event = (TimeChartEvent) iterator.next();\r
-                        if (event.getTime() + event.getDuration() > fStartTime && event.getTime() < fStopTime && event.getDuration() > fMaxDuration\r
-                                && event.getNbEvents() > 1) {\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-                if (hasNext) {\r
-                    if (event.getItemizedEntry() == null) {\r
-                        itemizeEvent(event);\r
-                    } else {\r
-                        itemizeTraceEntry(event.getItemizedEntry());\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        public void itemizeEvent(TimeChartEvent event) {\r
-            synchronized (event) {\r
-                if (event.isItemizing()) {\r
-                    return;\r
-                }\r
-                event.setItemizing(true);\r
-            }\r
-            TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(fTimeAnalysisEntry.getTrace(), (int) Math.min(\r
-                    event.getNbEvents() + 1, fDisplayWidth * 2));\r
-            synchronized (event.getRankRangeList()) {\r
-                for (RankRange range : event.getRankRangeList()) {\r
-                    timeAnalysisEntry.setLastRank(range.getFirstRank());\r
-                    updateTraceEntry(timeAnalysisEntry, range.getLastRank() + 1, event.getTime(), event.getTime() + event.getDuration());\r
-                }\r
-            }\r
-            event.setItemizedEntry(timeAnalysisEntry);\r
-            redrawViewer(false);\r
-            itemizeTraceEntry(timeAnalysisEntry);\r
-            synchronized (event) {\r
-                event.setItemizing(false);\r
-            }\r
-        }\r
-    }\r
-\r
-    private void redecorate() {\r
-        synchronized (fDecorateThreads) {\r
-            for (DecorateThread thread : fDecorateThreads) {\r
-                thread.cancel();\r
-            }\r
-            fDecorateThreads.clear();\r
-            for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
-                DecorateThread thread = new DecorateThread(fTimeAnalysisEntries.get(i));\r
-                thread.start();\r
-                fDecorateThreads.add(thread);\r
-            }\r
-        }\r
-    }\r
-\r
-    private class DecorateThread extends Thread {\r
-        private volatile boolean interrupted = false;\r
-        private final TimeChartAnalysisEntry fTimeAnalysisEntry;\r
-        private final TimeChartDecorationProvider fDecorationProvider;\r
-        private ITmfContext fContext;\r
-        private int fCount = 0;\r
-\r
-        private DecorateThread(TimeChartAnalysisEntry timeAnalysisEntry) {\r
-            super("Decorate Thread:" + timeAnalysisEntry.getName()); //$NON-NLS-1$\r
-            fTimeAnalysisEntry = timeAnalysisEntry;\r
-            fDecorationProvider = fDecorationProviders.get(timeAnalysisEntry.getTrace());\r
-        }\r
-\r
-        @Override\r
-        public void run() {\r
-            resetTraceEntry(fTimeAnalysisEntry);\r
-            redrawViewer(false);\r
-            decorateTraceEntry(fTimeAnalysisEntry, null);\r
-            redrawViewer(false);\r
-            synchronized (fDecorateThreads) {\r
-                fDecorateThreads.remove(this);\r
-            }\r
-            if (fContext != null) {\r
-               fContext.dispose();\r
-            }\r
-        }\r
-\r
-        public void resetTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry) {\r
-            Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTimeEventsIterator();\r
-            TimeChartEvent event = null;\r
-            boolean hasNext = true;\r
-            while (!interrupted && hasNext) {\r
-                synchronized (timeAnalysisEntry) {\r
-                    while (hasNext = iterator.hasNext()) {\r
-                        event = (TimeChartEvent) iterator.next();\r
-                        break;\r
-                    }\r
-                }\r
-                if (hasNext) {\r
-                    // TODO possible concurrency problem here with ItemizeJob\r
-                    event.setColorSettingPriority(ColorSettingsManager.PRIORITY_NONE);\r
-                    if (event.getItemizedEntry() != null) {\r
-                        resetTraceEntry(event.getItemizedEntry());\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        public void decorateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, TimeChartEvent parentEvent) {\r
-            // Set max duration high to ensure iterator does not consider\r
-            // itemized events\r
-            Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTimeEventsIterator(0, Long.MAX_VALUE, Long.MAX_VALUE);\r
-            TimeChartEvent event = null;\r
-            int entryPriority = ColorSettingsManager.PRIORITY_NONE;\r
-            boolean entryIsBookmarked = false;\r
-            boolean entryIsVisible = false;\r
-            boolean entryIsSearchMatch = false;\r
-            boolean hasNext = true;\r
-            while (!interrupted && hasNext) {\r
-                synchronized (timeAnalysisEntry) {\r
-                    while (hasNext = iterator.hasNext()) {\r
-                        event = (TimeChartEvent) iterator.next();\r
-                        break;\r
-                    }\r
-                }\r
-                if (hasNext) {\r
-                    // TODO possible concurrency problem here with ItemizeJob\r
-                    if (event.getItemizedEntry() == null) {\r
-                        decorateEvent(event);\r
-                    } else {\r
-                        decorateTraceEntry(event.getItemizedEntry(), event);\r
-                    }\r
-                    entryPriority = Math.min(entryPriority, event.getColorSettingPriority());\r
-                    entryIsBookmarked |= event.isBookmarked();\r
-                    entryIsVisible |= event.isVisible();\r
-                    entryIsSearchMatch |= event.isSearchMatch();\r
-                    if (++fCount % timeAnalysisEntry.getTrace().getCacheSize() == 0) {\r
-                        redrawViewer(false);\r
-                    }\r
-                }\r
-            }\r
-            if (parentEvent != null) {\r
-                parentEvent.setColorSettingPriority(entryPriority);\r
-                parentEvent.setIsBookmarked(entryIsBookmarked);\r
-                parentEvent.setIsVisible(entryIsVisible);\r
-                parentEvent.setIsSearchMatch(entryIsSearchMatch);\r
-            }\r
-        }\r
-\r
-        public void decorateEvent(TimeChartEvent timeChartEvent) {\r
-            // TODO possible concurrency problem here with ItemizeJob\r
-            TimeChartAnalysisEntry timeAnalysisEntry = (TimeChartAnalysisEntry) timeChartEvent.getEntry();\r
-            ITmfTrace<?> trace = timeAnalysisEntry.getTrace();\r
-            int priority = ColorSettingsManager.PRIORITY_NONE;\r
-            boolean isBookmarked = false;\r
-            boolean isVisible = false;\r
-            boolean isSearchMatch = false;\r
-            synchronized (timeChartEvent.getRankRangeList()) {\r
-                for (RankRange range : timeChartEvent.getRankRangeList()) {\r
-                    if (interrupted) {\r
-                        return;\r
-                    }\r
-                    if (fContext == null || fContext.getRank() != range.getFirstRank()) {\r
-                        if (fContext != null) {\r
-                               fContext.dispose();\r
-                        }\r
-                        fContext = trace.seekEvent(range.getFirstRank());\r
-                        fContext.setRank(range.getFirstRank());\r
-                    }\r
-                    while (true) {\r
-                        if (interrupted) {\r
-                            return;\r
-                        }\r
-                        long rank = fContext.getRank();\r
-                        ITmfEvent event = trace.getNext(fContext);\r
-                        if (event == null) {\r
-                            break;\r
-                        }\r
-                        long eventTime = event.getTimestamp().normalize(0, -9).getValue();\r
-                        if (eventTime >= timeChartEvent.getTime() && eventTime <= timeChartEvent.getTime() + timeChartEvent.getDuration()) {\r
-                            priority = Math.min(priority, ColorSettingsManager.getColorSettingPriority(event));\r
-                        }\r
-                        isBookmarked |= fDecorationProvider.isBookmark(rank);\r
-                        isVisible |= fDecorationProvider.isVisible(event);\r
-                        isSearchMatch |= fDecorationProvider.isSearchMatch(event);\r
-                        if (fContext.getRank() > range.getLastRank()) {\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            timeChartEvent.setColorSettingPriority(priority);\r
-            timeChartEvent.setIsBookmarked(isBookmarked);\r
-            timeChartEvent.setIsVisible(isVisible);\r
-            timeChartEvent.setIsSearchMatch(isSearchMatch);\r
-        }\r
-\r
-        public void cancel() {\r
-            interrupted = true;\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Listeners\r
-    // ------------------------------------------------------------------------\r
-\r
-    @Override\r
-    public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {\r
-        fStartTime = event.getStartTime();\r
-        fStopTime = event.getEndTime();\r
-        itemize(fStartTime, fStopTime);\r
-    }\r
-\r
-    @Override\r
-    public void selectionChanged(TimeGraphSelectionEvent event) {\r
-        ITimeGraphEntry timeAnalysisEntry = null;\r
-        if (event.getSelection() instanceof TimeChartAnalysisEntry) {\r
-            timeAnalysisEntry = event.getSelection();\r
-        } else if (event.getSelection() instanceof TimeChartEvent) {\r
-            timeAnalysisEntry = ((TimeChartEvent) event.getSelection()).getEntry();\r
-        }\r
-        if (timeAnalysisEntry instanceof TimeChartAnalysisEntry) {\r
-            broadcast(new TmfTraceSelectedSignal(this, ((TimeChartAnalysisEntry) timeAnalysisEntry).getTrace()));\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void timeSelected(TimeGraphTimeEvent event) {\r
-        broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event.getTime(), TIMESTAMP_SCALE)));\r
-    }\r
-\r
-    @Override\r
-    public void colorSettingsChanged(ColorSetting[] colorSettings) {\r
-        // Set presentation provider again to trigger re-creation of new color settings which are stored\r
-        // in the TimeGraphControl class\r
-        fViewer.setTimeGraphProvider(fPresentationProvider);\r
-        redecorate();\r
-    }\r
-\r
-    @Override\r
-    public void resourceChanged(IResourceChangeEvent event) {\r
-        for (IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {\r
-            for (TimeChartDecorationProvider provider : fDecorationProviders.values()) {\r
-                if (delta.getResource().equals(provider.getBookmarksFile())) {\r
-                    if (delta.getKind() == IResourceDelta.CHANGED && delta.getMarker().getAttribute(IMarker.LOCATION, -1) != -1) {\r
-                        provider.refreshBookmarks();\r
-                    } else if (delta.getKind() == IResourceDelta.REMOVED) {\r
-                        provider.refreshBookmarks();\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        redecorate();\r
-    }\r
-\r
-    @Override\r
-    public void filterApplied(ITmfFilter filter, ITmfTrace<?> trace) {\r
-        TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
-        decorationProvider.filterApplied(filter);\r
-        redecorate();\r
-    }\r
-\r
-    @Override\r
-    public void searchApplied(ITmfFilter filter, ITmfTrace<?> trace) {\r
-        TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
-        decorationProvider.searchApplied(filter);\r
-        redecorate();\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Signal handlers\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Handler for the Trace Opened signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void traceOpened(TmfTraceOpenedSignal signal) {\r
-        if (fTimeAnalysisEntries == null) {\r
-            return;\r
-        }\r
-        final ITmfTrace<?> trace = signal.getTrace();\r
-        final IFile bookmarksFile = signal.getBookmarksFile();\r
-        final ITmfEventsFilterProvider eventsFilterProvider = signal.getEventsFilterProvider();\r
-        TimeChartAnalysisEntry timeAnalysisEntry = null;\r
-        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
-            if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
-                timeAnalysisEntry = fTimeAnalysisEntries.get(i);\r
-                break;\r
-            }\r
-        }\r
-        if (timeAnalysisEntry == null) {\r
-            timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);\r
-            fTimeAnalysisEntries.add(timeAnalysisEntry);\r
-            fDecorationProviders.put(trace, new TimeChartDecorationProvider(bookmarksFile));\r
-            Thread thread = new ProcessTraceThread(timeAnalysisEntry);\r
-            thread.start();\r
-        }\r
-        refreshViewer();\r
-        if (eventsFilterProvider != null) {\r
-            eventsFilterProvider.addEventsFilterListener(this);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Handler for the Trace Closed signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void traceClosed(TmfTraceClosedSignal signal) {\r
-        if (fTimeAnalysisEntries == null) {\r
-            return;\r
-        }\r
-        final ITmfTrace<?> trace = signal.getTrace();\r
-        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
-            if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
-                fTimeAnalysisEntries.remove(i);\r
-                fDecorationProviders.remove(trace);\r
-                refreshViewer();\r
-                break;\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Handler for the Trace Selected signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void traceSelected(TmfTraceSelectedSignal signal) {\r
-        if (signal.getSource() != this && fTimeAnalysisEntries != null) {\r
-            ITmfTrace<?> trace = signal.getTrace();\r
-            for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
-                if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
-                    fViewer.setSelection(fTimeAnalysisEntries.get(i));\r
-                    break;\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Handler for the Trace Updated signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void traceUpdated(TmfTraceUpdatedSignal signal) {\r
-        if (fTimeAnalysisEntries == null) {\r
-            return;\r
-        }\r
-        final ITmfTrace<?> trace = signal.getTrace();\r
-        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
-            TimeChartAnalysisEntry timeAnalysisEntry = fTimeAnalysisEntries.get(i);\r
-            if (timeAnalysisEntry.getTrace().equals(trace)) {\r
-                updateTraceEntry(timeAnalysisEntry, Long.MAX_VALUE, 0, Long.MAX_VALUE);\r
-                break;\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Handler for the Time Synch signal\r
-     *\r
-     * @param signal\r
-     *            The incoming signal\r
-     */\r
-    @TmfSignalHandler\r
-    public void currentTimeUpdated(TmfTimeSynchSignal signal) {\r
-        final long time = signal.getCurrentTime().normalize(0, TIMESTAMP_SCALE).getValue();\r
-        Display.getDefault().asyncExec(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                fViewer.setSelectedTime(time, true);\r
-            }\r
-        });\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal;
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterListener;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;
+import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
+import org.eclipse.linuxtools.tmf.ui.views.colors.IColorSettingsListener;
+import org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartEvent.RankRange;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphSelectionEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+
+/**
+ * Generic Time Chart view, which is similar to a Gantt chart for trace analysis
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartView extends TmfView implements ITimeGraphRangeListener,
+        ITimeGraphSelectionListener, ITimeGraphTimeListener,
+        IColorSettingsListener, IResourceChangeListener,
+        ITmfEventsFilterListener {
+
+    /** TimeChartView's ID */
+    public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$
+
+    private static final int TIMESTAMP_SCALE = -9;
+
+    private final int fDisplayWidth;
+    private TimeGraphViewer fViewer;
+    private final ArrayList<TimeChartAnalysisEntry> fTimeAnalysisEntries = new ArrayList<TimeChartAnalysisEntry>();
+    private final Map<ITmfTrace<?>, TimeChartDecorationProvider> fDecorationProviders = new HashMap<ITmfTrace<?>, TimeChartDecorationProvider>();
+    private ArrayList<DecorateThread> fDecorateThreads;
+    private long fStartTime = 0;
+    private long fStopTime = Long.MAX_VALUE;
+    private boolean fRefreshBusy = false;
+    private boolean fRefreshPending = false;
+    private boolean fRedrawBusy = false;
+    private boolean fRedrawPending = false;
+    private final Object fSyncObj = new Object();
+    private ITimeGraphPresentationProvider fPresentationProvider;
+
+    /**
+     * Default constructor
+     */
+    public TimeChartView() {
+        super("Time Chart"); //$NON-NLS-1$
+        fDisplayWidth = Display.getDefault().getBounds().width;
+    }
+
+    @Override
+    public void createPartControl(Composite parent) {
+        fViewer = new TimeGraphViewer(parent, SWT.NONE);
+        fPresentationProvider = new TimeChartAnalysisProvider();
+        fViewer.setTimeGraphProvider(fPresentationProvider);
+        fViewer.setTimeCalendarFormat(true);
+        fViewer.addTimeListener(this);
+        fViewer.addRangeListener(this);
+        fViewer.addSelectionListener(this);
+        fViewer.setMinimumItemWidth(1);
+
+        IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
+        for (IEditorReference editorReference : editorReferences) {
+            IEditorPart editor = editorReference.getEditor(false);
+            if (editor instanceof ITmfTraceEditor) {
+                ITmfTrace<?> trace = ((ITmfTraceEditor) editor).getTrace();
+                if (trace != null) {
+                    IFile bookmarksFile = ((ITmfTraceEditor) editor).getBookmarksFile();
+                    TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);
+                    fTimeAnalysisEntries.add(timeAnalysisEntry);
+                    fDecorationProviders.put(trace, new TimeChartDecorationProvider(bookmarksFile));
+                    Thread thread = new ProcessTraceThread(timeAnalysisEntry);
+                    thread.start();
+                }
+            }
+        }
+        fViewer.setInput(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));
+
+        fDecorateThreads = new ArrayList<DecorateThread>();
+        ColorSettingsManager.addColorSettingsListener(this);
+        ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+    }
+
+    @Override
+    public void dispose() {
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+        for (DecorateThread thread : fDecorateThreads) {
+            thread.cancel();
+        }
+        ColorSettingsManager.removeColorSettingsListener(this);
+        super.dispose();
+    }
+
+    @Override
+    public void setFocus() {
+        fViewer.setFocus();
+    }
+
+    private class ProcessTraceThread extends Thread {
+
+        private final TimeChartAnalysisEntry fTimeAnalysisEntry;
+
+        public ProcessTraceThread(TimeChartAnalysisEntry timeAnalysisEntry) {
+            super("ProcessTraceJob:" + timeAnalysisEntry.getName()); //$NON-NLS-1$
+            fTimeAnalysisEntry = timeAnalysisEntry;
+        }
+
+        @Override
+        public void run() {
+            updateTraceEntry(fTimeAnalysisEntry, Long.MAX_VALUE, 0, Long.MAX_VALUE);
+        }
+    }
+
+    private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, long stopRank, long startTime, long stopTime) {
+        ITmfTrace<?> trace = timeAnalysisEntry.getTrace();
+        TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);
+        if (decorationProvider == null) {
+            return; // the trace has been closed
+        }
+        ITmfContext context = null;
+        // TmfTimestamp lastTimestamp = null;
+        boolean done = false;
+        while (!done) {
+            synchronized (timeAnalysisEntry) {
+                if (timeAnalysisEntry.getLastRank() >= trace.getNbEvents()) {
+                    done = true;
+                    break;
+                }
+                if (context == null || context.getRank() != timeAnalysisEntry.getLastRank()) {
+                    if (context != null) {
+                        context.dispose();
+                    }
+                    if (timeAnalysisEntry.getLastRank() != -1) {
+                        context = trace.seekEvent(timeAnalysisEntry.getLastRank());
+                    } else {
+                        // context = trace.seekLocation(null);
+                        context = trace.seekEvent(0);
+                    }
+                }
+                while (true) {
+                    long rank = context.getRank();
+                    ITmfEvent event = trace.getNext(context);
+                    if (event == null) {
+                        done = true;
+                        break;
+                    }
+                    // if (!event.getTimestamp().equals(lastTimestamp)) {
+                    TimeChartEvent timeEvent = new TimeChartEvent(timeAnalysisEntry, event, rank, decorationProvider);
+                    if (timeEvent.getTime() >= startTime && timeEvent.getTime() <= stopTime) {
+                        timeAnalysisEntry.addTraceEvent(timeEvent);
+                    }
+                    // lastTimestamp = event.getTimestamp();
+                    // } *** commented out so that color setting priority gets
+                    // set even if the event has same time
+                    if (context.getRank() == trace.getNbEvents() || context.getRank() == stopRank) {
+                        done = true;
+                        break;
+                    }
+                    if (context.getRank() % trace.getCacheSize() == 1) {
+                        // break for UI refresh
+                        break;
+                    }
+                }
+                // timeAnalysisEntry.setLastRank(Math.min(trace.getNbEvents(),
+                // stopRank));
+                timeAnalysisEntry.setLastRank(context.getRank());
+            }
+            redrawViewer(true);
+        }
+        if (context != null) {
+            context.dispose();
+        }
+    }
+
+    private void refreshViewer() {
+        synchronized (fSyncObj) {
+            if (fRefreshBusy) {
+                fRefreshPending = true;
+                return;
+            }
+            fRefreshBusy = true;
+        }
+        // Perform the refresh on the UI thread
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fViewer.getControl().isDisposed()) {
+                    return;
+                }
+                fViewer.setInput(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));
+                fViewer.resetStartFinishTime();
+                synchronized (fSyncObj) {
+                    fRefreshBusy = false;
+                    if (fRefreshPending) {
+                        fRefreshPending = false;
+                        refreshViewer();
+                    }
+                }
+            }
+        });
+    }
+
+    private void redrawViewer(boolean resetTimeIntervals) {
+        synchronized (fSyncObj) {
+            if (fRedrawBusy) {
+                fRedrawPending = true;
+                return;
+            }
+            fRedrawBusy = true;
+        }
+        final boolean reset = resetTimeIntervals;
+        // Perform the refresh on the UI thread
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                if (fViewer.getControl().isDisposed()) {
+                    return;
+                }
+                if (reset) {
+                    fViewer.setTimeRange(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0]));
+                    fViewer.setTimeBounds();
+                }
+                fViewer.getControl().redraw();
+                fViewer.getControl().update();
+                synchronized (fSyncObj) {
+                    fRedrawBusy = false;
+                    if (fRedrawPending) {
+                        fRedrawPending = false;
+                        redrawViewer(reset);
+                    }
+                }
+            }
+        });
+    }
+
+    private void itemize(long startTime, long stopTime) {
+        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
+            Thread thread = new ItemizeThread(fTimeAnalysisEntries.get(i), startTime, stopTime);
+            thread.start();
+        }
+    }
+
+    private class ItemizeThread extends Thread {
+
+        private final TimeChartAnalysisEntry fTimeAnalysisEntry;
+        private final long fStartTime;
+        private final long fStopTime;
+        private final long fMaxDuration;
+
+        private ItemizeThread(TimeChartAnalysisEntry timeAnalysisEntry, long startTime, long stopTime) {
+            super("Itemize Thread:" + timeAnalysisEntry.getName()); //$NON-NLS-1$
+            fTimeAnalysisEntry = timeAnalysisEntry;
+            fStartTime = startTime;
+            fStopTime = stopTime;
+            fMaxDuration = 3 * (fStopTime - fStartTime) / fDisplayWidth;
+        }
+
+        @Override
+        public void run() {
+            itemizeTraceEntry(fTimeAnalysisEntry);
+        }
+
+        public void itemizeTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry) {
+            Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTimeEventsIterator();
+            TimeChartEvent event = null;
+            boolean hasNext = true;
+            while (hasNext) {
+                synchronized (timeAnalysisEntry) {
+                    while (hasNext = iterator.hasNext()) {
+                        event = (TimeChartEvent) iterator.next();
+                        if (event.getTime() + event.getDuration() > fStartTime && event.getTime() < fStopTime && event.getDuration() > fMaxDuration
+                                && event.getNbEvents() > 1) {
+                            break;
+                        }
+                    }
+                }
+                if (hasNext) {
+                    if (event.getItemizedEntry() == null) {
+                        itemizeEvent(event);
+                    } else {
+                        itemizeTraceEntry(event.getItemizedEntry());
+                    }
+                }
+            }
+        }
+
+        public void itemizeEvent(TimeChartEvent event) {
+            synchronized (event) {
+                if (event.isItemizing()) {
+                    return;
+                }
+                event.setItemizing(true);
+            }
+            TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(fTimeAnalysisEntry.getTrace(), (int) Math.min(
+                    event.getNbEvents() + 1, fDisplayWidth * 2));
+            synchronized (event.getRankRangeList()) {
+                for (RankRange range : event.getRankRangeList()) {
+                    timeAnalysisEntry.setLastRank(range.getFirstRank());
+                    updateTraceEntry(timeAnalysisEntry, range.getLastRank() + 1, event.getTime(), event.getTime() + event.getDuration());
+                }
+            }
+            event.setItemizedEntry(timeAnalysisEntry);
+            redrawViewer(false);
+            itemizeTraceEntry(timeAnalysisEntry);
+            synchronized (event) {
+                event.setItemizing(false);
+            }
+        }
+    }
+
+    private void redecorate() {
+        synchronized (fDecorateThreads) {
+            for (DecorateThread thread : fDecorateThreads) {
+                thread.cancel();
+            }
+            fDecorateThreads.clear();
+            for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
+                DecorateThread thread = new DecorateThread(fTimeAnalysisEntries.get(i));
+                thread.start();
+                fDecorateThreads.add(thread);
+            }
+        }
+    }
+
+    private class DecorateThread extends Thread {
+        private volatile boolean interrupted = false;
+        private final TimeChartAnalysisEntry fTimeAnalysisEntry;
+        private final TimeChartDecorationProvider fDecorationProvider;
+        private ITmfContext fContext;
+        private int fCount = 0;
+
+        private DecorateThread(TimeChartAnalysisEntry timeAnalysisEntry) {
+            super("Decorate Thread:" + timeAnalysisEntry.getName()); //$NON-NLS-1$
+            fTimeAnalysisEntry = timeAnalysisEntry;
+            fDecorationProvider = fDecorationProviders.get(timeAnalysisEntry.getTrace());
+        }
+
+        @Override
+        public void run() {
+            resetTraceEntry(fTimeAnalysisEntry);
+            redrawViewer(false);
+            decorateTraceEntry(fTimeAnalysisEntry, null);
+            redrawViewer(false);
+            synchronized (fDecorateThreads) {
+                fDecorateThreads.remove(this);
+            }
+            if (fContext != null) {
+               fContext.dispose();
+            }
+        }
+
+        public void resetTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry) {
+            Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTimeEventsIterator();
+            TimeChartEvent event = null;
+            boolean hasNext = true;
+            while (!interrupted && hasNext) {
+                synchronized (timeAnalysisEntry) {
+                    while (hasNext = iterator.hasNext()) {
+                        event = (TimeChartEvent) iterator.next();
+                        break;
+                    }
+                }
+                if (hasNext) {
+                    // TODO possible concurrency problem here with ItemizeJob
+                    event.setColorSettingPriority(ColorSettingsManager.PRIORITY_NONE);
+                    if (event.getItemizedEntry() != null) {
+                        resetTraceEntry(event.getItemizedEntry());
+                    }
+                }
+            }
+        }
+
+        public void decorateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, TimeChartEvent parentEvent) {
+            // Set max duration high to ensure iterator does not consider
+            // itemized events
+            Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTimeEventsIterator(0, Long.MAX_VALUE, Long.MAX_VALUE);
+            TimeChartEvent event = null;
+            int entryPriority = ColorSettingsManager.PRIORITY_NONE;
+            boolean entryIsBookmarked = false;
+            boolean entryIsVisible = false;
+            boolean entryIsSearchMatch = false;
+            boolean hasNext = true;
+            while (!interrupted && hasNext) {
+                synchronized (timeAnalysisEntry) {
+                    while (hasNext = iterator.hasNext()) {
+                        event = (TimeChartEvent) iterator.next();
+                        break;
+                    }
+                }
+                if (hasNext) {
+                    // TODO possible concurrency problem here with ItemizeJob
+                    if (event.getItemizedEntry() == null) {
+                        decorateEvent(event);
+                    } else {
+                        decorateTraceEntry(event.getItemizedEntry(), event);
+                    }
+                    entryPriority = Math.min(entryPriority, event.getColorSettingPriority());
+                    entryIsBookmarked |= event.isBookmarked();
+                    entryIsVisible |= event.isVisible();
+                    entryIsSearchMatch |= event.isSearchMatch();
+                    if (++fCount % timeAnalysisEntry.getTrace().getCacheSize() == 0) {
+                        redrawViewer(false);
+                    }
+                }
+            }
+            if (parentEvent != null) {
+                parentEvent.setColorSettingPriority(entryPriority);
+                parentEvent.setIsBookmarked(entryIsBookmarked);
+                parentEvent.setIsVisible(entryIsVisible);
+                parentEvent.setIsSearchMatch(entryIsSearchMatch);
+            }
+        }
+
+        public void decorateEvent(TimeChartEvent timeChartEvent) {
+            // TODO possible concurrency problem here with ItemizeJob
+            TimeChartAnalysisEntry timeAnalysisEntry = (TimeChartAnalysisEntry) timeChartEvent.getEntry();
+            ITmfTrace<?> trace = timeAnalysisEntry.getTrace();
+            int priority = ColorSettingsManager.PRIORITY_NONE;
+            boolean isBookmarked = false;
+            boolean isVisible = false;
+            boolean isSearchMatch = false;
+            synchronized (timeChartEvent.getRankRangeList()) {
+                for (RankRange range : timeChartEvent.getRankRangeList()) {
+                    if (interrupted) {
+                        return;
+                    }
+                    if (fContext == null || fContext.getRank() != range.getFirstRank()) {
+                        if (fContext != null) {
+                               fContext.dispose();
+                        }
+                        fContext = trace.seekEvent(range.getFirstRank());
+                        fContext.setRank(range.getFirstRank());
+                    }
+                    while (true) {
+                        if (interrupted) {
+                            return;
+                        }
+                        long rank = fContext.getRank();
+                        ITmfEvent event = trace.getNext(fContext);
+                        if (event == null) {
+                            break;
+                        }
+                        long eventTime = event.getTimestamp().normalize(0, -9).getValue();
+                        if (eventTime >= timeChartEvent.getTime() && eventTime <= timeChartEvent.getTime() + timeChartEvent.getDuration()) {
+                            priority = Math.min(priority, ColorSettingsManager.getColorSettingPriority(event));
+                        }
+                        isBookmarked |= fDecorationProvider.isBookmark(rank);
+                        isVisible |= fDecorationProvider.isVisible(event);
+                        isSearchMatch |= fDecorationProvider.isSearchMatch(event);
+                        if (fContext.getRank() > range.getLastRank()) {
+                            break;
+                        }
+                    }
+                }
+            }
+            timeChartEvent.setColorSettingPriority(priority);
+            timeChartEvent.setIsBookmarked(isBookmarked);
+            timeChartEvent.setIsVisible(isVisible);
+            timeChartEvent.setIsSearchMatch(isSearchMatch);
+        }
+
+        public void cancel() {
+            interrupted = true;
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Listeners
+    // ------------------------------------------------------------------------
+
+    @Override
+    public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
+        fStartTime = event.getStartTime();
+        fStopTime = event.getEndTime();
+        itemize(fStartTime, fStopTime);
+    }
+
+    @Override
+    public void selectionChanged(TimeGraphSelectionEvent event) {
+        ITimeGraphEntry timeAnalysisEntry = null;
+        if (event.getSelection() instanceof TimeChartAnalysisEntry) {
+            timeAnalysisEntry = event.getSelection();
+        } else if (event.getSelection() instanceof TimeChartEvent) {
+            timeAnalysisEntry = ((TimeChartEvent) event.getSelection()).getEntry();
+        }
+        if (timeAnalysisEntry instanceof TimeChartAnalysisEntry) {
+            broadcast(new TmfTraceSelectedSignal(this, ((TimeChartAnalysisEntry) timeAnalysisEntry).getTrace()));
+        }
+    }
+
+    @Override
+    public void timeSelected(TimeGraphTimeEvent event) {
+        broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event.getTime(), TIMESTAMP_SCALE)));
+    }
+
+    @Override
+    public void colorSettingsChanged(ColorSetting[] colorSettings) {
+        // Set presentation provider again to trigger re-creation of new color settings which are stored
+        // in the TimeGraphControl class
+        fViewer.setTimeGraphProvider(fPresentationProvider);
+        redecorate();
+    }
+
+    @Override
+    public void resourceChanged(IResourceChangeEvent event) {
+        for (IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
+            for (TimeChartDecorationProvider provider : fDecorationProviders.values()) {
+                if (delta.getResource().equals(provider.getBookmarksFile())) {
+                    if (delta.getKind() == IResourceDelta.CHANGED && delta.getMarker().getAttribute(IMarker.LOCATION, -1) != -1) {
+                        provider.refreshBookmarks();
+                    } else if (delta.getKind() == IResourceDelta.REMOVED) {
+                        provider.refreshBookmarks();
+                    }
+                }
+            }
+        }
+        redecorate();
+    }
+
+    @Override
+    public void filterApplied(ITmfFilter filter, ITmfTrace<?> trace) {
+        TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);
+        decorationProvider.filterApplied(filter);
+        redecorate();
+    }
+
+    @Override
+    public void searchApplied(ITmfFilter filter, ITmfTrace<?> trace) {
+        TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);
+        decorationProvider.searchApplied(filter);
+        redecorate();
+    }
+
+    // ------------------------------------------------------------------------
+    // Signal handlers
+    // ------------------------------------------------------------------------
+
+    /**
+     * Handler for the Trace Opened signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void traceOpened(TmfTraceOpenedSignal signal) {
+        if (fTimeAnalysisEntries == null) {
+            return;
+        }
+        final ITmfTrace<?> trace = signal.getTrace();
+        final IFile bookmarksFile = signal.getBookmarksFile();
+        final ITmfEventsFilterProvider eventsFilterProvider = signal.getEventsFilterProvider();
+        TimeChartAnalysisEntry timeAnalysisEntry = null;
+        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
+            if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {
+                timeAnalysisEntry = fTimeAnalysisEntries.get(i);
+                break;
+            }
+        }
+        if (timeAnalysisEntry == null) {
+            timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);
+            fTimeAnalysisEntries.add(timeAnalysisEntry);
+            fDecorationProviders.put(trace, new TimeChartDecorationProvider(bookmarksFile));
+            Thread thread = new ProcessTraceThread(timeAnalysisEntry);
+            thread.start();
+        }
+        refreshViewer();
+        if (eventsFilterProvider != null) {
+            eventsFilterProvider.addEventsFilterListener(this);
+        }
+    }
+
+    /**
+     * Handler for the Trace Closed signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void traceClosed(TmfTraceClosedSignal signal) {
+        if (fTimeAnalysisEntries == null) {
+            return;
+        }
+        final ITmfTrace<?> trace = signal.getTrace();
+        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
+            if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {
+                fTimeAnalysisEntries.remove(i);
+                fDecorationProviders.remove(trace);
+                refreshViewer();
+                break;
+            }
+        }
+    }
+
+    /**
+     * Handler for the Trace Selected signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void traceSelected(TmfTraceSelectedSignal signal) {
+        if (signal.getSource() != this && fTimeAnalysisEntries != null) {
+            ITmfTrace<?> trace = signal.getTrace();
+            for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
+                if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {
+                    fViewer.setSelection(fTimeAnalysisEntries.get(i));
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * Handler for the Trace Updated signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void traceUpdated(TmfTraceUpdatedSignal signal) {
+        if (fTimeAnalysisEntries == null) {
+            return;
+        }
+        final ITmfTrace<?> trace = signal.getTrace();
+        for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
+            TimeChartAnalysisEntry timeAnalysisEntry = fTimeAnalysisEntries.get(i);
+            if (timeAnalysisEntry.getTrace().equals(trace)) {
+                updateTraceEntry(timeAnalysisEntry, Long.MAX_VALUE, 0, Long.MAX_VALUE);
+                break;
+            }
+        }
+    }
+
+    /**
+     * Handler for the Time Synch signal
+     *
+     * @param signal
+     *            The incoming signal
+     */
+    @TmfSignalHandler
+    public void currentTimeUpdated(TmfTimeSynchSignal signal) {
+        final long time = signal.getCurrentTime().normalize(0, TIMESTAMP_SCALE).getValue();
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                fViewer.setSelectedTime(time, true);
+            }
+        });
+    }
+
+}
index 2ee72aee175ca1c51b8bcac721eff04d63e0c099..d8c6815de28b0ea14f0ba14780457a0674048981 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- ******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.rawviewer;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.CaretEvent;\r
-import org.eclipse.swt.custom.CaretListener;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.custom.StyledText;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.events.ControlListener;\r
-import org.eclipse.swt.events.KeyEvent;\r
-import org.eclipse.swt.events.KeyListener;\r
-import org.eclipse.swt.events.MouseAdapter;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseMoveListener;\r
-import org.eclipse.swt.events.MouseTrackListener;\r
-import org.eclipse.swt.events.MouseWheelListener;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Listener;\r
-import org.eclipse.swt.widgets.Menu;\r
-import org.eclipse.swt.widgets.Slider;\r
-\r
-/**\r
- * TmfRawEventViewer allows for the display of the raw data for an arbitrarily\r
- * large number of TMF events.\r
- * \r
- * It is essentially a Composite of a StyledText area and a Slider, where the number\r
- * of visible lines in the StyledText control is set to fill the viewer display area.\r
- * An underlying data model is used to store a cache of event raw text line data.\r
- * The slider is ratio-based.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TmfRawEventViewer extends Composite implements ControlListener, SelectionListener,\r
-                KeyListener, CaretListener, MouseMoveListener, MouseTrackListener, MouseWheelListener {\r
-\r
-    private static final Color COLOR_BACKGROUND_ODD = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);\r
-    private static final Color COLOR_BACKGROUND_EVEN = new Color(Display.getDefault(), 242, 242, 242);\r
-    private static final Color COLOR_BACKGROUND_SELECTED = new Color(Display.getDefault(), 231, 246, 254);\r
-    private static final Color COLOR_BACKGROUND_HIGHLIGHTED = new Color(Display.getDefault(), 246, 252, 255);\r
-    private static final int MAX_LINE_DATA_SIZE = 1000;\r
-    private static final int SLIDER_MAX = 1000000;\r
-\r
-    private ITmfTrace<?> fTrace;\r
-    private ITmfContext fBottomContext;\r
-    \r
-    private ScrolledComposite fScrolledComposite;\r
-    private Composite fTextArea;\r
-    private StyledText fStyledText;\r
-    private Font fFixedFont;\r
-       private Slider fSlider;\r
-\r
-       private List<LineData> fLines = new ArrayList<LineData>();\r
-       private boolean fActualRanks = false;\r
-       private int fTopLineIndex;\r
-       private int fLastTopLineIndex;\r
-       private CaretPosition[] fStoredCaretPosition = new CaretPosition[]\r
-                   { new CaretPosition(0, 0), new CaretPosition(0,0)};\r
-       private int fNumVisibleLines;\r
-    private ITmfLocation<?> fSelectedLocation = null;\r
-    private long fHighlightedRank = Long.MIN_VALUE;\r
-    private int fCursorYCoordinate = -1;\r
-    private int fHoldSelection = 0;\r
-\r
-       private static class LineData {\r
-           long rank;\r
-           ITmfLocation<?> location;\r
-           String string;\r
-           public LineData(long rank, ITmfLocation<?> location, String string) {\r
-               this.rank = rank;\r
-               this.location = location;\r
-            if (string.length() == 0) {\r
-                this.string = " "; // workaround for setLineBackground has no effect on empty line //$NON-NLS-1$\r
-            } else {\r
-                this.string = string;\r
-            }\r
-           }\r
-        @Override\r
-        public String toString() {\r
-            return rank + " [" + location + "]: " + string; //$NON-NLS-1$ //$NON-NLS-2$\r
-        }\r
-       }\r
-\r
-       private static class CaretPosition {\r
-           int time;\r
-           int caretOffset;\r
-           public CaretPosition(int time, int caretOffset) {\r
-               this.time = time;\r
-               this.caretOffset = caretOffset;\r
-           }\r
-       }\r
-       \r
-       // ------------------------------------------------------------------------\r
-       // Constructor\r
-       // ------------------------------------------------------------------------\r
-\r
-       /**\r
-        * Constructor\r
-        * @param parent The parent composite\r
-        * @param style The style bits\r
-        */\r
-       public TmfRawEventViewer(Composite parent, int style) {\r
-               super(parent, style & (~SWT.H_SCROLL) & (~SWT.V_SCROLL));\r
-\r
-               // Set the layout\r
-               GridLayout gridLayout = new GridLayout();\r
-               gridLayout.numColumns = 2;\r
-               gridLayout.horizontalSpacing = 0;\r
-               gridLayout.verticalSpacing = 0;\r
-        gridLayout.marginWidth = 0;\r
-        gridLayout.marginHeight = 0;\r
-               setLayout(gridLayout);\r
-               \r
-               // Create the controls\r
-               createTextArea(style & SWT.H_SCROLL);\r
-               createSlider(style & SWT.V_SCROLL);\r
-               \r
-               // Prevent the slider from being traversed\r
-               setTabList(new Control[] { fScrolledComposite });\r
-       }\r
-       \r
-    @Override\r
-       public void dispose() {\r
-        if (fFixedFont != null) {\r
-            fFixedFont.dispose();\r
-            fFixedFont = null;\r
-        }\r
-           super.dispose();\r
-       }\r
-\r
-       // ------------------------------------------------------------------------\r
-       // Text area handling\r
-       // ------------------------------------------------------------------------\r
-\r
-    /**\r
-        * Create the text area and add listeners\r
-        */\r
-       private void createTextArea(int style) {\r
-           fScrolledComposite = new ScrolledComposite(this, style);\r
-           fScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-           fTextArea = new Composite(fScrolledComposite, SWT.NONE);\r
-        fTextArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        fScrolledComposite.setContent(fTextArea);\r
-        fScrolledComposite.setExpandHorizontal(true);\r
-        fScrolledComposite.setExpandVertical(true);\r
-        fScrolledComposite.setAlwaysShowScrollBars(true);\r
-        fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-        fScrolledComposite.addControlListener(this);\r
-\r
-        GridLayout textAreaGridLayout = new GridLayout();\r
-        textAreaGridLayout.marginHeight = 0;\r
-        textAreaGridLayout.marginWidth = 0;\r
-        fTextArea.setLayout(textAreaGridLayout);\r
-\r
-        if (fFixedFont == null) {\r
-            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$\r
-                fFixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            } else {\r
-                fFixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            }\r
-        }\r
-        \r
-        fStyledText = new StyledText(fTextArea, SWT.READ_ONLY);\r
-        fStyledText.setFont(fFixedFont);\r
-        fStyledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));\r
-        \r
-        fStyledText.addCaretListener(this);\r
-        fStyledText.addMouseMoveListener(this);\r
-        fStyledText.addMouseTrackListener(this);\r
-        fStyledText.addMouseWheelListener(this);\r
-        fStyledText.addListener(SWT.MouseWheel, new Listener() { // disable mouse scroll of horizontal scroll bar\r
-            @Override\r
-            public void handleEvent(Event event) { event.doit = false; }});\r
-        fStyledText.addKeyListener(this);\r
-        \r
-        fTextArea.setBackground(fStyledText.getBackground());\r
-        fTextArea.addMouseListener(new MouseAdapter() {\r
-                       @Override\r
-            public void mouseDown(MouseEvent e) {\r
-                               fTextArea.setFocus();\r
-            }});\r
-       }       \r
-\r
-       // ------------------------------------------------------------------------\r
-       // Slider handling\r
-       // ------------------------------------------------------------------------\r
-\r
-       private void createSlider(int style) {\r
-               fSlider = new Slider(this, SWT.VERTICAL);\r
-        fSlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));\r
-        fSlider.setValues(0, 0, SLIDER_MAX, SLIDER_MAX, 1, 1);\r
-               fSlider.addSelectionListener(this);\r
-        if ((style & SWT.V_SCROLL) == 0) {\r
-            fSlider.setVisible(false);\r
-        }\r
-       }\r
-\r
-       // ------------------------------------------------------------------------\r
-       // Controls interactions\r
-       // ------------------------------------------------------------------------\r
-\r
-       @Override\r
-       public boolean setFocus() {\r
-               boolean isVisible = isVisible();\r
-               if (isVisible) {\r
-                       fTextArea.setFocus();\r
-               }\r
-               return isVisible;\r
-       }\r
-       \r
-    @Override\r
-    public void setMenu(Menu menu) {\r
-        fStyledText.setMenu(menu);\r
-    }\r
-\r
-    /**\r
-     * Sets the trace and updates the content\r
-     * @param trace The trace to set\r
-     */\r
-    public void setTrace(ITmfTrace<?> trace) {\r
-           fTrace = trace;\r
-           fTopLineIndex = 0;\r
-           fLines.clear();\r
-           refreshEventCount();\r
-       }\r
-\r
-    /**\r
-     * Refreshes the event count, updates the slider thumb and loads display\r
-     */\r
-       public void refreshEventCount() {\r
-               if (fTrace != null) {\r
-                       if (fTrace.getNbEvents() > 0) {\r
-                               fSlider.setThumb((int) Math.max(SLIDER_MAX / fTrace.getNbEvents(), 1));\r
-                       } else {\r
-                               fSlider.setThumb(SLIDER_MAX);\r
-                       }\r
-\r
-                       if (!isVisible()) return;\r
-                   \r
-                       if (fLines.size() == 0) {\r
-                       setTopRank(0);\r
-                   } else if (fLines.size() < fNumVisibleLines) {\r
-                       fBottomContext = null;\r
-                       loadLineData();\r
-                       fillTextArea();\r
-                   //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
-                   fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));\r
-                   }\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Selects the event of given rank and makes it visible.\r
-        * @param rank The rank of event\r
-        */\r
-    public void selectAndReveal(long rank) {\r
-        if (fTrace == null || !isVisible()) {\r
-            return;\r
-        }\r
-        if (fActualRanks && fTopLineIndex < fLines.size() && rank >= fLines.get(fTopLineIndex).rank) {\r
-            int lastVisibleIndex = Math.min(fTopLineIndex + fNumVisibleLines, fLines.size()) - 1;\r
-            if (rank <= fLines.get(lastVisibleIndex).rank) {\r
-                for (int i = fTopLineIndex; i < fLines.size(); i++) {\r
-                    if (fLines.get(i).rank == rank) {\r
-                        fSelectedLocation = fLines.get(i).location;\r
-                        break;\r
-                    }\r
-                }\r
-                refreshLineBackgrounds();\r
-                return;\r
-            }\r
-        }\r
-        setTopRank(rank);\r
-        if (fLines.size() > 0 && fHoldSelection == 0) {\r
-            fSelectedLocation = fLines.get(0).location;\r
-            refreshLineBackgrounds();\r
-        }\r
-    }\r
-    /**\r
-     * Add a selection listener\r
-     * @param listener A listener to add\r
-     */\r
-    public void addSelectionListener(Listener listener) {\r
-        checkWidget();\r
-        if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);\r
-        addListener (SWT.Selection, listener);\r
-    }\r
-\r
-    /**\r
-     * Remove selection listener\r
-     * @param listener A listener to remove\r
-     */\r
-    public void removeSelectionListener(Listener listener) {\r
-        checkWidget();\r
-        if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);\r
-        removeListener(SWT.Selection, listener);\r
-    }\r
-\r
-    private void sendSelectionEvent(LineData lineData) {\r
-        Event event = new Event();\r
-        if (fActualRanks) {\r
-            event.data = Long.valueOf(lineData.rank);\r
-        } else {\r
-            event.data = lineData.location;\r
-        }\r
-        notifyListeners(SWT.Selection, event);\r
-    }\r
-    \r
-    private void setTopRank(long rank) {\r
-        fBottomContext = fTrace.seekEvent(rank);\r
-        if (fBottomContext == null) {\r
-            return;\r
-        }\r
-        fLines.clear();\r
-        fActualRanks = true;\r
-        fTopLineIndex = 0;\r
-        loadLineData();\r
-        refreshTextArea();\r
-        if (fLines.size() == 0) {\r
-            fSlider.setSelection(0);\r
-        } else {\r
-            //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
-            fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));\r
-        }\r
-    }\r
-    \r
-    private void setTopPosition(double ratio) {\r
-        fBottomContext = fTrace.seekEvent(ratio);\r
-        if (fBottomContext == null) {\r
-            return;\r
-        }\r
-        fBottomContext.setRank(0);\r
-        fLines.clear();\r
-        fActualRanks = false;\r
-        fTopLineIndex = 0;\r
-        loadLineData();\r
-        refreshTextArea();\r
-    }\r
-    \r
-       private void loadLineData() {\r
-        if (fTopLineIndex < 0) {\r
-            //if (fLines.size() > 0 && fLines.get(0).rank > 0) {\r
-                //long endRank = fLines.get(0).rank;\r
-                //long startRank = Math.max(0, endRank - fNumVisibleLines);\r
-                //TmfContext context = fTrace.seekEvent(startRank);\r
-                //int index = 0;\r
-                //while (context.getRank() < endRank) {\r
-                    //long rank = context.getRank();\r
-                    //ITmfLocation<?> location = context.getLocation();\r
-                    //TmfEvent event = fTrace.getNextEvent(context);\r
-                    //String[] lines = event.getRawText().split("\r?\n");\r
-                    //for (int i = 0; i < lines.length; i++) {\r
-                        //String line = lines[i];\r
-                        //LineData lineData = new LineData(rank, location, line); \r
-                        //fLines.add(index++, lineData);\r
-                        //fTopLineIndex++;\r
-                        //fLastTopLineIndex++;\r
-                    //}\r
-                //}\r
-            //}\r
-            if (fLines.size() > 0 && fTrace.getLocationRatio(fLines.get(0).location) > 0) {\r
-               double lastRatio = fTrace.getLocationRatio(fLines.get(fLines.size() - 1).location);\r
-                double firstRatio = fTrace.getLocationRatio(fLines.get(0).location);\r
-                double delta;\r
-                boolean singleEvent = false;\r
-                if (firstRatio != lastRatio) {\r
-                    // approximate ratio of at least 20 items\r
-                    delta = Math.max(20, fNumVisibleLines) * (lastRatio - firstRatio) / (fLines.size() - 1);\r
-                } else {\r
-                    delta = Math.pow(10, -15);\r
-                    singleEvent = true;\r
-                }\r
-                while (fTopLineIndex < 0) {\r
-                    ITmfLocation<?> endLocation = fLines.get(0).location;\r
-                    firstRatio = Math.max(0, firstRatio - delta);\r
-                    ITmfContext context = fTrace.seekEvent(firstRatio);\r
-                    ITmfLocation<?> location;\r
-                    int index = 0;\r
-                    long rank = 0;\r
-                    while (!context.getLocation().equals(endLocation)) {\r
-                        location = context.getLocation().clone();\r
-                        ITmfEvent event = fTrace.getNext(context);\r
-                        if (event == null) {\r
-                               break;\r
-                        }\r
-                        if (event.getContent() != null && event.getContent().getValue() != null) {\r
-                            String[] lines = event.getContent().getValue().toString().split("\r?\n"); //$NON-NLS-1$\r
-                            for (int i = 0; i < lines.length; i++) {\r
-                                String line = lines[i];\r
-                                LineData lineData = new LineData(rank, location, line); \r
-                                fLines.add(index++, lineData);\r
-                                fTopLineIndex++;\r
-                                fLastTopLineIndex++;\r
-                            }\r
-                        } else {\r
-                            LineData lineData = new LineData(rank, location, ""); //$NON-NLS-1$\r
-                            fLines.add(index++, lineData);\r
-                            fTopLineIndex++;\r
-                            fLastTopLineIndex++;\r
-                        }\r
-                        rank++;\r
-                    }\r
-                    long rankOffset = fLines.get(index).rank - rank;\r
-                    for (int i = 0; i < index; i++) {\r
-                        fLines.get(i).rank += rankOffset;\r
-                    }\r
-                    if (firstRatio == 0) {\r
-                        break;\r
-                    }\r
-                    if (singleEvent) {\r
-                       delta = Math.min(delta * 10, 0.1);\r
-                    }\r
-                }\r
-            }\r
-            if (fTopLineIndex < 0) {\r
-                fTopLineIndex = 0;\r
-            }\r
-        }\r
-           \r
-           while (fLines.size() - fTopLineIndex < fNumVisibleLines) {\r
-               if (fBottomContext == null) {\r
-                   if (fLines.size() == 0) {\r
-                       fBottomContext = fTrace.seekEvent(0);\r
-                   } else {\r
-                    //fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1);\r
-                       fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location);\r
-                       fTrace.getNext(fBottomContext);\r
-                   }\r
-                   if (fBottomContext == null) {\r
-                       break;\r
-                   }\r
-               }\r
-            long rank = fBottomContext.getRank();\r
-            ITmfLocation<?> location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;\r
-            ITmfEvent event = fTrace.getNext(fBottomContext);\r
-            if (event == null) {\r
-                break;\r
-            }\r
-            if (event.getContent() != null && event.getContent().getValue() != null) {\r
-                for (String line : event.getContent().getValue().toString().split("\r?\n")) { //$NON-NLS-1$\r
-                    int crPos;\r
-                    if ((crPos = line.indexOf('\r')) != -1) {\r
-                       line = line.substring(0, crPos);\r
-                    }\r
-                    LineData lineData = new LineData(rank, location, line); \r
-                    fLines.add(lineData);\r
-                }\r
-            } else {\r
-                LineData lineData = new LineData(rank, location, ""); //$NON-NLS-1$\r
-                fLines.add(lineData);\r
-            }\r
-           }\r
-           fTopLineIndex = Math.max(0, Math.min(fTopLineIndex, fLines.size() - 1));\r
-           \r
-           if (fLines.size() > MAX_LINE_DATA_SIZE) {\r
-               if (fTopLineIndex < MAX_LINE_DATA_SIZE / 2) {\r
-                   long rank = fLines.get(MAX_LINE_DATA_SIZE - 1).rank;\r
-                   for (int i = MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {\r
-                       if (fLines.get(i).rank > rank) {\r
-                           fLines.subList(i, fLines.size()).clear();\r
-                           fBottomContext = null;\r
-                           break;\r
-                       }\r
-                   }\r
-               } else {\r
-                   long rank = fLines.get(fLines.size() - MAX_LINE_DATA_SIZE).rank;\r
-                   for (int i = fLines.size() - MAX_LINE_DATA_SIZE - 1; i >= 0; i--) {\r
-                    if (fLines.get(i).rank < rank) {\r
-                        fLines.subList(0, i + 1).clear();\r
-                        fTopLineIndex -= (i + 1);\r
-                        fLastTopLineIndex -= (i + 1);\r
-                        break;\r
-                    }\r
-                   }\r
-               }\r
-           }\r
-       }\r
-       \r
-    private void refreshTextArea() {\r
-        fStyledText.setText(""); //$NON-NLS-1$\r
-        for (int i = 0; i < fLines.size() - fTopLineIndex && i < fNumVisibleLines; i++) {\r
-            if (i > 0) fStyledText.append("\n"); //$NON-NLS-1$\r
-            LineData lineData = fLines.get(fTopLineIndex + i);\r
-            fStyledText.append(lineData.string);\r
-            setLineBackground(i, lineData);\r
-        }\r
-        fTextArea.layout();\r
-        fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-        fLastTopLineIndex = fTopLineIndex;\r
-    }\r
-\r
-    private void fillTextArea() {\r
-        int nextLine = fStyledText.getCharCount() == 0 ? 0 : fStyledText.getLineCount();\r
-        for (int i = nextLine; i < fLines.size() - fTopLineIndex && i < fNumVisibleLines; i++) {\r
-            if (i > 0) fStyledText.append("\n"); //$NON-NLS-1$\r
-            LineData lineData = fLines.get(fTopLineIndex + i);\r
-            fStyledText.append(lineData.string);\r
-            setLineBackground(i, lineData);\r
-        }\r
-        int endLine = Math.min(fNumVisibleLines, fLines.size());\r
-        if (endLine < fStyledText.getLineCount()) {\r
-           int endOffset = fStyledText.getOffsetAtLine(endLine) - 1;\r
-           if (endOffset > fStyledText.getCharCount()) {\r
-                fHoldSelection++;\r
-               fStyledText.replaceTextRange(endOffset, fStyledText.getCharCount() - endOffset, ""); //$NON-NLS-1$\r
-                fHoldSelection--;\r
-           }\r
-        }\r
-        fTextArea.layout();\r
-        fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-    }\r
-\r
-       private void updateTextArea() {\r
-           if (fTopLineIndex < fLastTopLineIndex) {\r
-               StringBuffer insertedText = new StringBuffer();\r
-               for (int i = fTopLineIndex; i < fLastTopLineIndex; i++) {\r
-                   insertedText.append(fLines.get(i).string + "\n"); //$NON-NLS-1$\r
-               }\r
-               fStyledText.replaceTextRange(0, 0, insertedText.toString());\r
-            for (int i = 0; i < fLastTopLineIndex - fTopLineIndex; i++) {\r
-                LineData lineData = fLines.get(fTopLineIndex + i);\r
-                setLineBackground(i, lineData);\r
-            }\r
-               fLastTopLineIndex = fTopLineIndex;\r
-           } else if (fTopLineIndex > fLastTopLineIndex) {\r
-               int length = 0;\r
-               for (int i = 0; i < fTopLineIndex - fLastTopLineIndex && i < fNumVisibleLines; i++) {\r
-                   length += fLines.get(i + fLastTopLineIndex).string.length();\r
-                   if (i < fStyledText.getLineCount()) length += 1;\r
-               }\r
-               fStyledText.replaceTextRange(0, length, ""); //$NON-NLS-1$\r
-            fLastTopLineIndex = fTopLineIndex;\r
-            fillTextArea();\r
-           }\r
-        int endLine = Math.min(fNumVisibleLines, fLines.size());\r
-        if (endLine < fStyledText.getLineCount()) {\r
-           int endOffset = fStyledText.getOffsetAtLine(endLine) - 1;\r
-           if (endOffset > fStyledText.getCharCount()) {\r
-               fStyledText.replaceTextRange(endOffset, fStyledText.getCharCount() - endOffset, ""); //$NON-NLS-1$\r
-           }\r
-        }\r
-           fTextArea.layout();\r
-           fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-       }\r
-       \r
-       private void refreshLineBackgrounds() {\r
-        for (int i = 0; (i < fStyledText.getLineCount()) && (i < fNumVisibleLines) && (i < fLines.size() - fTopLineIndex); i++) {\r
-            LineData lineData = fLines.get(fTopLineIndex + i);\r
-            setLineBackground(i, lineData);\r
-        }\r
-       }\r
-\r
-       private void setLineBackground(int index, LineData lineData) {\r
-        if (lineData.location.equals(fSelectedLocation)) {\r
-            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_SELECTED);\r
-        } else if (lineData.rank == fHighlightedRank) {\r
-            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_HIGHLIGHTED);\r
-        } else if (lineData.rank % 2 == 0) {\r
-            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_EVEN);\r
-        } else {\r
-            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_ODD);\r
-        }\r
-       }\r
-\r
-       private void storeCaretPosition(int time, int caretOffset) {\r
-           if (fStoredCaretPosition[0].time == time) {\r
-               fStoredCaretPosition[0].caretOffset = caretOffset;\r
-           } else {\r
-               fStoredCaretPosition[1] = fStoredCaretPosition[0];\r
-               fStoredCaretPosition[0] = new CaretPosition(time, caretOffset);\r
-           }\r
-       }\r
-       \r
-       private int getPreviousCaretOffset(int time) {\r
-           if (fStoredCaretPosition[0].time == time) {\r
-               return fStoredCaretPosition[1].caretOffset;\r
-           }\r
-        return fStoredCaretPosition[0].caretOffset;\r
-       }\r
-\r
-       private void updateHighlightedRank() {\r
-        if (fCursorYCoordinate < 0 || fCursorYCoordinate > fStyledText.getSize().y) {\r
-            if (fHighlightedRank != Long.MIN_VALUE) {\r
-                fHighlightedRank = Long.MIN_VALUE;\r
-                refreshLineBackgrounds();\r
-            }\r
-            return;\r
-        }\r
-        int offset = fStyledText.getOffsetAtLocation(new Point(0, fCursorYCoordinate));\r
-        int line = fStyledText.getLineAtOffset(offset);\r
-        if (line < fLines.size() - fTopLineIndex) {\r
-            LineData lineData = fLines.get(fTopLineIndex + line);\r
-            if (fHighlightedRank != lineData.rank) {\r
-                fHighlightedRank = lineData.rank;\r
-                refreshLineBackgrounds();\r
-            }\r
-        } else {\r
-            if (fHighlightedRank != Long.MIN_VALUE) {\r
-                fHighlightedRank = Long.MIN_VALUE;\r
-                refreshLineBackgrounds();\r
-            }\r
-        }\r
-       }\r
-       \r
-    // ------------------------------------------------------------------------\r
-    // ControlListener (ScrolledComposite)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void controlResized(ControlEvent event) {\r
-        int areaHeight = fScrolledComposite.getSize().y;\r
-        if (fScrolledComposite.getHorizontalBar() != null) {\r
-            areaHeight -= fScrolledComposite.getHorizontalBar().getSize().y;\r
-        }\r
-        int lineHeight = fStyledText.getLineHeight();\r
-        fNumVisibleLines = Math.max((areaHeight + lineHeight - 1) / lineHeight, 1);\r
-\r
-        if (fBottomContext != null) {\r
-            loadLineData();\r
-            fillTextArea();\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void controlMoved(ControlEvent e) {\r
-    }\r
-       \r
-    // ------------------------------------------------------------------------\r
-    // SelectionListener (Slider)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void widgetSelected(SelectionEvent e) {\r
-       fTextArea.setFocus();\r
-        if (fLines.size() == 0) {\r
-            return;\r
-        }\r
-        if (e.detail == SWT.DRAG) {\r
-            return;\r
-        }\r
-        fHoldSelection++;\r
-        switch (e.detail) {\r
-            case SWT.NONE: {\r
-                //long rank = (long) (fTrace.getNbEvents() * ((double) fSlider.getSelection() / SLIDER_MAX));\r
-                //setTopRank(rank);\r
-               if (fSlider.getSelection() == 0 || fSlider.getThumb() == SLIDER_MAX) {\r
-                    fLines.clear();\r
-                    setTopPosition(0.0);\r
-                    break;\r
-               }\r
-                double ratio = (double) fSlider.getSelection() / (SLIDER_MAX - fSlider.getThumb());\r
-                double delta = Math.pow(10, -15);\r
-                fLines.clear();\r
-                while (fLines.size() == 0) {\r
-                    setTopPosition(ratio);\r
-                    if (ratio == 0.0) break;\r
-                    delta = Math.min(delta * 10, 0.1);\r
-                    ratio = Math.max(ratio - delta, 0.0);\r
-                }\r
-                break;\r
-            }\r
-            case SWT.ARROW_DOWN: {\r
-                if (fTopLineIndex >= fLines.size()) {\r
-                    break;\r
-                }\r
-                fTopLineIndex++;\r
-                loadLineData();\r
-                updateTextArea();\r
-                break;\r
-            }\r
-            case SWT.PAGE_DOWN: {\r
-                fTopLineIndex += Math.max(fNumVisibleLines - 1, 1);\r
-                loadLineData();\r
-                updateTextArea();\r
-                break;\r
-            }\r
-            case SWT.ARROW_UP: {\r
-                //if (fLines.size() == 0 || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {\r
-                if (fLines.size() == 0) {// || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {\r
-                    break;\r
-                }\r
-                fTopLineIndex--;\r
-                loadLineData();\r
-                updateTextArea();\r
-                break;\r
-            }\r
-            case SWT.PAGE_UP: {\r
-                fTopLineIndex -= Math.max(fNumVisibleLines - 1, 1);\r
-                loadLineData();\r
-                updateTextArea();\r
-                break;\r
-            }\r
-            case SWT.HOME: {\r
-                //selectAndReveal(0);\r
-                setTopPosition(0.0);\r
-                break;\r
-            }\r
-            case SWT.END: {\r
-                //if (fTrace.getNbEvents() > 0) {\r
-                    //selectAndReveal(fTrace.getNbEvents() - 1);\r
-                //}\r
-                double ratio = 1.0;\r
-                double delta = Math.pow(10, -15);\r
-                fLines.clear();\r
-                while (fLines.size() == 0) {\r
-                    setTopPosition(ratio);\r
-                    if (ratio == 0.0) break;\r
-                    delta = Math.min(delta * 10, 0.1);\r
-                    ratio = Math.max(ratio - delta, 0.0);\r
-                }\r
-                break;\r
-            }\r
-            default:\r
-                break;\r
-        }\r
-        //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
-        if (e.detail != SWT.NONE) {\r
-            fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));\r
-        }\r
-        \r
-        fHoldSelection = 0;\r
-    }\r
-\r
-    @Override\r
-    public void widgetDefaultSelected(SelectionEvent e) {\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // KeyListener (StyledText)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void keyPressed(KeyEvent e) {\r
-        if (fLines.size() == 0) {\r
-            return;\r
-        }\r
-        int caretOffset = fStyledText.getCaretOffset();\r
-        int previousCaretOffset = getPreviousCaretOffset(e.time);\r
-        int previousLineAtCaretPosition = fStyledText.getLineAtOffset(previousCaretOffset);\r
-        int previousColumnAtCaretPosition = getPreviousCaretOffset(e.time) - fStyledText.getOffsetAtLine(previousLineAtCaretPosition);\r
-        switch (e.keyCode) {\r
-            case SWT.ARROW_DOWN: {\r
-                if (previousLineAtCaretPosition < (fNumVisibleLines - 2)) {\r
-                    break;\r
-                }\r
-                fHoldSelection++;\r
-                fTopLineIndex++;\r
-                loadLineData();\r
-                updateTextArea();\r
-                fHoldSelection--;\r
-                LineData lineData = fLines.get(fTopLineIndex + fStyledText.getLineAtOffset(fStyledText.getCaretOffset()));\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-                break;\r
-            }\r
-            case SWT.PAGE_DOWN: {\r
-                if (previousLineAtCaretPosition >= (fNumVisibleLines - 1)) {\r
-                    fHoldSelection++;\r
-                    if (fLines.get(fTopLineIndex + previousLineAtCaretPosition).rank % 2 == 0) {\r
-                        fStyledText.setLineBackground(previousLineAtCaretPosition, 1, COLOR_BACKGROUND_EVEN);\r
-                    } else {\r
-                        fStyledText.setLineBackground(previousLineAtCaretPosition, 1, COLOR_BACKGROUND_ODD);\r
-                    }\r
-                    fSelectedLocation = null;\r
-                    fTopLineIndex += Math.max(fNumVisibleLines - 1, 1);\r
-                    loadLineData();\r
-                    updateTextArea();\r
-                    fHoldSelection--;\r
-                }\r
-                int line = Math.min(fNumVisibleLines - 1, fStyledText.getLineCount() - 1);\r
-                int offset = fStyledText.getOffsetAtLine(line);\r
-                fStyledText.setSelection(offset + Math.min(previousColumnAtCaretPosition, fLines.get(fTopLineIndex + line).string.length()));\r
-                break;\r
-            }\r
-            case SWT.ARROW_RIGHT: {\r
-                if (previousCaretOffset < fStyledText.getCharCount() || previousLineAtCaretPosition < (fNumVisibleLines - 2)) {\r
-                    break;\r
-                }\r
-                fHoldSelection++;\r
-                fTopLineIndex++;\r
-                loadLineData();\r
-                updateTextArea();\r
-                fHoldSelection--;\r
-                fStyledText.setSelection(fStyledText.getCaretOffset() + 1);\r
-                break;\r
-            }\r
-            case SWT.ARROW_UP: {\r
-                if (previousLineAtCaretPosition > 0) {\r
-                    break;\r
-                }\r
-                if (fLines.size() == 0) {// || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {\r
-                    break;\r
-                }\r
-                fHoldSelection++;\r
-                fTopLineIndex--;\r
-                loadLineData();\r
-                updateTextArea();\r
-                fHoldSelection--;\r
-                LineData lineData = fLines.get(fTopLineIndex);\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-                fStyledText.setSelection(caretOffset);\r
-                break;\r
-            }\r
-            case SWT.PAGE_UP: {\r
-                if (previousLineAtCaretPosition > 0) {\r
-                    break;\r
-                }\r
-                fHoldSelection++;\r
-                fTopLineIndex -= Math.max(fNumVisibleLines - 1, 1);\r
-                loadLineData();\r
-                updateTextArea();\r
-                fHoldSelection--;\r
-                LineData lineData = fLines.get(fTopLineIndex);\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-                fStyledText.setSelection(caretOffset);\r
-                break;\r
-            }\r
-            case SWT.ARROW_LEFT: {\r
-                if (previousCaretOffset > 0) {\r
-                    break;\r
-                }\r
-                if (fLines.size() == 0) {// || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {\r
-                    break;\r
-                }\r
-                long topRank = fLines.get(fTopLineIndex).rank;\r
-                fHoldSelection++;\r
-                fTopLineIndex--;\r
-                loadLineData();\r
-                updateTextArea();\r
-                fHoldSelection--;\r
-                LineData lineData = fLines.get(fTopLineIndex);\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-                if (topRank != fLines.get(fTopLineIndex).rank) {\r
-                    fStyledText.setSelection(fLines.get(fTopLineIndex).string.length());\r
-                }\r
-                break;\r
-            }\r
-            case SWT.HOME: {\r
-                if ((e.stateMask & SWT.CTRL) == 0) {\r
-                    break;\r
-                }\r
-                //selectAndReveal(0);\r
-                setTopPosition(0.0);\r
-                LineData lineData = fLines.get(fTopLineIndex);\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-                break;\r
-            }\r
-            case SWT.END: {\r
-                if ((e.stateMask & SWT.CTRL) == 0) {\r
-                    break;\r
-                }\r
-                //if (fTrace.getNbEvents() > 0) {\r
-                    //selectAndReveal(fTrace.getNbEvents() - 1);\r
-                //}\r
-                double ratio = 1.0;\r
-                double delta = Math.pow(10, -15);\r
-                fLines.clear();\r
-                while (fLines.size() == 0) {\r
-                    setTopPosition(ratio);\r
-                    if (ratio == 0.0) break;\r
-                    delta = Math.min(delta * 10, 0.1);\r
-                    ratio = Math.max(ratio - delta, 0.0);\r
-                }\r
-                LineData lineData = fLines.get(fTopLineIndex);\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-                break;\r
-            }\r
-            default:\r
-                break;\r
-        }\r
-        //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
-        updateHighlightedRank();\r
-        fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));\r
-    }\r
-\r
-    @Override\r
-    public void keyReleased(KeyEvent e) {\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // CaretListener (StyledText)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void caretMoved(CaretEvent event) {\r
-        if (fHoldSelection == 0) {\r
-            int line = fStyledText.getLineAtOffset(event.caretOffset);\r
-            if (fTopLineIndex + line < fLines.size()) {\r
-                LineData lineData = fLines.get(fTopLineIndex + line);\r
-                if (!lineData.location.equals(fSelectedLocation)) {\r
-                    fSelectedLocation = lineData.location;\r
-                    refreshLineBackgrounds();\r
-                    sendSelectionEvent(lineData);\r
-                }\r
-            }\r
-        }\r
-        storeCaretPosition(event.time, event.caretOffset);\r
-        if (fHoldSelection == 0) {\r
-            Point caret = fStyledText.getLocationAtOffset(fStyledText.getCaretOffset());\r
-            Point origin = fScrolledComposite.getOrigin();\r
-            if (origin.x > caret.x) {\r
-                origin.x = caret.x;\r
-            } else if (caret.x - origin.x > fScrolledComposite.getSize().x) {\r
-                origin.x = caret.x - fScrolledComposite.getSize().x + 1;\r
-            }\r
-            fScrolledComposite.setOrigin(origin);\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // MouseMoveListener (StyledText)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void mouseMove(MouseEvent e) {\r
-        fCursorYCoordinate = e.y;\r
-        if (e.y < 0 || e.y > fStyledText.getSize().y) {\r
-            if (fHighlightedRank != Long.MIN_VALUE) {\r
-                fHighlightedRank = Long.MIN_VALUE;\r
-                refreshLineBackgrounds();\r
-            }\r
-            return;\r
-        }\r
-        int offset = fStyledText.getOffsetAtLocation(new Point(0, e.y));\r
-        int line = fStyledText.getLineAtOffset(offset);\r
-        if (line < fLines.size() - fTopLineIndex) {\r
-            LineData lineData = fLines.get(fTopLineIndex + line);\r
-            if (fHighlightedRank != lineData.rank) {\r
-                fHighlightedRank = lineData.rank;\r
-                refreshLineBackgrounds();\r
-            }\r
-        } else {\r
-            if (fHighlightedRank != Long.MIN_VALUE) {\r
-                fHighlightedRank = Long.MIN_VALUE;\r
-                refreshLineBackgrounds();\r
-            }\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // MouseTrackListener (StyledText)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void mouseExit(MouseEvent e) {\r
-        fCursorYCoordinate = -1;\r
-        if (fHighlightedRank != Long.MIN_VALUE) {\r
-            fHighlightedRank = Long.MIN_VALUE;\r
-            refreshLineBackgrounds();\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void mouseEnter(MouseEvent e) {\r
-        fCursorYCoordinate = e.y;\r
-    }\r
-\r
-    @Override\r
-    public void mouseHover(MouseEvent e) {\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // MouseWheelListener (StyledText)\r
-    // ------------------------------------------------------------------------\r
-    \r
-    @Override\r
-    public void mouseScrolled(MouseEvent e) {\r
-        if (fLines.size() == 0) {\r
-            return;\r
-        }\r
-        fHoldSelection++;\r
-        fTopLineIndex -= e.count;\r
-        loadLineData();\r
-        updateTextArea();\r
-        fHoldSelection = 0;\r
-        //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));\r
-        updateHighlightedRank();\r
-        fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));\r
-    }\r
-    \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.rawviewer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CaretEvent;
+import org.eclipse.swt.custom.CaretListener;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.MouseWheelListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Slider;
+
+/**
+ * TmfRawEventViewer allows for the display of the raw data for an arbitrarily
+ * large number of TMF events.
+ * 
+ * It is essentially a Composite of a StyledText area and a Slider, where the number
+ * of visible lines in the StyledText control is set to fill the viewer display area.
+ * An underlying data model is used to store a cache of event raw text line data.
+ * The slider is ratio-based.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TmfRawEventViewer extends Composite implements ControlListener, SelectionListener,
+                KeyListener, CaretListener, MouseMoveListener, MouseTrackListener, MouseWheelListener {
+
+    private static final Color COLOR_BACKGROUND_ODD = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
+    private static final Color COLOR_BACKGROUND_EVEN = new Color(Display.getDefault(), 242, 242, 242);
+    private static final Color COLOR_BACKGROUND_SELECTED = new Color(Display.getDefault(), 231, 246, 254);
+    private static final Color COLOR_BACKGROUND_HIGHLIGHTED = new Color(Display.getDefault(), 246, 252, 255);
+    private static final int MAX_LINE_DATA_SIZE = 1000;
+    private static final int SLIDER_MAX = 1000000;
+
+    private ITmfTrace<?> fTrace;
+    private ITmfContext fBottomContext;
+    
+    private ScrolledComposite fScrolledComposite;
+    private Composite fTextArea;
+    private StyledText fStyledText;
+    private Font fFixedFont;
+       private Slider fSlider;
+
+       private List<LineData> fLines = new ArrayList<LineData>();
+       private boolean fActualRanks = false;
+       private int fTopLineIndex;
+       private int fLastTopLineIndex;
+       private CaretPosition[] fStoredCaretPosition = new CaretPosition[]
+                   { new CaretPosition(0, 0), new CaretPosition(0,0)};
+       private int fNumVisibleLines;
+    private ITmfLocation<?> fSelectedLocation = null;
+    private long fHighlightedRank = Long.MIN_VALUE;
+    private int fCursorYCoordinate = -1;
+    private int fHoldSelection = 0;
+
+       private static class LineData {
+           long rank;
+           ITmfLocation<?> location;
+           String string;
+           public LineData(long rank, ITmfLocation<?> location, String string) {
+               this.rank = rank;
+               this.location = location;
+            if (string.length() == 0) {
+                this.string = " "; // workaround for setLineBackground has no effect on empty line //$NON-NLS-1$
+            } else {
+                this.string = string;
+            }
+           }
+        @Override
+        public String toString() {
+            return rank + " [" + location + "]: " + string; //$NON-NLS-1$ //$NON-NLS-2$
+        }
+       }
+
+       private static class CaretPosition {
+           int time;
+           int caretOffset;
+           public CaretPosition(int time, int caretOffset) {
+               this.time = time;
+               this.caretOffset = caretOffset;
+           }
+       }
+       
+       // ------------------------------------------------------------------------
+       // Constructor
+       // ------------------------------------------------------------------------
+
+       /**
+        * Constructor
+        * @param parent The parent composite
+        * @param style The style bits
+        */
+       public TmfRawEventViewer(Composite parent, int style) {
+               super(parent, style & (~SWT.H_SCROLL) & (~SWT.V_SCROLL));
+
+               // Set the layout
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 2;
+               gridLayout.horizontalSpacing = 0;
+               gridLayout.verticalSpacing = 0;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+               setLayout(gridLayout);
+               
+               // Create the controls
+               createTextArea(style & SWT.H_SCROLL);
+               createSlider(style & SWT.V_SCROLL);
+               
+               // Prevent the slider from being traversed
+               setTabList(new Control[] { fScrolledComposite });
+       }
+       
+    @Override
+       public void dispose() {
+        if (fFixedFont != null) {
+            fFixedFont.dispose();
+            fFixedFont = null;
+        }
+           super.dispose();
+       }
+
+       // ------------------------------------------------------------------------
+       // Text area handling
+       // ------------------------------------------------------------------------
+
+    /**
+        * Create the text area and add listeners
+        */
+       private void createTextArea(int style) {
+           fScrolledComposite = new ScrolledComposite(this, style);
+           fScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+           fTextArea = new Composite(fScrolledComposite, SWT.NONE);
+        fTextArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        fScrolledComposite.setContent(fTextArea);
+        fScrolledComposite.setExpandHorizontal(true);
+        fScrolledComposite.setExpandVertical(true);
+        fScrolledComposite.setAlwaysShowScrollBars(true);
+        fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+        fScrolledComposite.addControlListener(this);
+
+        GridLayout textAreaGridLayout = new GridLayout();
+        textAreaGridLayout.marginHeight = 0;
+        textAreaGridLayout.marginWidth = 0;
+        fTextArea.setLayout(textAreaGridLayout);
+
+        if (fFixedFont == null) {
+            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
+                fFixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$
+            } else {
+                fFixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$
+            }
+        }
+        
+        fStyledText = new StyledText(fTextArea, SWT.READ_ONLY);
+        fStyledText.setFont(fFixedFont);
+        fStyledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        
+        fStyledText.addCaretListener(this);
+        fStyledText.addMouseMoveListener(this);
+        fStyledText.addMouseTrackListener(this);
+        fStyledText.addMouseWheelListener(this);
+        fStyledText.addListener(SWT.MouseWheel, new Listener() { // disable mouse scroll of horizontal scroll bar
+            @Override
+            public void handleEvent(Event event) { event.doit = false; }});
+        fStyledText.addKeyListener(this);
+        
+        fTextArea.setBackground(fStyledText.getBackground());
+        fTextArea.addMouseListener(new MouseAdapter() {
+                       @Override
+            public void mouseDown(MouseEvent e) {
+                               fTextArea.setFocus();
+            }});
+       }       
+
+       // ------------------------------------------------------------------------
+       // Slider handling
+       // ------------------------------------------------------------------------
+
+       private void createSlider(int style) {
+               fSlider = new Slider(this, SWT.VERTICAL);
+        fSlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+        fSlider.setValues(0, 0, SLIDER_MAX, SLIDER_MAX, 1, 1);
+               fSlider.addSelectionListener(this);
+        if ((style & SWT.V_SCROLL) == 0) {
+            fSlider.setVisible(false);
+        }
+       }
+
+       // ------------------------------------------------------------------------
+       // Controls interactions
+       // ------------------------------------------------------------------------
+
+       @Override
+       public boolean setFocus() {
+               boolean isVisible = isVisible();
+               if (isVisible) {
+                       fTextArea.setFocus();
+               }
+               return isVisible;
+       }
+       
+    @Override
+    public void setMenu(Menu menu) {
+        fStyledText.setMenu(menu);
+    }
+
+    /**
+     * Sets the trace and updates the content
+     * @param trace The trace to set
+     */
+    public void setTrace(ITmfTrace<?> trace) {
+           fTrace = trace;
+           fTopLineIndex = 0;
+           fLines.clear();
+           refreshEventCount();
+       }
+
+    /**
+     * Refreshes the event count, updates the slider thumb and loads display
+     */
+       public void refreshEventCount() {
+               if (fTrace != null) {
+                       if (fTrace.getNbEvents() > 0) {
+                               fSlider.setThumb((int) Math.max(SLIDER_MAX / fTrace.getNbEvents(), 1));
+                       } else {
+                               fSlider.setThumb(SLIDER_MAX);
+                       }
+
+                       if (!isVisible()) return;
+                   
+                       if (fLines.size() == 0) {
+                       setTopRank(0);
+                   } else if (fLines.size() < fNumVisibleLines) {
+                       fBottomContext = null;
+                       loadLineData();
+                       fillTextArea();
+                   //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));
+                   fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));
+                   }
+               }
+       }
+       
+       /**
+        * Selects the event of given rank and makes it visible.
+        * @param rank The rank of event
+        */
+    public void selectAndReveal(long rank) {
+        if (fTrace == null || !isVisible()) {
+            return;
+        }
+        if (fActualRanks && fTopLineIndex < fLines.size() && rank >= fLines.get(fTopLineIndex).rank) {
+            int lastVisibleIndex = Math.min(fTopLineIndex + fNumVisibleLines, fLines.size()) - 1;
+            if (rank <= fLines.get(lastVisibleIndex).rank) {
+                for (int i = fTopLineIndex; i < fLines.size(); i++) {
+                    if (fLines.get(i).rank == rank) {
+                        fSelectedLocation = fLines.get(i).location;
+                        break;
+                    }
+                }
+                refreshLineBackgrounds();
+                return;
+            }
+        }
+        setTopRank(rank);
+        if (fLines.size() > 0 && fHoldSelection == 0) {
+            fSelectedLocation = fLines.get(0).location;
+            refreshLineBackgrounds();
+        }
+    }
+    /**
+     * Add a selection listener
+     * @param listener A listener to add
+     */
+    public void addSelectionListener(Listener listener) {
+        checkWidget();
+        if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+        addListener (SWT.Selection, listener);
+    }
+
+    /**
+     * Remove selection listener
+     * @param listener A listener to remove
+     */
+    public void removeSelectionListener(Listener listener) {
+        checkWidget();
+        if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+        removeListener(SWT.Selection, listener);
+    }
+
+    private void sendSelectionEvent(LineData lineData) {
+        Event event = new Event();
+        if (fActualRanks) {
+            event.data = Long.valueOf(lineData.rank);
+        } else {
+            event.data = lineData.location;
+        }
+        notifyListeners(SWT.Selection, event);
+    }
+    
+    private void setTopRank(long rank) {
+        fBottomContext = fTrace.seekEvent(rank);
+        if (fBottomContext == null) {
+            return;
+        }
+        fLines.clear();
+        fActualRanks = true;
+        fTopLineIndex = 0;
+        loadLineData();
+        refreshTextArea();
+        if (fLines.size() == 0) {
+            fSlider.setSelection(0);
+        } else {
+            //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));
+            fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));
+        }
+    }
+    
+    private void setTopPosition(double ratio) {
+        fBottomContext = fTrace.seekEvent(ratio);
+        if (fBottomContext == null) {
+            return;
+        }
+        fBottomContext.setRank(0);
+        fLines.clear();
+        fActualRanks = false;
+        fTopLineIndex = 0;
+        loadLineData();
+        refreshTextArea();
+    }
+    
+       private void loadLineData() {
+        if (fTopLineIndex < 0) {
+            //if (fLines.size() > 0 && fLines.get(0).rank > 0) {
+                //long endRank = fLines.get(0).rank;
+                //long startRank = Math.max(0, endRank - fNumVisibleLines);
+                //TmfContext context = fTrace.seekEvent(startRank);
+                //int index = 0;
+                //while (context.getRank() < endRank) {
+                    //long rank = context.getRank();
+                    //ITmfLocation<?> location = context.getLocation();
+                    //TmfEvent event = fTrace.getNextEvent(context);
+                    //String[] lines = event.getRawText().split("\r?\n");
+                    //for (int i = 0; i < lines.length; i++) {
+                        //String line = lines[i];
+                        //LineData lineData = new LineData(rank, location, line); 
+                        //fLines.add(index++, lineData);
+                        //fTopLineIndex++;
+                        //fLastTopLineIndex++;
+                    //}
+                //}
+            //}
+            if (fLines.size() > 0 && fTrace.getLocationRatio(fLines.get(0).location) > 0) {
+               double lastRatio = fTrace.getLocationRatio(fLines.get(fLines.size() - 1).location);
+                double firstRatio = fTrace.getLocationRatio(fLines.get(0).location);
+                double delta;
+                boolean singleEvent = false;
+                if (firstRatio != lastRatio) {
+                    // approximate ratio of at least 20 items
+                    delta = Math.max(20, fNumVisibleLines) * (lastRatio - firstRatio) / (fLines.size() - 1);
+                } else {
+                    delta = Math.pow(10, -15);
+                    singleEvent = true;
+                }
+                while (fTopLineIndex < 0) {
+                    ITmfLocation<?> endLocation = fLines.get(0).location;
+                    firstRatio = Math.max(0, firstRatio - delta);
+                    ITmfContext context = fTrace.seekEvent(firstRatio);
+                    ITmfLocation<?> location;
+                    int index = 0;
+                    long rank = 0;
+                    while (!context.getLocation().equals(endLocation)) {
+                        location = context.getLocation().clone();
+                        ITmfEvent event = fTrace.getNext(context);
+                        if (event == null) {
+                               break;
+                        }
+                        if (event.getContent() != null && event.getContent().getValue() != null) {
+                            String[] lines = event.getContent().getValue().toString().split("\r?\n"); //$NON-NLS-1$
+                            for (int i = 0; i < lines.length; i++) {
+                                String line = lines[i];
+                                LineData lineData = new LineData(rank, location, line); 
+                                fLines.add(index++, lineData);
+                                fTopLineIndex++;
+                                fLastTopLineIndex++;
+                            }
+                        } else {
+                            LineData lineData = new LineData(rank, location, ""); //$NON-NLS-1$
+                            fLines.add(index++, lineData);
+                            fTopLineIndex++;
+                            fLastTopLineIndex++;
+                        }
+                        rank++;
+                    }
+                    long rankOffset = fLines.get(index).rank - rank;
+                    for (int i = 0; i < index; i++) {
+                        fLines.get(i).rank += rankOffset;
+                    }
+                    if (firstRatio == 0) {
+                        break;
+                    }
+                    if (singleEvent) {
+                       delta = Math.min(delta * 10, 0.1);
+                    }
+                }
+            }
+            if (fTopLineIndex < 0) {
+                fTopLineIndex = 0;
+            }
+        }
+           
+           while (fLines.size() - fTopLineIndex < fNumVisibleLines) {
+               if (fBottomContext == null) {
+                   if (fLines.size() == 0) {
+                       fBottomContext = fTrace.seekEvent(0);
+                   } else {
+                    //fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1);
+                       fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location);
+                       fTrace.getNext(fBottomContext);
+                   }
+                   if (fBottomContext == null) {
+                       break;
+                   }
+               }
+            long rank = fBottomContext.getRank();
+            ITmfLocation<?> location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;
+            ITmfEvent event = fTrace.getNext(fBottomContext);
+            if (event == null) {
+                break;
+            }
+            if (event.getContent() != null && event.getContent().getValue() != null) {
+                for (String line : event.getContent().getValue().toString().split("\r?\n")) { //$NON-NLS-1$
+                    int crPos;
+                    if ((crPos = line.indexOf('\r')) != -1) {
+                       line = line.substring(0, crPos);
+                    }
+                    LineData lineData = new LineData(rank, location, line); 
+                    fLines.add(lineData);
+                }
+            } else {
+                LineData lineData = new LineData(rank, location, ""); //$NON-NLS-1$
+                fLines.add(lineData);
+            }
+           }
+           fTopLineIndex = Math.max(0, Math.min(fTopLineIndex, fLines.size() - 1));
+           
+           if (fLines.size() > MAX_LINE_DATA_SIZE) {
+               if (fTopLineIndex < MAX_LINE_DATA_SIZE / 2) {
+                   long rank = fLines.get(MAX_LINE_DATA_SIZE - 1).rank;
+                   for (int i = MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {
+                       if (fLines.get(i).rank > rank) {
+                           fLines.subList(i, fLines.size()).clear();
+                           fBottomContext = null;
+                           break;
+                       }
+                   }
+               } else {
+                   long rank = fLines.get(fLines.size() - MAX_LINE_DATA_SIZE).rank;
+                   for (int i = fLines.size() - MAX_LINE_DATA_SIZE - 1; i >= 0; i--) {
+                    if (fLines.get(i).rank < rank) {
+                        fLines.subList(0, i + 1).clear();
+                        fTopLineIndex -= (i + 1);
+                        fLastTopLineIndex -= (i + 1);
+                        break;
+                    }
+                   }
+               }
+           }
+       }
+       
+    private void refreshTextArea() {
+        fStyledText.setText(""); //$NON-NLS-1$
+        for (int i = 0; i < fLines.size() - fTopLineIndex && i < fNumVisibleLines; i++) {
+            if (i > 0) fStyledText.append("\n"); //$NON-NLS-1$
+            LineData lineData = fLines.get(fTopLineIndex + i);
+            fStyledText.append(lineData.string);
+            setLineBackground(i, lineData);
+        }
+        fTextArea.layout();
+        fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+        fLastTopLineIndex = fTopLineIndex;
+    }
+
+    private void fillTextArea() {
+        int nextLine = fStyledText.getCharCount() == 0 ? 0 : fStyledText.getLineCount();
+        for (int i = nextLine; i < fLines.size() - fTopLineIndex && i < fNumVisibleLines; i++) {
+            if (i > 0) fStyledText.append("\n"); //$NON-NLS-1$
+            LineData lineData = fLines.get(fTopLineIndex + i);
+            fStyledText.append(lineData.string);
+            setLineBackground(i, lineData);
+        }
+        int endLine = Math.min(fNumVisibleLines, fLines.size());
+        if (endLine < fStyledText.getLineCount()) {
+           int endOffset = fStyledText.getOffsetAtLine(endLine) - 1;
+           if (endOffset > fStyledText.getCharCount()) {
+                fHoldSelection++;
+               fStyledText.replaceTextRange(endOffset, fStyledText.getCharCount() - endOffset, ""); //$NON-NLS-1$
+                fHoldSelection--;
+           }
+        }
+        fTextArea.layout();
+        fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+    }
+
+       private void updateTextArea() {
+           if (fTopLineIndex < fLastTopLineIndex) {
+               StringBuffer insertedText = new StringBuffer();
+               for (int i = fTopLineIndex; i < fLastTopLineIndex; i++) {
+                   insertedText.append(fLines.get(i).string + "\n"); //$NON-NLS-1$
+               }
+               fStyledText.replaceTextRange(0, 0, insertedText.toString());
+            for (int i = 0; i < fLastTopLineIndex - fTopLineIndex; i++) {
+                LineData lineData = fLines.get(fTopLineIndex + i);
+                setLineBackground(i, lineData);
+            }
+               fLastTopLineIndex = fTopLineIndex;
+           } else if (fTopLineIndex > fLastTopLineIndex) {
+               int length = 0;
+               for (int i = 0; i < fTopLineIndex - fLastTopLineIndex && i < fNumVisibleLines; i++) {
+                   length += fLines.get(i + fLastTopLineIndex).string.length();
+                   if (i < fStyledText.getLineCount()) length += 1;
+               }
+               fStyledText.replaceTextRange(0, length, ""); //$NON-NLS-1$
+            fLastTopLineIndex = fTopLineIndex;
+            fillTextArea();
+           }
+        int endLine = Math.min(fNumVisibleLines, fLines.size());
+        if (endLine < fStyledText.getLineCount()) {
+           int endOffset = fStyledText.getOffsetAtLine(endLine) - 1;
+           if (endOffset > fStyledText.getCharCount()) {
+               fStyledText.replaceTextRange(endOffset, fStyledText.getCharCount() - endOffset, ""); //$NON-NLS-1$
+           }
+        }
+           fTextArea.layout();
+           fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+       }
+       
+       private void refreshLineBackgrounds() {
+        for (int i = 0; (i < fStyledText.getLineCount()) && (i < fNumVisibleLines) && (i < fLines.size() - fTopLineIndex); i++) {
+            LineData lineData = fLines.get(fTopLineIndex + i);
+            setLineBackground(i, lineData);
+        }
+       }
+
+       private void setLineBackground(int index, LineData lineData) {
+        if (lineData.location.equals(fSelectedLocation)) {
+            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_SELECTED);
+        } else if (lineData.rank == fHighlightedRank) {
+            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_HIGHLIGHTED);
+        } else if (lineData.rank % 2 == 0) {
+            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_EVEN);
+        } else {
+            fStyledText.setLineBackground(index, 1, COLOR_BACKGROUND_ODD);
+        }
+       }
+
+       private void storeCaretPosition(int time, int caretOffset) {
+           if (fStoredCaretPosition[0].time == time) {
+               fStoredCaretPosition[0].caretOffset = caretOffset;
+           } else {
+               fStoredCaretPosition[1] = fStoredCaretPosition[0];
+               fStoredCaretPosition[0] = new CaretPosition(time, caretOffset);
+           }
+       }
+       
+       private int getPreviousCaretOffset(int time) {
+           if (fStoredCaretPosition[0].time == time) {
+               return fStoredCaretPosition[1].caretOffset;
+           }
+        return fStoredCaretPosition[0].caretOffset;
+       }
+
+       private void updateHighlightedRank() {
+        if (fCursorYCoordinate < 0 || fCursorYCoordinate > fStyledText.getSize().y) {
+            if (fHighlightedRank != Long.MIN_VALUE) {
+                fHighlightedRank = Long.MIN_VALUE;
+                refreshLineBackgrounds();
+            }
+            return;
+        }
+        int offset = fStyledText.getOffsetAtLocation(new Point(0, fCursorYCoordinate));
+        int line = fStyledText.getLineAtOffset(offset);
+        if (line < fLines.size() - fTopLineIndex) {
+            LineData lineData = fLines.get(fTopLineIndex + line);
+            if (fHighlightedRank != lineData.rank) {
+                fHighlightedRank = lineData.rank;
+                refreshLineBackgrounds();
+            }
+        } else {
+            if (fHighlightedRank != Long.MIN_VALUE) {
+                fHighlightedRank = Long.MIN_VALUE;
+                refreshLineBackgrounds();
+            }
+        }
+       }
+       
+    // ------------------------------------------------------------------------
+    // ControlListener (ScrolledComposite)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void controlResized(ControlEvent event) {
+        int areaHeight = fScrolledComposite.getSize().y;
+        if (fScrolledComposite.getHorizontalBar() != null) {
+            areaHeight -= fScrolledComposite.getHorizontalBar().getSize().y;
+        }
+        int lineHeight = fStyledText.getLineHeight();
+        fNumVisibleLines = Math.max((areaHeight + lineHeight - 1) / lineHeight, 1);
+
+        if (fBottomContext != null) {
+            loadLineData();
+            fillTextArea();
+        }
+    }
+
+    @Override
+    public void controlMoved(ControlEvent e) {
+    }
+       
+    // ------------------------------------------------------------------------
+    // SelectionListener (Slider)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void widgetSelected(SelectionEvent e) {
+       fTextArea.setFocus();
+        if (fLines.size() == 0) {
+            return;
+        }
+        if (e.detail == SWT.DRAG) {
+            return;
+        }
+        fHoldSelection++;
+        switch (e.detail) {
+            case SWT.NONE: {
+                //long rank = (long) (fTrace.getNbEvents() * ((double) fSlider.getSelection() / SLIDER_MAX));
+                //setTopRank(rank);
+               if (fSlider.getSelection() == 0 || fSlider.getThumb() == SLIDER_MAX) {
+                    fLines.clear();
+                    setTopPosition(0.0);
+                    break;
+               }
+                double ratio = (double) fSlider.getSelection() / (SLIDER_MAX - fSlider.getThumb());
+                double delta = Math.pow(10, -15);
+                fLines.clear();
+                while (fLines.size() == 0) {
+                    setTopPosition(ratio);
+                    if (ratio == 0.0) break;
+                    delta = Math.min(delta * 10, 0.1);
+                    ratio = Math.max(ratio - delta, 0.0);
+                }
+                break;
+            }
+            case SWT.ARROW_DOWN: {
+                if (fTopLineIndex >= fLines.size()) {
+                    break;
+                }
+                fTopLineIndex++;
+                loadLineData();
+                updateTextArea();
+                break;
+            }
+            case SWT.PAGE_DOWN: {
+                fTopLineIndex += Math.max(fNumVisibleLines - 1, 1);
+                loadLineData();
+                updateTextArea();
+                break;
+            }
+            case SWT.ARROW_UP: {
+                //if (fLines.size() == 0 || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {
+                if (fLines.size() == 0) {// || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {
+                    break;
+                }
+                fTopLineIndex--;
+                loadLineData();
+                updateTextArea();
+                break;
+            }
+            case SWT.PAGE_UP: {
+                fTopLineIndex -= Math.max(fNumVisibleLines - 1, 1);
+                loadLineData();
+                updateTextArea();
+                break;
+            }
+            case SWT.HOME: {
+                //selectAndReveal(0);
+                setTopPosition(0.0);
+                break;
+            }
+            case SWT.END: {
+                //if (fTrace.getNbEvents() > 0) {
+                    //selectAndReveal(fTrace.getNbEvents() - 1);
+                //}
+                double ratio = 1.0;
+                double delta = Math.pow(10, -15);
+                fLines.clear();
+                while (fLines.size() == 0) {
+                    setTopPosition(ratio);
+                    if (ratio == 0.0) break;
+                    delta = Math.min(delta * 10, 0.1);
+                    ratio = Math.max(ratio - delta, 0.0);
+                }
+                break;
+            }
+            default:
+                break;
+        }
+        //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));
+        if (e.detail != SWT.NONE) {
+            fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));
+        }
+        
+        fHoldSelection = 0;
+    }
+
+    @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
+    }
+
+    // ------------------------------------------------------------------------
+    // KeyListener (StyledText)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void keyPressed(KeyEvent e) {
+        if (fLines.size() == 0) {
+            return;
+        }
+        int caretOffset = fStyledText.getCaretOffset();
+        int previousCaretOffset = getPreviousCaretOffset(e.time);
+        int previousLineAtCaretPosition = fStyledText.getLineAtOffset(previousCaretOffset);
+        int previousColumnAtCaretPosition = getPreviousCaretOffset(e.time) - fStyledText.getOffsetAtLine(previousLineAtCaretPosition);
+        switch (e.keyCode) {
+            case SWT.ARROW_DOWN: {
+                if (previousLineAtCaretPosition < (fNumVisibleLines - 2)) {
+                    break;
+                }
+                fHoldSelection++;
+                fTopLineIndex++;
+                loadLineData();
+                updateTextArea();
+                fHoldSelection--;
+                LineData lineData = fLines.get(fTopLineIndex + fStyledText.getLineAtOffset(fStyledText.getCaretOffset()));
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+                break;
+            }
+            case SWT.PAGE_DOWN: {
+                if (previousLineAtCaretPosition >= (fNumVisibleLines - 1)) {
+                    fHoldSelection++;
+                    if (fLines.get(fTopLineIndex + previousLineAtCaretPosition).rank % 2 == 0) {
+                        fStyledText.setLineBackground(previousLineAtCaretPosition, 1, COLOR_BACKGROUND_EVEN);
+                    } else {
+                        fStyledText.setLineBackground(previousLineAtCaretPosition, 1, COLOR_BACKGROUND_ODD);
+                    }
+                    fSelectedLocation = null;
+                    fTopLineIndex += Math.max(fNumVisibleLines - 1, 1);
+                    loadLineData();
+                    updateTextArea();
+                    fHoldSelection--;
+                }
+                int line = Math.min(fNumVisibleLines - 1, fStyledText.getLineCount() - 1);
+                int offset = fStyledText.getOffsetAtLine(line);
+                fStyledText.setSelection(offset + Math.min(previousColumnAtCaretPosition, fLines.get(fTopLineIndex + line).string.length()));
+                break;
+            }
+            case SWT.ARROW_RIGHT: {
+                if (previousCaretOffset < fStyledText.getCharCount() || previousLineAtCaretPosition < (fNumVisibleLines - 2)) {
+                    break;
+                }
+                fHoldSelection++;
+                fTopLineIndex++;
+                loadLineData();
+                updateTextArea();
+                fHoldSelection--;
+                fStyledText.setSelection(fStyledText.getCaretOffset() + 1);
+                break;
+            }
+            case SWT.ARROW_UP: {
+                if (previousLineAtCaretPosition > 0) {
+                    break;
+                }
+                if (fLines.size() == 0) {// || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {
+                    break;
+                }
+                fHoldSelection++;
+                fTopLineIndex--;
+                loadLineData();
+                updateTextArea();
+                fHoldSelection--;
+                LineData lineData = fLines.get(fTopLineIndex);
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+                fStyledText.setSelection(caretOffset);
+                break;
+            }
+            case SWT.PAGE_UP: {
+                if (previousLineAtCaretPosition > 0) {
+                    break;
+                }
+                fHoldSelection++;
+                fTopLineIndex -= Math.max(fNumVisibleLines - 1, 1);
+                loadLineData();
+                updateTextArea();
+                fHoldSelection--;
+                LineData lineData = fLines.get(fTopLineIndex);
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+                fStyledText.setSelection(caretOffset);
+                break;
+            }
+            case SWT.ARROW_LEFT: {
+                if (previousCaretOffset > 0) {
+                    break;
+                }
+                if (fLines.size() == 0) {// || (fTopLineIndex == 0 && fLines.get(0).rank == 0)) {
+                    break;
+                }
+                long topRank = fLines.get(fTopLineIndex).rank;
+                fHoldSelection++;
+                fTopLineIndex--;
+                loadLineData();
+                updateTextArea();
+                fHoldSelection--;
+                LineData lineData = fLines.get(fTopLineIndex);
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+                if (topRank != fLines.get(fTopLineIndex).rank) {
+                    fStyledText.setSelection(fLines.get(fTopLineIndex).string.length());
+                }
+                break;
+            }
+            case SWT.HOME: {
+                if ((e.stateMask & SWT.CTRL) == 0) {
+                    break;
+                }
+                //selectAndReveal(0);
+                setTopPosition(0.0);
+                LineData lineData = fLines.get(fTopLineIndex);
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+                break;
+            }
+            case SWT.END: {
+                if ((e.stateMask & SWT.CTRL) == 0) {
+                    break;
+                }
+                //if (fTrace.getNbEvents() > 0) {
+                    //selectAndReveal(fTrace.getNbEvents() - 1);
+                //}
+                double ratio = 1.0;
+                double delta = Math.pow(10, -15);
+                fLines.clear();
+                while (fLines.size() == 0) {
+                    setTopPosition(ratio);
+                    if (ratio == 0.0) break;
+                    delta = Math.min(delta * 10, 0.1);
+                    ratio = Math.max(ratio - delta, 0.0);
+                }
+                LineData lineData = fLines.get(fTopLineIndex);
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+                break;
+            }
+            default:
+                break;
+        }
+        //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));
+        updateHighlightedRank();
+        fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));
+    }
+
+    @Override
+    public void keyReleased(KeyEvent e) {
+    }
+
+    // ------------------------------------------------------------------------
+    // CaretListener (StyledText)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void caretMoved(CaretEvent event) {
+        if (fHoldSelection == 0) {
+            int line = fStyledText.getLineAtOffset(event.caretOffset);
+            if (fTopLineIndex + line < fLines.size()) {
+                LineData lineData = fLines.get(fTopLineIndex + line);
+                if (!lineData.location.equals(fSelectedLocation)) {
+                    fSelectedLocation = lineData.location;
+                    refreshLineBackgrounds();
+                    sendSelectionEvent(lineData);
+                }
+            }
+        }
+        storeCaretPosition(event.time, event.caretOffset);
+        if (fHoldSelection == 0) {
+            Point caret = fStyledText.getLocationAtOffset(fStyledText.getCaretOffset());
+            Point origin = fScrolledComposite.getOrigin();
+            if (origin.x > caret.x) {
+                origin.x = caret.x;
+            } else if (caret.x - origin.x > fScrolledComposite.getSize().x) {
+                origin.x = caret.x - fScrolledComposite.getSize().x + 1;
+            }
+            fScrolledComposite.setOrigin(origin);
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // MouseMoveListener (StyledText)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void mouseMove(MouseEvent e) {
+        fCursorYCoordinate = e.y;
+        if (e.y < 0 || e.y > fStyledText.getSize().y) {
+            if (fHighlightedRank != Long.MIN_VALUE) {
+                fHighlightedRank = Long.MIN_VALUE;
+                refreshLineBackgrounds();
+            }
+            return;
+        }
+        int offset = fStyledText.getOffsetAtLocation(new Point(0, e.y));
+        int line = fStyledText.getLineAtOffset(offset);
+        if (line < fLines.size() - fTopLineIndex) {
+            LineData lineData = fLines.get(fTopLineIndex + line);
+            if (fHighlightedRank != lineData.rank) {
+                fHighlightedRank = lineData.rank;
+                refreshLineBackgrounds();
+            }
+        } else {
+            if (fHighlightedRank != Long.MIN_VALUE) {
+                fHighlightedRank = Long.MIN_VALUE;
+                refreshLineBackgrounds();
+            }
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // MouseTrackListener (StyledText)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void mouseExit(MouseEvent e) {
+        fCursorYCoordinate = -1;
+        if (fHighlightedRank != Long.MIN_VALUE) {
+            fHighlightedRank = Long.MIN_VALUE;
+            refreshLineBackgrounds();
+        }
+    }
+
+    @Override
+    public void mouseEnter(MouseEvent e) {
+        fCursorYCoordinate = e.y;
+    }
+
+    @Override
+    public void mouseHover(MouseEvent e) {
+    }
+
+    // ------------------------------------------------------------------------
+    // MouseWheelListener (StyledText)
+    // ------------------------------------------------------------------------
+    
+    @Override
+    public void mouseScrolled(MouseEvent e) {
+        if (fLines.size() == 0) {
+            return;
+        }
+        fHoldSelection++;
+        fTopLineIndex -= e.count;
+        loadLineData();
+        updateTextArea();
+        fHoldSelection = 0;
+        //fSlider.setSelection((int) (SLIDER_MAX * ((double) fLines.get(fTopLineIndex).rank / fTrace.getNbEvents())));
+        updateHighlightedRank();
+        fSlider.setSelection((int) (SLIDER_MAX * fTrace.getLocationRatio(fLines.get(fTopLineIndex).location)));
+    }
+    
+}
index 648b5da6a99b8cfe783c0f0f3e95a3168af17640..700eb58a8aef1d38d8d20260519892dc78c58a7b 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-\r
-/**\r
- * Interface for the time graph widget provider\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeGraphPresentationProvider {\r
-\r
-    /**\r
-     * Returns the name of state types.\r
-     *\r
-     * @return the name of state types\r
-     */\r
-    public String getStateTypeName();\r
-\r
-    /**\r
-     * Returns table of states with state name to state color relationship.\r
-     *\r
-     * @return table of states with color and name\r
-     *\r
-     * @see #getStateTableIndex\r
-     */\r
-    public StateItem[] getStateTable();\r
-\r
-    /**\r
-     * Returns the index in the state table corresponding to this time event.\r
-     * The index should correspond to a state in the state table,\r
-     * otherwise the color SWT.COLOR_BLACK will be used.\r
-     * If the index returned is negative, the event will not be drawn.\r
-     *\r
-     * @param event the time event\r
-     * @return the corresponding state table index\r
-     *\r
-     * @see #getStateTable\r
-     */\r
-    public int getStateTableIndex(ITimeEvent event);\r
-\r
-    /**\r
-     * Called after drawing the control\r
-     *\r
-     * @param bounds\r
-     *            The drawing rectangle\r
-     * @param gc\r
-     *            The graphics context\r
-     */\r
-    public void postDrawControl(Rectangle bounds, GC gc);\r
-\r
-    /**\r
-     * Called after drawing an entry\r
-     *\r
-     * @param entry\r
-     *            the entry that was drawn\r
-     * @param bounds\r
-     *            the drawing rectangle\r
-     * @param gc\r
-     *            the graphics context\r
-     */\r
-    public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc);\r
-\r
-    /**\r
-     * Called after drawing an event\r
-     *\r
-     * @param event\r
-     *            the event that was drawn\r
-     * @param bounds\r
-     *            the drawing rectangle\r
-     * @param gc\r
-     *            the graphics context\r
-     */\r
-    public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc);\r
-\r
-    /**\r
-     * Returns the height of this item. This value is ignored if the time graph has a fixed item height.\r
-     *\r
-     * @param entry the entry\r
-     * @return the item height\r
-     *\r
-     * @see TimeGraphViewer#setItemHeight\r
-     */\r
-    public int getItemHeight(ITimeGraphEntry entry);\r
-\r
-    /**\r
-     * Provides the image icon for a given entry.\r
-     *\r
-     * @param entry the entry\r
-     * @return the image icon\r
-     */\r
-    public Image getItemImage(ITimeGraphEntry entry);\r
-\r
-    /**\r
-     * Returns the name of this event.\r
-     *\r
-     * @param event\r
-     *            The event\r
-     * @return The event name\r
-     */\r
-    public String getEventName(ITimeEvent event);\r
-\r
-    /**\r
-     * Returns a map of name and value providing additional information\r
-     * to display in the tool tip for this event.\r
-     *\r
-     * @param event the time event\r
-     * @return a map of tool tip information\r
-     */\r
-    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event);\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ * Interface for the time graph widget provider
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITimeGraphPresentationProvider {
+
+    /**
+     * Returns the name of state types.
+     *
+     * @return the name of state types
+     */
+    public String getStateTypeName();
+
+    /**
+     * Returns table of states with state name to state color relationship.
+     *
+     * @return table of states with color and name
+     *
+     * @see #getStateTableIndex
+     */
+    public StateItem[] getStateTable();
+
+    /**
+     * Returns the index in the state table corresponding to this time event.
+     * The index should correspond to a state in the state table,
+     * otherwise the color SWT.COLOR_BLACK will be used.
+     * If the index returned is negative, the event will not be drawn.
+     *
+     * @param event the time event
+     * @return the corresponding state table index
+     *
+     * @see #getStateTable
+     */
+    public int getStateTableIndex(ITimeEvent event);
+
+    /**
+     * Called after drawing the control
+     *
+     * @param bounds
+     *            The drawing rectangle
+     * @param gc
+     *            The graphics context
+     */
+    public void postDrawControl(Rectangle bounds, GC gc);
+
+    /**
+     * Called after drawing an entry
+     *
+     * @param entry
+     *            the entry that was drawn
+     * @param bounds
+     *            the drawing rectangle
+     * @param gc
+     *            the graphics context
+     */
+    public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc);
+
+    /**
+     * Called after drawing an event
+     *
+     * @param event
+     *            the event that was drawn
+     * @param bounds
+     *            the drawing rectangle
+     * @param gc
+     *            the graphics context
+     */
+    public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc);
+
+    /**
+     * Returns the height of this item. This value is ignored if the time graph has a fixed item height.
+     *
+     * @param entry the entry
+     * @return the item height
+     *
+     * @see TimeGraphViewer#setItemHeight
+     */
+    public int getItemHeight(ITimeGraphEntry entry);
+
+    /**
+     * Provides the image icon for a given entry.
+     *
+     * @param entry the entry
+     * @return the image icon
+     */
+    public Image getItemImage(ITimeGraphEntry entry);
+
+    /**
+     * Returns the name of this event.
+     *
+     * @param event
+     *            The event
+     * @return The event name
+     */
+    public String getEventName(ITimeEvent event);
+
+    /**
+     * Returns a map of name and value providing additional information
+     * to display in the tool tip for this event.
+     *
+     * @param event the time event
+     * @return a map of tool tip information
+     */
+    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event);
+
 }
\ No newline at end of file
index a0824db24d107ed1dc0bc69badd32e5bada641f3..77aee8593f700ae1d25b9a3c1b84cc5eb6b1630e 100644 (file)
@@ -1,31 +1,31 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventListener;\r
-\r
-/**\r
- * A listener which is notified when a timegraph changes its visible time range.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeGraphRangeListener extends EventListener {\r
-\r
-    /**\r
-     * Notifies that the timegraph range has changed.\r
-     *\r
-     * @param event event object describing details\r
-     */\r
-    public void timeRangeUpdated(TimeGraphRangeUpdateEvent event);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventListener;
+
+/**
+ * A listener which is notified when a timegraph changes its visible time range.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITimeGraphRangeListener extends EventListener {
+
+    /**
+     * Notifies that the timegraph range has changed.
+     *
+     * @param event event object describing details
+     */
+    public void timeRangeUpdated(TimeGraphRangeUpdateEvent event);
+}
index 40b93cbedf8046b1742d825b5b25411fdfc6f800..456026eafc9905048af5e5485267a56cbed6aaec 100644 (file)
@@ -1,31 +1,31 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventListener;\r
-\r
-/**\r
- * A listener which is notified when a timegraph changes its selected time.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeGraphSelectionListener extends EventListener {\r
-\r
-    /**\r
-     * Notifies that the timegraph selected entry has changed.\r
-     *\r
-     * @param event event object describing details\r
-     */\r
-    public void selectionChanged(TimeGraphSelectionEvent event);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventListener;
+
+/**
+ * A listener which is notified when a timegraph changes its selected time.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITimeGraphSelectionListener extends EventListener {
+
+    /**
+     * Notifies that the timegraph selected entry has changed.
+     *
+     * @param event event object describing details
+     */
+    public void selectionChanged(TimeGraphSelectionEvent event);
+}
index 6bdd2e5abed7618d9647b3a22cf300a29bbbee3e..d3cd24e6779ad4a680d7736ff0f65f342eeea59a 100644 (file)
@@ -1,31 +1,31 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventListener;\r
-\r
-/**\r
- * A listener which is notified when a timegraph changes its selected time.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeGraphTimeListener extends EventListener {\r
-\r
-    /**\r
-     * Notifies that the timegraph selected time has changed.\r
-     *\r
-     * @param event event object describing details\r
-     */\r
-    public void timeSelected(TimeGraphTimeEvent event);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventListener;
+
+/**
+ * A listener which is notified when a timegraph changes its selected time.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITimeGraphTimeListener extends EventListener {
+
+    /**
+     * Notifies that the timegraph selected time has changed.
+     *
+     * @param event event object describing details
+     */
+    public void timeSelected(TimeGraphTimeEvent event);
+}
index 7eb942b9826a4f8ef3fcdc79d78cd8723f5ae681..2e14dec03b04896ae8c33002558e718a584837bb 100644 (file)
@@ -1,36 +1,36 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-/**\r
- * A listener which is notified when a timegraph expands or collapses an entry.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeGraphTreeListener {\r
-\r
-    /**\r
-     * Notifies that an entry in the timegraph has been collapsed.\r
-     *\r
-     * @param event event object describing details\r
-     */\r
-    public void treeCollapsed(TimeGraphTreeExpansionEvent event);\r
-\r
-    /**\r
-     * Notifies that an entry in the timegraph has been expanded.\r
-     *\r
-     * @param event event object describing details\r
-     */\r
-    public void treeExpanded(TimeGraphTreeExpansionEvent event);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+/**
+ * A listener which is notified when a timegraph expands or collapses an entry.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public interface ITimeGraphTreeListener {
+
+    /**
+     * Notifies that an entry in the timegraph has been collapsed.
+     *
+     * @param event event object describing details
+     */
+    public void treeCollapsed(TimeGraphTreeExpansionEvent event);
+
+    /**
+     * Notifies that an entry in the timegraph has been expanded.
+     *
+     * @param event event object describing details
+     */
+    public void treeExpanded(TimeGraphTreeExpansionEvent event);
+}
index f8039cd4c0f92b6add83d2ce988a1647a79a9783..10dd07d492c6459250a304916a5ece33f255ca5d 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-\r
-import org.eclipse.jface.viewers.ILabelProviderListener;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.ITableLabelProvider;\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.ITreeViewerListener;\r
-import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.jface.viewers.TreeExpansionEvent;\r
-import org.eclipse.jface.viewers.TreeViewer;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.events.ControlAdapter;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseTrackAdapter;\r
-import org.eclipse.swt.events.MouseWheelListener;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Listener;\r
-import org.eclipse.swt.widgets.Slider;\r
-import org.eclipse.swt.widgets.Tree;\r
-import org.eclipse.swt.widgets.TreeColumn;\r
-import org.eclipse.swt.widgets.TreeItem;\r
-\r
-/**\r
- * Time graph "combo" view (with the list/tree on the left and the gantt chart\r
- * on the right)\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphCombo extends Composite {\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constants\r
-    // ------------------------------------------------------------------------\r
-\r
-    private static final Object FILLER = new Object();\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Fields\r
-    // ------------------------------------------------------------------------\r
-\r
-    // The tree viewer\r
-    private TreeViewer fTreeViewer;\r
-\r
-    // The time viewer\r
-    private TimeGraphViewer fTimeGraphViewer;\r
-\r
-    // The selection listener map\r
-    private final HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper> fSelectionListenerMap = new HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper>();\r
-\r
-    // Flag to block the tree selection changed listener when triggered by the time graph combo\r
-    private boolean fInhibitTreeSelection = false;\r
-\r
-    // Number of filler rows used by the tree content provider\r
-    private int fNumFillerRows;\r
-\r
-    // Calculated item height for Linux workaround\r
-    private int fLinuxItemHeight = 0;\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Classes\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * The TreeContentProviderWrapper is used to insert filler items after\r
-     * the elements of the tree's real content provider.\r
-     */\r
-    private class TreeContentProviderWrapper implements ITreeContentProvider {\r
-        private final ITreeContentProvider contentProvider;\r
-\r
-        public TreeContentProviderWrapper(ITreeContentProvider contentProvider) {\r
-            this.contentProvider = contentProvider;\r
-        }\r
-\r
-        @Override\r
-        public void dispose() {\r
-            contentProvider.dispose();\r
-        }\r
-\r
-        @Override\r
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-            contentProvider.inputChanged(viewer, oldInput, newInput);\r
-        }\r
-\r
-        @Override\r
-        public Object[] getElements(Object inputElement) {\r
-            Object[] elements = contentProvider.getElements(inputElement);\r
-            // add filler elements to ensure alignment with time analysis viewer\r
-            Object[] oElements = Arrays.copyOf(elements, elements.length + fNumFillerRows, new Object[0].getClass());\r
-            for (int i = 0; i < fNumFillerRows; i++) {\r
-                oElements[elements.length + i] = FILLER;\r
-            }\r
-            return oElements;\r
-        }\r
-\r
-        @Override\r
-        public Object[] getChildren(Object parentElement) {\r
-            if (parentElement instanceof ITimeGraphEntry) {\r
-                return contentProvider.getChildren(parentElement);\r
-            }\r
-            return new Object[0];\r
-        }\r
-\r
-        @Override\r
-        public Object getParent(Object element) {\r
-            if (element instanceof ITimeGraphEntry) {\r
-                return contentProvider.getParent(element);\r
-            }\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public boolean hasChildren(Object element) {\r
-            if (element instanceof ITimeGraphEntry) {\r
-                return contentProvider.hasChildren(element);\r
-            }\r
-            return false;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * The TreeLabelProviderWrapper is used to intercept the filler items\r
-     * from the calls to the tree's real label provider.\r
-     */\r
-    private class TreeLabelProviderWrapper implements ITableLabelProvider {\r
-        private final ITableLabelProvider labelProvider;\r
-\r
-        public TreeLabelProviderWrapper(ITableLabelProvider labelProvider) {\r
-            this.labelProvider = labelProvider;\r
-        }\r
-\r
-        @Override\r
-        public void addListener(ILabelProviderListener listener) {\r
-            labelProvider.addListener(listener);\r
-        }\r
-\r
-        @Override\r
-        public void dispose() {\r
-            labelProvider.dispose();\r
-        }\r
-\r
-        @Override\r
-        public boolean isLabelProperty(Object element, String property) {\r
-            if (element instanceof ITimeGraphEntry) {\r
-                return labelProvider.isLabelProperty(element, property);\r
-            }\r
-            return false;\r
-        }\r
-\r
-        @Override\r
-        public void removeListener(ILabelProviderListener listener) {\r
-            labelProvider.removeListener(listener);\r
-        }\r
-\r
-        @Override\r
-        public Image getColumnImage(Object element, int columnIndex) {\r
-            if (element instanceof ITimeGraphEntry) {\r
-                return labelProvider.getColumnImage(element, columnIndex);\r
-            }\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public String getColumnText(Object element, int columnIndex) {\r
-            if (element instanceof ITimeGraphEntry) {\r
-                return labelProvider.getColumnText(element, columnIndex);\r
-            }\r
-            return null;\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * The SelectionListenerWrapper is used to intercept the filler items from\r
-     * the time graph combo's real selection listener, and to prevent double\r
-     * notifications from being sent when selection changes in both tree and\r
-     * time graph at the same time.\r
-     */\r
-    private class SelectionListenerWrapper implements ISelectionChangedListener, ITimeGraphSelectionListener {\r
-        private final ITimeGraphSelectionListener listener;\r
-        private ITimeGraphEntry selection = null;\r
-\r
-        public SelectionListenerWrapper(ITimeGraphSelectionListener listener) {\r
-            this.listener = listener;\r
-        }\r
-\r
-        @Override\r
-        public void selectionChanged(SelectionChangedEvent event) {\r
-            if (fInhibitTreeSelection) {\r
-                return;\r
-            }\r
-            Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();\r
-            if (element instanceof ITimeGraphEntry) {\r
-                ITimeGraphEntry entry = (ITimeGraphEntry) element;\r
-                if (entry != selection) {\r
-                    selection = entry;\r
-                    listener.selectionChanged(new TimeGraphSelectionEvent(event.getSource(), selection));\r
-                }\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public void selectionChanged(TimeGraphSelectionEvent event) {\r
-            ITimeGraphEntry entry = event.getSelection();\r
-            if (entry != selection) {\r
-                selection = entry;\r
-                listener.selectionChanged(new TimeGraphSelectionEvent(event.getSource(), selection));\r
-            }\r
-        }\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constructors\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Constructs a new instance of this class given its parent\r
-     * and a style value describing its behavior and appearance.\r
-     *\r
-     * @param parent a widget which will be the parent of the new instance (cannot be null)\r
-     * @param style the style of widget to construct\r
-     */\r
-    public TimeGraphCombo(Composite parent, int style) {\r
-        super(parent, style);\r
-        setLayout(new FillLayout());\r
-\r
-        final SashForm sash = new SashForm(this, SWT.NONE);\r
-\r
-        fTreeViewer = new TreeViewer(sash, SWT.FULL_SELECTION | SWT.H_SCROLL);\r
-        final Tree tree = fTreeViewer.getTree();\r
-        tree.setHeaderVisible(true);\r
-        tree.setLinesVisible(true);\r
-\r
-        fTimeGraphViewer = new TimeGraphViewer(sash, SWT.NONE);\r
-        fTimeGraphViewer.setItemHeight(getItemHeight(tree));\r
-        fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());\r
-        fTimeGraphViewer.setBorderWidth(tree.getBorderWidth());\r
-        fTimeGraphViewer.setNameWidthPref(0);\r
-\r
-        // Feature in Windows. The tree vertical bar reappears when\r
-        // the control is resized so we need to hide it again.\r
-        // Bug in Linux. The tree header height is 0 in constructor,\r
-        // so we need to reset it later when the control is resized.\r
-        tree.addControlListener(new ControlAdapter() {\r
-            int depth = 0;\r
-            @Override\r
-            public void controlResized(ControlEvent e) {\r
-                if (depth == 0) {\r
-                    depth++;\r
-                    tree.getVerticalBar().setEnabled(false);\r
-                    // this can trigger controlResized recursively\r
-                    tree.getVerticalBar().setVisible(false);\r
-                    depth--;\r
-                }\r
-                fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());\r
-            }\r
-        });\r
-\r
-        // ensure synchronization of expanded items between tree and time graph\r
-        fTreeViewer.addTreeListener(new ITreeViewerListener() {\r
-            @Override\r
-            public void treeCollapsed(TreeExpansionEvent event) {\r
-                fTimeGraphViewer.setExpandedState((ITimeGraphEntry) event.getElement(), false);\r
-            }\r
-\r
-            @Override\r
-            public void treeExpanded(TreeExpansionEvent event) {\r
-                fTimeGraphViewer.setExpandedState((ITimeGraphEntry) event.getElement(), true);\r
-            }\r
-        });\r
-\r
-        // ensure synchronization of expanded items between tree and time graph\r
-        fTimeGraphViewer.addTreeListener(new ITimeGraphTreeListener() {\r
-            @Override\r
-            public void treeCollapsed(TimeGraphTreeExpansionEvent event) {\r
-                fTreeViewer.setExpandedState(event.getEntry(), false);\r
-            }\r
-\r
-            @Override\r
-            public void treeExpanded(TimeGraphTreeExpansionEvent event) {\r
-                fTreeViewer.setExpandedState(event.getEntry(), true);\r
-            }\r
-        });\r
-\r
-        // prevent mouse button from selecting a filler tree item\r
-        tree.addListener(SWT.MouseDown, new Listener() {\r
-            @Override\r
-            public void handleEvent(Event event) {\r
-                TreeItem treeItem = tree.getItem(new Point(event.x, event.y));\r
-                if (treeItem == null || treeItem.getData() == FILLER) {\r
-                    event.doit = false;\r
-                    ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                    if (treeItems.size() == 0) {\r
-                        fTreeViewer.setSelection(new StructuredSelection());\r
-                        fTimeGraphViewer.setSelection(null);\r
-                        return;\r
-                    }\r
-                    // this prevents from scrolling up when selecting\r
-                    // the partially visible tree item at the bottom\r
-                    tree.select(treeItems.get(treeItems.size() - 1));\r
-                    fTreeViewer.setSelection(new StructuredSelection());\r
-                    fTimeGraphViewer.setSelection(null);\r
-                }\r
-            }\r
-        });\r
-\r
-        // prevent mouse wheel from scrolling down into filler tree items\r
-        tree.addListener(SWT.MouseWheel, new Listener() {\r
-            @Override\r
-            public void handleEvent(Event event) {\r
-                event.doit = false;\r
-                Slider scrollBar = fTimeGraphViewer.getVerticalBar();\r
-                fTimeGraphViewer.setTopIndex(scrollBar.getSelection() - event.count);\r
-                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                if (treeItems.size() == 0) {\r
-                    return;\r
-                }\r
-                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                tree.setTopItem(treeItem);\r
-            }\r
-        });\r
-\r
-        // prevent key stroke from selecting a filler tree item\r
-        tree.addListener(SWT.KeyDown, new Listener() {\r
-            @Override\r
-            public void handleEvent(Event event) {\r
-                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                if (treeItems.size() == 0) {\r
-                    fTreeViewer.setSelection(new StructuredSelection());\r
-                    event.doit = false;\r
-                    return;\r
-                }\r
-                if (event.keyCode == SWT.ARROW_DOWN) {\r
-                    int index = Math.min(fTimeGraphViewer.getSelectionIndex() + 1, treeItems.size() - 1);\r
-                    fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(index).getData());\r
-                    event.doit = false;\r
-                } else if (event.keyCode == SWT.PAGE_DOWN) {\r
-                    int height = tree.getSize().y - tree.getHeaderHeight() - tree.getHorizontalBar().getSize().y;\r
-                    int countPerPage = height / getItemHeight(tree);\r
-                    int index = Math.min(fTimeGraphViewer.getSelectionIndex() + countPerPage - 1, treeItems.size() - 1);\r
-                    fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(index).getData());\r
-                    event.doit = false;\r
-                } else if (event.keyCode == SWT.END) {\r
-                    fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(treeItems.size() - 1).getData());\r
-                    event.doit = false;\r
-                }\r
-                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                tree.setTopItem(treeItem);\r
-                if (fTimeGraphViewer.getSelectionIndex() >= 0) {\r
-                    fTreeViewer.setSelection(new StructuredSelection(fTimeGraphViewer.getSelection()));\r
-                } else {\r
-                    fTreeViewer.setSelection(new StructuredSelection());\r
-                }\r
-            }\r
-        });\r
-\r
-        // ensure alignment of top item between tree and time graph\r
-        fTimeGraphViewer.getTimeGraphControl().addControlListener(new ControlAdapter() {\r
-            @Override\r
-            public void controlResized(ControlEvent e) {\r
-                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                if (treeItems.size() == 0) {\r
-                    return;\r
-                }\r
-                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                tree.setTopItem(treeItem);\r
-            }\r
-        });\r
-\r
-        // ensure synchronization of selected item between tree and time graph\r
-        fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {\r
-            @Override\r
-            public void selectionChanged(SelectionChangedEvent event) {\r
-                if (fInhibitTreeSelection) {\r
-                    return;\r
-                }\r
-                if (event.getSelection() instanceof IStructuredSelection) {\r
-                    Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();\r
-                    if (selection instanceof ITimeGraphEntry) {\r
-                        fTimeGraphViewer.setSelection((ITimeGraphEntry) selection);\r
-                    }\r
-                    ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                    if (treeItems.size() == 0) {\r
-                        return;\r
-                    }\r
-                    TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                    tree.setTopItem(treeItem);\r
-                }\r
-            }\r
-        });\r
-\r
-        // ensure synchronization of selected item between tree and time graph\r
-        fTimeGraphViewer.addSelectionListener(new ITimeGraphSelectionListener() {\r
-            @Override\r
-            public void selectionChanged(TimeGraphSelectionEvent event) {\r
-                ITimeGraphEntry entry = fTimeGraphViewer.getSelection();\r
-                fInhibitTreeSelection = true; // block the tree selection changed listener\r
-                if (entry != null) {\r
-                    StructuredSelection selection = new StructuredSelection(entry);\r
-                    fTreeViewer.setSelection(selection);\r
-                } else {\r
-                    fTreeViewer.setSelection(new StructuredSelection());\r
-                }\r
-                fInhibitTreeSelection = false;\r
-                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                if (treeItems.size() == 0) {\r
-                    return;\r
-                }\r
-                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                tree.setTopItem(treeItem);\r
-            }\r
-        });\r
-\r
-        // ensure alignment of top item between tree and time graph\r
-        fTimeGraphViewer.getVerticalBar().addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                if (treeItems.size() == 0) {\r
-                    return;\r
-                }\r
-                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                tree.setTopItem(treeItem);\r
-            }\r
-        });\r
-\r
-        // ensure alignment of top item between tree and time graph\r
-        fTimeGraphViewer.getTimeGraphControl().addMouseWheelListener(new MouseWheelListener() {\r
-            @Override\r
-            public void mouseScrolled(MouseEvent e) {\r
-                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-                if (treeItems.size() == 0) {\r
-                    return;\r
-                }\r
-                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-                tree.setTopItem(treeItem);\r
-            }\r
-        });\r
-\r
-        // ensure the tree has focus control when mouse is over it if the time graph had control\r
-        fTreeViewer.getControl().addMouseTrackListener(new MouseTrackAdapter() {\r
-            @Override\r
-            public void mouseEnter(MouseEvent e) {\r
-                if (fTimeGraphViewer.getTimeGraphControl().isFocusControl()) {\r
-                    fTreeViewer.getControl().setFocus();\r
-                }\r
-            }\r
-        });\r
-\r
-        // ensure the time graph has focus control when mouse is over it if the tree had control\r
-        fTimeGraphViewer.getTimeGraphControl().addMouseTrackListener(new MouseTrackAdapter() {\r
-            @Override\r
-            public void mouseEnter(MouseEvent e) {\r
-                if (fTreeViewer.getControl().isFocusControl()) {\r
-                    fTimeGraphViewer.getTimeGraphControl().setFocus();\r
-                }\r
-            }\r
-        });\r
-        fTimeGraphViewer.getTimeGraphScale().addMouseTrackListener(new MouseTrackAdapter() {\r
-            @Override\r
-            public void mouseEnter(MouseEvent e) {\r
-                if (fTreeViewer.getControl().isFocusControl()) {\r
-                    fTimeGraphViewer.getTimeGraphControl().setFocus();\r
-                }\r
-            }\r
-        });\r
-\r
-        // The filler rows are required to ensure alignment when the tree does not have a\r
-        // visible horizontal scroll bar. The tree does not allow its top item to be set\r
-        // to a value that would cause blank space to be drawn at the bottom of the tree.\r
-        fNumFillerRows = Display.getDefault().getBounds().height / getItemHeight(tree);\r
-\r
-        sash.setWeights(new int[] { 1, 1 });\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Accessors\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Returns this time graph combo's tree viewer.\r
-     *\r
-     * @return the tree viewer\r
-     */\r
-    public TreeViewer getTreeViewer() {\r
-        return fTreeViewer;\r
-    }\r
-\r
-    /**\r
-     * Returns this time graph combo's time graph viewer.\r
-     *\r
-     * @return the time graph viewer\r
-     */\r
-    public TimeGraphViewer getTimeGraphViewer() {\r
-        return fTimeGraphViewer;\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Control\r
-    // ------------------------------------------------------------------------\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.swt.widgets.Control#redraw()\r
-     */\r
-    @Override\r
-    public void redraw() {\r
-        fTimeGraphViewer.getControl().redraw();\r
-        super.redraw();\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Operations\r
-    // ------------------------------------------------------------------------\r
-\r
-    /**\r
-     * Sets the tree content provider used by this time graph combo.\r
-     *\r
-     * @param contentProvider the tree content provider\r
-     */\r
-    public void setTreeContentProvider(ITreeContentProvider contentProvider) {\r
-        fTreeViewer.setContentProvider(new TreeContentProviderWrapper(contentProvider));\r
-    }\r
-\r
-    /**\r
-     * Sets the tree label provider used by this time graph combo.\r
-     *\r
-     * @param labelProvider the tree label provider\r
-     */\r
-    public void setTreeLabelProvider(ITableLabelProvider labelProvider) {\r
-        fTreeViewer.setLabelProvider(new TreeLabelProviderWrapper(labelProvider));\r
-    }\r
-\r
-    /**\r
-     * Sets the tree columns for this time graph combo.\r
-     *\r
-     * @param columnNames the tree column names\r
-     */\r
-    public void setTreeColumns(String[] columnNames) {\r
-        final Tree tree = fTreeViewer.getTree();\r
-        for (String columnName : columnNames) {\r
-            TreeColumn column = new TreeColumn(tree, SWT.LEFT);\r
-            column.setText(columnName);\r
-            column.pack();\r
-        }\r
-    }\r
-\r
-\r
-    /**\r
-     * Sets the time graph provider used by this time graph combo.\r
-     *\r
-     * @param timeGraphProvider the time graph provider\r
-     */\r
-    public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {\r
-        fTimeGraphViewer.setTimeGraphProvider(timeGraphProvider);\r
-    }\r
-\r
-    /**\r
-     * Sets or clears the input for this time graph combo.\r
-     * The input array should only contain top-level elements.\r
-     *\r
-     * @param input the input of this time graph combo, or <code>null</code> if none\r
-     */\r
-    public void setInput(ITimeGraphEntry[] input) {\r
-        fInhibitTreeSelection = true;\r
-        fTreeViewer.setInput(input);\r
-        for (SelectionListenerWrapper listenerWrapper : fSelectionListenerMap.values()) {\r
-            listenerWrapper.selection = null;\r
-        }\r
-        fInhibitTreeSelection = false;\r
-        fTreeViewer.expandAll();\r
-        fTreeViewer.getTree().getVerticalBar().setEnabled(false);\r
-        fTreeViewer.getTree().getVerticalBar().setVisible(false);\r
-        fTimeGraphViewer.setItemHeight(getItemHeight(fTreeViewer.getTree()));\r
-        fTimeGraphViewer.setInput(input);\r
-    }\r
-\r
-    /**\r
-     * Refreshes this time graph completely with information freshly obtained from its model.\r
-     */\r
-    public void refresh() {\r
-        fTreeViewer.refresh();\r
-        fTimeGraphViewer.refresh();\r
-    }\r
-\r
-    /**\r
-     * Adds a listener for selection changes in this time graph combo.\r
-     *\r
-     * @param listener a selection listener\r
-     */\r
-    public void addSelectionListener(ITimeGraphSelectionListener listener) {\r
-        SelectionListenerWrapper listenerWrapper = new SelectionListenerWrapper(listener);\r
-        fTreeViewer.addSelectionChangedListener(listenerWrapper);\r
-        fSelectionListenerMap.put(listener, listenerWrapper);\r
-        fTimeGraphViewer.addSelectionListener(listenerWrapper);\r
-    }\r
-\r
-    /**\r
-     * Removes the given selection listener from this time graph combo.\r
-     *\r
-     * @param listener a selection changed listener\r
-     */\r
-    public void removeSelectionListener(ITimeGraphSelectionListener listener) {\r
-        SelectionListenerWrapper listenerWrapper = fSelectionListenerMap.remove(listener);\r
-        fTreeViewer.removeSelectionChangedListener(listenerWrapper);\r
-        fTimeGraphViewer.removeSelectionListener(listenerWrapper);\r
-    }\r
-\r
-    /**\r
-     * Sets the current selection for this time graph combo.\r
-     *\r
-     * @param selection the new selection\r
-     */\r
-    public void setSelection(ITimeGraphEntry selection) {\r
-        fTimeGraphViewer.setSelection(selection);\r
-        fInhibitTreeSelection = true; // block the tree selection changed listener\r
-        if (selection != null) {\r
-            StructuredSelection structuredSelection = new StructuredSelection(selection);\r
-            fTreeViewer.setSelection(structuredSelection);\r
-        } else {\r
-            fTreeViewer.setSelection(new StructuredSelection());\r
-        }\r
-        fInhibitTreeSelection = false;\r
-        ArrayList<TreeItem> treeItems = getVisibleExpandedItems(fTreeViewer.getTree());\r
-        if (treeItems.size() == 0) {\r
-            return;\r
-        }\r
-        TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());\r
-        fTreeViewer.getTree().setTopItem(treeItem);\r
-    }\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Internal\r
-    // ------------------------------------------------------------------------\r
-\r
-    private ArrayList<TreeItem> getVisibleExpandedItems(Tree tree) {\r
-        ArrayList<TreeItem> items = new ArrayList<TreeItem>();\r
-        for (TreeItem item : tree.getItems()) {\r
-            if (item.getData() == FILLER) {\r
-                break;\r
-            }\r
-            items.add(item);\r
-            if (item.getExpanded()) {\r
-                items.addAll(getVisibleExpandedItems(item));\r
-            }\r
-        }\r
-        return items;\r
-    }\r
-\r
-    private ArrayList<TreeItem> getVisibleExpandedItems(TreeItem treeItem) {\r
-        ArrayList<TreeItem> items = new ArrayList<TreeItem>();\r
-        for (TreeItem item : treeItem.getItems()) {\r
-            items.add(item);\r
-            if (item.getExpanded()) {\r
-                items.addAll(getVisibleExpandedItems(item));\r
-            }\r
-        }\r
-        return items;\r
-    }\r
-\r
-    private int getItemHeight(final Tree tree) {\r
-        /*\r
-         * Bug in Linux.  The method getItemHeight doesn't always return the correct value.\r
-         */\r
-        if (fLinuxItemHeight >= 0 && System.getProperty("os.name").contains("Linux")) { //$NON-NLS-1$ //$NON-NLS-2$\r
-            if (fLinuxItemHeight != 0) {\r
-                return fLinuxItemHeight;\r
-            }\r
-            ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);\r
-            if (treeItems.size() > 1) {\r
-                final TreeItem treeItem0 = treeItems.get(0);\r
-                final TreeItem treeItem1 = treeItems.get(1);\r
-                PaintListener paintListener = new PaintListener() {\r
-                    @Override\r
-                    public void paintControl(PaintEvent e) {\r
-                        tree.removePaintListener(this);\r
-                        int y0 = treeItem0.getBounds().y;\r
-                        int y1 = treeItem1.getBounds().y;\r
-                        int itemHeight = y1 - y0;\r
-                        if (itemHeight > 0) {\r
-                            fLinuxItemHeight = itemHeight;\r
-                            fTimeGraphViewer.setItemHeight(itemHeight);\r
-                        }\r
-                    }\r
-                };\r
-                tree.addPaintListener(paintListener);\r
-            }\r
-        } else {\r
-            fLinuxItemHeight = -1; // Not Linux, don't perform os.name check anymore\r
-        }\r
-        return tree.getItemHeight();\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeViewerListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeExpansionEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.MouseWheelListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Time graph "combo" view (with the list/tree on the left and the gantt chart
+ * on the right)
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeGraphCombo extends Composite {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+
+    private static final Object FILLER = new Object();
+
+    // ------------------------------------------------------------------------
+    // Fields
+    // ------------------------------------------------------------------------
+
+    // The tree viewer
+    private TreeViewer fTreeViewer;
+
+    // The time viewer
+    private TimeGraphViewer fTimeGraphViewer;
+
+    // The selection listener map
+    private final HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper> fSelectionListenerMap = new HashMap<ITimeGraphSelectionListener, SelectionListenerWrapper>();
+
+    // Flag to block the tree selection changed listener when triggered by the time graph combo
+    private boolean fInhibitTreeSelection = false;
+
+    // Number of filler rows used by the tree content provider
+    private int fNumFillerRows;
+
+    // Calculated item height for Linux workaround
+    private int fLinuxItemHeight = 0;
+
+    // ------------------------------------------------------------------------
+    // Classes
+    // ------------------------------------------------------------------------
+
+    /**
+     * The TreeContentProviderWrapper is used to insert filler items after
+     * the elements of the tree's real content provider.
+     */
+    private class TreeContentProviderWrapper implements ITreeContentProvider {
+        private final ITreeContentProvider contentProvider;
+
+        public TreeContentProviderWrapper(ITreeContentProvider contentProvider) {
+            this.contentProvider = contentProvider;
+        }
+
+        @Override
+        public void dispose() {
+            contentProvider.dispose();
+        }
+
+        @Override
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+            contentProvider.inputChanged(viewer, oldInput, newInput);
+        }
+
+        @Override
+        public Object[] getElements(Object inputElement) {
+            Object[] elements = contentProvider.getElements(inputElement);
+            // add filler elements to ensure alignment with time analysis viewer
+            Object[] oElements = Arrays.copyOf(elements, elements.length + fNumFillerRows, new Object[0].getClass());
+            for (int i = 0; i < fNumFillerRows; i++) {
+                oElements[elements.length + i] = FILLER;
+            }
+            return oElements;
+        }
+
+        @Override
+        public Object[] getChildren(Object parentElement) {
+            if (parentElement instanceof ITimeGraphEntry) {
+                return contentProvider.getChildren(parentElement);
+            }
+            return new Object[0];
+        }
+
+        @Override
+        public Object getParent(Object element) {
+            if (element instanceof ITimeGraphEntry) {
+                return contentProvider.getParent(element);
+            }
+            return null;
+        }
+
+        @Override
+        public boolean hasChildren(Object element) {
+            if (element instanceof ITimeGraphEntry) {
+                return contentProvider.hasChildren(element);
+            }
+            return false;
+        }
+    }
+
+    /**
+     * The TreeLabelProviderWrapper is used to intercept the filler items
+     * from the calls to the tree's real label provider.
+     */
+    private class TreeLabelProviderWrapper implements ITableLabelProvider {
+        private final ITableLabelProvider labelProvider;
+
+        public TreeLabelProviderWrapper(ITableLabelProvider labelProvider) {
+            this.labelProvider = labelProvider;
+        }
+
+        @Override
+        public void addListener(ILabelProviderListener listener) {
+            labelProvider.addListener(listener);
+        }
+
+        @Override
+        public void dispose() {
+            labelProvider.dispose();
+        }
+
+        @Override
+        public boolean isLabelProperty(Object element, String property) {
+            if (element instanceof ITimeGraphEntry) {
+                return labelProvider.isLabelProperty(element, property);
+            }
+            return false;
+        }
+
+        @Override
+        public void removeListener(ILabelProviderListener listener) {
+            labelProvider.removeListener(listener);
+        }
+
+        @Override
+        public Image getColumnImage(Object element, int columnIndex) {
+            if (element instanceof ITimeGraphEntry) {
+                return labelProvider.getColumnImage(element, columnIndex);
+            }
+            return null;
+        }
+
+        @Override
+        public String getColumnText(Object element, int columnIndex) {
+            if (element instanceof ITimeGraphEntry) {
+                return labelProvider.getColumnText(element, columnIndex);
+            }
+            return null;
+        }
+
+    }
+
+    /**
+     * The SelectionListenerWrapper is used to intercept the filler items from
+     * the time graph combo's real selection listener, and to prevent double
+     * notifications from being sent when selection changes in both tree and
+     * time graph at the same time.
+     */
+    private class SelectionListenerWrapper implements ISelectionChangedListener, ITimeGraphSelectionListener {
+        private final ITimeGraphSelectionListener listener;
+        private ITimeGraphEntry selection = null;
+
+        public SelectionListenerWrapper(ITimeGraphSelectionListener listener) {
+            this.listener = listener;
+        }
+
+        @Override
+        public void selectionChanged(SelectionChangedEvent event) {
+            if (fInhibitTreeSelection) {
+                return;
+            }
+            Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
+            if (element instanceof ITimeGraphEntry) {
+                ITimeGraphEntry entry = (ITimeGraphEntry) element;
+                if (entry != selection) {
+                    selection = entry;
+                    listener.selectionChanged(new TimeGraphSelectionEvent(event.getSource(), selection));
+                }
+            }
+        }
+
+        @Override
+        public void selectionChanged(TimeGraphSelectionEvent event) {
+            ITimeGraphEntry entry = event.getSelection();
+            if (entry != selection) {
+                selection = entry;
+                listener.selectionChanged(new TimeGraphSelectionEvent(event.getSource(), selection));
+            }
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     */
+    public TimeGraphCombo(Composite parent, int style) {
+        super(parent, style);
+        setLayout(new FillLayout());
+
+        final SashForm sash = new SashForm(this, SWT.NONE);
+
+        fTreeViewer = new TreeViewer(sash, SWT.FULL_SELECTION | SWT.H_SCROLL);
+        final Tree tree = fTreeViewer.getTree();
+        tree.setHeaderVisible(true);
+        tree.setLinesVisible(true);
+
+        fTimeGraphViewer = new TimeGraphViewer(sash, SWT.NONE);
+        fTimeGraphViewer.setItemHeight(getItemHeight(tree));
+        fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());
+        fTimeGraphViewer.setBorderWidth(tree.getBorderWidth());
+        fTimeGraphViewer.setNameWidthPref(0);
+
+        // Feature in Windows. The tree vertical bar reappears when
+        // the control is resized so we need to hide it again.
+        // Bug in Linux. The tree header height is 0 in constructor,
+        // so we need to reset it later when the control is resized.
+        tree.addControlListener(new ControlAdapter() {
+            int depth = 0;
+            @Override
+            public void controlResized(ControlEvent e) {
+                if (depth == 0) {
+                    depth++;
+                    tree.getVerticalBar().setEnabled(false);
+                    // this can trigger controlResized recursively
+                    tree.getVerticalBar().setVisible(false);
+                    depth--;
+                }
+                fTimeGraphViewer.setHeaderHeight(tree.getHeaderHeight());
+            }
+        });
+
+        // ensure synchronization of expanded items between tree and time graph
+        fTreeViewer.addTreeListener(new ITreeViewerListener() {
+            @Override
+            public void treeCollapsed(TreeExpansionEvent event) {
+                fTimeGraphViewer.setExpandedState((ITimeGraphEntry) event.getElement(), false);
+            }
+
+            @Override
+            public void treeExpanded(TreeExpansionEvent event) {
+                fTimeGraphViewer.setExpandedState((ITimeGraphEntry) event.getElement(), true);
+            }
+        });
+
+        // ensure synchronization of expanded items between tree and time graph
+        fTimeGraphViewer.addTreeListener(new ITimeGraphTreeListener() {
+            @Override
+            public void treeCollapsed(TimeGraphTreeExpansionEvent event) {
+                fTreeViewer.setExpandedState(event.getEntry(), false);
+            }
+
+            @Override
+            public void treeExpanded(TimeGraphTreeExpansionEvent event) {
+                fTreeViewer.setExpandedState(event.getEntry(), true);
+            }
+        });
+
+        // prevent mouse button from selecting a filler tree item
+        tree.addListener(SWT.MouseDown, new Listener() {
+            @Override
+            public void handleEvent(Event event) {
+                TreeItem treeItem = tree.getItem(new Point(event.x, event.y));
+                if (treeItem == null || treeItem.getData() == FILLER) {
+                    event.doit = false;
+                    ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                    if (treeItems.size() == 0) {
+                        fTreeViewer.setSelection(new StructuredSelection());
+                        fTimeGraphViewer.setSelection(null);
+                        return;
+                    }
+                    // this prevents from scrolling up when selecting
+                    // the partially visible tree item at the bottom
+                    tree.select(treeItems.get(treeItems.size() - 1));
+                    fTreeViewer.setSelection(new StructuredSelection());
+                    fTimeGraphViewer.setSelection(null);
+                }
+            }
+        });
+
+        // prevent mouse wheel from scrolling down into filler tree items
+        tree.addListener(SWT.MouseWheel, new Listener() {
+            @Override
+            public void handleEvent(Event event) {
+                event.doit = false;
+                Slider scrollBar = fTimeGraphViewer.getVerticalBar();
+                fTimeGraphViewer.setTopIndex(scrollBar.getSelection() - event.count);
+                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                if (treeItems.size() == 0) {
+                    return;
+                }
+                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                tree.setTopItem(treeItem);
+            }
+        });
+
+        // prevent key stroke from selecting a filler tree item
+        tree.addListener(SWT.KeyDown, new Listener() {
+            @Override
+            public void handleEvent(Event event) {
+                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                if (treeItems.size() == 0) {
+                    fTreeViewer.setSelection(new StructuredSelection());
+                    event.doit = false;
+                    return;
+                }
+                if (event.keyCode == SWT.ARROW_DOWN) {
+                    int index = Math.min(fTimeGraphViewer.getSelectionIndex() + 1, treeItems.size() - 1);
+                    fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(index).getData());
+                    event.doit = false;
+                } else if (event.keyCode == SWT.PAGE_DOWN) {
+                    int height = tree.getSize().y - tree.getHeaderHeight() - tree.getHorizontalBar().getSize().y;
+                    int countPerPage = height / getItemHeight(tree);
+                    int index = Math.min(fTimeGraphViewer.getSelectionIndex() + countPerPage - 1, treeItems.size() - 1);
+                    fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(index).getData());
+                    event.doit = false;
+                } else if (event.keyCode == SWT.END) {
+                    fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(treeItems.size() - 1).getData());
+                    event.doit = false;
+                }
+                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                tree.setTopItem(treeItem);
+                if (fTimeGraphViewer.getSelectionIndex() >= 0) {
+                    fTreeViewer.setSelection(new StructuredSelection(fTimeGraphViewer.getSelection()));
+                } else {
+                    fTreeViewer.setSelection(new StructuredSelection());
+                }
+            }
+        });
+
+        // ensure alignment of top item between tree and time graph
+        fTimeGraphViewer.getTimeGraphControl().addControlListener(new ControlAdapter() {
+            @Override
+            public void controlResized(ControlEvent e) {
+                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                if (treeItems.size() == 0) {
+                    return;
+                }
+                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                tree.setTopItem(treeItem);
+            }
+        });
+
+        // ensure synchronization of selected item between tree and time graph
+        fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+            @Override
+            public void selectionChanged(SelectionChangedEvent event) {
+                if (fInhibitTreeSelection) {
+                    return;
+                }
+                if (event.getSelection() instanceof IStructuredSelection) {
+                    Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
+                    if (selection instanceof ITimeGraphEntry) {
+                        fTimeGraphViewer.setSelection((ITimeGraphEntry) selection);
+                    }
+                    ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                    if (treeItems.size() == 0) {
+                        return;
+                    }
+                    TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                    tree.setTopItem(treeItem);
+                }
+            }
+        });
+
+        // ensure synchronization of selected item between tree and time graph
+        fTimeGraphViewer.addSelectionListener(new ITimeGraphSelectionListener() {
+            @Override
+            public void selectionChanged(TimeGraphSelectionEvent event) {
+                ITimeGraphEntry entry = fTimeGraphViewer.getSelection();
+                fInhibitTreeSelection = true; // block the tree selection changed listener
+                if (entry != null) {
+                    StructuredSelection selection = new StructuredSelection(entry);
+                    fTreeViewer.setSelection(selection);
+                } else {
+                    fTreeViewer.setSelection(new StructuredSelection());
+                }
+                fInhibitTreeSelection = false;
+                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                if (treeItems.size() == 0) {
+                    return;
+                }
+                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                tree.setTopItem(treeItem);
+            }
+        });
+
+        // ensure alignment of top item between tree and time graph
+        fTimeGraphViewer.getVerticalBar().addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                if (treeItems.size() == 0) {
+                    return;
+                }
+                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                tree.setTopItem(treeItem);
+            }
+        });
+
+        // ensure alignment of top item between tree and time graph
+        fTimeGraphViewer.getTimeGraphControl().addMouseWheelListener(new MouseWheelListener() {
+            @Override
+            public void mouseScrolled(MouseEvent e) {
+                ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+                if (treeItems.size() == 0) {
+                    return;
+                }
+                TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+                tree.setTopItem(treeItem);
+            }
+        });
+
+        // ensure the tree has focus control when mouse is over it if the time graph had control
+        fTreeViewer.getControl().addMouseTrackListener(new MouseTrackAdapter() {
+            @Override
+            public void mouseEnter(MouseEvent e) {
+                if (fTimeGraphViewer.getTimeGraphControl().isFocusControl()) {
+                    fTreeViewer.getControl().setFocus();
+                }
+            }
+        });
+
+        // ensure the time graph has focus control when mouse is over it if the tree had control
+        fTimeGraphViewer.getTimeGraphControl().addMouseTrackListener(new MouseTrackAdapter() {
+            @Override
+            public void mouseEnter(MouseEvent e) {
+                if (fTreeViewer.getControl().isFocusControl()) {
+                    fTimeGraphViewer.getTimeGraphControl().setFocus();
+                }
+            }
+        });
+        fTimeGraphViewer.getTimeGraphScale().addMouseTrackListener(new MouseTrackAdapter() {
+            @Override
+            public void mouseEnter(MouseEvent e) {
+                if (fTreeViewer.getControl().isFocusControl()) {
+                    fTimeGraphViewer.getTimeGraphControl().setFocus();
+                }
+            }
+        });
+
+        // The filler rows are required to ensure alignment when the tree does not have a
+        // visible horizontal scroll bar. The tree does not allow its top item to be set
+        // to a value that would cause blank space to be drawn at the bottom of the tree.
+        fNumFillerRows = Display.getDefault().getBounds().height / getItemHeight(tree);
+
+        sash.setWeights(new int[] { 1, 1 });
+    }
+
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Returns this time graph combo's tree viewer.
+     *
+     * @return the tree viewer
+     */
+    public TreeViewer getTreeViewer() {
+        return fTreeViewer;
+    }
+
+    /**
+     * Returns this time graph combo's time graph viewer.
+     *
+     * @return the time graph viewer
+     */
+    public TimeGraphViewer getTimeGraphViewer() {
+        return fTimeGraphViewer;
+    }
+
+    // ------------------------------------------------------------------------
+    // Control
+    // ------------------------------------------------------------------------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.widgets.Control#redraw()
+     */
+    @Override
+    public void redraw() {
+        fTimeGraphViewer.getControl().redraw();
+        super.redraw();
+    }
+
+    // ------------------------------------------------------------------------
+    // Operations
+    // ------------------------------------------------------------------------
+
+    /**
+     * Sets the tree content provider used by this time graph combo.
+     *
+     * @param contentProvider the tree content provider
+     */
+    public void setTreeContentProvider(ITreeContentProvider contentProvider) {
+        fTreeViewer.setContentProvider(new TreeContentProviderWrapper(contentProvider));
+    }
+
+    /**
+     * Sets the tree label provider used by this time graph combo.
+     *
+     * @param labelProvider the tree label provider
+     */
+    public void setTreeLabelProvider(ITableLabelProvider labelProvider) {
+        fTreeViewer.setLabelProvider(new TreeLabelProviderWrapper(labelProvider));
+    }
+
+    /**
+     * Sets the tree columns for this time graph combo.
+     *
+     * @param columnNames the tree column names
+     */
+    public void setTreeColumns(String[] columnNames) {
+        final Tree tree = fTreeViewer.getTree();
+        for (String columnName : columnNames) {
+            TreeColumn column = new TreeColumn(tree, SWT.LEFT);
+            column.setText(columnName);
+            column.pack();
+        }
+    }
+
+
+    /**
+     * Sets the time graph provider used by this time graph combo.
+     *
+     * @param timeGraphProvider the time graph provider
+     */
+    public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {
+        fTimeGraphViewer.setTimeGraphProvider(timeGraphProvider);
+    }
+
+    /**
+     * Sets or clears the input for this time graph combo.
+     * The input array should only contain top-level elements.
+     *
+     * @param input the input of this time graph combo, or <code>null</code> if none
+     */
+    public void setInput(ITimeGraphEntry[] input) {
+        fInhibitTreeSelection = true;
+        fTreeViewer.setInput(input);
+        for (SelectionListenerWrapper listenerWrapper : fSelectionListenerMap.values()) {
+            listenerWrapper.selection = null;
+        }
+        fInhibitTreeSelection = false;
+        fTreeViewer.expandAll();
+        fTreeViewer.getTree().getVerticalBar().setEnabled(false);
+        fTreeViewer.getTree().getVerticalBar().setVisible(false);
+        fTimeGraphViewer.setItemHeight(getItemHeight(fTreeViewer.getTree()));
+        fTimeGraphViewer.setInput(input);
+    }
+
+    /**
+     * Refreshes this time graph completely with information freshly obtained from its model.
+     */
+    public void refresh() {
+        fTreeViewer.refresh();
+        fTimeGraphViewer.refresh();
+    }
+
+    /**
+     * Adds a listener for selection changes in this time graph combo.
+     *
+     * @param listener a selection listener
+     */
+    public void addSelectionListener(ITimeGraphSelectionListener listener) {
+        SelectionListenerWrapper listenerWrapper = new SelectionListenerWrapper(listener);
+        fTreeViewer.addSelectionChangedListener(listenerWrapper);
+        fSelectionListenerMap.put(listener, listenerWrapper);
+        fTimeGraphViewer.addSelectionListener(listenerWrapper);
+    }
+
+    /**
+     * Removes the given selection listener from this time graph combo.
+     *
+     * @param listener a selection changed listener
+     */
+    public void removeSelectionListener(ITimeGraphSelectionListener listener) {
+        SelectionListenerWrapper listenerWrapper = fSelectionListenerMap.remove(listener);
+        fTreeViewer.removeSelectionChangedListener(listenerWrapper);
+        fTimeGraphViewer.removeSelectionListener(listenerWrapper);
+    }
+
+    /**
+     * Sets the current selection for this time graph combo.
+     *
+     * @param selection the new selection
+     */
+    public void setSelection(ITimeGraphEntry selection) {
+        fTimeGraphViewer.setSelection(selection);
+        fInhibitTreeSelection = true; // block the tree selection changed listener
+        if (selection != null) {
+            StructuredSelection structuredSelection = new StructuredSelection(selection);
+            fTreeViewer.setSelection(structuredSelection);
+        } else {
+            fTreeViewer.setSelection(new StructuredSelection());
+        }
+        fInhibitTreeSelection = false;
+        ArrayList<TreeItem> treeItems = getVisibleExpandedItems(fTreeViewer.getTree());
+        if (treeItems.size() == 0) {
+            return;
+        }
+        TreeItem treeItem = treeItems.get(fTimeGraphViewer.getTopIndex());
+        fTreeViewer.getTree().setTopItem(treeItem);
+    }
+
+    // ------------------------------------------------------------------------
+    // Internal
+    // ------------------------------------------------------------------------
+
+    private ArrayList<TreeItem> getVisibleExpandedItems(Tree tree) {
+        ArrayList<TreeItem> items = new ArrayList<TreeItem>();
+        for (TreeItem item : tree.getItems()) {
+            if (item.getData() == FILLER) {
+                break;
+            }
+            items.add(item);
+            if (item.getExpanded()) {
+                items.addAll(getVisibleExpandedItems(item));
+            }
+        }
+        return items;
+    }
+
+    private ArrayList<TreeItem> getVisibleExpandedItems(TreeItem treeItem) {
+        ArrayList<TreeItem> items = new ArrayList<TreeItem>();
+        for (TreeItem item : treeItem.getItems()) {
+            items.add(item);
+            if (item.getExpanded()) {
+                items.addAll(getVisibleExpandedItems(item));
+            }
+        }
+        return items;
+    }
+
+    private int getItemHeight(final Tree tree) {
+        /*
+         * Bug in Linux.  The method getItemHeight doesn't always return the correct value.
+         */
+        if (fLinuxItemHeight >= 0 && System.getProperty("os.name").contains("Linux")) { //$NON-NLS-1$ //$NON-NLS-2$
+            if (fLinuxItemHeight != 0) {
+                return fLinuxItemHeight;
+            }
+            ArrayList<TreeItem> treeItems = getVisibleExpandedItems(tree);
+            if (treeItems.size() > 1) {
+                final TreeItem treeItem0 = treeItems.get(0);
+                final TreeItem treeItem1 = treeItems.get(1);
+                PaintListener paintListener = new PaintListener() {
+                    @Override
+                    public void paintControl(PaintEvent e) {
+                        tree.removePaintListener(this);
+                        int y0 = treeItem0.getBounds().y;
+                        int y1 = treeItem1.getBounds().y;
+                        int itemHeight = y1 - y0;
+                        if (itemHeight > 0) {
+                            fLinuxItemHeight = itemHeight;
+                            fTimeGraphViewer.setItemHeight(itemHeight);
+                        }
+                    }
+                };
+                tree.addPaintListener(paintListener);
+            }
+        } else {
+            fLinuxItemHeight = -1; // Not Linux, don't perform os.name check anymore
+        }
+        return tree.getItemHeight();
+    }
+
+}
index de63a2f7cff23a622cc97eae83ae805742a0379a..b30179cc9af5a9570a847005b7422482f82faed9 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010, 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *   Patrick Tasse - Refactoring\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-\r
-/**\r
- * Provider class for the time graph provider\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- *\r
- */\r
-public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider {\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Constants\r
-    // ------------------------------------------------------------------------\r
-    private static final int DEFAULT_ITEM_HEIGHT = 19;\r
-\r
-    // ------------------------------------------------------------------------\r
-    // Operations\r
-    // ------------------------------------------------------------------------\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTypeName()\r
-     */\r
-    @Override\r
-    public String getStateTypeName() {\r
-        return Messages.TmfTimeLegend_TRACE_STATES;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTable()\r
-     */\r
-    @Override\r
-    public StateItem[] getStateTable() {\r
-        return null;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventTableIndex(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)\r
-     */\r
-    @Override\r
-    public int getStateTableIndex(ITimeEvent event) {\r
-        return 0;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawControl(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)\r
-     */\r
-    @Override\r
-    public void postDrawControl(Rectangle bounds, GC gc) {\r
-        // Override to add own drawing code\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEntry(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)\r
-     */\r
-    @Override\r
-    public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc) {\r
-        // Override to add own drawing code\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEvent(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)\r
-     */\r
-    @Override\r
-    public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) {\r
-        // Override to add own drawing code\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemHeight(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)\r
-     */\r
-    @Override\r
-    public int getItemHeight(ITimeGraphEntry entry) {\r
-        return DEFAULT_ITEM_HEIGHT;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemImage(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)\r
-     */\r
-    @Override\r
-    public Image getItemImage(ITimeGraphEntry entry) {\r
-        return null;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)\r
-     */\r
-    @Override\r
-    public String getEventName(ITimeEvent event) {\r
-        return null;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)\r
-     */\r
-    @Override\r
-    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
-        return null;\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2010, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon - Initial API and implementation
+ *   Patrick Tasse - Refactoring
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.Map;
+
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ * Provider class for the time graph provider
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ *
+ */
+public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider {
+
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+    private static final int DEFAULT_ITEM_HEIGHT = 19;
+
+    // ------------------------------------------------------------------------
+    // Operations
+    // ------------------------------------------------------------------------
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTypeName()
+     */
+    @Override
+    public String getStateTypeName() {
+        return Messages.TmfTimeLegend_TRACE_STATES;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTable()
+     */
+    @Override
+    public StateItem[] getStateTable() {
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventTableIndex(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
+     */
+    @Override
+    public int getStateTableIndex(ITimeEvent event) {
+        return 0;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawControl(org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
+     */
+    @Override
+    public void postDrawControl(Rectangle bounds, GC gc) {
+        // Override to add own drawing code
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEntry(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
+     */
+    @Override
+    public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc) {
+        // Override to add own drawing code
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#postDrawEvent(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.graphics.GC)
+     */
+    @Override
+    public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) {
+        // Override to add own drawing code
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemHeight(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
+     */
+    @Override
+    public int getItemHeight(ITimeGraphEntry entry) {
+        return DEFAULT_ITEM_HEIGHT;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getItemImage(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)
+     */
+    @Override
+    public Image getItemImage(ITimeGraphEntry entry) {
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
+     */
+    @Override
+    public String getEventName(ITimeEvent event) {
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getEventHoverToolTipInfo(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent)
+     */
+    @Override
+    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {
+        return null;
+    }
+
 }
\ No newline at end of file
index 2013b1bcebcb7c532cb5bec4004b011683acd529..1d59f51e3ae32d6d404f7d9a3c4afa3e115d89e5 100644 (file)
@@ -1,71 +1,71 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventObject;\r
-\r
-/**\r
- * Notifier for the time graph that the time range has been updated.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphRangeUpdateEvent extends EventObject {\r
-\r
-    /**\r
-     * Default serial version UID for this class.\r
-     * @since 1.0\r
-     */\r
-    private static final long serialVersionUID = 1L;\r
-\r
-    /**\r
-     * The start time.\r
-     */\r
-    private final long fStartTime;\r
-\r
-    /**\r
-     * The end time.\r
-     */\r
-    private final long fEndTime;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param source\r
-     *            The source of this event\r
-     * @param startTime\r
-     *            The start time\r
-     * @param endTime\r
-     *            The end time\r
-     */\r
-    public TimeGraphRangeUpdateEvent(Object source, long startTime, long endTime) {\r
-        super(source);\r
-        fStartTime = startTime;\r
-        fEndTime = endTime;\r
-    }\r
-\r
-    /**\r
-     * @return the start time\r
-     */\r
-    public long getStartTime() {\r
-        return fStartTime;\r
-    }\r
-\r
-    /**\r
-     * @return the end time\r
-     */\r
-    public long getEndTime() {\r
-        return fEndTime;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventObject;
+
+/**
+ * Notifier for the time graph that the time range has been updated.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeGraphRangeUpdateEvent extends EventObject {
+
+    /**
+     * Default serial version UID for this class.
+     * @since 1.0
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The start time.
+     */
+    private final long fStartTime;
+
+    /**
+     * The end time.
+     */
+    private final long fEndTime;
+
+    /**
+     * Standard constructor
+     *
+     * @param source
+     *            The source of this event
+     * @param startTime
+     *            The start time
+     * @param endTime
+     *            The end time
+     */
+    public TimeGraphRangeUpdateEvent(Object source, long startTime, long endTime) {
+        super(source);
+        fStartTime = startTime;
+        fEndTime = endTime;
+    }
+
+    /**
+     * @return the start time
+     */
+    public long getStartTime() {
+        return fStartTime;
+    }
+
+    /**
+     * @return the end time
+     */
+    public long getEndTime() {
+        return fEndTime;
+    }
+
+}
index 842d3164c5dd142241d2cb21ed3593ee9f1ae9ad..eac0ded656b4dd934601b5e58fe35da45310f252 100644 (file)
@@ -1,58 +1,58 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventObject;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * Notifier for the time graph that an object in the views has been selected.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphSelectionEvent extends EventObject {\r
-\r
-    /**\r
-     * Default serial version UID for this class.\r
-     * @since 1.0\r
-     */\r
-    private static final long serialVersionUID = 1L;\r
-\r
-    /**\r
-     * The selected entry.\r
-     */\r
-    private final ITimeGraphEntry fSelection;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param source\r
-     *            The source of this event\r
-     * @param selection\r
-     *            The entry that was selected\r
-     */\r
-    public TimeGraphSelectionEvent(Object source, ITimeGraphEntry selection) {\r
-        super(source);\r
-        fSelection = selection;\r
-    }\r
-\r
-    /**\r
-     * @return the selected entry or null if the selection is empty.\r
-     */\r
-    public ITimeGraphEntry getSelection() {\r
-        return fSelection;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventObject;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * Notifier for the time graph that an object in the views has been selected.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeGraphSelectionEvent extends EventObject {
+
+    /**
+     * Default serial version UID for this class.
+     * @since 1.0
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The selected entry.
+     */
+    private final ITimeGraphEntry fSelection;
+
+    /**
+     * Standard constructor
+     *
+     * @param source
+     *            The source of this event
+     * @param selection
+     *            The entry that was selected
+     */
+    public TimeGraphSelectionEvent(Object source, ITimeGraphEntry selection) {
+        super(source);
+        fSelection = selection;
+    }
+
+    /**
+     * @return the selected entry or null if the selection is empty.
+     */
+    public ITimeGraphEntry getSelection() {
+        return fSelection;
+    }
+
+}
index 963bec2d382fb0e9456f411f3fe112c4f05be60c..b6c476ce30f594051447f4fe9cf58e137b638f50 100644 (file)
@@ -1,56 +1,56 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventObject;\r
-\r
-/**\r
- * Event for the time graph view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphTimeEvent extends EventObject {\r
-\r
-    /**\r
-     * Default serial version UID for this class.\r
-     * @since 1.0\r
-     */\r
-    private static final long serialVersionUID = 1L;\r
-\r
-    /**\r
-     * The selected time.\r
-     */\r
-    private final long fTime;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param source\r
-     *            The source of this event\r
-     * @param time\r
-     *            The time that was requested\r
-     */\r
-    public TimeGraphTimeEvent(Object source, long time) {\r
-        super(source);\r
-        fTime = time;\r
-    }\r
-\r
-    /**\r
-     * @return the selected time\r
-     */\r
-    public long getTime() {\r
-        return fTime;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventObject;
+
+/**
+ * Event for the time graph view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeGraphTimeEvent extends EventObject {
+
+    /**
+     * Default serial version UID for this class.
+     * @since 1.0
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The selected time.
+     */
+    private final long fTime;
+
+    /**
+     * Standard constructor
+     *
+     * @param source
+     *            The source of this event
+     * @param time
+     *            The time that was requested
+     */
+    public TimeGraphTimeEvent(Object source, long time) {
+        super(source);
+        fTime = time;
+    }
+
+    /**
+     * @return the selected time
+     */
+    public long getTime() {
+        return fTime;
+    }
+
+}
index 57683c6eb673997c794ed9e68ca490fa4a9e8d7e..9cf37a83733a04bf5dba2b978b49c748b22a127e 100644 (file)
@@ -1,57 +1,57 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.EventObject;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * Notifier for the time graph view that a tree has been expanded.\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphTreeExpansionEvent extends EventObject {\r
-\r
-    /**\r
-     * Default serial version UID for this class.\r
-     * @since 1.0\r
-     */\r
-    private static final long serialVersionUID = 1L;\r
-\r
-    /**\r
-     * The entry that was expanded or collapsed.\r
-     */\r
-    private final ITimeGraphEntry fEntry;\r
-\r
-    /**\r
-     * Creates a new event for the given source and entry.\r
-     *\r
-     * @param source the tree viewer\r
-     * @param entry the entry\r
-     */\r
-    public TimeGraphTreeExpansionEvent(Object source, ITimeGraphEntry entry) {\r
-        super(source);\r
-        fEntry = entry;\r
-    }\r
-\r
-    /**\r
-     * Returns the entry that got expanded or collapsed.\r
-     *\r
-     * @return the entry\r
-     */\r
-    public ITimeGraphEntry getEntry() {\r
-        return fEntry;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventObject;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * Notifier for the time graph view that a tree has been expanded.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeGraphTreeExpansionEvent extends EventObject {
+
+    /**
+     * Default serial version UID for this class.
+     * @since 1.0
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The entry that was expanded or collapsed.
+     */
+    private final ITimeGraphEntry fEntry;
+
+    /**
+     * Creates a new event for the given source and entry.
+     *
+     * @param source the tree viewer
+     * @param entry the entry
+     */
+    public TimeGraphTreeExpansionEvent(Object source, ITimeGraphEntry entry) {
+        super(source);
+        fEntry = entry;
+    }
+
+    /**
+     * Returns the entry that got expanded or collapsed.
+     *
+     * @return the entry
+     */
+    public ITimeGraphEntry getEntry() {
+        return fEntry;
+    }
+}
index ca3c629a53698a6acc83a7a1f5c724cfc6a3d2f0..c1cf32663f1257bbc55007d7330264fde30395e5 100644 (file)
-/*****************************************************************************\r
- * Copyright (c) 2007, 2008 Intel Corporation, 2009, 2010, 2011, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alexander N. Alexeev, Intel - Add monitors statistics support\r
- *   Alvaro Sanchez-Leon - Adapted for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TimeGraphLegend;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphScale;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphTooltipHandler;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.ControlAdapter;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.events.KeyAdapter;\r
-import org.eclipse.swt.events.KeyEvent;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseWheelListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.ScrollBar;\r
-import org.eclipse.swt.widgets.Slider;\r
-\r
-/**\r
- * Generic time graph viewer implementation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse, and others\r
- */\r
-public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {\r
-\r
-    /** vars */\r
-    private long _minTimeInterval;\r
-    private long _selectedTime;\r
-    private ITimeGraphEntry _selectedEntry;\r
-    private long _beginTime;\r
-    private long _endTime;\r
-    private long _time0;\r
-    private long _time1;\r
-    private long _time0_;\r
-    private long _time1_;\r
-    private long _time0_extSynch = 0;\r
-    private long _time1_extSynch = 0;\r
-    private boolean _timeRangeFixed;\r
-    private int _nameWidthPref = 200;\r
-    private int _minNameWidth = 6;\r
-    private int _nameWidth;\r
-    private Composite _dataViewer;\r
-\r
-    private TimeGraphControl _stateCtrl;\r
-    private TimeGraphScale _timeScaleCtrl;\r
-    private Slider _verticalScrollBar;\r
-    private TimeGraphTooltipHandler _threadTip;\r
-    private TimeGraphColorScheme _colors;\r
-    private ITimeGraphPresentationProvider fTimeGraphProvider;\r
-\r
-    ArrayList<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<ITimeGraphSelectionListener>();\r
-    ArrayList<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>();\r
-    ArrayList<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>();\r
-\r
-    // Calender Time format, using Epoch reference or Relative time\r
-    // format(default\r
-    private boolean calendarTimeFormat = false;\r
-    private int borderWidth = 0;\r
-    private int timeScaleHeight = 22;\r
-\r
-    private Action resetScale;\r
-    private Action showLegendAction;\r
-    private Action nextEventAction;\r
-    private Action prevEventAction;\r
-    private Action nextItemAction;\r
-    private Action previousItemAction;\r
-    private Action zoomInAction;\r
-    private Action zoomOutAction;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param parent\r
-     *            The parent UI composite object\r
-     * @param style\r
-     *            The style to use\r
-     */\r
-    public TimeGraphViewer(Composite parent, int style) {\r
-        createDataViewer(parent, style);\r
-    }\r
-\r
-    /**\r
-     * Sets the timegraph provider used by this timegraph viewer.\r
-     *\r
-     * @param timeGraphProvider the timegraph provider\r
-     */\r
-    public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {\r
-        fTimeGraphProvider = timeGraphProvider;\r
-        _stateCtrl.setTimeGraphProvider(timeGraphProvider);\r
-        _threadTip = new TimeGraphTooltipHandler(_dataViewer.getShell(), fTimeGraphProvider, this);\r
-        _threadTip.activateHoverHelp(_stateCtrl);\r
-    }\r
-\r
-    /**\r
-     * Sets or clears the input for this time graph viewer.\r
-     * The input array should only contain top-level elements.\r
-     *\r
-     * @param input the input of this time graph viewer, or <code>null</code> if none\r
-     */\r
-    public void setInput(ITimeGraphEntry[] input) {\r
-        if (null != _stateCtrl) {\r
-            if (null == input) {\r
-                input = new ITimeGraphEntry[0];\r
-            }\r
-            setTimeRange(input);\r
-            _verticalScrollBar.setEnabled(true);\r
-            setTopIndex(0);\r
-            _selectedTime = 0;\r
-            _selectedEntry = null;\r
-            refreshAllData(input);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Refresh the view\r
-     */\r
-    public void refresh() {\r
-        setInput(_stateCtrl.getTraces());\r
-    }\r
-\r
-    /**\r
-     * Callback for when the control is moved\r
-     *\r
-     * @param e\r
-     *            The caller event\r
-     */\r
-    public void controlMoved(ControlEvent e) {\r
-    }\r
-\r
-    /**\r
-     * Callback for when the control is resized\r
-     *\r
-     * @param e\r
-     *            The caller event\r
-     */\r
-    public void controlResized(ControlEvent e) {\r
-        resizeControls();\r
-    }\r
-\r
-    /**\r
-     * Handler for when the model is updated. Called from the display order in\r
-     * the API\r
-     *\r
-     * @param traces\r
-     *            The traces in the model\r
-     * @param start\r
-     *            The start time\r
-     * @param end\r
-     *            The end time\r
-     * @param updateTimeBounds\r
-     *            Should we updated the time bounds too\r
-     */\r
-    public void modelUpdate(ITimeGraphEntry[] traces, long start,\r
-            long end, boolean updateTimeBounds) {\r
-        if (null != _stateCtrl) {\r
-            //loadOptions();\r
-            updateInternalData(traces, start, end);\r
-            if (updateTimeBounds) {\r
-                _timeRangeFixed = true;\r
-                // set window to match limits\r
-                setStartFinishTime(_time0_, _time1_);\r
-            } else {\r
-                _stateCtrl.redraw();\r
-                _timeScaleCtrl.redraw();\r
-            }\r
-        }\r
-    }\r
-\r
-    protected String getViewTypeStr() {\r
-        return "viewoption.threads"; //$NON-NLS-1$\r
-    }\r
-\r
-    int getMarginWidth(int idx) {\r
-        return 0;\r
-    }\r
-\r
-    int getMarginHeight(int idx) {\r
-        return 0;\r
-    }\r
-\r
-    void loadOptions() {\r
-        _minTimeInterval = 1;\r
-        _selectedTime = -1;\r
-        _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$\r
-                _nameWidthPref, _minNameWidth, 1000);\r
-    }\r
-\r
-    void saveOptions() {\r
-        Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$\r
-    }\r
-\r
-    protected Control createDataViewer(Composite parent, int style) {\r
-        loadOptions();\r
-        _colors = new TimeGraphColorScheme();\r
-        _dataViewer = new Composite(parent, style) {\r
-            @Override\r
-            public void redraw() {\r
-                _timeScaleCtrl.redraw();\r
-                _stateCtrl.redraw();\r
-                super.redraw();\r
-            }\r
-        };\r
-        GridLayout gl = new GridLayout(2, false);\r
-        gl.marginHeight = borderWidth;\r
-        gl.marginWidth = 0;\r
-        gl.verticalSpacing = 0;\r
-        gl.horizontalSpacing = 0;\r
-        _dataViewer.setLayout(gl);\r
-\r
-        _timeScaleCtrl = new TimeGraphScale(_dataViewer, _colors);\r
-        _timeScaleCtrl.setTimeProvider(this);\r
-        _timeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));\r
-        _timeScaleCtrl.setHeight(timeScaleHeight);\r
-\r
-        _verticalScrollBar = new Slider(_dataViewer, SWT.VERTICAL | SWT.NO_FOCUS);\r
-        _verticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 2));\r
-        _verticalScrollBar.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                setTopIndex(_verticalScrollBar.getSelection());\r
-            }\r
-        });\r
-        _verticalScrollBar.setEnabled(false);\r
-\r
-        _stateCtrl = createTimeGraphControl();\r
-\r
-        _stateCtrl.setTimeProvider(this);\r
-        _stateCtrl.addSelectionListener(this);\r
-        _stateCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));\r
-        _stateCtrl.addMouseWheelListener(new MouseWheelListener() {\r
-            @Override\r
-            public void mouseScrolled(MouseEvent e) {\r
-                adjustVerticalScrollBar();\r
-            }\r
-        });\r
-        _stateCtrl.addKeyListener(new KeyAdapter() {\r
-            @Override\r
-            public void keyPressed(KeyEvent e) {\r
-                adjustVerticalScrollBar();\r
-            }\r
-        });\r
-\r
-        Composite filler = new Composite(_dataViewer, SWT.NONE);\r
-        GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);\r
-        gd.heightHint = _stateCtrl.getHorizontalBar().getSize().y;\r
-        filler.setLayoutData(gd);\r
-        filler.setLayout(new FillLayout());\r
-\r
-        _stateCtrl.addControlListener(new ControlAdapter() {\r
-            @Override\r
-            public void controlResized(ControlEvent event) {\r
-                resizeControls();\r
-            }\r
-        });\r
-        resizeControls();\r
-        _dataViewer.update();\r
-        adjustVerticalScrollBar();\r
-        return _dataViewer;\r
-    }\r
-\r
-    /**\r
-     * Dispose the view.\r
-     */\r
-    public void dispose() {\r
-        saveOptions();\r
-        _stateCtrl.dispose();\r
-        _dataViewer.dispose();\r
-        _colors.dispose();\r
-    }\r
-\r
-    protected TimeGraphControl createTimeGraphControl() {\r
-        return new TimeGraphControl(_dataViewer, _colors);\r
-    }\r
-\r
-    /**\r
-     * Resize the controls\r
-     */\r
-    public void resizeControls() {\r
-        Rectangle r = _dataViewer.getClientArea();\r
-        if (r.isEmpty()) {\r
-            return;\r
-        }\r
-\r
-        int width = r.width;\r
-        if (_nameWidth > width - _minNameWidth) {\r
-            _nameWidth = width - _minNameWidth;\r
-        }\r
-        if (_nameWidth < _minNameWidth) {\r
-            _nameWidth = _minNameWidth;\r
-        }\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Try to set most convenient time range for display.\r
-     *\r
-     * @param traces\r
-     *            The traces in the model\r
-     */\r
-    public void setTimeRange(ITimeGraphEntry traces[]) {\r
-        _endTime = 0;\r
-        _beginTime = -1;\r
-        for (int i = 0; i < traces.length; i++) {\r
-            ITimeGraphEntry entry = traces[i];\r
-            if (entry.getEndTime() >= entry.getStartTime() && entry.getEndTime() > 0) {\r
-                if (_beginTime < 0 || entry.getStartTime() < _beginTime) {\r
-                    _beginTime = entry.getStartTime();\r
-                }\r
-                if (entry.getEndTime() > _endTime) {\r
-                    _endTime = entry.getEndTime();\r
-                }\r
-            }\r
-        }\r
-\r
-        if (_beginTime < 0) {\r
-            _beginTime = 0;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Recalculate the time bounds\r
-     */\r
-    public void setTimeBounds() {\r
-        //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
-        _time0_ = _beginTime;\r
-        if (_time0_ < 0) {\r
-            _time0_ = 0;\r
-        }\r
-        // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;\r
-        _time1_ = _endTime;\r
-        // _time0_ = Math.floor(_time0_);\r
-        // _time1_ = Math.ceil(_time1_);\r
-        if (!_timeRangeFixed) {\r
-            _time0 = _time0_;\r
-            _time1 = _time1_;\r
-        }\r
-        if (_time1 - _time0 < _minTimeInterval) {\r
-            _time1 = Math.min(_time1_, _time0 + _minTimeInterval);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * @param traces\r
-     * @param start\r
-     * @param end\r
-     */\r
-    void updateInternalData(ITimeGraphEntry[] traces, long start, long end) {\r
-        if (null == traces) {\r
-            traces = new ITimeGraphEntry[0];\r
-        }\r
-        if ((start == 0 && end == 0) || start < 0 || end < 0) {\r
-            // Start and end time are unspecified and need to be determined from\r
-            // individual processes\r
-            setTimeRange(traces);\r
-        } else {\r
-            _beginTime = start;\r
-            _endTime = end;\r
-        }\r
-\r
-        refreshAllData(traces);\r
-    }\r
-\r
-    /**\r
-     * @param traces\r
-     */\r
-    private void refreshAllData(ITimeGraphEntry[] traces) {\r
-        setTimeBounds();\r
-        if (_selectedTime < _beginTime) {\r
-            _selectedTime = _beginTime;\r
-        } else if (_selectedTime > _endTime) {\r
-            _selectedTime = _endTime;\r
-        }\r
-        _stateCtrl.refreshData(traces);\r
-        _timeScaleCtrl.redraw();\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Callback for when this view is focused\r
-     */\r
-    public void setFocus() {\r
-        if (null != _stateCtrl) {\r
-            _stateCtrl.setFocus();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Get the current focus status of this view.\r
-     *\r
-     * @return If the view is currently focused, or not\r
-     */\r
-    public boolean isInFocus() {\r
-        return _stateCtrl.isInFocus();\r
-    }\r
-\r
-    /**\r
-     * Get the view's current selection\r
-     *\r
-     * @return The entry that is selected\r
-     */\r
-    public ITimeGraphEntry getSelection() {\r
-        return _stateCtrl.getSelectedTrace();\r
-    }\r
-\r
-    /**\r
-     * Get the index of the current selection\r
-     *\r
-     * @return The index\r
-     */\r
-    public int getSelectionIndex() {\r
-        return _stateCtrl.getSelectedIndex();\r
-    }\r
-\r
-    @Override\r
-    public long getTime0() {\r
-        return _time0;\r
-    }\r
-\r
-    @Override\r
-    public long getTime1() {\r
-        return _time1;\r
-    }\r
-\r
-    @Override\r
-    public long getMinTimeInterval() {\r
-        return _minTimeInterval;\r
-    }\r
-\r
-    @Override\r
-    public int getNameSpace() {\r
-        return _nameWidth;\r
-    }\r
-\r
-    @Override\r
-    public void setNameSpace(int width) {\r
-        _nameWidth = width;\r
-        width = _stateCtrl.getClientArea().width;\r
-        if (_nameWidth > width - 6) {\r
-            _nameWidth = width - 6;\r
-        }\r
-        if (_nameWidth < 6) {\r
-            _nameWidth = 6;\r
-        }\r
-        _stateCtrl.adjustScrolls();\r
-        _stateCtrl.redraw();\r
-        _timeScaleCtrl.redraw();\r
-    }\r
-\r
-    @Override\r
-    public int getTimeSpace() {\r
-        int w = _stateCtrl.getClientArea().width;\r
-        return w - _nameWidth;\r
-    }\r
-\r
-    @Override\r
-    public long getSelectedTime() {\r
-        return _selectedTime;\r
-    }\r
-\r
-    @Override\r
-    public long getBeginTime() {\r
-        return _beginTime;\r
-    }\r
-\r
-    @Override\r
-    public long getEndTime() {\r
-        return _endTime;\r
-    }\r
-\r
-    @Override\r
-    public long getMaxTime() {\r
-        return _time1_;\r
-    }\r
-\r
-    @Override\r
-    public long getMinTime() {\r
-        return _time0_;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
-     * #setStartFinishTimeNotify(long, long)\r
-     */\r
-    @Override\r
-    public void setStartFinishTimeNotify(long time0, long time1) {\r
-        setStartFinishTime(time0, time1);\r
-        notifyRangeListeners(time0, time1);\r
-    }\r
-\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()\r
-     */\r
-    @Override\r
-    public void notifyStartFinishTime() {\r
-        notifyRangeListeners(_time0, _time1);\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
-     * #setStartFinishTime(long, long)\r
-     */\r
-    @Override\r
-    public void setStartFinishTime(long time0, long time1) {\r
-        _time0 = time0;\r
-        if (_time0 < _time0_) {\r
-            _time0 = _time0_;\r
-        }\r
-        if (_time0 > _time1_) {\r
-            _time0 = _time1_;\r
-        }\r
-        _time1 = time1;\r
-        if (_time1 < _time0_) {\r
-            _time1 = _time0_;\r
-        }\r
-        if (_time1 > _time1_) {\r
-            _time1 = _time1_;\r
-        }\r
-        if (_time1 - _time0 < _minTimeInterval) {\r
-            _time1 = Math.min(_time1_, _time0 + _minTimeInterval);\r
-        }\r
-        _timeRangeFixed = true;\r
-        _stateCtrl.adjustScrolls();\r
-        _stateCtrl.redraw();\r
-        _timeScaleCtrl.redraw();\r
-    }\r
-\r
-    /**\r
-     * Set the time bounds to the provided values\r
-     *\r
-     * @param beginTime\r
-     *            The start time of the window\r
-     * @param endTime\r
-     *            The end time\r
-     */\r
-    public void setTimeBounds(long beginTime, long endTime) {\r
-        _beginTime = beginTime;\r
-        _endTime = endTime;\r
-        _time0_ = beginTime;\r
-        _time1_ = endTime;\r
-        _stateCtrl.adjustScrolls();\r
-    }\r
-\r
-    @Override\r
-    public void resetStartFinishTime() {\r
-        setStartFinishTimeNotify(_time0_, _time1_);\r
-        _timeRangeFixed = false;\r
-    }\r
-\r
-    @Override\r
-    public void setSelectedTimeNotify(long time, boolean ensureVisible) {\r
-        setSelectedTimeInt(time, ensureVisible, true);\r
-    }\r
-\r
-    @Override\r
-    public void setSelectedTime(long time, boolean ensureVisible) {\r
-        setSelectedTimeInt(time, ensureVisible, false);\r
-    }\r
-\r
-    private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) {\r
-        long time0 = _time0;\r
-        long time1 = _time1;\r
-        if (ensureVisible) {\r
-            long timeSpace = (long) ((_time1 - _time0) * .02);\r
-            long timeMid = (long) ((_time1 - _time0) * .5);\r
-            if (time < _time0 + timeSpace) {\r
-                long dt = _time0 - time + timeMid;\r
-                _time0 -= dt;\r
-                _time1 -= dt;\r
-            } else if (time > _time1 - timeSpace) {\r
-                long dt = time - _time1 + timeMid;\r
-                _time0 += dt;\r
-                _time1 += dt;\r
-            }\r
-            if (_time0 < _time0_) {\r
-                _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0));\r
-                _time0 = _time0_;\r
-            } else if (_time1 > _time1_) {\r
-                _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_));\r
-                _time1 = _time1_;\r
-            }\r
-        }\r
-        if (_time1 - _time0 < _minTimeInterval) {\r
-            _time1 = Math.min(_time1_, _time0 + _minTimeInterval);\r
-        }\r
-        _stateCtrl.adjustScrolls();\r
-        _stateCtrl.redraw();\r
-        _timeScaleCtrl.redraw();\r
-\r
-\r
-        boolean notifySelectedTime = (time != _selectedTime);\r
-        _selectedTime = time;\r
-\r
-        if (doNotify && ((time0 != _time0) || (time1 != _time1))) {\r
-            notifyRangeListeners(_time0, _time1);\r
-        }\r
-\r
-        if (doNotify && notifySelectedTime) {\r
-            notifyTimeListeners(_selectedTime);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void widgetDefaultSelected(SelectionEvent e) {\r
-        if (_selectedEntry != getSelection()) {\r
-            _selectedEntry = getSelection();\r
-            notifySelectionListeners(_selectedEntry);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void widgetSelected(SelectionEvent e) {\r
-        if (_selectedEntry != getSelection()) {\r
-            _selectedEntry = getSelection();\r
-            notifySelectionListeners(_selectedEntry);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Callback for when the next event is selected\r
-     */\r
-    public void selectNextEvent() {\r
-        _stateCtrl.selectNextEvent();\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Callback for when the previous event is selected\r
-     */\r
-    public void selectPrevEvent() {\r
-        _stateCtrl.selectPrevEvent();\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Callback for when the next item is selected\r
-     */\r
-    public void selectNextItem() {\r
-        _stateCtrl.selectNextTrace();\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Callback for when the previous item is selected\r
-     */\r
-    public void selectPrevItem() {\r
-        _stateCtrl.selectPrevTrace();\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Callback for the show legend action\r
-     */\r
-    public void showLegend() {\r
-        if (_dataViewer == null || _dataViewer.isDisposed()) {\r
-            return;\r
-        }\r
-\r
-        TimeGraphLegend.open(_dataViewer.getShell(), fTimeGraphProvider);\r
-    }\r
-\r
-    /**\r
-     * Callback for the Zoom In action\r
-     */\r
-    public void zoomIn() {\r
-        _stateCtrl.zoomIn();\r
-    }\r
-\r
-    /**\r
-     * Callback for the Zoom Out action\r
-     */\r
-    public void zoomOut() {\r
-        _stateCtrl.zoomOut();\r
-    }\r
-\r
-    private String getPreferenceString(String string) {\r
-        return getViewTypeStr() + "." + string; //$NON-NLS-1$\r
-    }\r
-\r
-    /**\r
-     * Add a selection listener\r
-     *\r
-     * @param listener\r
-     *            The listener to add\r
-     */\r
-    public void addSelectionListener(ITimeGraphSelectionListener listener) {\r
-        fSelectionListeners.add(listener);\r
-    }\r
-\r
-    /**\r
-     * Remove a selection listener\r
-     *\r
-     * @param listener\r
-     *            The listener to remove\r
-     */\r
-    public void removeSelectionListener(ITimeGraphSelectionListener listener) {\r
-        fSelectionListeners.remove(listener);\r
-    }\r
-\r
-    private void notifySelectionListeners(ITimeGraphEntry selection) {\r
-        TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection);\r
-\r
-        for (ITimeGraphSelectionListener listener : fSelectionListeners) {\r
-            listener.selectionChanged(event);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Add a time listener\r
-     *\r
-     * @param listener\r
-     *            The listener to add\r
-     */\r
-    public void addTimeListener(ITimeGraphTimeListener listener) {\r
-        fTimeListeners.add(listener);\r
-    }\r
-\r
-    /**\r
-     * Remove a time listener\r
-     *\r
-     * @param listener\r
-     *            The listener to remove\r
-     */\r
-    public void removeTimeListener(ITimeGraphTimeListener listener) {\r
-        fTimeListeners.remove(listener);\r
-    }\r
-\r
-    private void notifyTimeListeners(long time) {\r
-        TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, time);\r
-\r
-        for (ITimeGraphTimeListener listener : fTimeListeners) {\r
-            listener.timeSelected(event);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Add a range listener\r
-     *\r
-     * @param listener\r
-     *            The listener to add\r
-     */\r
-    public void addRangeListener(ITimeGraphRangeListener listener) {\r
-        fRangeListeners.add(listener);\r
-    }\r
-\r
-    /**\r
-     * Remove a range listener\r
-     *\r
-     * @param listener\r
-     *            The listener to remove\r
-     */\r
-    public void removeRangeListener(ITimeGraphRangeListener listener) {\r
-        fRangeListeners.remove(listener);\r
-    }\r
-\r
-    private void notifyRangeListeners(long startTime, long endTime) {\r
-        // Check if the time has actually changed from last notification\r
-        if (startTime != _time0_extSynch || endTime != _time1_extSynch) {\r
-            // Notify Time Scale Selection Listeners\r
-            TimeGraphRangeUpdateEvent event = new TimeGraphRangeUpdateEvent(this, startTime, endTime);\r
-\r
-            for (ITimeGraphRangeListener listener : fRangeListeners) {\r
-                listener.timeRangeUpdated(event);\r
-            }\r
-\r
-            // update external synch timers\r
-            updateExtSynchTimers();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Callback to set a selected event in the view\r
-     *\r
-     * @param event\r
-     *            The event that was selected\r
-     * @param source\r
-     *            The source of this selection event\r
-     */\r
-    public void setSelectedEvent(ITimeEvent event, Object source) {\r
-        if (event == null || source == this) {\r
-            return;\r
-        }\r
-        _selectedEntry = event.getEntry();\r
-        _stateCtrl.selectItem(_selectedEntry, false);\r
-\r
-        setSelectedTimeInt(event.getTime(), true, true);\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Set the seeked time of a trace\r
-     *\r
-     * @param trace\r
-     *            The trace that was seeked\r
-     * @param time\r
-     *            The target time\r
-     * @param source\r
-     *            The source of this seek event\r
-     */\r
-    public void setSelectedTraceTime(ITimeGraphEntry trace, long time, Object source) {\r
-        if (trace == null || source == this) {\r
-            return;\r
-        }\r
-        _selectedEntry = trace;\r
-        _stateCtrl.selectItem(trace, false);\r
-\r
-        setSelectedTimeInt(time, true, true);\r
-    }\r
-\r
-    /**\r
-     * Callback for a trace selection\r
-     *\r
-     * @param trace\r
-     *            The trace that was selected\r
-     */\r
-    public void setSelection(ITimeGraphEntry trace) {\r
-        _selectedEntry = trace;\r
-        _stateCtrl.selectItem(trace, false);\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Callback for a time window selection\r
-     *\r
-     * @param time0\r
-     *            Start time of the range\r
-     * @param time1\r
-     *            End time of the range\r
-     * @param source\r
-     *            Source of the event\r
-     */\r
-    public void setSelectVisTimeWindow(long time0, long time1, Object source) {\r
-        if (source == this) {\r
-            return;\r
-        }\r
-\r
-        setStartFinishTime(time0, time1);\r
-\r
-        // update notification time values since we are now in synch with the\r
-        // external application\r
-        updateExtSynchTimers();\r
-    }\r
-\r
-    /**\r
-     * update the cache timers used to identify the need to send a time window\r
-     * update to external registered listeners\r
-     */\r
-    private void updateExtSynchTimers() {\r
-        // last time notification cache\r
-        _time0_extSynch = _time0;\r
-        _time1_extSynch = _time1;\r
-    }\r
-\r
-    /**\r
-     * Set the calendar format\r
-     *\r
-     * @param toAbsoluteCaltime\r
-     *            True for absolute time, false for relative\r
-     */\r
-    public void setTimeCalendarFormat(boolean toAbsoluteCaltime) {\r
-        calendarTimeFormat = toAbsoluteCaltime;\r
-    }\r
-\r
-    @Override\r
-    public boolean isCalendarFormat() {\r
-        return calendarTimeFormat;\r
-    }\r
-\r
-    /**\r
-     * Retrieve the border width\r
-     *\r
-     * @return The width\r
-     */\r
-    public int getBorderWidth() {\r
-        return borderWidth;\r
-    }\r
-\r
-    /**\r
-     * Set the border width\r
-     *\r
-     * @param borderWidth\r
-     *            The width\r
-     */\r
-    public void setBorderWidth(int borderWidth) {\r
-        if (borderWidth > -1) {\r
-            this.borderWidth = borderWidth;\r
-            GridLayout gl = (GridLayout)_dataViewer.getLayout();\r
-            gl.marginHeight = borderWidth;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the height of the header\r
-     *\r
-     * @return The height\r
-     */\r
-    public int getHeaderHeight() {\r
-        return timeScaleHeight;\r
-    }\r
-\r
-    /**\r
-     * Set the height of the header\r
-     *\r
-     * @param headerHeight\r
-     *            The height to set\r
-     */\r
-    public void setHeaderHeight(int headerHeight) {\r
-        if (headerHeight > -1) {\r
-            this.timeScaleHeight = headerHeight;\r
-            _timeScaleCtrl.setHeight(headerHeight);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the height of an item row\r
-     *\r
-     * @return The height\r
-     */\r
-    public int getItemHeight() {\r
-        if (_stateCtrl != null) {\r
-            return _stateCtrl.getItemHeight();\r
-        }\r
-        return 0;\r
-    }\r
-\r
-    /**\r
-     * Set the height of an item row\r
-     *\r
-     * @param rowHeight\r
-     *            The height to set\r
-     */\r
-    public void setItemHeight(int rowHeight) {\r
-        if (_stateCtrl != null) {\r
-            _stateCtrl.setItemHeight(rowHeight);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Set the minimum item width\r
-     *\r
-     * @param width\r
-     *            The min width\r
-     */\r
-    public void setMinimumItemWidth(int width) {\r
-        if (_stateCtrl != null) {\r
-            _stateCtrl.setMinimumItemWidth(width);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Set the width for the name column\r
-     *\r
-     * @param width The width\r
-     */\r
-    public void setNameWidthPref(int width) {\r
-        _nameWidthPref = width;\r
-        if (width == 0) {\r
-            _minNameWidth = 0;\r
-            _nameWidth = 0;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the configure width for the name column\r
-     *\r
-     * @param width\r
-     *            Unused?\r
-     * @return The width\r
-     */\r
-    public int getNameWidthPref(int width) {\r
-        return _nameWidthPref;\r
-    }\r
-\r
-    /**\r
-     * Returns the primary control associated with this viewer.\r
-     *\r
-     * @return the SWT control which displays this viewer's content\r
-     */\r
-    public Control getControl() {\r
-        return _dataViewer;\r
-    }\r
-\r
-    /**\r
-     * Returns the time graph control associated with this viewer.\r
-     *\r
-     * @return the time graph control\r
-     */\r
-    TimeGraphControl getTimeGraphControl() {\r
-        return _stateCtrl;\r
-    }\r
-\r
-    /**\r
-     * Returns the time graph scale associated with this viewer.\r
-     *\r
-     * @return the time graph scale\r
-     */\r
-    TimeGraphScale getTimeGraphScale() {\r
-        return _timeScaleCtrl;\r
-    }\r
-\r
-    /**\r
-     * Get the selection provider\r
-     *\r
-     * @return the selection provider\r
-     */\r
-    public ISelectionProvider getSelectionProvider() {\r
-        return _stateCtrl;\r
-    }\r
-\r
-    /**\r
-     * Wait for the cursor\r
-     *\r
-     * @param waitInd\r
-     *            Wait indefinitely?\r
-     */\r
-    public void waitCursor(boolean waitInd) {\r
-        _stateCtrl.waitCursor(waitInd);\r
-    }\r
-\r
-    /**\r
-     * Get the horizontal scroll bar object\r
-     *\r
-     * @return The scroll bar\r
-     */\r
-    public ScrollBar getHorizontalBar() {\r
-        return _stateCtrl.getHorizontalBar();\r
-    }\r
-\r
-    /**\r
-     * Get the vertical scroll bar object\r
-     *\r
-     * @return The scroll bar\r
-     */\r
-    public Slider getVerticalBar() {\r
-        return _verticalScrollBar;\r
-    }\r
-\r
-    /**\r
-     * Set the given index as the top one\r
-     *\r
-     * @param index\r
-     *            The index that will go to the top\r
-     */\r
-    public void setTopIndex(int index) {\r
-        _stateCtrl.setTopIndex(index);\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Retrieve the current top index\r
-     *\r
-     * @return The top index\r
-     */\r
-    public int getTopIndex() {\r
-        return _stateCtrl.getTopIndex();\r
-    }\r
-\r
-    /**\r
-     * Set the expanded state of an entry\r
-     *\r
-     * @param entry\r
-     *            The entry to expand/collapse\r
-     * @param expanded\r
-     *            True for expanded, false for collapsed\r
-     */\r
-    public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {\r
-        _stateCtrl.setExpandedState(entry, expanded);\r
-        adjustVerticalScrollBar();\r
-    }\r
-\r
-    /**\r
-     * Get the number of sub-elements when expanded\r
-     *\r
-     * @return The element count\r
-     */\r
-    public int getExpandedElementCount() {\r
-        return _stateCtrl.getExpandedElementCount();\r
-    }\r
-\r
-    /**\r
-     * Get the sub-elements\r
-     *\r
-     * @return The array of entries that are below this one\r
-     */\r
-    public ITimeGraphEntry[] getExpandedElements() {\r
-        return _stateCtrl.getExpandedElements();\r
-    }\r
-\r
-    /**\r
-     * Add a tree listener\r
-     *\r
-     * @param listener\r
-     *            The listener to add\r
-     */\r
-    public void addTreeListener(ITimeGraphTreeListener listener) {\r
-        _stateCtrl.addTreeListener(listener);\r
-    }\r
-\r
-    /**\r
-     * Remove a tree listener\r
-     *\r
-     * @param listener\r
-     *            The listener to remove\r
-     */\r
-    public void removeTreeListener(ITimeGraphTreeListener listener) {\r
-        _stateCtrl.removeTreeListener(listener);\r
-    }\r
-\r
-    /**\r
-     * Get the reset scale action.\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getResetScaleAction() {\r
-        if (resetScale == null) {\r
-            // resetScale\r
-            resetScale = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    resetStartFinishTime();\r
-                }\r
-            };\r
-            resetScale.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText);\r
-            resetScale.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText);\r
-            resetScale.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU));\r
-        }\r
-        return resetScale;\r
-    }\r
-\r
-    /**\r
-     * Get the show legend action.\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getShowLegendAction() {\r
-        if (showLegendAction == null) {\r
-            // showLegend\r
-            showLegendAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    showLegend();\r
-                }\r
-            };\r
-            showLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText);\r
-            showLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText);\r
-            showLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND));\r
-        }\r
-\r
-        return showLegendAction;\r
-    }\r
-\r
-    /**\r
-     * Get the the next event action.\r
-     *\r
-     * @return The action object\r
-     */\r
-    public Action getNextEventAction() {\r
-        if (nextEventAction == null) {\r
-            nextEventAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    selectNextEvent();\r
-                }\r
-            };\r
-\r
-            nextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText);\r
-            nextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText);\r
-            nextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT));\r
-        }\r
-\r
-        return nextEventAction;\r
-    }\r
-\r
-    /**\r
-     * Get the previous event action.\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getPreviousEventAction() {\r
-        if (prevEventAction == null) {\r
-            prevEventAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    selectPrevEvent();\r
-                }\r
-            };\r
-\r
-            prevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText);\r
-            prevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText);\r
-            prevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT));\r
-        }\r
-\r
-        return prevEventAction;\r
-    }\r
-\r
-    /**\r
-     * Get the next item action.\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getNextItemAction() {\r
-        if (nextItemAction == null) {\r
-\r
-            nextItemAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    selectNextItem();\r
-                }\r
-            };\r
-            nextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText);\r
-            nextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText);\r
-            nextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM));\r
-        }\r
-        return nextItemAction;\r
-    }\r
-\r
-    /**\r
-     * Get the previous item action.\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getPreviousItemAction() {\r
-        if (previousItemAction == null) {\r
-\r
-            previousItemAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    selectPrevItem();\r
-                }\r
-            };\r
-            previousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText);\r
-            previousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText);\r
-            previousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM));\r
-        }\r
-        return previousItemAction;\r
-    }\r
-\r
-    /**\r
-     * Get the zoom in action\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getZoomInAction() {\r
-        if (zoomInAction == null) {\r
-            zoomInAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    zoomIn();\r
-                }\r
-            };\r
-            zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);\r
-            zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);\r
-            zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));\r
-        }\r
-        return zoomInAction;\r
-    }\r
-\r
-    /**\r
-     * Get the zoom out action\r
-     *\r
-     * @return The Action object\r
-     */\r
-    public Action getZoomOutAction() {\r
-        if (zoomOutAction == null) {\r
-            zoomOutAction = new Action() {\r
-                @Override\r
-                public void run() {\r
-                    zoomOut();\r
-                }\r
-            };\r
-            zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);\r
-            zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);\r
-            zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));\r
-        }\r
-        return zoomOutAction;\r
-    }\r
-\r
-\r
-    private void adjustVerticalScrollBar() {\r
-        int topIndex = _stateCtrl.getTopIndex();\r
-        int countPerPage = _stateCtrl.countPerPage();\r
-        int expandedElementCount = _stateCtrl.getExpandedElementCount();\r
-        if (topIndex + countPerPage > expandedElementCount) {\r
-            _stateCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage));\r
-        }\r
-\r
-        int selection = _stateCtrl.getTopIndex();\r
-        int min = 0;\r
-        int max = Math.max(1, expandedElementCount - 1);\r
-        int thumb = Math.min(max, Math.max(1, countPerPage - 1));\r
-        int increment = 1;\r
-        int pageIncrement = Math.max(1, countPerPage);\r
-        _verticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement);\r
-    }\r
-\r
-\r
-\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation, 2009, 2010, 2011, 2012 Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alexander N. Alexeev, Intel - Add monitors statistics support
+ *   Alvaro Sanchez-Leon - Adapted for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TimeGraphLegend;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphScale;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphTooltipHandler;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseWheelListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Slider;
+
+/**
+ * Generic time graph viewer implementation
+ *
+ * @version 1.0
+ * @author Patrick Tasse, and others
+ */
+public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
+
+    /** vars */
+    private long _minTimeInterval;
+    private long _selectedTime;
+    private ITimeGraphEntry _selectedEntry;
+    private long _beginTime;
+    private long _endTime;
+    private long _time0;
+    private long _time1;
+    private long _time0_;
+    private long _time1_;
+    private long _time0_extSynch = 0;
+    private long _time1_extSynch = 0;
+    private boolean _timeRangeFixed;
+    private int _nameWidthPref = 200;
+    private int _minNameWidth = 6;
+    private int _nameWidth;
+    private Composite _dataViewer;
+
+    private TimeGraphControl _stateCtrl;
+    private TimeGraphScale _timeScaleCtrl;
+    private Slider _verticalScrollBar;
+    private TimeGraphTooltipHandler _threadTip;
+    private TimeGraphColorScheme _colors;
+    private ITimeGraphPresentationProvider fTimeGraphProvider;
+
+    ArrayList<ITimeGraphSelectionListener> fSelectionListeners = new ArrayList<ITimeGraphSelectionListener>();
+    ArrayList<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>();
+    ArrayList<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>();
+
+    // Calender Time format, using Epoch reference or Relative time
+    // format(default
+    private boolean calendarTimeFormat = false;
+    private int borderWidth = 0;
+    private int timeScaleHeight = 22;
+
+    private Action resetScale;
+    private Action showLegendAction;
+    private Action nextEventAction;
+    private Action prevEventAction;
+    private Action nextItemAction;
+    private Action previousItemAction;
+    private Action zoomInAction;
+    private Action zoomOutAction;
+
+    /**
+     * Standard constructor
+     *
+     * @param parent
+     *            The parent UI composite object
+     * @param style
+     *            The style to use
+     */
+    public TimeGraphViewer(Composite parent, int style) {
+        createDataViewer(parent, style);
+    }
+
+    /**
+     * Sets the timegraph provider used by this timegraph viewer.
+     *
+     * @param timeGraphProvider the timegraph provider
+     */
+    public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {
+        fTimeGraphProvider = timeGraphProvider;
+        _stateCtrl.setTimeGraphProvider(timeGraphProvider);
+        _threadTip = new TimeGraphTooltipHandler(_dataViewer.getShell(), fTimeGraphProvider, this);
+        _threadTip.activateHoverHelp(_stateCtrl);
+    }
+
+    /**
+     * Sets or clears the input for this time graph viewer.
+     * The input array should only contain top-level elements.
+     *
+     * @param input the input of this time graph viewer, or <code>null</code> if none
+     */
+    public void setInput(ITimeGraphEntry[] input) {
+        if (null != _stateCtrl) {
+            if (null == input) {
+                input = new ITimeGraphEntry[0];
+            }
+            setTimeRange(input);
+            _verticalScrollBar.setEnabled(true);
+            setTopIndex(0);
+            _selectedTime = 0;
+            _selectedEntry = null;
+            refreshAllData(input);
+        }
+    }
+
+    /**
+     * Refresh the view
+     */
+    public void refresh() {
+        setInput(_stateCtrl.getTraces());
+    }
+
+    /**
+     * Callback for when the control is moved
+     *
+     * @param e
+     *            The caller event
+     */
+    public void controlMoved(ControlEvent e) {
+    }
+
+    /**
+     * Callback for when the control is resized
+     *
+     * @param e
+     *            The caller event
+     */
+    public void controlResized(ControlEvent e) {
+        resizeControls();
+    }
+
+    /**
+     * Handler for when the model is updated. Called from the display order in
+     * the API
+     *
+     * @param traces
+     *            The traces in the model
+     * @param start
+     *            The start time
+     * @param end
+     *            The end time
+     * @param updateTimeBounds
+     *            Should we updated the time bounds too
+     */
+    public void modelUpdate(ITimeGraphEntry[] traces, long start,
+            long end, boolean updateTimeBounds) {
+        if (null != _stateCtrl) {
+            //loadOptions();
+            updateInternalData(traces, start, end);
+            if (updateTimeBounds) {
+                _timeRangeFixed = true;
+                // set window to match limits
+                setStartFinishTime(_time0_, _time1_);
+            } else {
+                _stateCtrl.redraw();
+                _timeScaleCtrl.redraw();
+            }
+        }
+    }
+
+    protected String getViewTypeStr() {
+        return "viewoption.threads"; //$NON-NLS-1$
+    }
+
+    int getMarginWidth(int idx) {
+        return 0;
+    }
+
+    int getMarginHeight(int idx) {
+        return 0;
+    }
+
+    void loadOptions() {
+        _minTimeInterval = 1;
+        _selectedTime = -1;
+        _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
+                _nameWidthPref, _minNameWidth, 1000);
+    }
+
+    void saveOptions() {
+        Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$
+    }
+
+    protected Control createDataViewer(Composite parent, int style) {
+        loadOptions();
+        _colors = new TimeGraphColorScheme();
+        _dataViewer = new Composite(parent, style) {
+            @Override
+            public void redraw() {
+                _timeScaleCtrl.redraw();
+                _stateCtrl.redraw();
+                super.redraw();
+            }
+        };
+        GridLayout gl = new GridLayout(2, false);
+        gl.marginHeight = borderWidth;
+        gl.marginWidth = 0;
+        gl.verticalSpacing = 0;
+        gl.horizontalSpacing = 0;
+        _dataViewer.setLayout(gl);
+
+        _timeScaleCtrl = new TimeGraphScale(_dataViewer, _colors);
+        _timeScaleCtrl.setTimeProvider(this);
+        _timeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
+        _timeScaleCtrl.setHeight(timeScaleHeight);
+
+        _verticalScrollBar = new Slider(_dataViewer, SWT.VERTICAL | SWT.NO_FOCUS);
+        _verticalScrollBar.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true, 1, 2));
+        _verticalScrollBar.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                setTopIndex(_verticalScrollBar.getSelection());
+            }
+        });
+        _verticalScrollBar.setEnabled(false);
+
+        _stateCtrl = createTimeGraphControl();
+
+        _stateCtrl.setTimeProvider(this);
+        _stateCtrl.addSelectionListener(this);
+        _stateCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
+        _stateCtrl.addMouseWheelListener(new MouseWheelListener() {
+            @Override
+            public void mouseScrolled(MouseEvent e) {
+                adjustVerticalScrollBar();
+            }
+        });
+        _stateCtrl.addKeyListener(new KeyAdapter() {
+            @Override
+            public void keyPressed(KeyEvent e) {
+                adjustVerticalScrollBar();
+            }
+        });
+
+        Composite filler = new Composite(_dataViewer, SWT.NONE);
+        GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
+        gd.heightHint = _stateCtrl.getHorizontalBar().getSize().y;
+        filler.setLayoutData(gd);
+        filler.setLayout(new FillLayout());
+
+        _stateCtrl.addControlListener(new ControlAdapter() {
+            @Override
+            public void controlResized(ControlEvent event) {
+                resizeControls();
+            }
+        });
+        resizeControls();
+        _dataViewer.update();
+        adjustVerticalScrollBar();
+        return _dataViewer;
+    }
+
+    /**
+     * Dispose the view.
+     */
+    public void dispose() {
+        saveOptions();
+        _stateCtrl.dispose();
+        _dataViewer.dispose();
+        _colors.dispose();
+    }
+
+    protected TimeGraphControl createTimeGraphControl() {
+        return new TimeGraphControl(_dataViewer, _colors);
+    }
+
+    /**
+     * Resize the controls
+     */
+    public void resizeControls() {
+        Rectangle r = _dataViewer.getClientArea();
+        if (r.isEmpty()) {
+            return;
+        }
+
+        int width = r.width;
+        if (_nameWidth > width - _minNameWidth) {
+            _nameWidth = width - _minNameWidth;
+        }
+        if (_nameWidth < _minNameWidth) {
+            _nameWidth = _minNameWidth;
+        }
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Try to set most convenient time range for display.
+     *
+     * @param traces
+     *            The traces in the model
+     */
+    public void setTimeRange(ITimeGraphEntry traces[]) {
+        _endTime = 0;
+        _beginTime = -1;
+        for (int i = 0; i < traces.length; i++) {
+            ITimeGraphEntry entry = traces[i];
+            if (entry.getEndTime() >= entry.getStartTime() && entry.getEndTime() > 0) {
+                if (_beginTime < 0 || entry.getStartTime() < _beginTime) {
+                    _beginTime = entry.getStartTime();
+                }
+                if (entry.getEndTime() > _endTime) {
+                    _endTime = entry.getEndTime();
+                }
+            }
+        }
+
+        if (_beginTime < 0) {
+            _beginTime = 0;
+        }
+    }
+
+    /**
+     * Recalculate the time bounds
+     */
+    public void setTimeBounds() {
+        //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);
+        _time0_ = _beginTime;
+        if (_time0_ < 0) {
+            _time0_ = 0;
+        }
+        // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;
+        _time1_ = _endTime;
+        // _time0_ = Math.floor(_time0_);
+        // _time1_ = Math.ceil(_time1_);
+        if (!_timeRangeFixed) {
+            _time0 = _time0_;
+            _time1 = _time1_;
+        }
+        if (_time1 - _time0 < _minTimeInterval) {
+            _time1 = Math.min(_time1_, _time0 + _minTimeInterval);
+        }
+    }
+
+    /**
+     * @param traces
+     * @param start
+     * @param end
+     */
+    void updateInternalData(ITimeGraphEntry[] traces, long start, long end) {
+        if (null == traces) {
+            traces = new ITimeGraphEntry[0];
+        }
+        if ((start == 0 && end == 0) || start < 0 || end < 0) {
+            // Start and end time are unspecified and need to be determined from
+            // individual processes
+            setTimeRange(traces);
+        } else {
+            _beginTime = start;
+            _endTime = end;
+        }
+
+        refreshAllData(traces);
+    }
+
+    /**
+     * @param traces
+     */
+    private void refreshAllData(ITimeGraphEntry[] traces) {
+        setTimeBounds();
+        if (_selectedTime < _beginTime) {
+            _selectedTime = _beginTime;
+        } else if (_selectedTime > _endTime) {
+            _selectedTime = _endTime;
+        }
+        _stateCtrl.refreshData(traces);
+        _timeScaleCtrl.redraw();
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Callback for when this view is focused
+     */
+    public void setFocus() {
+        if (null != _stateCtrl) {
+            _stateCtrl.setFocus();
+        }
+    }
+
+    /**
+     * Get the current focus status of this view.
+     *
+     * @return If the view is currently focused, or not
+     */
+    public boolean isInFocus() {
+        return _stateCtrl.isInFocus();
+    }
+
+    /**
+     * Get the view's current selection
+     *
+     * @return The entry that is selected
+     */
+    public ITimeGraphEntry getSelection() {
+        return _stateCtrl.getSelectedTrace();
+    }
+
+    /**
+     * Get the index of the current selection
+     *
+     * @return The index
+     */
+    public int getSelectionIndex() {
+        return _stateCtrl.getSelectedIndex();
+    }
+
+    @Override
+    public long getTime0() {
+        return _time0;
+    }
+
+    @Override
+    public long getTime1() {
+        return _time1;
+    }
+
+    @Override
+    public long getMinTimeInterval() {
+        return _minTimeInterval;
+    }
+
+    @Override
+    public int getNameSpace() {
+        return _nameWidth;
+    }
+
+    @Override
+    public void setNameSpace(int width) {
+        _nameWidth = width;
+        width = _stateCtrl.getClientArea().width;
+        if (_nameWidth > width - 6) {
+            _nameWidth = width - 6;
+        }
+        if (_nameWidth < 6) {
+            _nameWidth = 6;
+        }
+        _stateCtrl.adjustScrolls();
+        _stateCtrl.redraw();
+        _timeScaleCtrl.redraw();
+    }
+
+    @Override
+    public int getTimeSpace() {
+        int w = _stateCtrl.getClientArea().width;
+        return w - _nameWidth;
+    }
+
+    @Override
+    public long getSelectedTime() {
+        return _selectedTime;
+    }
+
+    @Override
+    public long getBeginTime() {
+        return _beginTime;
+    }
+
+    @Override
+    public long getEndTime() {
+        return _endTime;
+    }
+
+    @Override
+    public long getMaxTime() {
+        return _time1_;
+    }
+
+    @Override
+    public long getMinTime() {
+        return _time0_;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider
+     * #setStartFinishTimeNotify(long, long)
+     */
+    @Override
+    public void setStartFinishTimeNotify(long time0, long time1) {
+        setStartFinishTime(time0, time1);
+        notifyRangeListeners(time0, time1);
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()
+     */
+    @Override
+    public void notifyStartFinishTime() {
+        notifyRangeListeners(_time0, _time1);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider
+     * #setStartFinishTime(long, long)
+     */
+    @Override
+    public void setStartFinishTime(long time0, long time1) {
+        _time0 = time0;
+        if (_time0 < _time0_) {
+            _time0 = _time0_;
+        }
+        if (_time0 > _time1_) {
+            _time0 = _time1_;
+        }
+        _time1 = time1;
+        if (_time1 < _time0_) {
+            _time1 = _time0_;
+        }
+        if (_time1 > _time1_) {
+            _time1 = _time1_;
+        }
+        if (_time1 - _time0 < _minTimeInterval) {
+            _time1 = Math.min(_time1_, _time0 + _minTimeInterval);
+        }
+        _timeRangeFixed = true;
+        _stateCtrl.adjustScrolls();
+        _stateCtrl.redraw();
+        _timeScaleCtrl.redraw();
+    }
+
+    /**
+     * Set the time bounds to the provided values
+     *
+     * @param beginTime
+     *            The start time of the window
+     * @param endTime
+     *            The end time
+     */
+    public void setTimeBounds(long beginTime, long endTime) {
+        _beginTime = beginTime;
+        _endTime = endTime;
+        _time0_ = beginTime;
+        _time1_ = endTime;
+        _stateCtrl.adjustScrolls();
+    }
+
+    @Override
+    public void resetStartFinishTime() {
+        setStartFinishTimeNotify(_time0_, _time1_);
+        _timeRangeFixed = false;
+    }
+
+    @Override
+    public void setSelectedTimeNotify(long time, boolean ensureVisible) {
+        setSelectedTimeInt(time, ensureVisible, true);
+    }
+
+    @Override
+    public void setSelectedTime(long time, boolean ensureVisible) {
+        setSelectedTimeInt(time, ensureVisible, false);
+    }
+
+    private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) {
+        long time0 = _time0;
+        long time1 = _time1;
+        if (ensureVisible) {
+            long timeSpace = (long) ((_time1 - _time0) * .02);
+            long timeMid = (long) ((_time1 - _time0) * .5);
+            if (time < _time0 + timeSpace) {
+                long dt = _time0 - time + timeMid;
+                _time0 -= dt;
+                _time1 -= dt;
+            } else if (time > _time1 - timeSpace) {
+                long dt = time - _time1 + timeMid;
+                _time0 += dt;
+                _time1 += dt;
+            }
+            if (_time0 < _time0_) {
+                _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0));
+                _time0 = _time0_;
+            } else if (_time1 > _time1_) {
+                _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_));
+                _time1 = _time1_;
+            }
+        }
+        if (_time1 - _time0 < _minTimeInterval) {
+            _time1 = Math.min(_time1_, _time0 + _minTimeInterval);
+        }
+        _stateCtrl.adjustScrolls();
+        _stateCtrl.redraw();
+        _timeScaleCtrl.redraw();
+
+
+        boolean notifySelectedTime = (time != _selectedTime);
+        _selectedTime = time;
+
+        if (doNotify && ((time0 != _time0) || (time1 != _time1))) {
+            notifyRangeListeners(_time0, _time1);
+        }
+
+        if (doNotify && notifySelectedTime) {
+            notifyTimeListeners(_selectedTime);
+        }
+    }
+
+    @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
+        if (_selectedEntry != getSelection()) {
+            _selectedEntry = getSelection();
+            notifySelectionListeners(_selectedEntry);
+        }
+    }
+
+    @Override
+    public void widgetSelected(SelectionEvent e) {
+        if (_selectedEntry != getSelection()) {
+            _selectedEntry = getSelection();
+            notifySelectionListeners(_selectedEntry);
+        }
+    }
+
+    /**
+     * Callback for when the next event is selected
+     */
+    public void selectNextEvent() {
+        _stateCtrl.selectNextEvent();
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Callback for when the previous event is selected
+     */
+    public void selectPrevEvent() {
+        _stateCtrl.selectPrevEvent();
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Callback for when the next item is selected
+     */
+    public void selectNextItem() {
+        _stateCtrl.selectNextTrace();
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Callback for when the previous item is selected
+     */
+    public void selectPrevItem() {
+        _stateCtrl.selectPrevTrace();
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Callback for the show legend action
+     */
+    public void showLegend() {
+        if (_dataViewer == null || _dataViewer.isDisposed()) {
+            return;
+        }
+
+        TimeGraphLegend.open(_dataViewer.getShell(), fTimeGraphProvider);
+    }
+
+    /**
+     * Callback for the Zoom In action
+     */
+    public void zoomIn() {
+        _stateCtrl.zoomIn();
+    }
+
+    /**
+     * Callback for the Zoom Out action
+     */
+    public void zoomOut() {
+        _stateCtrl.zoomOut();
+    }
+
+    private String getPreferenceString(String string) {
+        return getViewTypeStr() + "." + string; //$NON-NLS-1$
+    }
+
+    /**
+     * Add a selection listener
+     *
+     * @param listener
+     *            The listener to add
+     */
+    public void addSelectionListener(ITimeGraphSelectionListener listener) {
+        fSelectionListeners.add(listener);
+    }
+
+    /**
+     * Remove a selection listener
+     *
+     * @param listener
+     *            The listener to remove
+     */
+    public void removeSelectionListener(ITimeGraphSelectionListener listener) {
+        fSelectionListeners.remove(listener);
+    }
+
+    private void notifySelectionListeners(ITimeGraphEntry selection) {
+        TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection);
+
+        for (ITimeGraphSelectionListener listener : fSelectionListeners) {
+            listener.selectionChanged(event);
+        }
+    }
+
+    /**
+     * Add a time listener
+     *
+     * @param listener
+     *            The listener to add
+     */
+    public void addTimeListener(ITimeGraphTimeListener listener) {
+        fTimeListeners.add(listener);
+    }
+
+    /**
+     * Remove a time listener
+     *
+     * @param listener
+     *            The listener to remove
+     */
+    public void removeTimeListener(ITimeGraphTimeListener listener) {
+        fTimeListeners.remove(listener);
+    }
+
+    private void notifyTimeListeners(long time) {
+        TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, time);
+
+        for (ITimeGraphTimeListener listener : fTimeListeners) {
+            listener.timeSelected(event);
+        }
+    }
+
+    /**
+     * Add a range listener
+     *
+     * @param listener
+     *            The listener to add
+     */
+    public void addRangeListener(ITimeGraphRangeListener listener) {
+        fRangeListeners.add(listener);
+    }
+
+    /**
+     * Remove a range listener
+     *
+     * @param listener
+     *            The listener to remove
+     */
+    public void removeRangeListener(ITimeGraphRangeListener listener) {
+        fRangeListeners.remove(listener);
+    }
+
+    private void notifyRangeListeners(long startTime, long endTime) {
+        // Check if the time has actually changed from last notification
+        if (startTime != _time0_extSynch || endTime != _time1_extSynch) {
+            // Notify Time Scale Selection Listeners
+            TimeGraphRangeUpdateEvent event = new TimeGraphRangeUpdateEvent(this, startTime, endTime);
+
+            for (ITimeGraphRangeListener listener : fRangeListeners) {
+                listener.timeRangeUpdated(event);
+            }
+
+            // update external synch timers
+            updateExtSynchTimers();
+        }
+    }
+
+    /**
+     * Callback to set a selected event in the view
+     *
+     * @param event
+     *            The event that was selected
+     * @param source
+     *            The source of this selection event
+     */
+    public void setSelectedEvent(ITimeEvent event, Object source) {
+        if (event == null || source == this) {
+            return;
+        }
+        _selectedEntry = event.getEntry();
+        _stateCtrl.selectItem(_selectedEntry, false);
+
+        setSelectedTimeInt(event.getTime(), true, true);
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Set the seeked time of a trace
+     *
+     * @param trace
+     *            The trace that was seeked
+     * @param time
+     *            The target time
+     * @param source
+     *            The source of this seek event
+     */
+    public void setSelectedTraceTime(ITimeGraphEntry trace, long time, Object source) {
+        if (trace == null || source == this) {
+            return;
+        }
+        _selectedEntry = trace;
+        _stateCtrl.selectItem(trace, false);
+
+        setSelectedTimeInt(time, true, true);
+    }
+
+    /**
+     * Callback for a trace selection
+     *
+     * @param trace
+     *            The trace that was selected
+     */
+    public void setSelection(ITimeGraphEntry trace) {
+        _selectedEntry = trace;
+        _stateCtrl.selectItem(trace, false);
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Callback for a time window selection
+     *
+     * @param time0
+     *            Start time of the range
+     * @param time1
+     *            End time of the range
+     * @param source
+     *            Source of the event
+     */
+    public void setSelectVisTimeWindow(long time0, long time1, Object source) {
+        if (source == this) {
+            return;
+        }
+
+        setStartFinishTime(time0, time1);
+
+        // update notification time values since we are now in synch with the
+        // external application
+        updateExtSynchTimers();
+    }
+
+    /**
+     * update the cache timers used to identify the need to send a time window
+     * update to external registered listeners
+     */
+    private void updateExtSynchTimers() {
+        // last time notification cache
+        _time0_extSynch = _time0;
+        _time1_extSynch = _time1;
+    }
+
+    /**
+     * Set the calendar format
+     *
+     * @param toAbsoluteCaltime
+     *            True for absolute time, false for relative
+     */
+    public void setTimeCalendarFormat(boolean toAbsoluteCaltime) {
+        calendarTimeFormat = toAbsoluteCaltime;
+    }
+
+    @Override
+    public boolean isCalendarFormat() {
+        return calendarTimeFormat;
+    }
+
+    /**
+     * Retrieve the border width
+     *
+     * @return The width
+     */
+    public int getBorderWidth() {
+        return borderWidth;
+    }
+
+    /**
+     * Set the border width
+     *
+     * @param borderWidth
+     *            The width
+     */
+    public void setBorderWidth(int borderWidth) {
+        if (borderWidth > -1) {
+            this.borderWidth = borderWidth;
+            GridLayout gl = (GridLayout)_dataViewer.getLayout();
+            gl.marginHeight = borderWidth;
+        }
+    }
+
+    /**
+     * Retrieve the height of the header
+     *
+     * @return The height
+     */
+    public int getHeaderHeight() {
+        return timeScaleHeight;
+    }
+
+    /**
+     * Set the height of the header
+     *
+     * @param headerHeight
+     *            The height to set
+     */
+    public void setHeaderHeight(int headerHeight) {
+        if (headerHeight > -1) {
+            this.timeScaleHeight = headerHeight;
+            _timeScaleCtrl.setHeight(headerHeight);
+        }
+    }
+
+    /**
+     * Retrieve the height of an item row
+     *
+     * @return The height
+     */
+    public int getItemHeight() {
+        if (_stateCtrl != null) {
+            return _stateCtrl.getItemHeight();
+        }
+        return 0;
+    }
+
+    /**
+     * Set the height of an item row
+     *
+     * @param rowHeight
+     *            The height to set
+     */
+    public void setItemHeight(int rowHeight) {
+        if (_stateCtrl != null) {
+            _stateCtrl.setItemHeight(rowHeight);
+        }
+    }
+
+    /**
+     * Set the minimum item width
+     *
+     * @param width
+     *            The min width
+     */
+    public void setMinimumItemWidth(int width) {
+        if (_stateCtrl != null) {
+            _stateCtrl.setMinimumItemWidth(width);
+        }
+    }
+
+    /**
+     * Set the width for the name column
+     *
+     * @param width The width
+     */
+    public void setNameWidthPref(int width) {
+        _nameWidthPref = width;
+        if (width == 0) {
+            _minNameWidth = 0;
+            _nameWidth = 0;
+        }
+    }
+
+    /**
+     * Retrieve the configure width for the name column
+     *
+     * @param width
+     *            Unused?
+     * @return The width
+     */
+    public int getNameWidthPref(int width) {
+        return _nameWidthPref;
+    }
+
+    /**
+     * Returns the primary control associated with this viewer.
+     *
+     * @return the SWT control which displays this viewer's content
+     */
+    public Control getControl() {
+        return _dataViewer;
+    }
+
+    /**
+     * Returns the time graph control associated with this viewer.
+     *
+     * @return the time graph control
+     */
+    TimeGraphControl getTimeGraphControl() {
+        return _stateCtrl;
+    }
+
+    /**
+     * Returns the time graph scale associated with this viewer.
+     *
+     * @return the time graph scale
+     */
+    TimeGraphScale getTimeGraphScale() {
+        return _timeScaleCtrl;
+    }
+
+    /**
+     * Get the selection provider
+     *
+     * @return the selection provider
+     */
+    public ISelectionProvider getSelectionProvider() {
+        return _stateCtrl;
+    }
+
+    /**
+     * Wait for the cursor
+     *
+     * @param waitInd
+     *            Wait indefinitely?
+     */
+    public void waitCursor(boolean waitInd) {
+        _stateCtrl.waitCursor(waitInd);
+    }
+
+    /**
+     * Get the horizontal scroll bar object
+     *
+     * @return The scroll bar
+     */
+    public ScrollBar getHorizontalBar() {
+        return _stateCtrl.getHorizontalBar();
+    }
+
+    /**
+     * Get the vertical scroll bar object
+     *
+     * @return The scroll bar
+     */
+    public Slider getVerticalBar() {
+        return _verticalScrollBar;
+    }
+
+    /**
+     * Set the given index as the top one
+     *
+     * @param index
+     *            The index that will go to the top
+     */
+    public void setTopIndex(int index) {
+        _stateCtrl.setTopIndex(index);
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Retrieve the current top index
+     *
+     * @return The top index
+     */
+    public int getTopIndex() {
+        return _stateCtrl.getTopIndex();
+    }
+
+    /**
+     * Set the expanded state of an entry
+     *
+     * @param entry
+     *            The entry to expand/collapse
+     * @param expanded
+     *            True for expanded, false for collapsed
+     */
+    public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {
+        _stateCtrl.setExpandedState(entry, expanded);
+        adjustVerticalScrollBar();
+    }
+
+    /**
+     * Get the number of sub-elements when expanded
+     *
+     * @return The element count
+     */
+    public int getExpandedElementCount() {
+        return _stateCtrl.getExpandedElementCount();
+    }
+
+    /**
+     * Get the sub-elements
+     *
+     * @return The array of entries that are below this one
+     */
+    public ITimeGraphEntry[] getExpandedElements() {
+        return _stateCtrl.getExpandedElements();
+    }
+
+    /**
+     * Add a tree listener
+     *
+     * @param listener
+     *            The listener to add
+     */
+    public void addTreeListener(ITimeGraphTreeListener listener) {
+        _stateCtrl.addTreeListener(listener);
+    }
+
+    /**
+     * Remove a tree listener
+     *
+     * @param listener
+     *            The listener to remove
+     */
+    public void removeTreeListener(ITimeGraphTreeListener listener) {
+        _stateCtrl.removeTreeListener(listener);
+    }
+
+    /**
+     * Get the reset scale action.
+     *
+     * @return The Action object
+     */
+    public Action getResetScaleAction() {
+        if (resetScale == null) {
+            // resetScale
+            resetScale = new Action() {
+                @Override
+                public void run() {
+                    resetStartFinishTime();
+                }
+            };
+            resetScale.setText(Messages.TmfTimeGraphViewer_ResetScaleActionNameText);
+            resetScale.setToolTipText(Messages.TmfTimeGraphViewer_ResetScaleActionToolTipText);
+            resetScale.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HOME_MENU));
+        }
+        return resetScale;
+    }
+
+    /**
+     * Get the show legend action.
+     *
+     * @return The Action object
+     */
+    public Action getShowLegendAction() {
+        if (showLegendAction == null) {
+            // showLegend
+            showLegendAction = new Action() {
+                @Override
+                public void run() {
+                    showLegend();
+                }
+            };
+            showLegendAction.setText(Messages.TmfTimeGraphViewer_LegendActionNameText);
+            showLegendAction.setToolTipText(Messages.TmfTimeGraphViewer_LegendActionToolTipText);
+            showLegendAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SHOW_LEGEND));
+        }
+
+        return showLegendAction;
+    }
+
+    /**
+     * Get the the next event action.
+     *
+     * @return The action object
+     */
+    public Action getNextEventAction() {
+        if (nextEventAction == null) {
+            nextEventAction = new Action() {
+                @Override
+                public void run() {
+                    selectNextEvent();
+                }
+            };
+
+            nextEventAction.setText(Messages.TmfTimeGraphViewer_NextEventActionNameText);
+            nextEventAction.setToolTipText(Messages.TmfTimeGraphViewer_NextEventActionToolTipText);
+            nextEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_EVENT));
+        }
+
+        return nextEventAction;
+    }
+
+    /**
+     * Get the previous event action.
+     *
+     * @return The Action object
+     */
+    public Action getPreviousEventAction() {
+        if (prevEventAction == null) {
+            prevEventAction = new Action() {
+                @Override
+                public void run() {
+                    selectPrevEvent();
+                }
+            };
+
+            prevEventAction.setText(Messages.TmfTimeGraphViewer_PreviousEventActionNameText);
+            prevEventAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousEventActionToolTipText);
+            prevEventAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_EVENT));
+        }
+
+        return prevEventAction;
+    }
+
+    /**
+     * Get the next item action.
+     *
+     * @return The Action object
+     */
+    public Action getNextItemAction() {
+        if (nextItemAction == null) {
+
+            nextItemAction = new Action() {
+                @Override
+                public void run() {
+                    selectNextItem();
+                }
+            };
+            nextItemAction.setText(Messages.TmfTimeGraphViewer_NextItemActionNameText);
+            nextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText);
+            nextItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEXT_ITEM));
+        }
+        return nextItemAction;
+    }
+
+    /**
+     * Get the previous item action.
+     *
+     * @return The Action object
+     */
+    public Action getPreviousItemAction() {
+        if (previousItemAction == null) {
+
+            previousItemAction = new Action() {
+                @Override
+                public void run() {
+                    selectPrevItem();
+                }
+            };
+            previousItemAction.setText(Messages.TmfTimeGraphViewer_PreviousItemActionNameText);
+            previousItemAction.setToolTipText(Messages.TmfTimeGraphViewer_PreviousItemActionToolTipText);
+            previousItemAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_PREV_ITEM));
+        }
+        return previousItemAction;
+    }
+
+    /**
+     * Get the zoom in action
+     *
+     * @return The Action object
+     */
+    public Action getZoomInAction() {
+        if (zoomInAction == null) {
+            zoomInAction = new Action() {
+                @Override
+                public void run() {
+                    zoomIn();
+                }
+            };
+            zoomInAction.setText(Messages.TmfTimeGraphViewer_ZoomInActionNameText);
+            zoomInAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomInActionToolTipText);
+            zoomInAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_IN_MENU));
+        }
+        return zoomInAction;
+    }
+
+    /**
+     * Get the zoom out action
+     *
+     * @return The Action object
+     */
+    public Action getZoomOutAction() {
+        if (zoomOutAction == null) {
+            zoomOutAction = new Action() {
+                @Override
+                public void run() {
+                    zoomOut();
+                }
+            };
+            zoomOutAction.setText(Messages.TmfTimeGraphViewer_ZoomOutActionNameText);
+            zoomOutAction.setToolTipText(Messages.TmfTimeGraphViewer_ZoomOutActionToolTipText);
+            zoomOutAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_ZOOM_OUT_MENU));
+        }
+        return zoomOutAction;
+    }
+
+
+    private void adjustVerticalScrollBar() {
+        int topIndex = _stateCtrl.getTopIndex();
+        int countPerPage = _stateCtrl.countPerPage();
+        int expandedElementCount = _stateCtrl.getExpandedElementCount();
+        if (topIndex + countPerPage > expandedElementCount) {
+            _stateCtrl.setTopIndex(Math.max(0, expandedElementCount - countPerPage));
+        }
+
+        int selection = _stateCtrl.getTopIndex();
+        int min = 0;
+        int max = Math.max(1, expandedElementCount - 1);
+        int thumb = Math.min(max, Math.max(1, countPerPage - 1));
+        int increment = 1;
+        int pageIncrement = Math.max(1, countPerPage);
+        _verticalScrollBar.setValues(selection, min, max, thumb, increment, pageIncrement);
+    }
+
+
+
+}
index 55c9d024593bc8807dc032ffb3529aeef50e5bae..e5e625ab3dd0514b899cc770a134604d9c750f17 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2009, 2012 Ericsson.\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *   Patrick Tasse - Refactoring\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs;\r
-\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.jface.dialogs.TitleAreaDialog;\r
-import org.eclipse.jface.resource.JFaceResources;\r
-import org.eclipse.jface.resource.LocalResourceManager;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Group;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Listener;\r
-import org.eclipse.swt.widgets.Shell;\r
-\r
-/**\r
- * Legend for the colors used in the time graph view\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphLegend extends TitleAreaDialog {\r
-\r
-    private final ITimeGraphPresentationProvider provider;\r
-    private final LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());\r
-\r
-    /**\r
-     * Open the time graph legend window\r
-     *\r
-     * @param parent\r
-     *            The parent shell\r
-     * @param provider\r
-     *            The presentation provider\r
-     */\r
-    public static void open(Shell parent, ITimeGraphPresentationProvider provider) {\r
-        (new TimeGraphLegend(parent, provider)).open();\r
-    }\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param parent\r
-     *            The parent shell\r
-     * @param provider\r
-     *            The presentation provider\r
-     */\r
-    public TimeGraphLegend(Shell parent, ITimeGraphPresentationProvider provider) {\r
-        super(parent);\r
-        this.provider = provider;\r
-        this.setShellStyle(getShellStyle());\r
-    }\r
-\r
-    @Override\r
-    protected Control createDialogArea(Composite parent) {\r
-        Composite dlgArea = (Composite) super.createDialogArea(parent);\r
-        Composite composite = new Composite(dlgArea, SWT.NONE);\r
-\r
-        GridLayout layout = new GridLayout();\r
-        layout.numColumns = 2;\r
-        composite.setLayout(layout);\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-        composite.setLayoutData(gd);\r
-\r
-        createStatesGroup(composite);\r
-\r
-        setTitle(Messages.TmfTimeLegend_LEGEND);\r
-        setDialogHelpAvailable(false);\r
-        setHelpAvailable(false);\r
-\r
-        return composite;\r
-    }\r
-\r
-    private void createStatesGroup(Composite composite) {\r
-        Group gs = new Group(composite, SWT.NONE);\r
-        gs.setText(provider.getStateTypeName() + " " + Messages.TmfTimeLegend_StateTypeName); //$NON-NLS-1$\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-        gs.setLayoutData(gd);\r
-\r
-        GridLayout layout = new GridLayout();\r
-        layout.numColumns = 2;\r
-        layout.marginWidth = 20;\r
-        layout.marginBottom = 10;\r
-        gs.setLayout(layout);\r
-\r
-        // Go through all the defined pairs of state color and state name and display them.\r
-        StateItem[] stateItems = provider.getStateTable();\r
-        for (int i = 0; i < stateItems.length; i++) {\r
-            //Get the color related to the index\r
-            RGB rgb = stateItems[i].getStateColor();\r
-\r
-            //Get the given name, provided by the interface to the application\r
-            String stateName = stateItems[i].getStateString();\r
-\r
-            // draw color with name\r
-            Bar bar = new Bar(gs, rgb);\r
-            gd = new GridData();\r
-            gd.widthHint = 40;\r
-            gd.heightHint = 20;\r
-            gd.verticalIndent = 8;\r
-            bar.setLayoutData(gd);\r
-            Label name = new Label(gs, SWT.NONE);\r
-            name.setText(stateName);\r
-            gd = new GridData();\r
-            gd.horizontalIndent = 10;\r
-            gd.verticalIndent = 8;\r
-            name.setLayoutData(gd);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    protected void configureShell(Shell shell) {\r
-        super.configureShell(shell);\r
-        shell.setText(Messages.TmfTimeLegend_TRACE_STATES_TITLE);\r
-    }\r
-\r
-    @Override\r
-    protected void createButtonsForButtonBar(Composite parent) {\r
-        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\r
-                true);\r
-    }\r
-\r
-    class Bar extends Canvas {\r
-        private final Color color;\r
-\r
-        public Bar(Composite parent, RGB rgb) {\r
-            super(parent, SWT.NONE);\r
-\r
-            color = fResourceManager.createColor(rgb);\r
-            addListener(SWT.Paint, new Listener() {\r
-                @Override\r
-                public void handleEvent(Event event) {\r
-                    draw(event.gc);\r
-                }\r
-            });\r
-        }\r
-\r
-        private void draw(GC gc) {\r
-            Rectangle r = getClientArea();\r
-            gc.setBackground(color);\r
-            gc.fillRectangle(r);\r
-            gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));\r
-            gc.drawRectangle(0, 0, r.width - 1, r.height - 1);\r
-        }\r
-\r
-        @Override\r
-        public void dispose() {\r
-            super.dispose();\r
-            color.dispose();\r
-        }\r
-\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon - Initial API and implementation
+ *   Patrick Tasse - Refactoring
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Legend for the colors used in the time graph view
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public class TimeGraphLegend extends TitleAreaDialog {
+
+    private final ITimeGraphPresentationProvider provider;
+    private final LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
+
+    /**
+     * Open the time graph legend window
+     *
+     * @param parent
+     *            The parent shell
+     * @param provider
+     *            The presentation provider
+     */
+    public static void open(Shell parent, ITimeGraphPresentationProvider provider) {
+        (new TimeGraphLegend(parent, provider)).open();
+    }
+
+    /**
+     * Standard constructor
+     *
+     * @param parent
+     *            The parent shell
+     * @param provider
+     *            The presentation provider
+     */
+    public TimeGraphLegend(Shell parent, ITimeGraphPresentationProvider provider) {
+        super(parent);
+        this.provider = provider;
+        this.setShellStyle(getShellStyle());
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite dlgArea = (Composite) super.createDialogArea(parent);
+        Composite composite = new Composite(dlgArea, SWT.NONE);
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        composite.setLayout(layout);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        composite.setLayoutData(gd);
+
+        createStatesGroup(composite);
+
+        setTitle(Messages.TmfTimeLegend_LEGEND);
+        setDialogHelpAvailable(false);
+        setHelpAvailable(false);
+
+        return composite;
+    }
+
+    private void createStatesGroup(Composite composite) {
+        Group gs = new Group(composite, SWT.NONE);
+        gs.setText(provider.getStateTypeName() + " " + Messages.TmfTimeLegend_StateTypeName); //$NON-NLS-1$
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        gs.setLayoutData(gd);
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        layout.marginWidth = 20;
+        layout.marginBottom = 10;
+        gs.setLayout(layout);
+
+        // Go through all the defined pairs of state color and state name and display them.
+        StateItem[] stateItems = provider.getStateTable();
+        for (int i = 0; i < stateItems.length; i++) {
+            //Get the color related to the index
+            RGB rgb = stateItems[i].getStateColor();
+
+            //Get the given name, provided by the interface to the application
+            String stateName = stateItems[i].getStateString();
+
+            // draw color with name
+            Bar bar = new Bar(gs, rgb);
+            gd = new GridData();
+            gd.widthHint = 40;
+            gd.heightHint = 20;
+            gd.verticalIndent = 8;
+            bar.setLayoutData(gd);
+            Label name = new Label(gs, SWT.NONE);
+            name.setText(stateName);
+            gd = new GridData();
+            gd.horizontalIndent = 10;
+            gd.verticalIndent = 8;
+            name.setLayoutData(gd);
+        }
+    }
+
+    @Override
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+        shell.setText(Messages.TmfTimeLegend_TRACE_STATES_TITLE);
+    }
+
+    @Override
+    protected void createButtonsForButtonBar(Composite parent) {
+        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+                true);
+    }
+
+    class Bar extends Canvas {
+        private final Color color;
+
+        public Bar(Composite parent, RGB rgb) {
+            super(parent, SWT.NONE);
+
+            color = fResourceManager.createColor(rgb);
+            addListener(SWT.Paint, new Listener() {
+                @Override
+                public void handleEvent(Event event) {
+                    draw(event.gc);
+                }
+            });
+        }
+
+        private void draw(GC gc) {
+            Rectangle r = getClientArea();
+            gc.setBackground(color);
+            gc.fillRectangle(r);
+            gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
+            gc.drawRectangle(0, 0, r.width - 1, r.height - 1);
+        }
+
+        @Override
+        public void dispose() {
+            super.dispose();
+            color.dispose();
+        }
+
+    }
+
+}
index 73a10e3bb664137b5a1c86370ecc6a37af41183e..9326eb84be7c2ae4d536c971d632acfbc26eb7af 100644 (file)
@@ -1,50 +1,50 @@
-/*******************************************************************************\r
- * Copyright (c) 2009, 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *   Patrick Tasse - Refactoring\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;\r
-\r
-/**\r
- * Interface for time events, for use in the timegraph view\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeEvent {\r
-\r
-    /**\r
-     * Get the entry matching this time event.\r
-     *\r
-     * @return The time graph entry\r
-     */\r
-    public ITimeGraphEntry getEntry();\r
-\r
-    /**\r
-     * Get the timestamp of this event.\r
-     *\r
-     * @return The event's time\r
-     */\r
-    public long getTime();\r
-\r
-    /**\r
-     * @return\r
-     * <list>\r
-     * <li>-1: Considers duration to be from current event till the next</li>\r
-     * <li>0: Duration is not relevant e.g. a Burst / no state associated</li>\r
-     * <li>>0: Valid duration value specified</li>\r
-     * </list>\r
-     * <p>\r
-     */\r
-    public long getDuration();\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon - Initial API and implementation
+ *   Patrick Tasse - Refactoring
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;
+
+/**
+ * Interface for time events, for use in the timegraph view
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public interface ITimeEvent {
+
+    /**
+     * Get the entry matching this time event.
+     *
+     * @return The time graph entry
+     */
+    public ITimeGraphEntry getEntry();
+
+    /**
+     * Get the timestamp of this event.
+     *
+     * @return The event's time
+     */
+    public long getTime();
+
+    /**
+     * @return
+     * <list>
+     * <li>-1: Considers duration to be from current event till the next</li>
+     * <li>0: Duration is not relevant e.g. a Burst / no state associated</li>
+     * <li>>0: Valid duration value specified</li>
+     * </list>
+     * <p>
+     */
+    public long getDuration();
+
 }
\ No newline at end of file
index 16d50257aaf961132c77555ebc4dabdfd8a87c35..f31d7c2a7ef914f089599fcbd18c471bb566b68c 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2009, 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *   Patrick Tasse - Refactoring\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;\r
-\r
-import java.util.Iterator;\r
-\r
-/**\r
- * Interface for an entry (row) in the time graph view\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeGraphEntry {\r
-\r
-    /**\r
-     * Returns the parent of this entry, or <code>null</code> if it has none.\r
-     *\r
-     * @return the parent element, or <code>null</code> if it has none\r
-     */\r
-    public ITimeGraphEntry getParent();\r
-\r
-    /**\r
-     * Returns whether this entry has children.\r
-     *\r
-     * @return <code>true</code> if the given element has children,\r
-     *  and <code>false</code> if it has no children\r
-     */\r
-    public boolean hasChildren();\r
-\r
-    /**\r
-     * Returns the child elements of this entry.\r
-     *\r
-     * @return an array of child elements\r
-     */\r
-    public ITimeGraphEntry[] getChildren();\r
-\r
-    /**\r
-     * Returns the name of this entry.\r
-     *\r
-     * @return the entry name\r
-     */\r
-    public String getName();\r
-\r
-    /**\r
-     * Returns the start time of this entry in nanoseconds.\r
-     *\r
-     * @return the start time\r
-     */\r
-    public long getStartTime();\r
-\r
-    /**\r
-     * Returns the end time of this entry in nanoseconds.\r
-     *\r
-     * @return the end time\r
-     */\r
-    public long getEndTime();\r
-\r
-    /**\r
-     * Returns whether this entry has time events.\r
-     * If true, the time events iterator should not be null.\r
-     *\r
-     * @return true if the entry has time events\r
-     *\r
-     * @see #getTimeEventsIterator\r
-     * @see #getTimeEventsIterator(long, long, long)\r
-     */\r
-    public boolean hasTimeEvents();\r
-\r
-    /**\r
-     * Get an iterator which returns all time events.\r
-     *\r
-     * @return the iterator\r
-     */\r
-    public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator();\r
-\r
-    /**\r
-     * Get an iterator which only returns events that fall within the start time and the stop time.\r
-     * The visible duration is the event duration below which further detail is not discernible.\r
-     * If no such iterator is implemented, provide a basic iterator which returns all events.\r
-     *\r
-     * @param startTime start time in nanoseconds\r
-     * @param stopTime stop time in nanoseconds\r
-     * @param visibleDuration duration of one pixel in nanoseconds\r
-     *\r
-     * @return the iterator\r
-     */\r
-    public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration);\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alvaro Sanchez-Leon - Initial API and implementation
+ *   Patrick Tasse - Refactoring
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;
+
+import java.util.Iterator;
+
+/**
+ * Interface for an entry (row) in the time graph view
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public interface ITimeGraphEntry {
+
+    /**
+     * Returns the parent of this entry, or <code>null</code> if it has none.
+     *
+     * @return the parent element, or <code>null</code> if it has none
+     */
+    public ITimeGraphEntry getParent();
+
+    /**
+     * Returns whether this entry has children.
+     *
+     * @return <code>true</code> if the given element has children,
+     *  and <code>false</code> if it has no children
+     */
+    public boolean hasChildren();
+
+    /**
+     * Returns the child elements of this entry.
+     *
+     * @return an array of child elements
+     */
+    public ITimeGraphEntry[] getChildren();
+
+    /**
+     * Returns the name of this entry.
+     *
+     * @return the entry name
+     */
+    public String getName();
+
+    /**
+     * Returns the start time of this entry in nanoseconds.
+     *
+     * @return the start time
+     */
+    public long getStartTime();
+
+    /**
+     * Returns the end time of this entry in nanoseconds.
+     *
+     * @return the end time
+     */
+    public long getEndTime();
+
+    /**
+     * Returns whether this entry has time events.
+     * If true, the time events iterator should not be null.
+     *
+     * @return true if the entry has time events
+     *
+     * @see #getTimeEventsIterator
+     * @see #getTimeEventsIterator(long, long, long)
+     */
+    public boolean hasTimeEvents();
+
+    /**
+     * Get an iterator which returns all time events.
+     *
+     * @return the iterator
+     */
+    public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator();
+
+    /**
+     * Get an iterator which only returns events that fall within the start time and the stop time.
+     * The visible duration is the event duration below which further detail is not discernible.
+     * If no such iterator is implemented, provide a basic iterator which returns all events.
+     *
+     * @param startTime start time in nanoseconds
+     * @param stopTime stop time in nanoseconds
+     * @param visibleDuration duration of one pixel in nanoseconds
+     *
+     * @return the iterator
+     */
+    public <T extends ITimeEvent> Iterator<T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration);
+}
index aa82194f7879048863ab9899395ba2b5038e3a5a..34988a6df5e7aa6256dab0b0faab95ecb52b4262 100644 (file)
@@ -1,56 +1,56 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;\r
-\r
-/**\r
- * Generic TimeEvent implementation\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-public class TimeEvent implements ITimeEvent {\r
-    protected ITimeGraphEntry fEntry;\r
-    protected long fTime;\r
-    protected long fDuration;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param entry\r
-     *            The entry matching this event\r
-     * @param time\r
-     *            The timestamp of this event\r
-     * @param duration\r
-     *            The duration of the event\r
-     */\r
-    public TimeEvent(ITimeGraphEntry entry, long time, long duration) {\r
-        fEntry = entry;\r
-        fTime = time;\r
-        fDuration = duration;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry getEntry() {\r
-        return fEntry;\r
-    }\r
-\r
-    @Override\r
-    public long getTime() {\r
-        return fTime;\r
-    }\r
-\r
-    @Override\r
-    public long getDuration() {\r
-        return fDuration;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;
+
+/**
+ * Generic TimeEvent implementation
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeEvent implements ITimeEvent {
+    protected ITimeGraphEntry fEntry;
+    protected long fTime;
+    protected long fDuration;
+
+    /**
+     * Standard constructor
+     *
+     * @param entry
+     *            The entry matching this event
+     * @param time
+     *            The timestamp of this event
+     * @param duration
+     *            The duration of the event
+     */
+    public TimeEvent(ITimeGraphEntry entry, long time, long duration) {
+        fEntry = entry;
+        fTime = time;
+        fDuration = duration;
+    }
+
+    @Override
+    public ITimeGraphEntry getEntry() {
+        return fEntry;
+    }
+
+    @Override
+    public long getTime() {
+        return fTime;
+    }
+
+    @Override
+    public long getDuration() {
+        return fDuration;
+    }
+}
index 3b9fc98a8ce92fb11665411c159df6a222a5c2f4..260eb1b4cf3e572bb21681d2a330af594d4406de 100644 (file)
-/*****************************************************************************\r
- * Copyright (c) 2007 Intel Corporation, 2010, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alvaro Sanchez-Leon - Updated for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-/**\r
- * Time data provider interface, for use in the timegraph widget.\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public interface ITimeDataProvider {\r
-\r
-    /**\r
-     * @return The selected time\r
-     */\r
-    long getSelectedTime();\r
-\r
-    /**\r
-     * @return The beginning time\r
-     */\r
-    long getBeginTime();\r
-\r
-    /**\r
-     * @return The end time\r
-     */\r
-    long getEndTime();\r
-\r
-    /**\r
-     * @return The minimum time\r
-     */\r
-    long getMinTime();\r
-\r
-    /**\r
-     * @return The maximum time\r
-     */\r
-    long getMaxTime();\r
-\r
-    /**\r
-     * @return The start time of the current selection window\r
-     */\r
-    long getTime0();\r
-\r
-    /**\r
-     * @return The end time of the current selection window\r
-     */\r
-    long getTime1();\r
-\r
-    /**\r
-     * @return The minimal time interval\r
-     */\r
-    long getMinTimeInterval();\r
-\r
-    /**\r
-     * Updates the time range and notify registered listeners\r
-     *\r
-     * @param time0\r
-     * @param time1\r
-     */\r
-    void setStartFinishTimeNotify(long time0, long time1);\r
-\r
-    /**\r
-     * Update the time range but do not trigger event notification\r
-     *\r
-     * @param time0\r
-     * @param time1\r
-     */\r
-    void setStartFinishTime(long time0, long time1);\r
-\r
-    /**\r
-     * Notify registered listeners without updating the time range\r
-     */\r
-    void notifyStartFinishTime();\r
-\r
-    /**\r
-     * Updates the selected time, adjusts the time range if necessary and\r
-     * notifies any registered listeners about the new selected time and new\r
-     * range (if necessary)\r
-     *\r
-     * @param time\r
-     *            A Time to set\r
-     * @param ensureVisible\r
-     *            Ensure visibility of new time (will adjust time range if\r
-     *            necessary)\r
-     */\r
-    public void setSelectedTimeNotify(long time, boolean ensureVisible);\r
-\r
-    /**\r
-     * Updates the selected time and adjusts the time range if necessary without\r
-     * notifying registered listeners.\r
-     *\r
-     * @param time\r
-     *            A Time to set\r
-     * @param ensureVisible\r
-     *            Ensure visibility of new time (will adjust time range if\r
-     *            necessary)\r
-     */\r
-    public void setSelectedTime(long time, boolean ensureVisible);\r
-\r
-    /**\r
-     * Reset the start and end times\r
-     */\r
-    void resetStartFinishTime();\r
-\r
-    /**\r
-     * @return The names' width\r
-     */\r
-    int getNameSpace();\r
-\r
-    /**\r
-     * Set the names' width\r
-     *\r
-     * @param width\r
-     */\r
-    void setNameSpace(int width);\r
-\r
-    /**\r
-     * @return The width for timestamps\r
-     */\r
-    int getTimeSpace();\r
-\r
-    /**\r
-     * @return If the calendar format is absolute (true) or relative (false)\r
-     */\r
-    boolean isCalendarFormat();\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2007 Intel Corporation, 2010, 2012 Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alvaro Sanchez-Leon - Updated for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+/**
+ * Time data provider interface, for use in the timegraph widget.
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public interface ITimeDataProvider {
+
+    /**
+     * @return The selected time
+     */
+    long getSelectedTime();
+
+    /**
+     * @return The beginning time
+     */
+    long getBeginTime();
+
+    /**
+     * @return The end time
+     */
+    long getEndTime();
+
+    /**
+     * @return The minimum time
+     */
+    long getMinTime();
+
+    /**
+     * @return The maximum time
+     */
+    long getMaxTime();
+
+    /**
+     * @return The start time of the current selection window
+     */
+    long getTime0();
+
+    /**
+     * @return The end time of the current selection window
+     */
+    long getTime1();
+
+    /**
+     * @return The minimal time interval
+     */
+    long getMinTimeInterval();
+
+    /**
+     * Updates the time range and notify registered listeners
+     *
+     * @param time0
+     * @param time1
+     */
+    void setStartFinishTimeNotify(long time0, long time1);
+
+    /**
+     * Update the time range but do not trigger event notification
+     *
+     * @param time0
+     * @param time1
+     */
+    void setStartFinishTime(long time0, long time1);
+
+    /**
+     * Notify registered listeners without updating the time range
+     */
+    void notifyStartFinishTime();
+
+    /**
+     * Updates the selected time, adjusts the time range if necessary and
+     * notifies any registered listeners about the new selected time and new
+     * range (if necessary)
+     *
+     * @param time
+     *            A Time to set
+     * @param ensureVisible
+     *            Ensure visibility of new time (will adjust time range if
+     *            necessary)
+     */
+    public void setSelectedTimeNotify(long time, boolean ensureVisible);
+
+    /**
+     * Updates the selected time and adjusts the time range if necessary without
+     * notifying registered listeners.
+     *
+     * @param time
+     *            A Time to set
+     * @param ensureVisible
+     *            Ensure visibility of new time (will adjust time range if
+     *            necessary)
+     */
+    public void setSelectedTime(long time, boolean ensureVisible);
+
+    /**
+     * Reset the start and end times
+     */
+    void resetStartFinishTime();
+
+    /**
+     * @return The names' width
+     */
+    int getNameSpace();
+
+    /**
+     * Set the names' width
+     *
+     * @param width
+     */
+    void setNameSpace(int width);
+
+    /**
+     * @return The width for timestamps
+     */
+    int getTimeSpace();
+
+    /**
+     * @return If the calendar format is absolute (true) or relative (false)
+     */
+    boolean isCalendarFormat();
+}
index 96d818911614c18092318e7e14bcb76d81804f73..3be2c0a5b67942ccf2d084005afb2d65b2b363f7 100644 (file)
-/*****************************************************************************\r
- * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alvaro Sanchez-Leon - Updated for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-/**\r
- * Base control abstract class for the time graph widget\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public abstract class TimeGraphBaseControl extends Canvas implements PaintListener {\r
-\r
-    /** Default left margin size */\r
-    static public final int MARGIN = 4;\r
-\r
-    /** Default expanded size */\r
-    static public final int EXPAND_SIZE = 9; // the [+] or [-] control size\r
-\r
-    /** Default size of the right margin */\r
-    static public final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible\r
-\r
-    /** Default size for small icons */\r
-    static public final int SMALL_ICON_SIZE = 16;\r
-\r
-    protected TimeGraphColorScheme _colors;\r
-    protected int _fontHeight = 0;\r
-\r
-    /**\r
-     * Basic constructor. Uses a default style value\r
-     *\r
-     * @param parent\r
-     *            The parent composite object\r
-     * @param colors\r
-     *            The color scheme to use\r
-     */\r
-    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors) {\r
-        this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);\r
-    }\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param parent\r
-     *            The parent composite object\r
-     * @param colors\r
-     *            The color scheme to use\r
-     * @param style\r
-     *            The index of the style to use\r
-     */\r
-    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors, int style) {\r
-        super(parent, style);\r
-        _colors = colors;\r
-        addPaintListener(this);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        super.dispose();\r
-    }\r
-\r
-    @Override\r
-    public void paintControl(PaintEvent e) {\r
-        if (e.widget != this) {\r
-            return;\r
-        }\r
-        _fontHeight = e.gc.getFontMetrics().getHeight();\r
-        Rectangle bound = getClientArea();\r
-        if (!bound.isEmpty()) {\r
-            Color colBackup = e.gc.getBackground();\r
-            paint(bound, e);\r
-            e.gc.setBackground(colBackup);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Retrieve the current font's height\r
-     *\r
-     * @return The height\r
-     */\r
-    public int getFontHeight() {\r
-        return _fontHeight;\r
-    }\r
-\r
-    abstract void paint(Rectangle bound, PaintEvent e);\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alvaro Sanchez-Leon - Updated for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Base control abstract class for the time graph widget
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public abstract class TimeGraphBaseControl extends Canvas implements PaintListener {
+
+    /** Default left margin size */
+    static public final int MARGIN = 4;
+
+    /** Default expanded size */
+    static public final int EXPAND_SIZE = 9; // the [+] or [-] control size
+
+    /** Default size of the right margin */
+    static public final int RIGHT_MARGIN = 1; // 1 pixels less to make sure end time is visible
+
+    /** Default size for small icons */
+    static public final int SMALL_ICON_SIZE = 16;
+
+    protected TimeGraphColorScheme _colors;
+    protected int _fontHeight = 0;
+
+    /**
+     * Basic constructor. Uses a default style value
+     *
+     * @param parent
+     *            The parent composite object
+     * @param colors
+     *            The color scheme to use
+     */
+    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors) {
+        this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);
+    }
+
+    /**
+     * Standard constructor
+     *
+     * @param parent
+     *            The parent composite object
+     * @param colors
+     *            The color scheme to use
+     * @param style
+     *            The index of the style to use
+     */
+    public TimeGraphBaseControl(Composite parent, TimeGraphColorScheme colors, int style) {
+        super(parent, style);
+        _colors = colors;
+        addPaintListener(this);
+    }
+
+    @Override
+    public void dispose() {
+        super.dispose();
+    }
+
+    @Override
+    public void paintControl(PaintEvent e) {
+        if (e.widget != this) {
+            return;
+        }
+        _fontHeight = e.gc.getFontMetrics().getHeight();
+        Rectangle bound = getClientArea();
+        if (!bound.isEmpty()) {
+            Color colBackup = e.gc.getBackground();
+            paint(bound, e);
+            e.gc.setBackground(colBackup);
+        }
+    }
+
+    /**
+     * Retrieve the current font's height
+     *
+     * @return The height
+     */
+    public int getFontHeight() {
+        return _fontHeight;
+    }
+
+    abstract void paint(Rectangle bound, PaintEvent e);
+}
index d8061804b2ff2bdcfe61dc9117d241a45dfaf0e0..b398df40919223c054b72409d54056b575136b72 100644 (file)
-/*****************************************************************************\r
- * Copyright (c) 2008 Intel Corporation, 2009, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alvaro Sanchez-Leon - Updated for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-\r
-/**\r
- * Color theme used by the timegraph view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TimeGraphColorScheme {\r
-\r
-    // elements color indices\r
-    static public final int BLACK_STATE = 0;\r
-    static public final int GREEN_STATE = 1;\r
-    static public final int DARK_BLUE_STATE = 2;\r
-    static public final int ORANGE_STATE = 3;\r
-    static public final int GOLD_STATE = 4;\r
-    static public final int RED_STATE = 5;\r
-    static public final int GRAY_STATE = 6;\r
-    static public final int DARK_GREEN_STATE = 7;\r
-    static public final int DARK_YELLOW_STATE = 8;\r
-    static public final int MAGENTA3_STATE = 9;\r
-    static public final int PURPLE1_STATE = 10;\r
-    static public final int PINK1_STATE = 11;\r
-    static public final int AQUAMARINE_STATE = 12;\r
-    static public final int LIGHT_BLUE_STATE = 13;\r
-    static public final int CADET_BLUE_STATE = 14;\r
-    static public final int OLIVE_STATE = 15;\r
-\r
-    static public final int STATES0 = 0;\r
-    static public final int STATES1 = 15;\r
-\r
-    // selected state elements color indices\r
-    static public final int BLACK_STATE_SEL = 16;\r
-    static public final int GREEN_STATE_SEL = 17;\r
-    static public final int DARK_BLUE_STATE_SEL = 18;\r
-    static public final int ORANGE_STATE_SEL = 19;\r
-    static public final int GOLD_STATE_SEL = 20;\r
-    static public final int RED_STATE_SEL = 21;\r
-    static public final int GRAY_STATE_SEL = 22;\r
-    static public final int DARK_GREEN_STATE_SEL = 23;\r
-    static public final int DARK_YELLOW_STATE_SEL = 24;\r
-    static public final int MAGENTA3_STATE_SEL = 25;\r
-    static public final int PURPLE1_STATE_SEL = 26;\r
-    static public final int PINK1_STATE_SEL = 27;\r
-    static public final int AQUAMARINE_STATE_SEL = 28;\r
-    static public final int LIGHT_BLUE_STATE_SEL = 29;\r
-    static public final int CADET_BLUE_STATE_SEL = 30;\r
-    static public final int OLIVE_STATE_SEL = 31;\r
-\r
-    static public final int STATES_SEL0 = 16;\r
-    static public final int STATES_SEL1 = 31;\r
-\r
-    // colors indices for viewer controls\r
-    static public final int BACKGROUND = 32;\r
-    static public final int FOREGROUND = 33;\r
-    static public final int BACKGROUND_SEL = 34;\r
-    static public final int FOREGROUND_SEL = 35;\r
-    static public final int BACKGROUND_SEL_NOFOCUS = 36;\r
-    static public final int FOREGROUND_SEL_NOFOCUS = 37;\r
-    static public final int TOOL_BACKGROUND = 38;\r
-    static public final int TOOL_FOREGROUND = 39;\r
-\r
-    // misc colors\r
-    static public final int FIX_COLOR = 40;\r
-    static public final int WHITE = 41;\r
-    static public final int GRAY = 42;\r
-    static public final int BLACK = 43;\r
-    static public final int DARK_GRAY = 44;\r
-\r
-    // selected border color indices\r
-    static public final int BLACK_BORDER = 45;\r
-    static public final int GREEN_BORDER = 46;\r
-    static public final int DARK_BLUE_BORDER = 47;\r
-    static public final int ORANGE_BORDER = 48;\r
-    static public final int GOLD_BORDER = 49;\r
-    static public final int RED_BORDER = 50;\r
-    static public final int GRAY_BORDER = 51;\r
-    static public final int DARK_GREEN_BORDER1 = 52;\r
-    static public final int DARK_YELLOW_BORDER1 = 53;\r
-    static public final int MAGENTA3_BORDER1 = 54;\r
-    static public final int PURPLE1_BORDER1 = 55;\r
-    static public final int PINK1_BORDER1 = 56;\r
-    static public final int AQUAMARINE_BORDER1 = 57;\r
-    static public final int LIGHT_BLUE_BORDER1 = 58;\r
-    static public final int CADET_BLUE_STATE_BORDER = 59;\r
-    static public final int OLIVE_BORDER2 = 60;\r
-\r
-    static public final int STATES_BORDER0 = 45;\r
-    static public final int STATES_BORDER1 = 60;\r
-\r
-    static public final int MID_LINE = 61;\r
-    static public final int RED = 62;\r
-    static public final int GREEN = 63;\r
-    static public final int BLUE = 64;\r
-    static public final int YELLOW = 65;\r
-    static public final int CYAN = 66;\r
-    static public final int MAGENTA = 67;\r
-\r
-    static public final int SELECTED_TIME = 68;\r
-    static public final int LEGEND_BACKGROUND = 69;\r
-    static public final int LEGEND_FOREGROUND = 70;\r
-\r
-    // group items' colors\r
-    static public final int GR_BACKGROUND = 71;\r
-    static public final int GR_FOREGROUND = 72;\r
-    static public final int GR_BACKGROUND_SEL = 73;\r
-    static public final int GR_FOREGROUND_SEL = 74;\r
-    static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;\r
-    static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;\r
-\r
-    static public final int LIGHT_LINE = 77;\r
-    static public final int BACKGROUND_NAME = 78;\r
-    static public final int BACKGROUND_NAME_SEL = 79;\r
-    static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;\r
-\r
-    // Interraction's colors\r
-    static public final int TI_START_THREAD = BLACK;\r
-    static public final int TI_HANDOFF_LOCK = BLUE;\r
-    static public final int TI_NOTIFY_ALL = GREEN;\r
-    static public final int TI_NOTIFY = GREEN;\r
-    static public final int TI_NOTIFY_JOINED = DARK_GRAY;\r
-    static public final int TI_INTERRUPT = RED;\r
-    static public final int TI_WAIT_EXCEEDED = BLUE;\r
-\r
-    static interface IColorProvider {\r
-        public Color get();\r
-    }\r
-\r
-    static class SysCol implements IColorProvider {\r
-        int syscol;\r
-\r
-        SysCol(int syscol) {\r
-            this.syscol = syscol;\r
-        }\r
-\r
-        @Override\r
-        public Color get() {\r
-            return Utils.getSysColor(syscol);\r
-        }\r
-    }\r
-\r
-    static class RGB implements IColorProvider {\r
-        int r;\r
-        int g;\r
-        int b;\r
-\r
-        RGB(int r, int g, int b) {\r
-            this.r = r;\r
-            this.g = g;\r
-            this.b = b;\r
-        }\r
-\r
-        @Override\r
-        public Color get() {\r
-            return new Color(null, r, g, b);\r
-        }\r
-    }\r
-\r
-    static class Mix implements IColorProvider {\r
-        IColorProvider cp1;\r
-        IColorProvider cp2;\r
-        int w1;\r
-        int w2;\r
-\r
-        Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {\r
-            this.cp1 = cp1;\r
-            this.cp2 = cp2;\r
-            this.w1 = w1;\r
-            this.w2 = w2;\r
-        }\r
-\r
-        Mix(IColorProvider cp1, IColorProvider cp2) {\r
-            this.cp1 = cp1;\r
-            this.cp2 = cp2;\r
-            this.w1 = 1;\r
-            this.w2 = 1;\r
-        }\r
-\r
-        @Override\r
-        public Color get() {\r
-            Color col1 = cp1.get();\r
-            Color col2 = cp2.get();\r
-            Color col = Utils.mixColors(col1, col2, w1, w2);\r
-            return col;\r
-        }\r
-    }\r
-\r
-    static private final IColorProvider _providersMap[] = {\r
-        //\r
-        new RGB(100, 100, 100), // UNKNOWN\r
-        new RGB(174, 200, 124), // RUNNING\r
-        new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING\r
-        new RGB(210, 150, 60), // WAITING\r
-        new RGB(242, 225, 168), // BLOCKED\r
-        new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK\r
-        new RGB(200, 200, 200), // STOPPED\r
-        new RGB(35, 107, 42), // STEEL BLUE\r
-        new RGB(205,205,0), // DARK YELLOW\r
-        new RGB(205, 0, 205), // MAGENTA\r
-        new RGB(171, 130, 255), // PURPLE\r
-        new RGB(255, 181, 197), // PINK\r
-        new RGB(112, 219, 147), // AQUAMARINE\r
-        new RGB(198, 226, 255), // SLATEGRAY\r
-        new RGB(95, 158, 160), // CADET BLUE\r
-        new RGB(107, 142, 35), // OLIVE\r
-\r
-\r
-        //TODO: Does not seem to be used, check during clean-up\r
-        new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL\r
-        new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL\r
-        new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL\r
-        new SysCol(SWT.COLOR_CYAN), // WAITING_SEL\r
-        new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL\r
-        new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL\r
-        new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL\r
-        new SysCol(SWT.COLOR_WHITE),\r
-        new SysCol(SWT.COLOR_GREEN),\r
-        new SysCol(SWT.COLOR_BLUE),\r
-        new SysCol(SWT.COLOR_CYAN),\r
-        new SysCol(SWT.COLOR_YELLOW),\r
-        new SysCol(SWT.COLOR_RED),\r
-        new SysCol(SWT.COLOR_DARK_GRAY),\r
-        new SysCol(SWT.COLOR_WHITE),\r
-        new SysCol(SWT.COLOR_GREEN),\r
-\r
-\r
-        new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND\r
-        new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND\r
-        new RGB(232, 242, 254), // BACKGROUND_SEL\r
-        new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL\r
-        new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS\r
-        new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS\r
-        new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND\r
-        new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND\r
-\r
-        new SysCol(SWT.COLOR_GRAY), // FIX_COLOR\r
-        new SysCol(SWT.COLOR_WHITE), // WHITE\r
-        new SysCol(SWT.COLOR_GRAY), // GRAY\r
-        new SysCol(SWT.COLOR_BLACK), // BLACK\r
-        new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY\r
-\r
-        new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER\r
-        new RGB(75, 115, 120), // GREEN_BORDER\r
-        new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER\r
-        new RGB(242, 225, 168), // ORANGE_BORDER\r
-        new RGB(210, 150, 60), // GOLD_BORDER\r
-        new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER\r
-        new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER\r
-        new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER\r
-        new RGB(75, 115, 120), // DARK_YELLOW_BORDER\r
-        new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER\r
-        new RGB(242, 225, 168), // PURPLE1_BORDER\r
-        new RGB(210, 150, 60), // PINK1_BORDER\r
-        new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER\r
-        new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER\r
-        new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER\r
-        new RGB(75, 115, 120), // OLIVE_BORDER\r
-\r
-\r
-        new SysCol(SWT.COLOR_GRAY), // MID_LINE\r
-        new SysCol(SWT.COLOR_RED), // RED\r
-        new SysCol(SWT.COLOR_GREEN), // GREEN\r
-        new SysCol(SWT.COLOR_BLUE), // BLUE\r
-        new SysCol(SWT.COLOR_YELLOW), // YELLOW\r
-        new SysCol(SWT.COLOR_CYAN), // CYAN\r
-        new SysCol(SWT.COLOR_MAGENTA), // MAGENTA\r
-\r
-        new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME\r
-        new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND\r
-        new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND\r
-\r
-        new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_LIST_BACKGROUND)),     // GR_BACKGROUND\r
-        new RGB(0, 0, 50),                                                          // GR_FOREGROUND\r
-        new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1),         // GR_BACKGROUND_SEL\r
-        new RGB(0, 0, 50),                                                          // GR_FOREGROUND_SEL\r
-        new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1),         // GR_BACKGROUND_SEL_NOFOCUS\r
-        new RGB(0, 0, 50),                                                          // GR_FOREGROUND_SEL_NOFOCUS\r
-\r
-        new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE\r
-\r
-        new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6),   // BACKGROUND_NAME\r
-        new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6),                  // BACKGROUND_NAME_SEL\r
-        new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS\r
-    };\r
-\r
-    private final Color _colors[];\r
-\r
-    /**\r
-     * Default constructor\r
-     */\r
-    public TimeGraphColorScheme() {\r
-        _colors = new Color[_providersMap.length];\r
-    }\r
-\r
-    /**\r
-     * Dispose this color scheme\r
-     */\r
-    public void dispose() {\r
-        for (int i = 0; i < _colors.length; i++) {\r
-            Utils.dispose(_colors[i]);\r
-            _colors[i] = null;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Get the color matching the given index\r
-     *\r
-     * @param idx\r
-     *            The index\r
-     * @return The matching color\r
-     */\r
-    public Color getColor(int idx) {\r
-        if (null == _colors[idx]) {\r
-            if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {\r
-                Color col1 = getColor(idx - STATES_SEL0);\r
-                Color col2 = getColor(BACKGROUND_SEL);\r
-                _colors[idx] = Utils.mixColors(col1, col2, 3, 1);\r
-            } else {\r
-                _colors[idx] = _providersMap[idx].get();\r
-            }\r
-        }\r
-        return _colors[idx];\r
-    }\r
-\r
-    /**\r
-     * Get an entry's background color based on its status.\r
-     *\r
-     * @param selected\r
-     *            If the entry is selected\r
-     * @param focused\r
-     *            If the entry is focused\r
-     * @param name\r
-     *            Get the color of the name column (false for other columns)\r
-     * @return The matching color\r
-     */\r
-    public Color getBkColor(boolean selected, boolean focused, boolean name) {\r
-        if (name) {\r
-            if (selected && focused) {\r
-                return getColor(BACKGROUND_NAME_SEL);\r
-            }\r
-            if (selected) {\r
-                return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
-            }\r
-            return getColor(BACKGROUND_NAME);\r
-        }\r
-        if (selected && focused) {\r
-            return getColor(BACKGROUND_SEL);\r
-        }\r
-        if (selected) {\r
-            return getColor(BACKGROUND_SEL_NOFOCUS);\r
-        }\r
-        return getColor(BACKGROUND);\r
-    }\r
-\r
-    /**\r
-     * Get the correct foreground color\r
-     *\r
-     * @param selected\r
-     *            Is the entry selected\r
-     * @param focused\r
-     *            Is the entry focused\r
-     * @return The matching color\r
-     */\r
-    public Color getFgColor(boolean selected, boolean focused) {\r
-        if (selected && focused) {\r
-            return getColor(FOREGROUND_SEL);\r
-        }\r
-        if (selected) {\r
-            return getColor(FOREGROUND_SEL_NOFOCUS);\r
-        }\r
-        return getColor(FOREGROUND);\r
-    }\r
-\r
-    /**\r
-     * Get the correct background color group\r
-     *\r
-     * @param selected\r
-     *            Is the entry selected\r
-     * @param focused\r
-     *            Is the entry focused\r
-     * @return The matching color\r
-     */\r
-    public Color getBkColorGroup(boolean selected, boolean focused) {\r
-        if (selected && focused) {\r
-            return getColor(GR_BACKGROUND_SEL);\r
-        }\r
-        if (selected) {\r
-            return getColor(GR_BACKGROUND_SEL_NOFOCUS);\r
-        }\r
-        return getColor(GR_BACKGROUND);\r
-    }\r
-\r
-    /**\r
-     * Get the correct foreground color group\r
-     *\r
-     * @param selected\r
-     *            Is the entry selected\r
-     * @param focused\r
-     *            Is the entry focused\r
-     * @return The matching color\r
-     */\r
-    public Color getFgColorGroup(boolean selected, boolean focused) {\r
-        if (selected && focused) {\r
-            return getColor(GR_FOREGROUND_SEL);\r
-        }\r
-        if (selected) {\r
-            return getColor(GR_FOREGROUND_SEL_NOFOCUS);\r
-        }\r
-        return getColor(GR_FOREGROUND);\r
-    }\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2008 Intel Corporation, 2009, 2012 Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alvaro Sanchez-Leon - Updated for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Color theme used by the timegraph view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TimeGraphColorScheme {
+
+    // elements color indices
+    static public final int BLACK_STATE = 0;
+    static public final int GREEN_STATE = 1;
+    static public final int DARK_BLUE_STATE = 2;
+    static public final int ORANGE_STATE = 3;
+    static public final int GOLD_STATE = 4;
+    static public final int RED_STATE = 5;
+    static public final int GRAY_STATE = 6;
+    static public final int DARK_GREEN_STATE = 7;
+    static public final int DARK_YELLOW_STATE = 8;
+    static public final int MAGENTA3_STATE = 9;
+    static public final int PURPLE1_STATE = 10;
+    static public final int PINK1_STATE = 11;
+    static public final int AQUAMARINE_STATE = 12;
+    static public final int LIGHT_BLUE_STATE = 13;
+    static public final int CADET_BLUE_STATE = 14;
+    static public final int OLIVE_STATE = 15;
+
+    static public final int STATES0 = 0;
+    static public final int STATES1 = 15;
+
+    // selected state elements color indices
+    static public final int BLACK_STATE_SEL = 16;
+    static public final int GREEN_STATE_SEL = 17;
+    static public final int DARK_BLUE_STATE_SEL = 18;
+    static public final int ORANGE_STATE_SEL = 19;
+    static public final int GOLD_STATE_SEL = 20;
+    static public final int RED_STATE_SEL = 21;
+    static public final int GRAY_STATE_SEL = 22;
+    static public final int DARK_GREEN_STATE_SEL = 23;
+    static public final int DARK_YELLOW_STATE_SEL = 24;
+    static public final int MAGENTA3_STATE_SEL = 25;
+    static public final int PURPLE1_STATE_SEL = 26;
+    static public final int PINK1_STATE_SEL = 27;
+    static public final int AQUAMARINE_STATE_SEL = 28;
+    static public final int LIGHT_BLUE_STATE_SEL = 29;
+    static public final int CADET_BLUE_STATE_SEL = 30;
+    static public final int OLIVE_STATE_SEL = 31;
+
+    static public final int STATES_SEL0 = 16;
+    static public final int STATES_SEL1 = 31;
+
+    // colors indices for viewer controls
+    static public final int BACKGROUND = 32;
+    static public final int FOREGROUND = 33;
+    static public final int BACKGROUND_SEL = 34;
+    static public final int FOREGROUND_SEL = 35;
+    static public final int BACKGROUND_SEL_NOFOCUS = 36;
+    static public final int FOREGROUND_SEL_NOFOCUS = 37;
+    static public final int TOOL_BACKGROUND = 38;
+    static public final int TOOL_FOREGROUND = 39;
+
+    // misc colors
+    static public final int FIX_COLOR = 40;
+    static public final int WHITE = 41;
+    static public final int GRAY = 42;
+    static public final int BLACK = 43;
+    static public final int DARK_GRAY = 44;
+
+    // selected border color indices
+    static public final int BLACK_BORDER = 45;
+    static public final int GREEN_BORDER = 46;
+    static public final int DARK_BLUE_BORDER = 47;
+    static public final int ORANGE_BORDER = 48;
+    static public final int GOLD_BORDER = 49;
+    static public final int RED_BORDER = 50;
+    static public final int GRAY_BORDER = 51;
+    static public final int DARK_GREEN_BORDER1 = 52;
+    static public final int DARK_YELLOW_BORDER1 = 53;
+    static public final int MAGENTA3_BORDER1 = 54;
+    static public final int PURPLE1_BORDER1 = 55;
+    static public final int PINK1_BORDER1 = 56;
+    static public final int AQUAMARINE_BORDER1 = 57;
+    static public final int LIGHT_BLUE_BORDER1 = 58;
+    static public final int CADET_BLUE_STATE_BORDER = 59;
+    static public final int OLIVE_BORDER2 = 60;
+
+    static public final int STATES_BORDER0 = 45;
+    static public final int STATES_BORDER1 = 60;
+
+    static public final int MID_LINE = 61;
+    static public final int RED = 62;
+    static public final int GREEN = 63;
+    static public final int BLUE = 64;
+    static public final int YELLOW = 65;
+    static public final int CYAN = 66;
+    static public final int MAGENTA = 67;
+
+    static public final int SELECTED_TIME = 68;
+    static public final int LEGEND_BACKGROUND = 69;
+    static public final int LEGEND_FOREGROUND = 70;
+
+    // group items' colors
+    static public final int GR_BACKGROUND = 71;
+    static public final int GR_FOREGROUND = 72;
+    static public final int GR_BACKGROUND_SEL = 73;
+    static public final int GR_FOREGROUND_SEL = 74;
+    static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;
+    static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;
+
+    static public final int LIGHT_LINE = 77;
+    static public final int BACKGROUND_NAME = 78;
+    static public final int BACKGROUND_NAME_SEL = 79;
+    static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;
+
+    // Interraction's colors
+    static public final int TI_START_THREAD = BLACK;
+    static public final int TI_HANDOFF_LOCK = BLUE;
+    static public final int TI_NOTIFY_ALL = GREEN;
+    static public final int TI_NOTIFY = GREEN;
+    static public final int TI_NOTIFY_JOINED = DARK_GRAY;
+    static public final int TI_INTERRUPT = RED;
+    static public final int TI_WAIT_EXCEEDED = BLUE;
+
+    static interface IColorProvider {
+        public Color get();
+    }
+
+    static class SysCol implements IColorProvider {
+        int syscol;
+
+        SysCol(int syscol) {
+            this.syscol = syscol;
+        }
+
+        @Override
+        public Color get() {
+            return Utils.getSysColor(syscol);
+        }
+    }
+
+    static class RGB implements IColorProvider {
+        int r;
+        int g;
+        int b;
+
+        RGB(int r, int g, int b) {
+            this.r = r;
+            this.g = g;
+            this.b = b;
+        }
+
+        @Override
+        public Color get() {
+            return new Color(null, r, g, b);
+        }
+    }
+
+    static class Mix implements IColorProvider {
+        IColorProvider cp1;
+        IColorProvider cp2;
+        int w1;
+        int w2;
+
+        Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {
+            this.cp1 = cp1;
+            this.cp2 = cp2;
+            this.w1 = w1;
+            this.w2 = w2;
+        }
+
+        Mix(IColorProvider cp1, IColorProvider cp2) {
+            this.cp1 = cp1;
+            this.cp2 = cp2;
+            this.w1 = 1;
+            this.w2 = 1;
+        }
+
+        @Override
+        public Color get() {
+            Color col1 = cp1.get();
+            Color col2 = cp2.get();
+            Color col = Utils.mixColors(col1, col2, w1, w2);
+            return col;
+        }
+    }
+
+    static private final IColorProvider _providersMap[] = {
+        //
+        new RGB(100, 100, 100), // UNKNOWN
+        new RGB(174, 200, 124), // RUNNING
+        new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING
+        new RGB(210, 150, 60), // WAITING
+        new RGB(242, 225, 168), // BLOCKED
+        new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK
+        new RGB(200, 200, 200), // STOPPED
+        new RGB(35, 107, 42), // STEEL BLUE
+        new RGB(205,205,0), // DARK YELLOW
+        new RGB(205, 0, 205), // MAGENTA
+        new RGB(171, 130, 255), // PURPLE
+        new RGB(255, 181, 197), // PINK
+        new RGB(112, 219, 147), // AQUAMARINE
+        new RGB(198, 226, 255), // SLATEGRAY
+        new RGB(95, 158, 160), // CADET BLUE
+        new RGB(107, 142, 35), // OLIVE
+
+
+        //TODO: Does not seem to be used, check during clean-up
+        new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL
+        new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL
+        new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL
+        new SysCol(SWT.COLOR_CYAN), // WAITING_SEL
+        new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL
+        new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL
+        new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL
+        new SysCol(SWT.COLOR_WHITE),
+        new SysCol(SWT.COLOR_GREEN),
+        new SysCol(SWT.COLOR_BLUE),
+        new SysCol(SWT.COLOR_CYAN),
+        new SysCol(SWT.COLOR_YELLOW),
+        new SysCol(SWT.COLOR_RED),
+        new SysCol(SWT.COLOR_DARK_GRAY),
+        new SysCol(SWT.COLOR_WHITE),
+        new SysCol(SWT.COLOR_GREEN),
+
+
+        new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND
+        new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND
+        new RGB(232, 242, 254), // BACKGROUND_SEL
+        new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL
+        new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS
+        new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS
+        new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND
+        new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND
+
+        new SysCol(SWT.COLOR_GRAY), // FIX_COLOR
+        new SysCol(SWT.COLOR_WHITE), // WHITE
+        new SysCol(SWT.COLOR_GRAY), // GRAY
+        new SysCol(SWT.COLOR_BLACK), // BLACK
+        new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY
+
+        new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER
+        new RGB(75, 115, 120), // GREEN_BORDER
+        new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER
+        new RGB(242, 225, 168), // ORANGE_BORDER
+        new RGB(210, 150, 60), // GOLD_BORDER
+        new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER
+        new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER
+        new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER
+        new RGB(75, 115, 120), // DARK_YELLOW_BORDER
+        new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER
+        new RGB(242, 225, 168), // PURPLE1_BORDER
+        new RGB(210, 150, 60), // PINK1_BORDER
+        new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER
+        new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER
+        new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER
+        new RGB(75, 115, 120), // OLIVE_BORDER
+
+
+        new SysCol(SWT.COLOR_GRAY), // MID_LINE
+        new SysCol(SWT.COLOR_RED), // RED
+        new SysCol(SWT.COLOR_GREEN), // GREEN
+        new SysCol(SWT.COLOR_BLUE), // BLUE
+        new SysCol(SWT.COLOR_YELLOW), // YELLOW
+        new SysCol(SWT.COLOR_CYAN), // CYAN
+        new SysCol(SWT.COLOR_MAGENTA), // MAGENTA
+
+        new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME
+        new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND
+        new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND
+
+        new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_LIST_BACKGROUND)),     // GR_BACKGROUND
+        new RGB(0, 0, 50),                                                          // GR_FOREGROUND
+        new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1),         // GR_BACKGROUND_SEL
+        new RGB(0, 0, 50),                                                          // GR_FOREGROUND_SEL
+        new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1),         // GR_BACKGROUND_SEL_NOFOCUS
+        new RGB(0, 0, 50),                                                          // GR_FOREGROUND_SEL_NOFOCUS
+
+        new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE
+
+        new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6),   // BACKGROUND_NAME
+        new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6),                  // BACKGROUND_NAME_SEL
+        new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS
+    };
+
+    private final Color _colors[];
+
+    /**
+     * Default constructor
+     */
+    public TimeGraphColorScheme() {
+        _colors = new Color[_providersMap.length];
+    }
+
+    /**
+     * Dispose this color scheme
+     */
+    public void dispose() {
+        for (int i = 0; i < _colors.length; i++) {
+            Utils.dispose(_colors[i]);
+            _colors[i] = null;
+        }
+    }
+
+    /**
+     * Get the color matching the given index
+     *
+     * @param idx
+     *            The index
+     * @return The matching color
+     */
+    public Color getColor(int idx) {
+        if (null == _colors[idx]) {
+            if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {
+                Color col1 = getColor(idx - STATES_SEL0);
+                Color col2 = getColor(BACKGROUND_SEL);
+                _colors[idx] = Utils.mixColors(col1, col2, 3, 1);
+            } else {
+                _colors[idx] = _providersMap[idx].get();
+            }
+        }
+        return _colors[idx];
+    }
+
+    /**
+     * Get an entry's background color based on its status.
+     *
+     * @param selected
+     *            If the entry is selected
+     * @param focused
+     *            If the entry is focused
+     * @param name
+     *            Get the color of the name column (false for other columns)
+     * @return The matching color
+     */
+    public Color getBkColor(boolean selected, boolean focused, boolean name) {
+        if (name) {
+            if (selected && focused) {
+                return getColor(BACKGROUND_NAME_SEL);
+            }
+            if (selected) {
+                return getColor(BACKGROUND_NAME_SEL_NOFOCUS);
+            }
+            return getColor(BACKGROUND_NAME);
+        }
+        if (selected && focused) {
+            return getColor(BACKGROUND_SEL);
+        }
+        if (selected) {
+            return getColor(BACKGROUND_SEL_NOFOCUS);
+        }
+        return getColor(BACKGROUND);
+    }
+
+    /**
+     * Get the correct foreground color
+     *
+     * @param selected
+     *            Is the entry selected
+     * @param focused
+     *            Is the entry focused
+     * @return The matching color
+     */
+    public Color getFgColor(boolean selected, boolean focused) {
+        if (selected && focused) {
+            return getColor(FOREGROUND_SEL);
+        }
+        if (selected) {
+            return getColor(FOREGROUND_SEL_NOFOCUS);
+        }
+        return getColor(FOREGROUND);
+    }
+
+    /**
+     * Get the correct background color group
+     *
+     * @param selected
+     *            Is the entry selected
+     * @param focused
+     *            Is the entry focused
+     * @return The matching color
+     */
+    public Color getBkColorGroup(boolean selected, boolean focused) {
+        if (selected && focused) {
+            return getColor(GR_BACKGROUND_SEL);
+        }
+        if (selected) {
+            return getColor(GR_BACKGROUND_SEL_NOFOCUS);
+        }
+        return getColor(GR_BACKGROUND);
+    }
+
+    /**
+     * Get the correct foreground color group
+     *
+     * @param selected
+     *            Is the entry selected
+     * @param focused
+     *            Is the entry focused
+     * @return The matching color
+     */
+    public Color getFgColorGroup(boolean selected, boolean focused) {
+        if (selected && focused) {
+            return getColor(GR_FOREGROUND_SEL);
+        }
+        if (selected) {
+            return getColor(GR_FOREGROUND_SEL_NOFOCUS);
+        }
+        return getColor(GR_FOREGROUND);
+    }
+}
index 5d7bb318c30e4c43cbc34ffc9df94dd4e3554256..f2a7eb515feeff5b6744acbeea641583df288b0d 100644 (file)
@@ -1,58 +1,58 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-/**\r
- * Item in the generic time graph view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TimeGraphItem {\r
-    public boolean _expanded;\r
-    public boolean _selected;\r
-    public boolean _hasChildren;\r
-    public int itemHeight;\r
-    public int level;\r
-    public List<TimeGraphItem> children;\r
-    public String _name;\r
-    public ITimeGraphEntry _trace;\r
-\r
-    /**\r
-     * Standard constructor\r
-     *\r
-     * @param trace\r
-     *            The entry matching to trace to which this item is associated\r
-     * @param name\r
-     *            The name of the item\r
-     * @param level\r
-     *            The tree level of this entry (0 = top level)\r
-     */\r
-    public TimeGraphItem(ITimeGraphEntry trace, String name, int level) {\r
-        this._trace = trace;\r
-        this._name = name;\r
-        this.level = level;\r
-        this.children = new ArrayList<TimeGraphItem>();\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return _name;\r
-    }\r
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+
+/**
+ * Item in the generic time graph view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TimeGraphItem {
+    public boolean _expanded;
+    public boolean _selected;
+    public boolean _hasChildren;
+    public int itemHeight;
+    public int level;
+    public List<TimeGraphItem> children;
+    public String _name;
+    public ITimeGraphEntry _trace;
+
+    /**
+     * Standard constructor
+     *
+     * @param trace
+     *            The entry matching to trace to which this item is associated
+     * @param name
+     *            The name of the item
+     * @param level
+     *            The tree level of this entry (0 = top level)
+     */
+    public TimeGraphItem(ITimeGraphEntry trace, String name, int level) {
+        this._trace = trace;
+        this._name = name;
+        this.level = level;
+        this.children = new ArrayList<TimeGraphItem>();
+    }
+
+    @Override
+    public String toString() {
+        return _name;
+    }
 }
\ No newline at end of file
index 101c33302ff6905622f2cb8890d0fc0fc51e2944..072d11fbd7b7dfef5d9912443db5b0fab82fe29e 100644 (file)
@@ -1,96 +1,96 @@
-/*****************************************************************************\r
- * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alvaro Sanchez-Leon - Updated for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-\r
-/**\r
- * Selection object for the time graph scale\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public class TimeGraphSelection implements IStructuredSelection {\r
-\r
-    List<Object> list = new ArrayList<Object>();\r
-\r
-    /**\r
-     * Default constructor\r
-     */\r
-    public TimeGraphSelection() {\r
-    }\r
-\r
-    /**\r
-     * "Wrapper" constructor. Instantiate a new selection object with only one\r
-     * existing selection.\r
-     *\r
-     * @param sel\r
-     *            The initial selection to add to this one\r
-     */\r
-    public TimeGraphSelection(Object sel) {\r
-        add(sel);\r
-    }\r
-\r
-    /**\r
-     * Add a selection to this one.\r
-     *\r
-     * @param sel\r
-     *            The selection to add\r
-     */\r
-    public void add(Object sel) {\r
-        if (null != sel && !list.contains(sel)) {\r
-            list.add(sel);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public Object getFirstElement() {\r
-        if (!list.isEmpty()) {\r
-            return list.get(0);\r
-        }\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public Iterator<Object> iterator() {\r
-        return list.iterator();\r
-    }\r
-\r
-    @Override\r
-    public int size() {\r
-        return list.size();\r
-    }\r
-\r
-    @Override\r
-    public Object[] toArray() {\r
-        return list.toArray();\r
-    }\r
-\r
-    @Override\r
-    public List<Object> toList() {\r
-        return list;\r
-    }\r
-\r
-    @Override\r
-    public boolean isEmpty() {\r
-        return list.isEmpty();\r
-    }\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2007 Intel Corporation, 2009, 2012 Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alvaro Sanchez-Leon - Updated for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * Selection object for the time graph scale
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public class TimeGraphSelection implements IStructuredSelection {
+
+    List<Object> list = new ArrayList<Object>();
+
+    /**
+     * Default constructor
+     */
+    public TimeGraphSelection() {
+    }
+
+    /**
+     * "Wrapper" constructor. Instantiate a new selection object with only one
+     * existing selection.
+     *
+     * @param sel
+     *            The initial selection to add to this one
+     */
+    public TimeGraphSelection(Object sel) {
+        add(sel);
+    }
+
+    /**
+     * Add a selection to this one.
+     *
+     * @param sel
+     *            The selection to add
+     */
+    public void add(Object sel) {
+        if (null != sel && !list.contains(sel)) {
+            list.add(sel);
+        }
+    }
+
+    @Override
+    public Object getFirstElement() {
+        if (!list.isEmpty()) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    @Override
+    public Iterator<Object> iterator() {
+        return list.iterator();
+    }
+
+    @Override
+    public int size() {
+        return list.size();
+    }
+
+    @Override
+    public Object[] toArray() {
+        return list.toArray();
+    }
+
+    @Override
+    public List<Object> toList() {
+        return list;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return list.isEmpty();
+    }
+}
index beb33a348b248e8c18ca3c6e78bc619ebd6b9691..0c81dbda21c60d83cddbd1227b48ac306e10083d 100644 (file)
-/*****************************************************************************\r
- * Copyright (c) 2007, 2008 Intel Corporation, 2009, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Intel Corporation - Initial API and implementation\r
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *   Alvaro Sanchez-Leon - Udpated for TMF\r
- *   Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import java.text.SimpleDateFormat;\r
-import java.util.Date;\r
-import java.util.Iterator;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Device;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-/**\r
- * General utilities and definitions used by the time graph widget\r
- *\r
- * @version 1.0\r
- * @author Alvaro Sanchez-Leon\r
- * @author Patrick Tasse\r
- */\r
-public class Utils {\r
-\r
-    /** Time format for dates and timestamp */\r
-    public enum TimeFormat {\r
-        /** Relative to the start of the trace */\r
-        RELATIVE,\r
-        /** Absolute timestamp (ie, relative to the Unix epoch) */\r
-        ABSOLUTE\r
-    }\r
-\r
-    static public final int IMG_THREAD_RUNNING = 0;\r
-    static public final int IMG_THREAD_SUSPENDED = 1;\r
-    static public final int IMG_THREAD_STOPPED = 2;\r
-    static public final int IMG_METHOD_RUNNING = 3;\r
-    static public final int IMG_METHOD = 4;\r
-    static public final int IMG_NUM = 5;\r
-\r
-    static public final Object[] _empty = new Object[0];\r
-\r
-    public static enum Resolution {\r
-        SECONDS, MILLISEC, MICROSEC, NANOSEC\r
-    }\r
-\r
-    static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$\r
-    static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$\r
-\r
-    static Rectangle clone(Rectangle source) {\r
-        return new Rectangle(source.x, source.y, source.width, source.height);\r
-    }\r
-\r
-    /**\r
-     * Initialize a Rectangle object to default values (all equal to 0)\r
-     *\r
-     * @param rect\r
-     *            The Rectangle to initialize\r
-     */\r
-    static public void init(Rectangle rect) {\r
-        rect.x = 0;\r
-        rect.y = 0;\r
-        rect.width = 0;\r
-        rect.height = 0;\r
-    }\r
-\r
-    /**\r
-     * Initialize a Rectangle object with all the given values\r
-     *\r
-     * @param rect\r
-     *            The Rectangle object to initialize\r
-     * @param x\r
-     *            The X coordinate\r
-     * @param y\r
-     *            The Y coordinate\r
-     * @param width\r
-     *            The width of the rectangle\r
-     * @param height\r
-     *            The height of the rectangle\r
-     */\r
-    static public void init(Rectangle rect, int x, int y, int width, int height) {\r
-        rect.x = x;\r
-        rect.y = y;\r
-        rect.width = width;\r
-        rect.height = height;\r
-    }\r
-\r
-    /**\r
-     * Initialize a Rectangle object to another existing Rectangle's values.\r
-     *\r
-     * @param rect\r
-     *            The Rectangle to initialize\r
-     * @param source\r
-     *            The reference Rectangle to copy\r
-     */\r
-    static public void init(Rectangle rect, Rectangle source) {\r
-        rect.x = source.x;\r
-        rect.y = source.y;\r
-        rect.width = source.width;\r
-        rect.height = source.height;\r
-    }\r
-\r
-    /**\r
-     * Reduce the size of a given rectangle by the given amounts.\r
-     *\r
-     * @param rect\r
-     *            The rectangle to modify\r
-     * @param x\r
-     *            The reduction in width\r
-     * @param y\r
-     *            The reduction in height\r
-     */\r
-    static public void deflate(Rectangle rect, int x, int y) {\r
-        rect.x += x;\r
-        rect.y += y;\r
-        rect.width -= x + x;\r
-        rect.height -= y + y;\r
-    }\r
-\r
-    /**\r
-     * Increase the size of a given rectangle by the given amounts.\r
-     *\r
-     * @param rect\r
-     *            The rectangle to modify\r
-     * @param x\r
-     *            The augmentation in width\r
-     * @param y\r
-     *            The augmentation in height\r
-     */\r
-    static public void inflate(Rectangle rect, int x, int y) {\r
-        rect.x -= x;\r
-        rect.y -= y;\r
-        rect.width += x + x;\r
-        rect.height += y + y;\r
-    }\r
-\r
-    static void dispose(Color col) {\r
-        if (null != col) {\r
-            col.dispose();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Get the resulting color from a mix of two existing ones for a given\r
-     * display.\r
-     *\r
-     * @param display\r
-     *            The display device (which might affect the color conversion)\r
-     * @param c1\r
-     *            The first color\r
-     * @param c2\r
-     *            The second color\r
-     * @param w1\r
-     *            The gamma level for color 1\r
-     * @param w2\r
-     *            The gamma level for color 2\r
-     * @return The resulting color\r
-     */\r
-    static public Color mixColors(Device display, Color c1, Color c2, int w1,\r
-            int w2) {\r
-        return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed())\r
-                / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen())\r
-                / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue())\r
-                / (w1 + w2));\r
-    }\r
-\r
-    /**\r
-     * Get the system color with the given ID.\r
-     *\r
-     * @param id\r
-     *            The color ID\r
-     * @return The resulting color\r
-     */\r
-    static public Color getSysColor(int id) {\r
-        Color col = Display.getCurrent().getSystemColor(id);\r
-        return new Color(col.getDevice(), col.getRGB());\r
-    }\r
-\r
-    /**\r
-     * Get the resulting color from a mix of two existing ones for the current\r
-     * display.\r
-     *\r
-     * @param col1\r
-     *            The first color\r
-     * @param col2\r
-     *            The second color\r
-     * @param w1\r
-     *            The gamma level for color 1\r
-     * @param w2\r
-     *            The gamma level for color 2\r
-     * @return The resulting color\r
-     */\r
-    static public Color mixColors(Color col1, Color col2, int w1, int w2) {\r
-        return mixColors(Display.getCurrent(), col1, col2, w1, w2);\r
-    }\r
-\r
-    /**\r
-     * Draw text in a rectangle.\r
-     *\r
-     * @param gc\r
-     *            The SWT GC object\r
-     * @param text\r
-     *            The text to draw\r
-     * @param rect\r
-     *            The rectangle object which is being drawn\r
-     * @param transp\r
-     *            Should we transpose the color\r
-     * @return The X coordinate where we have written\r
-     */\r
-    static public int drawText(GC gc, String text, Rectangle rect, boolean transp) {\r
-        Point size = gc.stringExtent(text);\r
-        gc.drawText(text, rect.x, rect.y, transp);\r
-        return size.x;\r
-    }\r
-\r
-    /**\r
-     * Draw text at a given location.\r
-     *\r
-     * @param gc\r
-     *            The SWT GC object\r
-     * @param text\r
-     *            The text to draw\r
-     * @param x\r
-     *            The X coordinate of the starting point\r
-     * @param y\r
-     *            the Y coordinate of the starting point\r
-     * @param transp\r
-     *            Should we transpose the color\r
-     * @return The X coordinate where we have written\r
-     */\r
-    static public int drawText(GC gc, String text, int x, int y, boolean transp) {\r
-        Point size = gc.stringExtent(text);\r
-        gc.drawText(text, x, y, transp);\r
-        return size.x;\r
-    }\r
-\r
-    /**\r
-     * Formats time in format: MM:SS:NNN\r
-     *\r
-     * @param time time\r
-     * @param format  0: MMMM:ss:nnnnnnnnn, 1: HH:MM:ss MMM.mmmm.nnn\r
-     * @param resolution the resolution\r
-     * @return the formatted time\r
-     */\r
-    static public String formatTime(long time, TimeFormat format, Resolution resolution) {\r
-        // if format is absolute (Calendar)\r
-        if (format == TimeFormat.ABSOLUTE) {\r
-            return formatTimeAbs(time, resolution);\r
-        }\r
-\r
-        StringBuffer str = new StringBuffer();\r
-        boolean neg = time < 0;\r
-        if (neg) {\r
-            time = -time;\r
-            str.append('-');\r
-        }\r
-\r
-        long sec = (long) (time * 1E-9);\r
-        // TODO: Expand to make it possible to select the minute, second, nanosecond format\r
-        //printing minutes is suppressed just sec and ns\r
-        // if (sec / 60 < 10)\r
-        // str.append('0');\r
-        // str.append(sec / 60);\r
-        // str.append(':');\r
-        // sec %= 60;\r
-        // if (sec < 10)\r
-        // str.append('0');\r
-        str.append(sec);\r
-        String ns = formatNs(time, resolution);\r
-        if (!ns.equals("")) { //$NON-NLS-1$\r
-            str.append('.');\r
-            str.append(ns);\r
-        }\r
-\r
-        return str.toString();\r
-    }\r
-\r
-    /**\r
-     * From input time in nanoseconds, convert to Date format YYYY-MM-dd\r
-     *\r
-     * @param absTime\r
-     *            The source time, in ns\r
-     * @return the formatted date\r
-     */\r
-    public static String formatDate(long absTime) {\r
-        String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));\r
-        return sdate;\r
-    }\r
-\r
-    /**\r
-     * Formats time in ns to Calendar format: HH:MM:SS MMM.mmm.nnn\r
-     *\r
-     * @param time\r
-     *            The source time, in ns\r
-     * @param res\r
-     *            The resolution to use\r
-     * @return the formatted time\r
-     */\r
-    static public String formatTimeAbs(long time, Resolution res) {\r
-        StringBuffer str = new StringBuffer();\r
-\r
-        // format time from nanoseconds to calendar time HH:MM:SS\r
-        String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
-        str.append(stime);\r
-        str.append('.');\r
-        // append the Milliseconds, MicroSeconds and NanoSeconds as specified in\r
-        // the Resolution\r
-        str.append(formatNs(time, res));\r
-        return str.toString();\r
-    }\r
-\r
-    /**\r
-     * Obtains the remainder fraction on unit Seconds of the entered value in\r
-     * nanoseconds. e.g. input: 1241207054171080214 ns The number of fraction\r
-     * seconds can be obtained by removing the last 9 digits: 1241207054 the\r
-     * fractional portion of seconds, expressed in ns is: 171080214\r
-     *\r
-     * @param time\r
-     *            The source time in ns\r
-     * @param res\r
-     *            The Resolution to use\r
-     * @return the formatted nanosec\r
-     */\r
-    public static String formatNs(long time, Resolution res) {\r
-        StringBuffer str = new StringBuffer();\r
-        boolean neg = time < 0;\r
-        if (neg) {\r
-            time = -time;\r
-        }\r
-\r
-        // The following approach could be used although performance\r
-        // decreases in half.\r
-        // String strVal = String.format("%09d", time);\r
-        // String tmp = strVal.substring(strVal.length() - 9);\r
-\r
-        long ns = time;\r
-        ns %= 1000000000;\r
-        if (ns < 10) {\r
-            str.append("00000000"); //$NON-NLS-1$\r
-        } else if (ns < 100) {\r
-            str.append("0000000"); //$NON-NLS-1$\r
-        } else if (ns < 1000) {\r
-            str.append("000000"); //$NON-NLS-1$\r
-        } else if (ns < 10000) {\r
-            str.append("00000"); //$NON-NLS-1$\r
-        } else if (ns < 100000) {\r
-            str.append("0000"); //$NON-NLS-1$\r
-        } else if (ns < 1000000) {\r
-            str.append("000"); //$NON-NLS-1$\r
-        } else if (ns < 10000000) {\r
-            str.append("00"); //$NON-NLS-1$\r
-        } else if (ns < 100000000) {\r
-            str.append("0"); //$NON-NLS-1$\r
-        }\r
-        str.append(ns);\r
-\r
-        if (res == Resolution.MILLISEC) {\r
-            return str.substring(0, 3);\r
-        } else if (res == Resolution.MICROSEC) {\r
-            return str.substring(0, 6);\r
-        } else if (res == Resolution.NANOSEC) {\r
-            return str.substring(0, 9);\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    /**\r
-     * FIXME Currently does nothing.\r
-     *\r
-     * @param opt\r
-     *            The option name\r
-     * @param def\r
-     *            The option value\r
-     * @param min\r
-     *            The minimal accepted value\r
-     * @param max\r
-     *            The maximal accepted value\r
-     * @return The value that was read\r
-     */\r
-    static public int loadIntOption(String opt, int def, int min, int max) {\r
-        // int val =\r
-        // TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
-        // if (0 == val)\r
-        // val = def;\r
-        // if (val < min)\r
-        // val = min;\r
-        // if (val > max)\r
-        // val = max;\r
-        return def;\r
-    }\r
-\r
-    /**\r
-     * FIXME currently does nothing\r
-     *\r
-     * @param opt\r
-     *            The option name\r
-     * @param val\r
-     *            The option value\r
-     */\r
-    static public void saveIntOption(String opt, int val) {\r
-        // TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);\r
-    }\r
-\r
-    static ITimeEvent getFirstEvent(ITimeGraphEntry entry) {\r
-        if (null == entry || ! entry.hasTimeEvents()) {\r
-            return null;\r
-        }\r
-        Iterator<ITimeEvent> iterator = entry.getTimeEventsIterator();\r
-        if (iterator != null && iterator.hasNext()) {\r
-            return iterator.next();\r
-        }\r
-        return null;\r
-    }\r
-\r
-    /**\r
-     * N means: <list> <li>-1: Previous Event</li> <li>0: Current Event</li> <li>\r
-     * 1: Next Event</li> <li>2: Previous Event when located in a non Event Area\r
-     * </list>\r
-     *\r
-     * @param entry\r
-     * @param time\r
-     * @param n\r
-     * @return\r
-     */\r
-    static ITimeEvent findEvent(ITimeGraphEntry entry, long time, int n) {\r
-        if (null == entry || ! entry.hasTimeEvents()) {\r
-            return null;\r
-        }\r
-        Iterator<ITimeEvent> iterator = entry.getTimeEventsIterator();\r
-        if (iterator == null) {\r
-            return null;\r
-        }\r
-        ITimeEvent nextEvent = null;\r
-        ITimeEvent currEvent = null;\r
-        ITimeEvent prevEvent = null;\r
-\r
-        while (iterator.hasNext()) {\r
-            nextEvent = iterator.next();\r
-            long nextStartTime = nextEvent.getTime();\r
-\r
-            if (nextStartTime > time) {\r
-                break;\r
-            }\r
-\r
-            if (currEvent == null || currEvent.getTime() != nextStartTime) {\r
-                prevEvent = currEvent;\r
-                currEvent = nextEvent;\r
-            }\r
-        }\r
-\r
-        if (n == -1) { //previous\r
-            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
-                return prevEvent;\r
-            }\r
-            return currEvent;\r
-        } else if (n == 0) { //current\r
-            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
-                return currEvent;\r
-            }\r
-            return null;\r
-        } else if (n == 1) { //next\r
-            if (nextEvent != null && nextEvent.getTime() > time) {\r
-                return nextEvent;\r
-            }\r
-            return null;\r
-        } else if (n == 2) { //current or previous when in empty space\r
-            return currEvent;\r
-        }\r
-\r
-        return null;\r
-    }\r
-\r
-    /**\r
-     * Pretty-print a method signature.\r
-     *\r
-     * @param sig\r
-     *            The original signature\r
-     * @return The pretty signature\r
-     */\r
-    static public String fixMethodSignature(String sig) {\r
-        int pos = sig.indexOf('(');\r
-        if (pos >= 0) {\r
-            String ret = sig.substring(0, pos);\r
-            sig = sig.substring(pos);\r
-            sig = sig + " " + ret; //$NON-NLS-1$\r
-        }\r
-        return sig;\r
-    }\r
-\r
-    /**\r
-     * Restore an original method signature from a pretty-printed one.\r
-     *\r
-     * @param sig\r
-     *            The pretty-printed signature\r
-     * @return The original method signature\r
-     */\r
-    static public String restoreMethodSignature(String sig) {\r
-        String ret = ""; //$NON-NLS-1$\r
-        int pos = sig.indexOf('(');\r
-        if (pos >= 0) {\r
-            ret = sig.substring(0, pos);\r
-            sig = sig.substring(pos + 1);\r
-        }\r
-        pos = sig.indexOf(')');\r
-        if (pos >= 0) {\r
-            sig = sig.substring(0, pos);\r
-        }\r
-        String args[] = sig.split(","); //$NON-NLS-1$\r
-        StringBuffer result = new StringBuffer("("); //$NON-NLS-1$\r
-        for (int i = 0; i < args.length; i++) {\r
-            String arg = args[i].trim();\r
-            if (arg.length() == 0 && args.length == 1) {\r
-                break;\r
-            }\r
-            result.append(getTypeSignature(arg));\r
-        }\r
-        result.append(")").append(getTypeSignature(ret)); //$NON-NLS-1$\r
-        return result.toString();\r
-    }\r
-\r
-    /**\r
-     * Get the mangled type information from an array of types.\r
-     *\r
-     * @param type\r
-     *            The types to convert. See method implementation for what it\r
-     *            expects.\r
-     * @return The mangled string of types\r
-     */\r
-    @SuppressWarnings("nls")\r
-    static public String getTypeSignature(String type) {\r
-        int dim = 0;\r
-        for (int j = 0; j < type.length(); j++) {\r
-            if (type.charAt(j) == '[') {\r
-                dim++;\r
-            }\r
-        }\r
-        int pos = type.indexOf('[');\r
-        if (pos >= 0) {\r
-            type = type.substring(0, pos);\r
-        }\r
-        StringBuffer sig = new StringBuffer(""); //$NON-NLS-1$\r
-        for (int j = 0; j < dim; j++)\r
-         {\r
-            sig.append("[");                 //$NON-NLS-1$\r
-        }\r
-        if (type.equals("boolean")) { //$NON-NLS-1$\r
-            sig.append('Z');\r
-        } else if (type.equals("byte")) { //$NON-NLS-1$\r
-            sig.append('B');\r
-        } else if (type.equals("char")) { //$NON-NLS-1$\r
-            sig.append('C');\r
-        } else if (type.equals("short")) { //$NON-NLS-1$\r
-            sig.append('S');\r
-        } else if (type.equals("int")) { //$NON-NLS-1$\r
-            sig.append('I');\r
-        } else if (type.equals("long")) { //$NON-NLS-1$\r
-            sig.append('J');\r
-        } else if (type.equals("float")) { //$NON-NLS-1$\r
-            sig.append('F');\r
-        } else if (type.equals("double")) { //$NON-NLS-1$\r
-            sig.append('D');\r
-        } else if (type.equals("void")) { //$NON-NLS-1$\r
-            sig.append('V');\r
-        }\r
-        else {\r
-            sig.append('L').append(type.replace('.', '/')).append(';');\r
-        }\r
-        return sig.toString();\r
-    }\r
-\r
-    /**\r
-     * Compare two doubles together.\r
-     *\r
-     * @param d1\r
-     *            First double\r
-     * @param d2\r
-     *            Second double\r
-     * @return 1 if they are different, and 0 if they are *exactly* the same.\r
-     *         Because of the way doubles are stored, it's possible for the\r
-     *         same number obtained in two different ways to actually look\r
-     *         different.\r
-     */\r
-    static public int compare(double d1, double d2) {\r
-        if (d1 > d2) {\r
-            return 1;\r
-        }\r
-        if (d1 < d2) {\r
-            return 1;\r
-        }\r
-        return 0;\r
-    }\r
-\r
-    /**\r
-     * Compare two character strings alphabetically. This is simply a wrapper\r
-     * around String.compareToIgnoreCase but that will handle cases where\r
-     * strings can be null\r
-     *\r
-     * @param s1\r
-     *            The first string\r
-     * @param s2\r
-     *            The second string\r
-     * @return A number below, equal, or greater than zero if the first string\r
-     *         is smaller, equal, or bigger (alphabetically) than the second\r
-     *         one.\r
-     */\r
-    static public int compare(String s1, String s2) {\r
-        if (s1 != null && s2 != null) {\r
-            return s1.compareToIgnoreCase(s2);\r
-        }\r
-        if (s1 != null) {\r
-            return 1;\r
-        }\r
-        if (s2 != null) {\r
-            return -1;\r
-        }\r
-        return 0;\r
-    }\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation, 2009, 2012 Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Intel Corporation - Initial API and implementation
+ *   Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *   Alvaro Sanchez-Leon - Udpated for TMF
+ *   Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * General utilities and definitions used by the time graph widget
+ *
+ * @version 1.0
+ * @author Alvaro Sanchez-Leon
+ * @author Patrick Tasse
+ */
+public class Utils {
+
+    /** Time format for dates and timestamp */
+    public enum TimeFormat {
+        /** Relative to the start of the trace */
+        RELATIVE,
+        /** Absolute timestamp (ie, relative to the Unix epoch) */
+        ABSOLUTE
+    }
+
+    static public final int IMG_THREAD_RUNNING = 0;
+    static public final int IMG_THREAD_SUSPENDED = 1;
+    static public final int IMG_THREAD_STOPPED = 2;
+    static public final int IMG_METHOD_RUNNING = 3;
+    static public final int IMG_METHOD = 4;
+    static public final int IMG_NUM = 5;
+
+    static public final Object[] _empty = new Object[0];
+
+    public static enum Resolution {
+        SECONDS, MILLISEC, MICROSEC, NANOSEC
+    }
+
+    static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
+    static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
+
+    static Rectangle clone(Rectangle source) {
+        return new Rectangle(source.x, source.y, source.width, source.height);
+    }
+
+    /**
+     * Initialize a Rectangle object to default values (all equal to 0)
+     *
+     * @param rect
+     *            The Rectangle to initialize
+     */
+    static public void init(Rectangle rect) {
+        rect.x = 0;
+        rect.y = 0;
+        rect.width = 0;
+        rect.height = 0;
+    }
+
+    /**
+     * Initialize a Rectangle object with all the given values
+     *
+     * @param rect
+     *            The Rectangle object to initialize
+     * @param x
+     *            The X coordinate
+     * @param y
+     *            The Y coordinate
+     * @param width
+     *            The width of the rectangle
+     * @param height
+     *            The height of the rectangle
+     */
+    static public void init(Rectangle rect, int x, int y, int width, int height) {
+        rect.x = x;
+        rect.y = y;
+        rect.width = width;
+        rect.height = height;
+    }
+
+    /**
+     * Initialize a Rectangle object to another existing Rectangle's values.
+     *
+     * @param rect
+     *            The Rectangle to initialize
+     * @param source
+     *            The reference Rectangle to copy
+     */
+    static public void init(Rectangle rect, Rectangle source) {
+        rect.x = source.x;
+        rect.y = source.y;
+        rect.width = source.width;
+        rect.height = source.height;
+    }
+
+    /**
+     * Reduce the size of a given rectangle by the given amounts.
+     *
+     * @param rect
+     *            The rectangle to modify
+     * @param x
+     *            The reduction in width
+     * @param y
+     *            The reduction in height
+     */
+    static public void deflate(Rectangle rect, int x, int y) {
+        rect.x += x;
+        rect.y += y;
+        rect.width -= x + x;
+        rect.height -= y + y;
+    }
+
+    /**
+     * Increase the size of a given rectangle by the given amounts.
+     *
+     * @param rect
+     *            The rectangle to modify
+     * @param x
+     *            The augmentation in width
+     * @param y
+     *            The augmentation in height
+     */
+    static public void inflate(Rectangle rect, int x, int y) {
+        rect.x -= x;
+        rect.y -= y;
+        rect.width += x + x;
+        rect.height += y + y;
+    }
+
+    static void dispose(Color col) {
+        if (null != col) {
+            col.dispose();
+        }
+    }
+
+    /**
+     * Get the resulting color from a mix of two existing ones for a given
+     * display.
+     *
+     * @param display
+     *            The display device (which might affect the color conversion)
+     * @param c1
+     *            The first color
+     * @param c2
+     *            The second color
+     * @param w1
+     *            The gamma level for color 1
+     * @param w2
+     *            The gamma level for color 2
+     * @return The resulting color
+     */
+    static public Color mixColors(Device display, Color c1, Color c2, int w1,
+            int w2) {
+        return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed())
+                / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen())
+                / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue())
+                / (w1 + w2));
+    }
+
+    /**
+     * Get the system color with the given ID.
+     *
+     * @param id
+     *            The color ID
+     * @return The resulting color
+     */
+    static public Color getSysColor(int id) {
+        Color col = Display.getCurrent().getSystemColor(id);
+        return new Color(col.getDevice(), col.getRGB());
+    }
+
+    /**
+     * Get the resulting color from a mix of two existing ones for the current
+     * display.
+     *
+     * @param col1
+     *            The first color
+     * @param col2
+     *            The second color
+     * @param w1
+     *            The gamma level for color 1
+     * @param w2
+     *            The gamma level for color 2
+     * @return The resulting color
+     */
+    static public Color mixColors(Color col1, Color col2, int w1, int w2) {
+        return mixColors(Display.getCurrent(), col1, col2, w1, w2);
+    }
+
+    /**
+     * Draw text in a rectangle.
+     *
+     * @param gc
+     *            The SWT GC object
+     * @param text
+     *            The text to draw
+     * @param rect
+     *            The rectangle object which is being drawn
+     * @param transp
+     *            Should we transpose the color
+     * @return The X coordinate where we have written
+     */
+    static public int drawText(GC gc, String text, Rectangle rect, boolean transp) {
+        Point size = gc.stringExtent(text);
+        gc.drawText(text, rect.x, rect.y, transp);
+        return size.x;
+    }
+
+    /**
+     * Draw text at a given location.
+     *
+     * @param gc
+     *            The SWT GC object
+     * @param text
+     *            The text to draw
+     * @param x
+     *            The X coordinate of the starting point
+     * @param y
+     *            the Y coordinate of the starting point
+     * @param transp
+     *            Should we transpose the color
+     * @return The X coordinate where we have written
+     */
+    static public int drawText(GC gc, String text, int x, int y, boolean transp) {
+        Point size = gc.stringExtent(text);
+        gc.drawText(text, x, y, transp);
+        return size.x;
+    }
+
+    /**
+     * Formats time in format: MM:SS:NNN
+     *
+     * @param time time
+     * @param format  0: MMMM:ss:nnnnnnnnn, 1: HH:MM:ss MMM.mmmm.nnn
+     * @param resolution the resolution
+     * @return the formatted time
+     */
+    static public String formatTime(long time, TimeFormat format, Resolution resolution) {
+        // if format is absolute (Calendar)
+        if (format == TimeFormat.ABSOLUTE) {
+            return formatTimeAbs(time, resolution);
+        }
+
+        StringBuffer str = new StringBuffer();
+        boolean neg = time < 0;
+        if (neg) {
+            time = -time;
+            str.append('-');
+        }
+
+        long sec = (long) (time * 1E-9);
+        // TODO: Expand to make it possible to select the minute, second, nanosecond format
+        //printing minutes is suppressed just sec and ns
+        // if (sec / 60 < 10)
+        // str.append('0');
+        // str.append(sec / 60);
+        // str.append(':');
+        // sec %= 60;
+        // if (sec < 10)
+        // str.append('0');
+        str.append(sec);
+        String ns = formatNs(time, resolution);
+        if (!ns.equals("")) { //$NON-NLS-1$
+            str.append('.');
+            str.append(ns);
+        }
+
+        return str.toString();
+    }
+
+    /**
+     * From input time in nanoseconds, convert to Date format YYYY-MM-dd
+     *
+     * @param absTime
+     *            The source time, in ns
+     * @return the formatted date
+     */
+    public static String formatDate(long absTime) {
+        String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));
+        return sdate;
+    }
+
+    /**
+     * Formats time in ns to Calendar format: HH:MM:SS MMM.mmm.nnn
+     *
+     * @param time
+     *            The source time, in ns
+     * @param res
+     *            The resolution to use
+     * @return the formatted time
+     */
+    static public String formatTimeAbs(long time, Resolution res) {
+        StringBuffer str = new StringBuffer();
+
+        // format time from nanoseconds to calendar time HH:MM:SS
+        String stime = stimeformat.format(new Date((long) (time * 1E-6)));
+        str.append(stime);
+        str.append('.');
+        // append the Milliseconds, MicroSeconds and NanoSeconds as specified in
+        // the Resolution
+        str.append(formatNs(time, res));
+        return str.toString();
+    }
+
+    /**
+     * Obtains the remainder fraction on unit Seconds of the entered value in
+     * nanoseconds. e.g. input: 1241207054171080214 ns The number of fraction
+     * seconds can be obtained by removing the last 9 digits: 1241207054 the
+     * fractional portion of seconds, expressed in ns is: 171080214
+     *
+     * @param time
+     *            The source time in ns
+     * @param res
+     *            The Resolution to use
+     * @return the formatted nanosec
+     */
+    public static String formatNs(long time, Resolution res) {
+        StringBuffer str = new StringBuffer();
+        boolean neg = time < 0;
+        if (neg) {
+            time = -time;
+        }
+
+        // The following approach could be used although performance
+        // decreases in half.
+        // String strVal = String.format("%09d", time);
+        // String tmp = strVal.substring(strVal.length() - 9);
+
+        long ns = time;
+        ns %= 1000000000;
+        if (ns < 10) {
+            str.append("00000000"); //$NON-NLS-1$
+        } else if (ns < 100) {
+            str.append("0000000"); //$NON-NLS-1$
+        } else if (ns < 1000) {
+            str.append("000000"); //$NON-NLS-1$
+        } else if (ns < 10000) {
+            str.append("00000"); //$NON-NLS-1$
+        } else if (ns < 100000) {
+            str.append("0000"); //$NON-NLS-1$
+        } else if (ns < 1000000) {
+            str.append("000"); //$NON-NLS-1$
+        } else if (ns < 10000000) {
+            str.append("00"); //$NON-NLS-1$
+        } else if (ns < 100000000) {
+            str.append("0"); //$NON-NLS-1$
+        }
+        str.append(ns);
+
+        if (res == Resolution.MILLISEC) {
+            return str.substring(0, 3);
+        } else if (res == Resolution.MICROSEC) {
+            return str.substring(0, 6);
+        } else if (res == Resolution.NANOSEC) {
+            return str.substring(0, 9);
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    /**
+     * FIXME Currently does nothing.
+     *
+     * @param opt
+     *            The option name
+     * @param def
+     *            The option value
+     * @param min
+     *            The minimal accepted value
+     * @param max
+     *            The maximal accepted value
+     * @return The value that was read
+     */
+    static public int loadIntOption(String opt, int def, int min, int max) {
+        // int val =
+        // TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);
+        // if (0 == val)
+        // val = def;
+        // if (val < min)
+        // val = min;
+        // if (val > max)
+        // val = max;
+        return def;
+    }
+
+    /**
+     * FIXME currently does nothing
+     *
+     * @param opt
+     *            The option name
+     * @param val
+     *            The option value
+     */
+    static public void saveIntOption(String opt, int val) {
+        // TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);
+    }
+
+    static ITimeEvent getFirstEvent(ITimeGraphEntry entry) {
+        if (null == entry || ! entry.hasTimeEvents()) {
+            return null;
+        }
+        Iterator<ITimeEvent> iterator = entry.getTimeEventsIterator();
+        if (iterator != null && iterator.hasNext()) {
+            return iterator.next();
+        }
+        return null;
+    }
+
+    /**
+     * N means: <list> <li>-1: Previous Event</li> <li>0: Current Event</li> <li>
+     * 1: Next Event</li> <li>2: Previous Event when located in a non Event Area
+     * </list>
+     *
+     * @param entry
+     * @param time
+     * @param n
+     * @return
+     */
+    static ITimeEvent findEvent(ITimeGraphEntry entry, long time, int n) {
+        if (null == entry || ! entry.hasTimeEvents()) {
+            return null;
+        }
+        Iterator<ITimeEvent> iterator = entry.getTimeEventsIterator();
+        if (iterator == null) {
+            return null;
+        }
+        ITimeEvent nextEvent = null;
+        ITimeEvent currEvent = null;
+        ITimeEvent prevEvent = null;
+
+        while (iterator.hasNext()) {
+            nextEvent = iterator.next();
+            long nextStartTime = nextEvent.getTime();
+
+            if (nextStartTime > time) {
+                break;
+            }
+
+            if (currEvent == null || currEvent.getTime() != nextStartTime) {
+                prevEvent = currEvent;
+                currEvent = nextEvent;
+            }
+        }
+
+        if (n == -1) { //previous
+            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {
+                return prevEvent;
+            }
+            return currEvent;
+        } else if (n == 0) { //current
+            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {
+                return currEvent;
+            }
+            return null;
+        } else if (n == 1) { //next
+            if (nextEvent != null && nextEvent.getTime() > time) {
+                return nextEvent;
+            }
+            return null;
+        } else if (n == 2) { //current or previous when in empty space
+            return currEvent;
+        }
+
+        return null;
+    }
+
+    /**
+     * Pretty-print a method signature.
+     *
+     * @param sig
+     *            The original signature
+     * @return The pretty signature
+     */
+    static public String fixMethodSignature(String sig) {
+        int pos = sig.indexOf('(');
+        if (pos >= 0) {
+            String ret = sig.substring(0, pos);
+            sig = sig.substring(pos);
+            sig = sig + " " + ret; //$NON-NLS-1$
+        }
+        return sig;
+    }
+
+    /**
+     * Restore an original method signature from a pretty-printed one.
+     *
+     * @param sig
+     *            The pretty-printed signature
+     * @return The original method signature
+     */
+    static public String restoreMethodSignature(String sig) {
+        String ret = ""; //$NON-NLS-1$
+        int pos = sig.indexOf('(');
+        if (pos >= 0) {
+            ret = sig.substring(0, pos);
+            sig = sig.substring(pos + 1);
+        }
+        pos = sig.indexOf(')');
+        if (pos >= 0) {
+            sig = sig.substring(0, pos);
+        }
+        String args[] = sig.split(","); //$NON-NLS-1$
+        StringBuffer result = new StringBuffer("("); //$NON-NLS-1$
+        for (int i = 0; i < args.length; i++) {
+            String arg = args[i].trim();
+            if (arg.length() == 0 && args.length == 1) {
+                break;
+            }
+            result.append(getTypeSignature(arg));
+        }
+        result.append(")").append(getTypeSignature(ret)); //$NON-NLS-1$
+        return result.toString();
+    }
+
+    /**
+     * Get the mangled type information from an array of types.
+     *
+     * @param type
+     *            The types to convert. See method implementation for what it
+     *            expects.
+     * @return The mangled string of types
+     */
+    @SuppressWarnings("nls")
+    static public String getTypeSignature(String type) {
+        int dim = 0;
+        for (int j = 0; j < type.length(); j++) {
+            if (type.charAt(j) == '[') {
+                dim++;
+            }
+        }
+        int pos = type.indexOf('[');
+        if (pos >= 0) {
+            type = type.substring(0, pos);
+        }
+        StringBuffer sig = new StringBuffer(""); //$NON-NLS-1$
+        for (int j = 0; j < dim; j++)
+         {
+            sig.append("[");                 //$NON-NLS-1$
+        }
+        if (type.equals("boolean")) { //$NON-NLS-1$
+            sig.append('Z');
+        } else if (type.equals("byte")) { //$NON-NLS-1$
+            sig.append('B');
+        } else if (type.equals("char")) { //$NON-NLS-1$
+            sig.append('C');
+        } else if (type.equals("short")) { //$NON-NLS-1$
+            sig.append('S');
+        } else if (type.equals("int")) { //$NON-NLS-1$
+            sig.append('I');
+        } else if (type.equals("long")) { //$NON-NLS-1$
+            sig.append('J');
+        } else if (type.equals("float")) { //$NON-NLS-1$
+            sig.append('F');
+        } else if (type.equals("double")) { //$NON-NLS-1$
+            sig.append('D');
+        } else if (type.equals("void")) { //$NON-NLS-1$
+            sig.append('V');
+        }
+        else {
+            sig.append('L').append(type.replace('.', '/')).append(';');
+        }
+        return sig.toString();
+    }
+
+    /**
+     * Compare two doubles together.
+     *
+     * @param d1
+     *            First double
+     * @param d2
+     *            Second double
+     * @return 1 if they are different, and 0 if they are *exactly* the same.
+     *         Because of the way doubles are stored, it's possible for the
+     *         same number obtained in two different ways to actually look
+     *         different.
+     */
+    static public int compare(double d1, double d2) {
+        if (d1 > d2) {
+            return 1;
+        }
+        if (d1 < d2) {
+            return 1;
+        }
+        return 0;
+    }
+
+    /**
+     * Compare two character strings alphabetically. This is simply a wrapper
+     * around String.compareToIgnoreCase but that will handle cases where
+     * strings can be null
+     *
+     * @param s1
+     *            The first string
+     * @param s2
+     *            The second string
+     * @return A number below, equal, or greater than zero if the first string
+     *         is smaller, equal, or bigger (alphabetically) than the second
+     *         one.
+     */
+    static public int compare(String s1, String s2) {
+        if (s1 != null && s2 != null) {
+            return s1.compareToIgnoreCase(s2);
+        }
+        if (s1 != null) {
+            return 1;
+        }
+        if (s2 != null) {
+            return -1;
+        }
+        return 0;
+    }
+}
index 67278e658d9d0a05fdbba3810e1d930c4725b30e..15baedd82b6c4be06c9ab9706260aa3969cd4207 100644 (file)
@@ -1,46 +1,46 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Matthew Khouzam - Extracted from TmfEventsView\r
- ******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.virtualtable;\r
-/**\r
- * ColumnData\r
- * @author Matthew Khouzam\r
- * @version 1.0\r
- *\r
- */\r
-public class ColumnData {\r
-    /**\r
-     * The title of the column\r
-     */\r
-    public final String header;\r
-    /**\r
-     * the width of the column in pixels\r
-     */\r
-    public final int    width;\r
-    /**\r
-     * the alignment of the column\r
-     */\r
-    public final int    alignment;\r
-\r
-    /**\r
-     * Constructor\r
-     * @param h header (title)\r
-     * @param w width\r
-     * @param a alignment\r
-     */\r
-    public ColumnData(String h, int w, int a) {\r
-        header = h;\r
-        width = w;\r
-        alignment = a;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Matthew Khouzam - Extracted from TmfEventsView
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.virtualtable;
+/**
+ * ColumnData
+ * @author Matthew Khouzam
+ * @version 1.0
+ *
+ */
+public class ColumnData {
+    /**
+     * The title of the column
+     */
+    public final String header;
+    /**
+     * the width of the column in pixels
+     */
+    public final int    width;
+    /**
+     * the alignment of the column
+     */
+    public final int    alignment;
+
+    /**
+     * Constructor
+     * @param h header (title)
+     * @param w width
+     * @param a alignment
+     */
+    public ColumnData(String h, int w, int a) {
+        header = h;
+        width = w;
+        alignment = a;
+    }
+
+}
This page took 1.197263 seconds and 5 git commands to generate.