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);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// This class can be used to load children nodes asynchronous in another thread
 /// </summary>
 /// <param name="root">The repository Node</param>
 /// <param name="credentials">The server crendentials to load children for the given Cmis Repo</param>
 /// <param name="method">Function for loading nodes</param>
 public AsyncNodeLoader(RootFolder root, CmisRepoCredentials credentials, LoadChildrenDelegate method, CheckChildrenDelegate check)
 {
     this.root = root;
     repoCredentials = credentials;
     this.actualNode = null;
     this.worker = new BackgroundWorker();
     this.method = method;
     this.check = check;
     this.worker.WorkerReportsProgress = false;
     this.worker.WorkerSupportsCancellation = true;
     this.worker.DoWork += new DoWorkEventHandler(DoWork);
     this.worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Finished);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Edit(CmisRepoCredentials credentials, string name, string remotePath, List<string> ignores, string localPath)
        {
            Name = name;
            this.credentials = credentials;
            this.remotePath = remotePath;
            this.Ignores = ignores;
            this.localPath = localPath;

            CreateEdit();

            Deletable      = true;

            DeleteEvent += delegate (object sender, DeleteEventArgs args) {
                args.RetVal = false;
                Controller.CloseWindow();
            };

            Controller.OpenWindowEvent += delegate
            {
                ShowAll ();
                Activate ();
            };
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get the sub-folders of a particular CMIS folder.
        /// </summary>
        /// <returns>Full path of each sub-folder, including leading slash.</returns>
        static public FolderTree GetSubfolderTree(CmisRepoCredentials credentials, string path, int depth)
        {
            // Connect to the CMIS repository.
            ISession session = Auth.Auth.GetCmisSession(credentials.Address.ToString(), credentials.UserName, credentials.Password.ToString(), credentials.RepoId);

            // Get the folder.
            IFolder folder;
            try
            {
                folder = (IFolder)session.GetObjectByPath(path);
            }
            catch (Exception ex)
            {
                Logger.Warn(String.Format("CmisUtils | exception when session GetObjectByPath for {0}", path), ex);
                throw;
            }

            // Debug the properties count, which allows to check whether a particular CMIS implementation is compliant or not.
            // For instance, IBM Connections is known to send an illegal count.
            Logger.Info("CmisUtils | folder.Properties.Count:" + folder.Properties.Count.ToString());
            try
            {
                IList<ITree<IFileableCmisObject>> trees = folder.GetFolderTree(depth);
                return new FolderTree(trees, folder, depth);
            }
            catch (Exception e)
            {
                Logger.Info("CmisUtils getSubFolderTree | Exception " + e.Message, e);
                throw;
            }
        }
Exemplo n.º 5
0
        private void ShowAdd2Page()
        {
            CmisTreeStore cmisStore = new CmisTreeStore ();
            Gtk.TreeView treeView = new Gtk.TreeView (cmisStore.CmisStore);

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

            Header = CmisSync.Properties_Resources.Which;

            VBox layout_vertical   = new VBox (false, 12);

            Button cancel_button = new Button (cancelText);
            cancel_button.Clicked += delegate {
                foreach (AsyncNodeLoader task in loader.Values)
                    task.Cancel();
                Controller.PageCancelled ();
            };

            Button continue_button = new Button (continueText)
            {
                Sensitive = (repositories.Count > 0)
            };

            continue_button.Clicked += delegate {
                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());
                }
            };

            Button back_button = new Button (backText)
            {
                Sensitive = true
            };

            back_button.Clicked += delegate {
                foreach (AsyncNodeLoader task in loader.Values)
                    task.Cancel();
                Controller.BackToPage1();
            };

            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;
                }

                RootFolder selectedRoot = repositories.Find (x => (x.Selected != false));
                Node parent = node;
                while (parent.Parent != null)
                {
                    parent = parent.Parent;
                }
                RootFolder root = parent as RootFolder;
                if (root != selectedRoot)
                {
                    selectedRoot.Selected = false;
                    cmisStore.UpdateCmisTree(selectedRoot);
                }

                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;
                Node parent = node;
                while (parent.Parent != null)
                {
                    parent = parent.Parent;
                }
                RootFolder root = parent as RootFolder;
                loader[root.Id].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(back_button);
            AddButton(cancel_button);
            AddButton(continue_button);

            if (repositories.Count > 0)
            {
                continue_button.GrabDefault ();
                continue_button.GrabFocus ();
            }
            else
            {
                back_button.GrabDefault ();
                back_button.GrabFocus ();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Loads a tree of remote sub folder with the depth of 2
 /// </summary>
 /// <param name="credentials"></param>
 /// <param name="root"></param>
 /// <returns></returns>
 public static List<Node> LoadSubFolderDelegate(CmisRepoCredentials credentials, Node root)
 {
     CmisUtils.FolderTree tree = CmisUtils.GetSubfolderTree(credentials, root.Path, 2);
     List<Node> children = CreateSubTrees(tree.Children, null);
     foreach (Node child in children)
         child.Parent = root;
     return children;
 }