# HG changeset patch # User Matti Laitinen # Date 1277290676 -10800 # Node ID 14dc2103a631ebb0330329683d60f69ceded0254 # Parent 15296fd0af4a3eb2da4158514071e584d281231e TraceAnalyser 1.0.5 diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.carbide.extensions.traceanalyser/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.carbide.extensions.traceanalyser/build.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,3 @@ +bin.includes = feature.xml,\ + license.txt,\ + license.htm diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.carbide.extensions.traceanalyser/feature.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.carbide.extensions.traceanalyser/feature.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,62 @@ + + + + + Trace Analyser tool is used for analysing OST trace data that is received from a device. + + + + Nokia Corporation and/or its subsidiary(-ies). All rights reserved. License: http://www.eclipse.org/legal/epl-v10.html. + + + + Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).All rights reserved. + This component and the accompanying materials are made available under the + terms of "Eclipse Public License v1.0" which accompanies this + distribution, and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Part of the graphics of the program are from Eclipse 3.1 platform + and CDT project in Eclipse community, which are made available under + the terms of the Eclipse Public License v1.0. + A copy of the EPL is provided at + http://www.eclipse.org/legal/epl-v10.html + + + + + + + + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.carbide.extensions.traceanalyser/license.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.carbide.extensions.traceanalyser/license.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,14 @@ +

Carbide.c++ Extensions - TraceViewer plug-in

+ +

License Information

+COPYRIGHTS
+Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).All rights reserved.
+This component and the accompanying materials are made available under the
+terms of "Eclipse Public License v1.0" which accompanies this
+distribution, and is available at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ +Part of the graphics of the program are from Eclipse 3.1 platform +and CDT project in Eclipse community, which are made available under +the terms of the Eclipse Public License v1.0. +A copy of the EPL is provided at +http://www.eclipse.org/legal/epl-v10.html \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/META-INF/MANIFEST.MF Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 1 +Bundle-Name: External Tool Help Template Plug-in +Bundle-SymbolicName: com.nokia.s60tools.traceanalyser.help;singleton=true +Bundle-Version: 1.0.3 +Bundle-Vendor: Nokia diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/about.html Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,25 @@ + + + + About + + + + +

About This Content

+ +

June, 2010

+ +

Copyright

+ +

Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights +reserved.
+License: http://www.eclipse.org/legal/epl-v10.html.

+ +


+

+ +

+ + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/book.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/book.css Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,183 @@ +/* + Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. + License: http://www.eclipse.org/legal/epl-v10.html +*/ + +/* Add whitespace around entire display to avoid crowding edges of view */ +/* 20070523-Removed top margin size to close gap between location breadcrumbs and page title */ +html { + margin: 2px 10px 10px 10px; + } + +/* Set default font to serif style, 12-pt and plain */ +body, p, table { + font-family: Verdana, Helvetica, Arial, sans-serif; + font-size: 13px; + font-weight: normal; +} + +/* Use sans-serif fonts for all title styles */ +h1, h2, h3, h4, h5, h6, strong, em { + font-family: Verdana, Helvetica, Arial, sans-serif; + color: #000000; + } + +h1 { font-size:20px } +h2 { font-size:18px } +h3 { font-size:16px } +h4 { font-size:14px } +h5 { font-size:13px } +h6 { font-size:12px } + +/* For headlines at the top of a view, add space */ +/* 20090224-changed green fade to gold header image */ +h1, h2, h3 { + background-image: url(html/images/gold_header.png); + background-repeat: no-repeat; + padding:10px 0px 10px 12px; + } + +li { + margin-bottom:8px; + margin-top:8px; + } + +/* Footer includes space and a gray line above the company logo */ +#footer { + padding-top:10px; + margin-top:20px; + border-top:1px solid #999; + font-family: Helvetica, sans-serif; + font-size: 11px; + color:#333; + } + +.listing { + font-family: "Courier New", Courier, mono; + color: #000000; + background-color: #FFFFCC; + margin: 5px 0px; + } + +.code, pre { + font-family: "Courier New", Courier, mono; + font-size: 13px; + color: #000000; + } + +.step { + /* background-color: #EEE; */ + /* margin: 10px 0px; */ + /* color: #111; */ + /* border-bottom:2px solid #EEE; */ + } + +.substep { + background-color: #EEE; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.table { + color: #999; + font-weight: bold; + padding-top: 5px; + } + +table { + border: solid #999 1px; + table-layout: auto; + font-size: 13px; + } + +td, th { + border: solid #999 1px; + padding: 5px; + vertical-align:top; + } + +/* 20070522-replaced gray with green background to match gradiant color for title */ +th { + background-color:#FFC550; /* background-color:#acd79b; + background-color:#999; + color:#FFF; */ + } + +div.ol.p { + margin-left: 3em; + } + +/* Make all ordered/unordered list items appear in bold gray */ +div ol > li, div ul > li { + font-weight:bold; + color: #333; + } + +div ol > p, div ul > p, div li > p { + font-weight:normal; + } + +/* Make all H4 and H5 items appear in bold gray against a light green background */ +div h5, div h4 { + padding:5px 0px 5px 12px; + background-color:#FDCB2F; + /* background-color: #EEE; */ + font-weight:bold; + color: #000000; + } + + +/* Notes stand out using a light top & bottom borders with dark gray text */ +p.note { + /* color: #03C; */ + /* background-color: #FFFF99; */ + color: #333; + padding: 5px; + margin-left: 1em; + margin-right: 1em; + border-top: solid #BBB thin; + border-bottom: solid #BBB thin; + } + + +/* Figure/Listing/Table titles are centered and gray */ +p.figure { + color: #333; + text-align: center; + font-weight: bold; + } + +/* highly visible red background and white text for things that need fixing before release */ +/* SHOULD NOT BE PRESENT IN RELEASED PRODUCTS */ +.fix { + background-color: red; + font-weight: bold; + color: white; + } + +.question { + font-style:italic; + font-weight:bold; + color: #555; + } + +.titleSmall { + font-family: Helvetica, sans-serif; + font-size: 11px; + } + + +.plain { + font-family: Helvetica, sans-serif; + font-size: 12px; + font-style: normal; + line-height: normal; + font-weight: normal; + font-variant: normal; + color: #000000; + text-decoration: none; + } + +a:link { color: #0033CC } +a:visited { color: #555555 } +a:hover { color: #0033CC } diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/build.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,8 @@ +bin.includes = META-INF/,\ + html/,\ + plugin.xml,\ + book.css +src.includes = html/,\ + META-INF/,\ + plugin.xml,\ + book.css diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/cheatsheet/getStarted_ta_cs.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/cheatsheet/getStarted_ta_cs.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,140 @@ + + + + + + + + +This tutorial shows you the steps for creating tracing rules in the TraceAnalyser tool. +

+Prerequisites +

+* TraceViewer and TraceBuilder applications are present in your Carbide.c++ environment. +

+* (Optional) TraceSwitch SIS is installed on your device. +

+You can obtain TraceSwitch from the S60 RnD SDK, under the RnD Tools folder. TraceSwitch, together with the ToolsStarter SIS, support the USB connection method by default. You only need to plug in the device to start receiving traces. +
+
+ + +Open or create a new project in Carbide.c++. + + + + +Adding Open System Traces (OST) means adding "tags" to your application's source code, to those places that you want to monitor. +
+
+The easiest way to do this is by using the TraceBuilder application: Carbide > TraceBuilder. +
+
+For example, to monitor timings in a camera application, you could add the first trace to capture the key press for taking a picture, and another where the taken picture is shown to the user. +
+
+The corresponding rule to be created in TraceAnalyser might then state that these actions must occur within 5 seconds. +
+
+ + + To use Open System Trace (OST) traces, you must include the "OpenSystemTrace.h" header file from the development environment. +

+
+
+ + + After compiling your project, you should have two files: +

+1: A SIS file of your application that you can install into the device by using USB. +

+2: An XML format dictionary file that is needed for activating and decoding traces in TraceViewer. +

+The file is generated into the following directory: +

+[SDK root]\epoc32\include\internal\symbiantraces\dictionary. + +
+
+ + + To start receiving traces on the TraceViewer application, define connection settings between the device and your PC. +

+Start the TraceViewer tool from Carbide > TraceViewer. +

+On the toolbar, click the small arrow and from the drop-down list, select Connection Settings. +

+
+
+ + + Trace activation is a way of generating specific trace data that is relevant for your components. This reduces the amount of traces listed on the TraceViewer user interface. +

+Start the TraceViewer tool from Carbide > TraceViewer. +

+Load the dictionary file (.xml) that contains the necessary component and group information. +

+Activate the components and groups you want to use. +

+For more information, see TraceViewer Help. +
+
+ + + Start TraceAnalyser from Carbide > TraceAnalyser. +

+Create either Timing or Parameter rule type for the events you want to monitor. +

+An example of the rule could be a statement like this: "Taking a picture should not take longer than 5 seconds." +
+
+ + + In TraceViewer, start receiving traces. +

+Run the SIS file of your application on the device. +
+
+ + + All executed trace rules (both passed and failed ones) are listed on the TraceAnalyser main view. +

+If some of them fail during execution (for example, an operation execution takes longer than defined in the rule), the TraceAnalyser icon will quickly flash to indicate that a rule violation has occurred. +

+To view the failed cases, select the Fail Log tab. +

+To view the traces that caused the failure, double-click a rule on the view. TraceViewer opens and scrolls to the traces. +

+Double-click the trace to jump to the codeline that caused the failure. +
+
+ + + + To view the traces that caused the failure, double-click a rule on the TraceAnalyser Fail Log. +

+TraceViewer opens and scrolls to the trace. +

+In TraceViewer, double-click the trace to jump to the codeline that caused the failure. +

+Once you have identified the problem in the source code, try to fix it and run the rule again. +
+
+ +
diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/contexts.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/contexts.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + In TraceAnalyser, you can create rules to supervise the time consumption of an application and detect timing violations. The main view shows both passed and failed rules. + + + + + + If a tracing rule fails (for example, the interval between operations is longer than defined), you can view more information about the violation on the Fail Log tab. + + + + + TraceAnalyser's Rule Editor dialog contains general fields for all rule types, and some specific fields for timing and parameter rules separately. + + + + + + In the Trace Selection dialog, you can view the trace dictionaries that are loaded in TraceViewer application, and select the traces you want to use. + + + + + TraceAnalyser history view shows you information on the rule's performance over time. + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/gs_index.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/gs_index.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,19 @@ + + + + + +Getting started + + + +

Getting started

+

The following topics give you information on how to get started with this tool:

+ + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/images/dg_mainview.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/images/dg_mainview.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/traceanalyser_basic_walkthrough.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/traceanalyser_basic_walkthrough.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,48 @@ + + + + +TraceAnalyser basic walk-through + +

TraceAnalyser basic walk-through

Before you start

+Setting up TraceAnalyser requires the following tracing tools:

The following steps are needed for using this tool:

    +
  1. Open or create a project in Carbide.c++.
  2. +
  3. To add OST traces to the source code, start the TraceBuilder tool from +Carbide > TraceBuilder.

    For more instructions, see the topic Adding +traces to the source code in TraceBuilder Help.

  4. +
  5. Set your project's include paths and compile the application. For instructions, +see Setting project include paths and compiling in TraceBuilder Help.

    +Note: Compilation uses TraceCompiler that generates the needed headers. +After compilation, you should have two files:

      +
    • a SIS file of your tool that you can now install into the device.
    • +
    • an XML format dictionary file that is needed for activating and decoding +traces in TraceViewer. It is generated into the following directory: [SDK +root]\epoc32\include\internal\symbiantraces\dictionary.
    • +
  6. +
  7. In TraceViewer, also define the settings for connecting your PC to the +device. The options are USB or eXtended Trace Interface (XTI).

    See +Setting TraceViewer preferences in TraceViewer Help.

    Tip: If +you have TraceSwitch enabled in the device, the USB connection is supported +by default and you only need to plug in the device to start receiving traces. +

  8. +
  9. To activate and decode traces, start the TraceViewer tool from Carbide +> TraceViewer, and activate the dictionary file there.

    For instructions, +see Trace activation in TraceViewer Help.

  10. +
  11. In TraceAnalyser, create the rules for issues you want to monitor: timings +or parameters.

    See example scenarios in TraceAnalyser overview and +step-by-step instructions in Creating +tracing rules.

  12. +
  13. Transfer your application's SIS file to the device and run it.

    If some +tracing rules fail during execution, they are listed on the TraceAnalyser's +Fail Log tab.

  14. +
  15. To analyse the failed rule in more detail, double-click it to view it +in the TraceViewer application. TraceViewer will show the codeline that caused +the failure.
  16. +
diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/traceanalyser_overview.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/gettingstarted/traceanalyser_overview.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,36 @@ + + + + +TraceAnalyser overview + +

TraceAnalyser overview

TraceAnalyser is a tool that enables +you to supervise the target application's time consumption during an operation, +or supervise parameters in Open System Trace (OST) traces.

With this +tool, you can create a set of rules that define:

TraceAnalyser lists both passed and failed events to the main view, +along with other information such as the pass rate. See the following example: +

Sample view of data filled in on the tabbed view.

+If a rule fails (for example, the interval between operations is longer than +defined), you can view more information about the violation on the Fail +Log tab.

You can also view history graphs of the defined rules, +to see how the performance of your application has changed over time.

Example: Analysing timings in a camera application

+When developing a camera application, you might want to define the following +kind of rule:

“Taking a picture should not take longer than +5 seconds.”

To monitor this programmatically, you can instrument +your code so that OST trace is placed to capture the key press for taking +a picture, and another where the taken picture is shown to the user. The corresponding +rule would then state that these actions must occur within 5 seconds.

+Related Tasks
diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/about_cpp.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/about_cpp.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/background_carbide.jpg Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/background_carbide.jpg has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/brandmark_cpp.gif Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/brandmark_cpp.gif has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/gold_header.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/gold_header.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/green_fade_left_68_165_28.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/images/green_fade_left_68_165_28.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/index.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/index.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/overviewTraceAnalyserExtContent.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/overviewTraceAnalyserExtContent.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,28 @@ + + + + + + + + + + + Learn about Trace Analyser and what it can do to improve your development efforts. + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser.css Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,2 @@ +a#traceanalyser img { background-image : url(traceanalyser.gif); } +a#traceanalyser:hover img { background-image : url(traceanalyser_hov.gif); } diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser.gif Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser.gif has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,9 @@ + +overview.traceanalyser = html/intro/traceanalyser.gif +overview.traceanalyser:hover = html/intro/traceanalyser_hov.gif + +whatsnew.traceanalyser = html/intro/traceanalyser.gif +whatsnew.traceanalyser:hover = html/intro/traceanalyser_hov.gif + +tutorials.traceanalyser = html/intro/traceanalyser.gif +tutorials.traceanalyser:hover = html/intro/traceanalyser_hov.gif diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser_hov.gif Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/traceanalyser_hov.gif has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/tutorialsTraceAnalyserExtContent.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/tutorialsTraceAnalyserExtContent.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,27 @@ + + + + + + + + + + + Start analysing traces by following step-by-step instructions. + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/whatsnewTraceAnalyserExtContent.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/intro/whatsnewTraceAnalyserExtContent.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,28 @@ + + + + + + + + + + + Learn about what's new in Trace Analyser for this release. + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/legal.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/legal.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,38 @@ + + + + + License Information + + + + +

License Information

+ +
COPYRIGHTS
+ +

Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights +reserved. This component and the accompanying materials are made available +under the terms of "Eclipse Public License v1.0" which accompanies this +distribution and is available at the URL http://www.eclipse.org/legal/epl-v10.html.

+ +

Initial Contributors:
+Nokia Corporation - initial contribution

+ +
NOTICES
+ +

Part of the graphics of the program are from Eclipse 3.1 platform and CDT +project in Eclipse community, which are made available under the terms of the +Eclipse Public License v1.0.

+ +

A copy of the EPL is provided at http://www.eclipse.org/legal/epl-v10.html +

+ + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/release_notes.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/release_notes.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,134 @@ + + + + + Release Notes + + + + +

Release Notes

+ +

TraceAnalyser – Version 1.0.5

+ +

Released June 20, 2010

+ + +

Product description

+ +

TraceAnalyser is a tool that enables you to supervise the target +application's time consumption during an operation, or supervise parameters in +Open System Trace (OST) traces.

+ +

The tool can be started by selecting the Carbide > TraceAnalyser +menu item.

+ +

Main features

+ +

With this tool, you can create a set of rules that define:

+ + +

TraceAnalyser lists both passed and failed events to the main view, along +with other information such as the pass rate.

+ +

What's new

+ + +

Installation notes

+ + +

System requirements

+ +

Basic requirements:

+ + +

Additional requirements:

+ + +

Compatibility issues

+ + +

Known issues

+ + +

Version history

+ +
Version 1.0.4 – 8th December 2009
+ +

Bug fixes related to Help

+ +
Version 1.0.3 – 8th December 2009
+ +

Bug fixes related to usage of TraceViewer API. Scrolled traces are now +filtered out from analysed traces.

+ +
Version 1.0.2 – 6th October 2009
+ +

Bug fixes related tousage of TraceViewer API. Traces received from +TraceViewer are not anymore cloned.

+ +
Version 1.0.1 – 19th August 2009
+ +

Bug fixes in help links.

+ +
Version 1.0.0 – 25th June 2009
+ +

The first version.

+ + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/creating_rules.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/creating_rules.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,85 @@ + + + + + +Creating tracing rules + +

Creating tracing rules

Before you start

Before you +can create tracing rules, check that you have:

See +TraceAnalyser basic walk-through for the complete steps.

To create +tracing rules, do the following:

    +
  1. Start TraceAnalyser from the Carbide > TraceAnalyser menu item. +
  2. +
  3. Click Create new rule.

    The Edit Rule dialog is displayed. +

  4. +
  5. From the Rule Type list box, select which kind of rule you are +creating:
      +
    • Timing rule for detecting if an operation can be executed within +a specified time limit.
    • +
    • Trace parameter rule for detecting if parameters are beyond a desireable +value range.
    • +
  6. +
  7. In the Rule Name field, type in a name for the rule.

    For example: +Camera Test.

  8. +
  9. (Optional) In the Description field, type in a free-form description +of what the rule is about.

    For example, for a timing rule: Test that +the Camera application is able to capture a picture within 1000ms time limit. +

  10. +
  11. Configure the rule-specific settings.

    For instructions, see either To define timing rules or To define +parameter rules below.

  12. +
  13. Connect your PC to the device by using the connection settings defined +in TraceViewer (USB or XTI).
  14. +
  15. In TraceViewer, activate the traces you want to receive.
  16. +
  17. Run your application on the device.

    During execution, TraceAnalyser +lists both passed and failed events to the main view, along with other information +such as the pass rate. See the following example:

  18. +

After the rules have been executed, you can do either of the following: +

To define timing rules:

    +
  1. To select which trace should be monitored as the first part of this rule +(Trace A), click Select Trace.

    The Select Trace for Rule dialog +is opened, showing the trace dictionaries that you loaded in TraceViewer earlier. +

  2. +
  3. Select the traces you want to use and click OK.
  4. +
  5. Repeat the above steps for Trace B.
  6. +
  7. In the Time Limit fields, enter the range the values in milliseconds +for Trace A and Trace B.
      +
    • For Time Limit A, the value means that Trace B must arrive after +this.
    • +
    • For Time Limit B, the value means that Trace B must arrive before +this.
    • +

    The following figure shows an example of how a tracing rule could +look like:

    Sample of the Edit Rule dialog with the sample values filled in.

  8. +
  9. To finish, click OK.
  10. +

To define parameter rules:

    +
  1. To select which trace should be monitored as the first part of this rule, +click Select Trace.

    The Select Trace for Rule dialog is opened, +showing the trace dictionaries that you loaded in TraceViewer earlier.

  2. +
  3. Select the traces you want to use and click OK.
  4. +
  5. From the Trace parameter should be list box, select the behavior +what you want the parameter and values to be:
      +
    • Greater than/Equal to
    • +
    • Less than/Equal to
    • +
    • Between
    • +
    • Equal to
    • +

    The following figure shows an example of how a tracing rule could +look like:

    Sample of the UI showing values for parameter rule type

  6. +
  7. To finish, click OK.
  8. +
Related tasks
+ diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/ParameterRuleDialog.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/ParameterRuleDialog.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/Thumbs.db Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/Thumbs.db has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/cb_activate.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/cb_activate.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/default_mainview.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/default_mainview.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_EditRule.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_EditRule.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_FailLog.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_FailLog.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_mainview.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_mainview.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_timingRule.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/dg_timingRule.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/tab_Graph.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/images/tab_Graph.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/modifying_rules.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/modifying_rules.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,31 @@ + + + + + + +Modifying rules + +

Modifying rules

To modify the tracing rules or counters, +do any of the following:

Related tasks
+ diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/tasks.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/tasks.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,26 @@ + + + + + +Configuring tracing rules with TraceAnalyser + +

Configuring tracing rules with TraceAnalyser

TraceAnalyser +is a tool that enables you to supervise and analyse the target application's +time consumption during an operation, or supervise parameters in Open System +Trace (OST) traces.

With this tool, you can create a set of rules that +define the order and maximum delay between two traces, or a value range that +must be met. Whenever some rule fails (for example, an operation takes longer +than what was required in the rule), a failure log is written to TraceAnalyser's +interface. You can also view history graphs of the defined rules.

+To see an overview of all the steps, start by reading +TraceAnalyser basic walk-through.

Related tasks
+ + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/viewing_failed_cases.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/viewing_failed_cases.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,25 @@ + + + + +Viewing the log of failed rules + +

Viewing the log of failed rules

If some of the rules fail +during execution, the TraceAnalyser icon will quickly flash to indicate that +a rule violation has occurred.

To view the failed cases:

    +
  1. Select the Fail Log tab.

    The failed rules are listed on the +view, with a timestamp of the operation, the name of the rule, scope of the +violation and the limit.

    See the following example:

  2. +
  3. To view the traces that caused the failure, double-click a rule on the +view.

    The TraceViewer application opens, and scrolls to the traces.

  4. +
  5. In TraceViewer, double-click the trace to jump directly to the codeline +that caused the failure.
  6. +
  7. Check the code, fix it as applicable and run the rule again.
  8. +

At any time, you can reset the view by clicking Clear Fail Log +.

Related tasks
. + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/viewing_the_history.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tasks/viewing_the_history.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,27 @@ + + + + +Viewing the rule history + +

Viewing the rule history

The rule Graph tab shows all detected +rule events for one rule. In this view, you can inspect how the +performance of your application has evolved over time.

+

To view the graph:

+

This view helps you track down reasons for your application's performance problems. +From the graph, you can see when the performance of the application +has deteriorated significantly. The graph is updated in real time, meaning +that if it is open while the corresponding rule event is received, the graph is +updated immediately.

Related tasks
+ diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tool.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/tool.htm Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,49 @@ + + + + + Carbide.c++ User Guide + + + + + +

 

+ + + + + + + + + + + +

+ +

 

+ +

 

+ +

 

+ +

+ +

Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All + rights reserved.
+ License: http://www.eclipse.org/legal/epl-v10.html.

+ +

+

TraceAnalyser User Guide

+ +

Version 1.0.5; June, 2010

+
+ + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/toolTOC.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/html/toolTOC.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.help/plugin.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/.classpath Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,7 @@ + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/.settings/org.eclipse.jdt.core.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/.settings/org.eclipse.jdt.core.prefs Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,7 @@ +#Thu Apr 23 12:23:21 EEST 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/META-INF/MANIFEST.MF Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Parameter Rule Type for Trace Analyser Plug-In +Bundle-SymbolicName: com.nokia.s60tools.traceanalyser.parameterrule;singleton:=true +Bundle-Version: 1.0.5 +Bundle-Vendor: Nokia +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: com.nokia.s60tools.traceanalyser;bundle-version="1.0.0", + org.eclipse.core.runtime;bundle-version="3.4.0", + org.eclipse.ui;bundle-version="3.4.1", + com.nokia.traceviewer;bundle-version="2.0.27" +Bundle-ActivationPolicy: lazy +Bundle-Activator: com.nokia.s60tools.traceanalyser.parameterrule.plugin.TraceAnalyserParameterRulePlugin +Export-Package: com.nokia.s60tools.traceanalyser.parameterrule.rule;x-friends:="com.nokia.s60tools.traceanalyser.tests" diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/build.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/plugin.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,13 @@ + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/src/com/nokia/s60tools/traceanalyser/parameterrule/plugin/TraceAnalyserParameterRulePlugin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/src/com/nokia/s60tools/traceanalyser/parameterrule/plugin/TraceAnalyserParameterRulePlugin.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.parameterrule.plugin; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class TraceAnalyserParameterRulePlugin extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.nokia.s60tools.traceanalyser.parameterrule"; + + // The shared instance + private static TraceAnalyserParameterRulePlugin plugin; + + /** + * TraceAnalyserParameterRulePlugin. + * The constructor + */ + public TraceAnalyserParameterRulePlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * getDefault. + * Returns the shared instance + * @return the shared instance + */ + public static TraceAnalyserParameterRulePlugin getDefault() { + return plugin; + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/src/com/nokia/s60tools/traceanalyser/parameterrule/rule/ParameterRule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/src/com/nokia/s60tools/traceanalyser/parameterrule/rule/ParameterRule.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,470 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.parameterrule.rule; + + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; + +import com.nokia.s60tools.traceanalyser.export.GeneralMethods; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.export.TraceInfo; +import com.nokia.s60tools.traceanalyser.export.RuleEvent.RuleStatus; +import com.nokia.s60tools.traceanalyser.parameterrule.rule.ParameterRuleType.ParameterType; +import com.nokia.traceviewer.engine.TraceProperties; + +public class ParameterRule extends TraceAnalyserRule { + + /* Strings that are searched from xml-file */ + + public static final String XML_TRACE = "ParameterTrace"; + public static final String XML_TYPE = "Type"; + public static final String XML_LIMITA = "LimitA"; + public static final String XML_LIMITB = "LimitB"; + + private ParameterType parameterType; + + private TraceInfo traceItem; + + private int LimitA; + private int LimitB; + + private String workingDirectory; + + /** + * ParameterRule. + * Constructor + */ + public ParameterRule() { + super("Parameter Rule"); + traceItem = new TraceInfo(); + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#writeXML() + */ + public boolean writeXML(){ + + if(rulePath == null){ + // get directory for rule. + + String path = getNextFreeDirectory(workingDirectory); + if(path != null){ + rulePath = path; + } + else{ + return false; + } + } + rulePath = addSlashToEnd(rulePath); + if(super.writeBasicInfoIntoFile()){ + String fileName = rulePath + FILENAME_ADDITIONAL_INFO; + try { + // Create file + FileWriter fstream = new FileWriter(fileName); + BufferedWriter output = new BufferedWriter(fstream); + output.write(this.getAdditionalInfoXmlString()); + // Close the output stream + output.close(); + return true; + } catch (Exception e) {// Catch exception if any + return false; + } + } + return false; + + } + + /** + * readXML. + * Reads xml-file and formats this rule's definitions. NOTE rulePath needs to be defined before calling this function. + */ + public boolean readXML(){ + if(super.readXML()){ + + if(rulePath != null){ + String additionalInfoPath = TraceAnalyserRule.addSlashToEnd(rulePath) + FILENAME_ADDITIONAL_INFO; + File additionalInfoFile = new File(additionalInfoPath); + boolean errorOccured = false; + if (additionalInfoFile.exists()) { + try { + // Create buffered reader. + BufferedReader input = new BufferedReader(new FileReader(additionalInfoFile)); + try { + if(!readFile(input)){ + errorOccured = true; + } + } + catch(Exception e){ + errorOccured = true; + } + finally { + input.close(); + } + } catch (Exception e) { + errorOccured = true; + } + } + if(errorOccured){ + return false; + } + else{ + return true; + } + } + } + return false; + } + + + /** + * readFile + * Reads xml file given as parameter. + * @param input bufferedReader opened to inputFile. + * @throws IOException if file operations fails. + * @return true if file was read successfully + */ + private boolean readFile(BufferedReader input) throws IOException{ + String line = null; + + // This while loop searches xml tags from file. When tag is found information is saved and + // new searchPhrase is updated. Tags are searched in order where they should be. + + if(!traceItem.readXMLBuffer(input, XML_TRACE)){ + return false; + } + + + String searchPhrase = XML_TYPE; + while ((line = input.readLine()) != null) { + if (line.contains(searchPhrase)) { + if(searchPhrase.equals(XML_TYPE)){ + String type = GeneralMethods.getTextBetweenQuotes(line); + if(!setParameterString(type)){ + return false; + } + searchPhrase = XML_LIMITA; + + } + + else if(searchPhrase.equals(XML_LIMITA)){ + LimitA = Integer.parseInt(GeneralMethods.getTextBetweenQuotes(line)); + searchPhrase = XML_LIMITB; + + } + else if(searchPhrase.equals(XML_LIMITB)){ + LimitB = Integer.parseInt(GeneralMethods.getTextBetweenQuotes(line)); + return true; + } + + } + + } + return false; + } + + /** + * getAdditionalInfoXmlString. + * @return XML string that can be written to file. + */ + private String getAdditionalInfoXmlString(){ + String xml = ""; + xml += "\n"; + xml += " \n"; + xml += traceItem.getXMLString(XML_TRACE,8); + xml += " \n"; + xml += " \n"; + xml += getLimitationInfoXmlString(8); + xml += " \n"; + xml += "\n"; + return xml; + } + + + /** + * getTimingInfoXmlString. + * @param indent indent that is used. + * @return xml-string that can be written to file. + */ + private String getLimitationInfoXmlString(int indent){ + String xml = ""; + String indentString = this.getIndentString(indent); + + xml += indentString + "\n"; + + xml += indentString + "<" + XML_LIMITA + "=\""; + xml += Integer.toString(LimitA); + xml += "\">\n"; + + xml += indentString + "<" + XML_LIMITB+ "=\""; + xml += Integer.toString(LimitB); + xml += "\">\n"; + + + return xml; + } + + + /** + * getParameterString. + * Returns parameter String + * @return Parameter type. + */ + public String getParameterString(){ + if(parameterType == ParameterType.BETWEEN){ + return ParameterRuleType.TYPE_COMBO_TEXTS_BETWEEN; + } + else if(parameterType == ParameterType.EQUAL){ + return ParameterRuleType.TYPE_COMBO_TEXTS_EQUAL_TO; + } + else if(parameterType == ParameterType.GREATER){ + return ParameterRuleType.TYPE_COMBO_TEXTS_GREATER_THAN; + } + else if(parameterType == ParameterType.LESS){ + return ParameterRuleType.TYPE_COMBO_TEXTS_LESS_THAN; + } + else{ + return null; + } + } + + /** + * setParameterString. + * @param type Sets parameter string + * @return true if string was equal to some rule type. + */ + public boolean setParameterString(String type){ + if(type.equals(ParameterRuleType.TYPE_COMBO_TEXTS_BETWEEN)){ + this.parameterType = ParameterType.BETWEEN; + return true; + } + else if(type.equals(ParameterRuleType.TYPE_COMBO_TEXTS_EQUAL_TO)){ + this.parameterType = ParameterType.EQUAL; + return true; + } + else if(type.equals(ParameterRuleType.TYPE_COMBO_TEXTS_GREATER_THAN)){ + this.parameterType = ParameterType.GREATER; + return true; + } + else if(type.equals(ParameterRuleType.TYPE_COMBO_TEXTS_LESS_THAN)){ + this.parameterType = ParameterType.LESS; + return true; + } + else{ + return false; + } + } + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#checkIfRuleFails(com.nokia.traceviewer.engine.TraceProperties) + */ + public RuleEvent checkRuleStatus(TraceProperties traceProperties) { + + + + //get properties of trace: + ArrayList properties = traceProperties.parameters; + if(properties.size() == 0){ + return new RuleEvent(RuleStatus.NONE); + } + + if(TraceInfo.compareTraces(traceProperties.information, traceItem.getIdNumbers())){ + //TODO trycatch + int parameter = Integer.parseInt(properties.get(0)); + + int violation = 0; + RuleStatus status = RuleStatus.PASS; + int limit = 0; + + if(parameterType == ParameterType.LESS){ + if( !(parameter <= LimitA) ){ + status = RuleStatus.FAIL; + violation = parameter - LimitA; + limit = LimitA; + } + else{ + status = RuleStatus.PASS; + } + + + } + else if(parameterType == ParameterType.EQUAL){ + if(parameter != LimitA ){ + status = RuleStatus.FAIL; + violation = parameter - LimitA; + limit = LimitA; + } + else{ + status = RuleStatus.PASS; + } + } + else if(parameterType == ParameterType.GREATER){ + if( !(parameter >= LimitA) ){ + status = RuleStatus.FAIL; + violation = parameter - LimitA; + limit = LimitA; + } + else{ + status = RuleStatus.PASS; + } + + } + + else if(parameterType == ParameterType.BETWEEN){ + if(parameter < LimitA){ + status = RuleStatus.FAIL; + violation = parameter - LimitA; + limit = LimitA; + + } + else if(parameter > LimitB){ + status = RuleStatus.FAIL; + violation = parameter - LimitB; + limit = LimitB; + } + else{ + status = RuleStatus.PASS; + + } + + } + return new RuleEvent( status, parameter, limit, violation, name, "", + new Date(), new int[]{traceProperties.traceNumber} ); + + + } + return new RuleEvent(RuleStatus.NONE); + + + + } + + + + + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#getUnit() + */ + public String getUnit(){ + return ""; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#equals(com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule) + */ + public boolean equals(TraceAnalyserRule rule) { + ParameterRule parameterRule = (ParameterRule) rule; + if (parameterRule.getName().equals(this.name) + && parameterRule.getDescription().equals(this.description) + && parameterRule.getLimitA() == this.LimitA + && parameterRule.getTraceItem().equals(this.traceItem)) { + if (parameterRule.getParameterType() == ParameterType.BETWEEN && + parameterRule.getLimitB() != this.LimitB ){ + return false; + } + return true; + } + else { + return false; + } + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#getLimits() + */ + public int[] getLimits() { + if(parameterType == ParameterType.BETWEEN){ + return new int[]{LimitA, LimitB}; + } + else{ + return new int[]{LimitA}; + + } + } + + /* Getters and setters for member variables. */ + + + public String getWorkingDirectory() { + return workingDirectory; + } + + public void setWorkingDirectory(String workingDirectory) { + this.workingDirectory = workingDirectory; + } + + public TraceInfo getTraceItem() { + return traceItem; + } + + public void setTraceItem(TraceInfo traceItem) { + this.traceItem = traceItem; + } + + + + public int getLimitA() { + return LimitA; + } + + public void setLimitA(int limitA) { + LimitA = limitA; + } + + public int getLimitB() { + return LimitB; + } + + public void setLimitB(int limitB) { + LimitB = limitB; + } + + public ParameterType getParameterType() { + return parameterType; + } + + public void setParameterType(ParameterType parameterType) { + this.parameterType = parameterType; + } + + + + + + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/src/com/nokia/s60tools/traceanalyser/parameterrule/rule/ParameterRuleType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.parameterrule/src/com/nokia/s60tools/traceanalyser/parameterrule/rule/ParameterRuleType.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,466 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.parameterrule.rule; + +import java.io.File; +import java.util.ArrayList; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType; +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleTypeListener; +import com.nokia.s60tools.traceanalyser.export.ITraceSelectionCompositeListener; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.export.TraceInfo; +import com.nokia.s60tools.traceanalyser.export.TraceSelectionComposite; +import com.nokia.s60tools.traceanalyser.parameterrule.plugin.TraceAnalyserParameterRulePlugin; +import com.nokia.traceviewer.engine.TraceInformation; + +/** + * class Parameter Rule. + * "Parameter Rule"-rule type for Trace Analyser + */ + +public class ParameterRuleType implements ITraceAnalyserRuleType, ITraceSelectionCompositeListener, SelectionListener, ModifyListener{ + + public static enum ParameterType{GREATER, LESS, BETWEEN, EQUAL}; + + public static final String TYPE_COMBO_TEXTS_GREATER_THAN = "Greater than/Equal to"; + public static final String TYPE_COMBO_TEXTS_LESS_THAN = "Less than/Equal to"; + public static final String TYPE_COMBO_TEXTS_BETWEEN = "Between"; + public static final String TYPE_COMBO_TEXTS_EQUAL_TO = "Equal to"; + + /* UI components */ + private GridData gridDataComposite; + private Composite compositeParameterRule; + private Combo comboParameterType; + private Text textParameterValue1; + private Text textParameterValue2; + private GridData gridDataTextRuleName2; + private GridData gridDataLabelAndText; + private Label labelAndText; + + /* Trace Selection composites */ + TraceSelectionComposite traceSelectionComposite; + + /* Edit rule-window */ + ITraceAnalyserRuleTypeListener listener; + + + /** + * TimingRule. + * constructor + */ + public ParameterRuleType(){ + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRule#createUIComponents(org.eclipse.swt.widgets.Composite) + */ + public void createUIComponents(Composite composite, ITraceAnalyserRuleTypeListener listener) { + + this.listener = listener; + + // Create composite for rule + compositeParameterRule = new Composite(composite, SWT.NONE); + GridLayout layoutcompositeParameterRule = new GridLayout(); + layoutcompositeParameterRule.numColumns = 1; + compositeParameterRule.setLayout(layoutcompositeParameterRule); + gridDataComposite = new GridData(GridData.FILL_HORIZONTAL); + compositeParameterRule.setLayoutData(gridDataComposite); + + // create trace selection components. + traceSelectionComposite = new TraceSelectionComposite(compositeParameterRule, "Trace:", this); + + // create composite for parameters + Composite compositeParameters = new Composite(compositeParameterRule, SWT.NONE); + GridLayout layoutcompositeParameters = new GridLayout(); + layoutcompositeParameters.numColumns = 4; + compositeParameters.setLayout(layoutcompositeParameters); + GridData gridDataCompositeParameters = new GridData(GridData.FILL_HORIZONTAL); + compositeParameters.setLayoutData(gridDataCompositeParameters); + + createParameterComponents(compositeParameters); + + + } + + private void createParameterComponents(Composite composite){ + + // create label + Label labelParameterText = new Label(composite, SWT.NONE); + labelParameterText.setText("Trace parameter(integer) should be:"); + GridData gridDataLabelParameterText = new GridData(GridData.BEGINNING); + gridDataLabelParameterText.horizontalSpan = 4; + labelParameterText.setLayoutData(gridDataLabelParameterText); + + + // Parameter type + comboParameterType = new Combo(composite, SWT.READ_ONLY); + GridData dataGridComboparameterTypeCombo = new GridData(GridData.BEGINNING); + comboParameterType.setLayoutData(dataGridComboparameterTypeCombo); + + String[] parameterTypes = new String[]{ TYPE_COMBO_TEXTS_GREATER_THAN, TYPE_COMBO_TEXTS_LESS_THAN, + TYPE_COMBO_TEXTS_BETWEEN, TYPE_COMBO_TEXTS_EQUAL_TO }; + comboParameterType.setItems(parameterTypes); + comboParameterType.select(0); + + // Create rule name text field + textParameterValue1 = new Text(composite, SWT.BORDER); + GridData gridDataTextRuleName = new GridData(GridData.BEGINNING); + gridDataTextRuleName.widthHint = 30; + + textParameterValue1.setToolTipText("Define Parameter"); + textParameterValue1.setLayoutData(gridDataTextRuleName); + + // create label + labelAndText = new Label(composite, SWT.NONE); + labelAndText.setText(" and "); + gridDataLabelAndText = new GridData(GridData.BEGINNING); + labelAndText.setLayoutData(gridDataLabelAndText); + + textParameterValue2 = new Text(composite, SWT.BORDER); + gridDataTextRuleName2 = new GridData(GridData.BEGINNING); + gridDataTextRuleName2.widthHint = 30; + textParameterValue2.setToolTipText("Define Parameter"); + textParameterValue2.setLayoutData(gridDataTextRuleName2); + + + Listener inputListener = new Listener() { + public void handleEvent(Event event) { + String string = event.text; + char[] chars = new char[string.length()]; + string.getChars(0, chars.length, chars, 0); + for (int i = 0; i < chars.length; i++) { + if (!('0' <= chars[i] && chars[i] <= '9')) { + event.doit = false; + return; + } + } + + } + + }; + // Set text box to accept only numbers. + textParameterValue1.addListener(SWT.Verify, inputListener); + textParameterValue2.addListener(SWT.Verify, inputListener); + + comboParameterType.addSelectionListener(this); + textParameterValue1.addModifyListener(this); + textParameterValue2.addModifyListener(this); + +/* comboParameterType.addSelectionListener(new SelectionListener(){ + + public void widgetDefaultSelected(SelectionEvent event) { + // Nothing to be done + + } + + public void widgetSelected(SelectionEvent arg0) { + + + hideAndRevealParameter2(); + listener.canFinish(); + } + + }); + */ + } + + private void hideAndRevealParameter2(){ + boolean value = false; + if(comboParameterType.getText().equals("Between")){ + value = true; + } + textParameterValue2.setVisible(value); + labelAndText.setVisible(value); + + gridDataLabelAndText.exclude = !value; + gridDataTextRuleName2.exclude = !value; + + textParameterValue2.getParent().layout(); + textParameterValue2.getParent().redraw(); + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRule#setVisible(boolean) + */ + public void setVisible(boolean value){ + compositeParameterRule.setVisible(value); + gridDataComposite.exclude = !value; + hideAndRevealParameter2(); + + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#saveRule(java.lang.String, java.lang.String) + */ + public TraceAnalyserRule getRule(String name, String description){ + + // Create new parameter rule. + ParameterRule newRule = new ParameterRule(); + + // set basic info. + newRule.setName(name); + newRule.setDescription(description); + + + // set directory for rule. + newRule.setWorkingDirectory(getPluginWorkingLocation()); + + // set trace item for rule. + newRule.setTraceItem(traceSelectionComposite.getTraceInformation()); + + + + // set parameter type for rule. + + if(comboParameterType.getText().equals(TYPE_COMBO_TEXTS_GREATER_THAN)){ + newRule.setParameterType(ParameterType.GREATER); + } + else if(comboParameterType.getText().equals(TYPE_COMBO_TEXTS_EQUAL_TO)){ + newRule.setParameterType(ParameterType.EQUAL); + + } + else if(comboParameterType.getText().equals(TYPE_COMBO_TEXTS_BETWEEN)){ + newRule.setParameterType(ParameterType.BETWEEN); + + } + else if(comboParameterType.getText().equals(TYPE_COMBO_TEXTS_LESS_THAN)){ + newRule.setParameterType(ParameterType.LESS); + + } + + // if empty, set to zero. + if(textParameterValue1.getText() == ""){ + textParameterValue1.setText("0"); + } + + if(newRule.getParameterType() != ParameterType.BETWEEN || textParameterValue2.getText() == ""){ + textParameterValue2.setText("0"); + + } + int limitA = 0; + int limitB = 0; + try{ + limitA = Integer.parseInt(textParameterValue1.getText()); + limitB = Integer.parseInt(textParameterValue2.getText()); + } + catch (Exception e) { + e.printStackTrace(); + } + newRule.setLimitA(limitA); + newRule.setLimitB(limitB); + + // write rule into xml-file. + // if(newRule.writeXML()){ + return newRule; + //} + //else{ + //return null; + // } + //return null; + } + + + /** + * getPluginWorkingLocation. + * Returns a path where Rule plugin can do various tasks (located under workspace). + */ + public static String getPluginWorkingLocation() { + IPath location = Platform.getStateLocation( TraceAnalyserParameterRulePlugin.getDefault().getBundle()); + return location.toOSString(); + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#getRules() + */ + public ArrayList getRules(){ + + ArrayList rules = new ArrayList(); + File rootFolder = new File(getPluginWorkingLocation()); + File[] rootFiles = rootFolder.listFiles(); + int i = 0; + + while( i < rootFiles.length ){ + if(rootFiles[i].isDirectory()){ + // Create new rule. + ParameterRule rule = new ParameterRule(); + rule.setRulePath(rootFiles[i].toString()); + + // read XML, if successful add object to arraylist. + if( rule.readXML() ){ + rules.add(rule); + } + } + i++; + + } + + return rules; + + } + + /** + * getRuleType. + * @param this rule types name. + */ + public String getRuleType() { + return "Parameter Rule"; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#formatRuleDefinitions(com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule) + */ + public boolean formatRuleDefinitions(TraceAnalyserRule rule) { + + if(ParameterRule.class == rule.getClass()){ + ParameterRule parameterRule = (ParameterRule) rule; + + traceSelectionComposite.setTraceItem(parameterRule.getTraceItem()); + + comboParameterType.select(parameterRule.getParameterType().ordinal()); + + textParameterValue1.setText(Integer.toString(parameterRule.getLimitA())); + textParameterValue2.setText(Integer.toString(parameterRule.getLimitB())); + + return true; + } + return false; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#canFinish() + */ + public String canFinish() { + if(traceSelectionComposite.getTraceInformation() == null ){ + return "Trace must be defined."; + } + if(textParameterValue1.getText().equals("")){ + return "Limit must be defined."; + } + + if(textParameterValue2.isVisible() && textParameterValue2.getText().equals("")){ + return "Both Limits must be defined"; + } + + if(comboParameterType.getText().equals(TYPE_COMBO_TEXTS_BETWEEN)){ + int limit1 = Integer.parseInt(textParameterValue1.getText()); + int limit2 = Integer.parseInt(textParameterValue2.getText()); + if(limit1 >= limit2 ){ + return "Second limitation parameter must be greater that first."; + } + } + + + return null; + + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceSelectionCompositeListener#traceInfoUpdated() + */ + public void traceInfoUpdated() { + listener.canFinish(); + } + + public void widgetDefaultSelected(SelectionEvent arg0) { + // Nothing to be done + + } + + public void widgetSelected(SelectionEvent event) { + + if(event.widget == comboParameterType){ + hideAndRevealParameter2(); + listener.canFinish(); + } + } + + public void modifyText(ModifyEvent arg0) { + listener.canFinish(); + + } + + static public ParameterRule createDummyRule(String ruleName, ParameterType type){ + // Create new timing rule. + + ParameterRule newRule = new ParameterRule(); + + // set basic info. + newRule.setName(ruleName); + newRule.setDescription("testDescription"); + + // set directory for rule. + newRule.setWorkingDirectory(getPluginWorkingLocation()); + + // set trace items for rule. + TraceInfo info1 = new TraceInfo(); + TraceInformation information = new TraceInformation(); + information.setTraceId(1); + info1.setIdNumbers(information); + info1.setIdNumbers(information); + + newRule.setTraceItem(info1); + + newRule.setParameterType(type); + + + int limitA = 0; + int limitB = 0; + try{ + limitA = Integer.parseInt("10"); + limitB = Integer.parseInt("100"); + } + catch (Exception e) { + e.printStackTrace(); + } + newRule.setLimitA(limitA); + if(type == ParameterType.BETWEEN){ + newRule.setLimitB(limitB); + } + // write rule into xml-file. + return newRule; + + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/.classpath Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,7 @@ + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/.settings/org.eclipse.jdt.core.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/.settings/org.eclipse.jdt.core.prefs Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,7 @@ +#Tue Mar 17 13:09:19 EET 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/META-INF/MANIFEST.MF Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Timing Rule Type for Trace Analyser Plug-In +Bundle-SymbolicName: com.nokia.s60tools.traceanalyser.timingrule;singleton:=true +Bundle-Version: 1.0.5 +Bundle-Vendor: Nokia +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: com.nokia.s60tools.traceanalyser;bundle-version="1.0.0", + org.eclipse.core.runtime;bundle-version="3.4.0", + org.eclipse.ui;bundle-version="3.4.1", + com.nokia.traceviewer;bundle-version="2.0.27" +Bundle-ActivationPolicy: lazy +Bundle-Activator: com.nokia.s60tools.traceanalyser.timingrule.plugin.TraceAnalyserTimingRulePlugin +Export-Package: com.nokia.s60tools.traceanalyser.timingrule.rule;x-friends:="com.nokia.s60tools.traceanalyser.tests" diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/build.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/plugin.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,13 @@ + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/src/com/nokia/s60tools/traceanalyser/timingrule/plugin/TraceAnalyserTimingRulePlugin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/src/com/nokia/s60tools/traceanalyser/timingrule/plugin/TraceAnalyserTimingRulePlugin.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.timingrule.plugin; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class TraceAnalyserTimingRulePlugin extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.nokia.s60tools.traceanalyser.timingrule"; + + // The shared instance + private static TraceAnalyserTimingRulePlugin plugin; + + /** + * TraceAnalyserTimingRulePlugin. + * The constructor + */ + public TraceAnalyserTimingRulePlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * getDefault. + * Returns the shared instance + * @return the shared instance + */ + public static TraceAnalyserTimingRulePlugin getDefault() { + return plugin; + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/src/com/nokia/s60tools/traceanalyser/timingrule/rule/TimingRule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/src/com/nokia/s60tools/traceanalyser/timingrule/rule/TimingRule.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,365 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.timingrule.rule; + + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Date; + +import com.nokia.s60tools.traceanalyser.export.GeneralMethods; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.export.TraceInfo; +import com.nokia.s60tools.traceanalyser.export.RuleEvent.RuleStatus; +import com.nokia.traceviewer.engine.TraceInformation; +import com.nokia.traceviewer.engine.TraceProperties; + +public class TimingRule extends TraceAnalyserRule { + + /* Strings that are searched from xml-file */ + public static final String XML_COMPONENT_ID = "ComponentID"; + public static final String XML_GROUP_ID = "GroupID"; + public static final String XML_TRACE_ID = "TraceID"; + public static final String XML_TRACE_NAME = "TraceName"; + public static final String XML_TIME_LIMIT_A = "TimeLimitA"; + public static final String XML_TIME_LIMIT_B = "TimeLimitB"; + + + + + /* Trace items assigned for this rule */ + private TraceInfo traceItemA; + private TraceInfo traceItemB; + + /* Time limits assigned for this rule */ + private int timeLimitA; + private int timeLimitB; + + /* previous trace event that has something to do with this rule */ + //private TraceProperties previousEvent; + + private int previousTraceNumber; + private long previousTraceTimeStamp; + + private String workingDirectory; + + /** + * TimingRule. + * Constructor + */ + public TimingRule() { + super("Timing Rule"); + traceItemA = new TraceInfo(); + traceItemB = new TraceInfo(); + previousTraceNumber = -1; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#writeXML() + */ + public boolean writeXML(){ + + if(rulePath == null){ + // get directory for rule. + + String path = getNextFreeDirectory(workingDirectory); + if(path != null){ + rulePath = path; + } + else{ + return false; + } + } + rulePath = addSlashToEnd(rulePath); + if(super.writeBasicInfoIntoFile()){ + String fileName = rulePath + FILENAME_ADDITIONAL_INFO; + try { + // Create file + FileWriter fstream = new FileWriter(fileName); + BufferedWriter output = new BufferedWriter(fstream); + output.write(this.getAdditionalInfoXmlString()); + // Close the output stream + output.close(); + return true; + } catch (Exception e) {// Catch exception if any + return false; + } + } + return false; + + } + + /** + * readXML. + * Reads xml-file and formats this rule's definitions. NOTE rulePath needs to be defined before calling this function. + */ + public boolean readXML(){ + if(super.readXML()){ + + if(rulePath != null){ + String additionalInfoPath = TraceAnalyserRule.addSlashToEnd(rulePath) + FILENAME_ADDITIONAL_INFO; + File additionalInfoFile = new File(additionalInfoPath); + boolean errorOccured = false; + if (additionalInfoFile.exists()) { + try { + // Create buffered reader. + BufferedReader input = new BufferedReader(new FileReader(additionalInfoFile)); + try { + if(!readFile(input)){ + errorOccured = true; + } + } + catch(Exception e){ + errorOccured = true; + } + finally { + input.close(); + } + } catch (Exception e) { + errorOccured = true; + } + } + if(errorOccured){ + return false; + } + else{ + return true; + } + } + } + return false; + } + + + /** + * readFile. + * Reads xml file given as parameter. + * @param input bufferedReader opened to inputFile. + * @throws IOException if file operations fails. + * @return true if rule was read successfully + */ + private boolean readFile(BufferedReader input) throws IOException{ + String line = null; + + // This while loop searches xml tags from file. When tag is found information is saved and + // new searchPhrase is updated. Tags are searched in order where they should be. + + if(!traceItemA.readXMLBuffer(input, "TraceA")){ + return false; + } + + if(!traceItemB.readXMLBuffer(input, "TraceB")){ + return false; + } + + String searchPhrase = XML_TIME_LIMIT_A; + while ((line = input.readLine()) != null) { + if (line.contains(searchPhrase)) { + if(searchPhrase.equals(XML_TIME_LIMIT_A)){ + timeLimitA = Integer.parseInt(GeneralMethods.getTextBetweenQuotes(line)); + searchPhrase = XML_TIME_LIMIT_B; + + } + else if(searchPhrase.equals(XML_TIME_LIMIT_B)){ + timeLimitB = Integer.parseInt(GeneralMethods.getTextBetweenQuotes(line)); + return true; + } + + } + + } + return false; + } + + /** + * getAdditionalInfoXmlString. + * @return XML string that can be written to file. + */ + private String getAdditionalInfoXmlString(){ + String xml = ""; + xml += "\n"; + xml += " \n"; + xml += traceItemA.getXMLString("TraceA",8); + xml += traceItemB.getXMLString("TraceB",8); + xml += " \n"; + xml += " \n"; + xml += getTimingInfoXmlString(8); + xml += " \n"; + xml += "\n"; + return xml; + } + + /** + * getTimingInfoXmlString. + * @param indent indent that is used. + * @return xml-string that can be written to file. + */ + private String getTimingInfoXmlString(int indent){ + String xml = ""; + String indentString = this.getIndentString(indent); + xml += indentString + "<" + XML_TIME_LIMIT_A +"=\""; + xml += Integer.toString(timeLimitA); + xml += "\">\n"; + xml += indentString + "<" + XML_TIME_LIMIT_B +"=\""; + xml += Integer.toString(timeLimitB); + xml += "\">\n"; + + return xml; + } + + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#checkIfRuleFails(com.nokia.traceviewer.engine.TraceProperties) + */ + public RuleEvent checkRuleStatus(TraceProperties traceProperties) { + + + // check if received trace is trace A + if(TraceInfo.compareTraces(traceProperties.information, traceItemA.getIdNumbers())){ + previousTraceNumber = traceProperties.traceNumber; + previousTraceTimeStamp = traceProperties.timestamp; + + //previousEvent = traceProperties.clone(); + /*previousEvent = new TraceProperties(null); + previousEvent.timestamp = traceProperties.timestamp; + previousEvent.traceNumber = traceProperties.traceNumber;*/ + + } + + // Check if received trace is trace B + else if(TraceInfo.compareTraces(traceProperties.information, traceItemB.getIdNumbers()) && previousTraceNumber != -1){ + + + long difference = traceProperties.timestamp - previousTraceTimeStamp; + double doubleDiff = difference/1000000.0000; + difference = Math.round(doubleDiff); + + int[] traceNumbers = new int[]{previousTraceNumber, traceProperties.traceNumber}; + previousTraceNumber = -1; + + if(timeLimitA > difference){ + int violation = (int)difference - timeLimitA; + return new RuleEvent(RuleStatus.FAIL, (int)difference, timeLimitA, violation, name, "ms", + new Date(), traceNumbers ); + } + if(timeLimitB < difference){ + int violation = (int)difference - timeLimitB; + return new RuleEvent(RuleStatus.FAIL, (int)difference, timeLimitB, violation, name, "ms", + new Date(), traceNumbers ); + } + return new RuleEvent(RuleStatus.PASS, (int)difference, new Date(), "ms"); + + } + return new RuleEvent(RuleStatus.NONE); + + } + + + + + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#getUnit() + */ + public String getUnit(){ + return "ms"; + } + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#equals(com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule) + */ + public boolean equals(TraceAnalyserRule rule) { + TimingRule timingRule = (TimingRule) rule; + if (timingRule.getName().equals(this.name) + && timingRule.getDescription().equals(this.description) + && timingRule.getTimeLimitA() == this.timeLimitA + && timingRule.getTimeLimitB() == this.timeLimitB + && true + && timingRule.getTraceItemA().equals(this.traceItemA) + && timingRule.getTraceItemB().equals(this.traceItemB)) { + return true; + } + else { + return false; + } + } + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#getLimits() + */ + public int[] getLimits() { + return new int[]{timeLimitA, timeLimitB}; + } + + + /* Getters and setters for member variables. */ + public TraceInfo getTraceItemA() { + return traceItemA; + } + public void setTraceItemA(TraceInfo traceItemA) { + this.traceItemA = traceItemA; + } + public TraceInfo getTraceItemB() { + return traceItemB; + } + public void setTraceItemB(TraceInfo traceItemB) { + this.traceItemB = traceItemB; + } + public int getTimeLimitA() { + return timeLimitA; + } + public void setTimeLimitA(int timeLimitA) { + this.timeLimitA = timeLimitA; + } + public int getTimeLimitB() { + return timeLimitB; + } + public void setTimeLimitB(int timeLimitB) { + this.timeLimitB = timeLimitB; + } + + public String getWorkingDirectory() { + return workingDirectory; + } + + public void setWorkingDirectory(String workingDirectory) { + this.workingDirectory = workingDirectory; + } + + + + + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/src/com/nokia/s60tools/traceanalyser/timingrule/rule/TimingRuleType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser.timingrule/src/com/nokia/s60tools/traceanalyser/timingrule/rule/TimingRuleType.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,382 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.timingrule.rule; + +import java.io.File; +import java.util.ArrayList; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType; +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleTypeListener; +import com.nokia.s60tools.traceanalyser.export.ITraceSelectionCompositeListener; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.export.TraceInfo; +import com.nokia.s60tools.traceanalyser.export.TraceSelectionComposite; +import com.nokia.s60tools.traceanalyser.timingrule.plugin.TraceAnalyserTimingRulePlugin; +import com.nokia.traceviewer.engine.TraceInformation; + +/** + * class Timing Rule. + * "Parameter Rule"-rule type for Trace Analyser + */ + +public class TimingRuleType implements ITraceAnalyserRuleType, ITraceSelectionCompositeListener, ModifyListener{ + + /* UI components */ + private GridData gridDataComposite; + private Composite compositeTimingRule; + private Text textLimitTraceA; + private Text textLimitTraceB; + + /* Trace Selection composites */ + TraceSelectionComposite traceSelectionCompositeA; + TraceSelectionComposite traceSelectionCompositeB; + + /* Edit rule-window */ + ITraceAnalyserRuleTypeListener listener; + + + + /** + * TimingRule. + * constructor + */ + public TimingRuleType(){ + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRule#createUIComponents(org.eclipse.swt.widgets.Composite) + */ + public void createUIComponents(Composite composite, ITraceAnalyserRuleTypeListener listener) { + + this.listener = listener; + + // Create composite for rule + compositeTimingRule = new Composite(composite, SWT.NONE); + GridLayout layoutTraceA = new GridLayout(); + layoutTraceA.numColumns = 1; + compositeTimingRule.setLayout(layoutTraceA); + gridDataComposite = new GridData(GridData.FILL_HORIZONTAL); + compositeTimingRule.setLayoutData(gridDataComposite); + + // create trace selection components. + traceSelectionCompositeA = new TraceSelectionComposite(compositeTimingRule, "Trace A:", this); + traceSelectionCompositeB = new TraceSelectionComposite(compositeTimingRule, "Trace B:", this); + + // create composite for time limits + Composite compositeTimeLimits = new Composite(compositeTimingRule, SWT.NONE); + GridLayout layoutTimeLimitA = new GridLayout(); + layoutTimeLimitA.numColumns = 2; + compositeTimeLimits.setLayout(layoutTimeLimitA); + GridData gridDataTimeLimits = new GridData(GridData.FILL_HORIZONTAL); + compositeTimeLimits.setLayoutData(gridDataTimeLimits); + + // create time limit components. + textLimitTraceA = this.createTimeLimitControls(compositeTimeLimits, "Time Limit A(Trace B must arrive after this):"); + textLimitTraceB = this.createTimeLimitControls(compositeTimeLimits, "Time Limit B(Trace B must arrive before this):"); + + + } + + /** + * createTimeLimitControls. + * Method that creates time limit related ui-components. + * @param composite composite where components are placed + * @param labelText text of the label + * @return textBox where time limit is written. + */ + private Text createTimeLimitControls(Composite composite, String labelText){ + + // create composite for trace limit components + Composite compositeTimeLimits = new Composite(composite, SWT.NONE); + GridLayout layoutTimeLimitA = new GridLayout(); + layoutTimeLimitA.numColumns = 2; + compositeTimeLimits.setLayout(layoutTimeLimitA); + GridData gridDataTimeLimits = new GridData(GridData.FILL_HORIZONTAL); + compositeTimeLimits.setLayoutData(gridDataTimeLimits); + + // Create time limit label + Label labelTimeLimit = new Label(compositeTimeLimits, SWT.NONE); + labelTimeLimit.setText(labelText); + GridData gridDataLabelTimeLimit = new GridData(GridData.BEGINNING); + gridDataLabelTimeLimit.horizontalSpan = 2; + labelTimeLimit.setLayoutData(gridDataLabelTimeLimit); + + // Create time limit text box. + Text textBox = new Text(compositeTimeLimits, SWT.BORDER); + GridData gridDataTextBox = new GridData(GridData.BEGINNING); + gridDataTextBox.widthHint = 30; + textBox.setTextLimit(5); + textBox.setToolTipText("Define time limit for trace."); + textBox.setLayoutData(gridDataTextBox); + textBox.setText("0"); + + // Create ms-label + Label labelMS = new Label(compositeTimeLimits, SWT.NONE); + labelMS.setText("ms"); + + // Set text box to accept only numbers. + textBox.addListener(SWT.Verify, new Listener() { + public void handleEvent(Event event) { + String string = event.text; + char[] chars = new char[string.length()]; + string.getChars(0, chars.length, chars, 0); + for (int i = 0; i < chars.length; i++) { + if (!('0' <= chars[i] && chars[i] <= '9')) { + event.doit = false; + return; + } + } + } + + }); + + textBox.addModifyListener(this); + + return textBox; + + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRule#setVisible(boolean) + */ + public void setVisible(boolean value){ + compositeTimingRule.setVisible(value); + gridDataComposite.exclude = !value; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#saveRule(java.lang.String, java.lang.String) + */ + public TraceAnalyserRule getRule(String name, String description){ + + // Create new timing rule. + TimingRule newRule = new TimingRule(); + + // set basic info. + newRule.setName(name); + newRule.setDescription(description); + + + // set directory for rule. + newRule.setWorkingDirectory(getPluginWorkingLocation()); + + // set trace items for rule. + newRule.setTraceItemA(traceSelectionCompositeA.getTraceInformation()); + newRule.setTraceItemB(traceSelectionCompositeB.getTraceInformation()); + + + // set time limits for rule. + + // if empty, set to zero. + if(textLimitTraceA.getText() == ""){ + textLimitTraceA.setText("0"); + } + if(textLimitTraceB.getText() == ""){ + textLimitTraceB.setText("0"); + } + + int limitA = 0; + int limitB = 0; + try{ + limitA = Integer.parseInt(textLimitTraceA.getText()); + limitB = Integer.parseInt(textLimitTraceB.getText()); + } + catch (Exception e) { + e.printStackTrace(); + } + newRule.setTimeLimitA(limitA); + newRule.setTimeLimitB(limitB); + + // write rule into xml-file. + // if(newRule.writeXML()){ + return newRule; + //} + //else{ + //return null; + // } + } + + + /** + * getPluginWorkingLocation. + * Returns a path where Rule plugin can do various tasks (located under workspace). + */ + public static String getPluginWorkingLocation() { + IPath location = Platform.getStateLocation( TraceAnalyserTimingRulePlugin.getDefault().getBundle()); + return location.toOSString(); + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#getRules() + */ + public ArrayList getRules(){ + + ArrayList rules = new ArrayList(); + File rootFolder = new File(getPluginWorkingLocation()); + File[] rootFiles = rootFolder.listFiles(); + int i = 0; + + while( i < rootFiles.length ){ + if(rootFiles[i].isDirectory()){ + // Create new rule. + TimingRule rule = new TimingRule(); + rule.setRulePath(rootFiles[i].toString()); + + // read XML, if successful add object to arraylist. + if( rule.readXML() ){ + rules.add(rule); + } + } + i++; + + } + + return rules; + + } + + /** + * getRuleType. + * @param this rule types name. + */ + public String getRuleType() { + return "Timing Rule"; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#formatRuleDefinitions(com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule) + */ + public boolean formatRuleDefinitions(TraceAnalyserRule rule) { + + if(TimingRule.class == rule.getClass()){ + TimingRule timingRule = (TimingRule) rule; + + traceSelectionCompositeA.setTraceItem(timingRule.getTraceItemA()); + traceSelectionCompositeB.setTraceItem(timingRule.getTraceItemB()); + + textLimitTraceA.setText(Integer.toString( timingRule.getTimeLimitA())); + textLimitTraceB.setText(Integer.toString( timingRule.getTimeLimitB())); + return true; + } + return false; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType#canFinish() + */ + public String canFinish() { + if(traceSelectionCompositeA.getTraceInformation() == null ){ + return "Trace A must be defined"; + } + if(traceSelectionCompositeB.getTraceInformation() == null){ + return "Trace B must be defined"; + } + + int limit1 = Integer.parseInt(textLimitTraceA.getText()); + int limit2 = Integer.parseInt(textLimitTraceB.getText()); + + if(limit1 >= limit2 && !(limit1 == 0 && limit2 == 0) ){ + return "Limit B must be greater that limit A"; + } + + return null; + + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.ITraceSelectionCompositeListener#traceInfoUpdated() + */ + public void traceInfoUpdated() { + listener.canFinish(); + } + + static public TimingRule createDummyRule(String ruleName){ + // Create new timing rule. + + TimingRule newRule = new TimingRule(); + + // set basic info. + newRule.setName(ruleName); + newRule.setDescription("testDescription"); + + // set directory for rule. + newRule.setWorkingDirectory(getPluginWorkingLocation()); + + // set trace items for rule. + TraceInfo info1 = new TraceInfo(); + TraceInformation information = new TraceInformation(); + information.setTraceId(1); + info1.setIdNumbers(information); + info1.setIdNumbers(information); + + + TraceInfo info2 = new TraceInfo(); + TraceInformation information2 = new TraceInformation(); + information2.setTraceId(2); + info2.setIdNumbers(information2); + + newRule.setTraceItemA(info1); + newRule.setTraceItemB(info2); + + + + int limitA = 0; + int limitB = 0; + try{ + limitA = Integer.parseInt("10"); + limitB = Integer.parseInt("100"); + } + catch (Exception e) { + e.printStackTrace(); + } + newRule.setTimeLimitA(limitA); + newRule.setTimeLimitB(limitB); + + // write rule into xml-file. + return newRule; + + } + + public void modifyText(ModifyEvent arg0) { + listener.canFinish(); + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/.classpath Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,7 @@ + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/META-INF/MANIFEST.MF Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,59 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Carbide.c++ Extensions - Trace Analyser +Bundle-SymbolicName: com.nokia.s60tools.traceanalyser; singleton:=true +Bundle-Version: 1.0.5 +Bundle-Activator: com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin +Bundle-Vendor: Nokia +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.nokia.s60tools.ui;bundle-version="1.2.1", + com.nokia.traceviewer;bundle-version="2.0.27", + org.eclipse.ui.ide;bundle-version="3.4.1", + org.eclipse.draw2d;bundle-version="3.4.1" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Export-Package: com.nokia.s60tools.traceanalyser.containers;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="com.nokia.s60tools.traceanalyser.export, + com.nokia.traceviewer.engine", + com.nokia.s60tools.traceanalyser.export;uses:="com.nokia.traceviewer.engine,org.eclipse.swt.events,org.eclipse.swt.widgets", + com.nokia.s60tools.traceanalyser.interfaces;x-friends:="com.nokia.s60tools.traceanalyser.tests", + com.nokia.s60tools.traceanalyser.model;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="org.eclipse.core.runtime, + com.nokia.s60tools.traceanalyser.ui.views, + org.eclipse.core.runtime.jobs, + com.nokia.s60tools.traceanalyser.containers, + com.nokia.traceviewer.engine, + org.eclipse.ui, + com.nokia.s60tools.traceanalyser.interfaces, + com.nokia.traceviewer.engine.dataprocessor, + org.eclipse.jface.dialogs", + com.nokia.s60tools.traceanalyser.plugin;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="org.eclipse.jface.resource, + com.nokia.s60tools.traceanalyser.ui.views, + org.eclipse.ui.plugin, + org.osgi.framework, + com.nokia.s60tools.traceanalyser.model", + com.nokia.s60tools.traceanalyser.resources;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="org.eclipse.jface.resource, + org.eclipse.swt.graphics", + com.nokia.s60tools.traceanalyser.ui.actions;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="org.eclipse.jface.action, + org.eclipse.ui, + org.eclipse.jface.viewers", + com.nokia.s60tools.traceanalyser.ui.dialogs;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="com.nokia.s60tools.traceanalyser.export, + org.eclipse.swt.events, + org.eclipse.swt.widgets, + com.nokia.traceviewer.engine.activation, + org.eclipse.jface.dialogs", + com.nokia.s60tools.traceanalyser.ui.views;x-friends:="com.nokia.s60tools.traceanalyser.tests"; + uses:="org.eclipse.swt.events, + com.nokia.s60tools.ui, + com.nokia.s60tools.traceanalyser.interfaces, + org.eclipse.ui.part, + javax.swing, + org.eclipse.jface.viewers, + org.eclipse.swt.graphics, + org.eclipse.swt.widgets, + com.nokia.s60tools.traceanalyser.model" diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.html Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,20 @@ + + + +About + + + + +

About This Content

+ +

June 4, 2010

+ +

Copyright

+

Copyright © 2007-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
+This component and the accompanying materials are made available under the
+terms of "Eclipse Public License v1.0" which accompanies this
+distribution, and is available at the URL: http://www.eclipse.org/legal/epl-v10.html.

+ + + \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.ini Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,43 @@ +# +# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +# This text is shown in Feature Details -dialog when feature is selected. +aboutText=%productBlurb + +# Property "windowImage" contains path to window icon (16x16) +# needed for primary features only + +# Property "featureImage" contains path to feature image (32x32) +# Not using this in here because we do not want the icon to +# show on about dialog. Only using aboutText above. +#featureImage=icons/appdep.png + +# Property "aboutImage" contains path to product image (500x330 or 115x164) +# needed for primary features only + +# Property "appName" contains name of the application (translated) +# needed for primary features only + +# Property "welcomePerspective" contains the id of the perspective in which the +# welcome page is to be opened. +# optional diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.mappings --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.mappings Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +# about.mappings +# contains fill-ins for about.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. + +# The following should contain the build version. +# e.g. "0=20020612" +0=1 diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/about.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,33 @@ +# +# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +# about.properties +# contains externalized strings for about.ini +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# fill-ins are supplied by about.mappings +# This file should be translated. + +productBlurb=Carbide.c++ Extensions - TraceAnalyser \n\ +\n\ +Version: 1.0\n\ +Build id: {0}\n\ +\n\ +\n\ +Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).\n\ +All rights reserved. License: http://www.eclipse.org/legal/epl-v10.html.\n\ +\n\ +This product includes software developed by Eclipse Project\n\ +(http://www.eclipse.org/). \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/build.properties Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,14 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + contexts.xml,\ + about.html,\ + about.ini,\ + about.mappings,\ + about.properties +bin.excludes = icons/Thumbs.db,\ + icons/ClearOneCounter.png,\ + icons/PNG_04/ diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/ClearAllCounters.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/ClearAllCounters.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/ClearFailLog.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/ClearFailLog.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/CreateNewRule.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/CreateNewRule.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/FailReceived.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/FailReceived.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/TraceAnalyser.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/TraceAnalyser.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/TraceAnalyser_banner.png Binary file trace/traceanalyser/com.nokia.s60tools.traceanalyser/icons/TraceAnalyser_banner.png has changed diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/plugin.xml Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,64 @@ + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/schema/com.nokia.s60tools.traceanalyser.rule.exsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/schema/com.nokia.s60tools.traceanalyser.rule.exsd Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,84 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/schema/traceanalyserrule.exsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/schema/traceanalyserrule.exsd Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,107 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the trace provider + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/containers/DummyRule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/containers/DummyRule.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.containers; + +import java.util.ArrayList; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.traceviewer.engine.TraceProperties; + + +/** + * class DummyRule. + * DummyRule that is used for sending messages from rule manager to main view. + */ +public class DummyRule extends TraceAnalyserRule { + + /** + * DummyRule + * @param type Type of the rule. + */ + public DummyRule(String type) { + super(type); + name = type; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#checkRuleStatus(com.nokia.traceviewer.engine.TraceProperties) + */ + @Override + public RuleEvent checkRuleStatus(TraceProperties traceProperties) { + return null; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#getLimitUnit() + */ + @Override + public String getUnit() { + return null; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#readHistory() + */ + @Override + public ArrayList readHistory() { + return null; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#saveHistory(java.util.ArrayList) + */ + @Override + public boolean saveHistory(ArrayList history) { + return false; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#writeXML() + */ + @Override + public boolean writeXML() { + return false; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#equals(com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule) + */ + @Override + public boolean equals(TraceAnalyserRule rule) { + return false; + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule#getLimits() + */ + @Override + public int[] getLimits() { + return null; + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/containers/RuleInformation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/containers/RuleInformation.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.containers; + +import java.io.Serializable; +import java.util.ArrayList; + +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; + + +/** + * class RuleInformation. + * Class that contains information about one rule that is shown on main view of Trace Analyser. + */ +public class RuleInformation implements Serializable { + + + /** + * UID for serialization. + */ + private static final long serialVersionUID = 1L; + + + /* indexes for TableViewer */ + public static final int INDEX_CHECK_BOX = 0; + public static final int INDEX_NAME = 1; + public static final int INDEX_PASS = 2; + public static final int INDEX_FAIL = 3; + public static final int INDEX_PASS_FAIL_RATIO = 4; + public static final int INDEX_MIN = 5; + public static final int INDEX_MAX = 6; + public static final int INDEX_AVG = 7; + public static final int INDEX_MED = 8; + + /* Trace Analyser Rule object */ + private TraceAnalyserRule rule; + + /* amount of passes */ + private int pass; + + /* amount of fails */ + private int fail; + + /* min value */ + private int min; + + /* max value */ + private int max; + + /* average value */ + private int avg; + + /* median value */ + private int med; + + /* all history events */ + private ArrayList events; + + /** + * RuleInformation + * Constructor + * @param rule rule for this information. + */ + public RuleInformation(TraceAnalyserRule rule){ + this.rule = rule; + this.events = new ArrayList(); + } + + + /** + * getText. + * MainView can use this to get description for each column in the grid + * @param index index of the column + * @return value for asked column + */ + public String getText(int index) { + String retval = ""; + switch (index) { + case INDEX_CHECK_BOX: + retval = ""; + break; + case INDEX_NAME: + retval = rule.getName(); + break; + case INDEX_PASS: + retval = Integer.toString(pass); + break; + case INDEX_FAIL: + retval = Integer.toString(fail); + break; + case INDEX_PASS_FAIL_RATIO: + + double value = getPassPercent(); + if(value == -1){ + return "-"; + } + else{ + retval = Double.toString(value); + } + + break; + case INDEX_MAX: + retval = Integer.toString(max) + rule.getUnit(); + break; + case INDEX_MIN: + retval = Integer.toString(min) + rule.getUnit(); + break; + case INDEX_AVG: + if(pass > 0 || fail > 0){ + retval = Integer.toString(avg) + rule.getUnit(); + } + else{ + retval = "-"; + } + break; + case INDEX_MED: + if(pass > 0 || fail > 0){ + retval = Integer.toString(med) + rule.getUnit(); + } + else{ + retval = "-"; + } + break; + default: + break; + } + return retval; + } + + /** + * delete. + * Deletes rule and all information relating to it. + * @return true if file operations were successful + */ + public boolean delete(){ + return rule.delete(); + } + + /* Getters and setters for member variables */ + + public TraceAnalyserRule getRule() { + return rule; + } + public void setRule(TraceAnalyserRule rule) { + this.rule = rule; + } + public int getPass() { + return pass; + } + public void setPass(int pass) { + this.pass = pass; + } + public int getFail() { + return fail; + } + public void setFail(int fail) { + this.fail = fail; + } + public int getMin() { + return min; + } + public void setMin(int min) { + this.min = min; + } + public int getMax() { + return max; + } + public void setMax(int max) { + this.max = max; + } + public int getAvg() { + return avg; + } + public void setAvg(int avg) { + this.avg = avg; + } + public int getMed() { + return med; + } + public void setMed(int med) { + this.med = med; + } + + public ArrayList getEvents() { + return events; + } + public void setEvents(ArrayList events) { + this.events = events; + } + + /** + * getPassPercent. + * @return returns current pass percent for rule. + */ + public double getPassPercent(){ + if(pass == 0 && fail == 0){ + return -1; + } + else{ + double passDouble = pass; + double allEvents = fail + pass; + double value = passDouble / allEvents; + double roundedValue = (int)(value * 1000 + 0.5)/10.0; + return roundedValue; + } + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/GeneralMethods.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/GeneralMethods.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.export; + +public class GeneralMethods { + /** + * getTextBetweenQuotes. + * Returns text between two first quotation marks on line that is give as parameter + * @param line where quotations are searched. + * @return text between quotation marks + */ + public static String getTextBetweenQuotes(String line){ + int index = 0; + if((index =line.indexOf("\"")) > -1){ + line = line.substring(index+1); + if((index =line.indexOf("\"")) > -1){ + return line.substring(0,index); + } + } + return null; + } +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/ITraceAnalyserRuleType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/ITraceAnalyserRuleType.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.export; +import java.util.ArrayList; +import org.eclipse.swt.widgets.Composite; + +/** + * interface ITraceAnalyserRuleType. + * Interface that all Trace Analyser rule type Plug + * -Ins must implement + * + */ +public interface ITraceAnalyserRuleType { + + /** + * createUIComponents. + * Method that places all UI components related + * to rule into give composite-parameter. + * @param composite composite where all UI + * components all placed + * @param listener listener for UI-changes. + */ + public void createUIComponents( + Composite composite, + ITraceAnalyserRuleTypeListener listener); + + /** + * formatRuleDefinitions. + * Inserts settings from given rule to UI + * components if rule's type is same. + * @param rule rule which values are formatted + * to UI. + * @return true if parameter rule was from + * this type. + */ + public boolean formatRuleDefinitions( + TraceAnalyserRule rule); + + /** + * getRuleName. + * @return Name of the rule + */ + public String getRuleType(); + + /** + * setVisible. + * Excludes & hides rule's ui components. + * @param value true if rule needs to be hidden. + */ + public void setVisible(boolean value); + + /** + * getRule. + * Gets rule from values that are inserted into + * user interface. + * @param name rule name. + * @param description rule description. + * @return Trace Analyser Rule + */ + public TraceAnalyserRule getRule(String name, + String description); + + /** + * getRules. + * Loads list of rules from file system. + * @return Rule list. + */ + public ArrayList getRules(); + + /** + * canFinish. + * @return implementation of this rule type method + * returns null if this page is complete. + * If page is not complete, error message is returned. + */ + public String canFinish(); + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/ITraceAnalyserRuleTypeListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/ITraceAnalyserRuleTypeListener.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.export; + +public interface ITraceAnalyserRuleTypeListener { + + /** + * canFinish. + * this method is called when some values of ui components have changed + * and UI needs to check if finishing is possible + */ + public void canFinish(); +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/ITraceSelectionCompositeListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/ITraceSelectionCompositeListener.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.export; + +public interface ITraceSelectionCompositeListener { + + /** + * traceInfoUpdated. + * This method is called when trace item information is changed. + */ + public void traceInfoUpdated(); + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/RuleEvent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/RuleEvent.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,303 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.export; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * class RuleEvent. + * Class that represents one rule event, either passed or failed. Rule event also contains + * trace value that was measured and limit that was violated. + */ +public class RuleEvent implements Serializable { + /** + * serialization UID number + */ + private static final long serialVersionUID = 1L; + + + /* indexes for fail log tableviewer */ + public static final int INDEX_FAIL_LOG_TIME = 0; + public static final int INDEX_FAIL_LOG_RULE_NAME = 1; + public static final int INDEX_FAIL_LOG_VIOLATION = 2; + public static final int INDEX_FAIL_LOG_LIMIT = 3; + + /* indexes for History views tableviewer */ + public static final int INDEX_HISTORY_STATUS = 0; + public static final int INDEX_HISTORY_TIME = 1; + public static final int INDEX_HISTORY_VALUE = 2; + public static final int INDEX_HISTORY_VIOLATION = 3; + + /* Status stating if rule was failed or passed. */ + public enum RuleStatus{ PASS, NONE, FAIL}; + private RuleStatus status; + + /* value that was measured */ + private int value; + + /* measured violation */ + private int violation; + + /* limit that was broken */ + private int limit; + + /* time when violation occured */ + private Date time; + + /* Numbers of traces */ + private int[] traceNumbers; + + /* unit of value */ + private String unit = ""; + + /* Name of the rule */ + private String ruleName; + + /** + * RuleEvent. + * constructor + * @param status Status stating if rule was failed or passed. + * @param value value that was measured + * @param limit limit that was broken + * @param ruleName Name of the rule + * @param unit unit of value + * @param time time when violation occured + * @param traceNumbers Numbers of traces + */ + public RuleEvent(RuleStatus status, int value, int limit, int violation, String ruleName, + String unit, Date time, int[] traceNumbers){ + this.status = status; + this.value = value; + this.limit = limit; + this.ruleName = ruleName; + this.unit = unit; + this.time = time; + this.traceNumbers = traceNumbers; + this.violation = violation; + } + + /** + * RuleEvent. + * constructor + * @param status Status stating if rule was failed or passed. + */ + public RuleEvent(RuleStatus status){ + this.status = status; + this.value = 0; + this.limit = 0; + this.ruleName = ""; + this.unit = ""; + this.time = null; + this.traceNumbers = null; + } + + /** + * RuleEvent. + * constructor + * @param status Status stating if rule was failed or passed. + * @param value value that was measured + * @param limit limit that was broken + * @param ruleName Name of the rule + * @param unit unit of value + */ + public RuleEvent(RuleStatus status, int value, Date time, String unit) { + this.status = status; + this.value = value; + this.time = time; + this.unit = unit; + } + + /** + * RuleEvent. + * constructor + */ + public RuleEvent(){ + this.status = RuleStatus.NONE; + this.value = 0; + this.limit = 0; + this.ruleName = ""; + this.unit = ""; + this.time = null; + this.traceNumbers = null; + + } + + /** + * equals + * Comparator. + * @param event event that is compared to this object. + * @return true if events are equal. + */ + public boolean equals(RuleEvent event){ + if( limit == event.getLimit() && + status == event.getStatus() && + value == event.getValue() ){ + return true; + } + else{ + return false; + } + } + + /** + * getFailLogText. + * Fail log can use this to get description for each column in the grid + * @param index index of the column + * @return value for asked column + */ + + public String getFailLogText(int index) { + String retval = ""; + switch (index) { + case INDEX_FAIL_LOG_TIME: + if(time != null){ + SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss:SSS"); + retval = formatter.format(time); + } + else{ + return ""; + } + break; + case INDEX_FAIL_LOG_RULE_NAME: + retval = ruleName ; + break; + case INDEX_FAIL_LOG_VIOLATION: + retval = Integer.toString(violation) + unit; + break; + case INDEX_FAIL_LOG_LIMIT: + retval = Integer.toString(limit) + unit; + break; + default: + break; + } + return retval; + } + + /** + * getHistoryText. + * History View can use this to get description for each column in the grid + * @param index index of the column + * @return value for asked column + */ + public String getHistoryText(int index) { + String retval = ""; + switch (index) { + case INDEX_HISTORY_STATUS: + if(status == RuleStatus.FAIL){ + retval = "Fail"; + } + else{ + retval = "Pass"; + } + break; + case INDEX_HISTORY_TIME: + if(time != null){ + SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss:SSS"); + retval = formatter.format(time); + } + else{ + return ""; + } + break; + case INDEX_HISTORY_VALUE: + retval = Integer.toString(value) + unit; + break; + case INDEX_HISTORY_VIOLATION: + if(status == RuleStatus.FAIL){ + retval = Integer.toString(value - limit) + unit; + } + else{ + retval = ""; + } + break; + default: + break; + } + return retval; + } + + /* getters and setters for member variables */ + + public RuleStatus getStatus() { + return status; + } + public void setStatus(RuleStatus status) { + this.status = status; + } + + public int getLimit() { + return limit; + } + public void setLimit(int limit) { + this.limit = limit; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public Date getTime() { + return time; + } + + public void setTime(Date time) { + this.time = time; + } + + public int[] getTraceNumbers() { + return traceNumbers; + } + + public void setTraceNumbers(int[] traceNumbers) { + this.traceNumbers = traceNumbers; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String ruleName) { + this.ruleName = ruleName; + } + + public int getViolation() { + return violation; + } + + public void setViolation(int violation) { + this.violation = violation; + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/TraceAnalyserRule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/TraceAnalyserRule.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,521 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.export; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.ArrayList; + +import com.nokia.traceviewer.engine.TraceProperties; + + +/** + * class TraceAnalyserRule. + * Base class for every Trace Analyser rule. + */ +public abstract class TraceAnalyserRule { + + + /* indexes for TableViewer */ + public static final int INDEX_RULE_NAME = 0; + public static final int INDEX_FILE_DESCRIPTION = 1; + + /* XML-file names */ + public static final String FILENAME_BASIC_INFO ="BasicInfo.xml"; + public static final String FILENAME_ADDITIONAL_INFO ="AdditionalInfo.xml"; + public static final String FILENAME_HISTORY = "History.log"; + + /* XML-tags that are used in saving rule data */ + public static final String XML_NAME = " \n"; + xml += XML_DESCRIPTION; + xml += description + "\">\n"; + xml += XML_ACTIVATED; + xml += activated + "\">\n"; + xml += "\n"; + return xml; + } + + + + /** + * TraceAnalyserRule + * Constructor + * @param ruleType Rule Type's name + */ + public TraceAnalyserRule(String ruleType){ + this.ruleTypeName = ruleType; + this.activated = true; + } + + /** + * getName. + * @return name of the rule + */ + public String getName() { + return name; + } + + /** + * setName. + * @param name, new name for the rule + */ + public void setName(String name) { + this.name = name; + } + + /** + * getDescription. + * @return description of the rule + */ + public String getDescription() { + return description; + } + + /** + * setDescription. + * @param description, new description for the rule + */ + public void setDescription(String definition) { + this.description = definition; + } + + /** + * getRuleType + * @return type of the rule + */ + public String getRuleType() { + return ruleTypeName; + } + + /** + * setRuleType + * @param ruleType, a new rule type + */ + public void setRuleName(String ruleName) { + this.ruleTypeName = ruleName; + } + + /** + * getRulePath. + * @return path of rule's setting files + */ + public String getRulePath() { + return rulePath; + } + + /** + * setRulePath. + * @param rulePath, a new path for setting files. + */ + public void setRulePath(String rulePath) { + this.rulePath = rulePath; + } + + + /** + * isActivated. + * @return true if rule is activated + */ + public boolean isActivated() { + return activated; + } + + /** + * setActivated + * sets activation value of rule. + * @param activated + */ + public void setActivated(boolean activated) { + this.activated = activated; + } + + /** + * getNextFreeDirectory. + * Creates next free directory for Trace Analyser Rule data files + * @return next free directory where files can be copied. + */ + public String getNextFreeDirectory(String directory){ + + // Get file list + File file = new File( directory ); + String[] fileList = file.list(); + + + directory = TraceAnalyserRule.addSlashToEnd( directory ); + int i = 0; + File newFile = null; + + // if some files are found + if( fileList != null ){ + // Go thru directory in a loop and search for first free integer value for directory name. + while( i <= fileList.length ){ + + newFile = new File( directory + Integer.toString(i) ); + if ( !newFile.isDirectory() ){ + break; + } + i++; + } + } + else{ + newFile = new File( directory + "0" ); + } + + // if directories are created successfully, return path, if not return null + if( newFile.mkdirs() ){ + String newFileString = TraceAnalyserRule.addSlashToEnd(newFile.toString()); + return newFileString; + } + else{ + return null; + } + + } + + /** + * getText. + * MainView can use this to get description for each column in the grid + * @param index index of the column + * @return value for asked column + */ + public String getText(int index) { + String retval = ""; + switch (index) { + case INDEX_RULE_NAME: + retval = name; + break; + case INDEX_FILE_DESCRIPTION: + retval = description; + break; + default: + break; + } + return retval; + } + + /** + * readXML. + * Reads basic info from xml file. NOTE. rulePath variable must be defined before reading. + * @return true if rule info was read successfully + */ + public boolean readXML(){ + if (rulePath != null) { + String basicInfoPath = TraceAnalyserRule.addSlashToEnd(rulePath) + FILENAME_BASIC_INFO; + + //Open file + File basicInfoFile = new File(basicInfoPath); + if (basicInfoFile.exists()) { + try { + // Create buffered reader + BufferedReader input = new BufferedReader(new FileReader(basicInfoFile)); + try { + String line = null; + + // Read file + while ((line = input.readLine()) != null) { + // detect XML-tags and save values. + if (line.contains(XML_NAME)) { + name = GeneralMethods.getTextBetweenQuotes(line); + } + else if (line.contains(XML_DESCRIPTION)) { + description = GeneralMethods.getTextBetweenQuotes(line); + } + else if(line.contains(XML_ACTIVATED)){ + if(GeneralMethods.getTextBetweenQuotes(line).equals("false")){ + activated = false; + } + else{ + activated = true; + } + + } + } + + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + + // close file. + input.close(); + + // confirm that all needed info was read + if (name != null && description != null) { + return true; + } + } + } + catch (IOException ex) { + ex.printStackTrace(); + } + } + } + return false; + } + + /** + * If the last character of the given path is not backslash, it is added + * and path with backslash is returned. + * @param path Path to which backslash is added + * @return Path which last character is backslash + */ + public static String addSlashToEnd(String path) { + if (path.endsWith(File.separator)){ + return path; + } + else{ + return path + File.separator; + } + } + + /** + * delete. + * Deletes this rule. I.e deletes all files under this + * rule folder and finally deletes the rule folder + */ + public boolean delete() { + if (!"".equals(rulePath) && rulePath != null) { + return this.deleteDir(new File(rulePath)); + } + else{ + return true; + } + + } + + /** + * deleteDir + * Deletes directory and everything inside. + * @param dir directory name + * @return true if file operations were successful + */ + private boolean deleteDir(File dir) { + if ( dir.isDirectory() ) { + + // get list of everything inside file. + String[] children = dir.list(); + + // go thru file list and call this function recursively. + for ( int i=0; i < children.length; i++) { + boolean success = deleteDir(new File(dir, children[i])); + if (!success) { + return false; + } + } + } + // after everything inside directory is deleted, remove directory itself. + boolean value = dir.delete(); + return value; + } + + /** + * getTextBetweenQuotes. + * Returns text between two first quotation marks on line that is give as parameter + * @param line where quotations are searched. + * @return text between quotation marks + */ + /*protected String getTextBetweenQuotes(String line){ + int index = 0; + if((index =line.indexOf("\"")) > -1){ + line = line.substring(index+1); + if((index =line.indexOf("\"")) > -1){ + return line.substring(0,index); + } + } + return null; + }*/ + + /** + * getIndentString. + * @param indent indent. + * @return string containing as many spaces as parameter states. + */ + protected String getIndentString(int indent){ + String indentString = ""; + while(indent > 0){ + indentString += " "; + indent--; + } + return indentString; + } + + /** + * checkRuleStatus. + * Checks if parameter trace has some affect on rule. + * @param traceProperties received trace + * @return ruleEvent. + */ + public abstract RuleEvent checkRuleStatus(TraceProperties traceProperties); + + /** + * getLimitUnit. + * @return unit of value that is measured. + */ + public abstract String getUnit(); + + /** + * readHistory. + * Reads history data from file system. + * @return arraylist containing history data. + */ + @SuppressWarnings("unchecked") + public ArrayList readHistory() { + ArrayList history = null; + + try { + String fileName = addSlashToEnd(rulePath) + FILENAME_HISTORY; + // use buffering + InputStream file = new FileInputStream(fileName); + InputStream buffer = new BufferedInputStream(file); + ObjectInput input = new ObjectInputStream(buffer); + try { + // deserialize the List + history = (ArrayList) input.readObject(); + + } finally { + input.close(); + if (history == null) { + history = new ArrayList(); + } + } + } catch (ClassNotFoundException ex) { + ex.printStackTrace(); + history = new ArrayList(); + } catch (IOException ex) { + history = new ArrayList(); + } + return history; + } + + /** + * saveHistory. + * Saves given history data into this rule's own folder. + * @param history history data that is saved. + * @return true if file operations were successful + */ + public boolean saveHistory(ArrayList history) { + + boolean retVal = true; + try { + String fileName = addSlashToEnd(rulePath) + FILENAME_HISTORY; + + OutputStream file = new FileOutputStream(fileName); + OutputStream buffer = new BufferedOutputStream(file); + ObjectOutput output = new ObjectOutputStream(buffer); + try { + // serialize fail list. + output.writeObject(history); + } finally { + output.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + retVal = false; + } + return retVal; + + } + + /** + * equals, + * Comparator + * @param rule Rule that is compared to this rule. + * @return true if rules are equal. + */ + public abstract boolean equals(TraceAnalyserRule rule); + + + /** + * getLimits. + * @return all limits that are defined for rule + */ + public abstract int[] getLimits(); +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/TraceInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/TraceInfo.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,217 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.export; + +import java.io.BufferedReader; +import java.io.IOException; + +import com.nokia.traceviewer.engine.TraceInformation; + +/** + * class TraceInfo. + * Class that contains name and id numbers of one trace. + * + */ +public class TraceInfo { + + public static final String XML_COMPONENT_ID = "ComponentID"; + public static final String XML_GROUP_ID = "GroupID"; + public static final String XML_TRACE_ID = "TraceID"; + public static final String XML_TRACE_NAME = "TraceName"; + + /* TraceInformation object containing ComponentID, GroupID and TraceID */ + private TraceInformation idNumbers; + + /* Name of the Trace */ + private String traceName; + + /** + * TraceInfo. + * Constructor. + */ + public TraceInfo() { + idNumbers = new TraceInformation(); + traceName = ""; + } + + /** + * getXMLString. + * Returns XML-string that is written to file when saving rule. + * @param itemName Name of the trace item. + * @param indent indent that is used. + * @return xml string. + */ + public String getXMLString(String itemName, int indent) { + String xml = ""; + String indentString = getIndentString(indent); + + xml += indentString + "<" + itemName + ">\n"; + + xml += indentString + " " + "<" + XML_COMPONENT_ID + "=\""; + xml += Integer.toHexString(idNumbers.getComponentId()); + xml += "\">\n"; + + xml += indentString + " " + "<" + XML_GROUP_ID + "=\""; + xml += Integer.toHexString(idNumbers.getGroupId()); + xml += "\">\n"; + + xml += indentString + " " + "<" + XML_TRACE_ID + "=\""; + xml += Integer.toHexString(idNumbers.getTraceId()); + xml += "\">\n"; + + xml += indentString + " " + "<" + XML_TRACE_NAME + "=\""; + xml += traceName; + xml += "\">\n"; + + xml += indentString + "\n"; + + return xml; + } + + /** + * readXMLBuffer. + * Reads xml trace information from bufferedReader and saves it into this object + * @param input bufferedReader + * @param searchTraceName name of the trace in buffer + * @throws IOException + * @throws NumberFormatException + */ + + public boolean readXMLBuffer(BufferedReader input, String searchTraceName) throws NumberFormatException, IOException{ + + String line = null; + + + // This while loop searches xml tags from file. When tag is found information is saved and + // new searchPhrase is updated. Tags are searched in order where they should be. + + String searchPhrase = searchTraceName; + while ((line = input.readLine()) != null) { + if (line.contains(searchPhrase)) { + if (searchPhrase.equals(searchTraceName)) { + searchPhrase = XML_COMPONENT_ID; + } + + + else if (searchPhrase.equals(XML_COMPONENT_ID)) { + Long id = Long.parseLong(GeneralMethods.getTextBetweenQuotes(line), 16); + idNumbers.setComponentId(id.intValue()); + searchPhrase = XML_GROUP_ID; + } + else if (searchPhrase.equals(XML_GROUP_ID)) { + idNumbers.setGroupId(Integer.parseInt(GeneralMethods.getTextBetweenQuotes(line), 16)); + searchPhrase = XML_TRACE_ID; + } + else if (searchPhrase.equals(XML_TRACE_ID)) { + idNumbers.setTraceId(Integer.parseInt(GeneralMethods.getTextBetweenQuotes(line), 16)); + searchPhrase = XML_TRACE_NAME; + } + else if (searchPhrase.equals(XML_TRACE_NAME)) { + String name = GeneralMethods.getTextBetweenQuotes(line); + setTraceName(name); + return true; + } + } + } + return false; + + } + + /** + * getIndentString. + * @param indent indent. + * @return string containing as many spaces as parameter states. + */ + protected String getIndentString(int indent){ + String indentString = ""; + while(indent > 0){ + indentString += " "; + indent--; + } + return indentString; + } + + /** + * getIdNumbers. + * @return id numbers of the trace. + */ + public TraceInformation getIdNumbers() { + return idNumbers; + } + + /** + * setIdNumbers. + * @param idNumbers + */ + public void setIdNumbers(TraceInformation idNumbers) { + this.idNumbers = idNumbers; + } + + /** + * getTraceName. + * @return name of the trace. + */ + public String getTraceName() { + return traceName; + } + + /** + * setTraceName. + * @param traceName + */ + public void setTraceName(String traceName) { + this.traceName = traceName; + } + + /** + * equals. + * compares two traceInfos + * @param traceB + * @return true if traceinfo objects are equal. + */ + public boolean equals(TraceInfo traceB){ + if(compareTraces(this.getIdNumbers(), traceB.getIdNumbers()) && + this.traceName.equals(traceB.getTraceName())){ + return true; + } + else{ + return false; + } + } + + + /** + * compareTraces. + * compares two traces. + * @param traceA Trace A + * @param traceB Trace B + * @return true if trace information was same. + */ + public static boolean compareTraces(TraceInformation traceA, TraceInformation traceB){ + if(traceA.getComponentId() == traceB.getComponentId() && + traceA.getGroupId() == traceB.getGroupId()&& + traceA.getTraceId() == traceB.getTraceId()){ + return true; + } + else{ + return false; + } + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/TraceSelectionComposite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/export/TraceSelectionComposite.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.export; + + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +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.Label; +import org.eclipse.swt.widgets.Text; + +import com.nokia.s60tools.traceanalyser.ui.dialogs.TraceSelectionDialog; +import com.nokia.traceviewer.engine.TraceInformation; +import com.nokia.traceviewer.engine.activation.TraceActivationTraceItem; + + +/** + * class TraceSelectionComposite. + * Class that can be used for creating UI-components for selecting trace. + * creates + */ +public class TraceSelectionComposite implements SelectionListener { + + /* UI-components */ + private Text textTrace; + private Composite compositeTraceSelection; + private GridData gridDataTraceSelection; + + /* Selected Trace item */ + private TraceInfo traceItem; + + /* selection listener */ + ITraceSelectionCompositeListener listener; + + /** + * TraceSelectionComposite. + * Constructor for Trace Selection component. + * @param composite composite where components are placed. + * @param traceName name for the label. + * @param listener trace item's change listener(optional). + */ + public TraceSelectionComposite(Composite composite, String traceName, ITraceSelectionCompositeListener listener ){ + + this.listener = listener; + + // create Composite for trace selection components + compositeTraceSelection = new Composite(composite, SWT.NONE); + GridLayout layoutTraceSelection = new GridLayout(); + layoutTraceSelection.numColumns = 2; + compositeTraceSelection.setLayout(layoutTraceSelection); + gridDataTraceSelection = new GridData(GridData.FILL_HORIZONTAL); + compositeTraceSelection.setLayoutData(gridDataTraceSelection); + + // create label + Label labelTrace = new Label(compositeTraceSelection, SWT.NONE); + labelTrace.setText(traceName); + GridData gridDataLabelTrace = new GridData(GridData.FILL_HORIZONTAL); + gridDataLabelTrace.horizontalSpan = 2; + labelTrace.setLayoutData(gridDataLabelTrace); + + // created trace name text field. + textTrace = new Text(compositeTraceSelection, SWT.BORDER); + GridData gridDataTextTrace = new GridData(SWT.FILL, SWT.CENTER, true, false); + textTrace.setToolTipText("Trace that is assigned for this rule."); + textTrace.setLayoutData(gridDataTextTrace); + textTrace.setEditable(false); + + // Create select trace button. + Button buttonSelectTrace = new Button(compositeTraceSelection, SWT.PUSH); + buttonSelectTrace.setText("Select Trace"); + buttonSelectTrace.addSelectionListener(this); + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(SelectionEvent arg0) { + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent arg0) { + // create dialog + TraceSelectionDialog dialog = new TraceSelectionDialog( compositeTraceSelection.getShell() ); + int retVal = dialog.open(); + // open query dialog + if( retVal == 0 ){ + //save trace; + TraceActivationTraceItem selectedItem = dialog.getSelectedTrace(); + + traceItem = new TraceInfo(); + TraceInformation idNumbers = new TraceInformation(); + idNumbers.setComponentId(selectedItem.getParent().getParent().getId()); + idNumbers.setGroupId(selectedItem.getParent().getId()); + idNumbers.setTraceId(selectedItem.getId()); + traceItem.setIdNumbers(idNumbers); + traceItem.setTraceName(selectedItem.getName()); + + this.updateTraceInfo(); + if(listener != null){ + listener.traceInfoUpdated(); + } + } + + // Cancel pressed + else if( retVal == 1 ){ + + } + } + + /** + * setVisible. + * Method that changes visibility of UI-components. + * @param value true, if components need to be shown. + */ + public void setVisible(boolean value){ + gridDataTraceSelection.exclude = !value; + compositeTraceSelection.setVisible(value); + + } + + /** + * updateTraceInfo. + * updates trace info into trace text box. + */ + private void updateTraceInfo(){ + if( traceItem != null){ + String text = traceItem.getTraceName(); + + // if trace name is null, set trace id numbers into text box + if(text == null || text.equals("null")){ + text = "Trace name not found( ComponentID = "; + text += Integer.toHexString(traceItem.getIdNumbers().getComponentId()); + text += ", GroupID = "; + text += Integer.toHexString(traceItem.getIdNumbers().getGroupId()); + text += ", TraceID = "; + text += Integer.toHexString(traceItem.getIdNumbers().getTraceId()); + text += " )"; + } + this.textTrace.setText(text); + } + } + + /** + * getTraceInformation. + * @return selected trace item. + */ + public TraceInfo getTraceInformation(){ + return traceItem; + + } + + + /** + * SetTraceItem. + * Sets trace item and updates + * @param traceItem a new trace item. + */ + public void setTraceItem(TraceInfo traceItem) { + this.traceItem = traceItem; + updateTraceInfo(); + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/interfaces/ITraceAnalyserFileObserver.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/interfaces/ITraceAnalyserFileObserver.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.interfaces; + +/** + * interface ITraceAnalyserFileObserver. + * interface that Trace Analyser File managers use when "read files"- operation is finished. + */ +public interface ITraceAnalyserFileObserver { + /** + * rulesUpdated. + * Rules are updated and all rules need to be reread. + */ + public void rulesUpdated(); + + /** + * ruleUpdated. + * One rule's history has been changed. + */ + public void ruleUpdated(String ruleName); + + /** + * failLogUpdated. + * Fail log is updated. + */ + public void failLogUpdated(); + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/Engine.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/Engine.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,314 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.model; + +import java.util.ArrayList; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + + +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver; +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; +import com.nokia.s60tools.traceanalyser.ui.views.MainView; + +/** + * class engine. + * Engine of Trace Analyser extension. + */ + +public class Engine implements ITraceAnalyserFileObserver { + + /* Fail Log Manager */ + private FailLogManager failLogManager; + + /* Rule Manager */ + private RuleManager ruleManager; + + /* Trace Listener */ + private TraceListener traceListener; + + /* list of rule types */ + ArrayList ruleTypes; + + /* Main view */ + MainView mainView; + + /** + * Engine. + * constructor. + */ + public Engine(){ + + // Get rule types + ruleTypes = new ArrayList(); + getRuleTypeArray(); + + // create fail log manager + failLogManager = new FailLogManager(this); + + // create rule manager + ruleManager = new RuleManager(this, ruleTypes); + + // create trace listener + traceListener = new TraceListener(this); + + // refresh fail log and rule information. + failLogManager.refresh(); + ruleManager.refresh(); + } + + /** + * setMainView. + * @param mainView main view. + */ + public void setMainView(MainView mainView){ + this.mainView = mainView; + } + + + /** + * getRuleArray. + * Searches for rule type plug-ins and creates rule array from them. + */ + private void getRuleTypeArray(){ + + final String EXTENSION_TRACE_ANALYSER_RULE = "traceanalyserrule"; //$NON-NLS-1$ + + try { + IExtensionRegistry er = Platform.getExtensionRegistry(); + IExtensionPoint ep = + er.getExtensionPoint(TraceAnalyserPlugin.PLUGIN_ID, EXTENSION_TRACE_ANALYSER_RULE); + IExtension[] extensions = ep.getExtensions(); + + // if plug-ins were found. + if (extensions != null && extensions.length > 0) { + + // read all found rules + for (int i = 0; i < extensions.length; i++) { + IConfigurationElement[] ce = extensions[i].getConfigurationElements(); + if (ce != null && ce.length > 0) { + try { + ITraceAnalyserRuleType provider = (ITraceAnalyserRuleType)ce[0].createExecutableExtension("class"); + if (provider != null) { + ruleTypes.add(provider); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * getFailLog + * @return fail log + */ + public RuleEvent[] getFailLog(){ + return failLogManager.getTraceAnalyserFailLog(); + } + + /** + * refreshFailLog. + * Refreshes Fail log + */ + public void refreshFailLog(){ + failLogManager.refresh(); + } + + /** + * clearFailLog. + * Clears fail log. + */ + public void clearFailLog(){ + failLogManager.clearLog(); + } + + /** + * addFailLogItem. + * @param item, new fail log item. + */ + public void addFailLogItem(RuleEvent item){ + failLogManager.addItem(item); + if(mainView != null){ + mainView.blinkIcon(); + } + } + + /** + * stop. + * Stops Trace Analyser Engine. + */ + public void stop(){ + failLogManager.saveLogToFile(); + ruleManager.saveData(); + traceListener.stopListening(); + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver#failLogUpdated() + */ + public void failLogUpdated() { + if(mainView != null){ + mainView.failLogUpdated(); + } + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver#rulesUpdated() + */ + public void rulesUpdated() { + TraceAnalyserRule[] rules = ruleManager.getActivatedRules(); + traceListener.setRules(rules); + if(mainView != null){ + mainView.rulesUpdated(); + } + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver#ruleUpdated(java.lang.String) + */ + public void ruleUpdated(String ruleName) { + if(mainView != null){ + mainView.ruleUpdated(ruleName); + } + } + + /** + * refreshRuleList. + * Refreshes rule list. + */ + public void refreshRuleList(){ + ruleManager.refresh(); + } + + /** + * getRuleInformation. + * @return Trace analyser rules. + */ + public RuleInformation[] getRuleInformation(){ + return ruleManager.getRuleInformation(); + } + + /** + * getRule. + * returns one rule. + * @param ruleName name of the rule that is requested. + * @return rule + */ + public TraceAnalyserRule getRule(String ruleName){ + return ruleManager.getRule(ruleName); + } + + /** + * getRuleTypes. + * @return Trace Analyser Rule Types + */ + public ArrayList getRuleTypes() { + return ruleTypes; + } + + /** + * addRule. + * @param newRule new Trace Analyser rule + * @return true if rule was added succesfully. + */ + public boolean addRule(TraceAnalyserRule newRule){ + boolean retval = ruleManager.addRule(newRule); + traceListener.setRules(ruleManager.getActivatedRules()); + return retval; + } + + + /** + * getTraceListener. + * @return trace listener + */ + public TraceListener getTraceListener() { + return traceListener; + } + + /** + * changeRuleaActivation. + * @param ruleName name of the rule + */ + public void changeRuleaActivation(String ruleName, boolean value){ + ruleManager.changeRuleActivation(ruleName, value); + TraceAnalyserRule[] rules = ruleManager.getActivatedRules(); + traceListener.setRules(rules); + } + /** + * removeRule + * @param ruleName rule that should be removed. + * @return true if rule was removed successfully. + */ + public boolean removeRule(String ruleName){ + return ruleManager.removeRule(ruleName); + } + + /** + * addRuleEvent. + * @param ruleName name of rule where event is added. + * @param event rule that event is added into. + */ + public void addRuleEvent(String ruleName, RuleEvent event){ + ruleManager.addHistoryEvent(ruleName, event); + } + + /** + * resets all rules history data. + */ + public void resetHistory(){ + ruleManager.clearHistory(); + } + + /** + * resets one rules history. + * @param ruleName + */ + public void resetOneRulesHistory(String ruleName){ + ruleManager.clearOneRulesHistory(ruleName); + } + + /** + * ruleExists. + * @param ruleName name of the rule + * @return true if rule with that name already exists + */ + + public boolean ruleExists(String ruleName){ + return ruleManager.ruleExists(ruleName); + } + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/FailLogManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/FailLogManager.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,243 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.model; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.*; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.ILock; + + +import com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver; +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; + + +/** + * This class is responsible for providing Trace Analyser Fail Log items to MainView's content provider. + */ +public class FailLogManager extends Job { + + /* file observer */ + ITraceAnalyserFileObserver filesObserver = null; + + /* accesslock */ + ILock accessLock = null; + + /* boolean value that is true when job is on-going */ + boolean jobRunning = false; + + /* list of fails */ + //ArrayList failLog; + ArrayList failLog; + + + /** + * TraceAnalyserFileManager. + * Constructor. + * @param observer observer, which is notified when reading is finished. + */ + public FailLogManager( ITraceAnalyserFileObserver observer ) { + super("Trace Analyser - Reading Fail Log"); + filesObserver = observer; + accessLock = Job.getJobManager().newLock(); + failLog = null; + } + + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + + accessLock.acquire(); + jobRunning = true; + + // if log has not yet been read, read it now. + if(failLog == null){ + loadLogFromFile(); + } + // notify main view that reading finished. + if(filesObserver != null){ + filesObserver.failLogUpdated(); + } + jobRunning = false; + accessLock.release(); + + return Status.OK_STATUS; + } + + + /** + * getTraceAnalyserFailLog. + * Method that returns read violations from fail log. + * If fails are not read method starts reading them. + * @return array containing all fail events. + */ + public RuleEvent[] getTraceAnalyserFailLog() { + // files have not yet been read, start reading process + if (failLog == null ) { + if(!jobRunning){ + jobRunning = true; + setPriority(Job.LONG); + setUser(false); + schedule(100); + } + RuleEvent[] cFiles = new RuleEvent[0]; + + + return cFiles; + } + else{ + return failLog.toArray(new RuleEvent[failLog.size()]); + + } + + } + + /** + * addItem. + * adds one item to fail log. + * @param newItem + */ + public void addItem(RuleEvent newItem){ + if(failLog != null){ + failLog.add(0,newItem); + } + if(filesObserver != null){ + filesObserver.failLogUpdated(); + } + } + + public void clearLog(){ + failLog.clear(); + if(filesObserver != null){ + filesObserver.failLogUpdated(); + } + } + + /** + * refresh. + * Refresh rule list. + */ + public void refresh() { + + accessLock.acquire(); + try { + if (!jobRunning){ + jobRunning = true; + setPriority(Job.LONG); + setUser(false); + schedule(100); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + accessLock.release(); + } + } + + /** + * getPluginWorkingLocation. + * Returns a path where Rule plug-in can do various tasks (located under workspace). + */ + private String getFailLogFileName() { + IPath location = Platform.getStateLocation( TraceAnalyserPlugin.getDefault().getBundle()); + return location.toOSString() + "//FailLog.log"; + } + + /** + * saveLogToFile. + * Saves fail log into file system. + */ + public void saveLogToFile(){ + try { + + OutputStream file = new FileOutputStream(getFailLogFileName()); + OutputStream buffer = new BufferedOutputStream(file); + ObjectOutput output = new ObjectOutputStream(buffer); + try { + // serialize fail list. + output.writeObject(failLog); + } finally { + output.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + /** + * loadLogFromFile. + * Loads fail list from file system. + */ + private void loadLogFromFile() { + try { + // use buffering + InputStream file = new FileInputStream(getFailLogFileName()); + InputStream buffer = new BufferedInputStream(file); + ObjectInput input = new ObjectInputStream(buffer); + try { + // deserialize the List + failLog = (ArrayList) input.readObject(); + + } finally { + input.close(); + if(failLog == null){ + failLog = new ArrayList(); + } + } + } catch (ClassNotFoundException ex) { + ex.printStackTrace(); + failLog = new ArrayList(); + + } catch (IOException ex) { + failLog = new ArrayList(); + + } + } + + /** + * setObserver. + * Sets observer. + * @param filesObserver, new observer. + */ + public void setObserver(ITraceAnalyserFileObserver filesObserver){ + this.filesObserver = filesObserver; + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/RuleManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/RuleManager.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,429 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.model; + +import java.util.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.ILock; + +import com.nokia.s60tools.traceanalyser.containers.DummyRule; +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.export.RuleEvent.RuleStatus; +import com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver; + + +/** + * This class is responsible for providing Trace Analyser rules and history data to MainView's content provider. + * Class calls every rule types getRules-method to get every Trace Analyser Rule rule. + * After that class calls each rules getHistoryData method to get history data. + */ +public class RuleManager extends Job { + + /* file observer */ + ITraceAnalyserFileObserver engine = null; + + /* accesslock */ + ILock accessLock = null; + + /* boolean value that is true when job is on-going */ + boolean jobRunning = false; + + /* List of rule types */ + ArrayList ruleTypes = null; + + /* HashMap containing each rule and its history data. */ + HashMap history = null; + + /** + * TraceAnalyserFileManager. + * Constructor. + * @param engine, engine which is notified when reading is finished. + * @param ruleTypes, ArrayList, which contains all rule types. + */ + public RuleManager( ITraceAnalyserFileObserver engine, ArrayList ruleTypes ) { + super("Trace Analyser - Reading Rules"); + this.engine = engine; + accessLock = Job.getJobManager().newLock(); + jobRunning = false; + this.ruleTypes = ruleTypes; + } + + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + + accessLock.acquire(); + + // if history has never been read, read it now. + if(history == null){ + + history = new HashMap(); + ArrayList ruleArray = new ArrayList(); + + // read rules + for(ITraceAnalyserRuleType item : ruleTypes){ + ruleArray.addAll(item.getRules()); + } + + // Read History. + for(TraceAnalyserRule item : ruleArray){ + + // Get history data from rule + RuleInformation information = new RuleInformation(item); + information.setEvents(item.readHistory()); + + // count history data(amount off passes, fails....) + countHistory(information); + history.put(item.getName(), information); + } + } + engine.rulesUpdated(); + accessLock.release(); + jobRunning = false; + return Status.OK_STATUS; + } + + + + /** + * getRuleInformation. + * Method that returns reads rules and history . If rules are not read method starts reading them. + * @return Rules and History data, or dummy object if job is on-going. + */ + public RuleInformation[] getRuleInformation() { + // files have not yet been read, start reading process + if (history == null) { + + if( jobRunning == false ){ + jobRunning = true; + setPriority(Job.LONG); + setUser(false); + schedule(100); + } + RuleInformation[] cFiles = new RuleInformation[1]; + DummyRule dummyRule = new DummyRule("Loading rules and history..."); + cFiles[0] = new RuleInformation(dummyRule); + return cFiles; + } + else{ + return history.values().toArray(new RuleInformation[history.size()]); + } + + } + + + + + /** + * refresh. + * Resfresh rule list. + */ + public void refresh() { + + accessLock.acquire(); + try { + if (!jobRunning) { + jobRunning = true; + setPriority(Job.LONG); + setUser(false); + schedule(100); + } + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + accessLock.release(); + } + } + + /** + * addRule. + * Adds new rule. + * @param newRule rule that should be added. + * @return true if rule was added(file operations successful) + */ + public boolean addRule(TraceAnalyserRule newRule){ + accessLock.acquire(); + if(history.containsKey(newRule.getName())){ + accessLock.release(); + return false; + } + else{ + history.put(newRule.getName(),new RuleInformation(newRule)); + accessLock.release(); + return true; + } + } + + /** + * changeRuleActivation + * @param ruleName name of the rule + + */ + public void changeRuleActivation(String ruleName, boolean value){ + RuleInformation information = history.get(ruleName); + if(information != null){ + information.getRule().setActivated(value); + + } + } + + + /** + * removeRule. + * Removes rule + * @param ruleName rule that should be removed. + * @return true if rule was removed(file operations successful) + */ + public boolean removeRule(String ruleName){ + accessLock.acquire(); + + RuleInformation item = history.get(ruleName); + boolean deleteComplete = item.delete(); + if( deleteComplete ){ + history.remove(ruleName); + } + accessLock.release(); + return deleteComplete; + + + } + + + /** + * saveHistory. + * Saves history data into each rule. + */ + @SuppressWarnings("unchecked") + public void saveData(){ + Set set = history.entrySet(); + Iterator i = set.iterator(); + int index = 0; + + + + while (i.hasNext()) { + Map.Entry me = (Map.Entry) i.next(); + RuleInformation information = (RuleInformation) me.getValue(); + if(!information.getRule().writeXML()){ + System.out.println("Unable to save rule definitions" + + information.getRule().getName()); + } + if (!information.getRule().saveHistory(information.getEvents())) { + System.out.println("Unable to save history data on rule" + + information.getRule().getName()); + } + + index++; + } + } + + /** + * getActivatedRules. + * @return array of all activated rules. + */ + @SuppressWarnings("unchecked") + public TraceAnalyserRule[] getActivatedRules() { + accessLock.acquire(); + TraceAnalyserRule[] ruleArray = null; + ArrayList rules = new ArrayList(); + if(history != null){ + //ruleArray = new TraceAnalyserRule[history.size()]; + Set set = history.entrySet(); + Iterator i = set.iterator(); + int index = 0; + while (i.hasNext()) { + Map.Entry me = (Map.Entry) i.next(); + TraceAnalyserRule rule = ((RuleInformation) me.getValue()).getRule(); + if(rule.isActivated()){ + rules.add(rule); + } + //ruleArray[index] = ((RuleInformation) me.getValue()).getRule().isActivated(); + index++; + } + ruleArray = rules.toArray(new TraceAnalyserRule[rules.size()]); + + } + else{ + ruleArray = new TraceAnalyserRule[0]; + } + accessLock.release(); + return ruleArray; + } + + /** + * addHistoryEvent. + * Adds new history event. + * @param ruleName name of the rule where event is added. + * @param event history event. + */ + public void addHistoryEvent(String ruleName, RuleEvent event){ + accessLock.acquire(); + RuleInformation item = history.get(ruleName); + item.getEvents().add(event); + countHistory(item); + engine.ruleUpdated(ruleName); + accessLock.release(); + + } + + + /** + * countHistory. + * Counts history values. + * @param information rule which history values are counted. + */ + private void countHistory(RuleInformation information){ + ArrayList events = information.getEvents(); + + int pass = 0; + int fail = 0; + int min = 0; + int max = 0; + int sum = 0; + + int[] values = new int[events.size()]; + + for(int i = 0; i < events.size(); i++){ + + + RuleEvent event = events.get(i); + + // if first event set as max and min value. + if(i == 0){ + min = event.getValue(); + max = event.getValue(); + } + else{ + // if event value is smaller than min value set event value as min. + if(event.getValue() < min){ + min = event.getValue(); + } + // if event value is greater than max value set event value as max. + else if(event.getValue() > max){ + max = event.getValue(); + } + } + + // count passes and fails. + if(event.getStatus() == RuleStatus.PASS){ + pass++; + } + else{ + fail++; + } + + // count sum and add value to value-array. + sum += event.getValue(); + values[i] = event.getValue(); + } + information.setPass(pass); + information.setFail(fail); + information.setMin(min); + information.setMax(max); + + // count average based on sum of values. + if(events.size() > 0){ + information.setAvg(sum/events.size()); + } + + // count median based on value-array. + if(values.length > 0){ + Arrays.sort(values); + information.setMed(values[values.length/2]); + } + + } + + + /** + * clearHistory. + * Clears history data about each rule. + */ + @SuppressWarnings("unchecked") + public void clearHistory(){ + Set set = history.entrySet(); + Iterator i = set.iterator(); + + int index = 0; + + while (i.hasNext()) { + Map.Entry me = (Map.Entry) i.next(); + ((RuleInformation) me.getValue()).setEvents(new ArrayList()); + countHistory((RuleInformation) me.getValue()); + index++; + } + engine.rulesUpdated(); + } + + /** + * clearOneRulesHistory. + * Clears history data about one rule. + * @param ruleName rule that's history is cleared. + */ + public void clearOneRulesHistory(String ruleName){ + RuleInformation information = history.get(ruleName); + information.setEvents(new ArrayList()); + countHistory(information); + engine.ruleUpdated(ruleName); + + } + + /** + * ruleExists. + * @param ruleName name of the rule + * @return true if rule with that name already exists + */ + public boolean ruleExists(String ruleName){ + if(history.get(ruleName) != null){ + return true; + } + else{ + return false; + } + } + + + /** + * getRule. + * returns one rule. + * @param ruleName name of the rule that is requested. + * @return rule + */ + public TraceAnalyserRule getRule(String ruleName){ + RuleInformation information = history.get(ruleName); + if(information != null){ + return information.getRule(); + } + else{ + return null; + } + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/StartupHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/StartupHandler.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.model; + +import org.eclipse.ui.IStartup; + +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; + +/** + * Startup handler is called when Carbide is started. + * Engine is started when carbide starts. + * + */ + +public class StartupHandler implements IStartup { + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IStartup#earlyStartup() + */ + public void earlyStartup() { + TraceAnalyserPlugin.startEngine(); + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/TraceListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/TraceListener.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.model; + + +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.export.RuleEvent.RuleStatus; +import com.nokia.traceviewer.api.DPLocation; +import com.nokia.traceviewer.api.TraceViewerAPI; +import com.nokia.traceviewer.api.TraceViewerAPI.TVAPIError; +import com.nokia.traceviewer.engine.TraceProperties; +import com.nokia.traceviewer.engine.dataprocessor.DataProcessor; + +/** + * class TraceListener. + * Class that is responsible for listening to trace. + */ +public class TraceListener implements DataProcessor { + + /* Trace Analyser engine */ + Engine engine; + + /* Rule array */ + TraceAnalyserRule[] rules = null; + + /** + * TraceListener. + * constructor. + * @param engine Trace Analyser Engine. + */ + public TraceListener(Engine engine){ + this.engine = engine; + //Add DataProcessor to TraceViewer + TVAPIError error = TVAPIError.NONE; + error = TraceViewerAPI.addDataProcessor(this, DPLocation.AFTER_VIEW, 50); // CodForChk_Dis_Magic + + // Check error code + if( error != TVAPIError.NONE ){ + System.out.println("Unable to add dataprocessor to TraceViewer"); + + } + } + + /** + * stopListening. + * stops listening to trace. + */ + public void stopListening(){ + //Add DataProcessor to TraceViewer + TVAPIError error = TVAPIError.NONE; + error = TraceViewerAPI.removeDataProcessor(this); + + // Check error code + if( error != TVAPIError.NONE ){ + System.out.println("Unable to remove dataprocessor from TraceViewer"); + } + } + + + /* + * (non-Javadoc) + * @see com.nokia.traceviewer.engine.dataprocessor.DataProcessor#processData(com.nokia.traceviewer.engine.TraceProperties) + */ + public void processData(TraceProperties traceEvent) { + + // Make sure that this is not scrolled trace + if(! traceEvent.traceConfiguration.isScrolledTrace()){ + if(rules != null){ + + // forwards trace to all rules and if rule some rule event is detected it is sent to engine and fail log. + for(TraceAnalyserRule rule:rules){ + + // Check rule status. + RuleEvent event = rule.checkRuleStatus(traceEvent); + + + if(event.getStatus() == RuleStatus.FAIL){ + + // if rule failed, create add item to fail log log item. + engine.addFailLogItem(event); + } + if(event.getStatus() != RuleStatus.NONE){ + // is some event(either fail or pass) is detected, sent it to engine. + engine.addRuleEvent(rule.getName(), event); + } + } + } + } + } + + /** + * setRules. + * @param traceAnalyserRules new rule array. + */ + public void setRules(TraceAnalyserRule[] traceAnalyserRules) { + this.rules = traceAnalyserRules; + } + + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/UserEnteredData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/model/UserEnteredData.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.model; + +import org.eclipse.jface.dialogs.IDialogSettings; + +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; + +/** + * This class is used to save and restore data which is entered by user in + * wizard pages. + * + */ +public class UserEnteredData { + + // section names + public static final String SECTION_SELECT_TRACE = "TraceSelectionDialog"; + public static final String PREVIOUS_DICTIONARY = "PreviousDictionary"; + public static final String PREVIOUS_GROUP = "PreviousGroup"; + + public static enum ValueTypes { PREVIOUS_GROUP, + PREVIOUS_DICTIONARY } + + + + /** + * getString + * gets string value from correct section + * @param valueType type of string + * @return String value + */ + + public String getString( ValueTypes valueType) { + try { + String retval = ""; + + // get value from correct section + switch(valueType){ + case PREVIOUS_DICTIONARY:{ + IDialogSettings section = getSection(SECTION_SELECT_TRACE); + if (section != null) { + retval = section.get(PREVIOUS_DICTIONARY); + + } + break; + + } + case PREVIOUS_GROUP:{ + IDialogSettings section = getSection(SECTION_SELECT_TRACE); + if (section != null) { + retval = section.get(PREVIOUS_GROUP); + } + break; + } + + + default:{ + break; + } + } + return retval; + } catch (Exception e) { + return ""; + } + } + + /** + * saveString + * saves string value into correct section. + * @param valueType type of string + * @param value value that is saved + */ + + public void saveString(ValueTypes valueType, String value) { + try { + + // save value into correct section + + switch(valueType){ + case PREVIOUS_DICTIONARY:{ + IDialogSettings section = getSection(SECTION_SELECT_TRACE); + if (section != null) { + section.put(PREVIOUS_DICTIONARY, value); + } + break; + } + case PREVIOUS_GROUP:{ + IDialogSettings section = getSection(SECTION_SELECT_TRACE); + if (section != null) { + section.put(PREVIOUS_GROUP, value); + } + break; + } + + default:{ + break; + } + } + + + } catch (Exception E) { + // No actions needed + } + } + + + /** + * Returns wanted section + * @param section name of the wanted section + * @return wanted section + */ + protected IDialogSettings getSection(String section) { + IDialogSettings retVal = null; + if (TraceAnalyserPlugin.getDefault().getDialogSettings() != null) { + retVal = TraceAnalyserPlugin.getDefault().getDialogSettings().getSection(section); + if (retVal == null) { + retVal = TraceAnalyserPlugin.getDefault().getDialogSettings().addNewSection(section); + } + } + return retVal; + } +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/plugin/TraceAnalyserPlugin.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/plugin/TraceAnalyserPlugin.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.plugin; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.jobs.ILock; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import com.nokia.s60tools.traceanalyser.model.Engine; +import com.nokia.s60tools.traceanalyser.resources.ImageResourceManager; +import com.nokia.s60tools.traceanalyser.ui.views.MainView; + + +/** + * The activator class controls the plug-in life cycle + */ +public class TraceAnalyserPlugin extends AbstractUIPlugin { + + /* Access lock */ + private static ILock accessLock = null; + + /* Install path of Plugin */ + private String pluginInstallPath = ""; + + /* Main view of Trace Analyser */ + private static MainView mainView; + + /* Engine of Trace Analyser */ + private static Engine engine; + + // The plug-in ID + public static final String PLUGIN_ID = "com.nokia.s60tools.traceanalyser"; + + // The shared instance + private static TraceAnalyserPlugin plugin; + + /** + * TraceAnalyserPlugin. + * The constructor + */ + public TraceAnalyserPlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + String pluginInstallLocation = getPluginInstallPath(); + + String imagesPath = getImagesPath(pluginInstallLocation); + + // Loading images required by this plug-in + ImageResourceManager.loadImages(imagesPath); + + accessLock = Job.getJobManager().newLock(); + + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + engine.stop(); + plugin = null; + super.stop(context); + } + + /** + * getDefault. + * Returns the shared instance + * @return the shared instance + */ + public static TraceAnalyserPlugin getDefault() { + return plugin; + } + + /** + * getImageDescriptor. + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + + /** + * getPluginInstallPath + * @return the path where this plugin is installed + */ + public static String getPluginInstallPath() { + try { + if ( plugin.pluginInstallPath.equals("") ) { //$NON-NLS-1$ + // URL to the plugin's root ("/") + URL relativeURL = plugin.getBundle().getEntry("/"); //$NON-NLS-1$ + // Converting into local path + URL localURL = FileLocator.toFileURL(relativeURL); + // Getting install location in correct form + File f = new File(localURL.getPath()); + plugin.pluginInstallPath = f.getAbsolutePath(); + } + return plugin.pluginInstallPath; + } catch (Exception e) { + return ""; //$NON-NLS-1$ + } + } + + /** + * getImagesPath. + * Gets images path relative to given plugin install path. + * @param pluginInstallPath Plugin installation path. + * @return Path were image resources are located. + * @throws IOException + */ + private String getImagesPath(String pluginInstallPath) throws IOException{ + return pluginInstallPath + + File.separatorChar + "icons"; //$NON-NLS-1$ + } + + /** + * startEngine. + * Starts Trace Analyser's engine. + */ + public static void startEngine(){ + accessLock.acquire(); + if(engine == null){ + engine = new Engine(); + } + accessLock.release(); + } + + /** + * getEngine + * getter for engine. If engine is not yet started this method starts it. + * @return + */ + public static Engine getEngine(){ + startEngine(); + return engine; + } + + /** + * getMainView. + * @return main view of Trace Analyser + */ + public static MainView getMainView() { + return mainView; + } + + /** + * setMainView. + * @param newMainView new main view. + */ + public static void setMainView(MainView newMainView) { + mainView = newMainView; + if(engine != null){ + engine.setMainView(mainView); + } + } + + + /** + * resets engine + */ + public static Engine restartEngine(){ + engine = new Engine(); + return engine; + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/resources/HelpContextIDs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/resources/HelpContextIDs.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.resources; + +/** + * IDs for context sensitive help. + * @see contexts.xml -file IDs links to + */ +public class HelpContextIDs { + + /** + * The plug-in ID. + */ + private static final String TRACE_ANALYSER_PROJECT_PLUGIN_ID = "com.nokia.s60tools.traceanalyser.help"; + + /** + * ID to Trace Analyser Help TOC + */ + + + public static final String TRACE_ANALYSER_MAIN_VIEW = + TRACE_ANALYSER_PROJECT_PLUGIN_ID +".TRACE_ANALYSER_MAIN_VIEW"; + + public static final String TRACE_ANALYSER_HISTORY_VIEW= + TRACE_ANALYSER_PROJECT_PLUGIN_ID +".TRACE_ANALYSER_HISTORY_VIEW"; + + public static final String TRACE_ANALYSER_FAIL_LOG = + TRACE_ANALYSER_PROJECT_PLUGIN_ID +".TRACE_ANALYSER_FAIL_LOG"; + + public static final String TRACE_ANALYSER_RULE_EDITOR = + TRACE_ANALYSER_PROJECT_PLUGIN_ID +".TRACE_ANALYSER_RULE_EDITOR"; + + public static final String TRACE_ANALYSER_TRACE_SELECTION_DIALOG = + TRACE_ANALYSER_PROJECT_PLUGIN_ID +".TRACE_ANALYSER_TRACE_SELECTION_DIALOG"; + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/resources/ImageKeys.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/resources/ImageKeys.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.resources; + +public class ImageKeys { + public static final String IMG_APP_ICON = "TRACE_ANALYSER_IMG_APP_ICON"; + public static final String IMG_CLEAR_ALL = "TRACE_ANALYSER_IMG_CLEAR_ALL"; + public static final String IMG_CREATE_NEW = "TRACE_ANALYSER_IMG_CREATE_NEW"; + public static final String IMG_FAIL_RECEIVED = "TRACE_ANALYSER_IMG_FAIL_RECEIVED"; + public static final String IMG_CLEAR_FAIL_LOG = "TRACE_ANALYSER_IMG_CLEAR_FAIL_LOG"; + public static final String IMG_TRACE_ANALYSER_BANNER = "TRACE_ANALYSER_IMG_APP_ICON_BANNER"; + +} \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/resources/ImageResourceManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/resources/ImageResourceManager.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,74 @@ +/* +* ============================================================================ +* Revision : $Rev:$ +* +* Copyright © 2009 Nokia. All rights reserved. +* This material, including documentation and any related computer +* programs, is protected by copyright controlled by Nokia. All +* rights are reserved. Copying, including reproducing, storing, +* adapting or translating, any or all of this material requires the +* prior written consent of Nokia. This material also contains +* confidential information which may not be disclosed to others +* without the prior written consent of Nokia. +============================================================================ +*/ + +package com.nokia.s60tools.traceanalyser.resources; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + + +/** + * Class for handling Trace Analyser icons. + * + */ +public class ImageResourceManager { + + public static void loadImages(String imagesPath){ + + Display disp = Display.getCurrent(); + + ImageRegistry imgReg = JFaceResources.getImageRegistry(); + + // + // Storing images to image registry + // + + /******************************************************************************* + * Copyright for the following group of images. + * Copyright ©2009 Nokia Corporation. All rights reserved. + *******************************************************************************/ + Image img = new Image( disp, imagesPath + "\\TraceAnalyser.png" ); + imgReg.put( ImageKeys.IMG_APP_ICON, img ); + + img = new Image( disp, imagesPath + "\\ClearAllCounters.png" ); + imgReg.put( ImageKeys.IMG_CLEAR_ALL, img ); + + img = new Image( disp, imagesPath + "\\CreateNewRule.png" ); + imgReg.put( ImageKeys.IMG_CREATE_NEW, img ); + + img = new Image( disp, imagesPath + "\\FailReceived.png" ); + imgReg.put( ImageKeys.IMG_FAIL_RECEIVED, img ); + + img = new Image( disp, imagesPath + "\\ClearFailLog.png" ); + imgReg.put( ImageKeys.IMG_CLEAR_FAIL_LOG, img ); + + img = new Image( disp, imagesPath + "\\TraceAnalyser_banner.png" ); + imgReg.put( ImageKeys.IMG_TRACE_ANALYSER_BANNER, img ); + + } + + public static ImageDescriptor getImageDescriptor( String key ){ + ImageRegistry imgReg = JFaceResources.getImageRegistry(); + return imgReg.getDescriptor( key ); + } + + public static Image getImage( String key ){ + ImageRegistry imgReg = JFaceResources.getImageRegistry(); + return imgReg.get(key); + } +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/actions/ToolbarShortcutAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/actions/ToolbarShortcutAction.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import com.nokia.s60tools.traceanalyser.ui.views.MainView; + + +/** + * Action for toolbar and import shortcuts that launch Trace Analyser + * @see IWorkbenchWindowActionDelegate + */ +public class ToolbarShortcutAction implements IWorkbenchWindowActionDelegate { + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + // Open Trace Analyser Main View + MainView.showAndReturnYourself(); + + } + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + // nothing to be done + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + // nothing to be done + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + // nothing to be done + } +} \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/dialogs/EditRuleDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/dialogs/EditRuleDialog.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,453 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.ui.dialogs; + +import java.util.ArrayList; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType; +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleTypeListener; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.model.Engine; +import com.nokia.s60tools.traceanalyser.resources.ImageKeys; +import com.nokia.s60tools.traceanalyser.resources.ImageResourceManager; + + +/** + * class Edit rule dialog + * Dialog that can be used for editing rule's definitions. + */ +public class EditRuleDialog extends TitleAreaDialog implements SelectionListener, ModifyListener, ITraceAnalyserRuleTypeListener { + + Composite contents; + + /* UI-Components */ + private Group groupConstComponents; + + /* Rule Type related components */ + private Composite compositeRuleType; + private Label labelRuleType; + private Combo comboRuleType; + + /* Rule Name related components */ + private Composite compositeRuleName; + private Label labelRuleName; + private Text textRuleName; + + /* Rule Description relates components */ + private Composite compositeRuleDescription; + private Label labelRuleDescription; + private Text textRuleDescription; + + /* Rule type that is currently opened */ + private ITraceAnalyserRuleType shownRule; + + /* All rule types */ + private ArrayList rules; + + /* Group for Rule plugins own UI-components */ + private Group groupAdditionalComponents; + + /* Rule that is used when formatting values to ui-components.*/ + private TraceAnalyserRule rule; + + private Engine engine; + + private boolean createNewRule = false; + + private String oldRuleName = null; + + /** + * TraceSelectionDialog. + * Constructor. + * @param parentShell + */ + public EditRuleDialog(Shell parentShell, ArrayList rules, TraceAnalyserRule rule, Engine engine, boolean createNewRule) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.RESIZE); + this.rules = rules; + this.rule = rule; + this.engine = engine; + this.createNewRule = createNewRule; + if(createNewRule == false){ + oldRuleName = rule.getName(); + } + } + + + @Override + /** + * createDialogArea. + * Method that places ui components into give composite. + */ + protected Control createDialogArea(Composite parent) { + + getShell().setText("Edit Rule"); + setTitle("Edit Rule Definitions"); + + setTitleImage(ImageResourceManager.getImage(ImageKeys.IMG_TRACE_ANALYSER_BANNER)); + + // Set the minimum size for dialog + getShell().setMinimumSize(new Point( 550, 500)); + + // create composite where all components are placed + contents = new Composite(parent, SWT.NONE); + GridLayout contentsLayout = new GridLayout(); + contentsLayout.numColumns = 1; + contents.setLayout(contentsLayout); + contents.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // create group for components that are present for every rule type. + groupConstComponents = new Group(contents, SWT.NONE); + GridLayout layoutGroupConstComponents = new GridLayout(); + layoutGroupConstComponents.numColumns = 1; + groupConstComponents.setLayout(layoutGroupConstComponents); + GridData gridDataGroupConstComponents = new GridData(GridData.FILL_HORIZONTAL); + groupConstComponents.setLayoutData(gridDataGroupConstComponents); + groupConstComponents.setText("Basic Settings"); + + + // create ui components that are present for every rule type. + this.createConstComponents(groupConstComponents); + + // create Group for additional components + groupAdditionalComponents = new Group(contents, SWT.NONE); + GridLayout layoutGroupAdditionalComponents = new GridLayout(); + layoutGroupAdditionalComponents.numColumns = 1; + groupAdditionalComponents.setLayout(layoutGroupAdditionalComponents); + groupAdditionalComponents.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + groupAdditionalComponents.setText("Rule type specific settings"); + + + // Add all additional rule type's ui components into Group groupAdditionalComponents + for( ITraceAnalyserRuleType item : rules ){ + item.createUIComponents(groupAdditionalComponents, this); + // hide components. + item.setVisible(false); + + } + + // if editing existing rule, format values from it to UI-components and disable rule type selection. + if(rule != null){ + textRuleName.setText(rule.getName()); + textRuleDescription.setText(rule.getDescription()); + for(int i = 0; i < rules.size(); i++){ + if( rules.get(i).formatRuleDefinitions(rule)){ + comboRuleType.select(i); + comboRuleType.setEnabled(false); + break; + } + } + } + + // hide all rule components except selected rule's components. + this.hideAndRevealItems(); + setHelps(); + return contents; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + public void createButtonsForButtonBar( Composite composite ){ + super.createButtonsForButtonBar(composite); + this.canFinish(); + } + + /** + * createConstComponents. + * Method that created UI components that are same on every rule. + * @param composite composite where components are placed. + */ + private void createConstComponents(Composite composite){ + this.createRuleTypeComposite(composite); + this.createRuleNameComposite(composite); + this.createRuleDescriptionComposite(composite); + } + + /** + * createRuleTypeComposite. + * Method that creates all rule name related components. + * @param composite + */ + private void createRuleTypeComposite(Composite composite){ + + // create composite for rule type components + compositeRuleType = new Composite(composite, SWT.NONE); + GridLayout contentsLayout = new GridLayout(); + contentsLayout.numColumns = 2; + compositeRuleType.setLayout(contentsLayout); + compositeRuleType.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Create rule type label + labelRuleType = new Label(compositeRuleType, SWT.NONE); + labelRuleType.setText("Rule Type:"); + + // Create rule type combo + comboRuleType = new Combo(compositeRuleType, SWT.READ_ONLY); + GridData dataGridComboRuleType = new GridData(GridData.FILL_HORIZONTAL); + comboRuleType.setLayoutData(dataGridComboRuleType); + comboRuleType.addSelectionListener(this); + + // get rule type's names from rule array and add them to combo box. + for(ITraceAnalyserRuleType item : rules){ + comboRuleType.add(item.getRuleType()); + } + + // Select first item if possible + if( comboRuleType.getItems().length > 0 ){ + comboRuleType.select(0); + } + + + + } + + /** + * createRuleNameComposite. + * Method that creates all rule name related components. + * @param composite composite where components are placed. + */ + private void createRuleNameComposite(Composite composite){ + + // create composite for rule name components + compositeRuleName = new Composite(composite, SWT.NONE); + GridLayout layoutCompositeRuleName = new GridLayout(); + layoutCompositeRuleName.numColumns = 2; + compositeRuleName.setLayout(layoutCompositeRuleName); + compositeRuleName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Create rule name label + labelRuleName = new Label(compositeRuleName, SWT.NONE); + labelRuleName.setText("Rule Name:"); + + // Create rule name text field + textRuleName = new Text(compositeRuleName, SWT.BORDER); + GridData gridDataTextRuleName = new GridData(SWT.FILL, SWT.CENTER, true, false); + textRuleName.setToolTipText("Define Name of the Rule."); + textRuleName.setLayoutData(gridDataTextRuleName); + textRuleName.addModifyListener(this); + } + + /** + * createRuleDescriptionComposite. + * Method that creates all rule description related components. + * @param composite + */ + private void createRuleDescriptionComposite(Composite composite){ + // create composite for rule name components + compositeRuleDescription = new Composite(composite, SWT.NONE); + GridLayout layoutCompositeRuleDescription = new GridLayout(); + layoutCompositeRuleDescription.numColumns = 1; + compositeRuleDescription.setLayout(layoutCompositeRuleDescription); + compositeRuleDescription.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Create rule type label + labelRuleDescription = new Label(compositeRuleDescription, SWT.NONE); + labelRuleDescription.setText("Rule Description(optional):"); + + // Create rule description text field + textRuleDescription = new Text(compositeRuleDescription, SWT.BORDER | SWT.MULTI); + + GridData gridDataTextRuleDescription = new GridData(GridData.FILL_HORIZONTAL); + textRuleDescription.setToolTipText("Define description for rule."); + textRuleDescription.setLayoutData(gridDataTextRuleDescription); + } + + + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(SelectionEvent arg0) { + // nothing to be done. + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent event) { + if( event.widget == comboRuleType ){ + this.hideAndRevealItems(); + } + this.canFinish(); + } + + /** + * + */ + private void hideAndRevealItems(){ + int selectedIndex = comboRuleType.getSelectionIndex(); + if(selectedIndex >= 0 && selectedIndex < rules.size()){ + + if(shownRule != null){ + shownRule.setVisible(false); + } + shownRule = rules.get(selectedIndex); + shownRule.setVisible(true); + } + + contents.layout(); + } + + /** + * Set this page's context sensitive helps + */ + protected void setHelps() { + // Set help + PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_RULE_EDITOR); + } + + /** + * canFinish. + * Method that checks that all needed information is filled into UI-components. + * Method also takes care enabling/disabling OK-button and printing error messages if needed. + */ + public void canFinish(){ + String message = "Some of the mandatory fields is not filled properly:\n"; + + if(this.getButton(OK) != null){ + + // if no rule types found, set error message and disable ok + if( comboRuleType.getItems().length == 0 ){ + setMessage("No Trace Analyser rule types found from plugins-directory. Probably some parts of the Trace Analyser plug-in are missing.", org.eclipse.jface.dialogs.IMessageProvider.ERROR); + this.getButton(OK).setEnabled(false); + return; + } + + // if name-field is empty, set warning message and disable ok-button. + else if( textRuleName.getText().length() == 0 ){ + message += "Rule name missing"; + setMessage(message, org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + this.getButton(OK).setEnabled(false); + return; + } + + else if(engine.ruleExists(textRuleName.getText()) && createNewRule){ + message += "Rule with same name already exists."; + setMessage(message, org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + this.getButton(OK).setEnabled(false); + return; + } + + // ask from shown rule if all needed information is present. + else if(this.shownRule != null){ + String error = shownRule.canFinish(); + if( error != null){ + message += error; + setMessage(message, org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + this.getButton(OK).setEnabled(false); + return; + } + } + + // clear error message and set ok enabled. + + setMessage(""); + this.getButton(OK).setEnabled(true); + return; + } + return; + + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + public void modifyText(ModifyEvent event) { + if(event.widget == textRuleName){ + try{ + this.canFinish(); + } + catch (NullPointerException e) { + // Do nothing + } + } + + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + public void okPressed(){ + if( shownRule != null){ + TraceAnalyserRule newRule = shownRule.getRule(textRuleName.getText(), textRuleDescription.getText()); + if(newRule!= null){ + + if(createNewRule == false){ + + // Confirm that rule user really wants to save new rule defitions. + MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); + messageBox.setText("Trace Analyse - Edit Rule"); + messageBox.setMessage("Editing rule will clear rule's history. Are you sure you want to save new rule definitions?"); + int retval = messageBox.open(); + if(retval == SWT.YES){ + if(!engine.removeRule(oldRuleName)){ + MessageDialog.openError( getShell(), "Trace Analyser - error", "An error occured when trying to save rule." ); + return; + } + + } + else{ //if retval == SWT.NO + return; + } + + + } + + if(!engine.addRule(newRule)){ + MessageDialog.openError( getShell(), "Trace Analyser - error", "Unable to save rule, perhaps rule with same name already exists?" ); + + } + this.close(); + } + else{ + MessageDialog.openError( getShell(), "Trace Analyser - error", "An error occured when trying to save rule." ); + } + + } + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/dialogs/TraceSelectionDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/dialogs/TraceSelectionDialog.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,691 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.ui.dialogs; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +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.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; + + +import com.nokia.s60tools.traceanalyser.model.UserEnteredData; +import com.nokia.s60tools.traceanalyser.model.UserEnteredData.ValueTypes; +import com.nokia.s60tools.traceanalyser.resources.ImageKeys; +import com.nokia.s60tools.traceanalyser.resources.ImageResourceManager; +import com.nokia.s60tools.traceanalyser.ui.views.MainView; +import com.nokia.traceviewer.api.TraceViewerAPI; +import com.nokia.traceviewer.engine.activation.TraceActivationComponentItem; +import com.nokia.traceviewer.engine.activation.TraceActivationGroupItem; +import com.nokia.traceviewer.engine.activation.TraceActivationTraceItem; + + +/** + * class Trace selection dialog + * Dialog that can be used for selecting one Trace item from imported trace dictionaries. + */ +public class TraceSelectionDialog extends TitleAreaDialog implements SelectionListener, ModifyListener { + + + /* UI-components */ + + /* Dictionary-related components */ + private Composite compositeDictionaries; + private Table tableGroups; + private Label labelDictinaryFilter; + private Text textDictionaryFilter; + + /* Group related components */ + private Composite compositeGroups; + private Table tableDictionaries; + private Label labelGroupFilter; + private Text textGroupFilter; + + /* Trace related components */ + private Composite compositeTraces; + private Table tableTraces; + private Label labelTraceFilter; + private Text textTraceFilter; + + + /* List of trace dictionaries */ + private ArrayList dictionaryList; + + /* Currently selected trace item */ + TraceActivationTraceItem selectedTrace; + + /* Strings */ + public final static String TEXT_FILTER = "Filter:"; + + /* Column width's for each table */ + public final static int COLUMN_DICTIONARIES_NAME = 150; + public final static int COLUMN_GROUPS_ID = 45; + public final static int COLUMN_GROUPS_NAME = 200; + public final static int COLUMN_TRACES_ID = 45; + public final static int COLUMN_TRACES_NAME = 350; + + @SuppressWarnings("unchecked") + public class TraceActivationComponentComparator implements Comparator { + + public final int compare(Object pFirst, Object pSecond) { + String aFirstWeight = ((TraceActivationComponentItem) pFirst).getName(); + String aSecondWeight = ((TraceActivationComponentItem) pSecond).getName(); + return aFirstWeight.compareToIgnoreCase(aSecondWeight); + } // end compare + + } + + /** + * TraceSelectionDialog. + * Constructor. + * @param parentShell + */ + public TraceSelectionDialog(Shell parentShell) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS); + } + + @Override + /** + * createDialogArea. + */ + protected Control createDialogArea(Composite parent) { + + + getShell().setText("Select Trace"); + + setTitle("Select Trace For Rule"); + setTitleImage(ImageResourceManager.getImage(ImageKeys.IMG_TRACE_ANALYSER_BANNER)); + + // Set the minimum size for dialog + getShell().setMinimumSize(new Point(600, 500)); + // create composite where all components are placed + Composite contents = new Composite(parent, SWT.NONE); + GridLayout contentsLayout = new GridLayout(); + contentsLayout.numColumns = 1; + contents.setLayout(contentsLayout); + contents.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // create group where all components are placed + Group group = new Group(contents, SWT.NONE); + GridLayout layoutContents = new GridLayout(); + layoutContents.numColumns = 3; + group.setLayout(layoutContents); + group.setText("Select Trace"); + GridData contentsGridData = new GridData(GridData.FILL_BOTH); + group.setLayoutData(contentsGridData); + + // create tables for trace selection + this.createDictionaryTable( group ); + this.createGroupsTable(group); + this.createTracesTable(group); + loadUserEnteredData(); + + setHelps(); + return contents; + } + + /** + * createDictionaryTable. + * Places dictionary table into given composite. + * @param composite composite where table is placed. + */ + private void createDictionaryTable( Composite composite ){ + + // Create dictionaries - composite + compositeDictionaries = new Composite( composite, SWT.NONE ); + compositeDictionaries.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridLayout layoutDictionaries = new GridLayout(); + layoutDictionaries.numColumns = 2; + compositeDictionaries.setLayout(layoutDictionaries); + + // Table that contains all traces from selected dictionary + tableDictionaries = new Table(compositeDictionaries, SWT.BORDER | SWT.FULL_SELECTION ); + GridData gridDataDictionaryTable = new GridData(GridData.FILL_BOTH); + gridDataDictionaryTable.horizontalSpan = 2; + gridDataDictionaryTable.heightHint = 250; + tableDictionaries.setLayoutData(gridDataDictionaryTable); + tableDictionaries.setHeaderVisible(true); + tableDictionaries.addSelectionListener( this ); + + // add columns into table + TableColumn columnDictionary = new TableColumn(tableDictionaries, SWT.LEFT); + columnDictionary.setText("Dictionary Name"); + columnDictionary.setWidth(COLUMN_DICTIONARIES_NAME); + + // Create dictionary filter label + labelDictinaryFilter = new Label(compositeDictionaries, SWT.NONE); + labelDictinaryFilter.setText(TEXT_FILTER); + + // Create dictionary filter text field + textDictionaryFilter = new Text(compositeDictionaries, SWT.BORDER); + GridData groupFilterTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + textDictionaryFilter.setToolTipText("Filter for Dictionary"); + textDictionaryFilter.setLayoutData(groupFilterTextGridData); + textDictionaryFilter.addModifyListener(this); + + // update dictionary list(load list from TraceViewer): + updateDictionaryList(); + + + } + + + /** + * createGroupsTable. + * Places group table into given composite. + * @param composite composite where table is placed. + */ + private void createGroupsTable( Composite composite ){ + + // create composite for group table + compositeGroups = new Composite( composite, SWT.NONE ); + compositeGroups.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridLayout layoutGroups = new GridLayout(); + layoutGroups.numColumns = 2; + compositeGroups.setLayout(layoutGroups); + + // Table that contains all groups from selected dictionary + tableGroups = new Table(compositeGroups, SWT.BORDER | SWT.FULL_SELECTION ); + GridData gridDataTableGroups = new GridData(GridData.FILL_BOTH); + gridDataTableGroups.horizontalSpan = 2; + gridDataTableGroups.heightHint = 250; + tableGroups.setLayoutData(gridDataTableGroups); + tableGroups.setHeaderVisible(true); + tableGroups.addSelectionListener( this ); + + // add columns into table + TableColumn columnID = new TableColumn(tableGroups, SWT.LEFT); + columnID.setText("ID"); + columnID.setWidth(COLUMN_GROUPS_ID); + TableColumn columnGroup = new TableColumn(tableGroups, SWT.LEFT); + columnGroup.setText("Group Name"); + columnGroup.setWidth(COLUMN_GROUPS_NAME); + + // Create Group filter label + labelGroupFilter = new Label(compositeGroups, SWT.NONE); + labelGroupFilter.setText(TEXT_FILTER); + + // Create trace filter text field + textGroupFilter = new Text(compositeGroups, SWT.BORDER); + GridData gridDataTextTraceFilter = new GridData(SWT.FILL, SWT.CENTER, true, false); + textGroupFilter.setToolTipText("Filter for Group"); + textGroupFilter.setLayoutData(gridDataTextTraceFilter); + textGroupFilter.addModifyListener(this); + + } + + + /** + * createTracesTable. + * Places group table into given composite. + * @param composite composite where table is placed. + */ + private void createTracesTable(Composite composite){ + + // create composite for Traces table + compositeTraces = new Composite( composite, SWT.NONE ); + compositeTraces.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridLayout layoutTraces = new GridLayout(); + layoutTraces.numColumns = 2; + compositeTraces.setLayout(layoutTraces); + + // Table that contains all traces from selected dictionary + tableTraces = new Table(compositeTraces, SWT.BORDER | SWT.FULL_SELECTION ); + GridData gridDataTableTraces = new GridData(GridData.FILL_BOTH); + gridDataTableTraces.horizontalSpan = 2; + gridDataTableTraces.heightHint = 250; + tableTraces.setLayoutData(gridDataTableTraces); + tableTraces.setHeaderVisible(true); + tableTraces.addSelectionListener( this ); + + // add columns into table + TableColumn columnID = new TableColumn(tableTraces, SWT.LEFT); + columnID.setText("ID"); + columnID.setWidth(COLUMN_TRACES_ID); + TableColumn columnGroup = new TableColumn(tableTraces, SWT.LEFT); + columnGroup.setText("Trace Name"); + columnGroup.setWidth(COLUMN_TRACES_NAME); + + // Create trace filter label + labelTraceFilter = new Label(compositeTraces, SWT.NONE); + labelTraceFilter.setText(TEXT_FILTER); + + // Create trace filter text field + textTraceFilter = new Text(compositeTraces, SWT.BORDER); + GridData gridDataTextTraceFilter = new GridData(SWT.FILL, SWT.CENTER, true, false); + textTraceFilter.setToolTipText("Filter for Group"); + textTraceFilter.setLayoutData(gridDataTextTraceFilter); + textTraceFilter.addModifyListener(this); + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(SelectionEvent event) { + + // if doubleclick detected in trace-table, close dialog. + if(event.widget == tableTraces){ + okPressed(); + } + + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent event) { + if( event.widget == tableDictionaries ){ + + // when selection in dictionary-table changes, update group list + this.updateGroupList(); + this.updateTraceList(); + this.setSelectedTraceItem(); + } + else if( event.widget == tableGroups ){ + + // when selection in groups-table changes, update trace list + this.updateTraceList(); + this.setSelectedTraceItem(); + + } + else if( event.widget == tableTraces ){ + + this.setSelectedTraceItem(); + + } + } + + /** + * containsIgnoreCase. + * Contains-operation that ignores stings case. + * @param line string where another parameter is searched from + * @param searchPhrase String that is searched from another given parameter + * @return + */ + private boolean containsIgnoreCase( String line, String searchPhrase ){ + + // convert both Strings to lowercase. + line = line.toLowerCase(); + searchPhrase = searchPhrase.toLowerCase(); + + // compare lowercase strings to each other. + return line.contains(searchPhrase); + + } + + /** + * updateDictionaryList. + * Loads dictionary list from TraveViewer and updates dictionary-table + */ + @SuppressWarnings("unchecked") + private void updateDictionaryList(){ + + + // remove all items from dictionary-table + tableDictionaries.removeAll(); + + + // get dictionary components from TraceViewer + dictionaryList = TraceViewerAPI.getDictionaryComponents(); + + // Sort list into aphabetical order. + Collections.sort(dictionaryList, new TraceActivationComponentComparator()); + + if(dictionaryList.size() == 0){ + //TODO do something! + MainView.showTraceViewer(); + MainView.showAndReturnYourself(); + dictionaryList = TraceViewerAPI.getDictionaryComponents(); + + } + + int tableIndexNumber = 0; + + // go thru dictionary list and add dictionaries to table + while( tableIndexNumber < dictionaryList.size() ){ + if( textDictionaryFilter.getText() != "" && + !this.containsIgnoreCase( dictionaryList.get(tableIndexNumber).getName(), textDictionaryFilter.getText() ) ){ + // if filter is set, delete dictionary name if it does not contain filter text. + dictionaryList.remove(tableIndexNumber); + } + else{ + // create new table item into table + TableItem newItem = new TableItem(tableDictionaries, SWT.NONE, tableIndexNumber); + newItem.setText( new String[]{ dictionaryList.get(tableIndexNumber).getName() } ); + tableIndexNumber++; + } + } + + if( dictionaryList.size() > 0){ + setMessage("Select dictionary where needed trace is found.", org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + } + + if( dictionaryList.size() == 0){ + setMessage("No loaded trace dictionaries found from TraceViewer. See help for more information.", org.eclipse.jface.dialogs.IMessageProvider.WARNING); + + } + + + } + + /** + * updateGroupList. + * Loads Group list from TraceViewer and updates Groups-table + */ + private void updateGroupList(){ + + + // Reset array + tableGroups.removeAll(); + + ArrayList groupList = this.getSelectedDictionarysItems(); + + if( groupList != null ){ + + int tableIndexNumber = 0; + // go thru dictionary list + while( tableIndexNumber < groupList.size() ){ + if( textGroupFilter.getText() != "" && + !this.containsIgnoreCase( groupList.get(tableIndexNumber).getName(), textGroupFilter.getText() ) ){ + // if filter is set, delete dictionary name if it does not contain filter text. + groupList.remove(tableIndexNumber); + } + else{ + // add new item into table + TableItem newItem = new TableItem(tableGroups, SWT.NONE, tableIndexNumber); + newItem.setText( new String[]{ "0x"+Integer.toHexString(groupList.get(tableIndexNumber).getId()), groupList.get(tableIndexNumber).getName() } ); + tableIndexNumber++; + } + } + } + + if( groupList != null && groupList.size() > 0){ + setMessage("Select group where needed trace is found.",org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + } + + + + } + + /** + * updateTraceList. + * Loads Trace list from TraceViewer and updates traces-table. + */ + private void updateTraceList(){ + + + // Reset array + tableTraces.removeAll(); + + ArrayList traceList = this.getSelectedGroupsItems(); + + boolean nullNamesFound = false; + + if( traceList != null ){ + int tableIndexNumber = 0; + + // go thru dictionary list + while( tableIndexNumber < traceList.size() ){ + if( textTraceFilter.getText() != "" && + + !this.containsIgnoreCase( traceList.get(tableIndexNumber).getName(), textTraceFilter.getText() ) ){ + // if filter is set, delete dictionary name if it does not contain filter text. + traceList.remove(tableIndexNumber); + } + else{ + // add new item into table + TableItem newItem = new TableItem(tableTraces, SWT.NONE, tableIndexNumber); + + // get id and convert id to hex + String id = "0x"+Integer.toHexString(traceList.get(tableIndexNumber).getId()); + String name = traceList.get(tableIndexNumber).getName(); + + if(name == null){ + nullNamesFound = true; + } + + newItem.setText(new String[]{id ,name}); + tableIndexNumber++; + } + } + } + + if( traceList != null && traceList.size() > 0){ + setMessage("Select Trace.", org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + + } + + + + if (nullNamesFound){ + setMessage("No trace names were found from trace definitions file. See help for more information.", org.eclipse.jface.dialogs.IMessageProvider.INFORMATION); + } + + + + } + + + + /** + * setSelectedGroupItem. + * sets selected trace item into private variable called selectedTrace and enables of disables. + */ + private void setSelectedTraceItem(){ + + ArrayList traceList = this.getSelectedGroupsItems(); + + if( traceList != null ){ + + int index = tableTraces.getSelectionIndex(); + if( index != -1 == index < traceList.size()){ + this.selectedTrace = traceList.get(index); + this.getButton(OK).setEnabled(true); + setMessage(null); + + return; + } + } + this.getButton(OK).setEnabled(false); + this.selectedTrace = null; + } + + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + public void modifyText(ModifyEvent event) { + if( event.widget == textDictionaryFilter ){ + // if Dictionary filter is edited + + // update dictionary list + this.updateDictionaryList(); + + // update groups list + this.updateGroupList(); + + // update trace list. + this.updateTraceList(); + + // Update selected trece + this.setSelectedTraceItem(); + + } + else if( event.widget == textGroupFilter ){ + // if Group filter is edited + + // update group list. + this.updateGroupList(); + + // update trace list. + this.updateTraceList(); + + } + else if( event.widget == textTraceFilter ){ + // if Trace filter is edited + + // update trace list. + this.updateTraceList(); + + } + } + + /** + * getSelectedDictionarysItems. + * @return currently selected dictionarys items and null is no dictionary is selected. + */ + private ArrayList getSelectedDictionarysItems(){ + int index = tableDictionaries.getSelectionIndex(); + if(index != -1 && index < dictionaryList.size()){ + + //Get selected dictionary + TraceActivationComponentItem dictionary = dictionaryList.get(index); + ArrayList groupList = new ArrayList( dictionary.getGroups() ); + return groupList; + } + else{ + return null; + } + } + + /** + * getSelectedGroupsItems. + * @return currently selected groups items and null if no group is selected. + */ + private ArrayList getSelectedGroupsItems(){ + ArrayList groupItems = this.getSelectedDictionarysItems(); + if( groupItems != null ){ + int index = tableGroups.getSelectionIndex(); + if(index != -1 && index < groupItems.size()){ + ArrayList traceList = new ArrayList (groupItems.get(index).getTraces()); + return traceList; + } + } + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + public void createButtonsForButtonBar( Composite composite ){ + super.createButtonsForButtonBar(composite); + // OK button is always disabled when dialog is opened. + this.setSelectedTraceItem(); + + } + + /** + * getSelectedTrace + * @return Selected trace, null if no trace is selected. + */ + public TraceActivationTraceItem getSelectedTrace() { + return selectedTrace; + } + + + + /** + * loadUserEnteredData + * loads previous values into UI components + */ + private void loadUserEnteredData(){ + UserEnteredData data = new UserEnteredData(); + + String previousDictionary = data.getString(ValueTypes.PREVIOUS_DICTIONARY); + String previousGroup = data.getString(ValueTypes.PREVIOUS_GROUP); + int ii = 0; + while(ii < tableDictionaries.getItemCount()){ + if( tableDictionaries.getItem(ii).getText(0).equals(previousDictionary)){ + tableDictionaries.setSelection(ii); + updateGroupList(); + ii = 0; + while(ii < tableGroups.getItemCount()){ + if(tableGroups.getItem(ii).getText(0).equals(previousGroup)){ + tableGroups.setSelection(ii); + updateTraceList(); + break; + } + ii++; + } + break; + } + ii++; + } + + + + } + + /** + * saveUserEnteredData + * Saves current user entered data from UI components + */ + public void saveUserEnteredData(){ + UserEnteredData data = new UserEnteredData(); + + String item = tableDictionaries.getSelection()[0].getText(0); + data.saveString(ValueTypes.PREVIOUS_DICTIONARY, item); + + item = tableGroups.getSelection()[0].getText(0); + data.saveString(ValueTypes.PREVIOUS_GROUP, item); + } + + + /* + * (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + public void okPressed(){ + saveUserEnteredData(); + this.close(); + + } + + /** + * Set this page's context sensitive helps + */ + protected void setHelps() { + // Set help + PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_TRACE_SELECTION_DIALOG); + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryEditor.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,212 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.editors; + +import java.util.ArrayList; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.MultiPageEditorPart; + +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; +import com.nokia.s60tools.traceanalyser.ui.views.MainView; +import com.nokia.s60tools.ui.S60ToolsTable; +import com.nokia.s60tools.ui.S60ToolsTableColumnData; +import com.nokia.s60tools.ui.S60ToolsTableFactory; + + +/** + * HistoryEditor. + * History view of Trace Analyser + */ +public class HistoryEditor extends MultiPageEditorPart{ + + /* Tableviewer for history table */ + TableViewer viewer; + + /* contentprovider for history table */ + HistoryTableContentProvider contentProvider; + + /* Name of the rule */ + String ruleName; + + /* History Graph object */ + HistoryGraph graph; + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.MultiPageEditorPart#createPages() + */ + @Override + protected void createPages() { + int index = 0; + createGraphPage(index); + index++; + createTablePage(index); + + ruleName = ((HistoryEditorInput)this.getEditorInput()).getEvents().getRule().getName(); + setPartName(ruleName); + setHelps(); + } + + /** + * createTablePage. + * Method that creates table page of view + * @param index tab index of this page + */ + private void createTablePage(int index){ + // create composite where all components are placed + Composite composite = new Composite(getContainer(), SWT.NONE); + GridLayout contentsLayout = new GridLayout(); + contentsLayout.numColumns = 1; + composite.setLayout(contentsLayout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // Create column name array + ArrayList columnArrayList = new ArrayList(); + + // add column names + columnArrayList.add(new S60ToolsTableColumnData("Status", 60, 0, HistoryTableDataSorter.STATUS)); + columnArrayList.add(new S60ToolsTableColumnData("Time", 150, 1, HistoryTableDataSorter.TIME)); + columnArrayList.add(new S60ToolsTableColumnData("Value", 60, 2, HistoryTableDataSorter.VALUE)); + columnArrayList.add(new S60ToolsTableColumnData("Violation", 60, 3, HistoryTableDataSorter.VIOLATION)); + + + S60ToolsTableColumnData[] columnDataTableHistory = columnArrayList.toArray(new S60ToolsTableColumnData[0]); + + // Create table for history events + S60ToolsTable tableHistory = S60ToolsTableFactory.create(composite, columnDataTableHistory); + ArrayList events = ((HistoryEditorInput)this.getEditorInput()).getEvents().getEvents(); + + viewer = new TableViewer(tableHistory.getTableInstance()); + contentProvider = new HistoryTableContentProvider(events); + viewer.setContentProvider(contentProvider); + viewer.setLabelProvider(new HistoryTableLabelProvider()); + viewer.setComparator(new HistoryTableDataSorter()); + viewer.setSorter(new HistoryTableDataSorter()); + //viewer.setInput(getViewSite()); + viewer.setInput(this.getSite()); + tableHistory.setHostingViewer(viewer); + + // add this page to composite + addPage(composite); + + // set page name + setPageText(index,"Table" ); + + } + + /** + * createGraphPage. + * Method that creates graph page of view + * @param index tab index of this page + */ + private void createGraphPage(int index){ + + // create composite where all components are placed + Composite composite = new Composite(getContainer(), SWT.NONE); + GridLayout contentsLayout = new GridLayout(); + contentsLayout.numColumns = 1; + composite.setLayout(contentsLayout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + graph = new HistoryGraph(composite, + ((HistoryEditorInput)this.getEditorInput()).getEvents()); + graph.drawGraph(); + + addPage(composite); + setPageText(index,"Graph" ); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void doSave(IProgressMonitor arg0) { + // Nothing to be done + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.EditorPart#doSaveAs() + */ + @Override + public void doSaveAs() { + // Nothing to be done + + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() + */ + @Override + public boolean isSaveAsAllowed() { + // Nothing to be done + return false; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.MultiPageEditorPart#dispose() + */ + public void dispose(){ + MainView view = TraceAnalyserPlugin.getMainView(); + graph.dispose(); + if(view != null){ + view.editorClosed(ruleName); + } + } + + /** + * getRuleName. + * @return rule name + */ + public String getRuleName(){ + return ruleName; + } + + /** + * historyUpdated. + * Method that is called when rule's history is updated + * so that graph and table needs to be refreshed. + */ + public void historyUpdated(){ + graph.redraw(); + viewer.refresh(); + } + + /** + * Set this page's context sensitive helps + */ + protected void setHelps() { + // Set help + PlatformUI.getWorkbench().getHelpSystem().setHelp( viewer.getControl(), com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_HISTORY_VIEW); + graph.setHelps(); + } + +} \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryEditorInput.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryEditorInput.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.editors; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IPersistableElement; +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; + +/** + * Trace Analyser specific input to the HistoryEditor. + * + */ +public class HistoryEditorInput implements IEditorInput { + + /* Event history */ + private RuleInformation events; + + /** + * HistoryEditorInput. + * constructor + * @param events history events. + */ + public HistoryEditorInput(RuleInformation events) { + this.events = events; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#exists() + */ + public boolean exists() { + return false; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getImageDescriptor() + */ + public ImageDescriptor getImageDescriptor() { + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getPersistable() + */ + public IPersistableElement getPersistable() { + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IEditorInput#getToolTipText() + */ + public String getToolTipText() { + return events.getRule().getName(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + @SuppressWarnings("unchecked") + public Object getAdapter(Class adapter) { + return null; + } + + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if(!(o instanceof HistoryEditorInput)){ + return false; + } + HistoryEditorInput otherInput = (HistoryEditorInput) o; + return otherInput.getEvents().getRule().getName().equals(events.getRule().getName()); + + + } + + /** + * getEvents. + * @return history events + */ + public RuleInformation getEvents() { + return events; + } + + /** + * getName + * @return name of the rule. + */ + public String getName() { + return events.getRule().getName(); + } +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryGraph.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryGraph.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,404 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.editors; + + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.model.Engine; +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; + + +/** + * HistoryGraph. + * Graph UI-component for Trace Analyser + */ +public class HistoryGraph implements MouseMoveListener { + + // Margins for each border + private static final int MARGIN_LEFT = 100; + private static final int MARGIN_OTHERS = 40; + private static final int GRAPHMARGIN = 10; + + /* RuleInformation that is drawn to screen */ + private RuleInformation information; + + /* TraceAnalyser engine */ + Engine engine; + + /* UI components */ + private Composite composite; + private Canvas canvas; + + /** + * HistoryGraph. + * @param composite composite where components are placed. + * @param information information which is drawn to screen. + */ + HistoryGraph(Composite composite, RuleInformation information){ + this.composite = composite; + this.information = information; + this.engine = TraceAnalyserPlugin.getEngine(); + } + + /** + * drawGraph. + * Draws graph to screen. + */ + void drawGraph(){ + if(canvas != null){ + canvas.dispose(); + } + canvas = new Canvas(composite, SWT.BORDER); + canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // Add mouse mouse listener. + canvas.addMouseMoveListener(this); + + // Add paint listener + canvas.addPaintListener(new PaintListener() { + public void paintControl(PaintEvent e) { + GC gc = e.gc; + drawBox(gc); + drawLimits(gc); + drawEvents(gc); + } + + + }); + + } + + + /** + * redraw. + * Redraws screen. + */ + public void redraw(){ + canvas.redraw(); + } + + + /** + * getCanvasSize. + * @return size or the canvas. + */ + private Point getCanvasSize(){ + Point point = canvas.getSize(); + point.x -= 5; + point.y -= 5; + return point; + } + + /** + * drawBox. + * Draws box for graph into graphics content. + * @param gc graphics content where content is drawn + */ + private void drawBox(GC gc){ + + gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + + // count start points of box + int startPointX = MARGIN_LEFT - GRAPHMARGIN; + int startPointY = MARGIN_OTHERS - GRAPHMARGIN; + + // Count width and height of box + Point canvasSize = getCanvasSize(); + int width = canvasSize.x - (MARGIN_LEFT + MARGIN_OTHERS - GRAPHMARGIN*2); + int height = canvasSize.y - (MARGIN_OTHERS*2 - GRAPHMARGIN*2); + + // draw and fill rectangle. + gc.fillRectangle(startPointX, startPointY, width, height); + gc.drawRectangle(startPointX, startPointY, width, height); + + + } + + + /** + * drawEvents. + * Draws all history events to screen. + * @param gc graphics content where content is drawn + */ + private void drawEvents(GC gc){ + + ArrayList events = information.getEvents(); + Point canvasSize = getCanvasSize(); + + // Count start points + double sizeY = canvasSize.y - MARGIN_OTHERS * 2; + double sizeX = canvasSize.x - (MARGIN_LEFT + MARGIN_OTHERS); + + + int[] minAndMax = getMinAndMax(); + int min = minAndMax[0]; + int max = minAndMax[1]; + + + // get difference between min and max value. + int difference = max - min; + + // get multiplier for Y values from that difference. + double yMultiplier = sizeY / difference; + + // get multiplier for X values from canvas size and smount of events. + double xMultiplier = sizeX / (events.size() - 1); + + gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + int[] previousValues = new int[2]; + int i = 0; + + while(i < events.size()){ + + gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + + // count x-value based on what event is drawn to screen + int xValue = (int)(i * xMultiplier); + + // count y-value based on what event value is. + double yValueDouble = events.get(i).getValue() - min; + yValueDouble *= yMultiplier; + int yValue = (int)(sizeY - yValueDouble); + + // add margins + xValue += MARGIN_LEFT; + yValue += MARGIN_OTHERS; + + // Draw mark on one event(currently disabled) + // drawMark(gc, xValue, yValue); + + gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + + // Draw line between this and previous event. + if(i > 0 ){ + gc.drawLine(xValue, yValue, previousValues[0], previousValues[1]); + } + + // save value to previous value variable + previousValues[0] = xValue; + previousValues[1] = yValue; + + i++; + } + } + + /** + * drawMark. + * Draws mark of one event into given coordinate + * @param gc graphics content where content is drawn + * @param xValue x-coordinate + * @param yValue y-coordinate + */ + @SuppressWarnings("unused") + private void drawMark(GC gc, int xValue, int yValue){ + gc.fillOval(xValue - 3, yValue - 3, 6, 6); + gc.drawOval(xValue - 3, yValue - 3, 6, 6); + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) + */ + public void mouseMove(MouseEvent event) { + + // sets tooltip based on what is x-coordinate of mouse. + + Point canvasSize = getCanvasSize(); + int drawingAreaSize = canvasSize.x - (MARGIN_LEFT + MARGIN_OTHERS) ; + + // Count divider for x-coordinate + double unit = (double)drawingAreaSize / ((double)information.getEvents().size() - 1); + + // If mouse pointer is over graph area + if(event.x < (canvasSize.x - (MARGIN_OTHERS-GRAPHMARGIN)) && + event.x > (MARGIN_LEFT - GRAPHMARGIN) && + event.y > (MARGIN_OTHERS - GRAPHMARGIN) && + event.y < (canvasSize.y - (MARGIN_OTHERS-GRAPHMARGIN)) ) + { + // Count item's index based on x-coordinate + double indexDouble = (event.x - MARGIN_LEFT) / unit; + indexDouble += 0.5; + int index = (int)indexDouble; + + if(index > information.getEvents().size()){ + index = information.getEvents().size()-1; + } + + // Get time and measured value from object and set tooltip + Date date = information.getEvents().get(index).getTime(); + SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss:SSS"); + canvas.setToolTipText("Time:" + formatter.format(date) + " Value:" + Integer.toString(information.getEvents().get(index).getValue())); + + } + else{ + canvas.setToolTipText(null); + } + + + + } + + /** + * dispose. + */ + public void dispose(){ + canvas.dispose(); + } + + + /** + * drawLimits. + * Draws y-axis max and min values + 3 values between those into given graphics content. + * @param gc graphics content where content is drawn + */ + private void drawLimits(GC gc) { + + // Left margin before texts + int numberMargin = 20; + int letterSize = 12; + Point canvasSize = getCanvasSize(); + + int min = 0; + int max = 0; + + int[] minAndMax = getMinAndMax(); + min = minAndMax[0]; + max = minAndMax[1]; + + // get difference between min and max value. + double difference = max - min; + + // get multiplier for Y values from that difference. + double yMultiplier = (canvasSize.y - MARGIN_OTHERS * 2) / difference; + + + double xCoordDifference = ((double)(canvasSize.y - MARGIN_OTHERS * 2)) / 4; + double valueDifference = ((double)(difference)) / 4; + + // Set colors + gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + + // Get start values + double yCoord = (double)MARGIN_OTHERS; + double value = (double)max; + + int i = 0; + while(i < 5){ + + // draw value + String printedValueText = Integer.toString((int)(value + 0.5)) + information.getRule().getUnit(); + gc.drawText(printedValueText, numberMargin, (int) yCoord - letterSize); + + // draw text + drawLine(gc, (int)yCoord, numberMargin, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + yCoord += xCoordDifference; + value -= valueDifference; + i++; + + } + + // draw "Time ->" text into x-axis. + Point timeText = new Point(canvasSize.x / 2, canvasSize.y - MARGIN_OTHERS + 12); + gc.drawText("Time ->", timeText.x, timeText.y); + + + // draw limits into graph + + TraceAnalyserRule rule = engine.getRule(this.information.getRule().getName()); + int[] limits = rule.getLimits(); + + + for(int item : limits){ + int yValue = (int)((item - min) * yMultiplier); + yCoord = canvasSize.y - MARGIN_OTHERS - yValue; + drawLine(gc, (int)yCoord, numberMargin, Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } + + } + + /** + * drawLine. + * Draws straight line into given y-coordinate. + * @param gc graphics content where content is drawn + * @param yCoord y-coordinate + * @param numbeMargin margin in front of line. + */ + private void drawLine(GC gc, int yCoord, int numberMargin, Color color){ + Color previousColor = gc.getForeground(); + gc.setForeground(color); + gc.drawLine(numberMargin, yCoord,getCanvasSize().x-(MARGIN_OTHERS-GRAPHMARGIN), yCoord ); + gc.setForeground(previousColor); + + + } + + /** + * Returnns min and max value from one rule's history + * @return + */ + private int[] getMinAndMax(){ + TraceAnalyserRule rule = engine.getRule(this.information.getRule().getName()); + + int[] limits = rule.getLimits(); + + int min = information.getMin(); + int max = information.getMax(); + + for(int item : limits){ + if(item > max){ + max = item; + } + else if(item < min){ + min = item; + } + } + + return new int[]{min,max}; + } + + /** + * sets context sensitive helps + */ + public void setHelps(){ + PlatformUI.getWorkbench().getHelpSystem().setHelp( canvas, com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_HISTORY_VIEW); + + } +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryTableContentProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryTableContentProvider.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.editors; + +import java.util.ArrayList; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +import com.nokia.s60tools.traceanalyser.export.RuleEvent; + + /* + * HistoryTableContentProvider. + * Content provider for history table + */ + + class HistoryTableContentProvider implements IStructuredContentProvider { + + /* event list */ + ArrayList events; + + /** + * HistoryTableContentProvider. + * Constructor + * @param events event list + */ + public HistoryTableContentProvider(ArrayList events){ + this.events = events; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object parent) { + return events.toArray(new RuleEvent[events.size()]); + } + + } \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryTableDataSorter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryTableDataSorter.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.ui.editors; +import org.eclipse.jface.viewers.Viewer; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.RuleEvent.RuleStatus; +import com.nokia.s60tools.ui.S60ToolsViewerSorter; + +/** + * class HistoryTableDataSorter + * Data sorter for Trace Analyser's history view. + */ + +public class HistoryTableDataSorter extends S60ToolsViewerSorter { + + /** + * Numbers of columns that can be sorted. + */ + public static final int STATUS = 1; + public static final int TIME = 2; + public static final int VALUE = 3; + public static final int VIOLATION = 4; + + public HistoryTableDataSorter() { + super(); + // By default set sort criteria to time + setSortCriteria(TIME); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public int compare(Viewer viewer, Object e1, Object e2) { + + + // By default comparison does not do any ordering + int comparisonResult = 0; + + RuleEvent f1 = (RuleEvent) e1; + RuleEvent f2 = (RuleEvent) e2; + + switch (sortCriteria) { + + case STATUS: + + if(f1.getStatus() == f2.getStatus()){ + comparisonResult = 0; + } + else if(f1.getStatus() == RuleStatus.FAIL){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + break; + + case -1: + case TIME: + if(f1.getTime().before(f2.getTime())){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + break; + + case VALUE: + if(f1.getValue() < f2.getValue()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + break; + + case VIOLATION: + if(f1.getViolation() > f2.getViolation()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + + break; + + default: + break; + } + + return comparisonResult; + + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryTableLabelProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/editors/HistoryTableLabelProvider.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.editors; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + + +import com.nokia.s60tools.traceanalyser.export.RuleEvent; + +/** + * HistoryTableLabelProvider. + * Label provider for history table. + */ +class HistoryTableLabelProvider extends LabelProvider implements ITableLabelProvider { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) + */ + public String getColumnText(Object obj, int index) { + RuleEvent item = (RuleEvent)obj; + return item.getHistoryText(index); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) + */ + public Image getColumnImage(Object obj, int index) { + return getImage(obj); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object obj) { + return null; + } +} \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/FailLogTableContentProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/FailLogTableContentProvider.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.views; + + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + + +import com.nokia.s60tools.traceanalyser.model.Engine; + +/** + * class FailLogTableContentProvider + * content provides for fail log table. + */ +class FailLogTableContentProvider implements IStructuredContentProvider { + + /* Trace Analyser engine */ + private final Engine engine; + + /** + * FailLogTableContentProvider. + * constructor. + * @param engine + */ + public FailLogTableContentProvider( Engine engine ){ + this.engine = engine; + } + + /** + * refresh. + * refreshes fail log. + */ + public void refresh() { + engine.refreshFailLog(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object parent) { + return engine.getFailLog(); + + } + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/FailLogTableDataSorter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/FailLogTableDataSorter.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.ui.views; +import org.eclipse.jface.viewers.Viewer; + +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.ui.S60ToolsViewerSorter; + + +/** + * class FailLogTableDataSorter + * Data sorter for Trace Analyser's fail log view. + */ + +public class FailLogTableDataSorter extends S60ToolsViewerSorter { + + /** + * Numbers of columns that can be sorted. + */ + public static final int TIME = 1; + public static final int RULE = 2; + public static final int VIOLATION = 3; + public static final int LIMIT = 4; + + + public FailLogTableDataSorter() { + super(); + // By default set sort criteria to time + setSortCriteria(TIME); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public int compare(Viewer viewer, Object e1, Object e2) { + + + // By default comparison does not do any ordering + int comparisonResult = 0; + + RuleEvent f1 = (RuleEvent) e1; + RuleEvent f2 = (RuleEvent) e2; + + switch (sortCriteria) { + + + case TIME: + case -1: + if(f1.getTime().before(f2.getTime())){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + break; + + case RULE: + comparisonResult = f1.getRuleName().compareToIgnoreCase(f2.getRuleName()); + + break; + + case VIOLATION: + if(f1.getViolation() > f2.getViolation()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + + break; + + case LIMIT: + if(f1.getLimit() > f2.getLimit()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + break; + + default: + break; + } + + return comparisonResult; + + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/FailLogTableLabelProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/FailLogTableLabelProvider.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.views; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; + +/** + * class FailLogTableLabelProvider + * fail log label provider. + */ +class FailLogTableLabelProvider extends LabelProvider implements ITableLabelProvider { + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) + */ + public String getColumnText(Object obj, int index) { + RuleEvent logItem = (RuleEvent)obj; + return logItem.getFailLogText(index); + + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) + */ + public Image getColumnImage(Object obj, int index) { + /*if (index == MemSpyFileBundle.INDEX_FILE_TYPE){ + return getImage(obj); + } + else{ + return null; + }*/ + return null; + + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object obj) { + /*MemSpyFileBundle bundle = (MemSpyFileBundle)obj; + if( bundle.isHeapDumpFile() ){ + return ImageResourceManager.getImage(ImageKeys.IMG_HEAP_DUMP); + } + else{ + return ImageResourceManager.getImage(ImageKeys.IMG_SWMT_LOG); + }*/ + return PlatformUI.getWorkbench(). + getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); + } +} \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/MainView.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/MainView.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,1124 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.views; + + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.Timer; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.part.*; +import org.eclipse.jface.viewers.*; +import org.eclipse.jface.action.*; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.*; +import org.eclipse.swt.widgets.Menu; + +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; +import com.nokia.s60tools.traceanalyser.export.ITraceAnalyserRuleType; +import com.nokia.s60tools.traceanalyser.export.RuleEvent; +import com.nokia.s60tools.traceanalyser.export.TraceAnalyserRule; +import com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver; +import com.nokia.s60tools.traceanalyser.model.Engine; +import com.nokia.s60tools.traceanalyser.plugin.TraceAnalyserPlugin; +import com.nokia.s60tools.traceanalyser.resources.ImageKeys; +import com.nokia.s60tools.traceanalyser.resources.ImageResourceManager; +import com.nokia.s60tools.traceanalyser.ui.dialogs.EditRuleDialog; +import com.nokia.s60tools.traceanalyser.ui.editors.HistoryEditor; +import com.nokia.s60tools.traceanalyser.ui.editors.HistoryEditorInput; +import com.nokia.s60tools.ui.S60ToolsTable; +import com.nokia.s60tools.ui.S60ToolsTableColumnData; +import com.nokia.s60tools.ui.S60ToolsTableFactory; +import com.nokia.traceviewer.api.TraceViewerAPI; +import com.nokia.traceviewer.api.TraceViewerAPI.TVAPIError; + + +/** + *

+ * MainView. + * The main view of Trace Analyser Carbide extension. + *

+ */ + +public class MainView extends ViewPart implements ITraceAnalyserFileObserver, SelectionListener, ActionListener, KeyListener { + + + /* TraceViewers ID */ + public static final String TRACE_VIEWER_VIEW_ID = "com.nokia.traceviewer.view.TraceViewerView"; + + /* Main view's ID */ + public static final String ID = "com.nokia.s60tools.traceanalyser.ui.views.MainView"; + private static final int TAB_INDEX_RULE_LIST = 0; + private static final int TAB_INDEX_FAIL_LOG =1; + + /* Table Viewers for both main view's tables. */ + private CheckboxTableViewer viewerRuleTable; + private TableViewer viewerFailLogTable; + + /* content providers for both main view's tables */ + private RuleTableContentProvider contentProviderRuleTable; + private FailLogTableContentProvider contentProviderFailLogTable; + + /* actions */ + + private Action doubleClickAction; + private Action actionCopyRule; + + /* rule view actions */ + private Action actionDeleteRule; + private Action actionClearOneRuleCounters; + private Action actionClearAllCounters; + private Action actionCreateNewRule; + private Action actionEditRule; + private Action actionShowHistory; + + /* fail log actions */ + private Action actionClearFailLog; + private Action actionShowInTraceViewer; + + /* list of rule types */ + ArrayList ruleTypes; + + /* composites for both tabs */ + private Composite compositeRules; + private Composite compositeFailLog; + + + /* Tab Folder for main view */ + TabFolder tabFolder; + + /* Trace Analyser engine */ + Engine engine; + + /* Timer that is used when blinking icon */ + Timer timer; + + /* count of how many times icon is blinked */ + int blinkCount; + + /* Arraylist containing all open editor views */ + ArrayList openEditors; + + + /** + * The constructor. + */ + public MainView() { + ruleTypes = new ArrayList(); + engine = TraceAnalyserPlugin.getEngine(); + TraceAnalyserPlugin.setMainView(this); + ruleTypes = engine.getRuleTypes(); + blinkCount = 0; + openEditors = new ArrayList(); + } + + /** + * showAndReturnYourself. + * Makes main view visible and returns an instance of itself. Can be called from + * an UI thread only. + * @return instance of main view + */ + public static MainView showAndReturnYourself() { + return showAndReturnYourself(false); + } + /** + * showAndReturnYourself. + * Makes main view visible and returns an instance of itself. Can be called from + * an UI thread only. + * @return instance of main view + */ + public static MainView showAndReturnYourself(boolean openOnly) { + try { + + IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (ww == null) + return null; + + IWorkbenchPage page = ww.getActivePage(); + IWorkbenchPart currentPart = page.getActivePart(); + // Checking if view is already open + IViewReference[] viewRefs = page.getViewReferences(); + for (int i = 0; i < viewRefs.length; i++) { + IViewReference reference = viewRefs[i]; + String id = reference.getId(); + if(id.equalsIgnoreCase(MainView.ID)){ + // Found, restoring the view + IViewPart viewPart = reference.getView(true); + if (!openOnly) + page.activate(viewPart); + return (MainView)viewPart; + } + } + + // View was not found, opening it up as a new view. + MainView mView = (MainView)page.showView(MainView.ID); + if (openOnly) + page.bringToTop(currentPart); + return mView; + + } catch (Exception e) { + e.printStackTrace(); + + return null; + } + } + + + /** + * This is a callback that will allow us + * to create the viewer and initialize it. + */ + public void createPartControl(Composite parent) { + + createTabControls(parent); + createFailLogTable(); + createRuleTable(); + + + // Create the help context id for the viewer's control + PlatformUI.getWorkbench().getHelpSystem().setHelp(viewerRuleTable.getControl(), "com.nokia.s60tools.traceanalyser.viewer"); + makeActions(); + hookContextMenu(); + hookDoubleClickAction(); + contributeToActionBars(); + + refreshRuleContentAndViewAsynch(); + refreshFailLogContentAndViewAsynch(); + readActivationStatus(); + setHelps(); + } + + /** + * Creates Tab controls + * @param parent composite where tab controls are placed. + */ + private void createTabControls(Composite parent){ + // create tab folder. + tabFolder = new TabFolder (parent, SWT.DOWN); + tabFolder.addSelectionListener(this); + + // create rule composite + compositeRules = new Composite(tabFolder, SWT.NONE); + GridLayout layoutCompositeRules = new GridLayout(); + layoutCompositeRules.numColumns = 1; + compositeRules.setLayout(layoutCompositeRules); + + // create fail log composite + compositeFailLog = new Composite(tabFolder, SWT.NONE); + GridLayout layoutCompositeFailLog = new GridLayout(); + layoutCompositeFailLog.numColumns = 1; + compositeFailLog.setLayout(layoutCompositeFailLog); + + // create tab items + TabItem item = new TabItem (tabFolder, SWT.NONE); + item.setText ("Trace Analyser rules"); + item.setControl(compositeRules); + tabFolder.pack(); + + TabItem item2 = new TabItem (tabFolder, SWT.NONE); + item2.setText ("Fail Log"); + item2.setControl(compositeFailLog); + tabFolder.pack(); + } + + /** + * Creates fail log table + */ + private void createFailLogTable(){ + // Create fail log table + ArrayList failLogColumnArrayList = new ArrayList(); + + failLogColumnArrayList.add(new S60ToolsTableColumnData("Time", 150, 0, FailLogTableDataSorter.TIME)); + failLogColumnArrayList.add(new S60ToolsTableColumnData("Rule", 175, 1, FailLogTableDataSorter.RULE)); + failLogColumnArrayList.add(new S60ToolsTableColumnData("Violation", 75, 2, FailLogTableDataSorter.VIOLATION)); + failLogColumnArrayList.add(new S60ToolsTableColumnData("Limit", 75, 3, FailLogTableDataSorter.LIMIT)); + + S60ToolsTableColumnData[] columnDataTableFailLog = failLogColumnArrayList.toArray(new S60ToolsTableColumnData[0]); + S60ToolsTable tableFailLog = S60ToolsTableFactory.create(compositeFailLog, columnDataTableFailLog); + + viewerFailLogTable = new TableViewer(tableFailLog.getTableInstance()); + contentProviderFailLogTable = new FailLogTableContentProvider(engine); + viewerFailLogTable.setContentProvider(contentProviderFailLogTable); + viewerFailLogTable.setLabelProvider(new FailLogTableLabelProvider()); + viewerFailLogTable.setComparator(new FailLogTableDataSorter()); + viewerFailLogTable.setSorter(new FailLogTableDataSorter()); + viewerFailLogTable.setInput(getViewSite()); + tableFailLog.setHostingViewer(viewerFailLogTable); + } + + + /** + * Creates rule table + */ + private void createRuleTable(){ + Table tableRules = new Table(compositeRules, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); + + tableRules.setLayoutData(new GridData(GridData.FILL_BOTH)); + tableRules.setLinesVisible(true); + tableRules.setHeaderVisible(true); + + // Add selection listeners for each column after creating it + tableRules.addSelectionListener(this); + + int parameter_column_length = 60; + + TableColumn tableColumn = new TableColumn(tableRules, SWT.NONE); + tableColumn.setWidth(20); + tableColumn.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + checkAllPressed(); + } + }); + + TableColumn tableColumn2 = new TableColumn(tableRules, SWT.NONE); + tableColumn2.setWidth(150); + tableColumn2.setText("Rule Name"); + + tableColumn2.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter(new RuleTableDataSorter( + RuleTableDataSorter.RULE_NAME)); + } + }); + + TableColumn tableColumn3 = new TableColumn(tableRules, SWT.NONE); + tableColumn3.setWidth(parameter_column_length); + tableColumn3.setText("Pass"); + + tableColumn3.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.PASS)); + } + }); + + + TableColumn tableColumn4 = new TableColumn(tableRules, SWT.NONE); + tableColumn4.setWidth(parameter_column_length); + tableColumn4.setText("Fail"); + tableColumn4.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.FAIL)); + } + }); + + TableColumn tableColumn5 = new TableColumn(tableRules, SWT.NONE); + tableColumn5.setWidth(parameter_column_length); + tableColumn5.setText("Pass %"); + tableColumn5.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.PASSPERCENT)); + } + }); + + TableColumn tableColumn6 = new TableColumn(tableRules, SWT.NONE); + tableColumn6.setWidth(parameter_column_length); + tableColumn6.setText("Min"); + tableColumn6.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.MIN)); + } + }); + + TableColumn tableColumn7 = new TableColumn(tableRules, SWT.NONE); + tableColumn7.setWidth(parameter_column_length); + tableColumn7.setText("Max"); + tableColumn7.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.MAX)); + } + }); + + TableColumn tableColumn8 = new TableColumn(tableRules, SWT.NONE); + tableColumn8.setWidth(parameter_column_length); + tableColumn8.setText("Avg"); + tableColumn8.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.AVG)); + } + }); + + TableColumn tableColumn9 = new TableColumn(tableRules, SWT.NONE); + tableColumn9.setWidth(parameter_column_length); + tableColumn9.setText("Med"); + tableColumn9.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + viewerRuleTable.setSorter( + new RuleTableDataSorter(RuleTableDataSorter.MED)); + } + }); + + viewerRuleTable = new CheckboxTableViewer(tableRules); + contentProviderRuleTable = new RuleTableContentProvider(engine); + viewerRuleTable.setContentProvider(contentProviderRuleTable); + viewerRuleTable.setLabelProvider(new RuleTableLabelProvider()); + /*viewerRuleTable.setComparator(new RuleTableDataSorter()); + viewerRuleTable.setSorter(new RuleTableDataSorter());*/ + viewerRuleTable.setInput(getViewSite()); + tableRules.addKeyListener(this); + + } + + + /** + * hookContextMenu. + * Creates context menu for main view. + */ + private void hookContextMenu() { + MenuManager menuMgrRuleTable = new MenuManager("#PopupMenu"); + menuMgrRuleTable.setRemoveAllWhenShown(true); + menuMgrRuleTable.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + MainView.this.fillContextMenuRuleTable(manager); + } + }); + Menu menuRuleTable = menuMgrRuleTable.createContextMenu(viewerRuleTable.getControl()); + viewerRuleTable.getControl().setMenu(menuRuleTable); + getSite().registerContextMenu(menuMgrRuleTable, viewerRuleTable); + + + MenuManager menuMgrFailLog = new MenuManager("#PopupMenu"); + menuMgrFailLog.setRemoveAllWhenShown(true); + menuMgrFailLog.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + MainView.this.fillContextMenuFailLog(manager); + } + }); + Menu menuFailLog = menuMgrFailLog.createContextMenu(viewerFailLogTable.getControl()); + viewerFailLogTable.getControl().setMenu(menuFailLog); + getSite().registerContextMenu(menuMgrFailLog, viewerFailLogTable); + } + + + + /** + * contributeToActionBars + */ + private void contributeToActionBars() { + IActionBars bars = getViewSite().getActionBars(); + fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + /** + * fillContextMenuRuleTable + * fills context menu for rule table. + * @param manager menumanager + */ + + @SuppressWarnings("unchecked") + private void fillContextMenuRuleTable(IMenuManager manager) { + ISelection selection = viewerRuleTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + if(selectionList.size() == 1){ + manager.add(actionEditRule); + manager.add(actionClearOneRuleCounters); + manager.add(actionShowHistory); + manager.add(actionCopyRule); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + manager.add(actionDeleteRule); + } + else if(selectionList.size() > 1){ + manager.add(actionClearOneRuleCounters); + manager.add(actionShowHistory); + manager.add(actionDeleteRule); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + } + + + /** + * fillContextMenuFailLog. + * fills context menu for fail log view. + * @param manager menumanager + */ + + private void fillContextMenuFailLog(IMenuManager manager) { + manager.add(actionShowInTraceViewer); + } + + /** + * fillLocalToolBar. + * fills local toolbar. + * @param manager menumanager + */ + private void fillLocalToolBar(IToolBarManager manager) { + manager.removeAll(); + if(tabFolder.getSelectionIndex() == TAB_INDEX_RULE_LIST && actionCopyRule != null){ + manager.add(actionCreateNewRule); + manager.add(actionClearAllCounters); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + manager.add(actionDeleteRule); + manager.update(true); + } + else if (tabFolder.getSelectionIndex() == TAB_INDEX_FAIL_LOG && actionCopyRule != null){ + manager.add(actionClearFailLog); + manager.update(true); + } + } + + /** + * fills local menu + */ + private void fillLocalPullDown(IMenuManager manager) { + manager.removeAll(); + if(tabFolder.getSelectionIndex() == TAB_INDEX_RULE_LIST && actionCopyRule != null){ + manager.add(actionCreateNewRule); + manager.add(actionClearAllCounters); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + manager.add(actionDeleteRule); + manager.update(true); + } + else if (tabFolder.getSelectionIndex() == TAB_INDEX_FAIL_LOG && actionCopyRule != null){ + manager.add(actionClearFailLog); + manager.update(true); + } + } + + /** + * makeActions. + * Creates actions for main view. + */ + @SuppressWarnings("unchecked") + private void makeActions() { + + actionDeleteRule = new Action() { + public void run() { + if(tabFolder.getSelectionIndex() == TAB_INDEX_RULE_LIST){ + ISelection selection = viewerRuleTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + + // Confirm deletion + if(showConfirmation("Trace Analyser - Delete Rule", "Are you sure you want to delete selected files?")){ + boolean error = false; + + for(RuleInformation item : selectionList){ + if(!engine.removeRule(item.getRule().getName())){ + error = true; + } + } + if(error){ + showErrorMessage("Trace Analyser - Error", "An error occured when deleting rule(s)."); + } + refreshRuleContentAndView(); + } + } + + } + }; + actionDeleteRule.setText("Delete Selected Rule"); + actionDeleteRule.setToolTipText("Delete Selected Rule"); + actionDeleteRule.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); + + + + actionClearOneRuleCounters = new Action() { + public void run() { + ISelection selection = viewerRuleTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + + if(showConfirmation("Trace Analyser - Clear History", "Are you sure you want to clear selected rule's history information?")){ + for(RuleInformation item : selectionList){ + engine.resetOneRulesHistory(item.getRule().getName()); + } + } + + } + }; + actionClearOneRuleCounters.setText("Clear Selected Rule's Counters"); + actionClearOneRuleCounters.setToolTipText("Clear Selected Rule's Counters"); + + + + actionClearAllCounters = new Action() { + public void run() { + if(showConfirmation("Trace Analyser - Clear History", "Are you sure you want to clear all rule's history information?")){ + engine.resetHistory(); + } + } + }; + actionClearAllCounters.setText("Clear All Rule's counters"); + actionClearAllCounters.setToolTipText("Clear All Rule's counters"); + actionClearAllCounters.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_CLEAR_ALL)); + + actionCreateNewRule = new Action() { + public void run() { + // create dialog + EditRuleDialog dialog = new EditRuleDialog(getSite().getShell(), ruleTypes, null, engine, true); + + // open query dialog + int retVal = dialog.open(); + + // if ok pressed + if( retVal == 0 ){ + refreshRuleContentAndViewAsynch(); + } + + } + }; + actionCreateNewRule.setText("Create New Rule"); + actionCreateNewRule.setToolTipText("Create New Rule"); + actionCreateNewRule.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_CREATE_NEW)); + + + doubleClickAction = new Action() { + public void run() { + if(tabFolder.getSelectionIndex() == TAB_INDEX_RULE_LIST){ + actionEditRule.run(); + } + else if(tabFolder.getSelectionIndex() == TAB_INDEX_FAIL_LOG){ + actionShowInTraceViewer.run(); + + } + } + }; + + actionEditRule = new Action() { + public void run() { + ISelection selection = viewerRuleTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + //verify that only one file is selected. + if( selectionList.size() == 1 ){ + + TraceAnalyserRule rule = selectionList.get(0).getRule(); + String ruleName = rule.getName(); + EditRuleDialog dialog = new EditRuleDialog(getSite().getShell(), ruleTypes, rule, engine, false); + int retVal = dialog.open(); + // open query dialog + if( retVal == 0 ){ + for(HistoryEditor item : openEditors){ + if(item.getRuleName().equals(ruleName)){ + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + activePage.closeAllEditors(false); + + } + } + refreshRuleContentAndViewAsynch(); + } + // Cancel pressed + else if( retVal == 1 ){ + + } + } + + } + }; + actionEditRule.setText("Edit Selected Rule"); + actionEditRule.setToolTipText("Edit Selected Rule"); + + actionClearFailLog = new Action() { + public void run() { + if(showConfirmation("Trace Analyser - Clear Fail Log", "Are your sure you want to clear Fail Log")){ + engine.clearFailLog(); + } + } + }; + actionClearFailLog.setText("Clear Fail Log"); + actionClearFailLog.setToolTipText("Clear Fail Log"); + actionClearFailLog.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_CLEAR_FAIL_LOG)); + + + + actionShowInTraceViewer = new Action() { + public void run() { + ISelection selection = viewerFailLogTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + //verify that only one file is selected. + if( selectionList.size() == 1 ){ + //sync to trace + + TVAPIError error; + if(selectionList.get(0).getTraceNumbers().length == 1){ + error = TraceViewerAPI.syncToTrace(selectionList.get(0).getTraceNumbers()[0], 0); + + } + else{ + error = TraceViewerAPI.syncToTrace(selectionList.get(0).getTraceNumbers()[0], selectionList.get(0).getTraceNumbers()[1]); + } + + + if(error == TVAPIError.NONE){ + showTraceViewer(); + } + else{ + showErrorMessage("Trace Analyser - Error", + "Unable to locate events from TraceViewer's log. Perhaps the log has been cleared."); + } + + } + } + }; + actionShowInTraceViewer.setText("Show in TraceViewer"); + actionShowInTraceViewer.setToolTipText("Show in TraceViewer"); + + actionShowHistory = new Action() { + public void run() { + ISelection selection = viewerRuleTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + //verify that only one file is selected. + if( selectionList.size() == 1 ){ + HistoryEditorInput input = new HistoryEditorInput(selectionList.get(0)); + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + openEditors.add((HistoryEditor)activePage.openEditor(input,"com.nokia.s60tools.traceanalyser.ui.editors.HistoryEditor")); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + } + }; + actionShowHistory.setText("Show History"); + actionShowHistory.setToolTipText("Show History"); + + + actionCopyRule = new Action() { + public void run() { + ISelection selection = viewerRuleTable.getSelection(); + Object obj = ((IStructuredSelection)selection).toList(); + List selectionList = (List)obj; + //verify that only one file is selected. + if( selectionList.size() == 1 ){ + + TraceAnalyserRule rule = selectionList.get(0).getRule(); + + EditRuleDialog dialog = new EditRuleDialog(getSite().getShell(), ruleTypes, rule, engine, true); + int retVal = dialog.open(); + // open query dialog + if( retVal == 0 ){ + + refreshRuleContentAndViewAsynch(); + } + // Cancel pressed + else if( retVal == 1 ){ + + } + + + + } + } + }; + actionCopyRule.setText("Copy Selected Rule"); + actionCopyRule.setToolTipText("Copy Selected Rule"); + } + + /** + * hookDoubleClickAction. + */ + private void hookDoubleClickAction() { + IDoubleClickListener listener = new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + doubleClickAction.run(); + } + }; + + viewerRuleTable.addDoubleClickListener(listener); + viewerFailLogTable.addDoubleClickListener(listener); + } + + + + /** + * Passing the focus request to the viewer's control. + */ + public void setFocus() { + viewerRuleTable.getControl().setFocus(); + } + + + + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver#rulesUpdated() + */ + public void rulesUpdated() { + Runnable refreshRunnable = new Runnable(){ + public void run(){ + + viewerRuleTable.refresh(); + readActivationStatus(); + for(HistoryEditor item : openEditors){ + item.historyUpdated(); + + } + + } + }; + + Display.getDefault().asyncExec(refreshRunnable); + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver#ruleUpdated(java.lang.String) + */ + public void ruleUpdated(final String ruleName){ + + Runnable refreshRunnable = new Runnable(){ + public void run(){ + + viewerRuleTable.refresh(); + readActivationStatus(); + + for(HistoryEditor item : openEditors){ + item.historyUpdated(); + + } + + } + }; + + Display.getDefault().asyncExec(refreshRunnable); + + } + + /** + * refreshRuleContentAndViewAsynch. + * Refreshes content and view asynchronously. + */ + private void refreshRuleContentAndViewAsynch(){ + Runnable refreshRunnable = new Runnable(){ + public void run(){ + refreshRuleContentAndView(); + } + }; + + Display.getDefault().asyncExec(refreshRunnable); + + } + /** + * refreshRuleContentAndView. + * Refreshes content and view asynchronously. + */ + private void refreshRuleContentAndView(){ + contentProviderRuleTable.refresh(); + viewerRuleTable.refresh(); + readActivationStatus(); + + + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(SelectionEvent arg0) { + // nothing to be done. + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent event) { + if(event.widget == tabFolder){ + contributeToActionBars(); + } + if(event.detail == SWT.CHECK){ + RuleInformation info = (RuleInformation)event.item.getData(); + boolean value = viewerRuleTable.getChecked(event.item.getData()); + engine.changeRuleaActivation(info.getRule().getName(), value); + } + } + + /* + * (non-Javadoc) + * @see com.nokia.s60tools.traceanalyser.interfaces.ITraceAnalyserFileObserver#failLogUpdated() + */ + public void failLogUpdated() { + Runnable refreshRunnable = new Runnable(){ + public void run(){ + + viewerFailLogTable.refresh(); + } + }; + + Display.getDefault().asyncExec(refreshRunnable); + + } + + /** + * refreshFailLogContentAndViewAsynch. + * Refreshes content and view asynchronously. + */ + private void refreshFailLogContentAndViewAsynch(){ + Runnable refreshRunnable = new Runnable(){ + public void run(){ + refreshFailLogContentAndView(); + } + }; + + Display.getDefault().asyncExec(refreshRunnable); + + } + /** + * refreshFailLogContentAndView. + * Refreshes content and view asynchronously. + */ + private void refreshFailLogContentAndView(){ + contentProviderFailLogTable.refresh(); + viewerFailLogTable.refresh(); + } + + public void dispose(){ + TraceAnalyserPlugin.setMainView(null); + } + + + /** + * showTraceViewer + * shows trace viewer plugin + */ + public static void showTraceViewer() { + try { + + IWorkbenchWindow ww = TraceAnalyserPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + if (ww == null) + return; + IWorkbenchPage page = ww.getActivePage(); + + // Checking if view is already open + IViewReference[] viewRefs = page.getViewReferences(); + for (int i = 0; i < viewRefs.length; i++) { + IViewReference reference = viewRefs[i]; + String id = reference.getId(); + if(id.equalsIgnoreCase(TRACE_VIEWER_VIEW_ID)){ + // Found, restoring the view + IViewPart viewPart = reference.getView(true); + page.activate(viewPart); + return; + } + } + + // View was not found, opening it up as a new view. + page.showView(TRACE_VIEWER_VIEW_ID); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * blinks icon when fail received. + */ + public void blinkIcon(){ + Runnable refreshRunnable = new Runnable(){ + public void run(){ + setTitleImage(ImageResourceManager.getImage(ImageKeys.IMG_FAIL_RECEIVED)); + } + }; + + + if(timer == null || !timer.isRunning()){ + timer = new Timer(500, this); + timer.start(); + Display.getDefault().asyncExec(refreshRunnable); + + } + else{ + + } + + } + + /* + * (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent arg0) { + Runnable refreshRunnable = new Runnable(){ + public void run(){ + + if(blinkCount % 2 == 1){ + setTitleImage(ImageResourceManager.getImage(ImageKeys.IMG_FAIL_RECEIVED)); + } + else{ + setTitleImage(ImageResourceManager.getImage(ImageKeys.IMG_APP_ICON)); + } + blinkCount++; + + if( blinkCount == 3){ + blinkCount = 0; + timer.stop(); + } + } + }; + Display.getDefault().asyncExec(refreshRunnable); + + } + + /** + * Reads activation status and sets table's check/uncheck status correct + */ + private void readActivationStatus(){ + int i = 0; + while(true){ + Object information = viewerRuleTable.getElementAt(i); + if(information != null){ + if( ((RuleInformation)information).getRule().isActivated()){ + viewerRuleTable.setChecked(information, true); + } + } + else{ + break; + } + i++; + + } + } + + + + /** + * showErrorMessage. + * shows error message asynchronously + * @param header header of message + * @param text error text + */ + public void showErrorMessage(String header, String text){ + MessageDialog.openError( getSite().getShell(), header, text); + } + + + + /** + * showConfirmation. + * Displays a Confirmation dialog + * @param header text for window header + * @param text text for window text + * @return true, if yes was pressed. + */ + public boolean showConfirmation(String header, String text){ + MessageBox messageBox = new MessageBox(this.getSite().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); + messageBox.setText(header); + messageBox.setMessage(text); + int retval = messageBox.open(); + if(retval == SWT.YES){ + return true; + } + else{ + return false; + } + + } + + + /** + * editorClosed + * removes editor pointer from openEditors-array + * @param ruleName name of the rule. + */ + public void editorClosed(String ruleName){ + HistoryEditor closeEditor = null; + for(HistoryEditor item : openEditors){ + if(item.getRuleName().equals(ruleName)){ + closeEditor = item; + } + } + openEditors.remove(closeEditor); + } + + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) + */ + public void keyPressed(KeyEvent keyEvent) { + + // if delete key is pressed run delete -action. + if( keyEvent.keyCode == java.awt.event.KeyEvent.VK_DELETE){ + actionDeleteRule.run(); + } + } + /* + * (non-Javadoc) + * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) + */ + public void keyReleased(KeyEvent arg0) { + // can be left empty. + } + + /** + * Activate/deactivate all rules in main view + */ + private void checkAllPressed(){ + boolean activationStatus = false; + + // compare amount of checked and unchecked rules + if( viewerRuleTable.getCheckedElements().length <= (viewerRuleTable.getTable().getItemCount() / 2)){ + activationStatus = true; + } + int i = 0; + while(true){ + RuleInformation information = (RuleInformation)viewerRuleTable.getElementAt(i); + if(information != null){ + viewerRuleTable.setChecked(information, activationStatus); + engine.changeRuleaActivation(information.getRule().getName(), activationStatus); + } + else{ + break; + } + i++; + + } + } + + /** + * Sets this page's context sensitive helps + */ + protected void setHelps() { + PlatformUI.getWorkbench().getHelpSystem().setHelp( viewerFailLogTable.getControl(), com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_FAIL_LOG); + PlatformUI.getWorkbench().getHelpSystem().setHelp( tabFolder, com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_MAIN_VIEW); + PlatformUI.getWorkbench().getHelpSystem().setHelp( viewerRuleTable.getControl(), com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_MAIN_VIEW); + PlatformUI.getWorkbench().getHelpSystem().setHelp( getSite().getShell(), com.nokia.s60tools.traceanalyser.resources.HelpContextIDs.TRACE_ANALYSER_MAIN_VIEW); + + } + + +} \ No newline at end of file diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/RuleTableContentProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/RuleTableContentProvider.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.views; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; +import com.nokia.s60tools.traceanalyser.model.Engine; + +/** + * class RuleTableContentProvider + * content provider for rule table. + */ +class RuleTableContentProvider implements IStructuredContentProvider { + + /* Trace Analyser Engine */ + private final Engine engine; + + /** + * RuleTableContentProvider. + * constructor. + * @param engine + */ + public RuleTableContentProvider(Engine engine){ + this.engine = engine; + } + + /** + * refresh + * refreshes rule list. + */ + public void refresh() { + engine.refreshRuleList(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object parent) { + return engine.getRuleInformation(); + } + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/RuleTableDataSorter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/RuleTableDataSorter.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.traceanalyser.ui.views; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; + +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; + + +/** + * class RuleTableDataSorter + * Data sorter for Trace Analyser's rule view. + */ + +public class RuleTableDataSorter extends ViewerSorter { + + /** + * Import function data is sorted by file name + */ + public static final int RULE_NAME = 2; + /** + * + */ + public static final int PASS = 3; + public static final int FAIL = 4; + public static final int PASSPERCENT = 5; + public static final int MIN = 6; + public static final int MAX = 7; + public static final int AVG = 8; + public static final int MED = 9; + + private int sortCriteria; + + public RuleTableDataSorter(int sortCriteria) { + super(); + // By default set sort criterie + this.sortCriteria = sortCriteria; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public int compare(Viewer viewer, Object e1, Object e2) { + + + // By default comparison does not do any ordering + int comparisonResult = 0; + + RuleInformation f1 = (RuleInformation) e1; + RuleInformation f2 = (RuleInformation) e2; + + switch (sortCriteria) { + + case RULE_NAME: + comparisonResult = f1.getRule().getName().compareToIgnoreCase(f2.getRule().getName()); + break; + case PASS: + if(f1.getPass() < f2.getPass()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + + } + break; + case FAIL: + if(f1.getFail() < f2.getFail()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + + } + break; + + case PASSPERCENT: + if(f1.getPassPercent() < f2.getPassPercent()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + } + break; + + case MIN: + if(f1.getMin() < f2.getMin()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + + } + break; + + case MAX: + if(f1.getMax() < f2.getMax()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + + } + break; + + case MED: + if(f1.getMed() < f2.getMed()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + + } + break; + case AVG: + if(f1.getAvg() < f2.getAvg()){ + comparisonResult = 1; + } + else{ + comparisonResult = -1; + + } + break; + + + default: + break; + } + + return comparisonResult; + + } + + + +} diff -r 15296fd0af4a -r 14dc2103a631 trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/RuleTableLabelProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trace/traceanalyser/com.nokia.s60tools.traceanalyser/src/com/nokia/s60tools/traceanalyser/ui/views/RuleTableLabelProvider.java Wed Jun 23 13:57:56 2010 +0300 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +package com.nokia.s60tools.traceanalyser.ui.views; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +import com.nokia.s60tools.traceanalyser.containers.RuleInformation; + +/** + * class RuleTableLabelProvider + * label provider for rule table. + * + */ + +class RuleTableLabelProvider extends LabelProvider implements ITableLabelProvider { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) + */ + public String getColumnText(Object obj, int index) { + RuleInformation rule = (RuleInformation)obj; + return rule.getText(index); + + + } + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) + */ + public Image getColumnImage(Object obj, int index) { + /*if (index == MemSpyFileBundle.INDEX_FILE_TYPE){ + return getImage(obj); + } + else{ + return null; + }*/ + return null; + + } + + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + + public Image getImage(Object obj) { + /*MemSpyFileBundle bundle = (MemSpyFileBundle)obj; + if( bundle.isHeapDumpFile() ){ + return ImageResourceManager.getImage(ImageKeys.IMG_HEAP_DUMP); + } + else{ + return ImageResourceManager.getImage(ImageKeys.IMG_SWMT_LOG); + }*/ + return PlatformUI.getWorkbench(). + getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); + } +} \ No newline at end of file