public static void GetButtonMode(ICswResources Resources, CswNbtPropertyReturn Return, CswPropIdAttr PropId)
        {
            CswNbtResources            NbtResources = (CswNbtResources)Resources;
            CswNbtMetaDataNodeTypeProp BtnNTP       = NbtResources.MetaData.getNodeTypeProp(PropId.NodeTypePropId);
            CswNbtNode           Node    = NbtResources.Nodes.GetNode(PropId.NodeId);
            CswNbtNodePropButton btnProp = Node.Properties[BtnNTP].AsButton;

            if (false == string.IsNullOrEmpty(btnProp.Mode))
            {
                Return.Data.Mode = Node.Properties[BtnNTP].AsButton.Mode;
            }
        }
Exemple #2
0
 private void _toggleButtonVisibility(CswNbtNodePropButton Button, bool IsVisible, bool SaveToDb)
 {
     Button.setHidden(value: false == IsVisible, SaveToDb: SaveToDb);
 }
        private Int32 _populateDictionary( ICswNbtTree Tree, Collection<Int32> PropsToHide, Int32 Page = 0, Int32 PageLimit = 0 )
        {
            Int32 results = 0;
            for( Int32 c = Math.Max( 0, ( Page - 1 ) * PageLimit ); ( c < Tree.getChildNodeCount() && ( PageLimit < 1 || results < PageLimit ) ); c++ )
            {
                Tree.goToNthChild( c );

                TableNode thisNode = new TableNode();

                thisNode.NodeKey = Tree.getNodeKeyForCurrentPosition();

                // Note on FilterToNodeTypeId: 
                // It would be better to filter inside the view, 
                // but it's also much more work, and I'm not even sure this feature will be used.

                if( null != thisNode.NodeKey &&
                    ( Int32.MinValue == _FilterToNodeTypeId || _FilterToNodeTypeId == thisNode.NodeKey.NodeTypeId ) )
                {
                    thisNode.NodeType = _CswNbtResources.MetaData.getNodeType( thisNode.NodeKey.NodeTypeId );
                    if( null != thisNode.NodeType )
                    {
                        thisNode.NodeId = Tree.getNodeIdForCurrentPosition();
                        thisNode.NodeName = Tree.getNodeNameForCurrentPosition();
                        thisNode.Locked = Tree.getNodeLockedForCurrentPosition();
                        thisNode.Disabled = ( false == Tree.getNodeIncludedForCurrentPosition() );
                        thisNode.IsFavorite = Tree.getNodeFavoritedForCurrentPosition();

                        thisNode.ThumbnailUrl = _getThumbnailUrl( Tree.getNodeIconForCurrentPosition() );

                        thisNode.AllowView = _CswNbtResources.Permit.canAnyTab( Security.CswEnumNbtNodeTypePermission.View, thisNode.NodeType );
                        thisNode.AllowEdit = _CswNbtResources.Permit.canAnyTab( Security.CswEnumNbtNodeTypePermission.Edit, thisNode.NodeType );
                        thisNode.AllowDelete = _CswNbtResources.Permit.canNodeType( Security.CswEnumNbtNodeTypePermission.Delete, thisNode.NodeType );

                        // Properties
                        SortedSet<CswNbtSearchPropOrder.SearchOrder> orderDict = _CswNbtSearchPropOrder.getPropOrderDict( thisNode.NodeKey, _View );

                        foreach( CswNbtTreeNodeProp PropElm in Tree.getChildNodePropsOfNode() )
                        {
                            TableProp thisProp = new TableProp();
                            if( false == PropElm.Hidden )
                            {
                                thisProp.NodeTypePropId = PropElm.NodeTypePropId;
                                thisProp.ObjectClassPropId = PropElm.ObjectClassPropId;
                                if( PropsToHide == null || false == PropsToHide.Contains( thisProp.NodeTypePropId ) )
                                {
                                    thisProp.PropId = new CswPropIdAttr( thisNode.NodeId, thisProp.NodeTypePropId );
                                    thisProp.FieldType = PropElm.FieldType;
                                    thisProp.PropName = PropElm.PropName;
                                    thisProp.Gestalt = _Truncate( PropElm.Gestalt );
                                    thisProp.JctNodePropId = PropElm.JctNodePropId;

                                    // Special case: Image becomes thumbnail
                                    if( thisProp.FieldType == CswEnumNbtFieldType.Image )
                                    {
                                        thisNode.ThumbnailUrl = CswNbtNodePropImage.getLink( thisProp.JctNodePropId, thisNode.NodeId );
                                    }

                                    if( thisProp.FieldType == CswEnumNbtFieldType.MOL )
                                    {
                                        thisNode.ThumbnailUrl = CswNbtNodePropMol.getLink( thisProp.JctNodePropId, thisNode.NodeId );
                                    }
                                    else
                                    {
                                        CswNbtSearchPropOrder.SearchOrder thisOrder = orderDict.FirstOrDefault( Order => Order.NodeTypePropId == thisProp.NodeTypePropId ||
                                                                                                                         ( thisProp.ObjectClassPropId != Int32.MinValue &&
                                                                                                                           Order.ObjectClassPropId == thisProp.ObjectClassPropId ) );
                                        if( null != thisOrder )
                                        {
                                            thisProp.Source = thisOrder.Source;

                                            if( thisProp.FieldType == CswEnumNbtFieldType.Button )
                                            {
                                                // Include full info for rendering the button
                                                // This was done in such a way as to prevent instancing the CswNbtNode object, 
                                                // which we don't need for Buttons.
                                                CswNbtMetaDataNodeTypeProp NodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp( thisProp.NodeTypePropId );

                                                CswNbtWebServiceTabsAndProps ws = new CswNbtWebServiceTabsAndProps( _CswNbtResources, _CswNbtStatisticsEvents );
                                                Int32 TabId = Int32.MaxValue;
                                                if( null != NodeTypeProp.FirstEditLayout )
                                                {
                                                    TabId = NodeTypeProp.FirstEditLayout.TabId;
                                                }
                                                JProperty JpPropData = ws.makePropJson( thisNode.NodeId, TabId, NodeTypeProp, null, Int32.MinValue, Int32.MinValue, string.Empty, thisNode.Locked );
                                                thisProp.PropData = (JObject) JpPropData.Value;

                                                JObject PropValues = new JObject();
                                                CswNbtNodePropButton.AsJSON( NodeTypeProp, PropValues, PropElm.Field2, PropElm.Field1 );
                                                thisProp.PropData["values"] = PropValues;
                                            }
                                            if( false == thisNode.Props.ContainsKey( thisOrder.Order ) && false == thisNode.Props.ContainsValue( thisProp ) )
                                            {
                                                thisNode.Props.Add( thisOrder.Order, thisProp );
                                            }
                                            else
                                            {
                                                throw new CswDniException( CswEnumErrorType.Error, "A search result with the same value and position already exists in the result set.",
                                                   "{" + thisNode.NodeType.NodeTypeName + "} entity {" + thisNode.NodeName + "}, Id: {" + thisNode.NodeId + ", has a duplicate {" + thisProp.FieldType + "} property record for {" + thisProp.PropName + "} PropId: {" + thisProp.NodeTypePropId + "}" );
                                            }
                                        }
                                    }
                                } // if( false == PropsToHide.Contains( NodeTypePropId ) )
                            } //if (false == CswConvert.ToBoolean(PropElm["hidden"]))
                        } // foreach( XElement PropElm in NodeElm.Elements() )

                        if( false == _TableDict.ContainsKey( thisNode.NodeType ) )
                        {
                            _TableDict.Add( thisNode.NodeType, new Collection<TableNode>() );
                        }
                        _TableDict[thisNode.NodeType].Add( thisNode );
                        results++;

                    } // if( thisNode.NodeType != null )
                } // if(null != thisNode.NodeKey && ( Int32.MinValue == _FilterToNodeTypeId || _FilterToNodeTypeId == thisNode.NodeKey.NodeTypeId ) )
                Tree.goToParentNode();
            } // for( Int32 c = 0; c < Tree.getChildNodeCount(); c++ )
            return results;
        } // _populateDictionary()