This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 33205
Collapse All | Expand All

(-)AbstractNode.java (-34 / +1 lines)
Lines 447-471 Link Here
447
        return NO_NEW_TYPES;
447
        return NO_NEW_TYPES;
448
    }
448
    }
449
449
450
     private static final WeakHashMap overridesGetDefaultAction = new WeakHashMap (27);
451
    /** Checks whether subclass overrides a method
452
     */
453
    private boolean overridesAMethod (String name, Class[] arguments) {
454
        // we are subclass of AbstractNode
455
        try {
456
            java.lang.reflect.Method m = getClass ().getMethod (name, arguments);
457
458
            if (m.getDeclaringClass () != AbstractNode.class) {
459
                // ok somebody overriden the method
460
                return true;
461
            }
462
        } catch (NoSuchMethodException ex) {
463
            org.openide.ErrorManager.getDefault().notify(ex);
464
        }
465
        
466
        return false;
467
    }
468
    
469
   /** Gets preferred action.
450
   /** Gets preferred action.
470
     * By default, null.
451
     * By default, null.
471
     * @return preferred action
452
     * @return preferred action
Lines 473-493 Link Here
473
     * @since 3.29
454
     * @since 3.29
474
     */
455
     */
475
    public Action getPreferredAction() {
456
    public Action getPreferredAction() {
476
         boolean delegate = false;
457
         return preferredAction;
477
         
478
         Class c = getClass ();
479
         if (c != AbstractNode.class) {
480
             synchronized (overridesGetDefaultAction) {
481
                 Boolean b = (Boolean)overridesGetDefaultAction.get (c);
482
                 if (b == null) {
483
                     b = overridesAMethod ("getDefaultAction", new Class[0] ) ? Boolean.TRUE : Boolean.FALSE; // NOI18N
484
                     overridesGetDefaultAction.put (c, b);
485
                 }
486
                 delegate = b.booleanValue();
487
             }
488
         }
489
         
490
         return delegate ? getDefaultAction () : preferredAction;
491
    }
458
    }
492
    
459
    
493
    
460
    

Return to bug 33205