svn commit: r14520 - trunk/src/argouml-app/src/org/argouml: cognitive uml/cognitive

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2008-04-29 15:48:32-0700
New Revision: 14520

Modified:
   trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java
   trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java

Log:
Move knowledge of other subsystems out of ToDoItem

Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java?view=diff&rev=14520&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java&r1=14519&r2=14520
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ToDoItem.java	2008-04-29 15:48:32-0700
@@ -30,10 +30,7 @@
 
 import org.argouml.cognitive.critics.Wizard;
 import org.argouml.cognitive.critics.WizardItem;
-import org.argouml.model.Model;
 import org.argouml.util.CollectionUtil;
-import org.tigris.gef.base.Diagram;
-import org.tigris.gef.presentation.Fig;
 
 /**
  * This class defines the feedback items that can be placed on the
@@ -179,17 +176,11 @@
         theWizard = c.makeWizard(this);
     }
 
-    //TODO: The cognitive system should not be aware of any other
-    // system. Find a better way to do this.
-    private void checkArgument(Object dm) {
-        if (!Model.getFacade().isAUMLElement(dm)
-                && !(dm instanceof Fig)
-                && !(dm instanceof Diagram)) {
-
-            throw new IllegalArgumentException(
-                    "The offender must be a model element, "
-                    + "a Fig or a Diagram");
-        }
+    /**
+     * Override in subclass to validate the offender is an expected type.
+     * @param dm the offender (why dm?)
+     */
+    protected void checkArgument(Object dm) {
     }
 
     /**
@@ -334,14 +325,10 @@
      * TODO: Offenders need to be more strongly typed. - tfm 20070630
      */
     public ListSet getOffenders() {
+        // TODO: should not be using assert here but I don't want to change to
+        // IllegalStateException at lead up to a release as I don't know how
+        // much testing is done with assert on.
         assert theOffenders != null;
-        // TODO: The cognitive system should not be aware of any other
-        // system. Find a better way to do this. We should not use
-        // assert on public methods.
-        assert theOffenders.size() <= 0
-        	|| Model.getFacade().isAUMLElement(theOffenders.get(0))
-        	|| theOffenders.get(0) instanceof Fig
-        	|| theOffenders.get(0) instanceof Diagram;
         return theOffenders;
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java?view=diff&rev=14520&p1=trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java&p2=trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java&r1=14519&r2=14520
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/cognitive/UMLToDoItem.java	2008-04-29 15:48:32-0700
@@ -41,7 +41,10 @@
 import org.argouml.cognitive.ToDoItem;
 import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
+import org.argouml.model.Model;
 import org.argouml.ui.ProjectActions;
+import org.tigris.gef.base.Diagram;
+import org.tigris.gef.presentation.Fig;
 
 
 /**
@@ -170,4 +173,30 @@
             }
         }
     }
+    
+    @Override
+    public ListSet getOffenders() {
+        final ListSet offenders = getOffenders();
+        // TODO: should not be using assert here but I don't want to change to
+        // IllegalStateException at lead up to a release as I don't know how
+        // much testing is done with assert on.
+        assert offenders.size() <= 0
+        || Model.getFacade().isAUMLElement(offenders.get(0))
+        || offenders.get(0) instanceof Fig
+        || offenders.get(0) instanceof Diagram;
+        return offenders;
+    }
+    
+    @Override
+    protected void checkArgument(Object dm) {
+        if (!Model.getFacade().isAUMLElement(dm)
+                && !(dm instanceof Fig)
+                && !(dm instanceof Diagram)) {
+
+            throw new IllegalArgumentException(
+                    "The offender must be a model element, "
+                    + "a Fig or a Diagram");
+        }
+    }
+
 }
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.