use of org.cytoscape.internal.io.networklist.NetworkList 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.networklist.NetworkList in project cytoscape-impl by cytoscape.
the class SessionHandler method saveNetworkList.
private File saveNetworkList(final SessionAboutToBeSavedEvent e) {
final Map<Long, Integer> netOrder = netPanel.getNetworkListOrder();
// Create the JAXB objects
final NetworkList netList = new NetworkList();
for (final Entry<Long, Integer> entry : netOrder.entrySet()) {
final Long suid = entry.getKey();
final Integer order = entry.getValue();
if (order != null) {
final Network n = new Network();
n.setId(suid);
n.setOrder(order);
netList.getNetwork().add(n);
}
}
// Create temp file
File tmpFile = new File(System.getProperty("java.io.tmpdir"), NETWORK_LIST_FILENAME);
tmpFile.deleteOnExit();
// Write to the file
sessionIO.write(netList, tmpFile);
return tmpFile;
}
Aggregations