use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class ResourceTextFileBufferManager method computeValidateStateRule.
private ISchedulingRule computeValidateStateRule(IFileBuffer[] fileBuffers) {
ArrayList<IResource> list = new ArrayList<>();
for (IFileBuffer fileBuffer : fileBuffers) {
IResource resource = getWorkspaceFile(fileBuffer);
if (resource != null)
list.add(resource);
}
IResource[] resources = new IResource[list.size()];
list.toArray(resources);
IResourceRuleFactory factory = ResourcesPlugin.getWorkspace().getRuleFactory();
return factory.validateEditRule(resources);
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class ResourceTextFileBufferManager method validateEdit.
private IStatus validateEdit(IFileBuffer[] fileBuffers, Object computationContext) {
ArrayList<IFile> list = new ArrayList<>();
for (IFileBuffer fileBuffer : fileBuffers) {
IFile file = getWorkspaceFile(fileBuffer);
if (file != null)
list.add(file);
}
IFile[] files = new IFile[list.size()];
list.toArray(files);
return ResourcesPlugin.getWorkspace().validateEdit(files, computationContext);
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class ResourceTextFileBufferManager method validationStateChanged.
private void validationStateChanged(IFileBuffer[] fileBuffers, boolean validationState, IStatus status) {
for (IFileBuffer fileBuffer : fileBuffers) {
if (fileBuffer instanceof IStateValidationSupport) {
IStateValidationSupport support = (IStateValidationSupport) fileBuffer;
support.validationStateChanged(validationState, status);
}
}
}
use of org.eclipse.core.filebuffers.IFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test16_2.
/*
* Test IFileBufferListener#stateChanging for external changes
*/
@Test
public void test16_2() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
@Override
public void stateChanging(IFileBuffer buf) {
++count;
this.buffer = buf;
}
}
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);
if (deleteUnderlyingFile()) {
assertTrue(listener.count == 1);
assertTrue(listener.buffer == fileBuffer);
}
} 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 test10.
/*
* Test IFileBufferListener#bufferCreated and IFileBufferListener#bufferDisposed
*/
@Test
public void test10() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
@Override
public void bufferCreated(IFileBuffer buf) {
++count;
this.buffer = buf;
}
@Override
public void bufferDisposed(IFileBuffer buf) {
--count;
this.buffer = buf;
}
}
Listener listener = new Listener();
fManager.addFileBufferListener(listener);
try {
fManager.connectFileStore(fFileStore, null);
assertTrue(listener.count == 1);
assertNotNull(listener.buffer);
IFileBuffer fileBuffer = fManager.getFileStoreFileBuffer(fFileStore);
assertTrue(listener.buffer == fileBuffer);
fManager.disconnectFileStore(fFileStore, null);
assertTrue(listener.count == 0);
assertTrue(listener.buffer == fileBuffer);
} finally {
try {
fManager.disconnectFileStore(fFileStore, null);
} finally {
fManager.removeFileBufferListener(listener);
}
}
}
Aggregations