public IPath getStateLocation(Bundle bundle, boolean create) throws IllegalStateException { assertInitialized(); IPath result = getMetaArea().getStateLocation(bundle); if (create) result.toFile().mkdirs(); return result; }
if (!path.toFile().exists()) { String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString()); throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, null)); InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(path.toFile())); service.importPreferences(input); } catch (FileNotFoundException e) {
File file = path.toFile(); if (file.exists()) file.delete();
/** * Private constructor to enforce singleton usage. */ private PerformanceStatsProcessor() { super("Performance Stats"); //$NON-NLS-1$ setSystem(true); setPriority(DECORATE); BundleContext context = PlatformActivator.getContext(); String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')'; Collection<ServiceReference<FrameworkLog>> references; FrameworkLog perfLog = null; try { references = context.getServiceReferences(FrameworkLog.class, filter); if (references != null && !references.isEmpty()) { //just take the first matching service perfLog = context.getService(references.iterator().next()); //make sure correct location is set IPath logLocation = Platform.getLogFileLocation(); logLocation = logLocation.removeLastSegments(1).append("performance.log"); //$NON-NLS-1$ perfLog.setFile(logLocation.toFile(), false); } } catch (Exception e) { IStatus error = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, "Error loading performance log", e); //$NON-NLS-1$ InternalPlatform.getDefault().log(error); } //use the platform log if we couldn't create the performance log if (perfLog == null) perfLog = InternalPlatform.getDefault().getFrameworkLog(); log = perfLog; }
public static String getWorkspaceInvisibleProjectName(IPath workspacePath) { String fileName = workspacePath.toFile().getName(); String projectName = fileName + "_" + Integer.toHexString(workspacePath.toPortableString().hashCode()); return projectName; }
/** * Reads and returns a project description stored at the given location */ public ProjectDescription read(IPath location) throws IOException { try ( BufferedInputStream file = new BufferedInputStream(new FileInputStream(location.toFile())); ) { return read(new InputSource(file)); } }
private void verifyNoWorkspaceRootIsImported(File rootDir, IProgressMonitor monitor) { File workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(); if (rootDir.equals(workspaceRoot)) { throw new UnsupportedConfigurationException(String.format("Project %s location matches workspace root %s", rootDir.getName(), workspaceRoot.getAbsolutePath())); } }
protected void createDriver ( final IFolder nodeDir, final IProgressMonitor monitor, final File packageFolder, final Map<String, String> replacements, final String driverName ) throws IOException, Exception { final File sourceDir = new File ( nodeDir.getLocation ().toFile (), driverName ); replacements.put ( "driverName", driverName ); processDriver ( monitor, packageFolder, replacements, driverName, sourceDir ); replacements.remove ( "driverName" ); }
/** * Creates the meta area root directory. */ public synchronized void createMetaArea() throws CoreException { java.io.File workspaceLocation = metaAreaLocation.toFile(); Workspace.clear(workspaceLocation); if (!workspaceLocation.mkdirs()) { String message = NLS.bind(Messages.resources_writeWorkspaceMeta, workspaceLocation); throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, null, message, null); } }
public IPath getPreferenceLocation(String bundleName, boolean create) throws IllegalStateException { IPath result = getStateLocation(bundleName); if (create) result.toFile().mkdirs(); return result.append(PREFERENCES_FILE_NAME); }
public IPath getPreferenceLocation(String bundleName, boolean create) throws IllegalStateException { IPath result = getStateLocation(bundleName); if (create) result.toFile().mkdirs(); return result.append(PREFERENCES_FILE_NAME); }
/** * Returns a File that corresponds to the absolute location of the project's * root directory. */ public File workingDirectory() { return project.getProject().getLocation().toFile(); }
public DefaultBuildConfigurationProperties readBuildConfiguratonProperties(IProject project) { Preconditions.checkNotNull(project); PreferenceStore preferences = PreferenceStore.forProjectScope(project, PREF_NODE); return readPreferences(preferences, project.getLocation().toFile()); }
public IPath getStateLocation(Bundle bundle, boolean create) throws IllegalStateException { assertInitialized(); IPath result = getMetaArea().getStateLocation(bundle); if (create) result.toFile().mkdirs(); return result; }
/** * Returns the File to use for saving and restoring the last built state for the given project. */ private File getSerializationFile(IProject project) { if (!project.exists()) return null; IPath workingLocation = project.getWorkingLocation(JavaCore.PLUGIN_ID); return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$ }
static File getSerializationFile(IProject project) { if (!project.exists()) { return null; } IPath workingLocation = project.getWorkingLocation(API_TOOL_PLUGIN_ID); return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$ }
private String getPackageName(IPath javaFile) { IProject project = JavaLanguageServerPlugin.getProjectsManager().getDefaultProject(); if (project == null || !project.isAccessible()) { return ""; } IJavaProject javaProject = JavaCore.create(project); return JDTUtils.getPackageName(javaProject, javaFile.toFile().toURI()); }
@Override public void deleteProjectConfiguration(IProject project) { if (project.isAccessible()) { this.buildConfigurationPersistence.deletePathToRoot(project); } else { this.buildConfigurationPersistence.deletePathToRoot(project.getLocation().toFile()); } }
private static void convertCUResourceChange(WorkspaceEdit edit, RenameCompilationUnitChange cuChange) { ICompilationUnit modifiedCU = (ICompilationUnit) cuChange.getModifiedElement(); RenameFile rf = new RenameFile(); String newCUName = cuChange.getNewName(); IPath currentPath = modifiedCU.getResource().getLocation(); rf.setOldUri(ResourceUtils.fixURI(modifiedCU.getResource().getRawLocationURI())); IPath newPath = currentPath.removeLastSegments(1).append(newCUName); rf.setNewUri(ResourceUtils.fixURI(newPath.toFile().toURI())); edit.getDocumentChanges().add(Either.forRight(rf)); }
/** * Stores the widget values in the JAR package. */ @Override protected void updateModel() { super.updateModel(); String comboText= fAntScriptNamesCombo.getText(); IPath path= Path.fromOSString(comboText); if (path.segmentCount() > 0 && ensureAntScriptFileIsValid(path.toFile()) && path.getFileExtension() == null) path= path.addFileExtension(ANTSCRIPT_EXTENSION); fAntScriptLocation= getAbsoluteLocation(path); }