开发者

NetBeans Platform - how to get a callback when a property begins / ends editing

In my domain I have objects that are constantly being updated by a separate process, and I want a PropertySheetView to display the changing properties. The current implementation is set up such that the underlying domain model object is immutable, and thus when it changes, there is a new object published with a corresponding ID. At that point, my Node wrapping the object has subscribed, gets the updated object with a matching ID, and recreates the Sheet (via createSheet()) and calls setSheet with the updated information. This works fine at always showing the most recent version of the domain model object.

However, some of the properties are not read-only, but instead can be set. I would like to lock the sheet from being updated / overwritten, on either a row or sheet basis, while a property is being edited. In order to do this I need to listen for edit start and end calls so I can know when it's safe to update the sheet again.

This is crucial for my application; as it stands now you can't get through entering a new value before the sheet is refreshed and your edit goes away.

If it matters, I'm using a custom PropertyEditorSupport, but the default InplaceEditor.

I've done a lot of searching through the NetBeans source and I don't see any exposed API settings to listen for this stuff.

SheetCellEditor (org.openide.explorer.propertysheet) exposes an addCellEditorListener method, but A) I can't figure out how I would get a handle on the SheetCellEditor instance, and B) the methods exposed by SheetCellEditor are editingCanceled and editingStopped - there is no callback for editing started! Seems very silly. The SheetTable and BaseTable would expose this property too, as they extend JTable, but I cannot figure out how to get a handle to them either.

I notice that the CellEditor interface requires the method isCellEditable(), which supposedly returns true if the cell can be edited, and thus the editing begins. But again, this is implemented开发者_运维百科 by the SheetCellEditor which is not a public class, and I don't know how to get a reference to it.

Thank you for your help.


The best solution I could come up with was as follows:

Create a custom property editor. Make that editor implement InplaceEditor. Return a StringInplaceEditor which is a textfield. Attach a focus listener to that textfield. When focus is in the text field, it is being edited. Otherwise it is not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜