blob: 682cd66e63a56fcc36dbbd0592d6b7380a6bfb4a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*******************************************************************************
* Copyright (c) 2003 - 2005 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.bugzilla.ui.wizard;
import java.util.Iterator;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbench;
/**
* @author Shawn Minto
*
* The first page of the new bug wizard where the user chooses the bug's product
*/
public class WizardProductPage extends AbstractWizardListPage {
/** The list of products to submit a bug report for */
static java.util.List<String> products = null;
/** Reference to the bug wizard which created this page so we can create the second page */
NewBugWizard bugWizard;
/** String to hold previous product; determines if attribute option values need to be updated */
private String prevProduct;
/**
* Constructor for WizardProductPage
*
* @param workbench
* The instance of the workbench
* @param bugWiz
* The bug wizard which created this page
*/
public WizardProductPage(IWorkbench workbench, NewBugWizard bugWiz) {
super("Page1", "New Bug Report",
"Pick a product on which to enter a bug.", workbench);
this.bugWizard = bugWiz;
}
/**
* Populates the listBox with all available products.
*/
@Override
protected void populateList() {
Iterator<String> itr = products.iterator();
while (itr.hasNext()) {
String prod = itr.next();
listBox.add(prod);
}
}
@Override
public void handleEvent(Event event) {
handleEventHelper(event, "You must select a product");
}
@Override
public IWizardPage getNextPage() {
// save the product information to the model
saveDataToModel();
NewBugWizard wizard = (NewBugWizard) getWizard();
NewBugModel model = wizard.model;
// try to get the attributes from the bugzilla server
try {
if (!model.hasParsedAttributes() || !prevProduct.equals(model.getProduct())) {
if (model.isConnected()) {
BugzillaRepository.getInstance().getnewBugAttributes(model, false);
}
else {
BugzillaRepository.getInstance().getProdConfigAttributes(model);
}
model.setParsedAttributesStatus(true);
if (prevProduct == null) {
bugWizard.attributePage = new WizardAttributesPage(workbench);
bugWizard.addPage(bugWizard.attributePage);
}
else {
// selected product has changed
bugWizard.attributePage.setControl(null); // will createControl again with new attributes in model
}
}
} catch (Exception e) {
BugzillaPlugin.getDefault().logAndShowExceptionDetailsDialog(e, "occurred.", "Bugzilla Error");
}
return super.getNextPage();
}
/**
* Save the currently selected product to the model when next is clicked
*/
private void saveDataToModel() {
// Gets the model
NewBugModel model = bugWizard.model;
prevProduct = model.getProduct();
model.setProduct((listBox.getSelection())[0]);
}
@Override
public String getTableName() {
return "Product:";
}
}
|