use of org.cytoscape.internal.io.sessionstate.SessionState in project cytoscape-impl by cytoscape.
the class SessionHandler method postLoading.
private final void postLoading(final CySession sess) {
NetworkList netList = null;
final Map<String, List<File>> filesMap = sess.getAppFileListMap();
if (filesMap != null) {
final List<File> files = filesMap.get(APP_NAME);
if (files != null) {
SessionState sessState = null;
for (File f : files) {
if (f.getName().endsWith(SESSION_STATE_FILENAME))
sessState = sessionIO.read(f, SessionState.class);
else if (f.getName().endsWith(NETWORK_LIST_FILENAME))
netList = sessionIO.read(f, NetworkList.class);
}
if (sessState != null)
setCytoPanelStates(sessState.getCytopanels());
}
}
if (netList == null) {
// Probably a Cy2 session file, which does not provide a separate "network_list" file
// so let's get the orders from the networks in the CySession file
// (we just assume the Session Reader sent the networks in the correct order in a LinkedHashSet)
final Set<CyNetwork> netSet = sess.getNetworks();
final Map<Long, Integer> netOrder = new HashMap<>();
int count = 0;
for (CyNetwork n : netSet) netOrder.put(n.getSUID(), count++);
setSessionNetworks(netOrder);
} else {
setSessionNetworks(netList.getNetwork(), sess);
}
}
use of org.cytoscape.internal.io.sessionstate.SessionState in project cytoscape-impl by cytoscape.
the class SessionHandler method saveSessionState.
private File saveSessionState(final SessionAboutToBeSavedEvent e) {
final SessionState sessState = new SessionState();
// CytoPanels States
final Cytopanels cytopanels = new Cytopanels();
sessState.setCytopanels(cytopanels);
for (Map.Entry<String, CytoPanelName> entry : CYTOPANEL_NAMES.entrySet()) {
final CytoPanel p = desktop.getCytoPanel(entry.getValue());
final Cytopanel cytopanel = new Cytopanel();
cytopanel.setId(entry.getKey());
cytopanel.setPanelState(p.getState().toString());
cytopanel.setSelectedPanel(Integer.toString(p.getSelectedIndex()));
cytopanels.getCytopanel().add(cytopanel);
}
// Create temp file
File tmpFile = new File(System.getProperty("java.io.tmpdir"), SESSION_STATE_FILENAME);
tmpFile.deleteOnExit();
// Write to the file
sessionIO.write(sessState, tmpFile);
return tmpFile;
}
Aggregations