Search in sources :

Example 1 with CyJobMonitor

use of org.cytoscape.jobs.CyJobMonitor in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    // See if we have a graphics console or not
    ServiceReference ref = bc.getServiceReference("org.cytoscape.application.swing.CySwingApplication");
    CyJobManagerImpl jobManager = new CyJobManagerImpl();
    registerService(bc, jobManager, CyJobManager.class, new Properties());
    final CyJobMonitor jobMonitor;
    if (ref == null) {
        // No GUI...
        jobMonitor = new SimpleCyJobMonitor();
    } else {
        // So, if we have a GUI, create and register our status bar
        JobStatusBar statusBar = new JobStatusBar(serviceRegistrar);
        Properties statusBarProperties = new Properties();
        statusBarProperties.setProperty("type", "JobStatus");
        registerService(bc, statusBar, StatusBarPanelFactory.class, statusBarProperties);
        // So, if we have a GUI, start up our jobs monitor
        jobMonitor = new GUICyJobMonitor(serviceRegistrar, jobManager, statusBar);
        Properties guiJobProperties = new Properties();
        guiJobProperties.setProperty(TITLE, "Job Status Monitor");
        guiJobProperties.setProperty(PREFERRED_MENU, "Tools");
        registerService(bc, jobMonitor, TaskFactory.class, guiJobProperties);
    }
    // Our job manager also needs to handle the registration of jobs handlers and job session handlers
    registerServiceListener(bc, jobManager::addJobMonitor, jobManager::removeJobMonitor, CyJobMonitor.class);
    registerServiceListener(bc, jobManager::addExecutionService, jobManager::removeExecutionService, CyJobExecutionService.class);
    // Our job manager also needs to know about session load and save
    registerService(bc, jobManager, SessionAboutToBeSavedListener.class, new Properties());
    registerService(bc, jobManager, SessionLoadedListener.class, new Properties());
}
Also used : CyJobMonitor(org.cytoscape.jobs.CyJobMonitor) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

Properties (java.util.Properties)1 CyJobMonitor (org.cytoscape.jobs.CyJobMonitor)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1 ServiceReference (org.osgi.framework.ServiceReference)1