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.
Build 200412011810 (RC2) 1) Create new userdir, new JavaProject, edit Main.java 2) Add a property (private int value;) 3) Invoke context menu on 'value' | Refactoring ERROR: 'Encapsulate Fields' disabled. 4) Invoke refactoring context menu on 'main' (method name) ERROR: 'Encapsulate Fields' enabled 5) Repeat 3,4 ... same wrong 'Encapsulate Fields' enabled/disabled state. Notice: similar with 'Move Class' action in menu on a property vs. in class definition.
Enable/disable state of the refactoring action is controlled by the active node (for performance reasons). Setting of active nodes is delayed by design (in java module) - there is a 200ms timeout. I don't think this is a P2, since an easy workaround exists (just wait a little more time). We should redesign the actions so that they would be always enabled. This would solve the problem. It is too expensive to compute enabling/disabling of the action immediately based on the cursor position. Reassigning to Dusan to come up with a consistent scheme for disabling and enabling actions, since we already have other issues filed for various inconsistencies in this behavior.
I don't see any waiting 200ms workaround - the only workaround is close the context menu and open it again (quite painful). Opening/focusing only other context submenu (e.g. 'Go To') doesn't help too. Did I miss something?
You need to wait *before* you open the menu. You can see in the navigation view what node is active - when it switches the active node, you are safe to assume that the active node was set.
Rudolfe, please evaluate. Thanks
*** Issue 53434 has been marked as a duplicate of this issue. ***
I have also noticed that once the encapsulate is enabled if you move the mouse sometimes the option will still not be enabled and depending on where you are in the file it may or may not be enabled.
Should be fixed together with issue 40390
Checking in org/netbeans/modules/refactoring/ui/ChangeParametersAction.java; /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/ChangeParametersAction.java,v <-- ChangeParametersAction.java new revision: 1.13; previous revision: 1.12 done Checking in org/netbeans/modules/refactoring/ui/EncapsulateFieldAction.java; /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/EncapsulateFieldAction.java,v <-- EncapsulateFieldAction.java new revision: 1.11; previous revision: 1.10 done Checking in org/netbeans/modules/refactoring/ui/MoveClassAction.java; /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/MoveClassAction.java,v <-- MoveClassAction.java new revision: 1.13; previous revision: 1.12 done
Verified. Encapsulate Fields action is still enabled.