Inheritance: MonoMac.Foundation.NSObject
Ejemplo n.º 1
0
        public Node GetNode(Node root)
        {
            NSCmisTree     cmis  = this;
            Stack <string> paths = new Stack <string> ();

            do
            {
                paths.Push(cmis.Name);
                cmis = cmis.Parent;
            } while (cmis != null);

            Node node = root;

            do
            {
                string current = paths.Pop();
                if (current != node.Name)
                {
                    return(null);
                }
                if (paths.Count == 0)
                {
                    return(node);
                }
                node = node.Children.First(x => x.Name.Equals(paths.Peek()));
            } while (true);
        }
Ejemplo n.º 2
0
        public override void SetObjectValue(NSOutlineView outlineView, NSObject theObject, NSTableColumn tableColumn, NSObject item)
        {
            UpdateItem(ref item);
            Console.WriteLine("SetObjectValue " + item + ": " + theObject);
            if (item == null)
            {
                Console.WriteLine("SetObjectValue null Error");
                return;
            }
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("SetObjectValue Error");
                return;
            }
            if (tableColumn.Identifier == "Name")
            {
                NSNumber number = (NSNumber)theObject;
                if (number == null)
                {
                    Console.WriteLine("SetObjectValue number Error");
                    return;
                }
                SelectedEvent(cmis, number.IntValue);
                return;
            }
            return;
        }
Ejemplo n.º 3
0
 public NSCmisTree(Node root)
 {
     Name = root.Name;
     Status = root.Status;
     Selected = root.Selected;
     Parent = null;
     foreach (Node node in root.Children) {
         NSCmisTree child = new NSCmisTree (node);
         child.Parent = this;
         Children.Add (child);
     }
 }
Ejemplo n.º 4
0
        public override string ToString()
        {
            string     path   = Name;
            NSCmisTree parent = Parent;

            while (parent != null)
            {
                path   = parent.Name + "/" + path;
                parent = parent.Parent;
            }
            return(path);
        }
Ejemplo n.º 5
0
        public override NSObject GetObjectValue(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            UpdateItem(ref item);
//            Console.WriteLine ("GetObjectValue " + item);
            if (item == null)
            {
                return((NSString)"");
            }
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("GetObjectValue Error");
                return((NSString)"");
            }
            if (tableColumn.Identifier.Equals("Name"))
            {
                // Console.WriteLine ("GetObjectValue " + item);
                return((NSString)cmis.Name);

                /*
                 * switch (cmis.Selected) {
                 * case true:
                 *  return new NSNumber (1);
                 * case false:
                 *  return new NSNumber (0);
                 * case null:
                 *  return new NSNumber (-1);
                 * }
                 * return (NSString)cmis.Name;
                 */
            }
            if (tableColumn.Identifier.Equals("Status"))
            {
                switch (cmis.Status)
                {
                case LoadingStatus.START:
                    return((NSString)Properties_Resources.LoadingStatusSTART);

                case LoadingStatus.LOADING:
                    return((NSString)Properties_Resources.LoadingStatusLOADING);

                case LoadingStatus.ABORTED:
                    return((NSString)Properties_Resources.LoadingStatusABORTED);

                default:
                    return((NSString)"");
                }
                return((NSString)"");
            }
            Console.WriteLine("GetObjectValue Error");
            return((NSString)"");
        }
Ejemplo n.º 6
0
 public void UpdateCmisTree(RootFolder root)
 {
     lock (LockRepositories) {
         for (int i = 0; i < Repositories.Count; ++i) {
             if (Repositories [i].Name == root.Name) {
                 Repositories [i] = new NSCmisTree (root);
                 return;
             }
         }
         Repositories.Add (new NSCmisTree (root));
     }
 }
Ejemplo n.º 7
0
 public NSCmisTree(Node root)
 {
     Name     = root.Name;
     Status   = root.Status;
     Selected = root.Selected;
     Parent   = null;
     foreach (Node node in root.Children)
     {
         NSCmisTree child = new NSCmisTree(node);
         child.Parent = this;
         Children.Add(child);
     }
 }
Ejemplo n.º 8
0
 public void UpdateCmisTree(RootFolder root)
 {
     lock (LockRepositories) {
         for (int i = 0; i < Repositories.Count; ++i)
         {
             if (Repositories [i].Name == root.Name)
             {
                 Repositories [i] = new NSCmisTree(root);
                 return;
             }
         }
         Repositories.Add(new NSCmisTree(root));
     }
 }
Ejemplo n.º 9
0
        public override int GetChildrenCount(NSOutlineView outlineView, NSObject item)
        {
            UpdateItem(ref item);
//            Console.WriteLine ("GetChildrenCount " + item);
            if (item == null)
            {
                return(Repositories.Count);
            }
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("GetChildrenCount Error");
                return(0);
            }
            return(cmis.Children.Count);
        }
Ejemplo n.º 10
0
        public override NSObject GetChild(NSOutlineView outlineView, int childIndex, NSObject item)
        {
            UpdateItem(ref item);
//            Console.WriteLine ("GetChild " + item);
            if (item == null)
            {
                return(Repositories [childIndex]);
            }
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("GetChild Error");
                return(null);
            }
            return(cmis.Children [childIndex]);
        }
Ejemplo n.º 11
0
        private void UpdateItem(ref NSObject item)
        {
            lock (LockRepositories) {
                if (item == null)
                {
                    return;
                }
                NSCmisTree cmis = item as NSCmisTree;
                if (cmis == null)
                {
                    return;
                }

                Stack <string> paths = new Stack <string> ();
                do
                {
                    paths.Push(cmis.Name);
                    cmis = cmis.Parent;
                } while (cmis != null);

                string current = paths.Pop();
                cmis = Repositories.First(x => x.Name.Equals(current));
                if (cmis == null)
                {
                    return;
                }

                while (paths.Count > 0)
                {
                    current = paths.Pop();
                    cmis    = cmis.Children.First(x => x.Name.Equals(current));
                    if (cmis == null)
                    {
                        return;
                    }
                }

                item = cmis;
            }
        }
Ejemplo n.º 12
0
        public override bool ItemExpandable(NSOutlineView outlineView, NSObject item)
        {
            UpdateItem(ref item);
//            Console.WriteLine ("ItemExpandable " + item);
            if (item == null)
            {
                return(Repositories.Count > 0);
            }
            NSCmisTree cmis = item as NSCmisTree;

            if (cmis == null)
            {
                Console.WriteLine("ItemExpandable Error");
                return(false);
            }
//            Console.WriteLine ("ItemExpandable " + cmis.Name + " " + cmis.Children.Count);
            if (cmis.Parent == null && cmis.Selected == false)
            {
                return(false);
            }
            return(cmis.Children.Count > 0);
        }
Ejemplo n.º 13
0
        void OutlineSelected (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);

                for (int i = 0; i < Outline.RowCount; ++i) {
                    try {
                        Outline.ReloadItem (Outline.ItemAtRow (i));
                    } catch (Exception e) {
                        Console.WriteLine (e);
                    }
                }
            });
        }
        void OutlineSelected(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);
                    }
                }

                if (selectedRoot != null) {
                    foreach (RootFolder root in Repositories) {
                        if (root != selectedRoot) {
                            root.Selected = false;
                            DataSource.UpdateCmisTree(root);
                        }
                    }

                    Outline.ReloadData();
                } else {
                    for (int i = 0; i < Outline.RowCount; ++i) {
                        Outline.ReloadItem(Outline.ItemAtRow(i));
                    }
                }
            });
        }