Java Code Examples for org.eclipse.core.runtime.Path#isPrefixOf()
The following examples show how to use
org.eclipse.core.runtime.Path#isPrefixOf() .
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: ExternalResourceManager.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private static final Collection<IStatus> linkExternalDirectories(IProject p, Collection<File> externalDirectories, IProgressMonitor monitor) throws CoreException { monitor.beginTask(Messages.ExternalResourceManager_LinkingExternalFiles, externalDirectories.size()); Collection<IStatus> linkStatuses = new ArrayList<>(); recreateExternalsFolder(p.getName(), monitor); IFolder externalsFolder = p.getFolder(SpecialFolderNames.VIRTUAL_MOUNT_ROOT_DIR_NAME); Path projectPath = new Path(ResourceUtils.getAbsolutePath(p)); try{ for (File dir : externalDirectories) { boolean isInsideProject = projectPath.isPrefixOf(new Path(dir.getAbsolutePath())); if (dir.isDirectory() && !isInsideProject) { linkStatuses.add(linkDirectory(p, externalsFolder, dir, monitor, true)); monitor.worked(1); } } } finally{ monitor.done(); } return linkStatuses; }
Example 2
Source File: XdsProject.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * Tests whether the given {@link File} denotes the valid external directory. * @param buildSettings * @return */ private Predicate<File> newExternalDependencyDirectoryPredicate(BuildSettings buildSettings) { Path sdkHomePath = getSdkHomePath(buildSettings); Path projectPath = new Path(ResourceUtils.getAbsolutePath(getProject())); return d -> { if (d == null) { return true; // accept virtual folders } Path dirPath = new Path(d.getAbsolutePath()); boolean passes = d.isDirectory() && !projectPath.isPrefixOf(dirPath) && !dirPath.isPrefixOf(projectPath); if (passes && sdkHomePath != null){ // it is OK for sdkHomePath to be null, when it is not specified in settings passes &= !sdkHomePath.isPrefixOf(dirPath); } return passes; }; }
Example 3
Source File: XdsProject.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
protected Predicate<IResource> getResourceFilter() { BuildSettings buildSettings = BuildSettingsCache.createBuildSettings(getProject()); Predicate<File> pred = newExternalDependencyDirectoryPredicate(buildSettings); Sdk sdk = buildSettings.getSdk(); // TODO : modify this predicate to remove getRelativeFolderPathesToSkip methods return r -> { // accept all resources outside SpecialFolderNames.VIRTUAL_MOUNT_ROOT_DIR_NAME if (!ResourceUtils.isInsideFolder(SpecialFolderNames.VIRTUAL_MOUNT_ROOT_DIR_NAME, r)) { return true; } if (!JavaUtils.isOneOf(r, IContainer.class) || r.isVirtual()) { // accept all virtual folders and leaf resources return true; } // at this point we are testing non-virtual folder under the .mnt directory. File resourceFile = ResourceUtils.getAbsoluteFile(r); // skip external dependencies directories - they will be handled by the buildExternalDependenciesChildren if (pred.test(resourceFile)) { return false; } // skip library definition path directory - this will be handled by buildSdkLibraryChildren method if (sdk != null && sdk.getLibraryDefinitionsPath() != null) { Path libDefPath = new Path(sdk.getLibraryDefinitionsPath()); if (libDefPath.isPrefixOf(new Path(resourceFile.getAbsolutePath()))) { return false; } } return true; }; }
Example 4
Source File: ControlViewTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Test import * * @param createExperiment * flag to indicate to create an experiment or not * @param defaultExperiment * flag to indicate to use default experiment or not */ protected void testImport(boolean createExperiment, boolean defaultExperiment) { SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName(), ControlViewSwtBotUtil.SESSION_GROUP_NAME, getSessionName()); sessionItem.select(); TraceSessionComponent sessionComp = ControlViewSwtBotUtil.getSessionComponent(fNode, getSessionName()); String pathString = sessionComp.isSnapshotSession() ? sessionComp.getSnapshotInfo().getSnapshotPath() : sessionComp.getSessionPath(); IPath path = new Path(pathString); IWorkspace workspace = ResourcesPlugin.getWorkspace(); //get location of workspace (java.io.File) File workspaceDirectory = workspace.getRoot().getLocation().toFile(); Path workspacePath = new Path(workspaceDirectory.toString()); // Only do tests if session path is in workspace if (workspacePath.isPrefixOf(path)) { generateTrace(path); // Open import wizard SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.IMPORT_MENU_ITEM); menuBot.click(); SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.IMPORT_WIZARD_TITLE).activate(); // This will create the Remote project if needed closeImportWizard(shell, ControlViewSwtBotUtil.CANCEL_BUTTON); // Verify that remote project was created by import wizard TmfProjectElement tmfProject = verifyRemoteProject(); // Re-open import wizard menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.IMPORT_MENU_ITEM); menuBot.click(); shell = fBot.shell(ControlViewSwtBotUtil.IMPORT_WIZARD_TITLE).activate(); // Prepare and verify experiment handling String experimentName = prepareAndVerifyExperimentHandling(shell.bot(), createExperiment, defaultExperiment, path); // Finish and import closeImportWizard(shell, ControlViewSwtBotUtil.FINISH_BUTTON); // Verify experiment folder verifyExperimentFolder(createExperiment, tmfProject, experimentName); } }