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)
           
 ToDoItem elementAt(int index)
          Deprecated. for 0.25.4 by tfmorris. Use get(int).
 java.util.List<ToDoItem> elementListForOffender(java.lang.Object offender)
           
 java.util.Enumeration<ToDoItem> elements()
          Deprecated. for 0.25.4 by tfmorris. Use getToDoItemList().
 java.util.Vector<ToDoItem> elementsForOffender(java.lang.Object off)
          Deprecated. for 0.25.4 by tfmorris. Use elementListForOffender(Object).
 boolean explicitlyResolve(ToDoItem item, java.lang.String reason)
           
protected  void fireToDoItemAdded(ToDoItem item)
           
protected  void fireToDoItemChanged(ToDoItem item)
           
protected  void fireToDoItemRemoved(ToDoItem item)
           
protected  void fireToDoItemsAdded(java.util.List<ToDoItem> theItems)
           
protected  void fireToDoItemsRemoved(java.util.List<ToDoItem> theItems)
           
protected  void fireToDoListChanged()
          Notify all listeners that have registered interest for notification on this event type.
 void forceValidityCheck()
          Check each ToDoItem on the list to see if it is still valid.
protected  void forceValidityCheck(java.util.List<ToDoItem> removes)
          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.Vector getDecisions()
          Deprecated. by tfmorris for 0.25.4. Use getDecisionList().
static java.util.List<Goal> getGoalList()
           
static java.util.Vector getGoals()
          Deprecated. for 0.25.4 by tfmorris. Use 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.
 java.util.Vector<ToDoItem> getToDoItems()
          Deprecated. for 0.25.4 by tfmorris. Use getToDoItemList().
 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.
protected  void recomputeAllOffenders()
          Re-compute all offenders.
protected  void recomputeAllPosters()
          Reset all posters.
 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().


forceValidityCheck

protected void forceValidityCheck(java.util.List<ToDoItem> removes)
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().

Warning: Fragile code! No method that this method calls can synchronized the Designer, otherwise there will be deadlock.

Parameters:
removes - a synchronized list containing the items to be removed

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

getToDoItems

@Deprecated
public java.util.Vector<ToDoItem> getToDoItems()
Deprecated. for 0.25.4 by tfmorris. Use getToDoItemList().

Returns:
the todo items

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(java.util.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

getDecisions

@Deprecated
public static java.util.Vector getDecisions()
Deprecated. by tfmorris for 0.25.4. Use getDecisionList().

Returns:
the decisions

getDecisionList

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

getGoals

@Deprecated
public static java.util.Vector getGoals()
Deprecated. for 0.25.4 by tfmorris. Use getGoalList().

Returns:
the goals

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.


elementsForOffender

@Deprecated
public java.util.Vector<ToDoItem> elementsForOffender(java.lang.Object off)
Deprecated. for 0.25.4 by tfmorris. Use elementListForOffender(Object).

Parameters:
off - the offender
Returns:
the todo items for this offender

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

elements

@Deprecated
public java.util.Enumeration<ToDoItem> elements()
Deprecated. for 0.25.4 by tfmorris. Use getToDoItemList().

Returns:
the todo items

elementAt

@Deprecated
public ToDoItem elementAt(int index)
Deprecated. for 0.25.4 by tfmorris. Use get(int).

Parameters:
index - an index into the todo items list
Returns:
the item at the index

get

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

recomputeAllOffenders

protected void recomputeAllOffenders()
Re-compute all offenders.


recomputeAllPosters

protected void recomputeAllPosters()
Reset all posters.


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

fireToDoListChanged

protected void fireToDoListChanged()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

fireToDoItemChanged

protected void fireToDoItemChanged(ToDoItem item)
Parameters:
item - the todo item

fireToDoItemAdded

protected void fireToDoItemAdded(ToDoItem item)
Parameters:
item - the todo item

fireToDoItemsAdded

protected void fireToDoItemsAdded(java.util.List<ToDoItem> theItems)
Parameters:
theItems - the todo items

fireToDoItemRemoved

protected void fireToDoItemRemoved(ToDoItem item)
Parameters:
item - the todo item

fireToDoItemsRemoved

protected void fireToDoItemsRemoved(java.util.List<ToDoItem> theItems)
Parameters:
theItems - the todo items

toString

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


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Cookbook