Java Code Examples for org.eclipse.core.runtime.Path#EMPTY
The following examples show how to use
org.eclipse.core.runtime.Path#EMPTY .
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: JavaSearchScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IPath getPath(IJavaElement element, boolean relativeToRoot) { switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return Path.EMPTY; case IJavaElement.JAVA_PROJECT: return element.getPath(); case IJavaElement.PACKAGE_FRAGMENT_ROOT: if (relativeToRoot) return Path.EMPTY; return element.getPath(); case IJavaElement.PACKAGE_FRAGMENT: String relativePath = Util.concatWith(((PackageFragment) element).names, '/'); return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath)); case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName())); default: return getPath(element.getParent(), relativeToRoot); } }
Example 2
Source File: AbstractSarlMavenTest.java From sarl with Apache License 2.0 | 6 votes |
@Override protected void createFolders(IProject project, SubMonitor subMonitor, Shell shell) throws CoreException { if (this.folders != null) { for (final String folderName : this.folders) { IPath path = Path.fromPortableString(folderName); IPath tmpPath = Path.EMPTY; for (String segment : path.segments()) { tmpPath = tmpPath.append(segment); IFolder folder = project.getFolder(tmpPath.toPortableString()); if (!folder.exists()) { folder.create(false, true, subMonitor.newChild(1)); } } } } }
Example 3
Source File: SiteConfigurationServlet.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * @return The request's PathInfo as an IPath. */ private static IPath getPathInfo(HttpServletRequest req) { String pathString = req.getPathInfo(); IPath path = pathString == null ? Path.EMPTY : new Path(pathString); if (req.getContextPath().length() != 0) { IPath contextPath = new Path(req.getContextPath()); if (contextPath.isPrefixOf(path)) { path = path.removeFirstSegments(contextPath.segmentCount()); } } return path; }
Example 4
Source File: NewJavaProjectPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IPath decodePath(String str) { if ("#".equals(str)) { //$NON-NLS-1$ return null; } else if ("&".equals(str)) { //$NON-NLS-1$ return Path.EMPTY; } else { return Path.fromPortableString(decode(str)); } }
Example 5
Source File: StandardSREInstallTest.java From sarl with Apache License 2.0 | 5 votes |
@Test public void getClassPathEntry() { List<IRuntimeClasspathEntry> locations = new ArrayList<>(); LibraryLocation location = new LibraryLocation(this.path, Path.EMPTY, Path.EMPTY); IClasspathEntry cpEntry = JavaCore.newLibraryEntry( location.getSystemLibraryPath(), location.getSystemLibrarySourcePath(), location.getPackageRootPath()); IRuntimeClasspathEntry rtcpEntry = new RuntimeClasspathEntry(cpEntry); rtcpEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES); locations.add(rtcpEntry); assertEquals(locations, this.sre.getClassPathEntries()); }
Example 6
Source File: GitHandlerV1.java From orion.server with Eclipse Public License 1.0 | 4 votes |
@Override public boolean handleRequest(HttpServletRequest request, HttpServletResponse response, String gitPathInfo) throws ServletException { String[] infoParts = gitPathInfo.split("\\/", 3); //$NON-NLS-1$ if (infoParts.length < 2) return false; // malformed request, we don't know how to handle this String pathString = infoParts.length > 2 ? infoParts[2] : ""; if (request.getContextPath().length() != 0) { IPath path = pathString == null ? Path.EMPTY : new Path(pathString); IPath contextPath = new Path(request.getContextPath()); if (contextPath.isPrefixOf(path)) { pathString = path.removeFirstSegments(contextPath.segmentCount()).toString(); } } // TODO: Add to constants String tokenName = PreferenceHelper.getString("ltpa.token.name"); //$NON-NLS-1$ if (tokenName != null) { javax.servlet.http.Cookie[] cookies = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { Cookie currentCookie = cookies[i]; if (tokenName.equals(currentCookie.getName())) { Cookie loginCookie = new Cookie(currentCookie.getName(), GitUtils.sanitizeCookie(currentCookie.getValue())); request.setAttribute(GitConstants.KEY_SSO_TOKEN, loginCookie); } } } } if (infoParts[1].equals(Branch.RESOURCE)) { return branchHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Clone.RESOURCE)) { return cloneHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Commit.RESOURCE)) { return commitHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(ConfigOption.RESOURCE)) { return configHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Diff.RESOURCE)) { return diffHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Index.RESOURCE)) { return indexHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Remote.RESOURCE)) { return remoteHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Status.RESOURCE)) { return statusHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Tag.RESOURCE)) { return tagHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Blame.RESOURCE)) { return blameHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Ignore.RESOURCE)) { return ignoreHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Tree.RESOURCE)) { return treeHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Stash.RESOURCE)) { return stashHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(Submodule.RESOURCE)) { return submoduleHandlerV1.handleRequest(request, response, pathString); } else if (infoParts[1].equals(PullRequest.RESOURCE)) { return pullRequestHandlerV1.handleRequest(request, response, pathString); } return false; }
Example 7
Source File: GitTreeHandlerV1.java From orion.server with Eclipse Public License 1.0 | 4 votes |
@Override public boolean handleRequest(HttpServletRequest request, HttpServletResponse response, String pathString) throws ServletException { IPath path = pathString == null ? Path.EMPTY : new Path(pathString); int segmentCount = path.segmentCount(); if (getMethod(request) == Method.GET && ( segmentCount == 0 || ("workspace".equals(path.segment(0)) && path.segmentCount() == 2) || //$NON-NLS-1$ ("file".equals(path.segment(0)) && path.segmentCount() == 2) //$NON-NLS-1$ )) { String userId = request.getRemoteUser(); if (userId == null) { statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, "User name not specified", null)); return false; } try { UserInfo user = OrionConfiguration.getMetaStore().readUser(userId); URI baseLocation = new URI("orion", null, request.getServletPath(), null, null); baseLocation = URIUtil.append(baseLocation, Tree.RESOURCE); baseLocation = URIUtil.append(baseLocation, "file"); //$NON-NLS-N$ if (segmentCount == 0) { OrionServlet.writeJSONResponse(request, response, UserInfoResourceHandler.toJSON(user, baseLocation), JsonURIUnqualificationStrategy.ALL_NO_GIT); return true; } WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(path.segment(1)); if (workspace != null) { JSONArray children = new JSONArray(); for (String projectName : workspace.getProjectNames()) { ProjectInfo project = OrionConfiguration.getMetaStore().readProject(workspace.getUniqueId(), projectName); if (isAccessAllowed(user.getUserName(), project)) { IPath projectPath = GitUtils.pathFromProject(workspace, project); Map<IPath, File> gitDirs = GitUtils.getGitDirs(projectPath, Traverse.GO_DOWN); for (Map.Entry<IPath, File> entry : gitDirs.entrySet()) { JSONObject repo = listEntry(entry.getKey().lastSegment(), 0, true, 0, baseLocation, entry.getKey().toPortableString()); children.put(repo); } } } JSONObject result = listEntry(workspace.getFullName(), 0, true, 0, baseLocation, workspace.getUniqueId()); //$NON-NLS-1$ result.put(ProtocolConstants.KEY_ID, workspace.getUniqueId()); result.put(ProtocolConstants.KEY_CHILDREN, children); OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT); return true; } } catch (Exception e) { return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occurred while obtaining workspace data.", e)); } return true; } return super.handleRequest(request, response, pathString); }
Example 8
Source File: TestVMType.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { // for now use the same stub JAR for all IPath path = Path.fromOSString(new File(installLocation, RTSTUBS_JAR).getAbsolutePath()); return new LibraryLocation[] { new LibraryLocation(path, Path.EMPTY, Path.EMPTY) }; }
Example 9
Source File: RemoteGenerateManifestOperation.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Scan traceFolder for files that match the patterns specified in the * template file. When there is a match, the trace package element is used * to determine the trace name and trace type. * * @param traceGroup * The parent trace group element * @param parentElement * The immediate parent trace group or folder element * @param traceFolder * The folder to scan * @param recursionLevel * The recursion level (needed to find directory traces under the traceFolder * @param monitor * The progress monitor * @throws CoreException * Thrown by the file system implementation * @throws InterruptedException * Thrown if operation was cancelled */ private void generateElementsFromArchive( final RemoteImportTraceGroupElement traceGroup, final TracePackageElement parentElement, final IFileStore traceFolder, final int recursionLevel, IProgressMonitor monitor) throws CoreException, InterruptedException { int localRecursionLevel = recursionLevel + 1; IFileStore[] sources = traceFolder.childStores(EFS.NONE, monitor); for (int i = 0; i < sources.length; i++) { ModalContext.checkCanceled(monitor); SubMonitor subMonitor = SubMonitor.convert(monitor, sources.length); IFileStore fileStore = sources[i]; IPath fullArchivePath = TmfTraceCoreUtils.newSafePath(fileStore.toURI().getPath()); IFileInfo sourceInfo = fileStore.fetchInfo(); if (!sourceInfo.isDirectory()) { String rootPathString = traceGroup.getRootImportPath(); IPath rootPath = TmfTraceCoreUtils.newSafePath(rootPathString); IPath relativeTracePath = Path.EMPTY; if (rootPath.isPrefixOf(fullArchivePath)) { relativeTracePath = fullArchivePath.makeRelativeTo(rootPath); } Entry<Pattern, TracePackageTraceElement> matchingTemplateEntry = getMatchingTemplateElement(relativeTracePath); if (matchingTemplateEntry != null) { TracePackageTraceElement matchingTemplateElement = matchingTemplateEntry.getValue(); String traceType = matchingTemplateElement.getTraceType(); // If a single file is part of a directory trace, use the parent directory instead TracePackageElement parent = parentElement; if (matchesDirectoryTrace(relativeTracePath, matchingTemplateEntry)) { fullArchivePath = fullArchivePath.removeLastSegments(1); fDirectoryTraces.add(fullArchivePath); fileStore = fileStore.getParent(); sourceInfo = fileStore.fetchInfo(); parent = parentElement.getParent(); // Let the auto-detection choose the best trace type traceType = null; } else if ((localRecursionLevel > 1) && (!traceGroup.isRecursive())) { // Don't consider file traces on level 2 if it's not recursive continue; } if (sourceInfo.getLength() > 0 || sourceInfo.isDirectory()) { // Only add non-empty files String traceName = fullArchivePath.lastSegment(); String fileName = fileStore.getName(); // create new elements to decouple from input elements TracePackageTraceElement traceElement = new TracePackageTraceElement(parent, traceName, traceType); RemoteImportTraceFilesElement tracePackageFilesElement = new RemoteImportTraceFilesElement(traceElement, fileName, fileStore); tracePackageFilesElement.setVisible(false); } } } else { if (traceGroup.isRecursive() || localRecursionLevel < 2) { RemoteImportFolderElement folder = new RemoteImportFolderElement(parentElement, fileStore.getName()); generateElementsFromArchive(traceGroup, folder, fileStore, localRecursionLevel, subMonitor); } } } }
Example 10
Source File: WorkspaceConversionItemDialog.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public IConversionItem getConversionItem() { if (conversionItem == null) { conversionItem = new DefaultConversionItem(Path.EMPTY); } return conversionItem; }
Example 11
Source File: WorkspaceConversionItemDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public IConversionItem getConversionItem() { if (conversionItem == null) { conversionItem = new DefaultConversionItem(Path.EMPTY); } return conversionItem; }
Example 12
Source File: WizardSaveAsPage.java From birt with Eclipse Public License 1.0 | 4 votes |
public IPath getResult( ) { IPath path = support.getFileLocationFullPath( ) .append( support.getFileName( ) ); // If the user does not supply a file extension and if the save // as dialog was provided a default file name append the extension // of the default filename to the new name if ( ReportPlugin.getDefault( ) .isReportDesignFile( support.getInitialFileName( ) ) && !ReportPlugin.getDefault( ) .isReportDesignFile( path.toOSString( ) ) ) { String[] parts = support.getInitialFileName( ).split( "\\." ); //$NON-NLS-1$ path = path.addFileExtension( parts[parts.length - 1] ); } else if ( support.getInitialFileName( ) .endsWith( IReportEditorContants.TEMPLATE_FILE_EXTENTION ) && !path.toOSString( ) .endsWith( IReportEditorContants.TEMPLATE_FILE_EXTENTION ) ) { path = path.addFileExtension( "rpttemplate" ); //$NON-NLS-1$ } // If the path already exists then confirm overwrite. File file = path.toFile( ); if ( file.exists( ) ) { String[] buttons = new String[]{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = Messages.getFormattedString( "SaveAsDialog.overwriteQuestion", //$NON-NLS-1$ new Object[]{ path.toOSString( ) } ); MessageDialog d = new MessageDialog( getShell( ), Messages.getString( "SaveAsDialog.Question" ), //$NON-NLS-1$ null, question, MessageDialog.QUESTION, buttons, 0 ); int overwrite = d.open( ); switch ( overwrite ) { case 0 : // Yes break; case 1 : // No return null; case 2 : // Cancel default : return Path.EMPTY; } } return path; }
Example 13
Source File: WizardSaveAsPage.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Get the saving path * * @return the saving path */ public IPath getResult( ) { IPath path = resourceGroup.getContainerFullPath( ) .append( resourceGroup.getResource( ) ); // If the user does not supply a file extension and if the save // as dialog was provided a default file name append the extension // of the default filename to the new name if ( path.getFileExtension( ) == null ) { if ( originalFile != null && originalFile.getFileExtension( ) != null ) path = path.addFileExtension( originalFile.getFileExtension( ) ); else if ( originalName != null ) { int pos = originalName.lastIndexOf( '.' ); if ( ++pos > 0 && pos < originalName.length( ) ) path = path.addFileExtension( originalName.substring( pos ) ); } } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin.getWorkspace( ).getRoot( ).getFile( path ); if ( file.exists( ) ) { String[] buttons = new String[]{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = Messages.getFormattedString( "WizardSaveAsPage.OverwriteQuestion", //$NON-NLS-1$ new Object[]{ path.toOSString( ) } ); MessageDialog d = new MessageDialog( getShell( ), Messages.getString( "WizardSaveAsPage.Question" ), //$NON-NLS-1$ null, question, MessageDialog.QUESTION, buttons, 0 ); int overwrite = d.open( ); switch ( overwrite ) { case 0 : // Yes break; case 1 : // No return null; case 2 : // Cancel default : return Path.EMPTY; } } return path; }