Author: scooter
Date: 2011-09-01 11:36:18 -0700 (Thu, 01 Sep 2011)
New Revision: 26677
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
Log:
Fixed problem where session loading task monitor prevented our task monitor
from running, resulting in a deadlock
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
2011-08-31 23:31:22 UTC (rev 26676)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
2011-09-01 18:36:18 UTC (rev 26677)
@@ -66,6 +66,7 @@
private Properties systemProps = null;
private ChemInfoSettingsDialog settingsDialog = null;
+ private boolean sessionLock = false;
/**
* This is the main constructor, which will be called by Cytoscape's
Plugin Manager.
@@ -97,11 +98,16 @@
}
try {
- // Set ourselves up to listen for new networks
+ // Set ourselves up to listen for new networks, and
protect against session loading issues
Cytoscape.getDesktop().getSwingPropertyChangeSupport()
- .addPropertyChangeListener(
-
CytoscapeDesktop.NETWORK_VIEW_CREATED, this);
+
.addPropertyChangeListener(CytoscapeDesktop.NETWORK_VIEW_CREATED, this);
+ Cytoscape.getPropertyChangeSupport()
+
.addPropertyChangeListener(Cytoscape.SESSION_LOADED, this);
+
+ Cytoscape.getPropertyChangeSupport()
+
.addPropertyChangeListener(Integer.toString(Cytoscape.SESSION_OPENED), this);
+
((DGraphView) Cytoscape.getCurrentNetworkView())
.addNodeContextMenuListener(new
ChemVizContextMenu(systemProps, settingsDialog));
((DGraphView) Cytoscape.getCurrentNetworkView())
@@ -118,25 +124,38 @@
* menu listener to nodes within this network
*/
public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName() ==
CytoscapeDesktop.NETWORK_VIEW_CREATED) {
+ if
(evt.getPropertyName().equals(Integer.toString(Cytoscape.SESSION_OPENED))) {
+ sessionLock = true;
+ } else if (evt.getPropertyName() == Cytoscape.SESSION_LOADED) {
+ sessionLock = false;
+ } else if (evt.getPropertyName() ==
CytoscapeDesktop.NETWORK_VIEW_CREATED) {
CyNetworkView view = (CyNetworkView)evt.getNewValue();
- // Add menu to the context dialog
- view.addNodeContextMenuListener(new
ChemVizContextMenu(systemProps, settingsDialog));
- view.addEdgeContextMenuListener(new
ChemVizContextMenu(systemProps, settingsDialog));
- // Check to see if this view has custom graphics
- if
(CreateNodeGraphicsTask.hasCustomGraphics(view.getNetwork())) {
- List<Node> selection =
-
CreateNodeGraphicsTask.getCustomGraphicsNodes(view);
+ updateNetworkView(view);
+ }
+ }
- CreateNodeGraphicsTask loader = null;
- loader =
CreateNodeGraphicsTask.getCustomGraphicsTask(view);
- if (loader == null) {
- loader = new
CreateNodeGraphicsTask(selection, settingsDialog, false);
- } else {
- loader.setSelection(selection);
- loader.setRemove(false);
- }
+ private void updateNetworkView(CyNetworkView view) {
+ // Add menu to the context dialog
+ view.addNodeContextMenuListener(new
ChemVizContextMenu(systemProps, settingsDialog));
+ view.addEdgeContextMenuListener(new
ChemVizContextMenu(systemProps, settingsDialog));
+ // Check to see if this view has custom graphics
+ if
(CreateNodeGraphicsTask.hasCustomGraphics(view.getNetwork())) {
+ List<Node> selection =
+ CreateNodeGraphicsTask.getCustomGraphicsNodes(view);
+
+ CreateNodeGraphicsTask loader = null;
+ loader =
CreateNodeGraphicsTask.getCustomGraphicsTask(view);
+ if (loader == null) {
+ loader = new CreateNodeGraphicsTask(selection,
settingsDialog, false);
+ } else {
+ loader.setSelection(selection);
+ loader.setRemove(false);
+ }
+ if (!sessionLock)
TaskManager.executeTask(loader,
loader.getDefaultTaskConfig());
+ else {
+ loader.setTaskMonitor(null);
+ loader.run();
}
}
}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
2011-08-31 23:31:22 UTC (rev 26676)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
2011-09-01 18:36:18 UTC (rev 26677)
@@ -199,7 +199,8 @@
CyAttributes networkAttributes =
Cytoscape.getNetworkAttributes();
CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
CyNetworkView view = Cytoscape.getCurrentNetworkView();
- monitor.setPercentCompleted(0);
+ if (monitor != null)
+ monitor.setPercentCompleted(0);
if (removeCustomGraphics) {
ArrayList<NodeView> removeList = new
ArrayList<NodeView>(graphMap.keySet());
--
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.