use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RefactoringHistoryManager method removeIndexTree.
/**
* Removes the refactoring history index tree spanned by the specified file
* store.
*
* @param store
* the file store spanning the history index tree
* @param monitor
* the progress monitor to use
* @param task
* the task label to use
* @throws CoreException
* if an error occurs while removing the index tree
*/
private static void removeIndexTree(final IFileStore store, final IProgressMonitor monitor, final String task) throws CoreException {
try {
monitor.beginTask(task, 16);
final IFileInfo info = store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
if (info.isDirectory()) {
if (info.getName().equalsIgnoreCase(RefactoringHistoryService.NAME_HISTORY_FOLDER))
return;
final IFileStore[] stores = store.childStores(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
final IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
try {
subMonitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_updating_history, stores.length);
for (int index = 0; index < stores.length; index++) {
final IFileInfo current = stores[index].fetchInfo(EFS.NONE, new SubProgressMonitor(subMonitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
if (current.isDirectory()) {
final char[] characters = stores[index].getName().toCharArray();
for (int offset = 0; offset < characters.length; offset++) {
if (Character.isDigit(characters[offset]))
return;
else
continue;
}
}
}
} finally {
subMonitor.done();
}
}
final IFileStore parent = store.getParent();
store.delete(0, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
removeIndexTree(parent, new SubProgressMonitor(monitor, 12, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL), task);
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RefactoringHistoryManager method writeIndexEntry.
/**
* Writes the specified index entry to the refactoring history.
*
* @param file
* the history index file
* @param proxies
* the refactoring descriptors
* @param flags
* the flags to use (either {@link EFS#NONE} or
* {@link EFS#APPEND})
* @param monitor
* the progress monitor to use
* @param task
* the task label
* @throws CoreException
* if an error occurs while writing the index entry
* @throws IOException
* if an input/output error occurs
*/
private static void writeIndexEntry(final IFileStore file, final RefactoringDescriptorProxy[] proxies, final int flags, final IProgressMonitor monitor, final String task) throws CoreException, IOException {
OutputStream output = null;
try {
monitor.beginTask(task, 2);
file.getParent().mkdir(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
output = new BufferedOutputStream(file.openOutputStream(flags, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
writeRefactoringDescriptorProxies(output, proxies);
} finally {
monitor.done();
if (output != null) {
try {
output.close();
} catch (IOException exception) {
// Do nothing
}
}
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class RefactoringHistoryManager method readRefactoringHistory.
/**
* Reads the refactoring history from disk.
*
* @param start
* the start time stamp, inclusive
* @param end
* the end time stamp, inclusive
* @param monitor
* the progress monitor to use
* @return the refactoring history
*/
RefactoringHistory readRefactoringHistory(final long start, final long end, final IProgressMonitor monitor) {
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 200);
final Set set = new HashSet();
try {
if (fHistoryStore.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
readRefactoringDescriptorProxies(fHistoryStore, fProjectName, set, start, end, new SubProgressMonitor(monitor, 80), RefactoringCoreMessages.RefactoringHistoryService_retrieving_history);
final IFileStore store = EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation()).getChild(RefactoringHistoryService.NAME_HISTORY_FOLDER).getChild(RefactoringHistoryService.NAME_WORKSPACE_PROJECT);
if (store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
readRefactoringDescriptorProxies(store, null, set, start, end, new SubProgressMonitor(monitor, 80), RefactoringCoreMessages.RefactoringHistoryService_retrieving_history);
} catch (CoreException exception) {
RefactoringCorePlugin.log(exception);
}
final RefactoringDescriptorProxy[] proxies = new RefactoringDescriptorProxy[set.size()];
set.toArray(proxies);
return new RefactoringHistoryImplementation(proxies);
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class MoveResourceChange method performSourceRestore.
private void performSourceRestore(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(RefactoringCoreMessages.MoveResourceChange_progress_restore_source, 3);
try {
fRestoreSourceChange.initializeValidationData(new SubProgressMonitor(monitor, 1));
RefactoringStatus restoreStatus = fRestoreSourceChange.isValid(new SubProgressMonitor(monitor, 1));
if (!restoreStatus.hasFatalError()) {
fRestoreSourceChange.perform(new SubProgressMonitor(monitor, 1));
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.SubProgressMonitor in project che by eclipse.
the class MoveResourceChange method perform.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
*/
public final Change perform(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
try {
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask(getName(), 4);
Change deleteUndo = null;
// delete destination if required
IResource resourceAtDestination = fTarget.findMember(fSource.getName());
if (resourceAtDestination != null && resourceAtDestination.exists()) {
deleteUndo = performDestinationDelete(resourceAtDestination, new SubProgressMonitor(monitor, 1));
} else {
monitor.worked(1);
}
// move resource
long currentStamp = fSource.getModificationStamp();
IPath destinationPath = fTarget.getFullPath().append(fSource.getName());
fSource.move(destinationPath, IResource.KEEP_HISTORY | IResource.SHALLOW, new SubProgressMonitor(monitor, 2));
resourceAtDestination = ResourcesPlugin.getWorkspace().getRoot().findMember(destinationPath);
// restore timestamp at destination
if (fStampToRestore != IResource.NULL_STAMP) {
resourceAtDestination.revertModificationStamp(fStampToRestore);
}
// restore file at source
if (fRestoreSourceChange != null) {
performSourceRestore(new SubProgressMonitor(monitor, 1));
} else {
monitor.worked(1);
}
return new MoveResourceChange(resourceAtDestination, fSource.getParent(), currentStamp, deleteUndo);
} finally {
monitor.done();
}
}
Aggregations