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.
Do whatever change in a GUI form, and while the designer TopComponent is active and has focus, try to press Ctrl-Z to undo. It does nothing, just beeps. At the same moment the Undo action is enabled in toolbar/main menu and works properly. Looks like a context aware instance of UndoRedoAction is created in TopComponent.processKeyBinding with lookup from the TopComponent - but in this case (FormDesigner) the lookup does not contain UndoRedo.Provider, and the created action instance gets disabled. TopComponent has getUndoRedo() method, so it is a bit strange it can't make the context UndoRedoAction work on itself. I guess this is happening since UndoRedo.Provider introduction in June.
Stando, I am looking at 7ac2745d4c90, especially: TopComponent's: if( delegate.isEnabled() || getActivatedNodes() != null ) I am not really sure if this follows the subject of the changeset "ContextAwareActions should be enabled if the TopComponent has null activated nodes and the action survives focus changes". The condition looks way different. As a result the action delegate is disabled, but it still gets selected to represent action for Ctrl-Z. When Ctrl-Z is pressed, the system then just beeps, as the delegate is disabled. I admit, the problems are caused by UndoRedo.Provider as Tomáš suggests, but if I change the condition things start to work: # This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -1115,7 +1115,7 @@ if (action instanceof ContextAwareAction) { Action delegate = ((ContextAwareAction) action).createContextAwareInstance(getLookup()); assert delegate != null : "ContextAwareAction cannot return null: " + action; - if( delegate.isEnabled() || getActivatedNodes() != null ) + if( delegate.isEnabled() && getActivatedNodes() == null ) action = delegate; //else // use the global instance which might be enabled if it can survive focus changes Please evaluate and consider my patch.
core-main 9cd5be3f5adc
Integrated into 'main-golden', will be available in build *201101110000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/9cd5be3f5adc User: S. Aubrecht <saubrecht@netbeans.org> Log: #193182 - use context aware actions only if the action is enabled and activated nodes or non-null
Does the fix really work for you? Now (20110131) I see Undo/Redo actions completely disabled in the GUI Builder...
Actually the undo/redo is disabled only until another window is activated. I.e. when opening a form and moving components, undo/redo is disabled. Then switching to Properties or Palette and back to designer makes the actions enabled.
passing back to jarda
I've put breakpoint into openide.actions/**/UndoRedoAction.java's stateChanged and propertyChange methods. As soon as form is shown, the propertyChange method is called and listener is properly attached to the UndoRedo (which comes from core.multiview). However regardless of any changes I make in the formeditor, no state change event is delivered. I counclude that core.multiview's DelegateUndoRedo is broken. I don't have a unit test to prove that, however.
undo/redo shortcuts seem to be working fine in this configuration: Product Version: NetBeans IDE Dev (Build 110221-9ab76d1a9547) Java: 1.6.0_23; Java HotSpot(TM) 64-Bit Server VM 19.0-b09 System: Windows 7 version 6.1 running on amd64; Cp1250; cs_CZ (nb) Userdir: D:\hg\core-main\nbbuild\testuserdir please provide exact steps to reproduce and reopen, thanks
I can still reproduce in current builds, just open a GUI form that contains some components and right after opening drag a component. Undo/redo is disabled. But I think it can be fixed in GUI builder. The problem is much likely that when FormDesigner is called getUndoRedo() for the first time (after activated on opening), it is not yet loaded and so returns null. It gets one later, but there's no way the undo redo action can know that and ask again - until the window is activated again.
http://hg.netbeans.org/core-main/rev/42492b43632f
Integrated into 'main-golden', will be available in build *201102240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/42492b43632f User: Tomas Pavek <tpavek@netbeans.org> Log: #193182: add UndoRedo to lookup when form is loaded