Search in sources :

Example 1 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class IndexManager method removeSourceFolderFromIndex.

/**
     * Remove the content of the given source folder from the index.
     */
public void removeSourceFolderFromIndex(JavaProject javaProject, IPath sourceFolder, char[][] inclusionPatterns, char[][] exclusionPatterns) {
    IProject project = javaProject.getProject();
    if (this.jobEnd > this.jobStart) {
        // skip it if a job to index the project is already in the queue
        IndexRequest request = new IndexAllProject(project, this);
        if (isJobWaiting(request))
            return;
    }
    request(new RemoveFolderFromIndex(sourceFolder, inclusionPatterns, exclusionPatterns, project, this));
}
Also used : IProject(org.eclipse.core.resources.IProject)

Example 2 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class HandleFactory method getPkgFragmentRoot.

/**
	 * Returns the package fragment root that contains the given resource path.
	 */
private PackageFragmentRoot getPkgFragmentRoot(String pathString) {
    IPath path = new Path(pathString);
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0, max = projects.length; i < max; i++) {
        try {
            IProject project = projects[i];
            if (!project.isAccessible() || !project.hasNature(JavaCore.NATURE_ID))
                continue;
            IJavaProject javaProject = this.javaModel.getJavaProject(project);
            IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
            for (int j = 0, rootCount = roots.length; j < rootCount; j++) {
                PackageFragmentRoot root = (PackageFragmentRoot) roots[j];
                if (root.internalPath().isPrefixOf(path) && !Util.isExcluded(path, root.fullInclusionPatternChars(), root.fullExclusionPatternChars(), false)) {
                    return root;
                }
            }
        } catch (CoreException e) {
        // CoreException from hasNature - should not happen since we check that the project is accessible
        // JavaModelException from getPackageFragmentRoots - a problem occured while accessing project: nothing we can do, ignore
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) PackageFragmentRoot(org.eclipse.jdt.internal.core.PackageFragmentRoot) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) IJavaProject(org.eclipse.jdt.core.IJavaProject) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 3 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class RenameModifications method rename.

public void rename(IJavaProject project, RenameArguments args) {
    add(project, args, null);
    IProject rProject = project.getProject();
    if (rProject != null) {
        getResourceModifications().addRename(rProject, args);
        IProject[] referencingProjects = rProject.getReferencingProjects();
        for (int i = 0; i < referencingProjects.length; i++) {
            IFile classpath = getClasspathFile(referencingProjects[i]);
            if (classpath != null) {
                getResourceModifications().addChanged(classpath);
            }
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IProject(org.eclipse.core.resources.IProject)

Example 4 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class RenameResourceProcessor method createDescriptor.

protected RenameResourceDescriptor createDescriptor() {
    IResource resource = getResource();
    RenameResourceDescriptor descriptor = new RenameResourceDescriptor();
    descriptor.setProject(resource instanceof IProject ? null : resource.getProject().getName());
    descriptor.setDescription(Messages.format(RefactoringCoreMessages.RenameResourceProcessor_description, BasicElementLabels.getResourceName(resource)));
    descriptor.setComment(Messages.format(RefactoringCoreMessages.RenameResourceProcessor_comment, new String[] { BasicElementLabels.getPathLabel(resource.getFullPath(), false), BasicElementLabels.getResourceName(getNewResourceName()) }));
    descriptor.setFlags(RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE);
    descriptor.setResourcePath(resource.getFullPath());
    descriptor.setNewName(getNewResourceName());
    descriptor.setUpdateReferences(isUpdateReferences());
    return descriptor;
}
Also used : RenameResourceDescriptor(org.eclipse.ltk.core.refactoring.resource.RenameResourceDescriptor) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 5 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class ProjectUndoState method createExistentResourceFromHandle.

public void createExistentResourceFromHandle(IResource resource, IProgressMonitor monitor) throws CoreException {
    Assert.isLegal(resource instanceof IProject);
    if (resource.exists()) {
        return;
    }
    IProject projectHandle = (IProject) resource;
    //$NON-NLS-1$
    monitor.beginTask("", 200);
    monitor.setTaskName(RefactoringCoreMessages.FolderDescription_NewFolderProgress);
    if (projectDescription == null) {
        projectHandle.create(new SubProgressMonitor(monitor, 100));
    } else {
        projectHandle.create(projectDescription, new SubProgressMonitor(monitor, 100));
    }
    if (monitor.isCanceled()) {
        throw new OperationCanceledException();
    }
    if (openOnCreate) {
        projectHandle.open(IResource.NONE, new SubProgressMonitor(monitor, 100));
    }
    monitor.done();
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IProject(org.eclipse.core.resources.IProject) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Aggregations

IProject (org.eclipse.core.resources.IProject)2658 IFile (org.eclipse.core.resources.IFile)642 CoreException (org.eclipse.core.runtime.CoreException)598 Test (org.junit.Test)483 IPath (org.eclipse.core.runtime.IPath)408 IFolder (org.eclipse.core.resources.IFolder)339 IResource (org.eclipse.core.resources.IResource)305 File (java.io.File)279 ArrayList (java.util.ArrayList)270 Path (org.eclipse.core.runtime.Path)268 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)259 IOException (java.io.IOException)201 IJavaProject (org.eclipse.jdt.core.IJavaProject)193 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)186 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)175 IProjectDescription (org.eclipse.core.resources.IProjectDescription)161 IWorkspace (org.eclipse.core.resources.IWorkspace)138 IStatus (org.eclipse.core.runtime.IStatus)124 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)116 List (java.util.List)109