8047799: Remove WindowClosingSupport
Reviewed-by: anthony, alexsch
This commit is contained in:
parent
f5df1eca19
commit
c08e2bf586
@ -67,7 +67,6 @@ import sun.awt.AWTAccessor;
|
||||
import sun.awt.ConstrainableGraphics;
|
||||
import sun.awt.SubRegionShowable;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.WindowClosingListener;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.awt.dnd.SunDropTargetEvent;
|
||||
@ -544,8 +543,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
transient MouseWheelListener mouseWheelListener;
|
||||
transient InputMethodListener inputMethodListener;
|
||||
|
||||
transient RuntimeException windowClosingException = null;
|
||||
|
||||
/** Internal, constants for serialization */
|
||||
final static String actionListenerK = "actionL";
|
||||
final static String adjustmentListenerK = "adjustmentL";
|
||||
@ -4866,16 +4863,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
if (toolkit instanceof WindowClosingListener) {
|
||||
windowClosingException = ((WindowClosingListener)
|
||||
toolkit).windowClosingNotify((WindowEvent)e);
|
||||
if (checkWindowClosingException()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -4930,21 +4917,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 8. Special handling for 4061116 : Hook for browser to close modal
|
||||
* dialogs.
|
||||
*/
|
||||
if (id == WindowEvent.WINDOW_CLOSING && !e.isConsumed()) {
|
||||
if (toolkit instanceof WindowClosingListener) {
|
||||
windowClosingException =
|
||||
((WindowClosingListener)toolkit).
|
||||
windowClosingDelivered((WindowEvent)e);
|
||||
if (checkWindowClosingException()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 9. Allow the peer to process the event.
|
||||
* Except KeyEvents, they will be processed by peer after
|
||||
@ -5052,20 +5024,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean checkWindowClosingException() {
|
||||
if (windowClosingException != null) {
|
||||
if (this instanceof Dialog) {
|
||||
((Dialog)this).interruptBlocking();
|
||||
} else {
|
||||
windowClosingException.fillInStackTrace();
|
||||
windowClosingException.printStackTrace();
|
||||
windowClosingException = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean areInputMethodsEnabled() {
|
||||
// in 1.2, we assume input method support is required for all
|
||||
// components that handle key events, but components can turn off
|
||||
|
@ -2899,17 +2899,10 @@ public class Container extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
Runnable pumpEventsForHierarchy = new Runnable() {
|
||||
public void run() {
|
||||
EventDispatchThread dispatchThread =
|
||||
(EventDispatchThread)Thread.currentThread();
|
||||
dispatchThread.pumpEventsForHierarchy(
|
||||
new Conditional() {
|
||||
public boolean evaluate() {
|
||||
return ((windowClosingException == null) && (nativeContainer.modalComp != null)) ;
|
||||
}
|
||||
}, Container.this);
|
||||
}
|
||||
Runnable pumpEventsForHierarchy = () -> {
|
||||
EventDispatchThread dispatchThread = (EventDispatchThread)Thread.currentThread();
|
||||
dispatchThread.pumpEventsForHierarchy(() -> nativeContainer.modalComp != null,
|
||||
Container.this);
|
||||
};
|
||||
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
@ -2927,8 +2920,7 @@ public class Container extends Component {
|
||||
postEvent(new PeerEvent(this,
|
||||
pumpEventsForHierarchy,
|
||||
PeerEvent.PRIORITY_EVENT));
|
||||
while ((windowClosingException == null) &&
|
||||
(nativeContainer.modalComp != null))
|
||||
while (nativeContainer.modalComp != null)
|
||||
{
|
||||
try {
|
||||
getTreeLock().wait();
|
||||
@ -2938,10 +2930,6 @@ public class Container extends Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (windowClosingException != null) {
|
||||
windowClosingException.fillInStackTrace();
|
||||
throw windowClosingException;
|
||||
}
|
||||
if (predictedFocusOwner != null) {
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().
|
||||
dequeueKeyEvents(time, predictedFocusOwner);
|
||||
|
@ -40,6 +40,7 @@ import sun.awt.PeerEvent;
|
||||
import sun.awt.util.IdentityArrayList;
|
||||
import sun.awt.util.IdentityLinkedList;
|
||||
import java.security.AccessControlException;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
/**
|
||||
* A Dialog is a top-level window with a title and a border
|
||||
@ -1044,13 +1045,6 @@ public class Dialog extends Window {
|
||||
predictedFocusOwner = getMostRecentFocusOwner();
|
||||
if (conditionalShow(predictedFocusOwner, time)) {
|
||||
modalFilter = ModalEventFilter.createFilterForDialog(this);
|
||||
final Conditional cond = new Conditional() {
|
||||
@Override
|
||||
public boolean evaluate() {
|
||||
return windowClosingException == null;
|
||||
}
|
||||
};
|
||||
|
||||
// if this dialog is toolkit-modal, the filter should be added
|
||||
// to all EDTs (for all AppContexts)
|
||||
if (modalityType == ModalityType.TOOLKIT_MODAL) {
|
||||
@ -1063,10 +1057,7 @@ public class Dialog extends Window {
|
||||
EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
|
||||
// it may occur that EDT for appContext hasn't been started yet, so
|
||||
// we post an empty invocation event to trigger EDT initialization
|
||||
Runnable createEDT = new Runnable() {
|
||||
public void run() {};
|
||||
};
|
||||
eventQueue.postEvent(new InvocationEvent(this, createEDT));
|
||||
eventQueue.postEvent(new InvocationEvent(this, () -> {}));
|
||||
EventDispatchThread edt = eventQueue.getDispatchThread();
|
||||
edt.addEventFilter(modalFilter);
|
||||
}
|
||||
@ -1075,12 +1066,8 @@ public class Dialog extends Window {
|
||||
modalityPushed();
|
||||
try {
|
||||
final EventQueue eventQueue = AccessController.doPrivileged(
|
||||
new PrivilegedAction<EventQueue>() {
|
||||
public EventQueue run() {
|
||||
return Toolkit.getDefaultToolkit().getSystemEventQueue();
|
||||
}
|
||||
});
|
||||
secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
|
||||
(PrivilegedAction<EventQueue>) Toolkit.getDefaultToolkit()::getSystemEventQueue);
|
||||
secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0);
|
||||
if (!secondaryLoop.enter()) {
|
||||
secondaryLoop = null;
|
||||
}
|
||||
@ -1102,11 +1089,6 @@ public class Dialog extends Window {
|
||||
edt.removeEventFilter(modalFilter);
|
||||
}
|
||||
}
|
||||
|
||||
if (windowClosingException != null) {
|
||||
windowClosingException.fillInStackTrace();
|
||||
throw windowClosingException;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (predictedFocusOwner != null) {
|
||||
@ -1134,16 +1116,6 @@ public class Dialog extends Window {
|
||||
}
|
||||
}
|
||||
|
||||
void interruptBlocking() {
|
||||
if (isModal()) {
|
||||
disposeImpl();
|
||||
} else if (windowClosingException != null) {
|
||||
windowClosingException.fillInStackTrace();
|
||||
windowClosingException.printStackTrace();
|
||||
windowClosingException = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void hideAndDisposePreHandler() {
|
||||
isInHide = true;
|
||||
synchronized (getTreeLock()) {
|
||||
|
@ -59,8 +59,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessController;
|
||||
|
||||
public abstract class SunToolkit extends Toolkit
|
||||
implements WindowClosingSupport, WindowClosingListener,
|
||||
ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
|
||||
implements ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
|
||||
|
||||
// 8014718: logging has been removed from SunToolkit
|
||||
|
||||
@ -1201,42 +1200,6 @@ public abstract class SunToolkit extends Toolkit
|
||||
return getStartupLocale();
|
||||
}
|
||||
|
||||
// Support for window closing event notifications
|
||||
private transient WindowClosingListener windowClosingListener = null;
|
||||
/**
|
||||
* @see sun.awt.WindowClosingSupport#getWindowClosingListener
|
||||
*/
|
||||
public WindowClosingListener getWindowClosingListener() {
|
||||
return windowClosingListener;
|
||||
}
|
||||
/**
|
||||
* @see sun.awt.WindowClosingSupport#setWindowClosingListener
|
||||
*/
|
||||
public void setWindowClosingListener(WindowClosingListener wcl) {
|
||||
windowClosingListener = wcl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see sun.awt.WindowClosingListener#windowClosingNotify
|
||||
*/
|
||||
public RuntimeException windowClosingNotify(WindowEvent event) {
|
||||
if (windowClosingListener != null) {
|
||||
return windowClosingListener.windowClosingNotify(event);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see sun.awt.WindowClosingListener#windowClosingDelivered
|
||||
*/
|
||||
public RuntimeException windowClosingDelivered(WindowEvent event) {
|
||||
if (windowClosingListener != null) {
|
||||
return windowClosingListener.windowClosingDelivered(event);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static DefaultMouseInfoPeer mPeer = null;
|
||||
|
||||
protected synchronized MouseInfoPeer getMouseInfoPeer() {
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
/**
|
||||
* Interface for listening to WINDOW_CLOSING events before and
|
||||
* after they are posted to the queue.
|
||||
*/
|
||||
public interface WindowClosingListener {
|
||||
/**
|
||||
* Called before a WINDOW_CLOSING event gets posted to the queue.
|
||||
* @param event The WINDOW_CLOSING event that will be posted.
|
||||
* @return A RuntimeException if the result of this function
|
||||
* call needs to interrupt a blocking thread. The exception
|
||||
* returned will be thrown from that thread. This function
|
||||
* should return null otherwise.
|
||||
*/
|
||||
RuntimeException windowClosingNotify(WindowEvent event);
|
||||
/**
|
||||
* Called after a WINDOW_CLOSING event gets posted to the queue.
|
||||
* @param event The WINDOW_CLOSING event that has been posted.
|
||||
* @return A RuntimeException if the result of this function
|
||||
* call needs to interrupt a blocking thread. The exception
|
||||
* returned will be thrown from that thread. This function
|
||||
* should return null otherwise.
|
||||
*/
|
||||
RuntimeException windowClosingDelivered(WindowEvent event);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
/**
|
||||
* Interface for identifying and casting toolkits that support
|
||||
* WindowClosingListeners.
|
||||
*/
|
||||
public interface WindowClosingSupport {
|
||||
WindowClosingListener getWindowClosingListener();
|
||||
void setWindowClosingListener(WindowClosingListener wcl);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user