Search in sources :

Example 56 with SWTException

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);
            }
        });
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) SWTException(org.eclipse.swt.SWTException) Display(org.eclipse.swt.widgets.Display)

Example 57 with SWTException

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);
            }
        }
    }
}
Also used : SWTException(org.eclipse.swt.SWTException) Display(org.eclipse.swt.widgets.Display)

Aggregations

SWTException (org.eclipse.swt.SWTException)57 Test (org.junit.Test)29 Image (org.eclipse.swt.graphics.Image)21 Rectangle (org.eclipse.swt.graphics.Rectangle)14 ImageData (org.eclipse.swt.graphics.ImageData)13 IOException (java.io.IOException)8 Region (org.eclipse.swt.graphics.Region)8 Display (org.eclipse.swt.widgets.Display)8 SWTError (org.eclipse.swt.SWTError)7 PaletteData (org.eclipse.swt.graphics.PaletteData)7 RGB (org.eclipse.swt.graphics.RGB)7 InputStream (java.io.InputStream)6 Point (org.eclipse.swt.graphics.Point)6 MessageBox (org.eclipse.swt.widgets.MessageBox)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Cursor (org.eclipse.swt.graphics.Cursor)4 ImageLoader (org.eclipse.swt.graphics.ImageLoader)4 FileDialog (org.eclipse.swt.widgets.FileDialog)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Shell (org.eclipse.swt.widgets.Shell)3