Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Re: Close map programmatically?

(Resend-first attempt didn't reach the list.)

After input from Jody and a spelunk through the uDig source, I figured out how to close maps programmatically.

The below closes all open maps ignoring any edits.  Could be embellished to close currently active map by or a subset by calling ApplicationGIS.getActiveMap() or .getVisibleMaps(), then looking at MapPart.getMap() and comparing to (Map)IMap etc.

        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if( window==null ){
            return;
        }
        IWorkbenchPage page = window.getActivePage();
        if( page!=null ){
            IEditorPart[] editorparts = page.getEditors();
            for (IEditorPart editorpart: editorparts) {
                if( editorpart instanceof MapPart ){
                    page.activate(editorpart);
                    page.closeEditor(editorpart, false);
                }
            }
        }


Back to the top