Author: ruschein
Date: 2011-01-24 13:48:37 -0800 (Mon, 24 Jan 2011)
New Revision: 23577

Modified:
   
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
Log:
Now we fire a column creation event when a new virtual column gets added to a 
CyTable.

Modified: 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
===================================================================
--- 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
     2011-01-24 21:45:15 UTC (rev 23576)
+++ 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
     2011-01-24 21:48:37 UTC (rev 23577)
@@ -821,48 +821,50 @@
        }
 
        @Override
-       synchronized public final String addVirtualColumn(final String 
virtualColumn,
-                                                         final String 
sourceColumn,
-                                                         final CyTable 
sourceTable,
-                                                         final String 
sourceJoinKey,
-                                                         final String 
targetJoinKey)
+       public final String addVirtualColumn(final String virtualColumn, final 
String sourceColumn,
+                                            final CyTable sourceTable, final 
String sourceJoinKey,
+                                            final String targetJoinKey)
        {
-               if (virtualColumn == null)
-                       throw new NullPointerException("\"virtualColumn\" 
argument must never be null!");
-               if (sourceColumn == null)
-                       throw new NullPointerException("\"sourceColumn\" 
argument must never be null!");
-               if (sourceTable == null)
-                       throw new NullPointerException("\"sourceTable\" 
argument must never be null!");
-               if (sourceJoinKey == null)
-                       throw new NullPointerException("\"sourceJoinKey\" 
argument must never be null!");
-               if (targetJoinKey == null)
-                       throw new NullPointerException("\"targetJoinKey\" 
argument must never be null!");
+               final String targetColumnName = 
getUniqueColumnName(virtualColumn);
 
-               final Class<?> sourceColumnType = 
sourceTable.getType(sourceColumn);
-               if (sourceColumnType == null)
-                       throw new IllegalArgumentException("\"sourceColumn\" is 
not a column in \"sourceColumn\"!");
+               synchronized(this) {
+                       if (virtualColumn == null)
+                               throw new 
NullPointerException("\"virtualColumn\" argument must never be null!");
+                       if (sourceColumn == null)
+                               throw new 
NullPointerException("\"sourceColumn\" argument must never be null!");
+                       if (sourceTable == null)
+                               throw new NullPointerException("\"sourceTable\" 
argument must never be null!");
+                       if (sourceJoinKey == null)
+                               throw new 
NullPointerException("\"sourceJoinKey\" argument must never be null!");
+                       if (targetJoinKey == null)
+                               throw new 
NullPointerException("\"targetJoinKey\" argument must never be null!");
 
-               final Class<?> sourceJoinKeyType = 
sourceTable.getType(sourceJoinKey);
-               if (sourceJoinKeyType == null)
-                       throw new IllegalArgumentException("\"sourceJoinKey\" 
is not a known column in \"sourceTable\"!");
+                       final Class<?> sourceColumnType = 
sourceTable.getType(sourceColumn);
+                       if (sourceColumnType == null)
+                               throw new 
IllegalArgumentException("\"sourceColumn\" is not a column in 
\"sourceColumn\"!");
 
-               final Class<?> targetJoinKeyType = this.getType(targetJoinKey);
-               if (targetJoinKeyType == null)
-                       throw new IllegalArgumentException("\"targetJoinKey\" 
is not a known column in this table!");
+                       final Class<?> sourceJoinKeyType = 
sourceTable.getType(sourceJoinKey);
+                       if (sourceJoinKeyType == null)
+                               throw new 
IllegalArgumentException("\"sourceJoinKey\" is not a known column in 
\"sourceTable\"!");
 
-               if (sourceJoinKeyType != targetJoinKeyType)
-                       throw new IllegalArgumentException("\"sourceJoinKey\" 
has a different type from \"targetJoinKey\"!");
+                       final Class<?> targetJoinKeyType = 
this.getType(targetJoinKey);
+                       if (targetJoinKeyType == null)
+                               throw new 
IllegalArgumentException("\"targetJoinKey\" is not a known column in this 
table!");
 
-               final String targetColumnName = 
getUniqueColumnName(virtualColumn);
-               types.put(targetColumnName, sourceColumnType);
-               if (sourceColumnType == List.class) {
-                       final Class<?> listElementType = 
sourceTable.getListElementType(sourceColumn);
-                       listElementTypes.put(targetColumnName, listElementType);
+                       if (sourceJoinKeyType != targetJoinKeyType)
+                               throw new 
IllegalArgumentException("\"sourceJoinKey\" has a different type from 
\"targetJoinKey\"!");
+
+                       types.put(targetColumnName, sourceColumnType);
+                       if (sourceColumnType == List.class) {
+                               final Class<?> listElementType = 
sourceTable.getListElementType(sourceColumn);
+                               listElementTypes.put(targetColumnName, 
listElementType);
+                       }
+                       virtualColumnMap.put(
+                                            targetColumnName,
+                                            new VirtualColumn(sourceTable, 
sourceColumn, this, sourceJoinKey, targetJoinKey));
                }
-               virtualColumnMap.put(
-                       targetColumnName,
-                       new VirtualColumn(sourceTable, sourceColumn, this, 
sourceJoinKey, targetJoinKey));
 
+               eventHelper.fireSynchronousEvent(new ColumnCreatedEvent(this, 
targetColumnName));
                return targetColumnName;
        }
 

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