Search in sources :

Example 16 with SubProgressMonitor

use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.

the class FolderUndoState method createExistentResourceFromHandle.

public void createExistentResourceFromHandle(IResource resource, IProgressMonitor monitor) throws CoreException {
    Assert.isLegal(resource instanceof IFolder);
    if (resource.exists()) {
        return;
    }
    IFolder folderHandle = (IFolder) resource;
    try {
        //$NON-NLS-1$
        monitor.beginTask("", 200);
        monitor.setTaskName(RefactoringCoreMessages.FolderDescription_NewFolderProgress);
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        if (location != null) {
            folderHandle.createLink(location, IResource.ALLOW_MISSING_LOCAL, new SubProgressMonitor(monitor, 100));
        } else {
            folderHandle.create(false, true, new SubProgressMonitor(monitor, 100));
        }
        if (monitor.isCanceled()) {
            throw new OperationCanceledException();
        }
        createChildResources(folderHandle, monitor, 100);
    } finally {
        monitor.done();
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IFolder(org.eclipse.core.resources.IFolder)

Example 17 with SubProgressMonitor

use of org.eclipse.core.runtime.SubProgressMonitor 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)

Example 18 with SubProgressMonitor

use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.

the class ProjectDescription method createExistentResourceFromHandle.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#createExistentResourceFromHandle(org.eclipse.core.resources.IResource,
	 *      org.eclipse.core.runtime.IProgressMonitor)
	 */
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(UndoMessages.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)

Example 19 with SubProgressMonitor

use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.

the class IntroduceFactoryRefactoring method findNonPrimaryType.

private IType findNonPrimaryType(String fullyQualifiedName, IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
    SearchPattern p = SearchPattern.createPattern(fullyQualifiedName, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
    final RefactoringSearchEngine2 engine = new RefactoringSearchEngine2(p);
    engine.setFiltering(true, true);
    engine.setScope(RefactoringScopeFactory.create(fCtorBinding.getJavaElement().getJavaProject()));
    engine.setStatus(status);
    engine.searchPattern(new SubProgressMonitor(pm, 1));
    SearchResultGroup[] groups = (SearchResultGroup[]) engine.getResults();
    if (groups.length != 0) {
        for (int i = 0; i < groups.length; i++) {
            SearchMatch[] matches = groups[i].getSearchResults();
            for (int j = 0; j < matches.length; j++) {
                if (matches[j].getAccuracy() == SearchMatch.A_ACCURATE)
                    return (IType) matches[j].getElement();
            }
        }
    }
    return null;
}
Also used : SearchMatch(org.eclipse.jdt.core.search.SearchMatch) SearchPattern(org.eclipse.jdt.core.search.SearchPattern) SearchResultGroup(org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup) RefactoringSearchEngine2(org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 20 with SubProgressMonitor

use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.

the class IntroduceFactoryRefactoring method searchForCallsTo.

/**
	 * Search for all calls to the given <code>IMethodBinding</code> in the project
	 * that contains the compilation unit <code>fCUHandle</code>.
	 * @param methodBinding
	 * @param pm
	 * @param status
	 * @return an array of <code>SearchResultGroup</code>'s that identify the search matches
	 * @throws JavaModelException
	 */
private SearchResultGroup[] searchForCallsTo(IMethodBinding methodBinding, IProgressMonitor pm, RefactoringStatus status) throws JavaModelException {
    IMethod method = (IMethod) methodBinding.getJavaElement();
    final RefactoringSearchEngine2 engine = new RefactoringSearchEngine2(createSearchPattern(method, methodBinding));
    engine.setFiltering(true, true);
    engine.setScope(createSearchScope(method, methodBinding));
    engine.setStatus(status);
    engine.searchPattern(new SubProgressMonitor(pm, 1));
    return (SearchResultGroup[]) engine.getResults();
}
Also used : IMethod(org.eclipse.jdt.core.IMethod) RefactoringSearchEngine2(org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Aggregations

SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)213 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)53 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)53 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)39 CoreException (org.eclipse.core.runtime.CoreException)38 ArrayList (java.util.ArrayList)36 IFile (org.eclipse.core.resources.IFile)33 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)31 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)29 IOException (java.io.IOException)23 IType (org.eclipse.jdt.core.IType)19 HashSet (java.util.HashSet)17 IProject (org.eclipse.core.resources.IProject)14 IResource (org.eclipse.core.resources.IResource)14 File (java.io.File)13 List (java.util.List)13 IPath (org.eclipse.core.runtime.IPath)13 IMethod (org.eclipse.jdt.core.IMethod)13 HashMap (java.util.HashMap)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)11