Author: ruschein
Date: 2011-02-11 10:04:53 -0800 (Fri, 11 Feb 2011)
New Revision: 24097
Added:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedEvent.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedListener.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableAboutToBeDeletedEventTest.java
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableDeletedEvent.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableDeletedEventTest.java
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
Log:
Added a new TableAboutToBeDeleted event and listener.
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedEvent.java
(from rev 24095,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableDeletedEvent.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedEvent.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedEvent.java
2011-02-11 18:04:53 UTC (rev 24097)
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ 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.model.CyTable;
+import org.cytoscape.model.CyTableManager;
+
+
+/** This event signals that a table is about to be deleted. */
+public final class TableAboutToBeDeletedEvent extends AbstractTableEvent {
+ /**
+ * @param source the table manager
+ * @param table the table in which is about to be deleted from the
table manager
+ */
+ public TableAboutToBeDeletedEvent(final CyTableManager source, final
CyTable table) {
+ super(source, TableAboutToBeDeletedListener.class, table);
+ }
+}
Copied:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedListener.java
(from rev 24095,
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableDeletedListener.java)
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedListener.java
(rev 0)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableAboutToBeDeletedListener.java
2011-02-11 18:04:53 UTC (rev 24097)
@@ -0,0 +1,9 @@
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.event.CyListener;
+
+
+public interface TableAboutToBeDeletedListener extends CyListener {
+ public void handleEvent(TableAboutToBeDeletedEvent e);
+}
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableDeletedEvent.java
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableDeletedEvent.java
2011-02-11 17:25:15 UTC (rev 24096)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/TableDeletedEvent.java
2011-02-11 18:04:53 UTC (rev 24097)
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2008, 2010, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
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
@@ -28,18 +28,16 @@
package org.cytoscape.model.events;
-import org.cytoscape.model.CyTable;
+import org.cytoscape.event.AbstractCyEvent;
import org.cytoscape.model.CyTableManager;
-/**
- * This event signals that a table has been deleted.
- */
-public final class TableDeletedEvent extends AbstractTableEvent {
+/** This event signals that a table has been deleted. */
+public final class TableDeletedEvent extends AbstractCyEvent<CyTableManager> {
/**
- * @param source The table in which has been deleted from the table
manager
+ * @param source the table manager
*/
- public TableDeletedEvent(final CyTableManager source, final CyTable
table) {
- super(source, TableDeletedListener.class, table);
+ public TableDeletedEvent(final CyTableManager source) {
+ super(source, TableDeletedListener.class);
}
}
Copied:
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableAboutToBeDeletedEventTest.java
(from rev 24095,
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableDeletedEventTest.java)
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableAboutToBeDeletedEventTest.java
(rev 0)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableAboutToBeDeletedEventTest.java
2011-02-11 18:04:53 UTC (rev 24097)
@@ -0,0 +1,24 @@
+package org.cytoscape.model.events;
+
+
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTableManager;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import static org.mockito.Mockito.*;
+
+
+public class TableAboutToBeDeletedEventTest {
+ @Test
+ public final void testGetTable() {
+ final CyTableManager tableManager = mock(CyTableManager.class);
+ final CyTable table = mock(CyTable.class);
+ final TableAboutToBeDeletedEvent event = new
TableAboutToBeDeletedEvent(tableManager, table);
+ assertEquals("TableManager returned by getSource() is *not* the
one passed into the constructor!",
+ tableManager, event.getSource());
+ assertEquals("Table returned by getTable() is *not* the one
passed into the constructor!",
+ table, event.getTable());
+ }
+}
\ No newline at end of file
Modified:
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableDeletedEventTest.java
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableDeletedEventTest.java
2011-02-11 17:25:15 UTC (rev 24096)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/events/TableDeletedEventTest.java
2011-02-11 18:04:53 UTC (rev 24097)
@@ -1,7 +1,6 @@
package org.cytoscape.model.events;
-import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableManager;
import static org.junit.Assert.*;
@@ -14,11 +13,8 @@
@Test
public final void testGetTable() {
final CyTableManager tableManager = mock(CyTableManager.class);
- final CyTable table = mock(CyTable.class);
- final TableDeletedEvent event = new
TableDeletedEvent(tableManager, table);
+ final TableDeletedEvent event = new
TableDeletedEvent(tableManager);
assertEquals("TableManager returned by getSource() is *not* the
one passed into the constructor!",
tableManager, event.getSource());
- assertEquals("Table returned by getTable() is *not* the one
passed into the constructor!",
- table, event.getTable());
}
}
\ No newline at end of file
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-11 17:25:15 UTC (rev 24096)
+++
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
2011-02-11 18:04:53 UTC (rev 24097)
@@ -40,6 +40,7 @@
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTable.Mutability;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.events.TableAboutToBeDeletedEvent;
import org.cytoscape.model.events.TableDeletedEvent;
@@ -130,18 +131,26 @@
@Override
public void deleteTable(final long suid) {
- final CyTableImpl table;
+ CyTableImpl table;
synchronized(this) {
table = (CyTableImpl)tables.get(suid);
if (table == null)
return;
+ }
+ eventHelper.fireSynchronousEvent(new
TableAboutToBeDeletedEvent(this, 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!");
table.removeAllVirtColumns();
tables.remove(suid);
}
- eventHelper.fireSynchronousEvent(new TableDeletedEvent(this,
table));
+ eventHelper.fireSynchronousEvent(new TableDeletedEvent(this));
}
}
--
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.