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 32744
Collapse All | Expand All

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

Return to bug 32744