- NJInputPathElement *item = [outlineView itemAtRow:outlineView.selectedRow];
- return (NJInput *)((!item.children && item.parent) ? item : nil);
-}
-
-- (NSInteger)outlineView:(NSOutlineView *)outlineView
- numberOfChildrenOfItem:(NJInputPathElement *)item {
- return item ? item.children.count : _devices.count;
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView
- isItemExpandable:(NJInputPathElement *)item {
- return item ? [[item children] count] > 0: YES;
-}
-
-- (id)outlineView:(NSOutlineView *)outlineView
- child:(NSInteger)index
- ofItem:(NJInputPathElement *)item {
- return item ? item.children[index] : _devices[index];
-}
-
-- (id)outlineView:(NSOutlineView *)outlineView
-objectValueForTableColumn:(NSTableColumn *)tableColumn
- byItem:(NJInputPathElement *)item {
- return item ? item.name : @"root";
-}
-
-- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
- NJInputPathElement *item = [outlineView itemAtRow:outlineView.selectedRow];
- if (item)
- [NSUserDefaults.standardUserDefaults setObject:item.uid
- forKey:@"selected input"];
- [outputController loadCurrent];
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView
- isGroupItem:(NJInputPathElement *)item {
- return [item isKindOfClass:NJDevice.class];
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView_
- shouldSelectItem:(NJInputPathElement *)item {
- return ![self outlineView:outlineView_ isGroupItem:item];
-}
-
-- (void)outlineViewItemDidExpand:(NSNotification *)notification {
- NJInputPathElement *item = notification.userInfo[@"NSObject"];
- NSString *uid = item.uid;
- if (![_expanded containsObject:uid])
- [_expanded addObject:uid];
- while (_expanded.count > EXPANDED_MEMORY_MAX_SIZE)
- [_expanded removeObjectAtIndex:0];
- [NSUserDefaults.standardUserDefaults setObject:_expanded
- forKey:@"expanded rows"];
-}
-
-- (void)outlineViewItemDidCollapse:(NSNotification *)notification {
- NJInputPathElement *item = notification.userInfo[@"NSObject"];
- [_expanded removeObject:item.uid];
- [NSUserDefaults.standardUserDefaults setObject:_expanded
- forKey:@"expanded rows"];