public override void SelectionDidChange (NSNotification notification)
            {
                nint row = _controller.splitViewController.MainOutlineView.SelectedRow;
                if (row >= (nint)0) {
                    NSObject item = _controller.splitViewController.MainOutlineView.ItemAtRow ((int)row);
                    _controller.SetDefaultView ();
                    //NSTableView table = _controller.splitViewController.MainTableView;
                    _controller.RemoveTableColumns ();
                    List<ColumnOptions> columns = new List<ColumnOptions> ();
                    NSTableViewDataSource datasource;
                    _controller.CurrentSelectedNode = item as ScopeNode;
                    if (item is TrustedCertificateNode) {
                        _controller.AddToolbarItem.Label = "Add Cert Chain";
                        _controller.AddToolbarItem.Active = true;
                        _controller.DeleteToolbarItem.Label = "Delete Cert Chain";
                        _controller.DeleteToolbarItem.Active = true;
                        var trustedCertificateNode = item as TrustedCertificateNode;
                        var certificates = trustedCertificateNode.GetCertificates ();
                        datasource = new TrustedCertificatesDataSource{ Entries = certificates };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 100 },
                            new ColumnOptions{ DisplayName = "Status", Id = "Status", Width = 40 },
                            new ColumnOptions{ DisplayName = "Issued By", Id = "IssuedBy", Width = 150 },
                            new ColumnOptions{ DisplayName = "Issued On", Id = "IssuedOn", Width = 60 },
                            new ColumnOptions{ DisplayName = "Expiration", Id = "Expiration", Width = 60 },
                            new ColumnOptions{ DisplayName = "Purpose", Id = "Purpose", Width = 250 },
                        };
                    } else if (item is UsersNode) {
                        var node = item as UsersNode;
                        _controller.AddToolbarItem.Label = "Add User";
                        _controller.AddToolbarItem.Active = node.IsSystemDomain;
                        _controller.DeleteToolbarItem.Label = "Delete User";
                        _controller.DeleteToolbarItem.Active = node.IsSystemDomain;
                        var users = node.GetUsers (string.Empty);
                        datasource = new UsersDataSource{ Entries = users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 100 },
                            new ColumnOptions{ DisplayName = "First Name", Id = "FirstName", Width = 100 },
                            new ColumnOptions{ DisplayName = "Last Name", Id = "LastName", Width = 100 },
                            new ColumnOptions{ DisplayName = "Email", Id = "Email", Width = 80 },
                            new ColumnOptions{ DisplayName = "Description", Id = "Description", Width = 150 }
                        };
                    } else if (item is SolutionUsersNode) {
                        var node = item as SolutionUsersNode;
                        _controller.AddToolbarItem.Label = "Add Solution User";
                        _controller.AddToolbarItem.Active = node.IsSystemDomain;
                        _controller.DeleteToolbarItem.Label = "Delete Solution User";
                        _controller.DeleteToolbarItem.Active = node.IsSystemDomain;
                        var users = node.GetUsers (string.Empty);
                        datasource = new SolutionUsersDataSource{ Entries = users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 100 },
                            new ColumnOptions{ DisplayName = "Description", Id = "Description", Width = 150 },
                            new ColumnOptions{ DisplayName = "Disabled", Id = "Disabled", Width = 60 }
                        };
                    } else if (item is GroupsNode) {
                        var node = item as GroupsNode;
                        _controller.AddToolbarItem.Label = "Add Group";
                        _controller.AddToolbarItem.Active = node.IsSystemDomain;
                        _controller.DeleteToolbarItem.Label = "Delete Group";
                        _controller.DeleteToolbarItem.Active = node.IsSystemDomain;
                        var users = node.GetGroups (string.Empty);
                        datasource = new GroupsDataSource{ Entries = users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 100 },
                            new ColumnOptions{ DisplayName = "Domain", Id = "Domain", Width = 100 },
                            new ColumnOptions{ DisplayName = "Description", Id = "Description", Width = 150 }
                        };
                    } else if (item is RelyingPartyNode) {
                        _controller.AddToolbarItem.Label = "Add Relying Party";
                        _controller.AddToolbarItem.Active = true;
                        _controller.DeleteToolbarItem.Label = "Delete Relying Party";
                        _controller.DeleteToolbarItem.Active = true;
                        var node = item as RelyingPartyNode;
                        var users = node.GetRelyingParty ();
                        datasource = new RelyingPartyDataSource{ Entries = users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 100 },
                            new ColumnOptions{ DisplayName = "Url", Id = "Url", Width = 150 }
                        };
                    } else if (item is IdentityProvidersNode) {
                        _controller.AddToolbarItem.Label = "Add External IDP";
                        _controller.AddToolbarItem.Active = true;
                        _controller.DeleteToolbarItem.Label = "Delete External IDP";
                        _controller.DeleteToolbarItem.Active = true;
                        var node = item as IdentityProvidersNode;
                        var users = node.GetIdentityProviders ();
                        datasource = new IdentityProvidersDataSource{ Entries = users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Entity Id", Id = "Name", Width = 150 },
                            new ColumnOptions{ DisplayName = "Jit", Id = "Jit", Width = 60 }
                        };
                    } else if (item is OidcClientNode) {
                        _controller.AddToolbarItem.Label = "Add OIDC Client";
                        _controller.AddToolbarItem.Active = true;
                        _controller.DeleteToolbarItem.Label = "Delete OIDC Client";
                        _controller.DeleteToolbarItem.Active = true;
                        var node = item as OidcClientNode;
                        var users = node.GetOidcClients ();
                        datasource = new OidcClientDataSource{ Entries = users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Client Id", Id = "Name", Width = 150 },
                            new ColumnOptions{ DisplayName = "Certificate DN", Id = "CertificateDN", Width = 150 }
                        };
                    } else if (item is ServerNode) {
                        _controller.AddToolbarItem.Label = "Add Server";
                        _controller.AddToolbarItem.Active = false;
                        _controller.DeleteToolbarItem.Label = "Delete Server";
                        _controller.DeleteToolbarItem.Active = false;
                        ScopeNode node = item as ScopeNode;
                        datasource = new NodesDefaultDataSource{ Entries = node.Children };
                        columns = new List<ColumnOptions> { new ColumnOptions {
                                DisplayName = "Name",
                                Id = "Name",
                                Width = 250,
                            }
                        };
                    } else if (item is ExternalDomainsNode) {
                        _controller.AddToolbarItem.Label = "External Domain";
                        _controller.AddToolbarItem.Active = true;
                        _controller.DeleteToolbarItem.Label = "Delete External Domain";
                        _controller.DeleteToolbarItem.Active = false;
                        ScopeNode node = item as ScopeNode;
                        datasource = new NodesDefaultDataSource{ Entries = node.Children };
                        columns = new List<ColumnOptions> { new ColumnOptions {
                                DisplayName = "Name",
                                Id = "Name",
                                Width = 250,
                            }
                        };
                    } else if (item is ExternalDomainNode) {
                        _controller.AddToolbarItem.Label = "External Domain";
                        _controller.AddToolbarItem.Active = true;
                        _controller.DeleteToolbarItem.Label = "Delete External Domain";
                        _controller.DeleteToolbarItem.Active = true;
                        ScopeNode node = item as ScopeNode;
                        datasource = new NodesDefaultDataSource{ Entries = node.Children };
                        columns = new List<ColumnOptions> { new ColumnOptions {
                                DisplayName = "Name",
                                Id = "Name",
                                Width = 250,
                            }
                        };
                    } else if (item is TenantNode) {
                        _controller.AddToolbarItem.Label = "Add Tenant";
                        _controller.AddToolbarItem.Active = ((TenantNode)item).IsSystemTenant;
                        _controller.DeleteToolbarItem.Label = "Delete Tenant";
                        _controller.DeleteToolbarItem.Active = true;
                        _controller.PropertiesToolbarItem.Label = "Tenant Configuration";
                        ScopeNode node = item as ScopeNode;
                        datasource = new NodesDefaultDataSource{ Entries = node.Children };
                        columns = new List<ColumnOptions> { new ColumnOptions {
                                DisplayName = "Name",
                                Id = "Name",
                                Width = 250,
                            }
                        };
                    } else {
                        _controller.AddToolbarItem.Active = false;
                        _controller.DeleteToolbarItem.Active = false;
                        ScopeNode node = item as ScopeNode;
                        datasource = new NodesDefaultDataSource{ Entries = node.Children };
                        columns = new List<ColumnOptions> { new ColumnOptions {
                                DisplayName = "Name",
                                Id = "Name",
                                Width = 250,
                            }
                        };
                    }

                    foreach (var col in ListViewHelper.ToNSTableColumns (columns)) {
                        _controller.splitViewController.MainTableView.AddColumn (col);
                    }
                    _controller.splitViewController.MainTableView.DataSource = datasource;
                    _controller.splitViewController.MainTableView.ReloadData ();
                    var previous = _controller.splitViewController.MainTableView.SelectedRow;
                    if (_controller.splitViewController.MainTableView.RowCount > 0)
                        _controller.splitViewController.MainTableView.SelectRow (0, false);
                    if (previous == 0)
                        _controller.splitViewController.MainTableView.Delegate.SelectionDidChange (notification);

                    //GetCrumb (_controller.CurrentSelectedNode, _controller.CrumbTableView);
                }
            }
        partial void SearchText (AppKit.NSSearchField sender)
        {
            ActionHelper.Execute (delegate() {
                var item = CurrentSelectedNode;
                INSTableViewDataSource datasource = null; 
                var columns = new List<ColumnOptions> ();
                RemoveTableColumns ();
                if ((item is UsersNode) || (item is SolutionUsersNode) || (item is GroupsNode)) {
                    var domainName = string.Empty;
                    var tenant = item.GetTenant ();
                    var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken (_serverDto.ServerName);
                    domainName = (item is UsersNode) 
						? ((UsersNode)item).DomainName : (item is SolutionUsersNode) 
						? ((SolutionUsersNode)item).DomainName : (item is GroupsNode) 
						? ((GroupsNode)item).DomainName : auth.Login.DomainName;
                    var memberType = (item is UsersNode) ? MemberType.USER : (item is SolutionUsersNode) ? MemberType.SOLUTIONUSER : MemberType.GROUP;
                    var result = SnapInContext.Instance.ServiceGateway.Tenant.Search (_serverDto, tenant, domainName, memberType, SearchType.NAME, auth.Token, sender.StringValue);
                    if (item is UsersNode) {
                        datasource = new UsersDataSource{ Entries = result.Users };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 100 },
                            new ColumnOptions{ DisplayName = "First Name", Id = "FirstName", Width = 100 },
                            new ColumnOptions{ DisplayName = "Last Name", Id = "LastName", Width = 100 },
                            new ColumnOptions{ DisplayName = "Email", Id = "Email", Width = 80 },
                            new ColumnOptions{ DisplayName = "Description", Id = "Description", Width = 150 }
                        };
                    } else if (item is SolutionUsersNode) {
                        datasource = new SolutionUsersDataSource{ Entries = result.SolutionUsers };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 150 },
                            new ColumnOptions{ DisplayName = "Disabled", Id = "Disabled", Width = 60 },
                            new ColumnOptions{ DisplayName = "Description", Id = "Description", Width = 250 }
                        };
                    } else if (item is GroupsNode) {
                        datasource = new GroupsDataSource{ Entries = result.Groups };
                        columns = new List<ColumnOptions> { 
                            new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 150 },
                            new ColumnOptions{ DisplayName = "Domain", Id = "Domain", Width = 150 },
                            new ColumnOptions{ DisplayName = "Description", Id = "Description", Width = 250 }
                        };
                    } 
                } else if (item is RelyingPartyNode) {
                    var source = splitViewController.MainTableView.DataSource as RelyingPartyDataSource;
                    var nodes = source.Entries.FindAll (x => x.Name.Contains (sender.StringValue));
                    datasource = new RelyingPartyDataSource{ Entries = nodes };
                    columns = new List<ColumnOptions> { 
                        new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 150 },
                        new ColumnOptions{ DisplayName = "Url", Id = "Url", Width = 250 }
                    };
                } else if (item is TrustedCertificateNode) {
                    var source = splitViewController.MainTableView.DataSource as TrustedCertificatesDataSource;
                    var nodes = source.Entries.FindAll (x => x.Chain.Contains (sender.StringValue));
                    datasource = new TrustedCertificatesDataSource{ Entries = nodes };
                    columns = new List<ColumnOptions> { 
                        new ColumnOptions{ DisplayName = "Name", Id = "Name", Width = 80 },
                        new ColumnOptions{ DisplayName = "Status", Id = "Status", Width = 40 },
                        new ColumnOptions{ DisplayName = "Issued By", Id = "IssuedBy", Width = 100 },
                        new ColumnOptions{ DisplayName = "Issued On", Id = "IssuedOn", Width = 80 },
                        new ColumnOptions{ DisplayName = "Expiration", Id = "Expiration", Width = 80 },
                        new ColumnOptions{ DisplayName = "Purpose", Id = "Purpose", Width = 150 },
                    };
                } else if (item is IdentityProvidersNode) {
                    var source = splitViewController.MainTableView.DataSource as IdentityProvidersDataSource;
                    var nodes = source.Entries.FindAll (x => x.EntityID.Contains (sender.StringValue));
                    datasource = new IdentityProvidersDataSource{ Entries = nodes };
                    columns = new List<ColumnOptions> { 
                        new ColumnOptions{ DisplayName = "Entity Id", Id = "Name", Width = 250 },
                        new ColumnOptions{ DisplayName = "Jit", Id = "Jit", Width = 60 }
                    };
                } else if (item is OidcClientNode) {
                    var source = splitViewController.MainTableView.DataSource as OidcClientDataSource;
                    var nodes = source.Entries.FindAll (x => x.ClientId.Contains (sender.StringValue));
                    datasource = new OidcClientDataSource{ Entries = nodes };
                    columns = new List<ColumnOptions> { 
                        new ColumnOptions{ DisplayName = "Client Id", Id = "Name", Width = 250 },
                        new ColumnOptions{ DisplayName = "Certificate DN", Id = "CertificateDN", Width = 350 }
                    };
                } else {
                    var source = splitViewController.MainTableView.DataSource as NodesDefaultDataSource;
                    var nodes = source.Entries.FindAll (x => x.DisplayName.Contains (sender.StringValue));
                    datasource = new NodesDefaultDataSource (){ Entries = nodes };
                    columns = new List<ColumnOptions> { new ColumnOptions {
                            DisplayName = "Name",
                            Id = "Name",
                            Width = 250,
                        }
                    };
                }
                foreach (var col in ListViewHelper.ToNSTableColumns (columns)) {
                    splitViewController.MainTableView.AddColumn (col);
                }
                splitViewController.MainTableView.DataSource = datasource;
            });
        }