private IFile findFile(String path) { URI uri = new File(repository.getWorkTree(), path).toURI(); IFile[] workspaceFiles = ResourcesPlugin.getWorkspace().getRoot() .findFilesForLocationURI(uri); if (workspaceFiles.length > 0) return workspaceFiles[0]; else return null; }
@Override public IFile getFile() { IPath location = fLocationProvider.getLocation(); if (location == null) { return null; } IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(location.toFile().toURI()); if (files.length > 0) { return files[0]; } return null; }
private IFile findFile(String path) { URI uri = new File(repository.getWorkTree(), path).toURI(); IFile[] workspaceFiles = ResourcesPlugin.getWorkspace().getRoot() .findFilesForLocationURI(uri); if (workspaceFiles.length > 0) return workspaceFiles[0]; else return null; } }
@Override public String getUrlForFile(File file) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI()); if (files.length > 0) { return getUrlForResource(files[0]); } else { return null; } }
@Override public String getUrlForFile(File file) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI()); if (files.length > 0) { return getUrlForResource(files[0]); } else { return null; } }
protected static IFile resolveInWorkspace(final Path file) { final IFile[] workspaceFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toUri()); if (workspaceFiles.length < 1) { return null; } final IFile workspaceFile = workspaceFiles[0]; if (!workspaceFile.exists()) { return null; } return workspaceFile; }
@Override public String getUrlForFile(File file) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI()); if (files.length > 0) { return getUrlForResource(files[0]); } else { return null; } }
public static IFile[] findFilesForLocationURI(URI uri) { IWorkspaceRoot root = getWorkspaceRoot(); return root.findFilesForLocationURI(uri); }
protected IFile getIFile(String filePath) { if (filePath == null) { return null; } IFile file = fFileNameToIFile.get(filePath); if (file == null) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new Path(filePath).toFile().toURI()); if (files.length > 0) { file = files[0]; fFileNameToIFile.put(filePath, file); } } return file; }
/** * Return all handles to Resource files for the given URI (in absolute form) * * @param filePathURI * - Absolute URI to the file * @return - File handles to resource files within the workspace */ public static IFile[] getWorkSpaceFiles(URI filePathURI) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] files = null; if (filePathURI != null) { files = filterNonExistentFiles(root.findFilesForLocationURI(filePathURI)); } return files; }
/** * Checks whether there given file store points * to a file in the workspace. Only returns a * workspace file if there's a single match. * * @param fileStore the file store * @return the <code>IFile</code> that matches the given file store * @since 3.2 */ private IFile getWorkspaceFile(IFileStore fileStore) { IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot(); IFile[] files= workspaceRoot.findFilesForLocationURI(fileStore.toURI()); if (files != null && files.length == 1) return files[0]; return null; }
@Override public void addFactoryWorkspace(String path, FactoryWorkspace workspace) { final IFile[] findFilesForLocationURI = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(Paths.get(path).toUri()); if (findFilesForLocationURI.length > 0) { super.addFactoryWorkspace(findFilesForLocationURI[0].getProject().toString(), workspace); } }
/** * @return the schema file */ private IFile getSchemaFile() { // Ensure the schema is defined if (fSchema == null) { return null; } // Get the Java schema file File javaSchemaFile = new File(fSchema.getURL().getFile()); // Get the Eclipse schema file IFile[] eclipseSchemaFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(javaSchemaFile.toURI()); // Ensure the file was found in the workspace if (eclipseSchemaFiles.length == 0) { return null; } return eclipseSchemaFiles[0]; }
@Override public FactoryWorkspace getFactoryWorkspace(String path) { final IFile[] findFilesForLocationURI = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(Paths.get(path).toUri()); if ((findFilesForLocationURI.length > 0) && (findFilesForLocationURI[0].getProject() != null)) { return super.getFactoryWorkspace(findFilesForLocationURI[0].getProject().toString()); } return defaultWorkspace; }
/** * Determine whether or not the <code>IFileStore</code> represents a file * currently in the workspace. * * @param fileStore * The <code>IFileStore</code> to test * @return The workspace's <code>IFile</code> if it exists or * <code>null</code> if not */ private static IFile getWorkspaceFile(IFileStore fileStore) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] files = root.findFilesForLocationURI(fileStore.toURI()); files = filterNonExistentFiles(files); if (files == null || files.length == 0) return null; // for now only return the first file return files[0]; }
public static IFile getWorkspaceFile(File file, String expectedProjectName) { IWorkspaceRoot root = CoreUtil.getWorkspaceRoot(); IPath path = new Path(file.getAbsolutePath()); File f = path.toFile(); IFile[] files = root.findFilesForLocationURI(f.toURI()); if (files.length == 0) { return null; } for (IFile wsFile : files) { IProject project = wsFile.getProject(); String projectName = project.getName(); if (projectName.equals(expectedProjectName)) { return wsFile; } } return null; }
protected Set<IProject> getModifiedResources(File createdProjectDir) throws CoreException { try { File parentPom = JaxWsModuleNewHelper.getParentPomOf(new File(createdProjectDir, IMavenConstants.POM)); if (parentPom == null) { return Collections.emptySet(); } IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] resources = root.findFilesForLocationURI(parentPom.toURI()); Set<IProject> result = new HashSet<>(resources.length); for (IFile f : resources) { result.add(f.getProject()); } return result; } catch (IOException | ParserConfigurationException | SAXException e) { throw new CoreException(new ScoutStatus(e)); } }
protected FileListener(AFileManager<T> fileManager) { this.fileManager = fileManager; IPath absolutePath2 = new org.eclipse.core.runtime.Path(fileManager.getAbsolutePath()); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IPath rootLocation = root.getLocation(); if (absolutePath2.matchingFirstSegments(rootLocation) != rootLocation.segmentCount()) { try { final IFile[] filesOfLocation = root.findFilesForLocationURI(URI.create("file:/" + absolutePath2.toString().replace(" ", "%20"))); absolutePath2 = filesOfLocation[0].getFullPath().makeRelativeTo(rootLocation); } catch (final IndexOutOfBoundsException e) { Logger.logError(e); eclipseFile = null; return; } } this.eclipseFile = absolutePath2.makeRelativeTo(rootLocation); }
public Element createXML(IJavaProject[] projects) throws CoreException { if (fAntpath.length() > 0) { try { IPath filePath= Path.fromOSString(fAntpath); IPath directoryPath= filePath.removeLastSegments(1); IPath basePath= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (root.findFilesForLocationURI(URIUtil.toURI(filePath.makeAbsolute())).length > 0) { basePath= directoryPath; // only do relative path if ant file is stored in the workspace } JavadocWriter writer= new JavadocWriter(basePath, projects); return writer.createXML(this); } catch (ParserConfigurationException e) { String message= JavadocExportMessages.JavadocOptionsManager_createXM_error; throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e)); } } return null; }
public Element createXML(IJavaProject[] projects) throws CoreException { if (fAntpath.length() > 0) { try { IPath filePath= Path.fromOSString(fAntpath); IPath directoryPath= filePath.removeLastSegments(1); IPath basePath= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (root.findFilesForLocationURI(URIUtil.toURI(filePath.makeAbsolute())).length > 0) { basePath= directoryPath; // only do relative path if ant file is stored in the workspace } JavadocWriter writer= new JavadocWriter(basePath, projects); return writer.createXML(this); } catch (ParserConfigurationException e) { String message= JavadocExportMessages.JavadocOptionsManager_createXM_error; throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e)); } } return null; }