简体   繁体   中英

PropertyChangeSupport in SWT. How to listen for notifications e.g. in a Table?

Using Jfaces components I want to know how to detect if the UI control has been changed by the user.
I have seen that there is the interface PropertyChangeSupport where you can register a PropertyChangeListener but I can not figure out how to use these in an SWT application.
For example I have the following class for my data model.

class Person{  
   String firstName;  
   String lastName;  
   String address;  
   //etc  

}  

This represents essentially a row in an SWT Table (the LabelProvider will make a row object to be Person ).
I assume that the class person should have a PropertyChangeSupport member variable for the changes, but I can not figure out who registers for notifications?
The ViewPart ? The LabelProvider ? Something else?
Any help clearing this out?

Vogella has two very good tutorials on this topic.

This explains how to set up your data structure and include the PropertyChangeSupport (however, it is not used in this turorial). An easy method to update your viewer is viewer.refresh() . This would have to be called manually.

This tutorial shows how to use DataBinding (and finally use the PropertyChangeSupport ) which will notify the listener when change occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM