Search in sources :

Example 1 with IFileStore

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;
}
Also used : IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 2 with IFileStore

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();
    }
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFileStore(org.eclipse.core.filesystem.IFileStore) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 3 with IFileStore

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();
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CoreException(org.eclipse.core.runtime.CoreException) RefactoringDescriptorProxy(org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy) IFileStore(org.eclipse.core.filesystem.IFileStore) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) HashSet(java.util.HashSet)

Example 4 with IFileStore

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();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IFileStore(org.eclipse.core.filesystem.IFileStore) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 5 with IFileStore

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();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileStore(org.eclipse.core.filesystem.IFileStore) URI(java.net.URI) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Aggregations

IFileStore (org.eclipse.core.filesystem.IFileStore)178 CoreException (org.eclipse.core.runtime.CoreException)80 IOException (java.io.IOException)49 IPath (org.eclipse.core.runtime.IPath)42 IFileInfo (org.eclipse.core.filesystem.IFileInfo)33 URI (java.net.URI)30 Path (org.eclipse.core.runtime.Path)30 IFile (org.eclipse.core.resources.IFile)28 PartInitException (org.eclipse.ui.PartInitException)25 File (java.io.File)22 InputStream (java.io.InputStream)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)21 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)18 InputStreamReader (java.io.InputStreamReader)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)14 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)14 BufferedInputStream (java.io.BufferedInputStream)13 BufferedReader (java.io.BufferedReader)13 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)11 IStatus (org.eclipse.core.runtime.IStatus)11