sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/wizards/ReportCreationJob.java
changeset 7 8e12a575a9b5
equal deleted inserted replaced
6:f65f740e69f9 7:8e12a575a9b5
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 package com.nokia.s60tools.swmtanalyser.wizards;
       
    18 
       
    19 import java.awt.Color;
       
    20 import java.io.FileNotFoundException;
       
    21 import java.io.FileOutputStream;
       
    22 import java.io.IOException;
       
    23 import java.net.MalformedURLException;
       
    24 import java.util.ArrayList;
       
    25 
       
    26 import org.eclipse.core.runtime.IProgressMonitor;
       
    27 import org.eclipse.core.runtime.IStatus;
       
    28 import org.eclipse.core.runtime.Status;
       
    29 import org.eclipse.core.runtime.jobs.Job;
       
    30 import org.eclipse.swt.widgets.Display;
       
    31 import org.eclipse.swt.widgets.Tree;
       
    32 import org.eclipse.swt.widgets.TreeItem;
       
    33 
       
    34 import com.lowagie.text.BadElementException;
       
    35 import com.lowagie.text.Chapter;
       
    36 import com.lowagie.text.Chunk;
       
    37 import com.lowagie.text.Document;
       
    38 import com.lowagie.text.DocumentException;
       
    39 import com.lowagie.text.Element;
       
    40 import com.lowagie.text.Font;
       
    41 import com.lowagie.text.FontFactory;
       
    42 import com.lowagie.text.PageSize;
       
    43 import com.lowagie.text.Paragraph;
       
    44 import com.lowagie.text.Rectangle;
       
    45 import com.lowagie.text.pdf.GrayColor;
       
    46 import com.lowagie.text.pdf.PdfPCell;
       
    47 import com.lowagie.text.pdf.PdfPTable;
       
    48 import com.lowagie.text.pdf.PdfWriter;
       
    49 import com.nokia.s60tools.swmtanalyser.SwmtAnalyserPlugin;
       
    50 import com.nokia.s60tools.swmtanalyser.analysers.AnalyserConstants;
       
    51 import com.nokia.s60tools.swmtanalyser.data.OverviewData;
       
    52 import com.nokia.s60tools.util.console.AbstractProductSpecificConsole;
       
    53 import com.nokia.s60tools.util.console.IConsolePrintUtility;
       
    54 
       
    55 /**
       
    56  * Job to create PDF report.
       
    57  *
       
    58  */
       
    59 public class ReportCreationJob extends Job {
       
    60 	
       
    61 
       
    62 	/**
       
    63 	 * Spacing after a header text, to avoid texts to be too close each other
       
    64 	 */
       
    65 	private static final int SPACING_AFTER_HEADER_TEXT = 5;
       
    66 	//Paddings in cells
       
    67 	private float cellPaddingSmall;
       
    68 	private float cellPaddingTableHeader;
       
    69 	
       
    70 	//Colors used in document
       
    71 	private Color colorHeading;
       
    72 	private Color colorTableHeaderBackGrd;
       
    73 	private Color colorTable2ndHeaderBackGrd;
       
    74 	private Color colorSeverityNormal;
       
    75 	private Color colorSeverityHigh;
       
    76 	private Color colorSeverityCritical;
       
    77 	
       
    78 	//Fonts used in document
       
    79 	private Font fontTable2ndHeaderText;
       
    80 	private Font fontHeader;
       
    81 	private Font fontNormalSmallTables;
       
    82 	private Font fontNormal;
       
    83 	private Font fontHeading2;
       
    84 	private Font fontHeading1;
       
    85 	
       
    86 	//PDF filename
       
    87 	private String fileName = null;
       
    88 	//Use given comments
       
    89 	private String comment = null;
       
    90 	//Oveview info to write in pdf
       
    91 	private OverviewData ov;
       
    92 	//ROM Checksum to write in pdf
       
    93 	private String rom_checkSum_string;
       
    94 	//ROM Version to write in pdf
       
    95 	private String rom_version_string;
       
    96 	//Tree object to get the issues info
       
    97 	private Tree all_tree_items; 
       
    98 	//To save the report type option
       
    99 	boolean isOverviewReport;
       
   100 	//temporary variable
       
   101 	private PdfPTable table;
       
   102 	
       
   103 	/**
       
   104 	 * Job constructor.
       
   105 	 * @param name Job name
       
   106 	 * @param fileName PDF filename
       
   107 	 * @param comment User given comments
       
   108 	 * @param ov Overview object
       
   109 	 * @param checksum ROM Checksum
       
   110 	 * @param version ROM Version
       
   111 	 * @param issues_tree Tree object from Analysis view.
       
   112 	 * @param isOverviewReport report type
       
   113 	 */
       
   114 	public ReportCreationJob(String name, String fileName, String comment, OverviewData ov, String checksum, String version, Tree issues_tree, boolean isOverviewReport) {
       
   115 		super(name);
       
   116 		this.fileName = fileName;
       
   117 		this.comment = comment;
       
   118 		this.ov = ov;
       
   119 		this.rom_checkSum_string = checksum;
       
   120 		this.rom_version_string = version;
       
   121 		this.all_tree_items = issues_tree;
       
   122 		this.isOverviewReport = isOverviewReport;
       
   123 		
       
   124 		//Initialize Colors and Fonts
       
   125 		initStyles();				
       
   126 	}
       
   127 
       
   128 	/**
       
   129 	 * Initializing Colors and fonts to be used in PDF Document.
       
   130 	 * Color scheme is taken from Carbide logo.
       
   131 	 */
       
   132 	private void initStyles() {
       
   133 		
       
   134 		//
       
   135 		// Colors used are picked up from Carbide.c++ -logo, from dark blue to white
       
   136 		// #003399 = 0, 51, 153 -Dark blue
       
   137 		// #0088ff = 0, 136, 255 -mid blue
       
   138 		// #33aaff = 51, 170, 255 -mid blue 2
       
   139 		// #88ccff = 136, 204, 255 -thin blue
       
   140 		// #ffffff = -white
       
   141 		//
       
   142 		 
       
   143 		//
       
   144 		//Using Carbide.c++ logo colors to decorate report
       
   145 		//
       
   146 		colorHeading = new Color(0, 51, 153);
       
   147 		colorTableHeaderBackGrd = new Color (136, 204, 255);
       
   148 		colorTable2ndHeaderBackGrd = new Color (0, 136, 255);
       
   149 		
       
   150 
       
   151 		//
       
   152 		// Setting Severity Colors for PDF report from Analyser view colors.
       
   153 		//
       
   154 		org.eclipse.swt.graphics.Color color = AnalyserConstants.COLOR_SEVERITY_CRITICAL; 
       
   155 		colorSeverityCritical = new Color (color.getRed(),color.getGreen(),color.getBlue());		
       
   156 
       
   157 		color = AnalyserConstants.COLOR_SEVERITY_HIGH;
       
   158 		colorSeverityHigh = new Color (color.getRed(),color.getGreen(),color.getBlue());		
       
   159 		
       
   160 		color = AnalyserConstants.COLOR_SEVERITY_NORMAL; 
       
   161 		colorSeverityNormal = new Color (color.getRed(),color.getGreen(),color.getBlue());
       
   162 		
       
   163 		//
       
   164 		// Font used in report
       
   165 		//
       
   166 		String font =  FontFactory.HELVETICA;
       
   167 
       
   168 		//
       
   169 		// Creating fonts
       
   170 		//
       
   171 		fontTable2ndHeaderText = FontFactory.getFont(font,10f,Font.NORMAL, Color.WHITE);
       
   172 		fontHeader = FontFactory.getFont(font, 16, Font.BOLD, Color.BLACK);
       
   173 		fontNormalSmallTables = FontFactory.getFont(font,9f,Font.NORMAL);
       
   174 		fontNormal = FontFactory.getFont(font,10f,Font.NORMAL);
       
   175 		fontHeading2 = FontFactory.getFont(font,10f,Font.BOLD);
       
   176 		fontHeading1 = FontFactory.getFont(font,12f,Font.BOLD, colorHeading);
       
   177 		
       
   178 		cellPaddingSmall = 1.0f;
       
   179 		cellPaddingTableHeader = 3.0f;
       
   180 		
       
   181 	}
       
   182 
       
   183 	/* (non-Javadoc)
       
   184 	 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
       
   185 	 */
       
   186 	protected IStatus run(IProgressMonitor monitor) {
       
   187 	
       
   188 		monitor.beginTask("Creating report...", 10);
       
   189 
       
   190 		try {
       
   191 			//Instantiation of document object
       
   192 			Document document = new Document(PageSize.A4, 50, 50, 50, 50);
       
   193 			PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(this.fileName));
       
   194 			document.open();
       
   195 			
       
   196 			addGeneralDetails(document);
       
   197 			
       
   198 			if(!this.isOverviewReport) //If the report type is 1. i.e., report for selected issues only.
       
   199 			{
       
   200 				addSelectedIssuesReport(document);
       
   201 			}
       
   202 			else // If the report type is 2. i.e., Overview report
       
   203 			{
       
   204 				addOverviewReport(document);
       
   205 			}
       
   206 			
       
   207 			addComments(document);
       
   208 			
       
   209 			//Close document
       
   210 			document.close();
       
   211 			//Close the writer
       
   212 			writer.close();
       
   213 			
       
   214 			
       
   215 		} catch (DocumentException e) {
       
   216 			e.printStackTrace();
       
   217 			SwmtAnalyserPlugin.getConsole().println("Unable to write document, error was: '" +e +"'", IConsolePrintUtility.MSG_ERROR);
       
   218 		}		
       
   219 		catch (FileNotFoundException e) {
       
   220 			e.printStackTrace();
       
   221 			SwmtAnalyserPlugin.getConsole().println("Unable to write document, error was: '" +e +"'", IConsolePrintUtility.MSG_ERROR);
       
   222 		}		
       
   223 		catch (Exception e) {
       
   224 			e.printStackTrace();
       
   225 			AbstractProductSpecificConsole absConsole = (AbstractProductSpecificConsole)SwmtAnalyserPlugin.getConsole();
       
   226 			absConsole.printStackTrace(e);
       
   227 			SwmtAnalyserPlugin.getConsole().println("Unable to write document, error was: '" +e +"'", IConsolePrintUtility.MSG_ERROR);
       
   228 		}		
       
   229 		return Status.OK_STATUS;
       
   230 	}
       
   231 
       
   232 	private void addComments(Document document) throws DocumentException {
       
   233 		//Create new line
       
   234 		document.add(Chunk.NEWLINE);
       
   235 		//Comments heading
       
   236 		Paragraph comments_title = new Paragraph("User given comments", fontHeading1);
       
   237 		document.add(comments_title);
       
   238 		
       
   239 		Paragraph comments = new Paragraph(this.comment, fontNormal);
       
   240 		document.add(comments);
       
   241 	}
       
   242 
       
   243 	private void addGeneralDetails(Document document) throws DocumentException {
       
   244 		//Report Title
       
   245 		Paragraph title = new Paragraph("MemSpy - System Wide Memory Tracking - Analysis Report", fontHeader);
       
   246 		title.setAlignment(Element.ALIGN_CENTER);
       
   247 		document.add(title);
       
   248 		document.add(Chunk.NEWLINE);
       
   249 		
       
   250 		//Introduction title
       
   251 		Paragraph hdng = new Paragraph("Introduction of Memspy (S60) and SWMT Analyser", fontHeading1);
       
   252 		document.add(hdng);
       
   253 		
       
   254 		//About the MemSpy S60 Application
       
   255 		Paragraph intro_memspy = new Paragraph("The MemSpy S60 application tracks various subsystems that directly or indirectly contribute to overall system memory usage and provides information about the changes in these subsystems at specified time intervals.", fontNormal);
       
   256 		document.add(intro_memspy);
       
   257 		document.add(Chunk.NEWLINE);
       
   258 		//About the SWMT Analyser
       
   259 		Paragraph intro_swmt = new Paragraph("A System Wide Memory Tracker log file contains information about system wide memory status changes over time. SWMT Analyser is a Carbide.c++ Extension for analyzing System Wide Memory Tracking logs produced by the MemSpy S60 application and imported to PC with the MemSpy Carbide.c++ Extension.", fontNormal);
       
   260 		document.add(intro_swmt);
       
   261 		document.add(Chunk.NEWLINE);
       
   262 		
       
   263 		//Properties heading
       
   264 		Paragraph props_title = new Paragraph("Properties", fontHeading1);
       
   265 		document.add(props_title);
       
   266 		Chunk no_of_cycles = new Chunk("No of cycles	:	", fontHeading2);
       
   267 		document.add(no_of_cycles);
       
   268 		Chunk cycles = new Chunk(ov.noOfcycles+"", fontNormal);
       
   269 		document.add(cycles);
       
   270 		document.add(Chunk.NEWLINE);
       
   271 		
       
   272 		Chunk time_period = new Chunk("Time period	:	", fontHeading2);
       
   273 		document.add(time_period);
       
   274 		Chunk period = new Chunk(ov.fromTime+" to "+ov.toTime, fontNormal);
       
   275 		document.add(period);
       
   276 		document.add(Chunk.NEWLINE);
       
   277 		
       
   278 		Chunk duration = new Chunk("Time duration	:	", fontHeading2);
       
   279 		document.add(duration);
       
   280 		Chunk dur = new Chunk(ov.durationString, fontNormal);
       
   281 		document.add(dur);
       
   282 		document.add(Chunk.NEWLINE);
       
   283 		
       
   284 		
       
   285 		document.add(Chunk.NEWLINE);
       
   286 		Paragraph rom_title = new Paragraph("ROM Details", fontHeading1);
       
   287 		document.add(rom_title);
       
   288 		Chunk rom_checksum = new Chunk("ROM Checksum	:	", fontHeading2);
       
   289 		document.add(rom_checksum);
       
   290 		Chunk checksum = new Chunk(this.rom_checkSum_string, fontNormal);
       
   291 		document.add(checksum);
       
   292 		document.add(Chunk.NEWLINE);
       
   293 		
       
   294 		Chunk rom_version = new Chunk("ROM Version	:	", fontHeading2);
       
   295 		document.add(rom_version);
       
   296 		Chunk version = new Chunk(this.rom_version_string, fontNormal);
       
   297 		document.add(version);
       
   298 		document.add(Chunk.NEWLINE);
       
   299 		document.add(Chunk.NEWLINE);
       
   300 	}
       
   301 
       
   302 	private void addSelectedIssuesReport(Document document) throws DocumentException,
       
   303 			BadElementException {
       
   304 		Paragraph selected_title = new Paragraph("Selected issues", fontHeading1);
       
   305 		selected_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT);
       
   306 		document.add(selected_title);
       
   307 		
       
   308 		Display.getDefault().syncExec(new Runnable() {
       
   309 			public void run() {
       
   310 				table = getTableForTheSelectedIssues(all_tree_items);
       
   311 			}
       
   312 		});
       
   313 		document.add(table);
       
   314 
       
   315 		document.add(Chunk.NEWLINE);
       
   316 		
       
   317 
       
   318 		Paragraph graph_title = new Paragraph("Graph for the selected issues", fontHeading1);
       
   319 		//Using chapter, so title stays together with image 
       
   320 		Chapter chapter = new Chapter(graph_title,0);
       
   321 		//Chapter with out number, when depth is 0
       
   322 		chapter.setNumberDepth(0);
       
   323 
       
   324 		
       
   325 		com.lowagie.text.Image img = null;
       
   326 		try {
       
   327 			img = com.lowagie.text.Image.getInstance(SwmtAnalyserPlugin.getPluginInstallPath()+"\\swmt_graph.bmp");
       
   328 		} catch (MalformedURLException e) {
       
   329 			e.printStackTrace();
       
   330 		} catch (IOException e) {
       
   331 			e.printStackTrace();
       
   332 		}
       
   333 		img.scalePercent(50f);
       
   334 		img.setBorder(Rectangle.BOX);
       
   335 		img.setBorderWidth(1f);
       
   336 		img.setBorderColor(new GrayColor(0.5f));
       
   337 		//Adding image to chapter
       
   338 		chapter.add(img);
       
   339 		//Adding chapter to document
       
   340 		document.add(chapter);
       
   341 		
       
   342 	}
       
   343 
       
   344 	private void addOverviewReport(Document document) throws DocumentException {
       
   345 		Paragraph res_title = new Paragraph("Overview Of Analysis Results", fontHeading1);
       
   346 		res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT);
       
   347 		document.add(res_title);
       
   348 		
       
   349 		Display.getDefault().syncExec(new Runnable() {
       
   350 			public void run() {
       
   351 				table = getTableForOverallIssues(all_tree_items);
       
   352 			}
       
   353 		});
       
   354 		document.add(table);
       
   355 		document.add(Chunk.NEWLINE);
       
   356 		
       
   357 		res_title = new Paragraph("Details", fontHeading1);
       
   358 		document.add(res_title);
       
   359 		
       
   360 		res_title = new Paragraph("Critical Severity Issues", fontHeading2);
       
   361 		res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT);
       
   362 		
       
   363 		Display.getDefault().syncExec(new Runnable() {
       
   364 			public void run() {
       
   365 				table = getTableForIssues(all_tree_items, AnalyserConstants.Priority.CRITICAL);;
       
   366 			}
       
   367 		});
       
   368 		if(table!=null)
       
   369 		{
       
   370 			document.add(res_title);			
       
   371 			document.add(table);
       
   372 			document.add(Chunk.NEWLINE);
       
   373 		}
       
   374 		
       
   375 		res_title = new Paragraph("High Severity Issues", fontHeading2);
       
   376 		res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT);
       
   377 		
       
   378 		Display.getDefault().syncExec(new Runnable() {
       
   379 			public void run() {
       
   380 				table = getTableForIssues(all_tree_items, AnalyserConstants.Priority.HIGH);
       
   381 			}
       
   382 		});
       
   383 		if(table!=null)
       
   384 		{
       
   385 			document.add(res_title);
       
   386 			document.add(table);
       
   387 			document.add(Chunk.NEWLINE);
       
   388 		}
       
   389 		
       
   390 		res_title = new Paragraph("Normal Severity Issues", fontHeading2);
       
   391 		res_title.setSpacingAfter(SPACING_AFTER_HEADER_TEXT);
       
   392 		
       
   393 		Display.getDefault().syncExec(new Runnable() {
       
   394 			public void run() {
       
   395 				table = getTableForIssues(all_tree_items, AnalyserConstants.Priority.NORMAL);
       
   396 			}
       
   397 		});
       
   398 		if(table!=null)
       
   399 		{
       
   400 			document.add(res_title);
       
   401 			document.add(table);
       
   402 		}
       
   403 	}
       
   404 	
       
   405 	/**
       
   406 	 * Returns a table for issues of given priority type from the selected issues.
       
   407 	 * @param allTreeItems tree
       
   408 	 * @param p priority
       
   409 	 * @return
       
   410 	 */
       
   411 	private PdfPTable getTableForIssues(Tree allTreeItems, AnalyserConstants.Priority p) {
       
   412 		
       
   413 		float[] relativeWidth = {60, 25, 15};//100% total
       
   414 		PdfPTable table = new PdfPTable(relativeWidth);
       
   415 		table.setWidthPercentage(100);
       
   416 		
       
   417 		PdfPCell cell = new PdfPCell (new Paragraph ("Item name"));
       
   418 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   419 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   420 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   421 		cell.setPadding (cellPaddingTableHeader);		
       
   422 		table.addCell (cell);
       
   423 
       
   424 		cell = new PdfPCell (new Paragraph ("Event"));
       
   425 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   426 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   427 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   428 		cell.setPadding (cellPaddingTableHeader);
       
   429 		table.addCell (cell);
       
   430 		
       
   431 		cell = new PdfPCell (new Paragraph ("Delta"));
       
   432 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   433 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   434 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   435 		cell.setPadding (cellPaddingTableHeader);
       
   436 		table.addCell (cell);
       
   437 		
       
   438 		
       
   439 		for(TreeItem parent : allTreeItems.getItems())
       
   440 		{
       
   441 			for(TreeItem child : parent.getItems())
       
   442 			{
       
   443 				if(child.getText(4).toLowerCase().equals(p.toString().toLowerCase()))
       
   444 				{
       
   445 					
       
   446 					cell = new PdfPCell (new Paragraph (child.getText(1),fontNormalSmallTables));
       
   447 					cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   448 					cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   449 					cell.setPadding (cellPaddingSmall);
       
   450 					table.addCell (cell);
       
   451 					
       
   452 					cell = new PdfPCell (new Paragraph (child.getText(2),fontNormalSmallTables));
       
   453 					cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   454 					cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   455 					cell.setPadding (cellPaddingSmall);
       
   456 					table.addCell (cell);
       
   457 					
       
   458 					cell = new PdfPCell (new Paragraph (child.getText(3),fontNormalSmallTables));
       
   459 					cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   460 					cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   461 					cell.setPadding (cellPaddingSmall);
       
   462 					table.addCell (cell);
       
   463 				}
       
   464 			}
       
   465 		}
       
   466 		if(table.getRows().size() > 1)
       
   467 			return table;
       
   468 		
       
   469 		return table;
       
   470 	}
       
   471 
       
   472 	/**
       
   473 	 * Returns a table for the overview issues of all types.
       
   474 	 * @param all
       
   475 	 * @return
       
   476 	 */
       
   477 	private PdfPTable getTableForOverallIssues(Tree all) {
       
   478 		PdfPTable table = new PdfPTable(2);
       
   479 		table.setWidthPercentage(100);
       
   480 		
       
   481 		PdfPCell cell = new PdfPCell (new Paragraph ("Severity"));
       
   482 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   483 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   484 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   485 		cell.setPadding (cellPaddingTableHeader);
       
   486 		table.addCell (cell);
       
   487 
       
   488 		cell = new PdfPCell (new Paragraph ("Count"));
       
   489 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   490 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   491 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   492 		cell.setPadding (cellPaddingTableHeader);
       
   493 		table.addCell (cell);
       
   494 		
       
   495 		int critical = 0;
       
   496 		int high = 0;
       
   497 		int normal = 0;
       
   498 		
       
   499 		for(TreeItem parent : all.getItems())
       
   500 		{
       
   501 			for(TreeItem child : parent.getItems())
       
   502 			{
       
   503 				if(child.getText(4).toLowerCase().equals(AnalyserConstants.Priority.CRITICAL.toString().toLowerCase()))
       
   504 					critical++;
       
   505 				else if(child.getText(4).toLowerCase().equals(AnalyserConstants.Priority.HIGH.toString().toLowerCase()))
       
   506 					high++;
       
   507 				else if(child.getText(4).toLowerCase().equals(AnalyserConstants.Priority.NORMAL.toString().toLowerCase()))
       
   508 					normal++;
       
   509 			}
       
   510 		}
       
   511 		
       
   512 		table.addCell(new PdfPCell (new Paragraph ("CRITICAL",fontNormalSmallTables)));
       
   513 		table.addCell(new PdfPCell (new Paragraph (critical+"",fontNormalSmallTables)));
       
   514 		table.addCell(new PdfPCell (new Paragraph ("HIGH",fontNormalSmallTables)));
       
   515 		table.addCell(new PdfPCell (new Paragraph (high+"",fontNormalSmallTables)));
       
   516 		table.addCell(new PdfPCell (new Paragraph ("NORMAL",fontNormalSmallTables)));
       
   517 		table.addCell(new PdfPCell (new Paragraph (normal+"",fontNormalSmallTables)));
       
   518 		
       
   519 		return table;
       
   520 	}
       
   521 
       
   522 	/**
       
   523 	 * Returns a table for the selected issues.
       
   524 	 * @param issuesTree
       
   525 	 * @return
       
   526 	 */
       
   527 	private PdfPTable getTableForTheSelectedIssues(Tree issuesTree) {
       
   528 
       
   529 		float[] relativeWidth = {50, 22, 14, 14};//100% total
       
   530 		PdfPTable table = new PdfPTable(relativeWidth);
       
   531 		table.setWidthPercentage(100);
       
   532 		
       
   533 		PdfPCell cell = new PdfPCell (new Paragraph ("Item name"));
       
   534 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   535 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   536 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   537 		cell.setPadding (cellPaddingTableHeader);
       
   538 		table.addCell (cell);
       
   539 
       
   540 		cell = new PdfPCell (new Paragraph ("Event"));
       
   541 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   542 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   543 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   544 		cell.setPadding (cellPaddingTableHeader);
       
   545 		table.addCell (cell);
       
   546 		
       
   547 		cell = new PdfPCell (new Paragraph ("Delta"));
       
   548 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   549 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   550 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   551 		cell.setPadding (cellPaddingTableHeader);
       
   552 		table.addCell (cell);
       
   553 		
       
   554 		cell = new PdfPCell (new Paragraph ("Severity"));
       
   555 		cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   556 		cell.setVerticalAlignment (Element.ALIGN_MIDDLE);
       
   557 		cell.setBackgroundColor (colorTableHeaderBackGrd);
       
   558 		cell.setPadding (cellPaddingTableHeader);
       
   559 		table.addCell (cell);
       
   560 		
       
   561 		for(TreeItem item : issuesTree.getItems())
       
   562 		{
       
   563 			ArrayList<TreeItem> selected = new ArrayList<TreeItem>();
       
   564 			for(TreeItem child: item.getItems())
       
   565 				if(child.getChecked())
       
   566 					selected.add(child);
       
   567 			
       
   568 			if(selected.size() > 0)
       
   569 			{
       
   570 				cell = new PdfPCell (new Paragraph (item.getText(1),fontTable2ndHeaderText));
       
   571 				cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   572 				cell.setBackgroundColor (colorTable2ndHeaderBackGrd);
       
   573 				cell.setPadding (cellPaddingTableHeader);
       
   574 				cell.setColspan(4);
       
   575 				table.addCell (cell);
       
   576 				
       
   577 				for(TreeItem child: selected)
       
   578 				{
       
   579 					cell = new PdfPCell (new Paragraph (child.getText(1),fontNormalSmallTables));
       
   580 					cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   581 					cell.setPadding (cellPaddingSmall);
       
   582 					table.addCell (cell);
       
   583 					
       
   584 					cell = new PdfPCell (new Paragraph (child.getText(2),fontNormalSmallTables));
       
   585 					cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   586 					cell.setPadding (cellPaddingSmall);
       
   587 					table.addCell (cell);
       
   588 					
       
   589 					cell = new PdfPCell (new Paragraph (child.getText(3),fontNormalSmallTables));
       
   590 					cell.setHorizontalAlignment (Element.ALIGN_LEFT);
       
   591 					cell.setPadding (cellPaddingSmall);
       
   592 					table.addCell (cell);
       
   593 
       
   594 					cell = new PdfPCell (new Paragraph (child.getText(4),fontNormalSmallTables));
       
   595 					cell.setHorizontalAlignment (Element.ALIGN_CENTER);
       
   596 					
       
   597 					if(child.getText(4).toLowerCase().equals(AnalyserConstants.Priority.CRITICAL.toString().toLowerCase())){
       
   598 						cell.setBackgroundColor (colorSeverityCritical);
       
   599 					}
       
   600 					else if(child.getText(4).toLowerCase().equals(AnalyserConstants.Priority.HIGH.toString().toLowerCase())){
       
   601 						cell.setBackgroundColor (colorSeverityHigh);
       
   602 					}
       
   603 					else if(child.getText(4).toLowerCase().equals(AnalyserConstants.Priority.NORMAL.toString().toLowerCase())){
       
   604 						cell.setBackgroundColor (colorSeverityNormal);
       
   605 					}
       
   606 					cell.setPadding(cellPaddingSmall);
       
   607 					table.addCell (cell);
       
   608 				}
       
   609 			}
       
   610 		}		
       
   611 		return table;
       
   612 	}
       
   613 
       
   614 
       
   615 }