svn commit: r13552 - trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2007-09-17 12:44:14-0700
New Revision: 13552
Modified:
trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java
Log:
Add support for composite children which aren't otherwise covered. Fix logging typo. Minor efficiency improvements.
Modified: trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java?view=diff&rev=13552&p1=trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java&p2=trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java&r1=13551&r2=13552
==============================================================================
--- trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java (original)
+++ trunk/src_new/org/argouml/uml/cognitive/critics/ChildGenUML.java 2007-09-17 12:44:14-0700
@@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
@@ -35,6 +34,7 @@
import org.argouml.kernel.Project;
import org.argouml.model.Model;
import org.argouml.util.IteratorEnumeration;
+import org.argouml.util.SingleElementIterator;
import org.tigris.gef.base.Diagram;
import org.tigris.gef.util.ChildGenerator;
@@ -74,14 +74,17 @@
* Return an Iterator of the children of the given Object
*
* @param o object to return the children of
+ * @return an iterator over the children of the given object
* @see org.tigris.gef.util.ChildGenerator#gen(java.lang.Object)
*/
public Iterator gen2(Object o) {
- if (o == null) {
- LOG.debug("Object is null");
- } else {
- LOG.debug("Findin g children for " + o.getClass());
+ if (LOG.isDebugEnabled()) {
+ if (o == null) {
+ LOG.debug("Object is null");
+ } else {
+ LOG.debug("Finding children for " + o.getClass());
+ }
}
if (o instanceof Project) {
@@ -108,9 +111,10 @@
}
if (Model.getFacade().isAElementImport(o)) {
- Collection result = new ArrayList();
- result.add(Model.getFacade().getModelElement(o));
- return result.iterator(); //wasteful!
+ Object me = Model.getFacade().getModelElement(o);
+ if (me != null) {
+ return new SingleElementIterator(me);
+ }
}
@@ -171,10 +175,10 @@
return behavior.iterator();
}
}
-
- // tons more cases
- LOG.debug("No children found for: " + o.getClass());
-
- return Collections.EMPTY_SET.iterator();
+
+ // TODO: We can probably use this instead of all of the above
+ // legacy UML 1.3 code - tfm - 20070915
+ Collection result = Model.getFacade().getModelElementContents(o);
+ return result.iterator();
}
}