use of bndtools.internal.testcaseselection.JavaSearchScopeTestCaseLister in project bndtools by bndtools.
the class TestSuiteLabelProvider method doAdd.
void doAdd() {
// Prepare the exclusion list based on existing test cases
final Set<String> testSuitesSet = new HashSet<String>(testSuites);
// Create a filter from the exclusion list
ITestCaseFilter filter = new ITestCaseFilter() {
@Override
public boolean select(String testCaseName) {
return !testSuitesSet.contains(testCaseName);
}
};
IFormPage page = (IFormPage) getManagedForm().getContainer();
IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();
// Prepare the package lister from the Java project
IJavaProject javaProject = getJavaProject();
if (javaProject == null) {
MessageDialog.openError(getSection().getShell(), "Error", "Cannot add test cases: unable to find a Java project associated with the editor input.");
return;
}
IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
JavaSearchScopeTestCaseLister testCaseLister = new JavaSearchScopeTestCaseLister(searchScope, window);
// Create and open the dialog
TestCaseSelectionDialog dialog = new TestCaseSelectionDialog(getSection().getShell(), testCaseLister, filter, Messages.TestSuitesPart_title);
dialog.setSourceOnly(true);
dialog.setMultipleSelection(true);
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
List<String> added = new LinkedList<String>();
// Select the results
for (Object result : results) {
String newTestSuites = (String) result;
if (testSuites.add(newTestSuites)) {
added.add(newTestSuites);
}
}
// Update the model and view
if (!added.isEmpty()) {
viewer.add(added.toArray());
markDirty();
}
}
}
Aggregations