Author: bobtarling
Date: 2008-11-03 14:31:47-0800
New Revision: 15963
Modified:
trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java
trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java
Log:
Remove excessive duplication of todo items for events
Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java?view=diff&rev=15963&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java&r1=15962&r2=15963
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java (original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ToDoList.java 2008-11-03 14:31:47-0800
@@ -246,7 +246,7 @@
}
recomputeAllOffenders();
recomputeAllPosters();
- fireToDoItemsRemoved(Collections.unmodifiableList(removes));
+ fireToDoItemsRemoved(removes);
}
}
@@ -769,18 +769,20 @@
* @param theItems the todo items
*/
protected void fireToDoItemsAdded(List<ToDoItem> theItems) {
- // Guaranteed to return a non-null array
- Object[] listeners = listenerList.getListenerList();
- ToDoListEvent e = null;
- // Process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length - 2; i >= 0; i -= 2) {
- if (listeners[i] == ToDoListListener.class) {
- // Lazily create the event:
- if (e == null) {
- e = new ToDoListEvent(theItems);
+ if (theItems.size() > 0) {
+ // Guaranteed to return a non-null array
+ final Object[] listeners = listenerList.getListenerList();
+ ToDoListEvent e = null;
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == ToDoListListener.class) {
+ // Lazily create the event:
+ if (e == null) {
+ e = new ToDoListEvent(theItems);
+ }
+ ((ToDoListListener) listeners[i + 1]).toDoItemsAdded(e);
}
- ((ToDoListListener) listeners[i + 1]).toDoItemsAdded(e);
}
}
}
@@ -797,21 +799,21 @@
/**
* @param theItems the todo items
*/
- protected void fireToDoItemsRemoved(List<ToDoItem> theItems) {
- List<ToDoItem> toDoItems = null;
- // Guaranteed to return a non-null array
- Object[] listeners = listenerList.getListenerList();
- ToDoListEvent e = null;
- // Process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length - 2; i >= 0; i -= 2) {
- if (listeners[i] == ToDoListListener.class) {
- // Lazily create the event:
- if (e == null) {
- toDoItems = Collections.unmodifiableList(theItems);
- e = new ToDoListEvent(toDoItems);
+ protected void fireToDoItemsRemoved(final List<ToDoItem> theItems) {
+ if (theItems.size() > 0) {
+ // Guaranteed to return a non-null array
+ final Object[] listeners = listenerList.getListenerList();
+ ToDoListEvent e = null;
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == ToDoListListener.class) {
+ // Lazily create the event:
+ if (e == null) {
+ e = new ToDoListEvent(theItems);
+ }
+ ((ToDoListListener) listeners[i + 1]).toDoItemsRemoved(e);
}
- ((ToDoListListener) listeners[i + 1]).toDoItemsRemoved(e);
}
}
}
Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java?view=diff&rev=15963&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java&r1=15962&r2=15963
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java (original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ToDoListEvent.java 2008-11-03 14:31:47-0800
@@ -25,7 +25,7 @@
package org.argouml.cognitive;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Vector;
@@ -35,7 +35,7 @@
*/
public class ToDoListEvent {
- private List<ToDoItem> items = new ArrayList<ToDoItem>();
+ private final List<ToDoItem> items;
/**
* The constructor.
@@ -50,10 +50,10 @@
* Make a copy of the list to guarantee that it remains
* stable throughout the lifetime of this event.
*
- * @param i the List of ToDoItems that were changed/added/removed
+ * @param toDoItems the List of ToDoItems that were changed/added/removed
*/
- public ToDoListEvent(List<ToDoItem> i) {
- items.addAll(i);
+ public ToDoListEvent(final List<ToDoItem> toDoItems) {
+ items = Collections.unmodifiableList(toDoItems);
}
/**
@@ -71,5 +71,4 @@
public List<ToDoItem> getToDoItemList() {
return items;
}
-
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.