use of org.eclipse.scanning.api.event.bean.IBeanListener in project gda-core by openGDA.
the class ApplicationActionBarAdvisor method buildScanStatus.
private StatusLineContributionItem buildScanStatus() {
StatusLineContributionItem scanStatus = new StatusLineContributionItem("GDA-ScanStatus", true, 55);
IEventService service = ServiceHolder.getEventService();
try {
ISubscriber<IBeanListener<StatusBean>> statusTopicSubscriber = service.createSubscriber(getActiveMqUri(), EventConstants.STATUS_TOPIC);
statusTopicSubscriber.addListener(event -> {
if (event.getBean() instanceof ScanBean) {
updateScanDetails(scanStatus, (ScanBean) event.getBean());
}
});
ApplicationWorkbenchAdvisor.addCleanupWork(() -> {
try {
statusTopicSubscriber.removeAllListeners();
statusTopicSubscriber.close();
} catch (EventException e1) {
logger.error("Error removing listener from STATUS_TOPIC", e1);
}
});
} catch (NullPointerException e) {
// Handling for non-StatusQueueView/Mapping beamlines, prevent stack trace being printed to console
if (service == null) {
logger.warn("EventService null when adding listener to STATUS_TOPIC, ScanBean status bar progress disabled. If this beamline uses the Queue, this will cause errors elsewhere");
} else {
throw e;
}
} catch (Exception e2) {
logger.error("Error adding listener to STATUS_TOPIC", e2);
}
return scanStatus;
}
Aggregations