use of org.eclipse.core.filesystem.IFileStore in project che by eclipse.
the class FileStore method getFileStore.
/**
* The default implementation of {@link IFileStore#getFileStore(IPath)}
* Subclasses may override.
*
* @since org.eclipse.core.filesystem 1.2
*/
public IFileStore getFileStore(IPath path) {
IFileStore result = this;
String segment = null;
for (int i = 0, imax = path.segmentCount(); i < imax; i++) {
segment = path.segment(i);
if (//$NON-NLS-1$
segment.equals("."))
continue;
else if (//$NON-NLS-1$
segment.equals("..") && result.getParent() != null)
result = result.getParent();
else
result = result.getChild(segment);
}
return result;
}
use of org.eclipse.core.filesystem.IFileStore 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.filesystem.IFileStore 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.filesystem.IFileStore in project che by eclipse.
the class RefactoringHistoryService method moveHistory.
/**
* Moves the project history from the old project to the new one.
*
* @param oldProject
* the old project, which does not exist anymore
* @param newProject
* the new project, which already exists
* @param monitor
* the progress monitor to use
*/
private void moveHistory(final IProject oldProject, final IProject newProject, final IProgressMonitor monitor) {
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_updating_history, 60);
final IFileStore historyStore = EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation()).getChild(NAME_HISTORY_FOLDER);
final String oldName = oldProject.getName();
final String newName = newProject.getName();
final IFileStore oldStore = historyStore.getChild(oldName);
if (oldStore.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists()) {
final IFileStore newStore = historyStore.getChild(newName);
if (newStore.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
newStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
oldStore.move(newStore, EFS.OVERWRITE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
}
} catch (CoreException exception) {
RefactoringCorePlugin.log(exception);
} finally {
monitor.done();
}
}
use of org.eclipse.core.filesystem.IFileStore in project che by eclipse.
the class RefactoringHistoryService method deleteRefactoringHistory.
/**
* Deletes the refactoring history of a project. Refactorings associated
* with the workspace are not deleted.
* <p>
* If a refactoring history is deleted, all files stored in the hidden
* refactoring history folder of the project folder are removed. If no
* shared refactoring history is enabled, the refactoring history
* information is removed from the internal workspace refactoring history.
* </p>
*
* @param project
* the project to delete its history
* @param monitor
* the progress monitor to use, or <code>null</code>
* @throws CoreException
* if an error occurs while deleting the refactoring history.
* Reasons include:
* <ul>
* <li>An I/O error occurs while deleting the refactoring
* history.</li>
* </ul>
*/
public void deleteRefactoringHistory(final IProject project, IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(project);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_deleting_refactorings, 100);
final String name = project.getName();
final IFileStore stateStore = EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation());
if (name.equals(NAME_WORKSPACE_PROJECT)) {
final IFileStore metaStore = stateStore.getChild(NAME_HISTORY_FOLDER).getChild(name);
metaStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 100));
} else {
final URI uri = project.getLocationURI();
if (uri != null && project.isAccessible()) {
try {
final IFileStore metaStore = stateStore.getChild(NAME_HISTORY_FOLDER).getChild(name);
metaStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 20));
final IFileStore projectStore = EFS.getStore(uri).getChild(NAME_HISTORY_FOLDER);
projectStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 20));
} finally {
project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 60));
}
}
}
} finally {
monitor.done();
}
}
Aggregations