Author: mvw
Date: 2007-05-27 00:25:08-0700
New Revision: 12684
Modified:
trunk/src_new/org/argouml/cognitive/Designer.java
trunk/src_new/org/argouml/cognitive/ToDoList.java
trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java
trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java
Log:
Modified the ToDoList from quasi-singleton to composed by Designer.
Modified: trunk/src_new/org/argouml/cognitive/Designer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/Designer.java?view=diff&rev=12684&p1=trunk/src_new/org/argouml/cognitive/Designer.java&p2=trunk/src_new/org/argouml/cognitive/Designer.java&r1=12683&r2=12684
==============================================================================
--- trunk/src_new/org/argouml/cognitive/Designer.java (original)
+++ trunk/src_new/org/argouml/cognitive/Designer.java 2007-05-27 00:25:08-0700
@@ -80,15 +80,15 @@
private static boolean userWorking;
- private static Vector unspecDecisionVector;
- private static Vector unspecGoalVector;
+ private static Vector<Decision> unspecDecisionVector;
+ private static Vector<Goal> unspecGoalVector;
private static Action saveAction;
static {
- unspecDecisionVector = new Vector();
+ unspecDecisionVector = new Vector<Decision>();
unspecDecisionVector.addElement(Decision.UNSPEC);
- unspecGoalVector = new Vector();
+ unspecGoalVector = new Vector<Goal>();
unspecGoalVector.addElement(Goal.getUnspecifiedGoal());
}
@@ -162,15 +162,15 @@
/**
* dm's that should be critiqued ASAP.
*/
- private Vector hotQueue;
+ private Vector<Object> hotQueue;
- private Vector hotReasonQueue;
+ private Vector<Long> hotReasonQueue;
- private Vector addQueue;
+ private Vector<Object> addQueue;
- private Vector addReasonQueue;
+ private Vector<Long> addReasonQueue;
- private Vector removeQueue;
+ private Vector<Object> removeQueue;
private static int longestAdd;
@@ -179,7 +179,7 @@
/**
* dm's that should be critiqued relatively soon.
*/
- private Vector warmQueue;
+ private Vector<Object> warmQueue;
private ChildGenerator childGenerator;
@@ -215,23 +215,23 @@
agency = new Agency();
prefs = new Properties();
- toDoList = ToDoList.getInstance();
-
+ toDoList = new ToDoList();
toDoList.spawnValidityChecker(this);
+
userWorking = false;
critiquingInterval = 8000;
critiqueCPUPercent = 10;
- hotQueue = new Vector();
- hotReasonQueue = new Vector();
- addQueue = new Vector();
- addReasonQueue = new Vector();
- removeQueue = new Vector();
+ hotQueue = new Vector<Object>();
+ hotReasonQueue = new Vector<Long>();
+ addQueue = new Vector<Object>();
+ addReasonQueue = new Vector<Long>();
+ removeQueue = new Vector<Object>();
longestAdd = 0;
longestHot = 0;
- warmQueue = new Vector();
+ warmQueue = new Vector<Object>();
childGenerator = new EmptyChildGenerator();
@@ -314,7 +314,7 @@
while (hotQueue.size() > 0) {
Object dm = hotQueue.elementAt(0);
Long reasonCode =
- (Long) hotReasonQueue.elementAt(0);
+ hotReasonQueue.elementAt(0);
hotQueue.removeElementAt(0);
hotReasonQueue.removeElementAt(0);
Agency.applyAllCritics(dm, theDesigner(),
@@ -406,7 +406,7 @@
addReasonQueue.addElement(reasonCodeObj);
} else {
Long reasonCodeObj =
- (Long) addReasonQueue.elementAt(addQueueIndex);
+ addReasonQueue.elementAt(addQueueIndex);
long rc = reasonCodeObj.longValue() | rCode;
Long newReasonCodeObj = new Long(rc);
addReasonQueue.setElementAt(newReasonCodeObj, addQueueIndex);
@@ -659,7 +659,9 @@
/*
* @see org.argouml.cognitive.Poster#getSupportedDecisions()
*/
- public Vector getSupportedDecisions() { return unspecDecisionVector; }
+ public Vector<Decision> getSupportedDecisions() {
+ return unspecDecisionVector;
+ }
/*
* @see org.argouml.cognitive.Poster#supports(org.argouml.cognitive.Goal)
@@ -669,7 +671,9 @@
/*
* @see org.argouml.cognitive.Poster#getSupportedGoals()
*/
- public Vector getSupportedGoals() { return unspecGoalVector; }
+ public Vector<Goal> getSupportedGoals() {
+ return unspecGoalVector;
+ }
/*
* @see org.argouml.cognitive.Poster#containsKnowledgeType(java.lang.String)
Modified: trunk/src_new/org/argouml/cognitive/ToDoList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/ToDoList.java?view=diff&rev=12684&p1=trunk/src_new/org/argouml/cognitive/ToDoList.java&p2=trunk/src_new/org/argouml/cognitive/ToDoList.java&r1=12683&r2=12684
==============================================================================
--- trunk/src_new/org/argouml/cognitive/ToDoList.java (original)
+++ trunk/src_new/org/argouml/cognitive/ToDoList.java 2007-05-27 00:25:08-0700
@@ -48,7 +48,7 @@
* the myrid details of their task. It is all to
* easy to skip a step in the design process,
* leave part of the design unspecified, of make
- * a mistake that requires revision. Argo provides
+ * 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,
@@ -60,10 +60,6 @@
* by decision supported, by offending design
* element, etc.<p>
*
- * The to do lists right now are a bit
- * unstable. Please test and let us know
- * what you find through Issuezilla.<p>
- *
* Items are shown under all applicable headings.<p>
*
* This class is dependent on Designer.<p>
@@ -123,12 +119,6 @@
private static int numNotValid;
/**
- * The ToDoList instance that is also the validity checking thread.
- * this thread should probably be factored out...
- */
- private static ToDoList theInstance;
-
- /**
* state variable for whether the validity checking thread is paused
* (waiting).
*/
@@ -138,10 +128,9 @@
// constructor
/**
- * Creates a new todolist. Use getInstance() if you want to create the
- * validity checking thread.
+ * Creates a new todolist. The only ToDoList is owned by the Designer.
*/
- public ToDoList() {
+ ToDoList() {
items = new Vector<ToDoItem>(100);
resolvedItems = new LinkedHashSet<ResolvedCritic>(100);
@@ -152,19 +141,6 @@
}
/**
- * Returns the validity checking thread instance.
- *
- * @return the validity checking thread instance
- */
- public static ToDoList getInstance() {
-
- if (theInstance == null) {
- theInstance = new ToDoList();
- }
- return theInstance;
- }
-
- /**
* Start a Thread to delete old items from the ToDoList.
*
* @param d the designer
@@ -499,7 +475,7 @@
/**
* @param item the todo item
- * @param reason the reason
+ * @param reason the reason TODO: Use it!
* @return <code>true</code> if the argument was a component of this
* vector; <code>false</code> otherwise
* @throws UnresolvableException unable to resolve
@@ -545,10 +521,9 @@
*/
public synchronized void removeAllElements() {
LOG.debug("removing all todo items");
- Vector oldItems = (Vector) items.clone();
- int size = oldItems.size();
- for (int i = 0; i < size; i++) {
- removeE((ToDoItem) oldItems.elementAt(i));
+ Vector<ToDoItem> oldItems = new Vector<ToDoItem>(items);
+ for (ToDoItem tdi : oldItems) {
+ removeE(tdi);
}
recomputeAllOffenders();
Modified: trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java?view=diff&rev=12684&p1=trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java&p2=trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java&r1=12683&r2=12684
==============================================================================
--- trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java (original)
+++ trunk/src_new/org/argouml/cognitive/ui/ToDoPane.java 2007-05-27 00:25:08-0700
@@ -111,7 +111,7 @@
/**
* Vector of TreeModels.
*/
- private Vector perspectives;
+ private Vector<ToDoPerspective> perspectives;
private ToDoPerspective curPerspective;
private ToDoList root;
@@ -133,7 +133,7 @@
combo = new JComboBox();
tree = new DisplayTextTree();
- perspectives = new Vector();
+ perspectives = new Vector<ToDoPerspective>();
countLabel = new JLabel(formatCountLabel(999));
countLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
@@ -189,22 +189,21 @@
/**
* @return the perspectives treemodels
*/
- public Vector getPerspectives() { return perspectives; }
+ public Vector<ToDoPerspective> getPerspectives() { return perspectives; }
/**
* @param pers the perspectives
*/
- public void setPerspectives(Vector pers) {
+ public void setPerspectives(Vector<ToDoPerspective> pers) {
perspectives = pers;
if (pers.isEmpty()) {
curPerspective = null;
} else {
- curPerspective = (ToDoPerspective) pers.elementAt(0);
+ curPerspective = pers.elementAt(0);
}
- java.util.Enumeration persEnum = perspectives.elements();
- while (persEnum.hasMoreElements()) {
- combo.addItem(persEnum.nextElement());
+ for (ToDoPerspective tdp : perspectives) {
+ combo.addItem(tdp);
}
if (pers.isEmpty()) {
@@ -212,7 +211,7 @@
} else if (pers.contains(curPerspective)) {
setCurPerspective(curPerspective);
} else {
- setCurPerspective((ToDoPerspective) perspectives.elementAt(0));
+ setCurPerspective(perspectives.elementAt(0));
}
updateTree();
}
@@ -467,7 +466,9 @@
* @param row the selected row in the tree
* @param path the path in the tree of the selected item
*/
- public static void mySingleClick(int row, TreePath path) {
+ public static void mySingleClick(
+ @SuppressWarnings("unused") int row,
+ @SuppressWarnings("unused") TreePath path) {
clicksInToDoPane++;
}
@@ -478,7 +479,9 @@
* @param row the selected row in the tree
* @param path the path in the tree of the selected item
*/
- public void myDoubleClick(int row, TreePath path) {
+ public void myDoubleClick(
+ @SuppressWarnings("unused") int row,
+ @SuppressWarnings("unused") TreePath path) {
dblClicksInToDoPane++;
if (getSelectedObject() == null) {
return;
@@ -496,7 +499,7 @@
/**
* The perspectives to be chosen in the combobox are built here.
*/
- private static Vector buildPerspectives() {
+ private static Vector<ToDoPerspective> buildPerspectives() {
ToDoPerspective priority = new ToDoByPriority();
ToDoPerspective decision = new ToDoByDecision();
@@ -506,7 +509,7 @@
ToDoPerspective type = new ToDoByType();
// add the perspetives to a vector for the combobox
- Vector perspectives = new Vector();
+ Vector<ToDoPerspective> perspectives = new Vector<ToDoPerspective>();
perspectives.add(priority);
perspectives.add(decision);
Modified: trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java?view=diff&rev=12684&p1=trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java&p2=trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java&r1=12683&r2=12684
==============================================================================
--- trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java (original)
+++ trunk/src_new/org/argouml/ui/cmd/ActionAutoCritique.java 2007-05-27 00:25:08-0700
@@ -29,7 +29,6 @@
import javax.swing.Action;
import org.argouml.cognitive.Designer;
-import org.argouml.cognitive.ToDoList;
import org.argouml.i18n.Translator;
import org.tigris.gef.undo.UndoableAction;
@@ -65,7 +64,8 @@
d.setAutoCritique(!b);
// stop/start cleaning up invalid TodoItems.
- ToDoList.getInstance().setPaused(!ToDoList.getInstance().isPaused());
+ Designer.theDesigner().getToDoList().setPaused(
+ !Designer.theDesigner().getToDoList().isPaused());
}
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.