Search in sources :

Example 1 with CyShutdown

use of org.cytoscape.application.CyShutdown in project cytoscape-impl by cytoscape.

the class MacCyActivator method start.

@Override
public void start(BundleContext context) throws Exception {
    final CyServiceRegistrar serviceRegistrar = getService(context, CyServiceRegistrar.class);
    final CyShutdown shutdown = getService(context, CyShutdown.class);
    final TaskFactory aboutTaskFactory = new HelpAboutTaskFactory(serviceRegistrar);
    final DialogTaskManager taskManager = getService(context, DialogTaskManager.class);
    final CyShutdownEvent[] lastShutdownEvent = new CyShutdownEvent[1];
    CyShutdownListener listener = (CyShutdownEvent e) -> {
        lastShutdownEvent[0] = e;
    };
    registerService(context, listener, CyShutdownListener.class, new Properties());
    Application application = Application.getApplication();
    application.setQuitHandler((QuitEvent event, QuitResponse response) -> {
        shutdown.exit(0);
        if (lastShutdownEvent[0] != null && !lastShutdownEvent[0].actuallyShutdown()) {
            response.cancelQuit();
        }
    });
    application.setAboutHandler((AboutEvent event) -> {
        taskManager.execute(aboutTaskFactory.createTaskIterator());
    });
}
Also used : AboutEvent(com.apple.eawt.AppEvent.AboutEvent) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyShutdownListener(org.cytoscape.application.events.CyShutdownListener) HelpAboutTaskFactory(org.cytoscape.internal.view.help.HelpAboutTaskFactory) HelpAboutTaskFactory(org.cytoscape.internal.view.help.HelpAboutTaskFactory) TaskFactory(org.cytoscape.work.TaskFactory) Application(com.apple.eawt.Application) CyShutdownEvent(org.cytoscape.application.events.CyShutdownEvent) QuitResponse(com.apple.eawt.QuitResponse) CyShutdown(org.cytoscape.application.CyShutdown) QuitEvent(com.apple.eawt.AppEvent.QuitEvent)

Example 2 with CyShutdown

use of org.cytoscape.application.CyShutdown in project cytoscape-impl by cytoscape.

the class CyActivator method start.

public void start(BundleContext bc) {
    CommandLineArgs args = getService(bc, CommandLineArgs.class);
    CyVersion cyVersion = getService(bc, CyVersion.class);
    CyShutdown cyShutdown = getService(bc, CyShutdown.class);
    StreamUtil streamUtil = getService(bc, StreamUtil.class);
    OpenSessionTaskFactory loadSession = getService(bc, OpenSessionTaskFactory.class);
    LoadNetworkFileTaskFactory networkFileLoader = getService(bc, LoadNetworkFileTaskFactory.class);
    LoadNetworkURLTaskFactory networkURLLoader = getService(bc, LoadNetworkURLTaskFactory.class);
    LoadVizmapFileTaskFactory visualStylesLoader = getService(bc, LoadVizmapFileTaskFactory.class);
    TaskManager<?, ?> taskManager = getService(bc, TaskManager.class);
    CyServiceRegistrar registrar = getService(bc, CyServiceRegistrar.class);
    CyProperty<Properties> props = (CyProperty<Properties>) getService(bc, CyProperty.class, "(cyPropertyName=cytoscape3.props)");
    StartupConfig sc = new StartupConfig(props.getProperties(), streamUtil, loadSession, networkFileLoader, networkURLLoader, visualStylesLoader, taskManager, registrar);
    Parser p = new Parser(args.getArgs(), cyShutdown, cyVersion, sc, props.getProperties());
    sc.start();
}
Also used : CyVersion(org.cytoscape.application.CyVersion) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) LoadVizmapFileTaskFactory(org.cytoscape.task.read.LoadVizmapFileTaskFactory) CyProperty(org.cytoscape.property.CyProperty) LoadNetworkURLTaskFactory(org.cytoscape.task.read.LoadNetworkURLTaskFactory) StreamUtil(org.cytoscape.io.util.StreamUtil) OpenSessionTaskFactory(org.cytoscape.task.read.OpenSessionTaskFactory) CommandLineArgs(org.cytoscape.cmdline.CommandLineArgs) LoadNetworkFileTaskFactory(org.cytoscape.task.read.LoadNetworkFileTaskFactory) CyShutdown(org.cytoscape.application.CyShutdown)

Example 3 with CyShutdown

use of org.cytoscape.application.CyShutdown in project cytoscape-impl by cytoscape.

the class QuitTask method run.

@Override
public void run(TaskMonitor tm) {
    CyShutdown shutdown = serviceRegistrar.getService(CyShutdown.class);
    shutdown.exit(0, true);
}
Also used : CyShutdown(org.cytoscape.application.CyShutdown)

Example 4 with CyShutdown

use of org.cytoscape.application.CyShutdown in project cytoscape-impl by cytoscape.

the class CyActivator method start.

public void start(BundleContext bc) {
    final CommandLineArgs args = getService(bc, CommandLineArgs.class);
    final CyVersion cyVersion = getService(bc, CyVersion.class);
    final CyShutdown cyShutdown = getService(bc, CyShutdown.class);
    final AvailableCommands availableCommands = getService(bc, AvailableCommands.class);
    final CommandExecutorTaskFactory cmdExec = getService(bc, CommandExecutorTaskFactory.class);
    final SynchronousTaskManager taskManager = getService(bc, SynchronousTaskManager.class);
    new Thread(new Runnable() {

        public void run() {
            StartupConfig sc = new StartupConfig(cmdExec, taskManager);
            Parser p = new Parser(args.getArgs(), cyShutdown, cyVersion, sc, availableCommands);
            sc.start();
            try {
                Thread.sleep(200);
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
            cyShutdown.exit(0);
        }
    }).start();
}
Also used : CommandExecutorTaskFactory(org.cytoscape.command.CommandExecutorTaskFactory) SynchronousTaskManager(org.cytoscape.work.SynchronousTaskManager) CyVersion(org.cytoscape.application.CyVersion) AvailableCommands(org.cytoscape.command.AvailableCommands) CommandLineArgs(org.cytoscape.cmdline.CommandLineArgs) CyShutdown(org.cytoscape.application.CyShutdown)

Aggregations

CyShutdown (org.cytoscape.application.CyShutdown)4 Properties (java.util.Properties)2 CyVersion (org.cytoscape.application.CyVersion)2 CommandLineArgs (org.cytoscape.cmdline.CommandLineArgs)2 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)2 AboutEvent (com.apple.eawt.AppEvent.AboutEvent)1 QuitEvent (com.apple.eawt.AppEvent.QuitEvent)1 Application (com.apple.eawt.Application)1 QuitResponse (com.apple.eawt.QuitResponse)1 CyShutdownEvent (org.cytoscape.application.events.CyShutdownEvent)1 CyShutdownListener (org.cytoscape.application.events.CyShutdownListener)1 AvailableCommands (org.cytoscape.command.AvailableCommands)1 CommandExecutorTaskFactory (org.cytoscape.command.CommandExecutorTaskFactory)1 HelpAboutTaskFactory (org.cytoscape.internal.view.help.HelpAboutTaskFactory)1 StreamUtil (org.cytoscape.io.util.StreamUtil)1 CyProperty (org.cytoscape.property.CyProperty)1 LoadNetworkFileTaskFactory (org.cytoscape.task.read.LoadNetworkFileTaskFactory)1 LoadNetworkURLTaskFactory (org.cytoscape.task.read.LoadNetworkURLTaskFactory)1 LoadVizmapFileTaskFactory (org.cytoscape.task.read.LoadVizmapFileTaskFactory)1 OpenSessionTaskFactory (org.cytoscape.task.read.OpenSessionTaskFactory)1