< prev index next >

src/share/classes/java/awt/KeyboardFocusManager.java

Print this page
rev 1571 : 8010297: Missing isLoggable() checks in logging code
Summary: Add isLoggable() checks
Reviewed-by: anthony, mchung, serb
Contributed-by: Laurent Bourges <bourges.laurent@gmail.com>


2366                                                 temporary, cause);
2367                 heavyweightRequests.add(hwFocusRequest);
2368 
2369                 if (currentFocusOwner != null) {
2370                     FocusEvent currentFocusOwnerEvent =
2371                         new CausedFocusEvent(currentFocusOwner,
2372                                        FocusEvent.FOCUS_LOST,
2373                                        temporary, descendant, cause);
2374                     // Fix 5028014. Rolled out.
2375                     // SunToolkit.postPriorityEvent(currentFocusOwnerEvent);
2376                     SunToolkit.postEvent(currentFocusOwner.appContext,
2377                                          currentFocusOwnerEvent);
2378                 }
2379                 FocusEvent newFocusOwnerEvent =
2380                     new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED,
2381                                    temporary, currentFocusOwner, cause);
2382                 // Fix 5028014. Rolled out.
2383                 // SunToolkit.postPriorityEvent(newFocusOwnerEvent);
2384                 SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
2385 
2386                 if (focusLog.isLoggable(Level.FINEST))
2387                     focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", String.valueOf(descendant));

2388                 return SNFH_SUCCESS_HANDLED;
2389             } else if (hwFocusRequest != null &&
2390                        hwFocusRequest.heavyweight == heavyweight) {
2391                 // 'heavyweight' doesn't have the native focus right now, but
2392                 // if all pending requests were completed, it would. Add
2393                 // descendant to the heavyweight's list of pending
2394                 // lightweight focus transfers.
2395                 if (hwFocusRequest.addLightweightRequest(descendant,
2396                                                          temporary, cause)) {
2397                     manager.enqueueKeyEvents(time, descendant);
2398                 }
2399 
2400                 if (focusLog.isLoggable(Level.FINEST))
2401                     focusLog.finest("3. SNFH_HANDLED for lightweight" +
2402                                     descendant + " in " + heavyweight);

2403                 return SNFH_SUCCESS_HANDLED;
2404             } else {
2405                 if (!focusedWindowChangeAllowed) {
2406                     // For purposes of computing oldFocusedWindow, we should look at
2407                     // the second to last HeavyweightFocusRequest on the queue iff the
2408                     // last HeavyweightFocusRequest is CLEAR_GLOBAL_FOCUS_OWNER. If
2409                     // there is no second to last HeavyweightFocusRequest, null is an
2410                     // acceptable value.
2411                     if (hwFocusRequest ==
2412                         HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER)
2413                     {
2414                         int size = heavyweightRequests.size();
2415                         hwFocusRequest = (HeavyweightFocusRequest)((size >= 2)
2416                             ? heavyweightRequests.get(size - 2)
2417                             : null);
2418                     }
2419                     if (focusedWindowChanged(heavyweight,
2420                                              (hwFocusRequest != null)
2421                                              ? hwFocusRequest.heavyweight
2422                                              : nativeFocusedWindow)) {
2423                         if (focusLog.isLoggable(Level.FINEST))
2424                             focusLog.finest("4. SNFH_FAILURE for " + descendant);

2425                         return SNFH_FAILURE;
2426                     }
2427                 }
2428 
2429                 manager.enqueueKeyEvents(time, descendant);
2430                 heavyweightRequests.add
2431                     (new HeavyweightFocusRequest(heavyweight, descendant,
2432                                                  temporary, cause));
2433                 if (focusLog.isLoggable(Level.FINEST))
2434                     focusLog.finest("5. SNFH_PROCEED for " + descendant);

2435                 return SNFH_SUCCESS_PROCEED;
2436             }
2437         }
2438     }
2439     static void heavyweightButtonDown(Component heavyweight, long time) {
2440         heavyweightButtonDown(heavyweight, time, false);
2441     }
2442     static void heavyweightButtonDown(Component heavyweight, long time, boolean acceptDuplicates) {
2443         if (log.isLoggable(Level.FINE)) {
2444             if (heavyweight == null) {
2445                 log.log(Level.FINE, "Assertion (heavyweight != null) failed");
2446             }
2447             if (time == 0) {
2448                 log.log(Level.FINE, "Assertion (time != 0) failed");
2449             }
2450         }
2451         KeyboardFocusManager manager = getCurrentKeyboardFocusManager(SunToolkit.targetToAppContext(heavyweight));
2452 
2453         synchronized (heavyweightRequests) {
2454             HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();




2366                                                 temporary, cause);
2367                 heavyweightRequests.add(hwFocusRequest);
2368 
2369                 if (currentFocusOwner != null) {
2370                     FocusEvent currentFocusOwnerEvent =
2371                         new CausedFocusEvent(currentFocusOwner,
2372                                        FocusEvent.FOCUS_LOST,
2373                                        temporary, descendant, cause);
2374                     // Fix 5028014. Rolled out.
2375                     // SunToolkit.postPriorityEvent(currentFocusOwnerEvent);
2376                     SunToolkit.postEvent(currentFocusOwner.appContext,
2377                                          currentFocusOwnerEvent);
2378                 }
2379                 FocusEvent newFocusOwnerEvent =
2380                     new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED,
2381                                    temporary, currentFocusOwner, cause);
2382                 // Fix 5028014. Rolled out.
2383                 // SunToolkit.postPriorityEvent(newFocusOwnerEvent);
2384                 SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
2385 
2386                 if (focusLog.isLoggable(Level.FINEST)) {
2387                     focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", String.valueOf(descendant));
2388                 }
2389                 return SNFH_SUCCESS_HANDLED;
2390             } else if (hwFocusRequest != null &&
2391                        hwFocusRequest.heavyweight == heavyweight) {
2392                 // 'heavyweight' doesn't have the native focus right now, but
2393                 // if all pending requests were completed, it would. Add
2394                 // descendant to the heavyweight's list of pending
2395                 // lightweight focus transfers.
2396                 if (hwFocusRequest.addLightweightRequest(descendant,
2397                                                          temporary, cause)) {
2398                     manager.enqueueKeyEvents(time, descendant);
2399                 }
2400 
2401                 if (focusLog.isLoggable(Level.FINEST)) {
2402                     focusLog.finest("3. SNFH_HANDLED for lightweight" +
2403                                     descendant + " in " + heavyweight);
2404                 }
2405                 return SNFH_SUCCESS_HANDLED;
2406             } else {
2407                 if (!focusedWindowChangeAllowed) {
2408                     // For purposes of computing oldFocusedWindow, we should look at
2409                     // the second to last HeavyweightFocusRequest on the queue iff the
2410                     // last HeavyweightFocusRequest is CLEAR_GLOBAL_FOCUS_OWNER. If
2411                     // there is no second to last HeavyweightFocusRequest, null is an
2412                     // acceptable value.
2413                     if (hwFocusRequest ==
2414                         HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER)
2415                     {
2416                         int size = heavyweightRequests.size();
2417                         hwFocusRequest = (HeavyweightFocusRequest)((size >= 2)
2418                             ? heavyweightRequests.get(size - 2)
2419                             : null);
2420                     }
2421                     if (focusedWindowChanged(heavyweight,
2422                                              (hwFocusRequest != null)
2423                                              ? hwFocusRequest.heavyweight
2424                                              : nativeFocusedWindow)) {
2425                         if (focusLog.isLoggable(Level.FINEST)) {
2426                             focusLog.finest("4. SNFH_FAILURE for " + descendant);
2427                         }
2428                         return SNFH_FAILURE;
2429                     }
2430                 }
2431 
2432                 manager.enqueueKeyEvents(time, descendant);
2433                 heavyweightRequests.add
2434                     (new HeavyweightFocusRequest(heavyweight, descendant,
2435                                                  temporary, cause));
2436                 if (focusLog.isLoggable(Level.FINEST)) {
2437                     focusLog.finest("5. SNFH_PROCEED for " + descendant);
2438                 }
2439                 return SNFH_SUCCESS_PROCEED;
2440             }
2441         }
2442     }
2443     static void heavyweightButtonDown(Component heavyweight, long time) {
2444         heavyweightButtonDown(heavyweight, time, false);
2445     }
2446     static void heavyweightButtonDown(Component heavyweight, long time, boolean acceptDuplicates) {
2447         if (log.isLoggable(Level.FINE)) {
2448             if (heavyweight == null) {
2449                 log.log(Level.FINE, "Assertion (heavyweight != null) failed");
2450             }
2451             if (time == 0) {
2452                 log.log(Level.FINE, "Assertion (time != 0) failed");
2453             }
2454         }
2455         KeyboardFocusManager manager = getCurrentKeyboardFocusManager(SunToolkit.targetToAppContext(heavyweight));
2456 
2457         synchronized (heavyweightRequests) {
2458             HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();


< prev index next >