use of org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension in project eclipse.platform.text by eclipse.
the class ResourceTextFileBufferManager method createEmptyDocument.
public IDocument createEmptyDocument(final IFile file) {
IDocument documentFromFactory = createEmptyDocumentFromFactory(file);
final IDocument document;
if (documentFromFactory != null)
document = documentFromFactory;
else
document = new SynchronizableDocument();
// Set the initial line delimiter
if (document instanceof IDocumentExtension4) {
String initalLineDelimiter = getLineDelimiterPreference(file);
if (initalLineDelimiter != null)
((IDocumentExtension4) document).setInitialLineDelimiter(initalLineDelimiter);
}
final IDocumentSetupParticipant[] participants = ((ResourceExtensionRegistry) fRegistry).getDocumentSetupParticipants(file);
if (participants != null) {
for (final IDocumentSetupParticipant participant : participants) {
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
if (participant instanceof IDocumentSetupParticipantExtension)
((IDocumentSetupParticipantExtension) participant).setup(document, file.getFullPath(), LocationKind.IFILE);
else
participant.setup(document);
if (document.getDocumentPartitioner() != null) {
String message = NLSUtility.format(FileBuffersMessages.TextFileBufferManager_warning_documentSetupInstallsDefaultPartitioner, participant.getClass());
IStatus status = new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null);
FileBuffersPlugin.getDefault().getLog().log(status);
}
}
@Override
public void handleException(Throwable t) {
IStatus status = new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.TextFileBufferManager_error_documentSetupFailed, t);
FileBuffersPlugin.getDefault().getLog().log(status);
}
};
SafeRunner.run(runnable);
}
}
return document;
}
use of org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension in project eclipse.platform.text by eclipse.
the class TextFileBufferManager method createEmptyDocument.
@Override
public IDocument createEmptyDocument(final IPath location, final LocationKind locationKind) {
IDocument documentFromFactory = createDocumentFromFactory(location, locationKind);
final IDocument document;
if (documentFromFactory != null)
document = documentFromFactory;
else
document = new SynchronizableDocument();
if (location == null)
return document;
// Set the initial line delimiter
if (document instanceof IDocumentExtension4) {
String initalLineDelimiter = getLineDelimiterPreference(location, locationKind);
if (initalLineDelimiter != null)
((IDocumentExtension4) document).setInitialLineDelimiter(initalLineDelimiter);
}
final IDocumentSetupParticipant[] participants = fRegistry.getDocumentSetupParticipants(location, locationKind);
if (participants != null) {
for (final IDocumentSetupParticipant participant : participants) {
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
if (participant instanceof IDocumentSetupParticipantExtension)
((IDocumentSetupParticipantExtension) participant).setup(document, location, locationKind);
else
participant.setup(document);
if (document.getDocumentPartitioner() != null) {
String message = NLSUtility.format(FileBuffersMessages.TextFileBufferManager_warning_documentSetupInstallsDefaultPartitioner, participant.getClass());
IStatus status = new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null);
FileBuffersPlugin.getDefault().getLog().log(status);
}
}
@Override
public void handleException(Throwable t) {
IStatus status = new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.TextFileBufferManager_error_documentSetupFailed, t);
FileBuffersPlugin.getDefault().getLog().log(status);
}
};
SafeRunner.run(runnable);
}
}
return document;
}
Aggregations