Search in sources :

Example 16 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.

the class TestSuiteLabelProvider method getJavaProject.

IJavaProject getJavaProject() {
    IFormPage page = (IFormPage) getManagedForm().getContainer();
    IEditorInput input = page.getEditorInput();
    IFile file = ResourceUtil.getFile(input);
    if (file != null) {
        return JavaCore.create(file.getProject());
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IEditorInput(org.eclipse.ui.IEditorInput)

Example 17 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage 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();
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ITestCaseFilter(bndtools.internal.testcaseselection.ITestCaseFilter) IFormPage(org.eclipse.ui.forms.editor.IFormPage) LinkedList(java.util.LinkedList) IJavaProject(org.eclipse.jdt.core.IJavaProject) TestCaseSelectionDialog(bndtools.internal.testcaseselection.TestCaseSelectionDialog) IJavaSearchScope(org.eclipse.jdt.core.search.IJavaSearchScope) JavaSearchScopeTestCaseLister(bndtools.internal.testcaseselection.JavaSearchScopeTestCaseLister) HashSet(java.util.HashSet)

Example 18 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.

the class DescriptionBundlePart method getJavaProject.

IJavaProject getJavaProject() {
    IFormPage formPage = (IFormPage) getManagedForm().getContainer();
    IFile file = ResourceUtil.getFile(formPage.getEditorInput());
    return file != null ? JavaCore.create(file.getProject()) : null;
}
Also used : IFile(org.eclipse.core.resources.IFile) IFormPage(org.eclipse.ui.forms.editor.IFormPage)

Example 19 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.

the class DescriptionDeveloperPart method getJavaProject.

IJavaProject getJavaProject() {
    IFormPage formPage = (IFormPage) getManagedForm().getContainer();
    IFile file = ResourceUtil.getFile(formPage.getEditorInput());
    return file != null ? JavaCore.create(file.getProject()) : null;
}
Also used : IFile(org.eclipse.core.resources.IFile) IFormPage(org.eclipse.ui.forms.editor.IFormPage)

Example 20 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.

the class DescriptionVendorPart method getJavaProject.

IJavaProject getJavaProject() {
    IFormPage formPage = (IFormPage) getManagedForm().getContainer();
    IFile file = ResourceUtil.getFile(formPage.getEditorInput());
    return file != null ? JavaCore.create(file.getProject()) : null;
}
Also used : IFile(org.eclipse.core.resources.IFile) IFormPage(org.eclipse.ui.forms.editor.IFormPage)

Aggregations

IFormPage (org.eclipse.ui.forms.editor.IFormPage)22 IFile (org.eclipse.core.resources.IFile)12 LinkedList (java.util.LinkedList)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)3 IEditorInput (org.eclipse.ui.IEditorInput)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 IPackageFilter (bndtools.internal.pkgselection.IPackageFilter)2 JavaSearchScopePackageLister (bndtools.internal.pkgselection.JavaSearchScopePackageLister)2 PackageSelectionDialog (bndtools.internal.pkgselection.PackageSelectionDialog)2 HashSet (java.util.HashSet)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 ExportedPackage (aQute.bnd.build.model.clauses.ExportedPackage)1 Attrs (aQute.bnd.header.Attrs)1 IPriority (bndtools.editor.common.IPriority)1 ITestCaseFilter (bndtools.internal.testcaseselection.ITestCaseFilter)1 JavaSearchScopeTestCaseLister (bndtools.internal.testcaseselection.JavaSearchScopeTestCaseLister)1 TestCaseSelectionDialog (bndtools.internal.testcaseselection.TestCaseSelectionDialog)1 BndPreferences (bndtools.preferences.BndPreferences)1