Author: ruschein
Date: 2011-02-10 12:30:11 -0800 (Thu, 10 Feb 2011)
New Revision: 24090
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.xml
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
Log:
Made use of the new TableDeletedEvent in CyTableManagerImpl.
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-02-10 20:27:17 UTC (rev 24089)
+++
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
2011-02-10 20:30:11 UTC (rev 24090)
@@ -33,12 +33,14 @@
import java.util.Map;
import java.util.Set;
+import org.cytoscape.event.CyEventHelper;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTable.Mutability;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.events.TableDeletedEvent;
/**
@@ -47,10 +49,13 @@
* provided as a service through Spring/OSGi.
*/
public class CyTableManagerImpl implements CyTableManager {
+ private final CyEventHelper eventHelper;
private final Map<Class<?>, Map<CyNetwork, Map<String,CyTable>>>
networkTableMap;
private final Map<Long,CyTable> tables;
- public CyTableManagerImpl() {
+ public CyTableManagerImpl(final CyEventHelper eventHelper) {
+ this.eventHelper = eventHelper;
+
networkTableMap = new HashMap<Class<?>, Map<CyNetwork,
Map<String,CyTable>>>();
networkTableMap.put( CyNetwork.class, new HashMap<CyNetwork,
Map<String,CyTable>>() );
networkTableMap.put( CyNode.class, new HashMap<CyNetwork,
Map<String,CyTable>>() );
@@ -124,15 +129,19 @@
}
@Override
- public synchronized void deleteTable(final long suid) {
- final CyTableImpl table = (CyTableImpl)tables.get(suid);
- if (table == null)
- return;
+ public void deleteTable(final long suid) {
+ final CyTableImpl table;
+ synchronized(this) {
+ table = (CyTableImpl)tables.get(suid);
+ if (table == null)
+ return;
- if (table.getMutability() != Mutability.MUTABLE)
- throw new IllegalArgumentException("can't delete an
immutable table!");
+ if (table.getMutability() != Mutability.MUTABLE)
+ throw new IllegalArgumentException("can't
delete an immutable table!");
- table.removeAllVirtColumns();
- tables.remove(suid);
+ table.removeAllVirtColumns();
+ tables.remove(suid);
+ }
+ eventHelper.fireSynchronousEvent(new TableDeletedEvent(this,
table));
}
}
Modified:
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
2011-02-10 20:27:17 UTC (rev 24089)
+++
core3/model-impl/trunk/impl/src/main/resources/META-INF/spring/bundle-context.xml
2011-02-10 20:30:11 UTC (rev 24090)
@@ -16,6 +16,7 @@
<context:annotation-config/>
<bean id="cyTableManager"
class="org.cytoscape.model.internal.CyTableManagerImpl">
+ <constructor-arg ref="cyEventHelperServiceRef" />
</bean>
<bean id="cyTableFactory"
class="org.cytoscape.model.internal.CyTableFactoryImpl">
Modified:
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
===================================================================
---
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
2011-02-10 20:27:17 UTC (rev 24089)
+++
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
2011-02-10 20:30:11 UTC (rev 24090)
@@ -48,9 +48,9 @@
public void setUp() {
super.setUp();
- mgrImpl = new CyTableManagerImpl();
+ CyEventHelper eh = new DummyCyEventHelper();
+ mgrImpl = new CyTableManagerImpl(eh);
mgr = mgrImpl;
- CyEventHelper eh = new DummyCyEventHelper();
final Interpreter interpreter = new InterpreterImpl();
goodNetwork =
new ArrayGraph(eh, mgrImpl,
Modified:
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
===================================================================
---
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
2011-02-10 20:27:17 UTC (rev 24089)
+++
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
2011-02-10 20:30:11 UTC (rev 24090)
@@ -54,7 +54,7 @@
public static CyRootNetwork getPublicRootInstance() {
DummyCyEventHelper deh = new DummyCyEventHelper();
- CyTableManagerImpl tm = new CyTableManagerImpl();
+ CyTableManagerImpl tm = new CyTableManagerImpl(deh);
Interpreter interp = new InterpreterImpl();
ArrayGraph ar = new ArrayGraph(deh, tm, new
CyTableFactoryImpl(deh, tm, interp), true);
return ar;
@@ -62,7 +62,7 @@
public static CyRootNetwork getPrivateRootInstance() {
DummyCyEventHelper deh = new DummyCyEventHelper();
- CyTableManagerImpl tm = new CyTableManagerImpl();
+ CyTableManagerImpl tm = new CyTableManagerImpl(deh);
Interpreter interp = new InterpreterImpl();
ArrayGraph ar = new ArrayGraph(deh, tm, new
CyTableFactoryImpl(deh, tm, interp), false);
return ar;
Modified:
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
===================================================================
---
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
2011-02-10 20:27:17 UTC (rev 24089)
+++
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
2011-02-10 20:30:11 UTC (rev 24090)
@@ -49,9 +49,9 @@
public class CySubNetworkCyTableManagerTest extends AbstractCyTableManagerTest
{
public void setUp() {
super.setUp();
- CyTableManagerImpl mgrImpl = new CyTableManagerImpl();
+ CyEventHelper eh = new DummyCyEventHelper();
+ CyTableManagerImpl mgrImpl = new CyTableManagerImpl(eh);
mgr = mgrImpl;
- CyEventHelper eh = new DummyCyEventHelper();
final Interpreter interpreter = new InterpreterImpl();
ArrayGraph baseNet =
new ArrayGraph(eh, mgrImpl,
--
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.