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.

Bug 193182 - Multiview's is broken: Shortcuts for undo/redo not working in GUI builder
Summary: Multiview's is broken: Shortcuts for undo/redo not working in GUI builder
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.0
Hardware: PC Windows Vista
: P2 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-09 17:53 UTC by Tomas Pavek
Modified: 2011-02-24 05:36 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Pavek 2010-12-09 17:53:06 UTC
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.
Comment 1 Jaroslav Tulach 2011-01-08 18:38:02 UTC
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.
Comment 2 Stanislav Aubrecht 2011-01-10 11:35:36 UTC
core-main 9cd5be3f5adc
Comment 3 Quality Engineering 2011-01-11 06:10:16 UTC
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
Comment 4 Tomas Pavek 2011-01-31 16:37:07 UTC
Does the fix really work for you? Now (20110131) I see Undo/Redo actions completely disabled in the GUI Builder...
Comment 5 Tomas Pavek 2011-01-31 17:42:10 UTC
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.
Comment 6 Stanislav Aubrecht 2011-02-01 13:17:01 UTC
passing back to jarda
Comment 7 Jaroslav Tulach 2011-02-17 12:56:02 UTC
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.
Comment 8 Stanislav Aubrecht 2011-02-21 14:09:31 UTC
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
Comment 9 Tomas Pavek 2011-02-21 18:27:15 UTC
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.
Comment 11 Quality Engineering 2011-02-24 05:36:37 UTC
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