Author: jm
Date: 2011-05-10 09:06:58 -0700 (Tue, 10 May 2011)
New Revision: 24993
Modified:
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
Log:
Made CyTableManagerImpl listen for destroyed NetworkViews so it can unregister
the appropriate tables
Modified:
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
===================================================================
---
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
2011-05-10 16:05:20 UTC (rev 24992)
+++
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
2011-05-10 16:06:58 UTC (rev 24993)
@@ -39,6 +39,8 @@
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTable.Mutability;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
+import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
import org.cytoscape.model.events.TableAboutToBeDeletedEvent;
import org.cytoscape.model.events.TableDeletedEvent;
import org.slf4j.Logger;
@@ -48,7 +50,7 @@
* An interface describing a factory used for managing {@link CyTable} objects.
* This class will be provided as a service through Spring/OSGi.
*/
-public class CyTableManagerImpl implements CyTableManager {
+public class CyTableManagerImpl implements CyTableManager,
NetworkAboutToBeDestroyedListener {
private static final Logger logger =
LoggerFactory.getLogger(CyTableManagerImpl.class);
@@ -128,8 +130,7 @@
return tables.get(suid);
}
- @Override
- public void deleteTable(final long suid) {
+ void deleteTableInternal(final long suid, boolean force) {
CyTableImpl table;
synchronized (this) {
table = (CyTableImpl) tables.get(suid);
@@ -144,7 +145,7 @@
if (table == null)
return;
- if (table.getMutability() != Mutability.MUTABLE)
+ if (!force && table.getMutability() != Mutability.MUTABLE)
throw new IllegalArgumentException("can't delete an immutable
table!");
table.removeAllVirtColumns();
@@ -155,4 +156,19 @@
logger.debug("CyTable removed: table ID = " + table.getSUID());
table = null;
}
+
+ @Override
+ public void handleEvent(NetworkAboutToBeDestroyedEvent e) {
+ CyNetwork network = e.getNetwork();
+ for (Class<?> type : new Class[] { CyNetwork.class, CyNode.class,
CyEdge.class }) {
+ for (CyTable table : getTableMap(type, network).values()) {
+ deleteTableInternal(table.getSUID(), true);
+ }
+ }
+ }
+
+ @Override
+ public void deleteTable(long suid) {
+ deleteTableInternal(suid, false);
+ }
}
Modified:
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-05-10 16:05:20 UTC (rev 24992)
+++
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-05-10 16:06:58 UTC (rev 24993)
@@ -27,7 +27,11 @@
</osgi:service>
<osgi:service id="cyTableManagerService"
- ref="cyTableManager"
interface="org.cytoscape.model.CyTableManager">
+ ref="cyTableManager">
+ <osgi:interfaces>
+ <value>org.cytoscape.model.CyTableManager</value>
+
<value>org.cytoscape.model.events.NetworkAboutToBeDestroyedListener</value>
+ </osgi:interfaces>
</osgi:service>
<osgi:service id="cyNetworkManagerService"
--
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.