/src/org/ishafoundation/archives/transcript/components/studio/markup/MarkupsTreeDataDescriptor.as

http://transcriptstudio4isha.googlecode.com/ · ActionScript · 62 lines · 53 code · 9 blank · 0 comment · 6 complexity · 4b515ddf73ad2df4ed4877504e1fa028 MD5 · raw file

  1. package org.ishafoundation.archives.transcript.components.studio.markup
  2. {
  3. import mx.collections.ArrayCollection;
  4. import mx.collections.ICollectionView;
  5. import mx.controls.treeClasses.ITreeDataDescriptor;
  6. import name.carter.mark.flex.project.mdoc.MNode;
  7. import name.carter.mark.flex.project.mdoc.MSegment;
  8. import name.carter.mark.flex.project.mdoc.MSuperNode;
  9. public class MarkupsTreeDataDescriptor implements ITreeDataDescriptor
  10. {
  11. public function MarkupsTreeDataDescriptor()
  12. {
  13. }
  14. public function getChildren(node:Object, model:Object=null):ICollectionView
  15. {
  16. var mnode:MNode = node as MNode;
  17. var result:Array = [];
  18. for each (var child:MNode in mnode.childNodes) {
  19. if (child is MSuperNode) {
  20. result.push(child);
  21. }
  22. else if (child is MSegment) {
  23. for each (var sChild:MNode in child.childNodes) {
  24. if (sChild is MSuperNode) {
  25. result.push(sChild);
  26. }
  27. }
  28. }
  29. }
  30. return new ArrayCollection(result);
  31. }
  32. public function hasChildren(node:Object, model:Object=null):Boolean
  33. {
  34. return getChildren(node).length > 0;
  35. }
  36. public function isBranch(node:Object, model:Object=null):Boolean
  37. {
  38. return hasChildren(node);
  39. }
  40. public function getData(node:Object, model:Object=null):Object
  41. {
  42. return node;
  43. }
  44. public function addChildAt(parent:Object, newChild:Object, index:int, model:Object=null):Boolean
  45. {
  46. throw new Error("not yet implemented");
  47. }
  48. public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean
  49. {
  50. throw new Error("not yet implemented");
  51. }
  52. }
  53. }