I'm closing all MMapMagnets (kind of property TopComponents), that should
only be visible when the MapTopComponents is with

        final WindowManager windowManager = WindowManager.getDefault();
        windowManager.getModes().stream().filter((mode) ->
!(mode.equals(windowManager.findMode(this)))).forEachOrdered((mode) -> {
            TopComponent selectedTopComponent =
mode.getSelectedTopComponent();
            for (TopComponent tc : mode.getTopComponents()) {
                if (tc instanceof MTopComponent && tc.isOpened() &&
!windowManager.isTopComponentFloating(tc)) {
                    if (tc instanceof MMapMagnet) {
                        if (tc.equals(selectedTopComponent)) {
                            mActiveMapMagnets.add(tc);
                        }

                        tc.close();
                        mMapMagnets.add(tc);
                    }
                }
            }
        });

In short, use the WindowManager and Modes.


And in context, no pun intended.
https://github.com/trixon/mapton/blob/8e149fbe9e2f1cfb0ff585f718c8e3c56eba82ba/core/src/main/java/org/mapton/core/ui/MapTopComponent.java#L192

Den tors 25 juli 2019 kl 06:35 skrev Peter Cheung <mcheun...@hotmail.com>:

> Dear All
>     How to maintain there is only one instance of a topcomponent window of
> a specific class?
>     How to close all topcomponent of a specific class?
>
>
> Thanks
> From Peter
>

Reply via email to