6907568: java/awt/KeyboardFocusManager.java inproperly merged and lost a changeset

Reapply fix for 6879044 in java.awt.KeyboardFocusManager

Reviewed-by: dcherepanov, asaha
This commit is contained in:
Mandy Chung 2009-12-08 09:02:09 -08:00
parent 45c70cd97e
commit 881a1c5842

@ -53,8 +53,7 @@ import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Level; import sun.util.logging.PlatformLogger;
import java.util.logging.Logger;
import sun.awt.AppContext; import sun.awt.AppContext;
import sun.awt.HeadlessToolkit; import sun.awt.HeadlessToolkit;
@ -111,7 +110,7 @@ public abstract class KeyboardFocusManager
{ {
// Shared focus engine logger // Shared focus engine logger
private static final Logger focusLog = Logger.getLogger("java.awt.focus.KeyboardFocusManager"); private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.KeyboardFocusManager");
static { static {
/* ensure that the necessary native libraries are loaded */ /* ensure that the necessary native libraries are loaded */
@ -154,7 +153,7 @@ public abstract class KeyboardFocusManager
*/ */
private static native void initIDs(); private static native void initIDs();
private static final Logger log = Logger.getLogger("java.awt.KeyboardFocusManager"); private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.KeyboardFocusManager");
/** /**
* The identifier for the Forward focus traversal keys. * The identifier for the Forward focus traversal keys.
@ -504,8 +503,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) { if (this == getCurrentKeyboardFocusManager()) {
return focusOwner; return focusOwner;
} else { } else {
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager()); focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
} }
throw new SecurityException(notPrivileged); throw new SecurityException(notPrivileged);
} }
@ -609,9 +608,9 @@ public abstract class KeyboardFocusManager
} }
void setNativeFocusOwner(Component comp) { void setNativeFocusOwner(Component comp) {
if (focusLog.isLoggable(Level.FINEST)) { if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.log(Level.FINEST, "Calling peer {0} setCurrentFocusOwner for {1}", focusLog.finest("Calling peer {0} setCurrentFocusOwner for {1}",
new Object[] {String.valueOf(peer), String.valueOf(comp)}); String.valueOf(peer), String.valueOf(comp));
} }
peer.setCurrentFocusOwner(comp); peer.setCurrentFocusOwner(comp);
} }
@ -673,8 +672,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) { if (this == getCurrentKeyboardFocusManager()) {
return permanentFocusOwner; return permanentFocusOwner;
} else { } else {
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager()); focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
} }
throw new SecurityException(notPrivileged); throw new SecurityException(notPrivileged);
} }
@ -781,8 +780,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) { if (this == getCurrentKeyboardFocusManager()) {
return focusedWindow; return focusedWindow;
} else { } else {
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager()); focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
} }
throw new SecurityException(notPrivileged); throw new SecurityException(notPrivileged);
} }
@ -885,8 +884,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) { if (this == getCurrentKeyboardFocusManager()) {
return activeWindow; return activeWindow;
} else { } else {
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager()); focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
} }
throw new SecurityException(notPrivileged); throw new SecurityException(notPrivileged);
} }
@ -919,8 +918,8 @@ public abstract class KeyboardFocusManager
Window oldActiveWindow; Window oldActiveWindow;
synchronized (KeyboardFocusManager.class) { synchronized (KeyboardFocusManager.class) {
oldActiveWindow = getActiveWindow(); oldActiveWindow = getActiveWindow();
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "Setting global active window to " + activeWindow + ", old active " + oldActiveWindow); focusLog.finer("Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
} }
try { try {
@ -1215,8 +1214,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) { if (this == getCurrentKeyboardFocusManager()) {
return currentFocusCycleRoot; return currentFocusCycleRoot;
} else { } else {
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager()); focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
} }
throw new SecurityException(notPrivileged); throw new SecurityException(notPrivileged);
} }
@ -2149,9 +2148,9 @@ public abstract class KeyboardFocusManager
HeavyweightFocusRequest(Component heavyweight, Component descendant, HeavyweightFocusRequest(Component heavyweight, Component descendant,
boolean temporary, CausedFocusEvent.Cause cause) { boolean temporary, CausedFocusEvent.Cause cause) {
if (log.isLoggable(Level.FINE)) { if (log.isLoggable(PlatformLogger.FINE)) {
if (heavyweight == null) { if (heavyweight == null) {
log.log(Level.FINE, "Assertion (heavyweight != null) failed"); log.fine("Assertion (heavyweight != null) failed");
} }
} }
@ -2161,12 +2160,12 @@ public abstract class KeyboardFocusManager
} }
boolean addLightweightRequest(Component descendant, boolean addLightweightRequest(Component descendant,
boolean temporary, CausedFocusEvent.Cause cause) { boolean temporary, CausedFocusEvent.Cause cause) {
if (log.isLoggable(Level.FINE)) { if (log.isLoggable(PlatformLogger.FINE)) {
if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
log.log(Level.FINE, "Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed"); log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
} }
if (descendant == null) { if (descendant == null) {
log.log(Level.FINE, "Assertion (descendant != null) failed"); log.fine("Assertion (descendant != null) failed");
} }
} }
@ -2339,12 +2338,12 @@ public abstract class KeyboardFocusManager
(Component heavyweight, Component descendant, boolean temporary, (Component heavyweight, Component descendant, boolean temporary,
boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
{ {
if (log.isLoggable(Level.FINE)) { if (log.isLoggable(PlatformLogger.FINE)) {
if (heavyweight == null) { if (heavyweight == null) {
log.log(Level.FINE, "Assertion (heavyweight != null) failed"); log.fine("Assertion (heavyweight != null) failed");
} }
if (time == 0) { if (time == 0) {
log.log(Level.FINE, "Assertion (time != 0) failed"); log.fine("Assertion (time != 0) failed");
} }
} }
@ -2361,30 +2360,30 @@ public abstract class KeyboardFocusManager
Component currentFocusOwner = thisManager.getGlobalFocusOwner(); Component currentFocusOwner = thisManager.getGlobalFocusOwner();
Component nativeFocusOwner = thisManager.getNativeFocusOwner(); Component nativeFocusOwner = thisManager.getNativeFocusOwner();
Window nativeFocusedWindow = thisManager.getNativeFocusedWindow(); Window nativeFocusedWindow = thisManager.getNativeFocusedWindow();
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.log(Level.FINER, "SNFH for {0} in {1}", focusLog.finer("SNFH for {0} in {1}",
new Object[] {String.valueOf(descendant), String.valueOf(heavyweight)}); String.valueOf(descendant), String.valueOf(heavyweight));
} }
if (focusLog.isLoggable(Level.FINEST)) { if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.log(Level.FINEST, "0. Current focus owner {0}", focusLog.finest("0. Current focus owner {0}",
String.valueOf(currentFocusOwner)); String.valueOf(currentFocusOwner));
focusLog.log(Level.FINEST, "0. Native focus owner {0}", focusLog.finest("0. Native focus owner {0}",
String.valueOf(nativeFocusOwner)); String.valueOf(nativeFocusOwner));
focusLog.log(Level.FINEST, "0. Native focused window {0}", focusLog.finest("0. Native focused window {0}",
String.valueOf(nativeFocusedWindow)); String.valueOf(nativeFocusedWindow));
} }
synchronized (heavyweightRequests) { synchronized (heavyweightRequests) {
HeavyweightFocusRequest hwFocusRequest = getLastHWRequest(); HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();
if (focusLog.isLoggable(Level.FINEST)) { if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.log(Level.FINEST, "Request {0}", String.valueOf(hwFocusRequest)); focusLog.finest("Request {0}", String.valueOf(hwFocusRequest));
} }
if (hwFocusRequest == null && if (hwFocusRequest == null &&
heavyweight == nativeFocusOwner) heavyweight == nativeFocusOwner)
{ {
if (descendant == currentFocusOwner) { if (descendant == currentFocusOwner) {
// Redundant request. // Redundant request.
if (focusLog.isLoggable(Level.FINEST)) if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.log(Level.FINEST, "1. SNFH_FAILURE for {0}", focusLog.finest("1. SNFH_FAILURE for {0}",
String.valueOf(descendant)); String.valueOf(descendant));
return SNFH_FAILURE; return SNFH_FAILURE;
} }
@ -2417,8 +2416,8 @@ public abstract class KeyboardFocusManager
// SunToolkit.postPriorityEvent(newFocusOwnerEvent); // SunToolkit.postPriorityEvent(newFocusOwnerEvent);
SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent); SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
if (focusLog.isLoggable(Level.FINEST)) if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", String.valueOf(descendant)); focusLog.finest("2. SNFH_HANDLED for {0}", String.valueOf(descendant));
return SNFH_SUCCESS_HANDLED; return SNFH_SUCCESS_HANDLED;
} else if (hwFocusRequest != null && } else if (hwFocusRequest != null &&
hwFocusRequest.heavyweight == heavyweight) { hwFocusRequest.heavyweight == heavyweight) {
@ -2431,7 +2430,7 @@ public abstract class KeyboardFocusManager
manager.enqueueKeyEvents(time, descendant); manager.enqueueKeyEvents(time, descendant);
} }
if (focusLog.isLoggable(Level.FINEST)) if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("3. SNFH_HANDLED for lightweight" + focusLog.finest("3. SNFH_HANDLED for lightweight" +
descendant + " in " + heavyweight); descendant + " in " + heavyweight);
return SNFH_SUCCESS_HANDLED; return SNFH_SUCCESS_HANDLED;
@ -2454,7 +2453,7 @@ public abstract class KeyboardFocusManager
(hwFocusRequest != null) (hwFocusRequest != null)
? hwFocusRequest.heavyweight ? hwFocusRequest.heavyweight
: nativeFocusedWindow)) { : nativeFocusedWindow)) {
if (focusLog.isLoggable(Level.FINEST)) if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("4. SNFH_FAILURE for " + descendant); focusLog.finest("4. SNFH_FAILURE for " + descendant);
return SNFH_FAILURE; return SNFH_FAILURE;
} }
@ -2464,7 +2463,7 @@ public abstract class KeyboardFocusManager
heavyweightRequests.add heavyweightRequests.add
(new HeavyweightFocusRequest(heavyweight, descendant, (new HeavyweightFocusRequest(heavyweight, descendant,
temporary, cause)); temporary, cause));
if (focusLog.isLoggable(Level.FINEST)) if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("5. SNFH_PROCEED for " + descendant); focusLog.finest("5. SNFH_PROCEED for " + descendant);
return SNFH_SUCCESS_PROCEED; return SNFH_SUCCESS_PROCEED;
} }
@ -2855,14 +2854,14 @@ public abstract class KeyboardFocusManager
} }
KeyboardFocusManager manager = getCurrentKeyboardFocusManager(); KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
if (focusLog.isLoggable(Level.FINER)) { if (focusLog.isLoggable(PlatformLogger.FINER)) {
if (event instanceof FocusEvent || event instanceof WindowEvent) { if (event instanceof FocusEvent || event instanceof WindowEvent) {
focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)}); focusLog.finer(">>> {0}", String.valueOf(event));
} }
if (focusLog.isLoggable(Level.FINER) && event instanceof KeyEvent) { if (focusLog.isLoggable(PlatformLogger.FINER) && event instanceof KeyEvent) {
focusLog.log(Level.FINER, " focus owner is {0}", focusLog.finer(" focus owner is {0}",
new Object[] {String.valueOf(manager.getGlobalFocusOwner())}); String.valueOf(manager.getGlobalFocusOwner()));
focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)}); focusLog.finer(">>> {0}", String.valueOf(event));
} }
} }
@ -2946,9 +2945,9 @@ public abstract class KeyboardFocusManager
} }
} }
static void removeLastFocusRequest(Component heavyweight) { static void removeLastFocusRequest(Component heavyweight) {
if (log.isLoggable(Level.FINE)) { if (log.isLoggable(PlatformLogger.FINE)) {
if (heavyweight == null) { if (heavyweight == null) {
log.log(Level.FINE, "Assertion (heavyweight != null) failed"); log.fine("Assertion (heavyweight != null) failed");
} }
} }