Author: mes
Date: 2010-08-17 15:02:48 -0700 (Tue, 17 Aug 2010)
New Revision: 21412

Added:
   
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
Removed:
   core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRowListener.java
   
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetEvent.java
   
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetListener.java
Modified:
   core3/model-api/trunk/pom.xml
   core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRow.java
   
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
Log:
refactored RowSet stuff to be a microlistener and added table unit tests

Modified: core3/model-api/trunk/pom.xml
===================================================================
--- core3/model-api/trunk/pom.xml       2010-08-17 22:00:02 UTC (rev 21411)
+++ core3/model-api/trunk/pom.xml       2010-08-17 22:02:48 UTC (rev 21412)
@@ -93,7 +93,7 @@
       <artifactId>event-api</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
-    
+
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
@@ -106,6 +106,14 @@
          <version>1.8.1</version> 
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.cytoscape</groupId>
+      <artifactId>event-api</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    
   </dependencies>
 
 </project>

Modified: core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRow.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRow.java  
2010-08-17 22:00:02 UTC (rev 21411)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRow.java  
2010-08-17 22:02:48 UTC (rev 21412)
@@ -91,15 +91,4 @@
         * Returns the {...@link CyDataTable} that this row belongs to.
         */
        CyDataTable getDataTable();
-
-       /**
-        * Adds a listener to this row.  The listener will be called when this
-        * row gets set.
-        */
-       void addRowListener(CyRowListener rl);
-
-       /**
-        * Removes an existing listener from this row.  
-        */
-       void removeRowListener(CyRowListener rl);
 }

Deleted: 
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRowListener.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRowListener.java  
2010-08-17 22:00:02 UTC (rev 21411)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyRowListener.java  
2010-08-17 22:02:48 UTC (rev 21412)
@@ -1,52 +0,0 @@
-
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-package org.cytoscape.model;
-
-
-/**
- * A listener interface that specifies a method that will be executed
- * when the value of a row is set. 
- */
-public interface CyRowListener {
-
-       /**
-        * Indicates that the specified column has been set to the
-        * specified value in the bound row.
-        */
-       void rowSet(String columnName, Object value);
-
-}

Deleted: 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetEvent.java
===================================================================
--- 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetEvent.java 
    2010-08-17 22:00:02 UTC (rev 21411)
+++ 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetEvent.java 
    2010-08-17 22:02:48 UTC (rev 21412)
@@ -1,63 +0,0 @@
-
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-package org.cytoscape.model.events;
-
-import org.cytoscape.event.AbstractCyEvent;
-
-import org.cytoscape.model.CyRow;
-
-
-/**
- * This event signals that an attribute has been set.
- */
-public final class RowSetEvent extends AbstractCyEvent<CyRow> {
-       private final String columnName;
-       
-       public RowSetEvent(final CyRow source, final String columnName) {
-               super(source, RowSetListener.class);
-               this.columnName = columnName;
-       }
-
-       /**
-        * DOCUMENT ME!
-        *
-        * @return The name of the attribute that has been set.
-        */
-       public String getColumnName() {
-               return columnName;
-       }
-}

Deleted: 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetListener.java
===================================================================
--- 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetListener.java
  2010-08-17 22:00:02 UTC (rev 21411)
+++ 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetListener.java
  2010-08-17 22:02:48 UTC (rev 21412)
@@ -1,47 +0,0 @@
-
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-package org.cytoscape.model.events;
-
-import org.cytoscape.event.CyListener;
-
-
-/**
- * Listener for RowSetEvents.
- */
-public interface RowSetListener extends CyListener {
-       void handleEvent(RowSetEvent e);
-}

Added: 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
===================================================================
--- 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
                             (rev 0)
+++ 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
     2010-08-17 22:02:48 UTC (rev 21412)
@@ -0,0 +1,49 @@
+
+/*
+ Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+
+package org.cytoscape.model.events;
+
+import org.cytoscape.event.CyMicroListener;
+import org.cytoscape.model.CyRow;
+
+
+/**
+ * Listener for row set events. The event source for this listener
+ * will the be the CyDataTable that contains the CyRow in question.
+ */
+public interface RowSetMicroListener extends CyMicroListener {
+       void handleRowSet(CyRow row, String columnName, Object value);
+}

Modified: 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
===================================================================
--- 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
        2010-08-17 22:00:02 UTC (rev 21411)
+++ 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
        2010-08-17 22:02:48 UTC (rev 21412)
@@ -42,7 +42,13 @@
 import junit.framework.TestSuite;
 
 import org.cytoscape.model.CyDataTable;
+import org.cytoscape.model.events.RowSetMicroListener;
+import org.cytoscape.model.events.ColumnCreatedEvent;
+import org.cytoscape.model.events.ColumnDeletedEvent;
 
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.event.DummyCyEventHelper;
+
 import java.awt.Color;
 
 import java.lang.RuntimeException;
@@ -57,6 +63,7 @@
 
        protected CyDataTable mgr;
        protected CyRow attrs;
+       protected DummyCyEventHelper eventHelper; 
 
 
        /**
@@ -220,5 +227,59 @@
                fail();
        }
 
+       public void testRowSetMicroListener() {
+               mgr.createColumn("someString", String.class, false);
+               attrs.set("someString", "apple");
+
+               Object last = eventHelper.getLastMicroListener();
+               assertNotNull( last );
+               assertTrue( last instanceof RowSetMicroListener );
+       }
+
+       public void testColumnCreatedEvent() {
+               mgr.createColumn("someInt", Integer.class, false);
+
+               Object last = eventHelper.getLastAsynchronousEvent();
+               assertNotNull( last );
+               assertTrue( last instanceof ColumnCreatedEvent );
+       }
+
+       public void testColumnDeletedEvent() {
+               mgr.createColumn("someInt", Integer.class, false);
+               mgr.deleteColumn("someInt");
+
+               Object last = eventHelper.getLastSynchronousEvent();
+               assertNotNull( last );
+               assertTrue( last instanceof ColumnDeletedEvent );
+       }
+
+       public void testColumnCreate() {
+               mgr.createColumn("someInt", Integer.class, false);
+               assertTrue( mgr.getColumnTypeMap().containsKey("someInt") );
+               assertEquals( mgr.getColumnTypeMap().get("someInt"), 
Integer.class );
+       }
+
+       public void testCreateUniqueColumn() {
+               mgr.createColumn("someInt", Integer.class, true);
+               assertTrue( mgr.getColumnTypeMap().containsKey("someInt") );
+               assertEquals( mgr.getColumnTypeMap().get("someInt"), 
Integer.class );
+               assertTrue( mgr.getUniqueColumns().contains("someInt"));
+       }
+
+       public void testCreateNonUniqueColumn() {
+               mgr.createColumn("someInt", Integer.class, false);
+               assertTrue( mgr.getColumnTypeMap().containsKey("someInt") );
+               assertEquals( mgr.getColumnTypeMap().get("someInt"), 
Integer.class );
+               assertFalse( mgr.getUniqueColumns().contains("someInt"));
+       }
+
+       public void testColumnDelete() {
+               mgr.createColumn("someInt", Integer.class, false);
+               assertTrue( mgr.getColumnTypeMap().containsKey("someInt") );
+               
+               mgr.deleteColumn("someInt");
+               assertFalse( mgr.getColumnTypeMap().containsKey("someInt") );
+       }
+
        // lots more needed
 }

-- 
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.

Reply via email to