/* start module: pyjamas.ui.Tree */
$pyjs['loaded_modules']['pyjamas.ui.Tree'] = function (__mod_name__) {
	if($pyjs['loaded_modules']['pyjamas.ui.Tree']['__was_initialized__']) return $pyjs['loaded_modules']['pyjamas.ui.Tree'];
	if(typeof $pyjs['loaded_modules']['pyjamas.ui'] == 'undefined' || !$pyjs['loaded_modules']['pyjamas.ui']['__was_initialized__']) $p['___import___']('pyjamas.ui', null);
	var $m = $pyjs['loaded_modules']['pyjamas.ui.Tree'];
	$m['__repr__'] = function() { return '<module: pyjamas.ui.Tree>'; };
	$m['__was_initialized__'] = true;
	if ((__mod_name__ === null) || (typeof __mod_name__ == 'undefined')) __mod_name__ = 'pyjamas.ui.Tree';
	$m['__name__'] = __mod_name__;
	$pyjs['loaded_modules']['pyjamas.ui']['Tree'] = $pyjs['loaded_modules']['pyjamas.ui.Tree'];


	$m['DOM'] = $p['___import___']('pyjamas.DOM', 'pyjamas.ui', null, false);
	$m['Factory'] = $p['___import___']('pyjamas.Factory', 'pyjamas.ui', null, false);
	$m['Set'] = $p['___import___']('sets.Set', 'pyjamas.ui', null, false);
	$m['pygwt'] = $p['___import___']('pygwt', 'pyjamas.ui');
	$m['Widget'] = $p['___import___']('pyjamas.ui.Widget.Widget', 'pyjamas.ui', null, false);
	$m['Event'] = $p['___import___']('pyjamas.ui.Event', 'pyjamas.ui', null, false);
	$m['Focus'] = $p['___import___']('pyjamas.ui.Focus', 'pyjamas.ui', null, false);
	$m['RootTreeItem'] = $p['___import___']('pyjamas.ui.TreeItem.RootTreeItem', 'pyjamas.ui', null, false);
	$m['TreeItem'] = $p['___import___']('pyjamas.ui.TreeItem.TreeItem', 'pyjamas.ui', null, false);
	$m['MouseListener'] = $p['___import___']('pyjamas.ui.MouseListener', 'pyjamas.ui', null, false);
	$m['KeyboardListener'] = $p['___import___']('pyjamas.ui.KeyboardListener', 'pyjamas.ui', null, false);
	$m['FocusListener'] = $p['___import___']('pyjamas.ui.FocusListener', 'pyjamas.ui', null, false);
	$m['Tree'] = (function(){
		var $cls_definition = new Object();
		var $method;
		$cls_definition['__module__'] = 'pyjamas.ui.Tree';
		$method = $pyjs__bind_method2('__init__', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
				var ka = arguments['length'] >= 1 ? arguments[arguments['length']-1] : arguments[arguments['length']];
				if (ka === null || typeof ka != 'object' || ka['__name__'] != 'dict' || typeof ka['$pyjs_is_kwarg'] == 'undefined') {
					var ka = arguments[arguments['length']+1];
				} else {
					delete ka['$pyjs_is_kwarg'];
				}
			} else {
				var self = arguments[0];
				var ka = arguments['length'] >= 2 ? arguments[arguments['length']-1] : arguments[arguments['length']];
				if (ka === null || typeof ka != 'object' || ka['__name__'] != 'dict' || typeof ka['$pyjs_is_kwarg'] == 'undefined') {
					ka = arguments[arguments['length']+1];
				} else {
					delete ka['$pyjs_is_kwarg'];
				}
			}
			if (typeof ka == 'undefined') {
				ka = $p['__empty_dict']();
				if (typeof self != 'undefined') {
					if (self !== null && typeof self['$pyjs_is_kwarg'] != 'undefined') {
						ka = self;
						self = arguments[1];
					}
				} else {
				}
			}
			var element,$or1,$or2;
			ka['__setitem__']('StyleName', ka['get']('StyleName', 'gwt-Tree'));
			self['root'] = null;
			self['childWidgets'] = $m['Set']();
			self['curSelection'] = null;
			self['focusable'] = null;
			self['focusListeners'] = $p['list']([]);
			self['mouseListeners'] = $p['list']([]);
			self['images'] = ka['pop']('Images', false);
			self['imageBase'] = $m['pygwt']['getImageBaseURL']($p['getattr'](self, 'images'));
			self['keyboardListeners'] = $p['list']([]);
			self['listeners'] = $p['list']([]);
			self['lastEventType'] = '';
			element = ($p['bool']($or1=ka['pop']('Element', null))?$or1:$m['DOM']['createDiv']());
			self['setElement'](element);
			$m['DOM']['setStyleAttribute'](self['getElement'](), 'position', 'relative');
			self['focusable'] = $m['Focus']['createFocusable']();
			$m['DOM']['setStyleAttribute']($p['getattr'](self, 'focusable'), 'outline', '0px');
			$m['DOM']['setElemAttribute']($p['getattr'](self, 'focusable'), 'hideFocus', 'true');
			$m['DOM']['setStyleAttribute']($p['getattr'](self, 'focusable'), 'fontSize', '0');
			$m['DOM']['setStyleAttribute']($p['getattr'](self, 'focusable'), 'position', 'absolute');
			$m['DOM']['setIntStyleAttribute']($p['getattr'](self, 'focusable'), 'zIndex', (typeof ($usub1=1)=='number'?
				-$usub1:
				$p['op_usub']($usub1)));
			$m['DOM']['appendChild'](self['getElement'](), $p['getattr'](self, 'focusable'));
			self['root'] = $m['RootTreeItem']();
			self['root']['setTree'](self);
			$pyjs_kwargs_call($m['Widget'], '__init__', null, ka, [{}, self]);
			self['sinkEvents'](($p['getattr']($m['Event'], 'ONMOUSEDOWN'))|($p['getattr']($m['Event'], 'ONCLICK'))|($p['getattr']($m['Event'], 'KEYEVENTS')));
			$m['DOM']['sinkEvents']($p['getattr'](self, 'focusable'), $p['getattr']($m['Event'], 'FOCUSEVENTS'));
			return null;
		}
	, 1, [null,['ka'],['self']]);
		$cls_definition['__init__'] = $method;
		$method = $pyjs__bind_method2('add', function(widget) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				widget = arguments[1];
			}

			self['addItem'](widget);
			return null;
		}
	, 1, [null,null,['self'],['widget']]);
		$cls_definition['add'] = $method;
		$method = $pyjs__bind_method2('addFocusListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['focusListeners']['append'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['addFocusListener'] = $method;
		$method = $pyjs__bind_method2('addItem', function(item) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
			}

			return self['insertItem'](item);
		}
	, 1, [null,null,['self'],['item']]);
		$cls_definition['addItem'] = $method;
		$method = $pyjs__bind_method2('insertItem', function(item, index) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
				index = arguments[2];
			}
			if (typeof index == 'undefined') index=arguments['callee']['__args__'][4][1];
			var ret;
			if ($p['bool']($p['isinstance'](item, $p['basestring']))) {
				item = $m['TreeItem'](item);
			}
			ret = self['root']['addItem'](item);
			if ($p['bool']((index === null))) {
				$m['DOM']['appendChild'](self['getElement'](), item['getElement']());
			}
			else {
				$m['DOM']['insertChild'](self['getElement'](), item['getElement'](), index);
			}
			return ret;
		}
	, 1, [null,null,['self'],['item'],['index', null]]);
		$cls_definition['insertItem'] = $method;
		$method = $pyjs__bind_method2('addKeyboardListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['keyboardListeners']['append'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['addKeyboardListener'] = $method;
		$method = $pyjs__bind_method2('addMouseListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['mouseListeners']['append'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['addMouseListener'] = $method;
		$method = $pyjs__bind_method2('addTreeListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['listeners']['append'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['addTreeListener'] = $method;
		$method = $pyjs__bind_method2('clear', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}
			var $iter1_nextval,$iter1_type,$iter1_idx,i,$iter1_iter,$iter1_array,$sub2,$sub1,size;
			size = self['root']['getChildCount']();
			$iter1_iter = $p['range'](size, 0, (typeof ($usub2=1)=='number'?
				-$usub2:
				$p['op_usub']($usub2)));
			$iter1_nextval=$p['__iter_prepare']($iter1_iter,false);
			while (typeof($p['__wrapped_next']($iter1_nextval)['$nextval']) != 'undefined') {
				i = $iter1_nextval['$nextval'];
				self['root']['getChild']($p['__op_sub']($sub1=i,$sub2=1))['remove']();
			}
			return null;
		}
	, 1, [null,null,['self']]);
		$cls_definition['clear'] = $method;
		$method = $pyjs__bind_method2('ensureSelectedItemVisible', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}
			var parent;
			if ($p['bool'](($p['getattr'](self, 'curSelection') === null))) {
				return null;
			}
			parent = self['curSelection']['getParentItem']();
			while ($p['bool']((parent !== null))) {
				parent['setState'](true);
				parent = parent['getParentItem']();
			}
			return null;
		}
	, 1, [null,null,['self']]);
		$cls_definition['ensureSelectedItemVisible'] = $method;
		$method = $pyjs__bind_method2('getImageBase', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return $p['getattr'](self, 'imageBase');
		}
	, 1, [null,null,['self']]);
		$cls_definition['getImageBase'] = $method;
		$method = $pyjs__bind_method2('getImages', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return $p['getattr'](self, 'images');
		}
	, 1, [null,null,['self']]);
		$cls_definition['getImages'] = $method;
		$method = $pyjs__bind_method2('getItem', function(index) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				index = arguments[1];
			}

			return self['root']['getChild'](index);
		}
	, 1, [null,null,['self'],['index']]);
		$cls_definition['getItem'] = $method;
		$method = $pyjs__bind_method2('getItemCount', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return self['root']['getChildCount']();
		}
	, 1, [null,null,['self']]);
		$cls_definition['getItemCount'] = $method;
		$method = $pyjs__bind_method2('getSelectedItem', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return $p['getattr'](self, 'curSelection');
		}
	, 1, [null,null,['self']]);
		$cls_definition['getSelectedItem'] = $method;
		$method = $pyjs__bind_method2('getTabIndex', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return $m['Focus']['getTabIndex']($p['getattr'](self, 'focusable'));
		}
	, 1, [null,null,['self']]);
		$cls_definition['getTabIndex'] = $method;
		$method = $pyjs__bind_method2('__iter__', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return self['root']['__iter__']();
		}
	, 1, [null,null,['self']]);
		$cls_definition['__iter__'] = $method;
		$method = $pyjs__bind_method2('onBrowserEvent', function(event) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				event = arguments[1];
			}
			var $or4,keycode,e,chain,$or3,$and1,item,etype,$and2;
			etype = $m['DOM']['eventGetType'](event);
			if ($p['bool']($p['op_eq'](etype, 'click'))) {
				e = $m['DOM']['eventGetTarget'](event);
				if ($p['bool'](($p['bool']($and1=!$p['bool'](self['shouldTreeDelegateFocusToElement'](e)))?($p['getattr'](self, 'curSelection') !== null):$and1))) {
					self['setFocus'](true);
				}
			}
			else if ($p['bool']($p['getattr']($m['MouseListener'], 'MOUSE_EVENTS')['__contains__'](etype))) {
				if ($p['bool']($p['op_eq'](etype, 'mousedown'))) {
					self['elementClicked']($p['getattr'](self, 'root'), $m['DOM']['eventGetTarget'](event));
				}
				$m['MouseListener']['fireMouseEvent']($p['getattr'](self, 'mouseListeners'), self, event);
			}
			else if ($p['bool'](($p['bool']($or3=$p['op_eq'](etype, 'blur'))?$or3:$p['op_eq'](etype, 'focus')))) {
				$m['FocusListener']['fireFocusEvent']($p['getattr'](self, 'focusListeners'), self, event);
			}
			else if ($p['bool']($p['op_eq'](etype, 'keydown'))) {
				if ($p['bool'](($p['getattr'](self, 'curSelection') === null))) {
					if ($p['bool'](($p['cmp'](self['root']['getChildCount'](), 0) == 1))) {
						self['onSelection'](self['root']['getChild'](0), true);
					}
					$m['Widget']['onBrowserEvent'](self, event);
					return null;
				}
				if ($p['bool']($p['op_eq']($p['getattr'](self, 'lastEventType'), 'keydown'))) {
					return null;
				}
				keycode = $m['DOM']['eventGetKeyCode'](event);
				if ($p['bool']($p['op_eq'](keycode, $p['getattr']($m['KeyboardListener'], 'KEY_UP')))) {
					self['moveSelectionUp']($p['getattr'](self, 'curSelection'), true);
					$m['DOM']['eventPreventDefault'](event);
				}
				else if ($p['bool']($p['op_eq'](keycode, $p['getattr']($m['KeyboardListener'], 'KEY_DOWN')))) {
					self['moveSelectionDown']($p['getattr'](self, 'curSelection'), true);
					$m['DOM']['eventPreventDefault'](event);
				}
				else if ($p['bool']($p['op_eq'](keycode, $p['getattr']($m['KeyboardListener'], 'KEY_LEFT')))) {
					if ($p['bool'](self['curSelection']['getState']())) {
						self['curSelection']['setState'](false);
					}
					$m['DOM']['eventPreventDefault'](event);
				}
				else if ($p['bool']($p['op_eq'](keycode, $p['getattr']($m['KeyboardListener'], 'KEY_RIGHT')))) {
					if ($p['bool'](!$p['bool'](self['curSelection']['getState']()))) {
						self['curSelection']['setState'](true);
					}
					$m['DOM']['eventPreventDefault'](event);
				}
			}
			else if ($p['bool']($p['op_eq'](etype, 'keyup'))) {
				if ($p['bool']($p['op_eq']($m['DOM']['eventGetKeyCode'](event), $p['getattr']($m['KeyboardListener'], 'KEY_TAB')))) {
					chain = $p['list']([]);
					self['collectElementChain'](chain, self['getElement'](), $m['DOM']['eventGetTarget'](event));
					item = self['findItemByChain'](chain, 0, $p['getattr'](self, 'root'));
					if ($p['bool'](!$p['op_eq'](item, self['getSelectedItem']()))) {
						self['setSelectedItem'](item, true);
					}
				}
			}
			else if ($p['bool']($p['op_eq'](etype, 'keypress'))) {
				$m['KeyboardListener']['fireKeyboardEvent']($p['getattr'](self, 'keyboardListeners'), self, event);
			}
			$m['Widget']['onBrowserEvent'](self, event);
			self['lastEventType'] = etype;
			return null;
		}
	, 1, [null,null,['self'],['event']]);
		$cls_definition['onBrowserEvent'] = $method;
		$method = $pyjs__bind_method2('remove', function(widget) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				widget = arguments[1];
			}

			throw ($p['Exception']('Widgets should never be directly removed from a tree'));
			return null;
		}
	, 1, [null,null,['self'],['widget']]);
		$cls_definition['remove'] = $method;
		$method = $pyjs__bind_method2('removeFocusListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['focusListeners']['remove'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['removeFocusListener'] = $method;
		$method = $pyjs__bind_method2('removeItem', function(item) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
			}

			self['root']['removeItem'](item);
			$m['DOM']['removeChild'](self['getElement'](), item['getElement']());
			return null;
		}
	, 1, [null,null,['self'],['item']]);
		$cls_definition['removeItem'] = $method;
		$method = $pyjs__bind_method2('removeItems', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			while ($p['bool'](($p['cmp'](self['getItemCount'](), 0) == 1))) {
				self['removeItem'](self['getItem'](0));
			}
			return null;
		}
	, 1, [null,null,['self']]);
		$cls_definition['removeItems'] = $method;
		$method = $pyjs__bind_method2('removeKeyboardListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['keyboardListeners']['remove'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['removeKeyboardListener'] = $method;
		$method = $pyjs__bind_method2('removeTreeListener', function(listener) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				listener = arguments[1];
			}

			self['listeners']['remove'](listener);
			return null;
		}
	, 1, [null,null,['self'],['listener']]);
		$cls_definition['removeTreeListener'] = $method;
		$method = $pyjs__bind_method2('setAccessKey', function(key) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				key = arguments[1];
			}

			$m['Focus']['setAccessKey']($p['getattr'](self, 'focusable'), key);
			return null;
		}
	, 1, [null,null,['self'],['key']]);
		$cls_definition['setAccessKey'] = $method;
		$method = $pyjs__bind_method2('setFocus', function(focus) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				focus = arguments[1];
			}

			if ($p['bool'](focus)) {
				$m['Focus']['focus']($p['getattr'](self, 'focusable'));
			}
			else {
				$m['Focus']['blur']($p['getattr'](self, 'focusable'));
			}
			return null;
		}
	, 1, [null,null,['self'],['focus']]);
		$cls_definition['setFocus'] = $method;
		$method = $pyjs__bind_method2('setImageBase', function(baseUrl) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				baseUrl = arguments[1];
			}

			self['imageBase'] = baseUrl;
			self['root']['updateStateRecursive']();
			return null;
		}
	, 1, [null,null,['self'],['baseUrl']]);
		$cls_definition['setImageBase'] = $method;
		$method = $pyjs__bind_method2('setImages', function(images) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				images = arguments[1];
			}

			if ($p['bool']($p['op_eq']($p['getattr'](self, 'images'), images))) {
				return null;
			}
			self['images'] = images;
			self['setImageBase']($m['pygwt']['getImageBaseURL']($p['getattr'](self, 'images')));
			return null;
		}
	, 1, [null,null,['self'],['images']]);
		$cls_definition['setImages'] = $method;
		$method = $pyjs__bind_method2('setSelectedItem', function(item, fireEvents) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
				fireEvents = arguments[2];
			}
			if (typeof fireEvents == 'undefined') fireEvents=arguments['callee']['__args__'][4][1];

			if ($p['bool']((item === null))) {
				if ($p['bool'](($p['getattr'](self, 'curSelection') === null))) {
					return null;
				}
				self['curSelection']['setSelected'](false);
				self['curSelection'] = null;
				return null;
			}
			self['onSelection'](item, fireEvents);
			return null;
		}
	, 1, [null,null,['self'],['item'],['fireEvents', true]]);
		$cls_definition['setSelectedItem'] = $method;
		$method = $pyjs__bind_method2('setTabIndex', function(index) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				index = arguments[1];
			}

			$m['Focus']['setTabIndex']($p['getattr'](self, 'focusable'), index);
			return null;
		}
	, 1, [null,null,['self'],['index']]);
		$cls_definition['setTabIndex'] = $method;
		$method = $pyjs__bind_method2('treeItemIterator', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}
			var accum;
			accum = $p['list']([]);
			self['root']['addTreeItems'](accum);
			return accum['__iter__']();
		}
	, 1, [null,null,['self']]);
		$cls_definition['treeItemIterator'] = $method;
		$method = $pyjs__bind_method2('collectElementChain', function(chain, hRoot, hElem) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				chain = arguments[1];
				hRoot = arguments[2];
				hElem = arguments[3];
			}
			var $or5,$or6;
			if ($p['bool'](($p['bool']($or5=(hElem === null))?$or5:$m['DOM']['compare'](hElem, hRoot)))) {
				return null;
			}
			self['collectElementChain'](chain, hRoot, $m['DOM']['getParent'](hElem));
			chain['append'](hElem);
			return null;
		}
	, 1, [null,null,['self'],['chain'],['hRoot'],['hElem']]);
		$cls_definition['collectElementChain'] = $method;
		$method = $pyjs__bind_method2('elementClicked', function(root, hElem) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				root = arguments[1];
				hElem = arguments[2];
			}
			var chain,item;
			chain = $p['list']([]);
			self['collectElementChain'](chain, self['getElement'](), hElem);
			item = self['findItemByChain'](chain, 0, root);
			if ($p['bool']((item !== null))) {
				if ($p['bool']($m['DOM']['compare'](item['getImageElement'](), hElem))) {
					item['setState'](!$p['bool'](item['getState']()), true);
					return true;
				}
				else if ($p['bool']($m['DOM']['isOrHasChild'](item['getElement'](), hElem))) {
					self['onSelection'](item, true);
					return true;
				}
			}
			return false;
		}
	, 1, [null,null,['self'],['root'],['hElem']]);
		$cls_definition['elementClicked'] = $method;
		$method = $pyjs__bind_method2('findDeepestOpenChild', function(item) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
			}
			var $sub3,$sub4;
			if ($p['bool'](!$p['bool'](item['getState']()))) {
				return item;
			}
			return self['findDeepestOpenChild'](item['getChild']($p['__op_sub']($sub3=item['getChildCount'](),$sub4=1)));
		}
	, 1, [null,null,['self'],['item']]);
		$cls_definition['findDeepestOpenChild'] = $method;
		$method = $pyjs__bind_method2('findItemByChain', function(chain, idx, root) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				chain = arguments[1];
				idx = arguments[2];
				root = arguments[3];
			}
			var $iter2_nextval,$iter2_type,$iter2_iter,hCurElem,i,retItem,$add2,$add3,$iter2_idx,$add1,$add4,child,$iter2_array;
			if ($p['bool']($p['op_eq'](idx, $p['len'](chain)))) {
				return root;
			}
			hCurElem = chain['__getitem__'](idx);
			$iter2_iter = $p['range'](root['getChildCount']());
			$iter2_nextval=$p['__iter_prepare']($iter2_iter,false);
			while (typeof($p['__wrapped_next']($iter2_nextval)['$nextval']) != 'undefined') {
				i = $iter2_nextval['$nextval'];
				child = root['getChild'](i);
				if ($p['bool']($m['DOM']['compare'](child['getElement'](), hCurElem))) {
					retItem = self['findItemByChain'](chain, $p['__op_add']($add1=idx,$add2=1), root['getChild'](i));
					if ($p['bool']((retItem === null))) {
						return child;
					}
					return retItem;
				}
			}
			return self['findItemByChain'](chain, $p['__op_add']($add3=idx,$add4=1), root);
		}
	, 1, [null,null,['self'],['chain'],['idx'],['root']]);
		$cls_definition['findItemByChain'] = $method;
		$method = $pyjs__bind_method2('moveFocus', function(selection) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				selection = arguments[1];
			}
			var containerLeft,focusableWidget,height,top,width,$sub8,$sub5,selectedElem,$sub7,$sub6,containerTop,left;
			focusableWidget = selection['getFocusableWidget']();
			if ($p['bool']((focusableWidget !== null))) {
				focusableWidget['setFocus'](true);
				$m['DOM']['scrollIntoView'](focusableWidget['getElement']());
			}
			else {
				selectedElem = selection['getContentElem']();
				containerLeft = self['getAbsoluteLeft']();
				containerTop = self['getAbsoluteTop']();
				left = $p['__op_sub']($sub5=$m['DOM']['getAbsoluteLeft'](selectedElem),$sub6=containerLeft);
				top = $p['__op_sub']($sub7=$m['DOM']['getAbsoluteTop'](selectedElem),$sub8=containerTop);
				width = $m['DOM']['getIntAttribute'](selectedElem, 'offsetWidth');
				height = $m['DOM']['getIntAttribute'](selectedElem, 'offsetHeight');
				$m['DOM']['setIntStyleAttribute']($p['getattr'](self, 'focusable'), 'left', $p['sprintf']('%spx', left));
				$m['DOM']['setIntStyleAttribute']($p['getattr'](self, 'focusable'), 'top', $p['sprintf']('%spx', top));
				$m['DOM']['setIntStyleAttribute']($p['getattr'](self, 'focusable'), 'width', $p['sprintf']('%spx', width));
				$m['DOM']['setIntStyleAttribute']($p['getattr'](self, 'focusable'), 'height', $p['sprintf']('%spx', height));
				$m['DOM']['scrollIntoView']($p['getattr'](self, 'focusable'));
				$m['Focus']['focus']($p['getattr'](self, 'focusable'));
			}
			return null;
		}
	, 1, [null,null,['self'],['selection']]);
		$cls_definition['moveFocus'] = $method;
		$method = $pyjs__bind_method2('moveSelectionDown', function(sel, dig) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				sel = arguments[1];
				dig = arguments[2];
			}
			var $or7,$sub10,parent,idx,$or8,$sub9,$add6,$add5;
			if ($p['bool']($p['op_eq'](sel, $p['getattr'](self, 'root')))) {
				return null;
			}
			parent = sel['getParentItem']();
			if ($p['bool']((parent === null))) {
				parent = $p['getattr'](self, 'root');
			}
			idx = parent['getChildIndex'](sel);
			if ($p['bool'](($p['bool']($or7=!$p['bool'](dig))?$or7:!$p['bool'](sel['getState']())))) {
				if ($p['bool'](($p['cmp'](idx, $p['__op_sub']($sub9=parent['getChildCount'](),$sub10=1)) == -1))) {
					self['onSelection'](parent['getChild']($p['__op_add']($add5=idx,$add6=1)), true);
				}
				else {
					self['moveSelectionDown'](parent, false);
				}
			}
			else if ($p['bool'](($p['cmp'](sel['getChildCount'](), 0) == 1))) {
				self['onSelection'](sel['getChild'](0), true);
			}
			return null;
		}
	, 1, [null,null,['self'],['sel'],['dig']]);
		$cls_definition['moveSelectionDown'] = $method;
		$method = $pyjs__bind_method2('moveSelectionUp', function(sel, climb) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				sel = arguments[1];
				climb = arguments[2];
			}
			var parent,idx,$sub12,$sub11,sibling;
			parent = sel['getParentItem']();
			if ($p['bool']((parent === null))) {
				parent = $p['getattr'](self, 'root');
			}
			idx = parent['getChildIndex'](sel);
			if ($p['bool'](($p['cmp'](idx, 0) == 1))) {
				sibling = parent['getChild']($p['__op_sub']($sub11=idx,$sub12=1));
				self['onSelection'](self['findDeepestOpenChild'](sibling), true);
			}
			else {
				self['onSelection'](parent, true);
			}
			return null;
		}
	, 1, [null,null,['self'],['sel'],['climb']]);
		$cls_definition['moveSelectionUp'] = $method;
		$method = $pyjs__bind_method2('onSelection', function(item, fireEvents) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
				fireEvents = arguments[2];
			}
			var $iter4_idx,$iter3_idx,$iter3_array,$iter4_nextval,$and3,$and4,$and5,onBefore,listener,$iter3_iter,$iter4_type,$iter3_type,$iter4_array,$and6,$iter4_iter,$iter3_nextval;
			if ($p['bool']($p['op_eq'](item, $p['getattr'](self, 'root')))) {
				return null;
			}
			if ($p['bool'](($p['bool']($and3=fireEvents)?$p['len']($p['getattr'](self, 'listeners')):$and3))) {
				$iter3_iter = $p['getattr'](self, 'listeners');
				$iter3_nextval=$p['__iter_prepare']($iter3_iter,false);
				while (typeof($p['__wrapped_next']($iter3_nextval)['$nextval']) != 'undefined') {
					listener = $iter3_nextval['$nextval'];
					onBefore = $p['getattr'](listener, 'onBeforeTreeItemSelected', null);
					if ($p['bool']((onBefore !== null))) {
						if ($p['bool'](!$p['bool'](onBefore(item)))) {
							return null;
						}
					}
				}
			}
			if ($p['bool'](($p['getattr'](self, 'curSelection') !== null))) {
				self['curSelection']['setSelected'](false);
			}
			self['curSelection'] = item;
			if ($p['bool'](($p['getattr'](self, 'curSelection') !== null))) {
				self['moveFocus']($p['getattr'](self, 'curSelection'));
				self['curSelection']['setSelected'](true);
				if ($p['bool'](($p['bool']($and5=fireEvents)?$p['len']($p['getattr'](self, 'listeners')):$and5))) {
					$iter4_iter = $p['getattr'](self, 'listeners');
					$iter4_nextval=$p['__iter_prepare']($iter4_iter,false);
					while (typeof($p['__wrapped_next']($iter4_nextval)['$nextval']) != 'undefined') {
						listener = $iter4_nextval['$nextval'];
						listener['onTreeItemSelected'](item);
					}
				}
			}
			return null;
		}
	, 1, [null,null,['self'],['item'],['fireEvents']]);
		$cls_definition['onSelection'] = $method;
		$method = $pyjs__bind_method2('doAttachChildren', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}
			var $iter5_nextval,$iter5_idx,child,$iter5_iter,$iter5_array,$iter5_type;
			$iter5_iter = self;
			$iter5_nextval=$p['__iter_prepare']($iter5_iter,false);
			while (typeof($p['__wrapped_next']($iter5_nextval)['$nextval']) != 'undefined') {
				child = $iter5_nextval['$nextval'];
				child['onAttach']();
			}
			$m['DOM']['setEventListener']($p['getattr'](self, 'focusable'), self);
			return null;
		}
	, 1, [null,null,['self']]);
		$cls_definition['doAttachChildren'] = $method;
		$method = $pyjs__bind_method2('doDetachChildren', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}
			var $iter6_idx,$iter6_type,$iter6_array,child,$iter6_iter,$iter6_nextval;
			$iter6_iter = self;
			$iter6_nextval=$p['__iter_prepare']($iter6_iter,false);
			while (typeof($p['__wrapped_next']($iter6_nextval)['$nextval']) != 'undefined') {
				child = $iter6_nextval['$nextval'];
				child['onDetach']();
			}
			$m['DOM']['setEventListener']($p['getattr'](self, 'focusable'), null);
			return null;
		}
	, 1, [null,null,['self']]);
		$cls_definition['doDetachChildren'] = $method;
		$method = $pyjs__bind_method2('onLoad', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			self['root']['updateStateRecursive']();
			return null;
		}
	, 1, [null,null,['self']]);
		$cls_definition['onLoad'] = $method;
		$method = $pyjs__bind_method2('adopt', function(content) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				content = arguments[1];
			}

			self['childWidgets']['add'](content);
			content['treeSetParent'](self);
			return null;
		}
	, 1, [null,null,['self'],['content']]);
		$cls_definition['adopt'] = $method;
		$method = $pyjs__bind_method2('disown', function(item) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
			}

			self['childWidgets']['remove'](item);
			item['treeSetParent'](null);
			return null;
		}
	, 1, [null,null,['self'],['item']]);
		$cls_definition['disown'] = $method;
		$method = $pyjs__bind_method2('fireStateChanged', function(item) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				item = arguments[1];
			}
			var $iter7_nextval,$iter7_iter,$iter7_array,listener,$iter7_idx,$iter7_type;
			$iter7_iter = $p['getattr'](self, 'listeners');
			$iter7_nextval=$p['__iter_prepare']($iter7_iter,false);
			while (typeof($p['__wrapped_next']($iter7_nextval)['$nextval']) != 'undefined') {
				listener = $iter7_nextval['$nextval'];
				if ($p['bool']($p['hasattr'](listener, 'onTreeItemStateChanged'))) {
					listener['onTreeItemStateChanged'](item);
				}
			}
			return null;
		}
	, 1, [null,null,['self'],['item']]);
		$cls_definition['fireStateChanged'] = $method;
		$method = $pyjs__bind_method2('getChildWidgets', function() {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
			}

			return $p['getattr'](self, 'childWidgets');
		}
	, 1, [null,null,['self']]);
		$cls_definition['getChildWidgets'] = $method;
		$method = $pyjs__bind_method2('shouldTreeDelegateFocusToElement', function(elem) {
			if (this['__is_instance__'] === true) {
				var self = this;
			} else {
				var self = arguments[0];
				elem = arguments[1];
			}
			var name,$or9,$or11,$or10;
			name = $p['str']($p['getattr'](elem, 'nodeName'));
			name = name['lower']();
			return ($p['bool']($or9=$p['op_eq'](name, 'select'))?$or9:($p['bool']($or10=$p['op_eq'](name, 'input'))?$or10:$p['op_eq'](name, 'checkbox')));
		}
	, 1, [null,null,['self'],['elem']]);
		$cls_definition['shouldTreeDelegateFocusToElement'] = $method;
		var $bases = new Array($m['Widget']);
		var $data = $p['dict']();
		for (var $item in $cls_definition) { $data['__setitem__']($item, $cls_definition[$item]); }
		return $p['_create_class']('Tree', $p['tuple']($bases), $data);
	})();
	$m['Factory']['registerClass']('pyjamas.ui.Tree', 'Tree', $m['Tree']);
	return this;
}; /* end pyjamas.ui.Tree */


/* end module: pyjamas.ui.Tree */


/*
PYJS_DEPS: ['pyjamas.DOM', 'pyjamas', 'pyjamas.Factory', 'sets.Set', 'sets', 'pygwt', 'pyjamas.ui.Widget.Widget', 'pyjamas.ui', 'pyjamas.ui.Widget', 'pyjamas.ui.Event', 'pyjamas.ui.Focus', 'pyjamas.ui.TreeItem.RootTreeItem', 'pyjamas.ui.TreeItem', 'pyjamas.ui.TreeItem.TreeItem', 'pyjamas.ui.MouseListener', 'pyjamas.ui.KeyboardListener', 'pyjamas.ui.FocusListener']
*/
