I am adding a event listener to my Singleton class. I am adding the listener in a add method.
public void add(TCComponentItemRevision tcRevision, TCComponentDataset selectedDataset) {
String revMasterForm;
tcRevision.getSession().addAIFComponentEventListener(this);
try {
revMasterForm = tcRevision.getRelatedComponent("IMAN_master_form_rev").getUid();
RevDataset pp = new RevDataset(tcRevision, selectedDataset, revMasterForm);
if (!rds.contains(pp)) {
rds.add(pp);
}
}
catch (TCException e) {
e.printStackTrace();
}
fireTableDataChanged();
}
I only want the lister to be adding once. So I figure there has to be some sort of a check.
something like
if (listener value == null) {
tcRevision.getSession().addAIFComponentEventListener(this);
}
But I am not sure how to get the listener value?
I don’t know what is the
TCComponentItemRevisionclass but since this code is inside a Sigleton anyway you could use aboolean addedListenerinside the Sigleton to check if the listener has been added: