use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test15.
/*
* Test IFileBufferListener#underlyingFileMoved
*/
@Test
public void test15() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
public IPath newLocation;
@Override
public void underlyingFileMoved(IFileBuffer buf, IPath location) {
++count;
this.buffer = buf;
this.newLocation = location;
}
}
Listener listener = new Listener();
fManager.addFileBufferListener(listener);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
assertTrue(listener.count == 0 && listener.buffer == null);
fManager.connectFileStore(fFileStore, null);
try {
fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
IPath newLocation = moveUnderlyingFile();
if (newLocation != null) {
assertTrue(listener.count == 1);
assertTrue(listener.buffer == fileBuffer);
assertEquals(listener.newLocation, newLocation);
}
} finally {
fManager.disconnectFileStore(fFileStore, null);
}
} finally {
fManager.removeFileBufferListener(listener);
}
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test11_1.
/*
* Test IFileBufferListener#dirtyStateChanged
*/
@Test
public void test11_1() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
public boolean isDirty;
@Override
public void dirtyStateChanged(IFileBuffer buf, boolean state) {
++count;
this.buffer = buf;
this.isDirty = state;
}
}
Listener listener = new Listener();
fManager.addFileBufferListener(listener);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
assertTrue(listener.count == 0 && listener.buffer == null);
fManager.connectFileStore(fFileStore, null);
try {
fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
IDocument document = fileBuffer.getDocument();
document.replace(0, 0, "prefix");
assertTrue(listener.count == 1);
assertTrue(listener.buffer == fileBuffer);
assertTrue(listener.isDirty);
fileBuffer.commit(null, true);
assertTrue(listener.count == 2);
assertTrue(listener.buffer == fileBuffer);
assertFalse(listener.isDirty);
} finally {
fManager.disconnectFileStore(fFileStore, null);
}
} finally {
fManager.removeFileBufferListener(listener);
}
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method test12_1.
/*
* Test IFileBufferListener#bufferContentAboutToBeReplaced/replaced
*/
@Test
public void test12_1() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer preBuffer, postBuffer;
public int preCount, postCount;
@Override
public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
++preCount;
preBuffer = buffer;
}
@Override
public void bufferContentReplaced(IFileBuffer buffer) {
++postCount;
postBuffer = buffer;
}
}
Listener listener = new Listener();
fManager.addFileBufferListener(listener);
try {
ITextFileBuffer fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertTrue(listener.preCount == 0 && listener.postCount == 0 && listener.preBuffer == null && listener.postBuffer == null);
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
IDocument document = fileBuffer.getDocument();
document.replace(0, 0, "prefix");
fileBuffer.revert(null);
assertTrue(listener.preCount == 1);
assertTrue(listener.preBuffer == fileBuffer);
assertTrue(listener.postCount == 1);
assertTrue(listener.postBuffer == fileBuffer);
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
} finally {
fManager.removeFileBufferListener(listener);
}
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class ResourceTextFileBufferManager method validationStateChangedFailed.
private void validationStateChangedFailed(IFileBuffer[] fileBuffers) {
for (IFileBuffer fileBuffer : fileBuffers) {
if (fileBuffer instanceof IStateValidationSupport) {
IStateValidationSupport support = (IStateValidationSupport) fileBuffer;
support.validationStateChangeFailed();
}
}
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class ResourceTextFileBufferManager method validationStateAboutToBeChanged.
private void validationStateAboutToBeChanged(IFileBuffer[] fileBuffers) {
for (IFileBuffer fileBuffer : fileBuffers) {
if (fileBuffer instanceof IStateValidationSupport) {
IStateValidationSupport support = (IStateValidationSupport) fileBuffer;
support.validationStateAboutToBeChanged();
}
}
}
Aggregations