use of org.eclipse.core.runtime.ISafeRunnable in project eclipse.platform.text by eclipse.
the class SpellingConfigurationBlock method updateListDependencies.
void updateListDependencies() {
SpellingEngineDescriptor desc = EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore);
String id;
if (desc == null) {
// safety in case there is no such descriptor
// $NON-NLS-1$
id = "";
String message = TextEditorMessages.SpellingConfigurationBlock_error_not_exist;
EditorsPlugin.log(new Status(IStatus.WARNING, EditorsUI.PLUGIN_ID, IStatus.OK, message, null));
fCurrentBlock = new ErrorPreferences(message);
} else {
id = desc.getId();
fCurrentBlock = fProviderPreferences.get(id);
if (fCurrentBlock == null) {
try {
fCurrentBlock = desc.createPreferences();
fProviderPreferences.put(id, fCurrentBlock);
} catch (CoreException e) {
EditorsPlugin.log(e);
fCurrentBlock = new ErrorPreferences(e.getLocalizedMessage());
}
}
}
Control control = fProviderControls.get(id);
if (control == null) {
final Control[] result = new Control[1];
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
result[0] = fCurrentBlock.createControl(fGroup);
}
@Override
public void handleException(Throwable x) {
}
};
SafeRunner.run(runnable);
control = result[0];
if (control == null) {
String message = TextEditorMessages.SpellingConfigurationBlock_info_no_preferences;
EditorsPlugin.log(new Status(IStatus.WARNING, EditorsUI.PLUGIN_ID, IStatus.OK, message, null));
control = new ErrorPreferences(message).createControl(fGroup);
} else {
fProviderControls.put(id, control);
}
}
Dialog.applyDialogFont(control);
fStackLayout.topControl = control;
control.pack();
fGroup.layout();
fGroup.getParent().layout();
fStatusMonitor.statusChanged(new StatusInfo());
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
fCurrentBlock.initialize(fStatusMonitor);
}
@Override
public void handleException(Throwable x) {
}
};
SafeRunner.run(runnable);
}
use of org.eclipse.core.runtime.ISafeRunnable in project eclipse.platform.text by eclipse.
the class SpellingConfigurationBlock method performDefaults.
@Override
public void performDefaults() {
restoreFromPreferences();
for (Iterator<ISpellingPreferenceBlock> it = fProviderPreferences.values().iterator(); it.hasNext(); ) {
final ISpellingPreferenceBlock block = it.next();
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
block.performDefaults();
}
@Override
public void handleException(Throwable x) {
}
};
SafeRunner.run(runnable);
}
}
use of org.eclipse.core.runtime.ISafeRunnable in project eclipse.platform.text by eclipse.
the class SpellingConfigurationBlock method canPerformOk.
@Override
public boolean canPerformOk() {
SpellingEngineDescriptor desc = EditorsUI.getSpellingService().getActiveSpellingEngineDescriptor(fStore);
// $NON-NLS-1$
String id = desc != null ? desc.getId() : "";
final ISpellingPreferenceBlock block = fProviderPreferences.get(id);
if (block == null)
return true;
final Boolean[] result = new Boolean[] { Boolean.TRUE };
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void run() throws Exception {
result[0] = Boolean.valueOf(block.canPerformOk());
}
@Override
public void handleException(Throwable x) {
}
};
SafeRunner.run(runnable);
return result[0].booleanValue();
}
use of org.eclipse.core.runtime.ISafeRunnable in project eclipse.platform.text by eclipse.
the class AbstractTextSearchViewPage method showMatch.
private void showMatch(final Match match, final boolean activateEditor) {
ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
if (exception instanceof PartInitException) {
PartInitException pie = (PartInitException) exception;
ErrorDialog.openError(getSite().getShell(), SearchMessages.DefaultSearchViewPage_show_match, SearchMessages.DefaultSearchViewPage_error_no_editor, pie.getStatus());
}
}
@Override
public void run() throws Exception {
IRegion location = getCurrentMatchLocation(match);
showMatch(match, location.getOffset(), location.getLength(), activateEditor);
}
};
SafeRunner.run(runnable);
}
use of org.eclipse.core.runtime.ISafeRunnable 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;
}
Aggregations