public static boolean isApplicable(IApiBaseline profile) { String loc = profile.getLocation(); return loc != null && new Path(loc).toFile().exists(); }
protected IFile getIFile(String filePath) { if (filePath == null) { return null; } IFile file = fFileNameToIFile.get(filePath); if (file == null) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new Path(filePath).toFile().toURI()); if (files.length > 0) { file = files[0]; fFileNameToIFile.put(filePath, file); } } return file; }
private boolean isProjectFile(Path path) { if (path == null || path.isEmpty()) { return false; } else if (!path.lastSegment().matches("(.*\\.csproj|project.json)")) { //$NON-NLS-1$ return false; } else if (!path.toFile().isFile()) { return false; } return true; }
private boolean isProjectFile(Path path) { if (path == null || path.isEmpty()) { return false; } else if (!path.lastSegment().matches("(.*\\.csproj|project.json)")) { //$NON-NLS-1$ return false; } else if (!path.toFile().isFile()) { return false; } return true; }
private void setLocationIfDefault() { if (!isExportLocDefault) { return; } String locationString = ""; //$NON-NLS-1$ if (isProjectFile(projectPath)) { locationString = projectPath.toFile().getParent().toString() + "/bin/" + configuration + "/" //$NON-NLS-1$ //$NON-NLS-2$ + getTargetFramework() + "/"; //$NON-NLS-1$ if (isSCD) { locationString += runtime + "/"; //$NON-NLS-1$ } } exportLocation = new File(locationString); exportLocationText.setText(locationString); }
protected File getAgentFile() throws CoreException { try { final URL agentfileurl = FileLocator.toFileURL(AgentJar.getResource()); return new Path(agentfileurl.getPath()).toFile(); } catch (IOException e) { throw new CoreException( EclEmmaStatus.NO_LOCAL_AGENTJAR_ERROR.getStatus(e)); } }
public static URL[] getFeaturePaths(String platformHome) { File file = new File(platformHome, "configuration/org.eclipse.update/platform.xml"); //$NON-NLS-1$ if (file.exists()) { try { String value = new Path(platformHome).toFile().toURL().toExternalForm(); System.setProperty(URL_PROPERTY, value); try { IPlatformConfiguration config = ConfiguratorUtils.getPlatformConfiguration(file.toURL()); return getConfiguredSitesPaths(platformHome, config, true); } finally { System.setProperty(URL_PROPERTY, EMPTY_STRING); } } catch (MalformedURLException e) { } catch (IOException e) { } } return scanLocations(getSites(platformHome, true)); }
public String[] recognizeJars(String path) { clearFiles(); if (path != null) { File file = (new Path(path)).toFile(); addJarsRecursive(file); } return getFiles(); }
/** * Get the file store for the local file system path. * * @param string * @return IFileStore or <code>null</code> if there is a * {@link CoreException}. */ public static IFileStore getFileStore(String string) { Path location = new Path(string); //see if there is an existing resource at that location that might have a different file store IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(location); if (file != null) { return getFileStore(file.getLocationURI()); } return getFileStore(location.toFile().toURI()); }
/** * Returns a list of file URLs for plug-ins or features found in a platform.xml file or in the default * directory ("plugins"/"features") if no platform.xml is available. * * @param platformHome base location for the installation, used to search for platform.xml * @param findFeatures if <code>true</code> will return paths to features, otherwise will return paths to plug-ins. * @return a list of URL paths to plug-ins or features. Possibly empty if the platform.xml had no entries or the default directory had no valid files */ public static URL[] getPlatformXMLPaths(String platformHome, boolean findFeatures) { File file = getPlatformFile(platformHome); if (file != null) { try { String value = new Path(platformHome).toFile().toURL().toExternalForm(); System.setProperty(URL_PROPERTY, value); try { IPlatformConfiguration config = ConfiguratorUtils.getPlatformConfiguration(file.toURL()); return getConfiguredSitesPaths(platformHome, config, findFeatures); } finally { System.setProperty(URL_PROPERTY, EMPTY_STRING); } } catch (MalformedURLException e) { } catch (IOException e) { } } return scanLocations(getSites(platformHome, findFeatures)); }
private void searchForTestMethods() { if (!pathText.getText().equals(loadedTestsParentProject) || testMethods == null) { loadedTestsParentProject = pathText.getText(); testMethods = null; Job.create(Messages.DotnetTestTab_retrieveClasses, (ICoreRunnable) monitor -> { testMethods = DotnetTestAccessor.getTestMethods(projectPath.toFile()); Display.getDefault().asyncExec(() -> { displayMethodSelectorDialog(); }); }).schedule(); } else { displayMethodSelectorDialog(); } }
private void searchForTestClass() { if (!pathText.getText().equals(loadedTestsParentProject) || testMethods == null) { loadedTestsParentProject = pathText.getText(); testMethods = null; Job.create(Messages.DotnetTestTab_retrieveClasses, (ICoreRunnable) monitor -> { testMethods = DotnetTestAccessor.getTestMethods(projectPath.toFile()); Display.getDefault().asyncExec(() -> { displayClassSelectorDialog(); }); }).schedule(); } else { displayClassSelectorDialog(); } }
private IStatus validatePath() { StatusInfo status= new StatusInfo(); String val= fPathField.getText(); if (val.length() == 0) { return status; } Path path= new Path(val); if (path.isAbsolute()) { if (!path.toFile().isDirectory()) { status.setWarning(NewWizardMessages.NativeLibrariesDialog_error_external_not_existing); return status; } } else { if (!(ResourcesPlugin.getWorkspace().getRoot().findMember(path) instanceof IContainer)) { status.setWarning(NewWizardMessages.NativeLibrariesDialog_error_internal_not_existing); return status; } } return status; }
private IStatus validatePath() { StatusInfo status= new StatusInfo(); String val= fPathField.getText(); if (val.length() == 0) { return status; } Path path= new Path(val); if (path.isAbsolute()) { if (!path.toFile().isDirectory()) { status.setWarning(NewWizardMessages.NativeLibrariesDialog_error_external_not_existing); return status; } } else { if (!(ResourcesPlugin.getWorkspace().getRoot().findMember(path) instanceof IContainer)) { status.setWarning(NewWizardMessages.NativeLibrariesDialog_error_internal_not_existing); return status; } } return status; }
public static URL[] getPluginPaths(String platformHome) { if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation())) && !isDevLaunchMode()) return ConfiguratorUtils.getCurrentPlatformConfiguration().getPluginPath(); File file = new File(platformHome, "configuration/org.eclipse.update/platform.xml"); //$NON-NLS-1$ if (file.exists()) { try { String value = new Path(platformHome).toFile().toURL().toExternalForm(); System.setProperty(URL_PROPERTY, value); try { IPlatformConfiguration config = ConfiguratorUtils.getPlatformConfiguration(file.toURL()); return getConfiguredSitesPaths(platformHome, config, false); } finally { System.setProperty(URL_PROPERTY, EMPTY_STRING); } } catch (MalformedURLException e) { } catch (IOException e) { } } return scanLocations(getSites(platformHome, false)); }
public void setInput(IEditorInput input) { fInput = input; fTargetFileInWorkspace = null; fTarget = null; File targetFile = null; if (input instanceof IFileEditorInput) { fTargetFileInWorkspace = ((IFileEditorInput) input).getFile(); targetFile = fTargetFileInWorkspace.getLocation().toFile(); } else if (input instanceof IURIEditorInput) { String part = ((IURIEditorInput) input).getURI().getSchemeSpecificPart(); Path path = new Path(part); fTargetFileInWorkspace = ResourcesPlugin.getWorkspace().getRoot().getFile(path); targetFile = path.toFile(); } //If the file is not available or invalid, close the target editor if (fTargetFileInWorkspace == null || targetFile == null || !targetFile.exists()) { TargetEditor.this.close(false); } PDEPlugin.getWorkspace().addResourceChangeListener(this); }
private IStatus validatePath() { StatusInfo status= new StatusInfo(); String val= fPathField.getText(); if (val.length() == 0) { return status; } Path path= new Path(val); if (path.isAbsolute()) { if (!path.toFile().isDirectory()) { status.setWarning(NewWizardMessages.NativeLibrariesDialog_error_external_not_existing); return status; } } else { if (!(ResourcesPlugin.getWorkspace().getRoot().findMember(path) instanceof IContainer)) { status.setWarning(NewWizardMessages.NativeLibrariesDialog_error_internal_not_existing); return status; } } return status; }
public boolean addJdkJarToClasspathEntries(String jdkJarFullPathName) { IJavaProject javaProject = getJavaProject(); if (javaProject == null) return false; IClasspathEntry[] entry = new IClasspathEntry[1]; Path path = new Path(jdkJarFullPathName); if (!path.toFile().exists()) { org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(J2EECreationResourceHandler.getString(J2EECreationResourceHandler.JdkJarFileDoesNotExist_UI, new Object[]{jdkJarFullPathName})); return false; } entry[0] = JavaCore.newLibraryEntry(path, null, null); addToClasspathEntries(entry); return true; }
private void handleExport() { FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE); dialog.setFilterExtensions(new String[] { "*.log" }); //$NON-NLS-1$ if (fDirectory != null) dialog.setFilterPath(fDirectory); String path = dialog.open(); if (path != null) { if (path.indexOf('.') == -1 && !path.endsWith(".log")) //$NON-NLS-1$ path += ".log"; //$NON-NLS-1$ File outputFile = new Path(path).toFile(); fDirectory = outputFile.getParent(); if (outputFile.exists()) { String message = NLS.bind(PDERuntimeMessages.LogView_confirmOverwrite_message, outputFile.toString()); if (!MessageDialog.openQuestion(getViewSite().getShell(), PDERuntimeMessages.LogView_exportLog, message)) return; } copy(fInputFile, outputFile); } }
/** * Import log from file selected in FileDialog. */ void handleImport() { FileDialog dialog = new FileDialog(getViewSite().getShell()); dialog.setFilterExtensions(new String[] {"*.log"}); //$NON-NLS-1$ if (fDirectory != null) dialog.setFilterPath(fDirectory); String path = dialog.open(); if (path == null) { // cancel return; } File file = new Path(path).toFile(); if (file.exists()) { handleImportPath(path); } else { String msg = NLS.bind(Messages.LogView_FileCouldNotBeFound, file.getName()); MessageDialog.openError(getViewSite().getShell(), Messages.LogView_OpenFile, msg); } }