Ejemplo n.º 1
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()
Ejemplo n.º 2
0
        } // getPropOrder()

        /// <summary>
        /// Returns the order in which properties should appear in the table
        /// </summary>
        public SortedSet <SearchOrder> getPropOrderDict(CswNbtNodeKey NodeKey, CswNbtView View = null)
        {
            SortedSet <SearchOrder> ret      = null;
            CswNbtMetaDataNodeType  NodeType = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);

            if (null != NodeType)
            {
                if (false == _PropOrderDict.ContainsKey(NodeType))
                {
                    ret = new SortedSet <SearchOrder>();

                    // View order goes first
                    if (View != null)
                    {
                        CswNbtViewRelationship ViewRel = (CswNbtViewRelationship)View.FindViewNodeByUniqueId(NodeKey.ViewNodeUniqueId);
                        if (ViewRel != null)
                        {
                            foreach (CswNbtViewProperty ViewProp in ViewRel.Properties)
                            {
                                SearchOrder ThisOrder = new SearchOrder
                                {
                                    NodeTypePropId    = ViewProp.NodeTypePropId,
                                    ObjectClassPropId = ViewProp.ObjectClassPropId,
                                    Source            = CswEnumNbtSearchPropOrderSourceType.View,
                                    Order             = 0
                                };


                                foreach (CswNbtViewProperty OtherViewProp in ViewRel.Properties)
                                {
                                    if ((OtherViewProp.Order != Int32.MinValue && OtherViewProp.Order < ViewProp.Order) ||
                                        ViewProp.Order == Int32.MinValue)
                                    {
                                        ThisOrder.Order += 1;
                                    }
                                }
                                ret.Add(ThisOrder);
                            } // foreach( CswNbtViewProperty ViewProp in ViewRel.Properties )
                        }     // if( ViewRel != null )
                    }         // if( _View != null )


                    // Table layout goes second
                    Int32 maxOrder = (ret.Count > 0) ? ret.Max().Order : 0;
                    if (false == _TableLayoutDict.Keys.Contains(NodeType))
                    {
                        _TableLayoutDict[NodeType] = _CswNbtResources.MetaData.NodeTypeLayout.getPropsInLayout(NodeType.NodeTypeId, Int32.MinValue, CswEnumNbtLayoutType.Table);
                    }
                    foreach (CswNbtMetaDataNodeTypeProp Prop in _TableLayoutDict[NodeType])
                    {
                        SearchOrder ThisOrder = new SearchOrder
                        {
                            NodeTypePropId    = Prop.PropId,
                            ObjectClassPropId = Prop.ObjectClassPropId,
                            Source            = CswEnumNbtSearchPropOrderSourceType.Table,
                        };
                        if (false == ret.Contains(ThisOrder))
                        {
                            CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout propTableLayout = Prop.getTableLayout();
                            if (propTableLayout.DisplayRow > 0)
                            {
                                ThisOrder.Order = maxOrder + propTableLayout.DisplayRow;
                                ret.Add(ThisOrder);
                            }
                        }
                    } // foreach( CswNbtMetaDataNodeTypeProp Prop in _TableLayoutDict[thisNode.NodeType] )


                    // Everything else in alphabetical order
                    maxOrder = (ret.Count > 0) ? ret.Max().Order : 0;
                    foreach (CswNbtMetaDataNodeTypeProp Prop in NodeType.getNodeTypeProps()
                             .OrderBy(Prop => Prop.PropName))
                    {
                        SearchOrder ThisOrder = new SearchOrder
                        {
                            NodeTypePropId    = Prop.PropId,
                            ObjectClassPropId = Prop.ObjectClassPropId,
                            Source            = CswEnumNbtSearchPropOrderSourceType.Results,
                        };
                        if (false == ret.Contains(ThisOrder))
                        {
                            maxOrder++;
                            ThisOrder.Order = maxOrder;
                            ret.Add(ThisOrder);
                        }
                    }
                    _PropOrderDict.Add(NodeType, ret);
                } // if( false == _PropOrderDict.ContainsKey( thisNode.NodeType ) )

                ret = _PropOrderDict[NodeType];
            } // if(null != NodeType)
            return(ret);
        }     //getPropOrderDict()
Ejemplo 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()