final boolean isEnabled(IFile file) { if (file == null || ! file.exists()) return false; if (fModifiesFile) { // without validate/edit we would do this: // return !file.isReadOnly(); // with validate/edit we have to return true return true; } return true; }
protected IMarker[] findTraceMarkers(IFile file) throws CoreException { if (!file.exists()) return new IMarker[0]; IMarker[] markers = file.findMarkers(MARKER_ID, false, IResource.DEPTH_ONE); return markers; }
/** * Checks if is file in workspace. * * @param aFileRelPath the a file rel path * @return true, if is file in workspace */ public boolean isFileInWorkspace(String aFileRelPath) { Object fileOrIFile = getIFileOrFile(aFileRelPath); return (fileOrIFile instanceof IFile && ((IFile) fileOrIFile).exists()); }
/** * @param path full absolute workspace path */ private static boolean isInternalFilePath(IPath path) { IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); // in case this is full workspace path it should start with project segment if(path.segmentCount() > 1 && wsRoot.getFile(path).exists()) { return true; } return false; }
public void load() throws CoreException { if (fFile.exists()) { InputStream stream = null; try { stream = new BufferedInputStream(fFile.getContents(true)); load(stream, false); } catch (CoreException e) { } } }
@Override protected IFile[] getChangedFiles() throws CoreException { IFile projectFile= fProject.getProject().getFile(".project"); //$NON-NLS-1$ if (projectFile != null && projectFile.exists()) { return new IFile[] {projectFile}; } return new IFile[0]; }
protected void validateEdit(IFile aFile) { if (overwriteHandler == null) return; if (!(aFile.exists() && aFile.isReadOnly())) return; overwriteHandler.validateEdit(aFile); }
protected IFile[] getChangedFiles() throws CoreException { IFile projectFile= fProject.getProject().getFile(".project"); //$NON-NLS-1$ if (projectFile != null && projectFile.exists()) { return new IFile[] {projectFile}; } return new IFile[0]; }
/** * Default implementation of {@link #getDocumentKey(Object)} that returns a * {@link FileEditorInput} for the element if the element adapts to {@link IFile}. * @see org.eclipse.compare.ISharedDocumentAdapter#getDocumentKey(java.lang.Object) */ public IEditorInput getDocumentKey(Object element) { IFile file = getFile(element); if (file != null && file.exists()) { return new FileEditorInput(file); } return null; }
protected void ensureParentExists(IFile file) throws CoreException { if (!file.exists()) { ensureExists(file.getParent()); } }
@Override protected void addChange(CompositeChange result, IFile file, IProgressMonitor pm) throws CoreException { if (file.exists()) { Change change = PluginManifestChange.createRenameChange(file, fElements.keySet().toArray(), getNewNames(), getTextChange(file), pm); if (change != null) result.add(change); } }
protected void addBuildPropertiesChange(CompositeChange result, IProgressMonitor pm) throws CoreException { IFile file = PDEProject.getBuildProperties(fProject); if (file.exists()) { Change change = BuildPropertiesChange.createRenameChange(file, fElements.keySet().toArray(), getNewNames(), pm); if (change != null) result.add(change); } }
public WorkspaceTranslationFile(IFile file) { super(Language.parse(file.getName())); Validate.notNull(file); Validate.isTrue(file.exists()); m_file = file; m_translationFileChangedListener = new P_TranslationFileChangedListener(); ResourcesPlugin.getWorkspace().addResourceChangeListener(new WeakResourceChangeListener(m_translationFileChangedListener), IResourceChangeEvent.POST_CHANGE); reload(new NullProgressMonitor()); }
@Override public Object getModifiedElement() { IFile file = PDEProject.getManifest(getProject()); if (file.exists()) return file; return super.getModifiedElement(); }
@Override public boolean acceptFile(IFile file) throws CoreException { if (fIsLightweightAutoRefresh && !file.exists()) return false; if (fIsFileSearchOnly) { synchronized (fLock) { fResult.addMatch(new FileMatch(file)); } } flushMatches(); return true; }
private void copyFile(String fileName, InputStream input, IContainer dst, boolean binary, IProgressMonitor monitor) throws CoreException { monitor.subTask(fileName); IFile dstFile = dst.getFile(new Path(fileName)); try (InputStream stream = getProcessedStream(fileName, input, binary)) { if (dstFile.exists()) { dstFile.setContents(stream, true, true, monitor); } else { dstFile.create(stream, true, monitor); } } catch (IOException e) { } }
private void validateBuildProperties(IProgressMonitor monitor) { if (monitor.isCanceled()) return; IProject project = getProject(); IFile file = PDEProject.getBuildProperties(project); if (file.exists()) { monitor.subTask(PDECoreMessages.ManifestConsistencyChecker_buildPropertiesSubtask); BuildErrorReporter ber = new BuildErrorReporter(file); ber.validateContent(monitor); } }
@Override public boolean canConfigure(IProject project, Set<IPath> ignoredDirectories, IProgressMonitor monitor) { IFile manifestFile = PDEProject.getManifest(project); if (manifestFile != null && manifestFile.exists()) { for (IPath ignoredDirectory : ignoredDirectories) { if (ignoredDirectory.isPrefixOf(manifestFile.getLocation())) { return false; } } } return hasOSGiManifest(project); }
private static IResource tryFindWorkspaceFile(InternalGradleBuild gradleBuild, Path filePath) { for (IProject project : getWorkspaceProjectsFor(gradleBuild)) { IPath projectLocation = project.getLocation(); if (projectLocation.isPrefixOf(filePath)) { IFile file = project.getFile(filePath.makeRelativeTo(projectLocation)); if (file.exists()) { return file; } } } return null; }
@Override public Object getModifiedElement() { IFile[] files = new IFile[] {PDEProject.getManifest(getProject()), PDEProject.getPluginXml(getProject())}; for (IFile file : files) { if (file.exists()) return file; } return super.getModifiedElement(); }