UndoRedo on Nodes (Part 2)

After the recording of the latest API Design Tip for the upcoming NetBeans Podcast, Jaroslav Tulach helped me with the problem I blogged about yesterday. First he expressed surprise at seeing Undo/Redo work on Nodes, which was never the intention, i.e., that feature was always intended for documents, e.g., the Java editor.

However, he then showed me where to find the Properties window in the NetBeans sources, where it is org.netbeans.core.windows.view.ui.NbSheet. It turns out that the Properties window does not have an activated node and hence the Node that implements UndoRedo.Provider is never put in the Lookup. Once we added, on line 303, "this.setActivatedNodes(nodes);", everything worked as expected, i.e., the Undo/Redo actions are now enabled, even when the Properties window is selected:

Maybe it means I should file an issue to get that line added to NbSheet?


We cannot just call setActivatedNodes in NbSheet, that would not be compatible. But we may design some contract where Node(s) will be able to tell the NbSheet that it should change its activated nodes.

Maybe Boolean.TRUE.equals(node.getValue("exposeInGlobalSheet"))

Feel free to pass API review with such change.

Posted by Jaroslav Tulach on November 24, 2011 at 09:10 PM PST #

Compatible for whom?

The reason NbSheet does not already set its own node selection is that it could introduce some kind of cycle - it is after all trying to track the activate nodes of other components.

Anyway it is unnecessary because the problem is in the toolbar button, not the property sheet. An action marked surviveFocusChange=true will continue to work naturally even when some component with no node selection (*), such as the property sheet or the output window, is activated.

(*) No selection is distinct from a selection containing zero nodes.

Posted by Jesse Glick on November 28, 2011 at 04:44 AM PST #

Following up on this excellent blog and Jesse's reply, how do I make the command associated with the global "Undo" button in the toolbar "surviveFocusChange"? I'm using Netbeans 7.0.1.

Thanks much,

Posted by Ayman Habib on September 17, 2012 at 02:53 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« July 2016