Search in sources :

Example 1 with StatusLineContributionItem

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));
}
Also used : StatusLineContributionItem(org.eclipse.ui.texteditor.StatusLineContributionItem) ServiceHolder(org.eclipse.scanning.event.ui.ServiceHolder) IJythonServerStatusObserver(gda.jython.IJythonServerStatusObserver) ContributionItemFactory(org.eclipse.ui.actions.ContributionItemFactory) WorkbenchPlugin(org.eclipse.ui.internal.WorkbenchPlugin) GdaImages(gda.rcp.views.GdaImages) JythonServerFacade(gda.jython.JythonServerFacade) InterfaceProvider(gda.jython.InterfaceProvider) URISyntaxException(java.net.URISyntaxException) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) LoggerFactory(org.slf4j.LoggerFactory) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) IToolBarManager(org.eclipse.jface.action.IToolBarManager) Workbench(org.eclipse.ui.internal.Workbench) Queue(gda.commandqueue.Queue) IBeanListener(org.eclipse.scanning.api.event.bean.IBeanListener) IActionBarConfigurer2(org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2) URI(java.net.URI) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) IExtension(org.eclipse.core.runtime.IExtension) LocalProperties(gda.configuration.properties.LocalProperties) Separator(org.eclipse.jface.action.Separator) PlatformUI(org.eclipse.ui.PlatformUI) GDA_GUI_STOP_ALL_COMMAND_ID(gda.configuration.properties.LocalProperties.GDA_GUI_STOP_ALL_COMMAND_ID) MenuManager(org.eclipse.jface.action.MenuManager) IActionSetDescriptor(org.eclipse.ui.internal.registry.IActionSetDescriptor) JythonServerStatus(gda.jython.JythonServerStatus) Display(org.eclipse.swt.widgets.Display) ClientDetails(gda.jython.batoncontrol.ClientDetails) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) GroupMarker(org.eclipse.jface.action.GroupMarker) IActionBarConfigurer(org.eclipse.ui.application.IActionBarConfigurer) MouseEvent(org.eclipse.swt.events.MouseEvent) ISharedImages(org.eclipse.ui.ISharedImages) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IObserver(gda.observable.IObserver) SWT(org.eclipse.swt.SWT) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GDA_GUI_STATUS_HIDE_STOP_ALL(gda.configuration.properties.LocalProperties.GDA_GUI_STATUS_HIDE_STOP_ALL) IEventService(org.eclipse.scanning.api.event.IEventService) BatonChanged(gda.jython.batoncontrol.BatonChanged) BatonView(uk.ac.gda.views.baton.BatonView) GDA_GUI_FORCE_LEFT_STOP_ALL(gda.configuration.properties.LocalProperties.GDA_GUI_FORCE_LEFT_STOP_ALL) UserAuthentication(gda.jython.authenticator.UserAuthentication) ProcessorCurrentItem(gda.commandqueue.ProcessorCurrentItem) Image(org.eclipse.swt.graphics.Image) RateLimiter(com.google.common.util.concurrent.RateLimiter) IWorkbenchHelpContextIds(org.eclipse.ui.internal.IWorkbenchHelpContextIds) LinkContributionLabel(uk.ac.gda.ui.status.LinkContributionLabel) IntroDescriptor(org.eclipse.ui.internal.intro.IntroDescriptor) ICoolBarManager(org.eclipse.jface.action.ICoolBarManager) ScanEvent(gda.scan.ScanEvent) IWorkbenchActionConstants(org.eclipse.ui.IWorkbenchActionConstants) StatusBean(org.eclipse.scanning.api.event.status.StatusBean) IActionCommandMappingService(org.eclipse.ui.internal.handlers.IActionCommandMappingService) StatusLineContributionItem(org.eclipse.ui.texteditor.StatusLineContributionItem) IDEWorkbenchMessages(org.eclipse.ui.internal.ide.IDEWorkbenchMessages) Logger(org.slf4j.Logger) WorkbenchMessages(org.eclipse.ui.internal.WorkbenchMessages) ActionSetRegistry(org.eclipse.ui.internal.registry.ActionSetRegistry) Action(org.eclipse.jface.action.Action) LinkContributionButton(uk.ac.gda.ui.status.LinkContributionButton) ActionBarAdvisor(org.eclipse.ui.application.ActionBarAdvisor) JythonStatus(gda.jython.JythonStatus) CommandQueueViewFactory(uk.ac.gda.client.CommandQueueViewFactory) ISubscriber(org.eclipse.scanning.api.event.core.ISubscriber) EventException(org.eclipse.scanning.api.event.EventException) IMenuManager(org.eclipse.jface.action.IMenuManager) Processor(gda.commandqueue.Processor) EventConstants(org.eclipse.scanning.api.event.EventConstants) LinkContributionItem(uk.ac.gda.ui.status.LinkContributionItem) IContributionItem(org.eclipse.jface.action.IContributionItem) ActionFactory(org.eclipse.ui.actions.ActionFactory) IJythonServerStatusObserver(gda.jython.IJythonServerStatusObserver) ScanEvent(gda.scan.ScanEvent) LinkContributionItem(uk.ac.gda.ui.status.LinkContributionItem) BatonChanged(gda.jython.batoncontrol.BatonChanged) JythonServerStatus(gda.jython.JythonServerStatus) URISyntaxException(java.net.URISyntaxException) EventException(org.eclipse.scanning.api.event.EventException) JythonServerFacade(gda.jython.JythonServerFacade)

Example 2 with StatusLineContributionItem

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;
}
Also used : StatusLineContributionItem(org.eclipse.ui.texteditor.StatusLineContributionItem) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) EventException(org.eclipse.scanning.api.event.EventException) IEventService(org.eclipse.scanning.api.event.IEventService) IBeanListener(org.eclipse.scanning.api.event.bean.IBeanListener) URISyntaxException(java.net.URISyntaxException) EventException(org.eclipse.scanning.api.event.EventException)

Example 3 with StatusLineContributionItem

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;
}
Also used : StatusLineContributionItem(org.eclipse.ui.texteditor.StatusLineContributionItem)

Aggregations

StatusLineContributionItem (org.eclipse.ui.texteditor.StatusLineContributionItem)3 URISyntaxException (java.net.URISyntaxException)2 EventException (org.eclipse.scanning.api.event.EventException)2 IEventService (org.eclipse.scanning.api.event.IEventService)2 IBeanListener (org.eclipse.scanning.api.event.bean.IBeanListener)2 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)2 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 Processor (gda.commandqueue.Processor)1 ProcessorCurrentItem (gda.commandqueue.ProcessorCurrentItem)1 Queue (gda.commandqueue.Queue)1 LocalProperties (gda.configuration.properties.LocalProperties)1 GDA_GUI_FORCE_LEFT_STOP_ALL (gda.configuration.properties.LocalProperties.GDA_GUI_FORCE_LEFT_STOP_ALL)1 GDA_GUI_STATUS_HIDE_STOP_ALL (gda.configuration.properties.LocalProperties.GDA_GUI_STATUS_HIDE_STOP_ALL)1 GDA_GUI_STOP_ALL_COMMAND_ID (gda.configuration.properties.LocalProperties.GDA_GUI_STOP_ALL_COMMAND_ID)1 IJythonServerStatusObserver (gda.jython.IJythonServerStatusObserver)1 InterfaceProvider (gda.jython.InterfaceProvider)1 JythonServerFacade (gda.jython.JythonServerFacade)1 JythonServerStatus (gda.jython.JythonServerStatus)1 JythonStatus (gda.jython.JythonStatus)1 UserAuthentication (gda.jython.authenticator.UserAuthentication)1