How to throw/catch events in geWorkbench
From Informatics
For example, you want to throw a project-node-added event inside AnalysisPanel.java, and catch that event inside ProjectPanel.java.
It means, ProjectPanel are interested in that project-node-added event, so who ever throw that event, ProjectPanel want to be notified.
And in this example, AnalysisPanel will be the one who throw the event.
in AnalysisPanel.java you'll need some code to tell geWorkbench that you'll probably need to publish event
@Publish public ProjectNodeAddedEvent publishProjectNodeAddedEvent( ProjectNodeAddedEvent event) { return event; }
in AnalysisPanel.java, when you want to publish that event, you use following line to create a event, and publish it.
ProjectNodeAddedEvent event = new ProjectNodeAddedEvent( "Analysis Result", null, dataSet); publishProjectNodeAddedEvent(event);
In ProjectPanel.java, you'll need to tell geWorkbench that you are interested in ProjectNodeAddedEvent by writing a subscribe/receive method
@Subscribe public void receive(org.geworkbench.events.ProjectNodeAddedEvent pnae, Object source) { }
To trace how this throw/catch event works, see How to trace events in geWorkbench