Java Code Examples for org.eclipse.core.runtime.Path#segmentCount()
The following examples show how to use
org.eclipse.core.runtime.Path#segmentCount() .
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: NodeJSDeploymentPlanner.java From orion.server with Eclipse Public License 1.0 | 6 votes |
protected String getApplicationName(IFileStore contentLocation) throws UnsupportedEncodingException { IFileStore rootStore = OrionConfiguration.getRootLocation(); Path relativePath = new Path(URLDecoder.decode(contentLocation.toURI().toString(), "UTF8").substring(rootStore.toURI().toString().length())); if (relativePath.segmentCount() < 4) { // not a change to a file in a project return null; } String projectDirectory = relativePath.segment(3); projectDirectory = projectDirectory.replaceFirst(" \\| ", " --- "); String[] folderNameParts = projectDirectory.split(" --- ", 2); if (folderNameParts.length > 1) return folderNameParts[1]; return folderNameParts[0]; }
Example 2
Source File: GenericDeploymentPlanner.java From orion.server with Eclipse Public License 1.0 | 6 votes |
protected String getApplicationName(IFileStore contentLocation) throws UnsupportedEncodingException { IFileStore rootStore = OrionConfiguration.getRootLocation(); Path relativePath = new Path(URLDecoder.decode(contentLocation.toURI().toString(), "UTF8").substring(rootStore.toURI().toString().length())); if (relativePath.segmentCount() < 4) { // not a change to a file in a project return null; } String projectDirectory = relativePath.segment(3); projectDirectory = projectDirectory.replaceFirst(" \\| ", " --- "); String[] folderNameParts = projectDirectory.split(" --- ", 2); if (folderNameParts.length > 1) return folderNameParts[1]; return folderNameParts[0]; }
Example 3
Source File: SerializableClasspathEntry.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private IPath restoreSourcePath(IPath baseDirectory, IPath sourceBaseDirectory) { Path path = new Path(sourceAttachmentPath); if (path.segmentCount() == 0) { return path; } switch (path.segment(0)) { case SOURCE_REPO_RELATIVE_PREFIX: return PathUtil.makePathAbsolute(path.removeFirstSegments(1), sourceBaseDirectory); case BINARY_REPO_RELATIVE_PREFIX: return PathUtil.makePathAbsolute(path.removeFirstSegments(1), baseDirectory); default: // Unknown prefix, use path only if valid if (path.toFile().exists()) { return path; } else { return null; } } }
Example 4
Source File: NodeJSDeploymentPlanner.java From orion.server with Eclipse Public License 1.0 | 5 votes |
protected String getApplicationHost(IFileStore contentLocation) throws UnsupportedEncodingException { IFileStore rootStore = OrionConfiguration.getRootLocation(); Path relativePath = new Path(URLDecoder.decode(contentLocation.toURI().toString(), "UTF8").substring(rootStore.toURI().toString().length())); if (relativePath.segmentCount() < 4) { // not a change to a file in a project return null; } String folderName = relativePath.segment(3); folderName = folderName.replaceFirst(" \\| ", " --- "); return ManifestUtils.slugify(folderName); }
Example 5
Source File: GenericDeploymentPlanner.java From orion.server with Eclipse Public License 1.0 | 5 votes |
protected String getApplicationHost(IFileStore contentLocation) throws UnsupportedEncodingException { IFileStore rootStore = OrionConfiguration.getRootLocation(); Path relativePath = new Path(URLDecoder.decode(contentLocation.toURI().toString(), "UTF8").substring(rootStore.toURI().toString().length())); if (relativePath.segmentCount() < 4) { // not a change to a file in a project return null; } String folderName = relativePath.segment(3); folderName = folderName.replaceFirst(" \\| ", " --- "); return ManifestUtils.slugify(folderName); }
Example 6
Source File: DirectoryHandlerV1.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private boolean handleDelete(HttpServletRequest request, HttpServletResponse response, IFileStore dir) throws JSONException, CoreException, ServletException, IOException { Path path = new Path(request.getPathInfo()); dir.delete(EFS.NONE, null); if (path.segmentCount() == 2) { // The folder is a project, remove the metadata OrionConfiguration.getMetaStore().deleteProject(path.segment(0), path.segment(1)); } else if (path.segmentCount() == 1) { // The folder is a workspace, remove the metadata String workspaceId = path.segment(0); OrionConfiguration.getMetaStore().deleteWorkspace(request.getRemoteUser(), workspaceId); } return true; }
Example 7
Source File: WizardFolderImportPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user * whether the existing resource at the given path should be overwritten. * * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or * <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
Example 8
Source File: BuildPathsBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Validates output location & build path. */ private void updateOutputLocationStatus() { fOutputLocationPath= null; String text= fBuildPathDialogField.getText(); if ("".equals(text)) { //$NON-NLS-1$ fOutputFolderStatus.setError(NewWizardMessages.BuildPathsBlock_error_EnterBuildPath); return; } IPath path= getOutputLocation(); fOutputLocationPath= path; IResource res= fWorkspaceRoot.findMember(path); if (res != null) { // if exists, must be a folder or project if (res.getType() == IResource.FILE) { fOutputFolderStatus.setError(NewWizardMessages.BuildPathsBlock_error_InvalidBuildPath); return; } } fOutputFolderStatus.setOK(); String pathStr= fBuildPathDialogField.getText(); Path outputPath= (new Path(pathStr)); pathStr= outputPath.lastSegment(); if (pathStr.equals(".settings") && outputPath.segmentCount() == 2) { //$NON-NLS-1$ fOutputFolderStatus.setWarning(NewWizardMessages.OutputLocation_SettingsAsLocation); } if (pathStr.charAt(0) == '.' && pathStr.length() > 1) { fOutputFolderStatus.setWarning(Messages.format(NewWizardMessages.OutputLocation_DotAsLocation, BasicElementLabels.getResourceName(pathStr))); } updateBuildPathStatus(); }
Example 9
Source File: ImportProjectWizardPage.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind( IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS .bind( IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1) .toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer() .getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog .getReturnCode()]; }
Example 10
Source File: ImportProjectWizardPage.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind( IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS .bind( IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1) .toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer() .getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog .getReturnCode()]; }