PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1package 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	
 7	import name.carter.mark.flex.project.mdoc.MNode;
 8	import name.carter.mark.flex.project.mdoc.MSegment;
 9	import name.carter.mark.flex.project.mdoc.MSuperNode;
10
11	public class MarkupsTreeDataDescriptor implements ITreeDataDescriptor
12	{
13		public function MarkupsTreeDataDescriptor()
14		{
15		}
16
17		public function getChildren(node:Object, model:Object=null):ICollectionView
18		{
19			var mnode:MNode = node as MNode;
20			var result:Array = [];
21			for each (var child:MNode in mnode.childNodes) {
22				if (child is MSuperNode) {
23					result.push(child);
24				}
25				else if (child is MSegment) {
26					for each (var sChild:MNode in child.childNodes) {
27						if (sChild is MSuperNode) {
28							result.push(sChild);
29						}						
30					}
31				}
32			}
33			return new ArrayCollection(result);
34		}
35		
36		public function hasChildren(node:Object, model:Object=null):Boolean
37		{
38			return getChildren(node).length > 0;
39		}
40		
41		public function isBranch(node:Object, model:Object=null):Boolean
42		{
43			return hasChildren(node);
44		}
45		
46		public function getData(node:Object, model:Object=null):Object
47		{
48			return node;
49		}
50		
51		public function addChildAt(parent:Object, newChild:Object, index:int, model:Object=null):Boolean
52		{
53			throw new Error("not yet implemented");
54		}
55		
56		public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean
57		{
58			throw new Error("not yet implemented");
59		}
60		
61	}
62}