Java Code Examples for org.eclipse.core.filebuffers.ITextFileBuffer#isDirty()

The following examples show how to use org.eclipse.core.filebuffers.ITextFileBuffer#isDirty() . 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: JavaDeleteProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void checkDirtyFile(RefactoringStatus result, IFile file) {
	if (file == null || !file.exists())
		return;
	ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
	if (buffer != null && buffer.isDirty()) {
		if (buffer.isStateValidated() && buffer.isSynchronized()) {
			result.addWarning(Messages.format(
				RefactoringCoreMessages.JavaDeleteProcessor_unsaved_changes,
				BasicElementLabels.getPathLabel(file.getFullPath(), false)));
		} else {
			result.addFatalError(Messages.format(
				RefactoringCoreMessages.JavaDeleteProcessor_unsaved_changes,
				BasicElementLabels.getPathLabel(file.getFullPath(), false)));
		}
	}
}
 
Example 2
Source File: AbstractDeleteChange.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
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();
}
 
Example 3
Source File: AbstractDeleteChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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();
}
 
Example 4
Source File: OpenTypeHistory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean isContainerDirty(TypeNameMatch match) {
	ICompilationUnit cu= match.getType().getCompilationUnit();
	if (cu == null) {
		return false;
	}
	IResource resource= cu.getResource();
	ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
	ITextFileBuffer textFileBuffer= manager.getTextFileBuffer(resource.getFullPath(), LocationKind.IFILE);
	if (textFileBuffer != null) {
		return textFileBuffer.isDirty();
	}
	return false;
}