use of org.eclipse.core.filebuffers.manipulation.FileBufferOperationRunner in project eclipse.platform.text by eclipse.
the class FileBufferOperationAction method doRun.
protected final void doRun(final IFile[] files, final IPath location, final IFileBufferOperation fileBufferOperation) {
Job job = new Job(fileBufferOperation.getOperationName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus status;
try {
int ticks = 100;
SubMonitor subMonitor = SubMonitor.convert(monitor, fFileBufferOperation.getOperationName(), ticks);
IPath[] locations;
if (files != null) {
ticks -= 30;
locations = generateLocations(files, subMonitor.split(30));
} else
locations = new IPath[] { location };
if (locations != null && locations.length > 0) {
FileBufferOperationRunner runner = new FileBufferOperationRunner(FileBuffers.getTextFileBufferManager(), getShell());
runner.execute(locations, fileBufferOperation, subMonitor.split(ticks));
}
status = Status.OK_STATUS;
} catch (OperationCanceledException e) {
// $NON-NLS-1$
status = new Status(IStatus.CANCEL, EditorsUI.PLUGIN_ID, IStatus.OK, "", null);
} catch (CoreException e) {
// $NON-NLS-1$
status = new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, "", e);
}
return status;
}
};
job.setUser(true);
job.schedule();
}
use of org.eclipse.core.filebuffers.manipulation.FileBufferOperationRunner in project eclipse.platform.text by eclipse.
the class FileBufferOperationHandler method doRun.
/**
* Runs the given operation.
*
* @param files the file on which to run this operation
* @param location the file buffer location
* @param fileBufferOperation the operation to run
*/
protected final void doRun(final IFile[] files, final IPath location, final IFileBufferOperation fileBufferOperation) {
Job job = new Job(fileBufferOperation.getOperationName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus status;
try {
int ticks = 100;
SubMonitor subMonitor = SubMonitor.convert(monitor, fFileBufferOperation.getOperationName(), ticks);
IPath[] locations;
if (files != null) {
ticks -= 30;
locations = generateLocations(files, subMonitor.split(30));
} else
locations = new IPath[] { location };
if (locations != null && locations.length > 0) {
FileBufferOperationRunner runner = new FileBufferOperationRunner(FileBuffers.getTextFileBufferManager(), getShell());
runner.execute(locations, fileBufferOperation, subMonitor.split(ticks));
}
status = Status.OK_STATUS;
} catch (OperationCanceledException e) {
// $NON-NLS-1$
status = new Status(IStatus.CANCEL, EditorsUI.PLUGIN_ID, IStatus.OK, "", null);
} catch (CoreException e) {
// $NON-NLS-1$
status = new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, "", e);
}
return status;
}
};
job.setUser(true);
job.schedule();
}
Aggregations