Undoable Property Sheet
By Geertjan-Oracle on May 23, 2013
Sometimes there's a need to integrate undo/redo functionality into the NetBeans Properties window. In other words, when the user types something in the Properties window, and presses Enter, you want the "Undo" action to become enabled, and later the "Redo" after you've undone the change.
Tim Boudreau once sent me, quite some time ago, a module that adds this behavior to the Properties window. About his solution, Tim wrote:
The solution consists of replacing the property sheet window with a custom one, which wraps every node in a FilterNode with properties which proxy the original and write them into a global undo/redo manager; and replace the standard undo/redo actions with ones which work over that global manager. The nice thing is that this will work over any node, without any changes to the nodes or their properties (within limits - if you have a property which is, say, a number that can only ever be increased, undoing such a change might fail - but that's a pretty rare situation).
It's still useful without the replacement undo/redo actions and without the global undo/redo manager, it just means that you have to give the property sheet window focus if you want to undo/redo (which may or may not be intuitive, but it's the way the window system works).
Here you see the solution in action in the Movie Analyzer example that was used at a NetBeans Platform Training held at MIT:
And this is where you can find the above sample, i.e., it includes Tim's Undoable Property Sheet:
Adding a Savable to it would be the next step so that the Save action is enabled when the user changes a property in the Properties window.