Java Code Examples for org.eclipse.core.filesystem.EFS#getLocalFileSystem()

The following examples show how to use org.eclipse.core.filesystem.EFS#getLocalFileSystem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkspaceResolvingURIMapper.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public IFileStore resolve(URI uri)
{
	IFileStore fileStore = baseMapper.resolve(uri);
	if (fileStore != null && fileStore.getFileSystem() == EFS.getLocalFileSystem()) // $codepro.audit.disable
																					// useEquals
	{
		try
		{
			fileStore = EFSUtils.fromLocalFile(fileStore.toLocalFile(EFS.NONE, new NullProgressMonitor()));
		}
		catch (CoreException e)
		{
			IdeLog.logError(WebServerCorePlugin.getDefault(), e);
		}
	}
	return fileStore;
}
 
Example 2
Source File: CompilationDirectorCLI.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
private void compile(IRepository repository, final String inputPathAsString, final String outputPathAsString)
		throws CoreException {
	IFileSystem localFS = EFS.getLocalFileSystem();
	final IFileStore outputPath = localFS.getStore(new Path(outputPathAsString));
	LocationContext context = new LocationContext(outputPath);
	final IFileStore sourcePath = localFS.getStore(new Path(inputPathAsString));
	if (!sourcePath.fetchInfo().exists()) {
		System.err.println(sourcePath + " does not exist");
		System.exit(1);
	}
	context.addSourcePath(sourcePath, outputPath);
	int mode = ICompilationDirector.CLEAN | ICompilationDirector.FULL_BUILD;
	if (Boolean.getBoolean("args.debug"))
		mode |= ICompilationDirector.DEBUG;
	IProblem[] problems = CompilationDirector.getInstance().compile(null, repository, context, mode, null);
	if (problems.length > 0) {
		MultiStatus parent = new MultiStatus(FrontEnd.PLUGIN_ID, IStatus.OK, "Problems occurred", null);
		for (int i = 0; i < problems.length; i++) {
			String message = problems[i].toString();
			parent.add(buildStatus(message, null));
		}
		LogUtils.log(parent);
	} else
		LogUtils.logInfo(FrontEnd.PLUGIN_ID, "Done", null);
}
 
Example 3
Source File: PlatformUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Copy a resource a the bundle to the destination path
 *
 * @param destinationFolder
 * @param bundle
 * @param resourceName
 * @return the copied resource
 */
public static void copyResourceDirectory(final File destFolder, final File sourceFolder,
        final IProgressMonitor monitor) {
    if (fileSystem == null) {
        fileSystem = EFS.getLocalFileSystem();
    }
    if (sourceFolder.isDirectory()) {
        final IFileStore sourceStore = fileSystem.fromLocalFile(sourceFolder);
        final IFileStore destStore = fileSystem.fromLocalFile(destFolder);
        try {
            sourceStore.copy(destStore, EFS.OVERWRITE, new NullProgressMonitor());
        } catch (final CoreException e) {
            BonitaStudioLog.error(e);
        }
    } else {
        copyResource(destFolder, sourceFolder.toURI(), monitor);
    }
}
 
Example 4
Source File: PlatformUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static void move(final File fileToMove, final File toDir, final IProgressMonitor monitor) {
    if (fileToMove == null || !fileToMove.exists()) {
        return;
    }

    if (fileSystem == null) {
        fileSystem = EFS.getLocalFileSystem();
    }

    final IFileStore fileToMoveStore = fileSystem.fromLocalFile(fileToMove);
    final IFileStore dest = fileSystem.fromLocalFile(toDir);
    try {
        fileToMoveStore.move(dest.getChild(fileToMoveStore.getName()), EFS.OVERWRITE, new NullProgressMonitor());
        monitor.worked(1);
    } catch (final CoreException e) {
        BonitaStudioLog.error(e);
    }

}
 
Example 5
Source File: PlatformUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy a resource a the bundle to the destination path
 *
 * @param destinationFolder
 * @param bundle
 * @param resourceName
 * @return the copied resource
 */
public static void copyResource(File destFolder, final File sourceFolder, final IProgressMonitor monitor) {
    if (fileSystem == null) {
        fileSystem = EFS.getLocalFileSystem();
    }
    if (sourceFolder.isDirectory()) {
        destFolder = destFolder.getParentFile();
    }
    copyResource(destFolder, sourceFolder.toURI(), monitor);
}
 
Example 6
Source File: PlatformUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void copyResource(final File destFolder, final URI uri,
        final IProgressMonitor monitor) {
    if (fileSystem == null) {
        fileSystem = EFS.getLocalFileSystem();
    }
    try {
        final IFileStore sourceStore = fileSystem.getStore(URIUtil.toURI(uri.getPath()));
        final IFileStore destStore = fileSystem.fromLocalFile(destFolder);
        sourceStore.copy(destStore.getChild(sourceStore.getName()), EFS.OVERWRITE, new NullProgressMonitor());
        monitor.worked(1);
    } catch (final Exception e) {
        BonitaStudioLog.error(e);
    }
}
 
Example 7
Source File: UIHelper.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * @param file The file to open
 * @param name A human readable name for the input file. If the file name is to be used, pass {@link File#getName()}
 * @see UIHelper#openEditorUnchecked(String, IEditorInput, boolean)
 */
public static IEditorPart openEditorUnchecked(final String editorId, final File file, final String name, final boolean activate) throws PartInitException {
	final IFileSystem localFileSystem = EFS.getLocalFileSystem();
	final IFileStore fromLocalFile = localFileSystem.fromLocalFile(file);
	return openEditorUnchecked(editorId, new NamedFileStoreEditorInput(fromLocalFile, name), activate);
}
 
Example 8
Source File: PlatformUtil.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public static IFileSystem getFileSystem() {
    if (fileSystem == null) {
        fileSystem = EFS.getLocalFileSystem();
    }
    return fileSystem;
}