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());
});
}
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();
}
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);
}
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();
}
Aggregations