Beispiel #1
0
        /// <summary>
        /// Return the serialized content of the browser.
        /// </summary>
        public SerializedKwsBrowser Serialize()
        {
            List<KwsBrowserFolderNode> folderList = new List<KwsBrowserFolderNode>();
            List<KwsBrowserKwsNode> kwsList = new List<KwsBrowserKwsNode>();
            RecursiveList(true, RootNode, folderList, kwsList);
            SerializedKwsBrowser skb = new SerializedKwsBrowser();

            foreach (KwsBrowserFolderNode fNode in folderList)
            {
                if (fNode.IsRoot()) continue;
                skb.FolderList.Add(new SerializedKwsBrowserFolder(fNode));
            }

            foreach (KwsBrowserKwsNode kNode in kwsList)
                skb.KwsList.Add(new SerializedKwsBrowserKws(kNode));

            skb.SelectedKwsID = (SelectedKws == null) ? 0 : SelectedKws.InternalID;

            return skb;
        }
Beispiel #2
0
        /// <summary>
        /// Link the workspaces and folders that have been deserialized. The 
        /// caller guarantees that all workspaces have a unique ID.
        /// 
        /// NOTE: this method is not the place where the state of the workspaces
        /// should be normalized. The workspace manager is not fully initialized
        /// so perform as few operations as possible. 'notInDbFlag' is true if 
        /// the workspaces aren't present in the local database because the KWM
        /// has been upgraded.
        /// </summary>
        public void LinkDeserializedKws(SerializedKwsBrowser skb, List<Workspace> kwsList, bool notInDbFlag)
        {
            // Deserialize the browser folders, reorder kwsList and get the
            // workspace folders.
            List<KwsBrowserFolderNode> kwsFolderList;
            List<bool> notifyFlagsList;

            UiBroker.Browser.Deserialize(skb, kwsList, out kwsFolderList, out notifyFlagsList);

            // Relink the workspaces.
            for (int i = 0; i < kwsList.Count; i++)
                RelinkWorkspaceObject(kwsList[i], kwsFolderList[i], notifyFlagsList[i], notInDbFlag);

            // Reselect the selected workspace, if any.
            UiBroker.Browser.SelectedKws = GetKwsByInternalID(skb.SelectedKwsID);

            // Adjust the public workspace ID.
            AdjustPublicKwsID();
        }
Beispiel #3
0
        /// <summary>
        /// Deserialize the content of the browser, reorder kwsList 
        /// appropriately and populate kwsFolderList with the folder of each 
        /// workspace.
        /// </summary>
        public void Deserialize(SerializedKwsBrowser skb, List<Workspace> kwsList, out List<KwsBrowserFolderNode> kwsFolderList, out List<bool> notifyFlagsList)
        {
            // Recreate the browser folders, in order.
            foreach (SerializedKwsBrowserFolder skbf in skb.FolderList)
                CreateFolderFromPath(skbf.Path).ExpandedFlag = skbf.ExpandedFlag;

            // Create a mapping between internal IDs and non-referenced workspaces.
            SortedDictionary<UInt64, Workspace> unrefTree = new SortedDictionary<UInt64, Workspace>();
            foreach (Workspace kws in kwsList) unrefTree[kws.InternalID] = kws;

            // Populate kwsList and kwsFolderList.
            kwsList.Clear();
            kwsFolderList = new List<KwsBrowserFolderNode>();
            notifyFlagsList = new List<bool>();

            // Process the workspaces found in the browser, in order.
            foreach (SerializedKwsBrowserKws skbk in skb.KwsList)
            {
                if (unrefTree.ContainsKey(skbk.ID))
                {
                    kwsList.Add(unrefTree[skbk.ID]);
                    kwsFolderList.Add(CreateFolderFromPath(skbk.ParentPath));
                    notifyFlagsList.Add(skbk.NotifyFlag);
                    unrefTree.Remove(skbk.ID);
                }
            }

            // Process the unreferenced workspaces.
            foreach (Workspace kws in unrefTree.Values)
            {
                kwsList.Add(kws);
                kwsFolderList.Add(PrimaryFolder);
                notifyFlagsList.Add(false);
            }
        }