2
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 the License "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 |
|
|
18 |
package com.nokia.carbide.internal.bugreport.ui.wizards;
|
|
19 |
|
|
20 |
import org.eclipse.jface.wizard.*;
|
|
21 |
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
22 |
import org.eclipse.core.runtime.*;
|
|
23 |
import com.nokia.carbide.internal.bugreport.export.IProduct;
|
|
24 |
import com.nokia.carbide.internal.bugreport.model.BugReportConsole;
|
|
25 |
import com.nokia.carbide.internal.bugreport.model.Communication;
|
|
26 |
import com.nokia.carbide.internal.bugreport.model.ConsoleLine;
|
|
27 |
import com.nokia.carbide.internal.bugreport.model.FieldsHandler;
|
|
28 |
import com.nokia.carbide.internal.bugreport.model.ProductHandler;
|
|
29 |
import com.nokia.carbide.internal.bugreport.resources.*;
|
|
30 |
|
|
31 |
import java.util.*;
|
|
32 |
import org.eclipse.jface.dialogs.MessageDialog;
|
|
33 |
import org.eclipse.jface.resource.ImageDescriptor;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* Bug_Report wizard
|
|
37 |
*
|
|
38 |
*/
|
|
39 |
public class NewBugReportWizard extends Wizard implements IWizard {
|
|
40 |
|
|
41 |
static private final ImageDescriptor bannerImgDescriptor =
|
|
42 |
ImageResourceManager.getImageDescriptor(ImageKeys.WIZARD_BANNER);
|
|
43 |
|
|
44 |
ProductSelectionPage productPage;
|
|
45 |
BugDescriptionPage bugPage;
|
|
46 |
SummaryPage summaryPage;
|
|
47 |
FieldsHandler fieldsHandler = null;
|
|
48 |
ProductHandler productHandler = null;
|
|
49 |
BugReportConsole console = null;
|
|
50 |
|
|
51 |
|
|
52 |
public NewBugReportWizard() throws RuntimeException {
|
|
53 |
setDefaultPageImageDescriptor(bannerImgDescriptor);
|
|
54 |
productHandler = new ProductHandler();
|
|
55 |
fieldsHandler = new FieldsHandler();
|
|
56 |
console = new BugReportConsole();
|
|
57 |
}
|
|
58 |
|
|
59 |
@Override
|
|
60 |
public boolean performFinish() {
|
|
61 |
try {
|
|
62 |
getContainer().run(true, true, new IRunnableWithProgress() {
|
|
63 |
public void run(IProgressMonitor monitor) {
|
|
64 |
monitor.beginTask(Messages.getString("NewBugReportWizard.SendingReport"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
|
|
65 |
String bugNumber = Communication.sendBugReport(fieldsHandler.getFieldsForSending(), productHandler.getProduct());
|
|
66 |
ConsoleLine line = new ConsoleLine(productHandler.getProduct(), bugNumber);
|
|
67 |
console.addLineToConsole(line);
|
|
68 |
|
|
69 |
monitor.done();
|
|
70 |
}
|
|
71 |
});
|
|
72 |
} catch (Exception e) {
|
|
73 |
e.printStackTrace();
|
|
74 |
MessageDialog.openError(this.getShell(), Messages.getString("NewBugReportWizard.BugReporting"), e.getCause().getLocalizedMessage()); //$NON-NLS-1$
|
|
75 |
return false;
|
|
76 |
}
|
|
77 |
|
|
78 |
return true;
|
|
79 |
}
|
|
80 |
|
|
81 |
@Override
|
|
82 |
public void addPages() {
|
|
83 |
|
|
84 |
// product is not initialized if there were multiple product plugins.
|
|
85 |
// in this case add a product selection page.
|
|
86 |
if (productHandler.getProduct() == null) {
|
|
87 |
productPage = new ProductSelectionPage(productHandler.getProducts());
|
|
88 |
addPage(productPage);
|
|
89 |
}
|
|
90 |
|
|
91 |
bugPage = new BugDescriptionPage();
|
|
92 |
addPage(bugPage);
|
|
93 |
bugPage.setProduct(productHandler.getProduct());
|
|
94 |
|
|
95 |
summaryPage = new SummaryPage();
|
|
96 |
addPage(summaryPage);
|
|
97 |
|
|
98 |
setWindowTitle(Messages.getString("NewBugReportWizard.BugReporting")); //$NON-NLS-1$
|
|
99 |
}
|
|
100 |
|
|
101 |
@Override
|
|
102 |
public IWizardPage getNextPage(IWizardPage page) {
|
|
103 |
|
|
104 |
// if there was a product selection page (because of multiple product plugins)
|
|
105 |
// get the selected product and give it to bugPage. Return bugPage for showing.
|
|
106 |
if (page == productPage) {
|
|
107 |
IProduct product = productPage.getProduct();
|
|
108 |
if (product == null) {
|
|
109 |
throw new RuntimeException(Messages.getString("NewBugReportWizard.CouldNotInitializeProduct")); //$NON-NLS-1$
|
|
110 |
}
|
|
111 |
productHandler.setProduct(product);
|
|
112 |
bugPage.setProduct(product);
|
|
113 |
return bugPage;
|
|
114 |
// Changing from bug_page to summary page.
|
|
115 |
} else if (page == bugPage) {
|
|
116 |
if (bugPage.canChangePage()) {
|
|
117 |
Hashtable<String, String> fields = bugPage.getFields();
|
|
118 |
fieldsHandler.prepareFinalFields(fields, productHandler.getProduct());
|
|
119 |
summaryPage.setSummaryText(fieldsHandler.getSummary());
|
|
120 |
return summaryPage;
|
|
121 |
}
|
|
122 |
}
|
|
123 |
return null;
|
|
124 |
}
|
|
125 |
|
|
126 |
@Override
|
|
127 |
public boolean canFinish() {
|
|
128 |
if (getContainer().getCurrentPage() == summaryPage)
|
|
129 |
return true;
|
|
130 |
|
|
131 |
return false;
|
|
132 |
}
|
|
133 |
|
|
134 |
@Override
|
|
135 |
public boolean needsProgressMonitor() {
|
|
136 |
return true;
|
|
137 |
}
|
|
138 |
|
|
139 |
}
|