|
Hello everyone!
Give me advice. I use 2 TopComponents in 2 other modules. TopComponents contain the same field. I need to view and modify data in these TopComponents simultaneously. These modules can transmit and receive data from each other. So, I put Lookup and InstanceContent in these modules. Using LookupListener and InstanceContent in the same module is it ok? Or is there a better decision? Thank you for your help! |
|
> I use 2 TopComponents in 2 other modules.
> TopComponents contain the same field. I need to view and modify data > in these TopComponents simultaneously. > These modules can transmit and receive data from each other. > So, I put Lookup and InstanceContent in these modules. > > Using LookupListener and InstanceContent in the same module is it ok? > Or is there a better decision? One module needs to be the owner of the data. If neither TopComponent modules should be, you need a third module with some kind of data manager. You can put this data manager in the lookup so the TopComponents can get an instance. @ServiceProvider(service=SharedDataManager.class) public class MySharedDataManager implements SharedDataManager{ public static final String PROP_MY_DATA = "myData"; public void addPropertyChangeListener(.... public void submitDataChanges(MyData myData){ ... triggers property change public MyData getMyData(... ) The TopComponents can register a listener on the manager to be notified of changes and submit their changes back to the manager. You could also implement property change support on the MyData class in which case the manager could listen for changes and process them (or veto even if you want to implement some kind of locking mechanism) |
|
On 20 February 2012 13:47, Timon Veenstra <[hidden email]> wrote:
>> I use 2 TopComponents in 2 other modules. >> TopComponents contain the same field. I need to view and modify data >> in these TopComponents simultaneously. >> These modules can transmit and receive data from each other. >> So, I put Lookup and InstanceContent in these modules. >> >> Using LookupListener and InstanceContent in the same module is it ok? >> Or is there a better decision? > > One module needs to be the owner of the data. If neither TopComponent > modules should be, you need a third module with some kind of data > manager. > You can put this data manager in the lookup so the TopComponents can > get an instance. > > @ServiceProvider(service=SharedDataManager.class) > public class MySharedDataManager implements SharedDataManager{ > public static final String PROP_MY_DATA = "myData"; > public void addPropertyChangeListener(.... > public void submitDataChanges(MyData myData){ ... triggers property change > public MyData getMyData(... ) > > The TopComponents can register a listener on the manager to be > notified of changes and submit their changes back to the manager. > You could also implement property change support on the MyData class > in which case the manager could listen for changes and process them > (or veto even if you want to implement some kind of locking mechanism) I realised I chose wrong way. Thank you, Timon. |
| Powered by Nabble | See how NAML generates this page |
