Posted By

laurenceosx on 03/14/12


Tagged

groovy


Versions (?)

Groovy Swing Recurse Components


 / Published in: Groovy
 

Groovy Swing Recurse Components

  1. def recurseComp( aComp, results = [] ) {
  2. if ( (aComp != null) && !(aComp in results) ) {
  3. results << aComp;
  4. if ( aComp.properties.components ) {
  5. aComp.components.each {
  6. recurseComp( it, results );
  7. }
  8. }
  9. }
  10. return results;
  11. }
  12.  
  13. def recurseCompByLevel( aComp, results = [], levels = [] ) {
  14. if ( (aComp != null) && !(aComp in results) ) {
  15. results << aComp;
  16. if ( aComp.properties.components ) {
  17.  
  18. levels << aComp.components.collect { it };
  19.  
  20. aComp.components.each {
  21. recurseCompByLevel( it, results, levels );
  22. }
  23. }
  24. }
  25. return levels;
  26. }

Report this snippet  

You need to login to post a comment.