protected static void saveFileIfNeeded(IFile file, IProgressMonitor pm) throws CoreException { ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager() .getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); if (buffer != null && buffer.isDirty() && buffer.isStateValidated() && buffer.isSynchronized()) { pm.beginTask("", 2); // $NON-NLS-1$ buffer.commit(new SubProgressMonitor(pm, 1), false); file.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(pm, 1)); } pm.done(); }
private void checkDirtyFile(RefactoringStatus result, IFile file) { if (!file.exists()) return; ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager() .getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); if (buffer != null && buffer.isDirty()) { String message = RefactoringCoreMessages.DeleteResourcesProcessor_warning_unsaved_file; if (buffer.isStateValidated() && buffer.isSynchronized()) { result.addWarning( Messages.format(message, BasicElementLabels.getPathLabel(file.getFullPath(), false))); } else { result.addFatalError( Messages.format(message, BasicElementLabels.getPathLabel(file.getFullPath(), false))); } } }