Author: clopes
Date: 2012-01-02 14:04:18 -0800 (Mon, 02 Jan 2012)
New Revision: 27898
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/properties/PropertiesFileFilter.java
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/CalculatorConverter.java
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
Log:
Fixes #486 : NullPointerException when loading the sampleData/galFiltered.cys
of Cytoscape 2.3
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/properties/PropertiesFileFilter.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/properties/PropertiesFileFilter.java
2012-01-02 21:47:24 UTC (rev 27897)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/properties/PropertiesFileFilter.java
2012-01-02 22:04:18 UTC (rev 27898)
@@ -40,7 +40,7 @@
// These two tests are so that we don't mistakenly accept a
cysession
// or bookmarks file, which might otherwise match the pattern
above.
- if (header.contains("<cysession") && header.contains("xmlns"))
+ if (header.contains("<cysession"))
return false;
if (header.contains("<bookmarks") && header.contains("xmlns"))
return false;
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/CalculatorConverter.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/CalculatorConverter.java
2012-01-02 21:47:24 UTC (rev 27897)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/CalculatorConverter.java
2012-01-02 22:04:18 UTC (rev 27898)
@@ -199,15 +199,24 @@
private Object getMappingFunction(Properties props, String mapperName,
VisualProperty vp) {
// e.g. "edgeColorCalculator.MyStyle-Edge Color-Discrete
Mapper.mapping."
String baseKey = (legacyKey != null ? legacyKey : key) + "." +
mapperName + ".mapping.";
-
String functionType = props.getProperty(baseKey + "type");
+
+ if (functionType == null) {
+ // Try 2.3 calculator names...
+ if (baseKey.startsWith("nodeFillColorCalculator.")) {
+ baseKey = "nodeColorCalculator." + mapperName +
".mapping.";
+ functionType = props.getProperty(baseKey +
"type");
+ }
+ }
+
String attrName = props.getProperty(baseKey + "controller");
// "ID" is actually the "name" column!!!
if ("ID".equalsIgnoreCase(attrName)) attrName = "name";
if ("DiscreteMapping".equalsIgnoreCase(functionType)) {
- byte controllerType =
Byte.parseByte(props.getProperty(baseKey + "controllerType"));
+ String controllerTypeProp = props.getProperty(baseKey +
"controllerType");
+ byte controllerType = controllerTypeProp != null ?
Byte.parseByte(controllerTypeProp) : TYPE_STRING;
AttributeType attrType = null;
switch (controllerType) {
Modified:
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
===================================================================
---
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
2012-01-02 21:47:24 UTC (rev 27897)
+++
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
2012-01-02 22:04:18 UTC (rev 27898)
@@ -59,7 +59,9 @@
import org.cytoscape.property.CyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
+import org.cytoscape.property.session.Desktop;
import org.cytoscape.property.session.NetworkFrame;
+import org.cytoscape.property.session.SessionState;
import org.cytoscape.session.CySession;
import org.cytoscape.session.CySessionManager;
import org.cytoscape.session.events.SessionAboutToBeSavedEvent;
@@ -170,6 +172,7 @@
if (!allNetworks.contains(rootNet)) {
allNetworks.add(rootNet);
+ // TODO: remove it once manager is
fixed to return all tables
for (Class<? extends CyTableEntry> type
: TYPES) {
Map<String, CyTable> tableMap =
netTblMgr.getTables(rootNet, type);
allTables.addAll(tableMap.values());
@@ -252,7 +255,6 @@
restoreNetworkViews(sess);
restoreTables(sess);
restoreVisualStyles(sess);
-// restoreSelection(sess);
}
currentSession = sess;
@@ -351,99 +353,37 @@
}
final Cysession cysess = sess.getCysession();
+ final SessionState sessionState = cysess.getSessionState();
// Get network frames info
- if (cysess.getSessionState().getDesktop().getNetworkFrames() !=
null) {
- List<NetworkFrame> frames =
cysess.getSessionState().getDesktop().getNetworkFrames().getNetworkFrame();
- Map<String, NetworkFrame> framesLookup = new
HashMap<String, NetworkFrame>();
-
- for (NetworkFrame nf : frames)
- framesLookup.put(nf.getFrameID(), nf);
-
- // Set visual styles to network views
- final Map<CyNetworkView, String> netStyleMap =
sess.getViewVisualStyleMap();
-
- for (Entry<CyNetworkView, String> entry :
netStyleMap.entrySet()) {
- final CyNetworkView netView = entry.getKey();
- final String stName = entry.getValue();
- final VisualStyle vs = stylesMap.get(stName);
-
- if (vs != null) {
- vmMgr.setVisualStyle(vs, netView);
- vs.apply(netView);
- netView.updateView();
+ if (sessionState != null) {
+ final Desktop desktop = sessionState.getDesktop();
+
+ if (desktop != null && desktop.getNetworkFrames() !=
null) {
+ final List<NetworkFrame> frames =
desktop.getNetworkFrames().getNetworkFrame();
+ final Map<String, NetworkFrame> framesLookup =
new HashMap<String, NetworkFrame>();
+
+ for (NetworkFrame nf : frames)
+ framesLookup.put(nf.getFrameID(), nf);
+
+ // Set visual styles to network views
+ final Map<CyNetworkView, String> netStyleMap =
sess.getViewVisualStyleMap();
+
+ for (Entry<CyNetworkView, String> entry :
netStyleMap.entrySet()) {
+ final CyNetworkView netView =
entry.getKey();
+ final String stName = entry.getValue();
+ final VisualStyle vs =
stylesMap.get(stName);
+
+ if (vs != null) {
+ vmMgr.setVisualStyle(vs,
netView);
+ vs.apply(netView);
+ netView.updateView();
+ }
}
}
}
}
-// private void restoreSelection(CySession sess) {
-// final Cysession cysess = sess.getCysession();
-// float version = 0;
-//
-// try {
-// version = Float.valueOf(cysess.getDocumentVersion());
-// } catch (Exception e) {
-// }
-//
-// if (version < 3.0) {
-// logger.debug("Restoring node/edge selection...");
-//
-// // First create network_title -> element_name lookup
maps
-// final Map<String, Set<String>> selectedNodesMap = new
HashMap<String, Set<String>>();
-// final Map<String, Set<String>> selectedEdgesMap = new
HashMap<String, Set<String>>();
-// final List<Network> networks =
cysess.getNetworkTree().getNetwork();
-//
-// for (Network net : networks) {
-// String netTitle = net.getId();
-//
-// if (net.getSelectedNodes() != null) {
-// // Store selected node names for future
reference
-// Set<String> selectedNodes = new
HashSet<String>();
-// selectedNodesMap.put(netTitle,
selectedNodes);
-//
-// for (Node n :
net.getSelectedNodes().getNode()) {
-// selectedNodes.add(n.getId());
-// }
-// }
-//
-// if (net.getSelectedEdges() != null) {
-// // Store selected edge names for future
reference
-// Set<String> selectedEdges = new
HashSet<String>();
-// selectedEdgesMap.put(netTitle,
selectedEdges);
-//
-// for (Edge e :
net.getSelectedEdges().getEdge()) {
-// selectedEdges.add(e.getId());
-// }
-// }
-// }
-//
-// // Now iterate through all CyNodes/Edges and select the
ones that are found in the lookup maps
-// Set<CyNetwork> cyNetworks = netMgr.getNetworkSet();
-//
-// if (cyNetworks != null) {
-// for (CyNetwork cyNet : cyNetworks) {
-// String netTitle =
cyNet.getCyRow().get(CyNetwork.NAME, String.class);
-//
-//
selectElementsByName(cyNet.getNodeList(), selectedNodesMap.get(netTitle));
-//
selectElementsByName(cyNet.getEdgeList(), selectedEdgesMap.get(netTitle));
-// }
-// }
-// }
-// }
-//
-// private <T extends CyTableEntry> void selectElementsByName(List<T>
entries, Set<String> names) {
-// if (entries != null && names != null) {
-// for (T entry : entries) {
-// CyRow row = entry.getCyRow();
-//
-// if (names.contains(row.get(CyNetwork.NAME,
String.class))) {
-// row.set(CyNetwork.SELECTED, true);
-// }
-// }
-// }
-// }
-
private void disposeCurrentSession(boolean removeVisualStyles) {
logger.debug("Disposing current session...");
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.