use of org.eclipse.swt.SWTException in project eclipse.platform.text by eclipse.
the class AnnotationPainter method modelChanged.
@Override
public void modelChanged(final AnnotationModelEvent event) {
Display textWidgetDisplay;
try {
StyledText textWidget = fTextWidget;
if (textWidget == null || textWidget.isDisposed())
return;
textWidgetDisplay = textWidget.getDisplay();
} catch (SWTException ex) {
if (ex.code == SWT.ERROR_WIDGET_DISPOSED)
return;
throw ex;
}
if (fIsSettingModel) {
// inside the UI thread -> no need for posting
if (textWidgetDisplay == Display.getCurrent())
updatePainting(event);
else {
/*
* we can throw away the changes since
* further update painting will happen
*/
return;
}
} else {
if (DEBUG && event != null && event.isWorldChange()) {
// $NON-NLS-1$
System.out.println("AP: WORLD CHANGED, stack trace follows:");
new Throwable().printStackTrace(System.out);
}
// XXX: posting here is a problem for annotations that are being
// removed and the positions of which are not updated to document
// changes any more. If the document gets modified between
// now and running the posted runnable, the position information
// is not accurate any longer.
textWidgetDisplay.asyncExec(new Runnable() {
@Override
public void run() {
if (fTextWidget != null && !fTextWidget.isDisposed())
updatePainting(event);
}
});
}
}
use of org.eclipse.swt.SWTException in project knime-core by knime.
the class KNIMEApplication method start.
/**
* {@inheritDoc}
*/
@Override
public Object start(final IApplicationContext appContext) throws Exception {
Display display = createDisplay();
try {
// open document listener needs to be registered as first
// thing to account for open document events during startup
KNIMEOpenDocumentEventProcessor openDocProcessor = new KNIMEOpenDocumentEventProcessor();
display.addListener(SWT.OpenDocument, openDocProcessor);
if (!checkInstanceLocation()) {
appContext.applicationRunning();
return EXIT_OK;
}
ViewUtils.setLookAndFeel();
ProfileManager.getInstance().applyProfiles();
// initialize KNIMEConstants as early as possible in order to avoid deadlocks during startup
KNIMEConstants.BUILD.toString();
parseApplicationArguments(appContext);
// initialize common classes early in order to avoid deadlocks
NodeLogger.class.getName();
RepositoryUpdater.INSTANCE.addDefaultRepositories();
RepositoryUpdater.INSTANCE.updateArtifactRepositoryURLs();
int returnCode;
if (m_checkForUpdates && checkForUpdates()) {
returnCode = PlatformUI.RETURN_RESTART;
} else {
startDeadlockDetectors(display);
// create the workbench with this advisor and run it until it
// exits
// N.B. createWorkbench remembers the advisor, and also
// registers
// the workbench globally so that all UI plug-ins can find it
// using
// PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench()
returnCode = PlatformUI.createAndRunWorkbench(display, getWorkbenchAdvisor(openDocProcessor));
}
// here to substitute in the relaunch return code if needed
if (returnCode != PlatformUI.RETURN_RESTART) {
return EXIT_OK;
}
// return that code now, otherwise this is a normal restart
return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE)) ? EXIT_RELAUNCH : EXIT_RESTART;
} finally {
if (display != null) {
try {
display.dispose();
} catch (SWTException e) {
// attempt to fix ui hangs on mac when the closes, see AP-8117
NodeLogger.getLogger(KNIMEApplication.class).debug("Exception while disposing Display object: " + e.getMessage(), e);
}
}
}
}
Aggregations