Skip to main content
summaryrefslogtreecommitdiffstats
blob: b5571349611f8e538ae6ef4224d863ece2ccfbad (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
/*******************************************************************************
 * Copyright (c) 2004, 2008 Tasktop Technologies 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:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.tasks.bugs.wizards;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.internal.tasks.bugs.AttributeTaskMapper;
import org.eclipse.mylyn.internal.tasks.bugs.KeyValueMapping;
import org.eclipse.mylyn.internal.tasks.bugs.SupportRequest;
import org.eclipse.mylyn.internal.tasks.bugs.TaskErrorReporter;
import org.eclipse.mylyn.internal.tasks.core.ITaskRepositoryFilter;
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskPage;

/**
 * @author Steffen Pingel
 */
public class ReportErrorWizard extends Wizard {

	private final IStatus status;

	private final SupportRequest request;

	private ReportErrorPage reportErrorPage;

	private NewTaskPage newTaskPage;

	private final TaskErrorReporter taskErrorReporter;

	public ReportErrorWizard(TaskErrorReporter taskErrorReporter, IStatus status) {
		this.taskErrorReporter = taskErrorReporter;
		this.status = status;
		this.request = taskErrorReporter.preProcess(status, null);
		setWindowTitle(Messages.ReportErrorWizard_Report_as_Bug);
	}

	@Override
	public void addPages() {
		reportErrorPage = new ReportErrorPage(request, status);
		addPage(reportErrorPage);
		KeyValueMapping defaultMapping = new KeyValueMapping(
				((AttributeTaskMapper) request.getDefaultContribution()).getAttributes());
		newTaskPage = new NewTaskPage(ITaskRepositoryFilter.CAN_CREATE_NEW_TASK, defaultMapping);
		addPage(newTaskPage);
	}

	@Override
	public boolean performFinish() {
		if (reportErrorPage.getSelectedContribution() != null) {
			taskErrorReporter.postProcess(reportErrorPage.getSelectedContribution());
			return true;
		} else {
			return newTaskPage.performFinish();
		}
	}

}

Back to the top