How to know is a molecule has been modified in Marvin?

User 818520b6b8

22-03-2005 11:53:48

Hi,





is there any way to know if a molecule has been edited or changed?





I show the molecule in Marvin View, double-click on it so it opens Marvin Sketch, modify it, close Sketch so it returns to Marvin View, and when I close Marvin View I want to save the molecule in database only if it changed.





At the moment I'm saving it always, but I don't want to save it if user didn't make any change.





Thanks.

ChemAxon 7c2d26e5cf

24-03-2005 13:27:06

You should listen PropertyChangeEvents in MViewPane. The "mol0" property indicates the structure has been changed in the viewer.


Code:



MViewPane viewPane;


...


viewPane.addPropertyChangeListener(this);


...





public void propertyChange(PropertyChangeEvent ev) {


    String name = ev.getPropertyName();


    if(name.equals("mols0")) {


        // do something


    }


}






I suggest to look at the following example in the Marvin Beans package that demonstrates how to handle PropertyChangeEvents.


examples/view-events/ViewEventTest.java