use of org.eclipse.ui.texteditor.StatusLineContributionItem in project gda-core by openGDA.
the class ApplicationActionBarAdvisor method fillStatusLine.
@Override
protected void fillStatusLine(IStatusLineManager manager) {
StatusLineContributionItem buildLogStatus = buildLogStatus();
manager.add(buildLogStatus);
LinkContributionItem batonStatus = buildBatonStatus();
manager.add(batonStatus);
StatusLineContributionItem scanStatus = buildScanStatus();
manager.add(scanStatus);
StatusLineContributionItem scriptStatus = buildScriptStatus();
manager.add(scriptStatus);
if (!LocalProperties.check(GDA_GUI_STATUS_HIDE_STOP_ALL)) {
LinkContributionItem stopAllButton = createStopAllButton();
if (LocalProperties.check(GDA_GUI_FORCE_LEFT_STOP_ALL)) {
manager.insertBefore(buildLogStatus.getId(), stopAllButton);
} else {
manager.add(stopAllButton);
}
// Add a bit of space after the button so it is not too close to the end marker
StatusLineContributionItem spacer = new StatusLineContributionItem("uk.ac.diamond.daq.stopall.spacer", true, 0);
manager.insertAfter(stopAllButton.getId(), spacer);
}
addQueueStatusContribution(manager);
IJythonServerStatusObserver serverObserver = (theObserved, changeCode) -> {
if (changeCode instanceof BatonChanged) {
updateBatonStatus(batonStatus);
} else if (changeCode instanceof JythonServerStatus) {
updateScriptStatus(scriptStatus, (JythonServerStatus) changeCode);
} else if (changeCode instanceof ScanEvent) {
updateScanDetails(scanStatus, (ScanEvent) changeCode);
}
};
// If throw exception from fillStatusLine(...) whole client fails.
try {
InterfaceProvider.getJSFObserver().addIObserver(serverObserver);
InterfaceProvider.getScanDataPointProvider().addScanEventObserver(serverObserver);
updateBatonStatus(batonStatus);
JythonServerFacade jsf = JythonServerFacade.getInstance();
JythonServerStatus jythonServerStatus = jsf.getServerStatus();
updateScanStatus(scanStatus, jythonServerStatus);
updateScriptStatus(scriptStatus, jythonServerStatus);
} catch (Exception ne) {
logger.error("Cannot connect to JythonServerFacade", ne);
Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Cannot Connect to GDA Server", "The GDA Server is not responding.\n\nPlease contact your GDA support engineer."));
}
ApplicationWorkbenchAdvisor.addCleanupWork(() -> InterfaceProvider.getJSFObserver().deleteIObserver(serverObserver));
}
use of org.eclipse.ui.texteditor.StatusLineContributionItem 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;
}
use of org.eclipse.ui.texteditor.StatusLineContributionItem in project gda-core by openGDA.
the class ApplicationActionBarAdvisor method buildLogStatus.
private StatusLineContributionItem buildLogStatus() {
StatusLineContributionItem logStatus = new StatusLineContributionItem("GDA-LoggedInUser", true, 15);
logStatus.setText(UserAuthentication.getUsername());
logStatus.setImage(GdaImages.getImage("user_gray.png"));
return logStatus;
}
Aggregations