Exemplo n.º 1
0
        private void _getDefaultContentRecursive(JObject ParentObj, CswNbtViewNode ViewNode)
        {
            Collection <CswNbtViewNode.CswNbtViewAddNodeTypeEntry> Entries = ViewNode.AllowedChildNodeTypes(true);

            if (Entries.Count > 0)
            {
                ParentObj["entries"] = new JObject();
                foreach (CswNbtViewNode.CswNbtViewAddNodeTypeEntry Entry in Entries)
                {
                    ParentObj["entries"][Entry.NodeType.NodeTypeName] = CswNbtWebServiceMainMenu.makeAddMenuItem(Entry.NodeType, new CswPrimaryKey(), string.Empty);
                }
            }
            JObject ChildObj = new JObject();

            ParentObj["children"] = ChildObj;

            // recurse
            foreach (CswNbtViewRelationship ChildViewRel in ViewNode.GetChildrenOfType(CswEnumNbtViewNodeType.CswNbtViewRelationship))
            {
                _getDefaultContentRecursive(ChildObj, ChildViewRel);
            }
        } // _getDefaultContentRecursive()
Exemplo n.º 2
0
        } // _runTreeNodesRecursive()

        /// <summary>
        /// Generate a JObject for the tree's current node
        /// </summary>
        private CswExtTree.TreeNode _getTreeNode(ICswNbtTree Tree, CswExtTree.TreeNode Parent, CswNbtSdTrees.Contract.Request Request)
        {
            CswExtTree.TreeNode Ret;
            if (null != Request && Request.UseCheckboxes)
            {
                Ret = new CswExtTree.TreeNodeWithCheckbox();
            }
            else
            {
                Ret = new CswExtTree.TreeNode();
            }

            CswNbtNodeKey ThisNodeKey       = Tree.getNodeKeyForCurrentPosition();
            string        ThisNodeName      = Tree.getNodeNameForCurrentPosition();
            string        ThisNodeIcon      = "";
            string        ThisNodeKeyString = ThisNodeKey.ToString();
            string        ThisNodeId        = "";
            int           ThisNodeTypeId    = int.MinValue;
            int           ThisObjectClassId = int.MinValue;

            bool ThisNodeLocked   = false;
            bool ThisNodeDisabled = false;
            bool ThisNodeFavorite = false;
            CswNbtMetaDataNodeType ThisNodeType = _CswNbtResources.MetaData.getNodeType(ThisNodeKey.NodeTypeId);

            switch (ThisNodeKey.NodeSpecies)
            {
            case CswEnumNbtNodeSpecies.Plain:
                ThisNodeId        = ThisNodeKey.NodeId.ToString();
                ThisNodeName      = Tree.getNodeNameForCurrentPosition();
                ThisNodeTypeId    = ThisNodeType.FirstVersionNodeTypeId;
                ThisObjectClassId = ThisNodeType.ObjectClassId;
                ThisNodeLocked    = Tree.getNodeLockedForCurrentPosition();
                ThisNodeDisabled  = (false == Tree.getNodeIncludedForCurrentPosition());
                ThisNodeFavorite  = Tree.getNodeFavoritedForCurrentPosition();
                if (ThisNodeFavorite)
                {
                    ThisNodeIcon = CswNbtMetaDataObjectClass.IconPrefix16 + "starsolid.png";
                }
                else
                {
                    ThisNodeIcon = CswNbtMetaDataObjectClass.IconPrefix16 + Tree.getNodeIconForCurrentPosition();
                }
                break;

            case CswEnumNbtNodeSpecies.Group:
                Ret.CssClass = "folder";
                break;
            }

            CswNbtViewNode ThisNodeViewNode = _View.FindViewNodeByUniqueId(ThisNodeKey.ViewNodeUniqueId);

            string ThisNodeState = "closed";

            if (ThisNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.More ||
                _View.ViewMode == CswEnumNbtViewRenderingMode.List ||
                (Tree.IsFullyPopulated && Tree.getChildNodeCount() == 0) ||
                (ThisNodeViewNode != null && ThisNodeViewNode.GetChildrenOfType(CswEnumNbtViewNodeType.CswNbtViewRelationship).Count == 0))
            {
                ThisNodeState = "leaf";
            }

            Ret.Name = ThisNodeName;
            Ret.Icon = ThisNodeIcon;
            Ret.Id   = ThisNodeKeyString;
            switch (ThisNodeState)
            {
            case "closed":
                Ret.Expanded = false;
                break;

            case "leaf":
                Ret.IsLeaf = true;
                break;
            }

            if (null != Request)
            {
                Ret.Expanded = Request.ExpandAll;
            }

            if (int.MinValue != ThisNodeTypeId)
            {
                Ret.NodeTypeId = ThisNodeTypeId.ToString();
            }
            if (int.MinValue != ThisObjectClassId)
            {
                Ret.ObjectClassId = ThisObjectClassId.ToString();
            }

            Ret.NodeSpecies = ThisNodeKey.NodeSpecies.ToString();
            Ret.NodeId      = ThisNodeId;
            Ret.IsLocked    = ThisNodeLocked;
            if (ThisNodeDisabled)
            {
                Ret.IsDisabled = true;
                Ret.CssClass   = "disabled";
            }
            Ret.IsFavorite = ThisNodeFavorite;

            if (null != Parent && false == string.IsNullOrEmpty(Parent.Path))
            {
                Ret.Path = Parent.Path;
            }
            else
            {
                Ret.ParentId = "root";
                Ret.Path     = "|root";
            }
            if (false == Tree.isCurrentPositionRoot())
            {
                CswNbtNodeKey ParentKey = Tree.getNodeKeyForParentOfCurrentPosition();
                if (ParentKey.NodeSpecies != CswEnumNbtNodeSpecies.Root)
                {
                    Ret.ParentId = ParentKey.ToString();
                }
            }

            Ret.Path += "|" + Ret.Id;

            if (Tree.getChildNodeCount() > 0)
            {
                Ret.Children = new Collection <CswExtTree.TreeNode>();
            }
            else
            {
                Ret.Children = null;
            }

            Collection <CswNbtTreeNodeProp> ThisNodeProps = Tree.getChildNodePropsOfNode();

            CswNbtViewRoot.forEachProperty EachNodeProp = (ViewProp) =>
            {
                foreach (CswNbtTreeNodeProp NodeProp in ThisNodeProps)
                {
                    if (NodeProp.PropName.ToLower().Trim() == ViewProp.Name.ToLower().Trim())
                    {
                        Ret.data[new CswExtJsGridDataIndex(_View.ViewName, ViewProp.Name.ToLower().Trim())] = NodeProp.Gestalt;
                    }
                }
            };

            _View.Root.eachRelationship(relationshipCallBack: null, propertyCallBack: EachNodeProp);

            //ThisNodeObj["childcnt"] = Tree.getChildNodeCount().ToString();


            return(Ret);
        } // _treeNodeJObject()
Exemplo n.º 3
0
        } // _runTreeNodesRecursive()

        /// <summary>
        /// Generate a JObject for the tree's current node
        /// </summary>
        private JObject _treeNodeJObject(ICswNbtTree Tree)
        {
            JObject ThisNodeObj = new JObject();

            CswNbtNodeKey ThisNodeKey       = Tree.getNodeKeyForCurrentPosition();
            string        ThisNodeName      = Tree.getNodeNameForCurrentPosition();
            string        ThisNodeIcon      = "";
            string        ThisNodeKeyString = ThisNodeKey.ToString();
            string        ThisNodeId        = "";

            string ThisNodeRel                  = "";
            bool   ThisNodeLocked               = false;
            bool   ThisNodeDisabled             = false;
            CswNbtMetaDataNodeType ThisNodeType = _CswNbtResources.MetaData.getNodeType(ThisNodeKey.NodeTypeId);

            switch (ThisNodeKey.NodeSpecies)
            {
            //case NodeSpecies.More:
            //    ThisNodeId = ThisNodeKey.NodeId.ToString();
            //    ThisNodeName = NodeSpecies.More.ToString() + "...";
            //    ThisNodeIcon = "Images/icons/triangle_blueS.gif";
            //    ThisNodeRel = "nt_" + ThisNodeType.FirstVersionNodeTypeId;
            //    break;
            case CswEnumNbtNodeSpecies.Plain:
                ThisNodeId       = ThisNodeKey.NodeId.ToString();
                ThisNodeName     = Tree.getNodeNameForCurrentPosition();
                ThisNodeRel      = "nt_" + ThisNodeType.FirstVersionNodeTypeId;
                ThisNodeLocked   = Tree.getNodeLockedForCurrentPosition();
                ThisNodeDisabled = (false == Tree.getNodeIncludedForCurrentPosition());
                if (false == string.IsNullOrEmpty(ThisNodeType.IconFileName))
                {
                    ThisNodeIcon = CswNbtMetaDataObjectClass.IconPrefix16 + ThisNodeType.IconFileName;
                }
                break;

            case CswEnumNbtNodeSpecies.Group:
                ThisNodeRel = "group";
                break;
            }

            CswNbtViewNode ThisNodeViewNode = _View.FindViewNodeByUniqueId(ThisNodeKey.ViewNodeUniqueId);

            string ThisNodeState = "closed";

            if (ThisNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.More ||
                _View.ViewMode == CswEnumNbtViewRenderingMode.List ||
                (Tree.IsFullyPopulated && Tree.getChildNodeCount() == 0) ||
                (ThisNodeViewNode != null && ThisNodeViewNode.GetChildrenOfType(CswEnumNbtViewNodeType.CswNbtViewRelationship).Count == 0))
            {
                ThisNodeState = "leaf";
            }

            ThisNodeObj["data"]       = ThisNodeName;
            ThisNodeObj["icon"]       = ThisNodeIcon;
            ThisNodeObj["attr"]       = new JObject();
            ThisNodeObj["attr"]["id"] = _IdPrefix + ThisNodeKeyString;   // This is the only unique string for this node in this tree
            //ThisNodeObj["attr"]["id"] = _IdPrefix + ThisNodeId;
            ThisNodeObj["attr"]["rel"]     = ThisNodeRel;
            ThisNodeObj["attr"]["state"]   = ThisNodeState;
            ThisNodeObj["attr"]["species"] = ThisNodeKey.NodeSpecies.ToString();
            ThisNodeObj["attr"]["nodeid"]  = ThisNodeId;
            ThisNodeObj["attr"]["nodekey"] = ThisNodeKeyString;
            ThisNodeObj["attr"]["locked"]  = ThisNodeLocked.ToString().ToLower();
            if (ThisNodeDisabled)
            {
                ThisNodeObj["attr"]["disabled"] = ThisNodeDisabled.ToString().ToLower();
            }
            CswNbtNodeKey ParentKey = Tree.getNodeKeyForParentOfCurrentPosition();

            if (ParentKey.NodeSpecies != CswEnumNbtNodeSpecies.Root)
            {
                ThisNodeObj["attr"]["parentkey"] = ParentKey.ToString();
            }

            //if( "leaf" != ThisNodeState && Tree.getChildNodeCount() > 0 )
            //{
            ThisNodeObj["state"]    = ThisNodeState;
            ThisNodeObj["children"] = new JArray();
            ThisNodeObj["childcnt"] = Tree.getChildNodeCount().ToString();
            //}
            return(ThisNodeObj);
        } // _treeNodeJObject()