Search in sources :

Example 1 with IFormPage

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

the class BuildOperationsPart method findEditorResource.

private IResource findEditorResource() {
    IFormPage formPage = (IFormPage) getManagedForm().getContainer();
    IResource resource = ResourceUtil.getResource(formPage.getEditorInput());
    return resource;
}
Also used : IFormPage(org.eclipse.ui.forms.editor.IFormPage) IResource(org.eclipse.core.resources.IResource)

Example 2 with IFormPage

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

the class ExportPatternsListPart method selectPackagesToAdd.

protected List<ExportedPackage> selectPackagesToAdd() {
    List<ExportedPackage> added = null;
    final IPackageFilter filter = new IPackageFilter() {

        @Override
        public boolean select(String packageName) {
            if (packageName.equals("java") || packageName.startsWith("java."))
                return false;
            return true;
        }
    };
    IFormPage page = (IFormPage) getManagedForm().getContainer();
    IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();
    // Prepare the package lister from the Java project
    IProject project = ResourceUtil.getResource(page.getEditorInput()).getProject();
    IJavaProject javaProject = JavaCore.create(project);
    IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
    JavaSearchScopePackageLister packageLister = new JavaSearchScopePackageLister(searchScope, window);
    // Create and open the dialog
    PackageSelectionDialog dialog = new PackageSelectionDialog(window.getShell(), packageLister, filter, "Select new packages to export from the bundle.");
    dialog.setSourceOnly(true);
    dialog.setMultipleSelection(true);
    if (dialog.open() == Window.OK) {
        Object[] results = dialog.getResult();
        added = new LinkedList<ExportedPackage>();
        // Select the results
        for (Object result : results) {
            String newPackageName = (String) result;
            ExportedPackage newPackage = new ExportedPackage(newPackageName, new Attrs());
            added.add(newPackage);
        }
    }
    return added;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Attrs(aQute.bnd.header.Attrs) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IProject(org.eclipse.core.resources.IProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) ExportedPackage(aQute.bnd.build.model.clauses.ExportedPackage) IJavaSearchScope(org.eclipse.jdt.core.search.IJavaSearchScope) JavaSearchScopePackageLister(bndtools.internal.pkgselection.JavaSearchScopePackageLister) IPackageFilter(bndtools.internal.pkgselection.IPackageFilter) PackageSelectionDialog(bndtools.internal.pkgselection.PackageSelectionDialog)

Example 3 with IFormPage

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

the class GeneralInfoPart 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 4 with IFormPage

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

the class BndEditor method updateIncludedPages.

private void updateIncludedPages() {
    List<String> requiredPageIds = new LinkedList<String>();
    // Need to know the file and project names.
    Pair<String, String> fileAndProject = getFileAndProject(getEditorInput());
    String path = fileAndProject.getFirst();
    String projectName = fileAndProject.getSecond();
    if (isMainWorkspaceConfig(path, projectName)) {
        requiredPageIds.add(WORKSPACE_PAGE);
    } else if (isExtWorkspaceConfig(path, projectName)) {
        requiredPageIds.add(WORKSPACE_EXT_PAGE);
        setTitleImage(buildFileImg);
    } else if (path.endsWith(LaunchConstants.EXT_BNDRUN)) {
        requiredPageIds.addAll(getPagesBndRun());
    } else {
        requiredPageIds.addAll(getPagesBnd(path));
    }
    requiredPageIds.add(SOURCE_PAGE);
    // Remove pages no longer required and remember the rest in a map
    int i = 0;
    Map<String, IFormPage> pageCache = new HashMap<String, IFormPage>(requiredPageIds.size());
    while (i < getPageCount()) {
        IFormPage current = (IFormPage) pages.get(i);
        if (!requiredPageIds.contains(current.getId()))
            removePage(i);
        else {
            pageCache.put(current.getId(), current);
            i++;
        }
    }
    // Cache new pages
    for (String pageId : requiredPageIds) {
        if (!pageCache.containsKey(pageId)) {
            IFormPage page = SOURCE_PAGE.equals(pageId) ? sourcePage : pageFactories.get(pageId).createPage(this, model, pageId);
            pageCache.put(pageId, page);
        }
    }
    // Add pages back in
    int requiredPointer = 0;
    int existingPointer = 0;
    while (requiredPointer < requiredPageIds.size()) {
        try {
            String requiredId = requiredPageIds.get(requiredPointer);
            if (existingPointer >= getPageCount()) {
                if (SOURCE_PAGE.equals(requiredId))
                    addPage(sourcePage, getEditorInput());
                else
                    addPage(pageCache.get(requiredId));
            } else {
                IFormPage existingPage = (IFormPage) pages.get(existingPointer);
                if (!requiredId.equals(existingPage.getId())) {
                    if (SOURCE_PAGE.equals(requiredId))
                        addPage(existingPointer, sourcePage, getEditorInput());
                    else
                        addPage(existingPointer, pageCache.get(requiredId));
                }
            }
            existingPointer++;
        } catch (PartInitException e) {
            logger.logError("Error adding page(s) to the editor.", e);
        }
        requiredPointer++;
    }
    // Set the source page title
    setPageText(sourcePage.getIndex(), "Source");
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IFormPage(org.eclipse.ui.forms.editor.IFormPage) PartInitException(org.eclipse.ui.PartInitException) LinkedList(java.util.LinkedList)

Example 5 with IFormPage

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

the class PrivatePackagesPart method getJavaProject.

private IJavaProject getJavaProject() {
    IFormPage page = (IFormPage) getManagedForm().getContainer();
    IEditorInput input = page.getEditorInput();
    if (!IFileEditorInput.class.isInstance(input)) {
        return null;
    }
    IProject project = ((IFileEditorInput) input).getFile().getProject();
    return JavaCore.create(project);
}
Also used : IFileEditorInput(org.eclipse.ui.IFileEditorInput) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IEditorInput(org.eclipse.ui.IEditorInput) IProject(org.eclipse.core.resources.IProject)

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