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

The following examples show how to use org.eclipse.core.filebuffers.ITextFileBuffer#isSynchronized() . 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: ContentTypeHelper.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the content of the given buffer.
 * 
 * @param buffer
 * @return the content of the given buffer.
 * @throws CoreException
 */
private static InputStream getContents(ITextFileBuffer buffer) throws CoreException {
	IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IFile file = workspaceRoot.getFile(buffer.getLocation());
	if (file.exists() && buffer.isSynchronized()) {
		return file.getContents();
	}
	return buffer.getFileStore().openInputStream(EFS.NONE, null);
}
 
Example 3
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 4
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();
}