To enable the monitor, the "Usage Statistics" view must be opened. Statistics and the usage log are gathered to the two corresponding files in the workspace root. If the "link" button is pressed the statistics will be updated live in the view as well.
To extend the monitor extend the ca.ubc.mylar.monitor.MylarMonitor class and implement the abstract methods. For example, to log every distinct IJavaElement selected do the following:
public void handleElementSelection(IJavaElement
selected, IJavaElement lastSelected, IJavaElement lastResolved) {
if (!selected.equals(lastSelected)) {
MonitorPlugin.log("IJavaElement selected: " + selected.getElementName());
}
}
Now you need to register your monitor by calling:
MonitorPlugin.getDefault().getMonitors().add(new MyNewMonitor());