blob: 5872aa9c731f98e3a7f0d4b153bc9eefac22e164 (
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
|
/*******************************************************************************
* Copyright (c) 2004 - 2006 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.internal.bugzilla.ui.tasklist;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositorySettingsPage;
import org.eclipse.mylar.internal.tasklist.ITaskHandler;
import org.eclipse.mylar.internal.tasklist.TaskRepositoryManager;
import org.eclipse.mylar.internal.tasklist.ui.views.TaskListView;
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractAddExistingTaskWizard;
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.mylar.internal.tasklist.ui.wizards.ExistingTaskWizardPage;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskRepositoryClient;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.TaskRepository;
/**
* @author Mik Kersten
*/
public class BugzillaTaskRepositoryClient implements ITaskRepositoryClient {
public String getLabel() {
return "Bugzilla (supports uncustomized 2.16-2.20)";
}
public String toString() {
return getLabel();
}
public AbstractRepositorySettingsPage getSettingsPage() {
return new BugzillaRepositorySettingsPage();
}
public String getKind() {
return BugzillaPlugin.REPOSITORY_KIND;
}
public ITask createTaskFromExistingId(TaskRepository repository, String id) {
int bugId = -1;
try {
if (id != null) {
bugId = Integer.parseInt(id);
} else {
return null;
}
} catch (NumberFormatException nfe) {
TaskListView.getDefault().showMessage("Invalid report id.");
return null;
}
ITask newTask = new BugzillaTask(TaskRepositoryManager.getHandle(repository.getUrl().toExternalForm(), bugId),
"<bugzilla info>", true, true);
ITaskHandler taskHandler = MylarTaskListPlugin.getDefault().getHandlerForElement(newTask);
if (taskHandler != null) {
ITask addedTask = taskHandler.addTaskToRegistry(newTask);
if (addedTask instanceof BugzillaTask) {
BugzillaTask newTask2 = (BugzillaTask) addedTask;
if (newTask2 == newTask) {
((BugzillaTask) newTask).scheduleDownloadReport();
} else {
newTask = newTask2;
((BugzillaTask) newTask).updateTaskDetails();
}
}
} else {
((BugzillaTask) newTask).scheduleDownloadReport();
}
return newTask;
}
public IWizard getQueryWizard(TaskRepository repository) {
return new AddBugzillaQueryWizard(repository);
}
public IWizard getAddExistingTaskWizard(TaskRepository repository) {
// TODO create a propper subclass for Bugzilla
return new AbstractAddExistingTaskWizard(repository) {
private ExistingTaskWizardPage page;
public void addPages() {
super.addPages();
this.page = new ExistingTaskWizardPage();
addPage(page);
}
protected String getTaskId() {
return page.getTaskId();
}
};
}
}
|