Search in sources :

Example 1 with ThreadsafeImageRegistry

use of org.knime.workbench.core.util.ThreadsafeImageRegistry in project knime-core by knime.

the class KNIMECorePlugin method createImageRegistry.

/**
 * {@inheritDoc}
 */
@Override
protected ImageRegistry createImageRegistry() {
    // If we are in the UI Thread use that
    if (Display.getCurrent() != null) {
        return new ThreadsafeImageRegistry(Display.getCurrent());
    } else {
        Display display;
        if (PlatformUI.isWorkbenchRunning()) {
            display = PlatformUI.getWorkbench().getDisplay();
        } else {
            display = Display.getDefault();
        }
        final AtomicReference<ImageRegistry> ref = new AtomicReference<>();
        display.syncExec(new Runnable() {

            @Override
            public void run() {
                ref.set(new ThreadsafeImageRegistry(Display.getCurrent()));
            }
        });
        return ref.get();
    }
}
Also used : ThreadsafeImageRegistry(org.knime.workbench.core.util.ThreadsafeImageRegistry) ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ThreadsafeImageRegistry(org.knime.workbench.core.util.ThreadsafeImageRegistry) AtomicReference(java.util.concurrent.atomic.AtomicReference) Display(org.eclipse.swt.widgets.Display)

Aggregations

AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)1 Display (org.eclipse.swt.widgets.Display)1 ThreadsafeImageRegistry (org.knime.workbench.core.util.ThreadsafeImageRegistry)1