blob: a48eb8fdd9afa63f882dfc0b1870c7c995ea787e (
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
|
/*******************************************************************************
* 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.Assert;
import org.eclipse.core.runtime.IBundleGroup;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.internal.tasks.bugs.PluginRepositoryMappingManager;
import org.eclipse.mylyn.internal.tasks.bugs.TasksBugsPlugin;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
/**
* @author Steffen Pingel
*/
public class ReportBugOrEnhancementWizard extends Wizard {
private SelectProductPage selectProductPage;
private PluginRepositoryMappingManager manager;
public ReportBugOrEnhancementWizard() {
setForcePreviousAndNextButtons(true);
setNeedsProgressMonitor(false);
setWindowTitle("Report Bug or Enhancement");
setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
}
@Override
public void addPages() {
manager = new PluginRepositoryMappingManager();
selectProductPage = new SelectProductPage("selectBundleGroupProvider", manager);
addPage(selectProductPage);
}
@Override
public boolean canFinish() {
return getSelectedBundleGroup() != null;
}
public IBundleGroup[] getSelectedBundleGroup() {
IWizardPage page = getContainer().getCurrentPage();
if (page instanceof SelectProductPage) {
if (page.isPageComplete() && !((SelectProductPage) page).canFlipToNextPage()) {
return ((SelectProductPage) page).getSelectedBundleGroups();
}
} else if (page instanceof SelectFeaturePage) {
if (page.isPageComplete()) {
return ((SelectFeaturePage) page).getSelectedBundleGroups();
}
}
return null;
}
@Override
public boolean performFinish() {
final IBundleGroup[] bundles = getSelectedBundleGroup();
Assert.isNotNull(bundles);
// delay run this until after the dialog has been closed
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
String prefix = bundles[0].getIdentifier();
for (int i = 1; i < bundles.length; i++) {
prefix = getCommonPrefix(prefix, bundles[i].getIdentifier());
}
TasksBugsPlugin.getTaskErrorReporter().handle(new FeatureStatus(prefix, bundles));
}
});
return true;
}
private static String getCommonPrefix(String s1, String s2) {
int len = Math.min(s1.length(), s2.length());
StringBuffer prefix = new StringBuffer(len);
for (int i = 0; i < len; i++) {
if (s1.charAt(i) == s2.charAt(i)) {
prefix.append(s1.charAt(i));
}
}
return prefix.toString();
}
}
|