Author: mvw
Date: 2007-07-15 01:19:01-0700
New Revision: 13073
Modified:
trunk/src_new/org/argouml/i18n/critics.properties
trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java
trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java
Log:
Worked out a TODO in CrTooManyClasses: implemented the right intention of this critic.
Modified: trunk/src_new/org/argouml/i18n/critics.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/i18n/critics.properties?view=diff&rev=13073&p1=trunk/src_new/org/argouml/i18n/critics.properties&p2=trunk/src_new/org/argouml/i18n/critics.properties&r1=13072&r2=13073
==============================================================================
--- trunk/src_new/org/argouml/i18n/critics.properties (original)
+++ trunk/src_new/org/argouml/i18n/critics.properties 2007-07-15 01:19:01-0700
@@ -711,13 +711,15 @@
line of text for an attribute.
critics.CrTooManyAttr-head = Reduce Attributes on <ocl>self</ocl>
critics.CrTooManyClasses-desc = There are too many classes in <ocl>self</ocl>. \
- If one class diagram has too many classes it may become very difficult \
- for humans to understand. \n\nDefining an understandable set of class \
- diagrams is an important part of your design. \n\nTo address this, \
- press the \"Next>\" button, or remove classes manually by clicking on \
- a class in the navigator pane or diagram and pressing the \"Del\" key. \
- Or you can make a new diagram...
-critics.CrTooManyClasses-head = Reduce Classes in Diagram <ocl>self</ocl>
+ If one namespace (i.e. model, package, class, etc.) \
+ has too many classes it may become very difficult \
+ for humans to understand. \n\nDefining an understandable \
+ namespace structure is an important part of your design. \
+ \nMove some classes into another namespace \
+ by click and drag in the explorer. \
+ \n\nTo change the treshold that triggers this critic \
+ press the \"Next>\" button.
+critics.CrTooManyClasses-head = Reduce Classes in Namespace <ocl>self</ocl>
critics.CrTooManyOper-desc = There are too many Operations on class \
<ocl>self</ocl>. Whenever one class becomes too central to the design \
it may become a maintenance bottleneck that must be updated \
Modified: trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java?view=diff&rev=13073&p1=trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java&p2=trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java&r1=13072&r2=13073
==============================================================================
--- trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java (original)
+++ trunk/src_new/org/argouml/uml/cognitive/critics/CrTooManyClasses.java 2007-07-15 01:19:01-0700
@@ -24,15 +24,15 @@
package org.argouml.uml.cognitive.critics;
+import java.util.ArrayList;
+import java.util.Collection;
+
import org.argouml.cognitive.Designer;
+import org.argouml.model.Model;
import org.argouml.uml.cognitive.UMLDecision;
-import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
/**
- * A critic to detect when a classdiagram has too many classes. <p>
- *
- * TODO: currently it checks for nodes (classes, interfaces, comments).
- * This critic should be rewritten to work with namespaces.
+ * A critic to detect when a namespace has too many classes.
*/
public class CrTooManyClasses extends AbstractCrTooMany {
@@ -45,10 +45,10 @@
* The constructor.
*/
public CrTooManyClasses() {
- // TODO: <ocl>self.name</ocl> is not expanded for diagram objects
- setupHeadAndDesc();
+ setupHeadAndDesc();
addSupportedDecision(UMLDecision.CLASS_SELECTION);
setThreshold(CLASS_THRESHOLD);
+ addTrigger("ownedElement");
}
/*
@@ -56,12 +56,18 @@
* java.lang.Object, org.argouml.cognitive.Designer)
*/
public boolean predicate2(Object dm, Designer dsgr) {
- if (!(dm instanceof UMLClassDiagram)) {
+ if (!(Model.getFacade().isANamespace(dm))) {
return NO_PROBLEM;
}
- UMLClassDiagram d = (UMLClassDiagram) dm;
- if (d.getGraphModel().getNodes().size() <= getThreshold()) {
+ Collection subs = Model.getFacade().getOwnedElements(dm);
+ Collection<Object> classes = new ArrayList<Object>();
+ for (Object me : subs) {
+ if (Model.getFacade().isAClass(me)) {
+ classes.add(me);
+ }
+ }
+ if (classes.size() <= getThreshold()) {
return NO_PROBLEM;
}
return PROBLEM_FOUND;
Modified: trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java?view=diff&rev=13073&p1=trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java&p2=trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java&r1=13072&r2=13073
==============================================================================
--- trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java (original)
+++ trunk/src_new/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java 2007-07-15 01:19:01-0700
@@ -34,7 +34,6 @@
import org.argouml.cognitive.Critic;
import org.argouml.model.Model;
import org.argouml.uml.diagram.deployment.ui.UMLDeploymentDiagram;
-import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
import org.argouml.uml.diagram.ui.UMLDiagram;
@@ -292,6 +291,7 @@
Object synchStateCls = Model.getMetaTypes().getSynchState();
// Class stateDiagramCls = UMLStateDiagram.class;
// Class useCaseDiagramCls = UMLUseCaseDiagram.class;
+ // Class classDiagramCls = UMLClassDiagram.class;
// TODO: Agency should allow registration by interface
// useful for MAssociation.
@@ -360,8 +360,7 @@
Agency.register(crTooManyOper, classCls);
Agency.register(crTooManyTransitions, stateVertexCls);
Agency.register(crTooManyStates, compositieStateCls);
- Class classDiagramCls = UMLClassDiagram.class;
- Agency.register(crTooManyClasses, classDiagramCls);
+ Agency.register(crTooManyClasses, namespaceCls);
Object pseudostateCls = Model.getMetaTypes().getPseudostate();
Object transitionCls = Model.getMetaTypes().getTransition();
Agency.register(noTrans1, stateVertexCls);
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.