use of org.cytoscape.session.events.SessionSavedEvent in project cytoscape-impl by cytoscape.
the class SaveSessionAsTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
CySession session = null;
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
try {
tm.setProgress(0.05);
session = serviceRegistrar.getService(CySessionManager.class).getCurrentSession();
writer = new CySessionWriter(session, file, serviceRegistrar);
writer.run(tm);
tm.setProgress(1.0);
// Add this session file URL as the most recent file.
if (!file.getName().endsWith(".cys"))
file = new File(file.getPath() + ".cys");
} catch (Exception e) {
eventHelper.fireEvent(new SessionSaveCancelledEvent(this));
throw e;
}
if (!cancelled) {
// Fire event to tell others session has been saved to a file.
eventHelper.fireEvent(new SessionSavedEvent(this, session, file.getAbsolutePath()));
serviceRegistrar.getService(RecentlyOpenedTracker.class).add(file.toURI().toURL());
}
}
use of org.cytoscape.session.events.SessionSavedEvent in project cytoscape-impl by cytoscape.
the class SaveSessionTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
CySession session = null;
File file = null;
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
try {
final CySessionManager sessionMgr = serviceRegistrar.getService(CySessionManager.class);
tm.setProgress(0.05);
session = sessionMgr.getCurrentSession();
final String fileName = sessionMgr.getCurrentSessionFileName();
file = new File(fileName);
writer = new CySessionWriter(session, file, serviceRegistrar);
writer.run(tm);
tm.setProgress(1.0);
// Add this session file URL as the most recent file.
if (!file.getName().endsWith(".cys"))
file = new File(file.getPath() + ".cys");
} catch (Exception e) {
eventHelper.fireEvent(new SessionSaveCancelledEvent(this));
throw e;
}
if (!cancelled) {
// Fire event to tell others session has been saved to a file.
eventHelper.fireEvent(new SessionSavedEvent(this, session, file.getAbsolutePath()));
serviceRegistrar.getService(RecentlyOpenedTracker.class).add(file.toURI().toURL());
}
}
Aggregations