use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RenamePackageChange method doRename.
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
IPackageFragment pack = getPackage();
if (pack == null)
return;
if (!fRenameSubpackages) {
renamePackage(pack, pm, createNewPath(), getNewName());
} else {
IPackageFragment[] allPackages = JavaElementUtil.getPackageAndSubpackages(pack);
Arrays.sort(allPackages, new Comparator<IPackageFragment>() {
public int compare(IPackageFragment o1, IPackageFragment o2) {
String p1 = o1.getElementName();
String p2 = o2.getElementName();
return p1.compareTo(p2);
}
});
int count = allPackages.length;
//$NON-NLS-1$
pm.beginTask("", count);
// When renaming to subpackage (a -> a.b), do it inside-out:
boolean insideOut = getNewName().startsWith(getOldName());
try {
for (int i = 0; i < count; i++) {
IPackageFragment currentPackage = allPackages[insideOut ? count - i - 1 : i];
renamePackage(currentPackage, new SubProgressMonitor(pm, 1), createNewPath(currentPackage), getNewName(currentPackage));
}
} finally {
pm.done();
}
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class UndoDeleteResourceChange method perform.
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
IResource created = fResourceDescription.createResource(pm);
created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1));
return new DeleteResourceChange(created.getFullPath(), true);
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class PackageFragmentRootReorgChange method perform.
@Override
public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException {
pm.beginTask(getName(), 2);
try {
String newName = getNewResourceName();
IPackageFragmentRoot root = getRoot();
ResourceMapping mapping = JavaElementResourceMapping.create(root);
final Change result = doPerformReorg(getDestinationProjectPath().append(newName), new SubProgressMonitor(pm, 1));
markAsExecuted(root, mapping);
return result;
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RenameJavaProjectChange method doRename.
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
try {
pm.beginTask(getName(), 2);
if (fUpdateReferences)
modifyClassPaths(new SubProgressMonitor(pm, 1));
IProject project = getProject();
if (project != null) {
IProjectDescription description = project.getDescription();
description.setName(getNewName());
project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1));
}
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class AbstractDeleteChange method saveFileIfNeeded.
protected static void saveFileIfNeeded(IFile file, IProgressMonitor pm) throws CoreException {
ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
if (buffer != null && buffer.isDirty() && buffer.isStateValidated() && buffer.isSynchronized()) {
//$NON-NLS-1$
pm.beginTask("", 2);
buffer.commit(new SubProgressMonitor(pm, 1), false);
file.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(pm, 1));
}
pm.done();
}
Aggregations