Author: mes
Date: 2012-04-24 15:33:22 -0700 (Tue, 24 Apr 2012)
New Revision: 28975
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractEdgesEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractNodesEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedListener.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedListener.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedListener.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedListener.java
Removed:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
Modified:
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
Log:
fixes #893 Separated GroupChangedEvent into four separate events
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractEdgesEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractEdgesEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractEdgesEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,32 @@
+
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyEdge;
+import java.util.List;
+import java.util.Collections;
+
+
+abstract class AbstractEdgesEvent extends AbstractCyEvent {
+
+ private final List<CyEdge> edges;
+
+ public AbstractEdgesEvent(final CyGroup source, List<CyEdge> edges,
Class<?> clazz) {
+ super(source, clazz);
+ if ( edges == null )
+ this.edges = Collections.emptyList();
+ else
+ this.edges = edges;
+ }
+
+ /**
+ * Returns the list of edges associated with this event. The list may
+ * be empty, but will not be null.
+ * @return the list of edges associated with this event.
+ */
+ public List<CyEdge> getEdges() {
+ return edges;
+ }
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractNodesEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractNodesEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractNodesEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,32 @@
+
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyNode;
+import java.util.List;
+import java.util.Collections;
+
+
+abstract class AbstractNodesEvent extends AbstractCyEvent {
+
+ private final List<CyNode> nodes;
+
+ public AbstractNodesEvent(final CyGroup source, List<CyNode> nodes,
Class<?> clazz) {
+ super(source, clazz);
+ if ( nodes == null )
+ this.nodes = Collections.emptyList();
+ else
+ this.nodes = nodes;
+ }
+
+ /**
+ * Returns the list of nodes associated with this event. The list may
+ * be empty, but will not be null.
+ * @return the list of nodes associated with this event.
+ */
+ public List<CyNode> getNodes() {
+ return nodes;
+ }
+}
Deleted:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
2012-04-24 21:20:30 UTC (rev 28974)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -1,95 +0,0 @@
-package org.cytoscape.group.events;
-
-import java.util.List;
-
-import org.cytoscape.event.AbstractCyEvent;
-import org.cytoscape.group.CyGroup;
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyIdentifiable;
-
-/**
- * This event signals that a group has changed, either by adding or
- * removing nodes or edges.
- *
- * @CyAPI.Final.Class
- */
-public final class GroupChangedEvent extends AbstractCyEvent<CyGroup> {
- /**
- * An enum describing the type of change that happened to the group.
- */
- public enum ChangeType {
- /** A single node was added. */
- NODE_ADDED,
- /** A single internal edge was added. */
- INTERNAL_EDGE_ADDED,
- /** A single external edge was added. */
- EXTERNAL_EDGE_ADDED,
- /** Mulitple nodes were added. */
- NODES_ADDED,
- /** One or more nodes were removed. */
- NODES_REMOVED,
- /** Multiple edges were added. */
- EDGES_ADDED,
- /** One or more edges were removed. */
- EDGES_REMOVED }
-
- private CyIdentifiable whatChanged;
- private List<CyNode> nodeList;
- private ChangeType change;
-
- /**
- * Constructs event.
- * @param source the {@link CyGroup} that has been changed.
- * @param whatChanged the {@link CyNode} or {@link CyEdge} or list of
{@link CyNode}s that were added or removed.
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public GroupChangedEvent(final CyGroup source, final Object
whatChanged, ChangeType change) {
- super(source, GroupChangedListener.class);
-
- this.whatChanged = null;
- this.change = change;
- this.nodeList = null;
-
- // If this is NODES_ADDED or REMOVED, then the "whatChanged"
argument must be a Collection
- if (change == ChangeType.NODES_ADDED || change ==
ChangeType.NODES_REMOVED) {
- if ((whatChanged instanceof List) &&
(((List)whatChanged).get(0) instanceof CyNode)) {
- this.nodeList = (List<CyNode>) whatChanged;
- } else
- throw new IllegalArgumentException("the
\"whatChanged\" parameter must be a list of nodes for NODES_ADDED or
NODES_REMOVED!");
- } else if ((whatChanged instanceof CyEdge) ||
- (whatChanged instanceof CyNode)) {
- this.whatChanged = (CyIdentifiable) whatChanged;
- } else {
- throw new IllegalArgumentException("the \"whatChanged\"
parameter must be a node or an edge!");
- }
-
- }
-
- /**
- * Get the object that changed. This should either be a CyEdge or a
CyNode.
- *
- * @return the CyTableEntry (CyNode or CyEdge) that was added or
removed.
- */
- public CyIdentifiable getChangedObject() {
- return whatChanged;
- }
-
- /**
- * Get the list of nodes that changed.
- *
- * @return the list of CyNodes that were added or removed.
- */
- public List<CyNode> getChangedNodes() {
- return nodeList;
- }
-
- /**
- * Was the change an add or a removal from the group.
- *
- * @return true if the node or edge was added.
- */
- public ChangeType getChangeType() {
- return change;
- }
-}
Deleted:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
2012-04-24 21:20:30 UTC (rev 28974)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -1,16 +0,0 @@
-package org.cytoscape.group.events;
-
-import org.cytoscape.event.CyListener;
-
-
-/**
- * Listener for {@link GroupChangedEvent}
- * @CyAPI.Spi.Interface
- */
-public interface GroupChangedListener extends CyListener {
- /**
- * The method that should handle the specified event.
- * @param e The event to be handled.
- */
- public void handleEvent(GroupChangedEvent e);
-}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,34 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyEdge;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * This event signals that edges have been added to the network.
+ *
+ * @CyAPI.Final.Class
+ */
+public final class GroupEdgesAddedEvent extends AbstractEdgesEvent {
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param edge A single edge added.
+ */
+ public GroupEdgesAddedEvent(final CyGroup source, CyEdge edge) {
+ this(source, Collections.singletonList(edge));
+ }
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param edges A list of edges added. May be null.
+ */
+ public GroupEdgesAddedEvent(final CyGroup source, List<CyEdge> edges) {
+ super(source, edges, GroupEdgesAddedListener.class);
+ }
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedListener.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedListener.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesAddedListener.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupEdgesAddedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupEdgesAddedListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ public void handleEvent(GroupEdgesAddedEvent e);
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,35 @@
+
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyEdge;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * This event signals that edges have been removed from the network.
+ *
+ * @CyAPI.Final.Class
+ */
+public final class GroupEdgesRemovedEvent extends AbstractEdgesEvent {
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param edge A single edge removed.
+ */
+ public GroupEdgesRemovedEvent(final CyGroup source, CyEdge edge) {
+ this(source, Collections.singletonList(edge));
+ }
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param edges A list of edges removed. May be null.
+ */
+ public GroupEdgesRemovedEvent(final CyGroup source, List<CyEdge> edges)
{
+ super(source, edges, GroupEdgesRemovedListener.class);
+ }
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedListener.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedListener.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupEdgesRemovedListener.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupEdgesRemovedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupEdgesRemovedListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ public void handleEvent(GroupEdgesRemovedEvent e);
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,35 @@
+
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyNode;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * This event signals that edges have been added to the network.
+ *
+ * @CyAPI.Final.Class
+ */
+public final class GroupNodesAddedEvent extends AbstractNodesEvent {
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param node A single node added.
+ */
+ public GroupNodesAddedEvent(final CyGroup source, CyNode node) {
+ this(source, Collections.singletonList(node));
+ }
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param nodes A list of nodes added.
+ */
+ public GroupNodesAddedEvent(final CyGroup source, List<CyNode> nodes) {
+ super(source, nodes, GroupNodesAddedListener.class);
+ }
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedListener.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedListener.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesAddedListener.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupNodesAddedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupNodesAddedListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ public void handleEvent(GroupNodesAddedEvent e);
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedEvent.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,35 @@
+
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyNode;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * This event signals that edges have been removed from the network.
+ *
+ * @CyAPI.Final.Class
+ */
+public final class GroupNodesRemovedEvent extends AbstractNodesEvent {
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param node A single node removed.
+ */
+ public GroupNodesRemovedEvent(final CyGroup source, CyNode node) {
+ this(source, Collections.singletonList(node));
+ }
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that is changing.
+ * @param nodes A list of nodes removed.
+ */
+ public GroupNodesRemovedEvent(final CyGroup source, List<CyNode> nodes)
{
+ super(source, nodes, GroupNodesRemovedListener.class);
+ }
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedListener.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedListener.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupNodesRemovedListener.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupNodesRemovedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupNodesRemovedListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ public void handleEvent(GroupNodesRemovedEvent e);
+}
Modified:
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
===================================================================
---
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
2012-04-24 21:20:30 UTC (rev 28974)
+++
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
2012-04-24 22:33:22 UTC (rev 28975)
@@ -40,7 +40,10 @@
import org.cytoscape.group.CyGroupManager;
import org.cytoscape.group.events.GroupAboutToBeRemovedEvent;
import org.cytoscape.group.events.GroupAddedToNetworkEvent;
-import org.cytoscape.group.events.GroupChangedEvent;
+import org.cytoscape.group.events.GroupNodesAddedEvent;
+import org.cytoscape.group.events.GroupNodesRemovedEvent;
+import org.cytoscape.group.events.GroupEdgesAddedEvent;
+import org.cytoscape.group.events.GroupEdgesRemovedEvent;
import org.cytoscape.group.events.GroupCollapsedEvent;
import org.cytoscape.group.events.GroupAboutToCollapseEvent;
@@ -200,7 +203,7 @@
for (CyNetwork net: collapseSet) {
updateCountAttributes(net);
}
- cyEventHelper.fireEvent(new
GroupChangedEvent(CyGroupImpl.this, node,
GroupChangedEvent.ChangeType.NODE_ADDED));
+ cyEventHelper.fireEvent(new
GroupNodesAddedEvent(CyGroupImpl.this, node));
}
}
@@ -213,7 +216,7 @@
throwIllegalArgumentException("Can only add an edge in
the same network tree");
getGroupNetwork().addEdge(edge);
if (!batchUpdate)
- cyEventHelper.fireEvent(new
GroupChangedEvent(CyGroupImpl.this, edge,
GroupChangedEvent.ChangeType.INTERNAL_EDGE_ADDED));
+ cyEventHelper.fireEvent(new
GroupEdgesAddedEvent(CyGroupImpl.this, edge));
}
/**
@@ -226,7 +229,7 @@
if (!externalEdges.contains(edge))
externalEdges.add(edge);
if (!batchUpdate)
- cyEventHelper.fireEvent(new
GroupChangedEvent(CyGroupImpl.this, edge,
GroupChangedEvent.ChangeType.EXTERNAL_EDGE_ADDED));
+ cyEventHelper.fireEvent(new
GroupEdgesAddedEvent(CyGroupImpl.this, edge));
}
/**
@@ -256,7 +259,7 @@
updateCountAttributes(net);
}
batchUpdate = false;
- cyEventHelper.fireEvent(new GroupChangedEvent(CyGroupImpl.this,
nodes, GroupChangedEvent.ChangeType.NODES_ADDED));
+ cyEventHelper.fireEvent(new
GroupNodesAddedEvent(CyGroupImpl.this, nodes));
}
/**
@@ -274,7 +277,7 @@
else
throwIllegalArgumentException("Attempted to add
an edge that has no node in the group");
}
- cyEventHelper.fireEvent(new GroupChangedEvent(CyGroupImpl.this,
edges, GroupChangedEvent.ChangeType.EDGES_ADDED));
+ cyEventHelper.fireEvent(new
GroupEdgesAddedEvent(CyGroupImpl.this, edges));
}
/**
@@ -302,7 +305,7 @@
for (CyNetwork net: collapseSet) {
updateCountAttributes(net);
}
- cyEventHelper.fireEvent(new GroupChangedEvent(CyGroupImpl.this,
nodes, GroupChangedEvent.ChangeType.NODES_REMOVED));
+ cyEventHelper.fireEvent(new
GroupNodesRemovedEvent(CyGroupImpl.this, nodes));
}
/**
@@ -319,7 +322,7 @@
else if (metaEdges.contains(edge))
metaEdges.remove(edge);
}
- cyEventHelper.fireEvent(new GroupChangedEvent(CyGroupImpl.this,
edges, GroupChangedEvent.ChangeType.EDGES_REMOVED));
+ cyEventHelper.fireEvent(new
GroupEdgesRemovedEvent(CyGroupImpl.this, edges));
}
/**
--
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.