use of org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange in project che by eclipse.
the class CreateFileChange method perform.
@Override
public Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException {
InputStream is = null;
try {
pm.beginTask(NLSChangesMessages.createFile_creating_resource, 3);
initializeEncoding();
IFile file = getOldFile(new SubProgressMonitor(pm, 1));
/*
if (file.exists()) {
CompositeChange composite= new CompositeChange(getName());
composite.add(new DeleteFileChange(file));
composite.add(new CreateFileChange(fPath, fSource, fEncoding, fStampToRestore, fExplicitEncoding));
pm.worked(1);
return composite.perform(new SubProgressMonitor(pm, 1));
} else { */
try {
is = new ByteArrayInputStream(fSource.getBytes(fEncoding));
file.create(is, false, new SubProgressMonitor(pm, 1));
if (fStampToRestore != IResource.NULL_STAMP) {
file.revertModificationStamp(fStampToRestore);
}
if (fExplicitEncoding) {
file.setCharset(fEncoding, new SubProgressMonitor(pm, 1));
} else {
pm.worked(1);
}
return new DeleteResourceChange(file.getFullPath(), true);
} catch (UnsupportedEncodingException e) {
throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
}
} finally {
try {
if (is != null)
is.close();
} catch (IOException ioe) {
throw new JavaModelException(ioe, IJavaModelStatusConstants.IO_EXCEPTION);
} finally {
pm.done();
}
}
}
use of org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange 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.ltk.core.refactoring.resource.DeleteResourceChange in project che by eclipse.
the class CreatePackageChange method perform.
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
try {
pm.beginTask(RefactoringCoreMessages.CreatePackageChange_Creating_package, 1);
if (fPackageFragment.exists()) {
return new NullChange();
} else {
IPackageFragmentRoot root = (IPackageFragmentRoot) fPackageFragment.getParent();
root.createPackageFragment(fPackageFragment.getElementName(), false, pm);
return new DeleteResourceChange(fPackageFragment.getPath(), true);
}
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange in project bndtools by bndtools.
the class CreateFileChange method perform.
@Override
public Change perform(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, encoding != null ? 2 : 1);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile file = root.getFile(path);
file.create(source, updateFlags, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
if (encoding != null)
file.setCharset(encoding, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
return new DeleteResourceChange(path, true);
}
use of org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange in project che by eclipse.
the class DeleteResourcesProcessor method createChange.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
*/
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
pm.beginTask(RefactoringCoreMessages.DeleteResourcesProcessor_create_task, fResources.length);
try {
RefactoringChangeDescriptor descriptor = new RefactoringChangeDescriptor(createDescriptor());
CompositeChange change = new CompositeChange(RefactoringCoreMessages.DeleteResourcesProcessor_change_name);
change.markAsSynthetic();
for (int i = 0; i < fResources.length; i++) {
pm.worked(1);
DeleteResourceChange dc = new DeleteResourceChange(fResources[i].getFullPath(), true, fDeleteContents);
dc.setDescriptor(descriptor);
change.add(dc);
}
return change;
} finally {
pm.done();
}
}
Aggregations