org.argouml.cognitive
Class ToDoList

java.lang.Object
  extended by java.util.Observable
      extended by org.argouml.cognitive.ToDoList
All Implemented Interfaces:
java.lang.Runnable

public class ToDoList
extends java.util.Observable
implements java.lang.Runnable

Implements a list of ToDoItem's.

It spawns a "sweeper" thread that periodically goes through the list and eliminates ToDoItem's that are no longer valid.

One difficulty designers face is keeping track of all the myriad details of their task. It is all too easy to skip a step in the design process, leave part of the design unspecified, or make a mistake that requires revision. ArgoUML provides the designer with a "to do" list user interface that presents action items in an organized form. These items can be suggestions from critics, reminders to finish steps in the process model, or personal notes entered by the designer. The choice control at the top of the "to do" list pane allow the designer to organize items in different ways: by priority, by decision supported, by offending design element, etc.

Items are shown under all applicable headings.

This class is dependent on Designer.

See Also:
Designer.inform(org.argouml.cognitive.ToDoItem)

Method Summary
 void addElement(ToDoItem item)
           
 boolean addResolvedCritic(ResolvedCritic rc)
          Add the given resolved critic to the list of resolved critics.
 void addToDoListListener(ToDoListListener l)
           
 java.util.List<ToDoItem> elementListForOffender(java.lang.Object offender)
           
 boolean explicitlyResolve(ToDoItem item, java.lang.String reason)
           
protected  void fireToDoItemChanged(ToDoItem item)
          Deprecated. in 0.27.2 by Bob Tarling. ToDoList is not designed to be extended so protected is not required. This method is not used with the package so scope will become private in future.
 void forceValidityCheck()
          Check each ToDoItem on the list to see if it is still valid.
 ToDoItem get(int index)
           
static java.util.List<Decision> getDecisionList()
           
static java.util.List<Goal> getGoalList()
           
 ListSet getOffenders()
           
 ListSet<Poster> getPosters()
           
 java.util.Set<ResolvedCritic> getResolvedItems()
          Returns the set of ResolvedCritics.
 java.util.List<ToDoItem> getToDoItemList()
          Returns the List of the ToDoItems.
 boolean isPaused()
           
 void notifyObservers()
           
 void notifyObservers(java.lang.Object o)
           
 void notifyObservers(java.lang.String action, java.lang.Object arg)
           
 void pause()
          Pause the validity checking thread.
 void removeAll(ToDoList list)
           
 void removeAllElements()
          Remove all todo items.
 boolean removeElement(ToDoItem item)
           
 void removeToDoListListener(ToDoListListener l)
           
 boolean resolve(ToDoItem item)
           
 void resume()
          Resume the validity checking thread.
 void run()
          Entry point for validity checker thread.
 void setPaused(boolean paused)
          sets the pause state.
 int size()
           
 void spawnValidityChecker(Designer d)
          Start a Thread to delete old items from the ToDoList.
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

spawnValidityChecker

public void spawnValidityChecker(Designer d)
Start a Thread to delete old items from the ToDoList.

Parameters:
d - the designer

run

public void run()
Entry point for validity checker thread. Periodically check to see if items on the list are still valid.

Specified by:
run in interface java.lang.Runnable

forceValidityCheck

public void forceValidityCheck()
Check each ToDoItem on the list to see if it is still valid. If not, then remove that item. This is called automatically by the ValidityCheckingThread, and it can be called by the user pressing a button via forceValidityCheck().


pause

public void pause()
Pause the validity checking thread.


resume

public void resume()
Resume the validity checking thread.


isPaused

public boolean isPaused()
Returns:
true is paused

setPaused

public void setPaused(boolean paused)
sets the pause state.

Parameters:
paused - if set to false, calls resume() also to start working

notifyObservers

public void notifyObservers(java.lang.String action,
                            java.lang.Object arg)
Parameters:
action - the action
arg - the argument

notifyObservers

public void notifyObservers(java.lang.Object o)
Overrides:
notifyObservers in class java.util.Observable

notifyObservers

public void notifyObservers()
Overrides:
notifyObservers in class java.util.Observable

getToDoItemList

public java.util.List<ToDoItem> getToDoItemList()
Returns the List of the ToDoItems. It is mandatory that code iterating over this list synchronize access to the list as described in Collections.synchronizedList(List).
  List list = toDoList.getToDoItemList();
      ...
  synchronized(list) {
      for (ToDoItem item : list ) { // Must be in synchronized block
      ....
  }
 

Returns:
the List of ToDo items.
See Also:
Collections.synchronizedList(List)

getResolvedItems

public java.util.Set<ResolvedCritic> getResolvedItems()
Returns the set of ResolvedCritics. It is mandatory that code iterating over this set synchronize access to the set as described in Collections.synchronizedSet(Set).
  Set set = toDoList.getResolvedItems();
      ...
  synchronized(set) {
      for (ResolvedCritic item : set ) { // Must be in synchronized block
      ....
  }
 

Returns:
the resolved items
See Also:
Collections.synchronizedSet(Set)

getOffenders

public ListSet getOffenders()
Returns:
the set of offenders TODO: The return value needs to be more strongly typed. - tfm - 20070630

getPosters

public ListSet<Poster> getPosters()
Returns:
the set of all the posters

getDecisionList

public static java.util.List<Decision> getDecisionList()
Returns:
the list of Decisions (empty by default).

getGoalList

public static java.util.List<Goal> getGoalList()
Returns:
The list of Goals (empty by default).

addElement

public void addElement(ToDoItem item)
Parameters:
item - the todo item to be added

removeAll

public void removeAll(ToDoList list)
Parameters:
list - the todo items to be removed

removeElement

public boolean removeElement(ToDoItem item)
Parameters:
item - the todo item to be removed
Returns:
true if the argument was a component of this list; false otherwise

resolve

public boolean resolve(ToDoItem item)
Parameters:
item - the todo item to be resolved
Returns:
true if the argument was a component of this list; false otherwise

explicitlyResolve

public boolean explicitlyResolve(ToDoItem item,
                                 java.lang.String reason)
                          throws UnresolvableException
Parameters:
item - the todo item
reason - the reason TODO: Use it!
Returns:
true if the argument was a component of this list; false otherwise
Throws:
UnresolvableException - unable to resolve

addResolvedCritic

public boolean addResolvedCritic(ResolvedCritic rc)
Add the given resolved critic to the list of resolved critics.

Parameters:
rc - the resolved critic
Returns:
true if successfully added; false otherwise

removeAllElements

public void removeAllElements()
Remove all todo items.


elementListForOffender

public java.util.List<ToDoItem> elementListForOffender(java.lang.Object offender)
Parameters:
offender - the offender
Returns:
A List of todo items for this offender.

Note: the previous implementation returned an internal static (global) list which could be modified at any point, requiring the caller to copy the list before using it (negating the value of caching the static copy). The current implementation returns a private copy which will not change, so callers don't need to copy it.


size

public int size()
Returns:
the number of todo items

get

public ToDoItem get(int index)
Parameters:
index - 0-based index to retrieve ToDoItem from
Returns:
the ToDoItem at the given index

addToDoListListener

public void addToDoListListener(ToDoListListener l)
Parameters:
l - the listener to be added

removeToDoListListener

public void removeToDoListListener(ToDoListListener l)
Parameters:
l - the listener to be removed

fireToDoItemChanged

@Deprecated
protected void fireToDoItemChanged(ToDoItem item)
Deprecated. in 0.27.2 by Bob Tarling. ToDoList is not designed to be extended so protected is not required. This method is not used with the package so scope will become private in future.

Parameters:
item - the todo item

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook