Java Code Examples for org.eclipse.core.runtime.IPath#isValidPath()
The following examples show how to use
org.eclipse.core.runtime.IPath#isValidPath() .
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: JarPackageData.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Gets the manifest file (as workspace resource). * * @return a file which points to the manifest */ public IFile getManifestFile() { IPath path= getManifestLocation(); if (path.isValidPath(path.toString()) && path.segmentCount() >= 2) return JavaPlugin.getWorkspace().getRoot().getFile(path); else return null; }
Example 2
Source File: JarPackageData.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Gets the description file (as workspace resource). * * @return a file which points to the description */ public IFile getDescriptionFile() { IPath path= getDescriptionLocation(); if (path.isValidPath(path.toString()) && path.segmentCount() >= 2) return JavaPlugin.getWorkspace().getRoot().getFile(path); else return null; }
Example 3
Source File: JarFileExportOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates a folder resource handle for the folder with the given workspace path. * * @param folderPath the path of the folder to create a handle for * @return the new folder resource handle */ private IFolder createFolderHandle(IPath folderPath) { if (folderPath.isValidPath(folderPath.toString()) && folderPath.segmentCount() >= 2) return JavaPlugin.getWorkspace().getRoot().getFolder(folderPath); else return null; }
Example 4
Source File: ClasspathEntry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void resolvedChainedLibraries(IPath jarPath, HashSet visited, ArrayList result) { if (visited.contains( jarPath)) return; visited.add(jarPath); JavaModelManager manager = JavaModelManager.getJavaModelManager(); if (manager.isNonChainingJar(jarPath)) return; List calledFileNames = getCalledFileNames(jarPath); if (calledFileNames == null) { manager.addNonChainingJar(jarPath); } else { Iterator calledFilesIterator = calledFileNames.iterator(); IPath directoryPath = jarPath.removeLastSegments(1); while (calledFilesIterator.hasNext()) { String calledFileName = (String) calledFilesIterator.next(); if (!directoryPath.isValidPath(calledFileName)) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } } else { IPath calledJar = directoryPath.append(new Path(calledFileName)); // Ignore if segment count is Zero (https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150) if (calledJar.segmentCount() == 0) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } continue; } resolvedChainedLibraries(calledJar, visited, result); result.add(calledJar); } } } }
Example 5
Source File: NewProjectNameAndLocationWizardPage.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * Returns whether this page's controls currently all contain valid * values. * * @return <code>true</code> if all controls are valid, and * <code>false</code> if at least one is invalid */ protected boolean validatePage() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); String projectFieldContents = getProjectNameFieldValue(); if (projectFieldContents.equals("")) { //$NON-NLS-1$ setErrorMessage(null); setMessage("Project name is empty"); return false; } IStatus nameStatus = workspace.validateName(projectFieldContents, IResource.PROJECT); if (!nameStatus.isOK()) { setErrorMessage(nameStatus.getMessage()); return false; } String locationFieldContents = getProjectLocationFieldValue(); if (locationFieldContents.equals("")) { //$NON-NLS-1$ setErrorMessage(null); setMessage("Project location is empty"); return false; } IPath path = new Path(""); //$NON-NLS-1$ if (!path.isValidPath(locationFieldContents)) { setErrorMessage("Project location is not valid"); return false; } //commented out. See comments on https://sourceforge.net/tracker/?func=detail&atid=577329&aid=1798364&group_id=85796 // if (!useDefaults // && Platform.getLocation().isPrefixOf( // new Path(locationFieldContents))) { // setErrorMessage("Default location error"); // return false; // } IProject projectHandle = getProjectHandle(); if (projectHandle.exists()) { setErrorMessage("Project already exists"); return false; } if (!useDefaults) { path = getLocationPath(); if (path.equals(workspace.getRoot().getLocation())) { setErrorMessage("Project location cannot be the workspace location."); return false; } } if (isDotProjectFileInLocation()) { setErrorMessage(".project found in: " + getLocationPath().toOSString() + " (use the Import Project wizard instead)."); return false; } if (getProjectInterpreter() == null) { setErrorMessage("Project interpreter not specified"); return false; } setErrorMessage(null); setMessage(null); // Look for existing Python files in the destination folder. File locFile = (!useDefaults ? getLocationPath() : getLocationPath().append(projectFieldContents)).toFile(); PyFileListing pyFileListing = PythonPathHelper.getModulesBelow(locFile, null, new ArrayList<>()); if (pyFileListing != null) { boolean foundInit = false; Collection<PyFileInfo> modulesBelow = pyFileListing.getFoundPyFileInfos(); for (PyFileInfo fileInfo : modulesBelow) { // Only notify existence of init files in the top-level directory. if (PythonPathHelper.isValidInitFile(fileInfo.getFile().getPath()) && fileInfo.getFile().getParentFile().equals(locFile)) { setMessage( "Project location contains an __init__.py file. Consider using the location's parent folder instead."); foundInit = true; break; } } if (!foundInit && modulesBelow.size() > 0) { setMessage("Project location contains existing Python files. The created project will include them."); } } return true; }
Example 6
Source File: JarPackageWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Creates a file resource handle for the file with the given workspace path. * This method does not create the file resource; this is the responsibility * of <code>createFile</code>. * * @param filePath the path of the file resource to create a handle for * @return the new file resource handle */ protected IFile createFileHandle(IPath filePath) { if (filePath.isValidPath(filePath.toString()) && filePath.segmentCount() >= 2) return ResourcesPlugin.getWorkspace().getRoot().getFile(filePath); else return null; }
Example 7
Source File: JarOptionsPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Creates a file resource handle for the file with the given workspace path. * This method does not create the file resource; this is the responsibility * of <code>createFile</code>. * * @param filePath the path of the file resource to create a handle for * @return the new file resource handle */ protected IFile createFileHandle(IPath filePath) { if (filePath.isValidPath(filePath.toString()) && filePath.segmentCount() >= 2) return JavaPlugin.getWorkspace().getRoot().getFile(filePath); else return null; }
Example 8
Source File: JarManifestWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Creates a file resource handle for the file with the given workspace path. * This method does not create the file resource; this is the responsibility * of <code>createFile</code>. * * @param filePath the path of the file resource to create a handle for * @return the new file resource handle */ protected IFile createFileHandle(IPath filePath) { if (filePath.isValidPath(filePath.toString()) && filePath.segmentCount() >= 2) return JavaPlugin.getWorkspace().getRoot().getFile(filePath); else return null; }