Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipse-dev] [aeri] Knowing whether Eclipse has an active window on all platforms

In advance: this is an urgent request and your input would be required before Mars.1 RC4 is out. Thank you.



Greetings eclipse-dev,


When an error is logged in Eclipse, AERI tests whether there is an active Eclipse window before it displays a popup notification (no active window - no popup).

This test is executed in a display.syncExec call as given below. This call, however, is now under suspicion to cause deadlocks (see [1] for details). 


public static boolean hasActiveWindow() {
        final Display display = getDisplay().orNull();
        if (display == null) {
            return false;
        }
        if (isUIThread()) {
            return display.getActiveShell() != null;
        }
        // else
        final AtomicBoolean res = new AtomicBoolean(false);
        display.syncExec(new Runnable() {
            @Override
            public void run() {
                if (display.getActiveShell() == null) {
                    res.set(false);
                } else {
                    res.set(true);
                }
            }
        });
        return res.get();
    }



I’d like to know how I can *reliably* determine (from a background thread) whether Eclipse has an active window (or an open wizard etc.) or not. What is the preferred way to do that? Would something like the lines below work (on all platforms)?

        IWorkbenchWindow[] ww = PlatformUI.getWorkbench().getWorkbenchWindows();
        for(IWorkbenchWindow wwwww){
            activePage = www.getActivePage(); // may be null. Is it always null when called from non-ui-thread?
            if(activePage!=null){
                // yes, there is an eclipse window that has focus?
            }
        }



I apologize for not running any tests myself on this yet. Time is short to fix that potential regression before Mars.1 and I’m likely not able to test all platforms reliably before RC4. That’s why I’m asking for your input directly.

Thanks in advance,
Marcel




Back to the top