Esempio n. 1
0
        private void CreateTreeView()
        {
            System.Uri resourceLocater = new System.Uri("/DataSpaceSync;component/FolderTreeMVC/TreeView.xaml", System.UriKind.Relative);
            treeView = Application.LoadComponent(resourceLocater) as TreeView;

            repo = new CmisSync.CmisTree.RootFolder()
            {
                Name    = FolderName,
                Id      = Credentials.RepoId,
                Address = Credentials.Address.ToString()
            };

            ObservableCollection <RootFolder> repos = new ObservableCollection <RootFolder>();

            repos.Add(repo);
            repo.Selected = true;

            asyncLoader = new AsyncNodeLoader(repo, Credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
            IgnoredFolderLoader.AddIgnoredFolderToRootNode(repo, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(repo, localPath);
            asyncLoader.Load(repo);

            treeView.DataContext = repos;

            treeView.AddHandler(TreeViewItem.ExpandedEvent, new RoutedEventHandler(delegate(object sender, RoutedEventArgs e)
            {
                TreeViewItem expandedItem = e.OriginalSource as TreeViewItem;
                Node expandedNode         = expandedItem.Header as Folder;
                if (expandedNode != null)
                {
                    asyncLoader.Load(expandedNode);
                }
            }));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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;

            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);
        }
Esempio n. 4
0
        /// <summary>
        /// Create the UI
        /// </summary>
        private void CreateEdit()
        {
            CmisTreeStore cmisStore = new CmisTreeStore();

            Gtk.TreeView treeView = new Gtk.TreeView(cmisStore.CmisStore);

            RootFolder root = new RootFolder()
            {
                Name    = this.Name,
                Id      = credentials.RepoId,
                Address = credentials.Address.ToString()
            };

            IgnoredFolderLoader.AddIgnoredFolderToRootNode(root, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(root, localPath);

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

            asyncLoader.UpdateNodeEvent += delegate {
                cmisStore.UpdateCmisTree(root);
            };
            cmisStore.UpdateCmisTree(root);
            asyncLoader.Load(root);

            Header = CmisSync.Properties_Resources.EditTitle;

            VBox layout_vertical = new VBox(false, 12);

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

            Button cancel_button = new Button(CmisSync.Properties_Resources.Cancel);

            cancel_button.Clicked += delegate {
                Close();
            };

            Button finish_button = new Button(CmisSync.Properties_Resources.SaveChanges);

            finish_button.Clicked += delegate {
                Ignores = NodeModelUtils.GetIgnoredFolder(root);
                Controller.SaveFolder();
                Close();
            };

            Gtk.TreeIter iter;
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;

            TreeViewColumn column = new TreeViewColumn();

            column.Title = "Name";
            CellRendererToggle renderToggle = new CellRendererToggle();

            column.PackStart(renderToggle, false);
            renderToggle.Activatable = true;
            column.AddAttribute(renderToggle, "active", (int)CmisTreeStore.Column.ColumnSelected);
            column.AddAttribute(renderToggle, "inconsistent", (int)CmisTreeStore.Column.ColumnSelectedThreeState);
            column.AddAttribute(renderToggle, "radio", (int)CmisTreeStore.Column.ColumnRoot);
            renderToggle.Toggled += delegate(object render, ToggledArgs args) {
                TreeIter iterToggled;
                if (!cmisStore.CmisStore.GetIterFromString(out iterToggled, args.Path))
                {
                    Console.WriteLine("Toggled GetIter Error " + args.Path);
                    return;
                }

                Node node = cmisStore.CmisStore.GetValue(iterToggled, (int)CmisTreeStore.Column.ColumnNode) as Node;
                if (node == null)
                {
                    Console.WriteLine("Toggled GetValue Error " + args.Path);
                    return;
                }

                if (node.Parent == null)
                {
                    node.Selected = true;
                }
                else
                {
                    if (node.Selected == false)
                    {
                        node.Selected = true;
                    }
                    else
                    {
                        node.Selected = false;
                    }
                }
                cmisStore.UpdateCmisTree(root);
            };
            CellRendererText renderText = new CellRendererText();

            column.PackStart(renderText, false);
            column.SetAttributes(renderText, "text", (int)CmisTreeStore.Column.ColumnName);
            column.Expand = true;
            treeView.AppendColumn(column);

            treeView.AppendColumn("Status", new StatusCellRenderer(), "text", (int)CmisTreeStore.Column.ColumnStatus);

            treeView.RowExpanded += delegate(object o, RowExpandedArgs args) {
                Node node = cmisStore.CmisStore.GetValue(args.Iter, (int)CmisTreeStore.Column.ColumnNode) as Node;
                asyncLoader.Load(node);
            };

            ScrolledWindow sw = new ScrolledWindow()
            {
                ShadowType = Gtk.ShadowType.In
            };

            sw.Add(treeView);

            layout_vertical.PackStart(new Label(""), false, false, 0);
            layout_vertical.PackStart(sw, true, true, 0);
            Add(layout_vertical);
            AddButton(cancel_button);
            AddButton(finish_button);

            finish_button.GrabDefault();

            this.ShowAll();
        }
Esempio n. 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();
        }