Creating Model Listener and accessing changes in Models inside Actions using Open API

I am writing an Action in Plugin to Listen changes in Models in Editor and call custom Java API. I am trying to use SModelListener but not sure how do I use this. Below is a sample code that I have written in Actions :
action TestAction {              
  mnemonic:<no mnemonic>        
  execute outside command: false
  also available in: << ... >>   
caption: Save Model            
  description: <no description>  
  icon: <no icon>        
  construction parameters        
    << ... >>     
  action context parameters ( always visible = false )         
    EditorContext context key: EDITOR_CONTEXT required         
    nlist<> nodes key: NODES required      
  <update block>  
  execute(event)->void {

  this.context.getModel().addModelListener();   // Not Sure what to give as Parameter

  additional methods  
  << ... >>      
}      Can Any one Help with any sample example or sample code or usage?

1 comment
Comment actions Permalink
You need to provide an SModelListener instance that will handle the model change notifications.
this.context.getModel().addModelListener(new SModelListener() {
  public void modelLoaded(SModel p0, boolean p1) {
    <no statements>
  public void modelReplaced(SModel p0) {
    <no statements>
  public void modelUnloaded(SModel p0) {
    <no statements>
  public void modelSaved(SModel p0) {
    <no statements>
  public void conflictDetected(SModel p0) {
    <no statements>
  public void problemsDetected(SModel p0, Iterable<SModel.Problem> p1) {
    <no statements>

Please sign in to leave a comment.