-- (NJInput *)selectedInput {
- id <NJInputPathElement> item = [outlineView itemAtRow:outlineView.selectedRow];
- return (!item.children && item.base) ? item : nil;
-}
-
-- (NSInteger)outlineView:(NSOutlineView *)outlineView
- numberOfChildrenOfItem:(id <NJInputPathElement>)item {
- return item ? item.children.count : _devices.count;
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView
- isItemExpandable:(id <NJInputPathElement>)item {
- return item ? [[item children] count] > 0: YES;
-}
-
-- (id)outlineView:(NSOutlineView *)outlineView
- child:(NSInteger)index
- ofItem:(id <NJInputPathElement>)item {
- return item ? item.children[index] : _devices[index];
-}
-
-- (id)outlineView:(NSOutlineView *)outlineView
-objectValueForTableColumn:(NSTableColumn *)tableColumn
- byItem:(id <NJInputPathElement>)item {
- return item ? item.name : @"root";
-}
-
-- (void)outlineViewSelectionDidChange:(NSNotification *)notification {
- id <NJInputPathElement> item = [outlineView itemAtRow:outlineView.selectedRow];
- if (item)
- [NSUserDefaults.standardUserDefaults setObject:item.uid
- forKey:@"selected input"];
- [outputController loadCurrent];
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView
- isGroupItem:(id <NJInputPathElement>)item {
- return [item isKindOfClass:NJDevice.class];
-}
-
-- (BOOL)outlineView:(NSOutlineView *)outlineView_
- shouldSelectItem:(id <NJInputPathElement>)item {
- return ![self outlineView:outlineView_ isGroupItem:item];
-}
-
-- (void)outlineViewItemDidExpand:(NSNotification *)notification {
- id <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 {
- id <NJInputPathElement> item = notification.userInfo[@"NSObject"];
- [_expanded removeObject:item.uid];
- [NSUserDefaults.standardUserDefaults setObject:_expanded
- forKey:@"expanded rows"];
-}
-
-- (void)setTranslatingEvents:(BOOL)translatingEvents {
- if (translatingEvents != _translatingEvents) {
- _translatingEvents = translatingEvents;
- NSInteger state = translatingEvents ? NSOnState : NSOffState;
- translatingEventsButton.state = state;
- NSString *name = translatingEvents
- ? NJEventTranslationActivated
- : NJEventTranslationDeactivated;