Java Code Examples for org.eclipse.core.filesystem.IFileStore#toURI()
The following examples show how to use
org.eclipse.core.filesystem.IFileStore#toURI() .
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: VerySimpleBuilder.java From textuml with Eclipse Public License 1.0 | 6 votes |
protected void createMarkers(IProject project, IProblem[] problems) throws CoreException { URI projectURI = project.getLocationURI(); for (int i = 0; i < problems.length; i++) { IFileStore source = (IFileStore) problems[i].getAttribute(IProblem.FILE_NAME); IResource target = project; if (source != null) { final URI sourceURI = source.toURI(); if (sourceURI != null) { URI relativeURI = projectURI.relativize(sourceURI); if (!relativeURI.isAbsolute()) target = project.getFile(new Path(relativeURI.getPath())); } } IMarker marker = target.createMarker(UIConstants.MARKER_TYPE); marker.setAttribute(IMarker.SEVERITY, getMarkerSeverity(problems[i].getSeverity())); marker.setAttribute(IMarker.MESSAGE, problems[i].getMessage()); marker.setAttribute(IMarker.LINE_NUMBER, getLineNumber(problems[i])); } }
Example 2
Source File: WorkspaceResourceHandler.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * Generates a file system location for newly created project. Creates a new * folder in the file system and ensures it is empty. */ private static URI generateProjectLocation(ProjectInfo project, String user) throws CoreException { IFileStore projectStore = OrionConfiguration.getMetaStore().getDefaultContentLocation(project); if (projectStore.fetchInfo().exists()) { //This folder must be empty initially or we risk showing another user's old private data projectStore.delete(EFS.NONE, null); } projectStore.mkdir(EFS.NONE, null); return projectStore.toURI(); }
Example 3
Source File: WorkspaceResourceHandler.java From orion.server with Eclipse Public License 1.0 | 5 votes |
public static void removeProject(String user, WorkspaceInfo workspace, ProjectInfo project) throws CoreException { // remove the project folder URI contentURI = project.getContentLocation(); // only delete project contents if they are in default location IFileStore projectStore = OrionConfiguration.getMetaStore().getDefaultContentLocation(project); URI defaultLocation = projectStore.toURI(); if (URIUtil.sameURI(defaultLocation, contentURI)) { projectStore.delete(EFS.NONE, null); } OrionConfiguration.getMetaStore().deleteProject(workspace.getUniqueId(), project.getFullName()); }
Example 4
Source File: ResourceUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Works only for the file:// based file stores. * @param fileStore * @param monitor * @return * @throws CoreException */ public static String getAbsolutePath(IFileStore fileStore, IProgressMonitor monitor) throws CoreException { if (fileStore == null) { return null; } URI uri = fileStore.toURI(); if (!EFS.SCHEME_FILE.equals(uri.getScheme())) { return null; } return getAbsolutePath(new File(uri)); }
Example 5
Source File: Model.java From tlaplus with MIT License | 5 votes |
private void renameLaunch(final Spec newSpec, String newModelName) { try { // create the model with the new name final String fullyQualifiedName = fullyQualifiedNameFromSpecNameAndModelName(newSpec.getName(), newModelName); final ILaunchConfigurationWorkingCopy copy = this.launchConfig.copy(fullyQualifiedName); copy.setAttribute(SPEC_NAME, newSpec.getName()); copy.setAttribute(ModelHelper.MODEL_NAME, newModelName); copy.setContainer(newSpec.getProject()); final ILaunchConfiguration renamed = copy.doSave(); final IFileStore ifs = ((LaunchConfiguration)launchConfig).getFileStore(); // delete the copy of the old model in the new toolbox directory if (ifs != null) { final IPath newToolboxName = renamed.getFile().getFullPath().removeLastSegments(1); final URI u = ifs.toURI(); final File oldLaunchConfigFile = new File(u); final File grandParentDirectory = oldLaunchConfigFile.getParentFile().getParentFile(); final String newToolboxDirectoryName = newToolboxName.toString() + ResourceHelper.TOOLBOX_DIRECTORY_SUFFIX; final File fileToDelete = Paths.get(grandParentDirectory.getAbsolutePath(), newToolboxDirectoryName, oldLaunchConfigFile.getName()).toFile(); if (!fileToDelete.delete()) { TLCActivator.logInfo("Could not delete old launch file [" + fileToDelete.getAbsolutePath() + "] - will attempt on app exit, which is better than nothing."); fileToDelete.deleteOnExit(); } } else { TLCActivator.logInfo("Could not get filestore for the original launch config; this is problematic."); } // delete the old model launchConfig.delete(); launchConfig = renamed; } catch (CoreException e) { TLCActivator.logError("Error renaming model.", e); } }
Example 6
Source File: EFSUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns the absolute path of this file, from the root of the filestore. * * @param file * @return */ public static String getAbsolutePath(IFileStore file) { if (file != null) { URI uri = file.toURI(); if (uri != null) { return uri.getPath(); } } return null; }
Example 7
Source File: SearchScope.java From orion.server with Eclipse Public License 1.0 | 4 votes |
public SearchScope(IFileStore fileStore, WorkspaceInfo workspace, ProjectInfo project) { this.fileStore = fileStore; this.workspace = workspace; this.project = project; file = new File(fileStore.toURI()); }