use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RenameFieldProcessor method doCheckFinalConditions.
@Override
protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
try {
//$NON-NLS-1$
pm.beginTask("", 18);
pm.setTaskName(RefactoringCoreMessages.RenameFieldRefactoring_checking);
RefactoringStatus result = new RefactoringStatus();
result.merge(Checks.checkIfCuBroken(fField));
if (result.hasFatalError())
return result;
result.merge(checkNewElementName(getNewElementName()));
pm.worked(1);
result.merge(checkEnclosingHierarchy());
pm.worked(1);
result.merge(checkNestedHierarchy(fField.getDeclaringType()));
pm.worked(1);
if (fUpdateReferences) {
pm.setTaskName(RefactoringCoreMessages.RenameFieldRefactoring_searching);
fReferences = getReferences(new SubProgressMonitor(pm, 3), result);
pm.setTaskName(RefactoringCoreMessages.RenameFieldRefactoring_checking);
} else {
fReferences = new SearchResultGroup[0];
pm.worked(3);
}
if (fUpdateReferences)
result.merge(analyzeAffectedCompilationUnits());
else
Checks.checkCompileErrorsInAffectedFile(result, fField.getResource());
if (getGetter() != null && fRenameGetter) {
result.merge(checkAccessor(new SubProgressMonitor(pm, 1), getGetter(), getNewGetterName()));
result.merge(Checks.checkIfConstructorName(getGetter(), getNewGetterName(), fField.getDeclaringType().getElementName()));
} else {
pm.worked(1);
}
if (getSetter() != null && fRenameSetter) {
result.merge(checkAccessor(new SubProgressMonitor(pm, 1), getSetter(), getNewSetterName()));
result.merge(Checks.checkIfConstructorName(getSetter(), getNewSetterName(), fField.getDeclaringType().getElementName()));
} else {
pm.worked(1);
}
result.merge(createChanges(new SubProgressMonitor(pm, 10)));
if (result.hasFatalError())
return result;
return result;
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RenameNonVirtualMethodProcessor method doCheckFinalConditions.
//----------- preconditions --------------
@Override
protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext checkContext) throws CoreException {
try {
//$NON-NLS-1$
pm.beginTask("", 3);
RefactoringStatus result = new RefactoringStatus();
result.merge(super.doCheckFinalConditions(new SubProgressMonitor(pm, 1), checkContext));
if (result.hasFatalError())
return result;
final IMethod method = getMethod();
final IType declaring = method.getDeclaringType();
final String name = getNewElementName();
IMethod[] hierarchyMethods = hierarchyDeclaresMethodName(new SubProgressMonitor(pm, 1), declaring.newTypeHierarchy(new SubProgressMonitor(pm, 1)), method, name);
for (int i = 0; i < hierarchyMethods.length; i++) {
IMethod hierarchyMethod = hierarchyMethods[i];
RefactoringStatusContext context = JavaStatusContext.create(hierarchyMethod);
if (Checks.compareParamTypes(method.getParameterTypes(), hierarchyMethod.getParameterTypes())) {
String message = Messages.format(RefactoringCoreMessages.RenamePrivateMethodRefactoring_hierarchy_defines, new String[] { BasicElementLabels.getJavaElementName(declaring.getFullyQualifiedName('.')), BasicElementLabels.getJavaElementName(name) });
result.addError(message, context);
} else {
String message = Messages.format(RefactoringCoreMessages.RenamePrivateMethodRefactoring_hierarchy_defines2, new String[] { BasicElementLabels.getJavaElementName(declaring.getFullyQualifiedName('.')), BasicElementLabels.getJavaElementName(name) });
result.addWarning(message, context);
}
}
return result;
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class ImportOperation method execute.
/* (non-Javadoc)
* Method declared on WorkbenchModifyOperation.
* Imports the specified file system objects from the file system.
*/
protected void execute(IProgressMonitor progressMonitor) {
monitor = progressMonitor;
try {
if (selectedFiles == null) {
//Set the amount to 1000 as we have no idea of how long this will take
monitor.beginTask("Importing:", 1000);
ContainerGenerator generator = new ContainerGenerator(destinationPath);
monitor.worked(30);
validateFiles(Arrays.asList(new Object[] { source }));
monitor.worked(50);
destinationContainer = generator.generateContainer(new SubProgressMonitor(monitor, 50));
importRecursivelyFrom(source, POLICY_DEFAULT);
//Be sure it finishes
monitor.worked(90);
} else {
// Choose twice the selected files size to take folders into account
int creationCount = selectedFiles.size();
monitor.beginTask("Importing:", creationCount + 100);
ContainerGenerator generator = new ContainerGenerator(destinationPath);
monitor.worked(30);
validateFiles(selectedFiles);
monitor.worked(50);
destinationContainer = generator.generateContainer(new SubProgressMonitor(monitor, 50));
importFileSystemObjects(selectedFiles);
monitor.done();
}
} catch (CoreException e) {
errorTable.add(e.getStatus());
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class ContainerGenerator method createProject.
/**
* Creates a project resource for the given project handle.
*
* @param projectHandle the handle to create a project resource
* @param monitor the progress monitor to show visual progress
* @return the project handle (<code>projectHandle</code>)
* @exception CoreException if the operation fails
* @exception OperationCanceledException if the operation is canceled
*/
private IProject createProject(IProject projectHandle, IProgressMonitor monitor) throws CoreException {
try {
//$NON-NLS-1$
monitor.beginTask("", 2000);
projectHandle.create(new SubProgressMonitor(monitor, 1000));
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
projectHandle.open(new SubProgressMonitor(monitor, 1000));
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
} finally {
monitor.done();
}
return projectHandle;
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class ContainerDescription method recordStateFromHistory.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.ide.undo.ResourceDescription#recordStateFromHistory(org.eclipse.core.resources.IResource,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void recordStateFromHistory(IResource resource, IProgressMonitor monitor) throws CoreException {
monitor.beginTask(UndoMessages.FolderDescription_SavingUndoInfoProgress, 100);
if (members != null) {
for (int i = 0; i < members.length; i++) {
if (members[i] instanceof FileDescription) {
IPath path = resource.getFullPath().append(((FileDescription) members[i]).name);
IFile fileHandle = resource.getWorkspace().getRoot().getFile(path);
members[i].recordStateFromHistory(fileHandle, new SubProgressMonitor(monitor, 100 / members.length));
} else if (members[i] instanceof FolderDescription) {
IPath path = resource.getFullPath().append(((FolderDescription) members[i]).name);
IFolder folderHandle = resource.getWorkspace().getRoot().getFolder(path);
members[i].recordStateFromHistory(folderHandle, new SubProgressMonitor(monitor, 100 / members.length));
}
}
}
monitor.done();
}
Aggregations