Undoable Property Sheet

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:

https://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/MovieAnalyzer

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.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

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.

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today