Groovy Swing Recurse Components


/ Published in: Groovy
Save to your folder(s)

Groovy Swing Recurse Components


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.