(final LaunchNode node, Frame[] prevFrames, final Runnable runner)
| 3856 | } |
| 3857 | |
| 3858 | private static void findFramesFor(final LaunchNode node, Frame[] prevFrames, final Runnable runner) { |
| 3859 | // get current frames |
| 3860 | Frame[] frames = Frame.getFrames(); |
| 3861 | // make newFrames collection |
| 3862 | final Collection<Frame> newFrames = new ArrayList<Frame>(); |
| 3863 | for (int i = 0; i < frames.length; i++) { |
| 3864 | // ignore message frames, DO_NOTHING frames and incidental frames |
| 3865 | if (frames[i] instanceof JFrame) { |
| 3866 | JFrame frame = (JFrame) frames[i]; |
| 3867 | if ((frame.getDefaultCloseOperation() == WindowConstants.DO_NOTHING_ON_CLOSE) |
| 3868 | || (frame instanceof MessageFrame) || (frame instanceof LauncherFrame)) { |
| 3869 | continue; |
| 3870 | } |
| 3871 | } |
| 3872 | if ((frames[i].getClass().getName().indexOf("SharedOwnerFrame") > -1)) { //$NON-NLS-1$ |
| 3873 | continue; |
| 3874 | } |
| 3875 | newFrames.add(frames[i]); |
| 3876 | } |
| 3877 | // throw out previous frames |
| 3878 | for (int i = 0; i < prevFrames.length; i++) { |
| 3879 | newFrames.remove(prevFrames[i]); |
| 3880 | } |
| 3881 | // return if no new frames found |
| 3882 | if (newFrames.isEmpty()) { |
| 3883 | return; |
| 3884 | } |
| 3885 | // look thru new frames for "control frame" |
| 3886 | // "control frame" is JFrame/EXIT_ON_CLOSE or OSPFrame/wishesToExit() |
| 3887 | frames = newFrames.toArray(new Frame[0]); |
| 3888 | newFrames.clear(); |
| 3889 | FrameCloser frameCloser = new FrameCloser(node, newFrames, runner); |
| 3890 | for (int i = 0; i < frames.length; i++) { |
| 3891 | if (frames[i] instanceof JFrame) { // found new frame |
| 3892 | JFrame frame = (JFrame) frames[i]; |
| 3893 | if (((frame instanceof AppFrame) && ((AppFrame) frame).wishesToExit()) |
| 3894 | || (frame.getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE)) { // found control frame |
| 3895 | if (frame.getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE) { |
| 3896 | // change default close operation from EXIT_ON_CLOSE to DISPOSE_ON_CLOSE |
| 3897 | // so exiting a launched app does not close Launcher |
| 3898 | frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); |
| 3899 | } |
| 3900 | // add window listener so control frames can close associated windows |
| 3901 | frame.addWindowListener(frameCloser); |
| 3902 | } |
| 3903 | newFrames.add(frame); |
| 3904 | } |
| 3905 | } |
| 3906 | // add frames to node |
| 3907 | if (node != null) { |
| 3908 | node.frames.addAll(newFrames); |
| 3909 | node.launchCount++; |
| 3910 | // turn off and release timer |
| 3911 | if (frameFinder != null) { |
| 3912 | frameFinder.stop(); |
| 3913 | frameFinder = null; |
| 3914 | } |
| 3915 | // repaint |
no test coverage detected