|
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 org.eclipse.jface.dialogs.MessageDialog; |
|
20 import org.eclipse.swt.program.Program; |
|
21 import org.eclipse.swt.widgets.Display; |
|
22 import org.eclipse.swt.widgets.Tree; |
|
23 |
|
24 import com.nokia.s60tools.swmtanalyser.data.OverviewData; |
|
25 import com.nokia.s60tools.ui.wizards.S60ToolsWizard; |
|
26 |
|
27 /** |
|
28 * Report Generation Wizard |
|
29 * |
|
30 */ |
|
31 public class ReportGenerationWizard extends S60ToolsWizard { |
|
32 |
|
33 //Comments page |
|
34 private CommentsPage comments_page; |
|
35 //Overview object to write overview info to pdf |
|
36 private OverviewData ov; |
|
37 //ROM Checksum |
|
38 private String rom_checkSum; |
|
39 //ROM Version |
|
40 private String rom_version; |
|
41 //Tree object from Analysis view |
|
42 private Tree issues_tree; |
|
43 //PDF file name |
|
44 private String fileName; |
|
45 |
|
46 /** |
|
47 * Constructor |
|
48 * @param ov Overview Data Object |
|
49 * @param checksum ROM Checksum string |
|
50 * @param version ROM Version string |
|
51 * @param issues_tree Tree object from the Analysis view. |
|
52 */ |
|
53 public ReportGenerationWizard(OverviewData ov, String checksum, String version, Tree issues_tree) { |
|
54 setWindowTitle("Create Report"); |
|
55 this.ov = ov; |
|
56 this.rom_checkSum = checksum; |
|
57 this.rom_version = version; |
|
58 this.issues_tree = issues_tree; |
|
59 } |
|
60 |
|
61 /* (non-Javadoc) |
|
62 * @see com.nokia.s60tools.ui.wizards.S60ToolsWizard#addPages() |
|
63 */ |
|
64 public void addPages() { |
|
65 comments_page = new CommentsPage("Comments", issues_tree); |
|
66 addPage(comments_page); |
|
67 } |
|
68 |
|
69 /* (non-Javadoc) |
|
70 * @see org.eclipse.jface.wizard.Wizard#performFinish() |
|
71 */ |
|
72 public boolean performFinish() { |
|
73 |
|
74 fileName = comments_page.getFileName(); |
|
75 String comment = comments_page.getComments(); |
|
76 boolean isOverviewReport = comments_page.isOverviewReportSelected(); |
|
77 ReportCreationJob engine = new ReportCreationJob("Creating report", fileName, comment, ov, this.rom_checkSum, this.rom_version, issues_tree, isOverviewReport); |
|
78 engine.setUser(true); |
|
79 engine.schedule(); |
|
80 |
|
81 //Ask user whether to open the created pdf file or not |
|
82 Runnable p = new Runnable(){ |
|
83 public void run() { |
|
84 if(MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),"Confirmation","Would you like to open the saved report?")) //$NON-NLS-2$ |
|
85 { |
|
86 Program p=Program.findProgram(".pdf"); |
|
87 if(p!=null) |
|
88 p.execute(fileName); |
|
89 } |
|
90 } |
|
91 }; |
|
92 Display.getDefault().asyncExec(p); |
|
93 return true; |
|
94 } |
|
95 |
|
96 /* (non-Javadoc) |
|
97 * @see org.eclipse.jface.wizard.Wizard#canFinish() |
|
98 */ |
|
99 public boolean canFinish() { |
|
100 return comments_page.checkForCompletion(); |
|
101 } |
|
102 |
|
103 } |