public boolean isValidPath(String path) { Path test = new Path(path); for (int i = 0, max = test.segmentCount(); i < max; i++) if (!isValidSegment(test.segment(i))) return false; return true; }
public static Object createCodeFormatter(Map<?, ?> options, String workspacePath) { if (options == null) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(workspacePath).segment(0)); if (project != null) { IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { options = javaProject.getOptions(true); } } } return ToolFactory.createCodeFormatter(options); }
public boolean isValidPath(String path) { Path test = new Path(path); for (int i = 0, max = test.segmentCount(); i < max; i++) if (!isValidSegment(test.segment(i))) return false; return true; }
public static Object createCodeFormatter(Map<?, ?> options, String workspacePath) { if (options == null) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(workspacePath).segment(0)); if (project != null) { IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { options = javaProject.getOptions(true); } } } return ToolFactory.createCodeFormatter(options); }
public void save(String filename, Map<String, String> map, HashSet<?> selected) { Properties properties = getTracingOptions(map); for (Enumeration<?> keys = properties.keys(); keys.hasMoreElements();) { String key = keys.nextElement().toString(); Path path = new Path(key); if (path.segmentCount() < 1 || !selected.contains(path.segment(0).toString())) { properties.remove(key); } } save(filename, properties); }
if (modelDirectory != null) referencedModelProjects.add(workspaceRoot.getProject(new Path(modelDirectory).segment(0))); String editDirectory = referencedGenModel.getEditDirectory(); if (editDirectory != null && !modelDirectory.equals(editDirectory) && !"".equals(editDirectory)) referencedEditProjects.add(workspaceRoot.getProject(new Path(editDirectory).segment(0)));
public void save(String filename, Map map, HashSet selected) { Properties properties = getTracingOptions(map); for (Enumeration keys = properties.keys(); keys.hasMoreElements();) { String key = keys.nextElement().toString(); Path path = new Path(key); if (path.segmentCount() < 1 || !selected.contains(path.segment(0).toString())) { properties.remove(key); } } save(filename, properties); }
private static IProject getProject(URI uri) { String projectName; if (isPlatformResourceURI(uri)) projectName = uri.segment(1); else if (uri.scheme() == null) { projectName = new Path(uri.path()).segment(0); //assume project name is first in the URI } else return null; IProject project = getWorkspace().getRoot().getProject(URI.decode(projectName)); if (project != null && project.isAccessible()) return project; else return null; }
/** * Returns whether the given string is syntactically correct as a path on * the specified file system. The device id is the prefix up to and * including the device separator for the specified file system; the path * proper is everything to the right of it, or the entire string if there is * no device separator. When the specified platform is a file system with no * meaningful device separator, the entire string is treated as the path * proper. The device id is not checked for validity; the path proper is * correct if each of the segments in its canonicalized form is valid. * * @param path the path to check * @param forWindows true if the path is for the Windows file system * @return <code>true</code> if the given string is a valid path, * and <code>false</code> otherwise * @see #isValidSegment(String, boolean) * @since 3.7 */ private static boolean isValidPath(String path, boolean forWindows) { Path test = new Path(path, forWindows); for (int i = 0, max = test.segmentCount(); i < max; i++) if (!Path.isValidSegment(test.segment(i), forWindows)) return false; return true; }
tpath = menuPath.segment(0);
/** * Returns whether the given string is syntactically correct as a path on * the specified file system. The device id is the prefix up to and * including the device separator for the specified file system; the path * proper is everything to the right of it, or the entire string if there is * no device separator. When the specified platform is a file system with no * meaningful device separator, the entire string is treated as the path * proper. The device id is not checked for validity; the path proper is * correct if each of the segments in its canonicalized form is valid. * * @param path the path to check * @param forWindows true if the path is for the Windows file system * @return <code>true</code> if the given string is a valid path, * and <code>false</code> otherwise * @see #isValidSegment(String, boolean) * @since 3.7 */ private static boolean isValidPath(String path, boolean forWindows) { Path test = new Path(path, forWindows); for (int i = 0, max = test.segmentCount(); i < max; i++) if (!Path.isValidSegment(test.segment(i), forWindows)) return false; return true; }
public IPath makeAbsolute() { if (isAbsolute()) { return this; } Path result = new Path(device, segments, separators | HAS_LEADING); //may need canonicalizing if it has leading ".." or "." segments if (result.segmentCount() > 0) { String first = result.segment(0); if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } } return result; }
public IPath makeAbsolute() { if (isAbsolute()) { return this; } Path result = new Path(device, segments, separators | HAS_LEADING); //may need canonicalizing if it has leading ".." or "." segments if (result.segmentCount() > 0) { String first = result.segment(0); if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } } return result; }
@Override public IPath makeAbsolute() { if (isAbsolute()) { return this; } Path result = new Path(device, segments, flags | HAS_LEADING); //may need canonicalizing if it has leading ".." or "." segments if (result.segmentCount() > 0) { String first = result.segment(0); if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } } return result; }
@Override public IPath makeAbsolute() { if (isAbsolute()) { return this; } Path result = new Path(device, segments, flags | HAS_LEADING); //may need canonicalizing if it has leading ".." or "." segments if (result.segmentCount() > 0) { String first = result.segment(0); if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } } return result; }
MElementContainer<MMenuElement> findMenuFromPath(MElementContainer<MMenuElement> menu, Path menuPath, int segment) { int idx = ContributionsAnalyzer.indexForId(menu, menuPath.segment(segment)); if (idx == -1) { if (segment + 1 < menuPath.segmentCount() || !menuPath.hasTrailingSeparator()) { return null; } return menu; } MElementContainer<MMenuElement> item = (MElementContainer<MMenuElement>) menu.getChildren() .get(idx); if (item.getChildren().isEmpty()) { if (segment + 1 == menuPath.segmentCount()) { return menu; } return null; } return findMenuFromPath(item, menuPath, segment + 1); } }
private void addExtraPrerequisites(IPluginModelBase model, ArrayList<IPluginModelBase> result) { try { IBuildModel buildModel = PluginRegistry.createBuildModel(model); if (buildModel == null) return; IBuildEntry entry = buildModel.getBuild().getEntry(IBuildEntry.JARS_EXTRA_CLASSPATH); if (entry == null) return; String[] tokens = entry.getTokens(); for (String token : tokens) { Path path = new Path(token); if (path.segmentCount() >= 2 && path.segment(0).equals("..")) { //$NON-NLS-1$ for (int j = 0; j < fModels.length; j++) { if (fModels[j].getPluginBase().getId().equals(path.segment(1)) && !result.contains(fModels[j])) { result.add(fModels[j]); } } } } } catch (CoreException e) { } }
private IStatus copy(String src, IFileStore destinationParent, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException { Path srcPath = new Path(src); IFileStore source = fileSystem.getStore(srcPath); String elementName = srcPath.segment(srcPath.segmentCount() - 1); IFileStore destination = destinationParent.getChild(elementName); SubMonitor subMonitor = SubMonitor.convert(monitor, 1); if (destination.fetchInfo().exists()) { return Status.OK_STATUS; } if (source.fetchInfo().isDirectory()) { destination.mkdir(EFS.NONE, new NullProgressMonitor()); } source.copy(destination, EFS.OVERWRITE, subMonitor.split(1)); return Status.OK_STATUS; }