Inheritance: NSOutlineViewDataSource
Exemple #1
0
        /// <summary>
        /// Create the UI
        /// </summary>
        private void CreateEdit()
        {
            RootFolder repo = new RootFolder()
            {
                Name = FolderName,
                Id = credentials.RepoId,
                Address = credentials.Address.ToString()
            };
            repo.Selected = true;
            IgnoredFolderLoader.AddIgnoredFolderToRootNode(repo, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(repo, localPath);
            List<RootFolder> repos = new List<RootFolder>();
            repos.Add(repo);

            OutlineViewDelegate DataDelegate = new OutlineViewDelegate ();
            CmisTree.CmisTreeDataSource DataSource = new CmisTree.CmisTreeDataSource(repos);

            CmisOutlineController OutlineController = new CmisOutlineController (DataSource, DataDelegate);

            AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
            asyncLoader.UpdateNodeEvent += delegate {
                InvokeOnMainThread(delegate {
                    DataSource.UpdateCmisTree(repo);
                    NSOutlineView view = OutlineController.OutlineView();
                    for (int i = 0; i < view.RowCount; ++i) {
                        view.ReloadItem(view.ItemAtRow(i));
                    }
                });
            };
            asyncLoader.Load(repo);

            DataDelegate.ItemExpanded += delegate(NSNotification notification)
            {
                InvokeOnMainThread(delegate {
                    NSCmisTree cmis = notification.UserInfo["NSObject"] as NSCmisTree;
                    if (cmis == null) {
                        Console.WriteLine("ItemExpanded Error");
                        return;
                    }

                    NSCmisTree cmisRoot = cmis;
                    while (cmisRoot.Parent != null) {
                        cmisRoot = cmisRoot.Parent;
                    }
                    if (repo.Name != cmisRoot.Name) {
                        Console.WriteLine("ItemExpanded find root Error");
                        return;
                    }

                    Node node = cmis.GetNode(repo);
                    if (node == null) {
                        Console.WriteLine("ItemExpanded find node Error");
                        return;
                    }
                    asyncLoader.Load(node);
                });
            };
            DataSource.SelectedEvent += delegate (NSCmisTree cmis, int selected) {
                InvokeOnMainThread(delegate {
                    Node node = cmis.GetNode(repo);
                    if (node == null) {
                        Console.WriteLine("SelectedEvent find node Error");
                    }
                    node.Selected = (selected != 0);
                    DataSource.UpdateCmisTree(repo);

                    NSOutlineView view = OutlineController.OutlineView();
                    for (int i = 0; i < view.RowCount; ++i) {
                        try{
                            view.ReloadItem(view.ItemAtRow(i));
                        }catch(Exception e) {
                            Console.WriteLine(e);
                        }
                    }
                });
            };

            OutlineController.View.Frame = new RectangleF (190, 60, 400, 240);
            ContentView.AddSubview (OutlineController.View);

            Controller.CloseWindowEvent += delegate
            {
                asyncLoader.Cancel();
            };

            Controller.OpenWindowEvent += delegate
            {
                InvokeOnMainThread (delegate {
                    OrderFrontRegardless ();
                });
            };


            NSButton finish_button = new NSButton()
            {
                Title = Properties_Resources.SaveChanges,
            };

            NSButton cancel_button = new NSButton()
            {
                Title = Properties_Resources.DiscardChanges
            };

            Buttons.Add(finish_button);
            Buttons.Add(cancel_button);

            finish_button.Activated += delegate
            {
                Ignores = NodeModelUtils.GetIgnoredFolder(repo);
                Controller.SaveFolder();
                InvokeOnMainThread (delegate {
                    PerformClose (this);
                });
            };

            cancel_button.Activated += delegate
            {
                InvokeOnMainThread (delegate {
                    PerformClose (this);
                });
            };

            this.Header = Properties_Resources.EditTitle;
            this.Description = "";
            this.ShowAll();
        }
        public override void AwakeFromNib ()
        {
            base.AwakeFromNib ();

            this.SideSplashView.Image = new NSImage (UIHelpers.GetImagePathname ("side-splash")) {
                Size = new SizeF (150, 482)
            };

            this.Header.StringValue = Properties_Resources.EditTitle;

            Repo = new RootFolder()
            {
                Name = FolderName,
                Id = Credentials.RepoId,
                Address = Credentials.Address.ToString()
            };
            Repo.Selected = true;
            IgnoredFolderLoader.AddIgnoredFolderToRootNode(Repo, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(Repo, localPath);
            List<RootFolder> repos = new List<RootFolder>();
            repos.Add(Repo);

            Loader = new AsyncNodeLoader(Repo, Credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);

            CancelButton.Title = Properties_Resources.DiscardChanges;
            FinishButton.Title = Properties_Resources.SaveChanges;

            DataDelegate = new OutlineViewDelegate ();
            DataSource = new CmisTree.CmisTreeDataSource(repos);
            Outline.DataSource = DataSource;
            Outline.Delegate = DataDelegate;

            this.AddressLabel.StringValue = Properties_Resources.CmisWebAddress;
            this.UserLabel.StringValue = Properties_Resources.User;
            this.PasswordLabel.StringValue = Properties_Resources.Password;

            this.AddressText.StringValue = Credentials.Address.ToString ();
            this.UserText.StringValue = Credentials.UserName;
            this.PasswordText.StringValue = Credentials.Password.ToString ();
            this.AddressText.Enabled = false;
            this.UserText.Enabled = false;
            this.LoginStatusProgress.IsDisplayedWhenStopped = false;
            this.LoginStatusLabel.Hidden = true;
            this.FolderTab.Label = Properties_Resources.AddingFolder;
            this.CredentialsTab.Label = Properties_Resources.Credentials;
            switch (this.type) {
            case EditType.EditFolder:
                TabView.SelectAt (0);
                break;
            case EditType.EditCredentials:
                TabView.SelectAt (1);
                break;
            default:
                TabView.SelectAt (0);
                break;
            }
            //  GUI workaround to remove ignore folder {{
            this.TabView.Remove (this.FolderTab);
            //  GUI workaround to remove ignore folder }}

            Controller.CloseWindowEvent += delegate
            {
                Loader.Cancel();
                this.Window.PerformClose (this);
                this.Dispose();
            };

            InsertEvent ();

            //  must be called after InsertEvent()
            Loader.Load(Repo);
            lock(loginLock)
                isClosed = false;

            OnPasswordChanged (this);
        }
        public override void AwakeFromNib() {
            base.AwakeFromNib();

            bool firstRepo = true;
            this.Repositories = new List<RootFolder>();
            Loader = new Dictionary<string, AsyncNodeLoader>();
            foreach (var repository in Controller.repositories) {
                RootFolder repo = new RootFolder() {
                    Name = repository.Name,
                    Id = repository.Id,
                    Address = this.Controller.saved_address.ToString()
                };
                this.Repositories.Add(repo);
                if (firstRepo) {
                    repo.Selected = true;
                    firstRepo = false;
                } else {
                    repo.Selected = false;
                }

                CmisRepoCredentials cred = new CmisRepoCredentials() {
                    UserName = this.Controller.saved_user,
                    Password = this.Controller.saved_password,
                    Address = this.Controller.saved_address,
                    RepoId = repository.Id
                };
                //  GUI workaround to remove ignore folder {{
                //AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, cred, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
                //Loader.Add(repo.Id, asyncLoader);
                repo.Status = LoadingStatus.DONE;
                //  GUI workaround to remove ignore folder }}

            }

            this.DataSource = new CmisTree.CmisTreeDataSource(this.Repositories);
            this.DataDelegate = new OutlineViewDelegate ();
            Outline.DataSource = this.DataSource;
            Outline.Delegate = this.DataDelegate;

            ContinueButton.Enabled = this.Repositories.Count > 0;
//            ContinueButton.KeyEquivalent = "\r";

            this.BackButton.Title = Properties_Resources.Back;
            this.CancelButton.Title = Properties_Resources.Cancel;
            this.ContinueButton.Title = Properties_Resources.Continue;

            this.InsertEvent();

            //  must be called after InsertEvent()
            //  GUI workaround to remove ignore folder {{
            //foreach (RootFolder repo in Repositories) {
            //    Loader [repo.Id].Load (repo);
            //}
            //  GUI workaround to remove ignore folder }}
        }
        public override void AwakeFromNib ()
        {
            base.AwakeFromNib ();

            bool firstRepo = true;
            Repositories = new List<RootFolder>();
            Loader = new Dictionary<string,AsyncNodeLoader> ();
            foreach (KeyValuePair<String, String> repository in Controller.repositories)
            {
                RootFolder repo = new RootFolder() {
                    Name = repository.Value,
                    Id = repository.Key,
                    Address = Controller.saved_address.ToString()
                };
                Repositories.Add(repo);
                if (firstRepo)
                {
                    repo.Selected = true;
                    firstRepo = false;
                }
                else
                {
                    repo.Selected = false;
                }
                CmisRepoCredentials cred = new CmisRepoCredentials()
                {
                    UserName = Controller.saved_user,
                    Password = Controller.saved_password,
                    Address = Controller.saved_address,
                    RepoId = repository.Key
                };
                AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, cred, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
                Loader.Add(repo.Id, asyncLoader);
            }

            DataSource = new CmisTree.CmisTreeDataSource(Repositories);
            DataDelegate = new OutlineViewDelegate ();
            Outline.DataSource = DataSource;
            Outline.Delegate = DataDelegate;

            ContinueButton.Enabled = (Repositories.Count > 0);
//            ContinueButton.KeyEquivalent = "\r";

            this.BackButton.Title = Properties_Resources.Back;
            this.CancelButton.Title = Properties_Resources.Cancel;
            this.ContinueButton.Title = Properties_Resources.Continue;

            InsertEvent ();

            //  must be called after InsertEvent()
            foreach (RootFolder repo in Repositories) {
                Loader [repo.Id].Load (repo);
            }
        }
Exemple #5
0
        /// <summary>
        /// Create the UI
        /// </summary>
        private void CreateEdit()
        {
            RootFolder repo = new RootFolder()
            {
                Name    = FolderName,
                Id      = credentials.RepoId,
                Address = credentials.Address.ToString()
            };

            repo.Selected = true;
            IgnoredFolderLoader.AddIgnoredFolderToRootNode(repo, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(repo, localPath);
            List <RootFolder> repos = new List <RootFolder>();

            repos.Add(repo);

            OutlineViewDelegate DataDelegate = new OutlineViewDelegate();

            CmisTree.CmisTreeDataSource DataSource = new CmisTree.CmisTreeDataSource(repos);

            CmisOutlineController OutlineController = new CmisOutlineController(DataSource, DataDelegate);

            AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);

            asyncLoader.UpdateNodeEvent += delegate {
                InvokeOnMainThread(delegate {
                    DataSource.UpdateCmisTree(repo);
                    NSOutlineView view = OutlineController.OutlineView();
                    for (int i = 0; i < view.RowCount; ++i)
                    {
                        view.ReloadItem(view.ItemAtRow(i));
                    }
                });
            };
            asyncLoader.Load(repo);

            DataDelegate.ItemExpanded += delegate(NSNotification notification)
            {
                InvokeOnMainThread(delegate {
                    NSCmisTree cmis = notification.UserInfo["NSObject"] as NSCmisTree;
                    if (cmis == null)
                    {
                        Console.WriteLine("ItemExpanded Error");
                        return;
                    }

                    NSCmisTree cmisRoot = cmis;
                    while (cmisRoot.Parent != null)
                    {
                        cmisRoot = cmisRoot.Parent;
                    }
                    if (repo.Name != cmisRoot.Name)
                    {
                        Console.WriteLine("ItemExpanded find root Error");
                        return;
                    }

                    Node node = cmis.GetNode(repo);
                    if (node == null)
                    {
                        Console.WriteLine("ItemExpanded find node Error");
                        return;
                    }
                    asyncLoader.Load(node);
                });
            };
            DataSource.SelectedEvent += delegate(NSCmisTree cmis, int selected) {
                InvokeOnMainThread(delegate {
                    Node node = cmis.GetNode(repo);
                    if (node == null)
                    {
                        Console.WriteLine("SelectedEvent find node Error");
                    }
                    node.Selected = (selected != 0);
                    DataSource.UpdateCmisTree(repo);

                    NSOutlineView view = OutlineController.OutlineView();
                    for (int i = 0; i < view.RowCount; ++i)
                    {
                        try{
                            view.ReloadItem(view.ItemAtRow(i));
                        }catch (Exception e) {
                            Console.WriteLine(e);
                        }
                    }
                });
            };

            OutlineController.View.Frame = new RectangleF(190, 60, 400, 240);
            ContentView.AddSubview(OutlineController.View);

            Controller.CloseWindowEvent += delegate
            {
                asyncLoader.Cancel();
            };

            Controller.OpenWindowEvent += delegate
            {
                InvokeOnMainThread(delegate {
                    OrderFrontRegardless();
                });
            };


            NSButton finish_button = new NSButton()
            {
                Title = Properties_Resources.SaveChanges,
            };

            NSButton cancel_button = new NSButton()
            {
                Title = Properties_Resources.DiscardChanges
            };

            Buttons.Add(finish_button);
            Buttons.Add(cancel_button);

            finish_button.Activated += delegate
            {
                Ignores = NodeModelUtils.GetIgnoredFolder(repo);
                Controller.SaveFolder();
                InvokeOnMainThread(delegate {
                    PerformClose(this);
                });
            };

            cancel_button.Activated += delegate
            {
                InvokeOnMainThread(delegate {
                    PerformClose(this);
                });
            };

            this.Header      = Properties_Resources.EditTitle;
            this.Description = "";
            this.ShowAll();
        }
Exemple #6
0
        void ShowFolderSeletionPage()
        {
            Header = Properties_Resources.Which;
            Description = "";
            bool firstRepo = true;
            Repositories = new List<RootFolder>();
            Loader = new Dictionary<string,AsyncNodeLoader> ();
            foreach (KeyValuePair<String, String> repository in Controller.repositories)
            {
                RootFolder repo = new RootFolder() {
                    Name = repository.Value,
                    Id = repository.Key,
                    Address = Controller.saved_address.ToString()
                };
                Repositories.Add(repo);
                if (firstRepo)
                {
                    repo.Selected = true;
                    firstRepo = false;
                }
                else
                {
                    repo.Selected = false;
                }
                CmisRepoCredentials cred = new CmisRepoCredentials()
                {
                    UserName = Controller.saved_user,
                    Password = Controller.saved_password,
                    Address = Controller.saved_address,
                    RepoId = repository.Key
                };
                AsyncNodeLoader asyncLoader = new AsyncNodeLoader(repo, cred, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
                asyncLoader.UpdateNodeEvent += delegate {
                    InvokeOnMainThread(delegate {
                        DataSource.UpdateCmisTree(repo);
                        NSOutlineView view = OutlineController.OutlineView();
                        for (int i = 0; i < view.RowCount; ++i) {
                            view.ReloadItem(view.ItemAtRow(i));
                        }
                    });
                };
                asyncLoader.Load(repo);
                Loader.Add(repo.Id, asyncLoader);
            }
            DataSource = new CmisTree.CmisTreeDataSource(Repositories);
            DataSource.SelectedEvent += delegate (NSCmisTree cmis, int selected) {
                InvokeOnMainThread(delegate {
                    RootFolder selectedRoot = null;
                    foreach (RootFolder root in Repositories) {
                        Node node = cmis.GetNode(root);
                        if (node != null) {
                            if (node.Parent == null && node.Selected == false) {
                                selectedRoot = root;
                            }
                            node.Selected = (selected != 0);
                            DataSource.UpdateCmisTree(root);
                        }
                    }

                    NSOutlineView view = OutlineController.OutlineView();
                    if (selectedRoot != null) {
                        foreach (RootFolder root in Repositories) {
                            if (root != selectedRoot) {
                                root.Selected = false;
                                DataSource.UpdateCmisTree(root);
                            }
                        }
                        view.ReloadData();
                    } else {
                        for (int i = 0; i < view.RowCount; ++i) {
                            view.ReloadItem(view.ItemAtRow(i));
                        }
                    }
                });
            };
            DataDelegate = new OutlineViewDelegate ();
            OutlineController = new CmisOutlineController (DataSource,DataDelegate);
            ContinueButton = new NSButton() {
                Title = Properties_Resources.Continue,
                Enabled = (Repositories.Count > 0)
            };
            CancelButton = new NSButton() {
                Title = Properties_Resources.Cancel
            };
            NSButton BackButton = new NSButton() {
                Title = Properties_Resources.Back
            };
//            DataDelegate.SelectionChanged += delegate
//            {
//                InvokeOnMainThread(delegate {
//                    NSOutlineView view = OutlineController.OutlineView();
//                    if (view.SelectedRow >= 0) {
//                        ContinueButton.Enabled = true;
//                    } else {
//                        ContinueButton.Enabled = false;
//                    }
//                });
//            };
            DataDelegate.ItemExpanded += delegate(NSNotification notification)
            {
                InvokeOnMainThread(delegate {
                    NSCmisTree cmis = notification.UserInfo["NSObject"] as NSCmisTree;
                    if (cmis == null) {
                        Console.WriteLine("ItemExpanded Error");
                        return;
                    }

                    NSCmisTree cmisRoot = cmis;
                    while (cmisRoot.Parent != null) {
                        cmisRoot = cmisRoot.Parent;
                    }
                    RootFolder root = Repositories.Find(x=>x.Name.Equals(cmisRoot.Name));
                    if (root == null) {
                        Console.WriteLine("ItemExpanded find root Error");
                        return;
                    }

                    Node node = cmis.GetNode(root);
                    if (node == null) {
                        Console.WriteLine("ItemExpanded find node Error");
                        return;
                    }
                    Loader[root.Id].Load(node);
                });
            };
            ContinueButton.Activated += delegate
            {
                InvokeOnMainThread(delegate {
                    NSOutlineView view = OutlineController.OutlineView();
//                    NSCmisTree cmis = (NSCmisTree)(view.ItemAtRow(view.SelectedRow));
//                    while (cmis.Parent != null)
//                        cmis = cmis.Parent;
//                    RootFolder root = Repositories.Find(x=>x.Name.Equals(cmis.Name));
                    RootFolder root = Repositories.Find(x=>(x.Selected != false));
                    if (root != null)
                    {
                        foreach (AsyncNodeLoader task in Loader.Values)
                            task.Cancel();
                        Controller.saved_repository = root.Id;
                        List<string> ignored = NodeModelUtils.GetIgnoredFolder(root);
                        List<string> selected = NodeModelUtils.GetSelectedFolder(root);
                        Controller.Add2PageCompleted(root.Id, root.Path, ignored.ToArray(), selected.ToArray());
                    }
                });
            };
            CancelButton.Activated += delegate
            {
                InvokeOnMainThread(delegate
                {
                    foreach (AsyncNodeLoader task in Loader.Values)
                        task.Cancel();
                    Controller.PageCancelled();
                });
            };
            BackButton.Activated += delegate
            {
                InvokeOnMainThread(delegate
                {
                    foreach (AsyncNodeLoader task in Loader.Values)
                        task.Cancel();
                    Controller.BackToPage1();
                });
            };

            OutlineController.View.Frame = new RectangleF (190, 60, 400, 240);
            ContentView.AddSubview(OutlineController.View);
            Buttons.Add(ContinueButton);
            Buttons.Add(BackButton);
            Buttons.Add(CancelButton);
        }
        public override void AwakeFromNib ()
        {
            base.AwakeFromNib ();

            this.SideSplashView.Image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "side-splash.png")) {
                Size = new SizeF (150, 482)
            };

            this.Header.StringValue = Properties_Resources.EditTitle;

            Repo = new RootFolder()
            {
                Name = FolderName,
                Id = credentials.RepoId,
                Address = credentials.Address.ToString()
            };
            Repo.Selected = true;
            IgnoredFolderLoader.AddIgnoredFolderToRootNode(Repo, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(Repo, localPath);
            List<RootFolder> repos = new List<RootFolder>();
            repos.Add(Repo);

            Loader = new AsyncNodeLoader(Repo, credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);

            CancelButton.Title = Properties_Resources.DiscardChanges;
            FinishButton.Title = Properties_Resources.SaveChanges;

            DataDelegate = new OutlineViewDelegate ();
            DataSource = new CmisTree.CmisTreeDataSource(repos);
            Outline.DataSource = DataSource;
            Outline.Delegate = DataDelegate;

            Controller.CloseWindowEvent += delegate
            {
                Loader.Cancel();
                this.Window.PerformClose (this);
                this.Dispose();
            };

            InsertEvent ();

            //  must be called after InsertEvent()
            Loader.Load(Repo);
        }