Esempio n. 1
0
        public CswNbtNodePropButton(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node)
            : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node)
        {
            CswNbtFieldTypeRuleButton FieldTypeRule = (CswNbtFieldTypeRuleButton)_FieldTypeRule;

            _StateSubField       = FieldTypeRule.StateSubField;
            _MenuOptionsSubField = FieldTypeRule.MenuOptionsSubField;
            _DisplayNameSubField = FieldTypeRule.DisplayNameField;
            _IconSubField        = FieldTypeRule.IconSubField;

            // Associate subfields with methods on this object, for SetSubFieldValue()
            _SubFieldMethods.Add(_StateSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => State, x => State = CswConvert.ToString(x)));
            _SubFieldMethods.Add(_MenuOptionsSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => MenuOptions, x => MenuOptions = CswConvert.ToString(x)));
            _SubFieldMethods.Add(_DisplayNameSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => DisplayName, x => DisplayName = CswConvert.ToString(x)));
            _SubFieldMethods.Add(_IconSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Icon, x => Icon = CswConvert.ToString(x)));
        }
Esempio n. 2
0
        } // TreeToJson()

        private void _TreeNodeToGrid(CswNbtView View, ICswNbtTree Tree, CswExtJsGrid grid, CswExtJsGridRow gridrow)
        {
            string gridUniquePrefix = _getUniquePrefix(View);
            Collection <CswNbtTreeNodeProp> ChildProps = Tree.getChildNodePropsOfNode();

            foreach (CswNbtTreeNodeProp Prop in ChildProps)
            {
                // Potential bug here!
                // If the view defines the property by objectclass propname, but the nodetype propname differs, this might break
                CswExtJsGridDataIndex dataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, Prop.PropName);

                bool   IsHidden = Prop.Hidden;
                bool   IsLocked = Tree.getNodeLockedForCurrentPosition();
                string newValue = string.Empty;
                if (false == IsHidden)
                {
                    CswPrimaryKey NodeId = Tree.getNodeIdForCurrentPosition();
                    CswNbtMetaDataNodeTypeProp MetaDataProp = _CswNbtResources.MetaData.getNodeTypeProp(Prop.NodeTypePropId);

                    string oldValue = Prop.Gestalt;
                    if (string.IsNullOrEmpty(oldValue))
                    {
                        oldValue = null;
                    }

                    switch (Prop.FieldType)
                    {
                    case CswEnumNbtFieldType.Button:
                        if (false == IsLocked)
                        {
                            CswNbtFieldTypeRuleButton buttonFTR = (CswNbtFieldTypeRuleButton)MetaDataProp.getFieldTypeRule();
                            grid.rowData.btns.Add(new CswExtJsGridButton
                            {
                                DataIndex    = dataIndex.ToString(),
                                RowNo        = gridrow.RowNo,
                                MenuOptions  = Prop[buttonFTR.MenuOptionsSubField.Column],
                                SelectedText = oldValue ?? Prop.PropName,
                                PropAttr     = new CswPropIdAttr(NodeId, Prop.NodeTypePropId).ToString(),
                                Mode         = String.IsNullOrEmpty(MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Extended)) ? "button" : MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Extended)
                            });
                        }
                        break;

                    case CswEnumNbtFieldType.File:
                        string LinkUrl = CswNbtNodePropBlob.getLink(Prop.JctNodePropId, NodeId);
                        if (false == string.IsNullOrEmpty(LinkUrl) && false == string.IsNullOrEmpty(oldValue))
                        {
                            newValue = "<a target=\"blank\" href=\"" + LinkUrl + "\">" + (oldValue) + "</a>";
                        }
                        break;

                    case CswEnumNbtFieldType.Image:
                        string ImageUrl = CswNbtNodePropImage.getLink(Prop.JctNodePropId, NodeId);
                        if (false == string.IsNullOrEmpty(ImageUrl))
                        {
                            newValue = "<a target=\"blank\" href=\"" + ImageUrl + "\">" + (oldValue ?? "Image") + "</a>";
                        }
                        break;

                    case CswEnumNbtFieldType.Link:

                        //string Href = CswNbtNodePropLink.GetFullURL( MetaDataProp.Attribute1, Prop.Field1_Big, MetaDataProp.Attribute2 );
                        string Href = CswNbtNodePropLink.GetFullURL(MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Attribute1),
                                                                    Prop.Field1_Big,
                                                                    MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Attribute2));
                        if (false == string.IsNullOrEmpty(Href))
                        {
                            newValue = "<a target=\"blank\" href=\"" + Href + "\">" + (oldValue ?? "Link") + "</a>";
                        }
                        break;

                    case CswEnumNbtFieldType.Logical:
                        newValue = CswConvert.ToDisplayString(CswConvert.ToTristate(oldValue));
                        break;

                    case CswEnumNbtFieldType.MOL:
                        string molUrl = CswNbtNodePropMol.getLink(Prop.JctNodePropId, NodeId);
                        if (false == string.IsNullOrEmpty(molUrl))
                        {
                            newValue = "<a target=\"blank\" href=\"" + molUrl + "\">" + "Structure.jpg" + "</a>";
                        }
                        break;

                    default:
                        newValue = oldValue;
                        break;
                    }
                }
                gridrow.data[dataIndex] = newValue;
            } // foreach( JObject Prop in ChildProps )

            // Recurse, but add properties of child nodes to the same gridrow
            for (Int32 c = 0; c < Tree.getChildNodeCount(); c++)
            {
                Tree.goToNthChild(c);
                _TreeNodeToGrid(View, Tree, grid, gridrow);
                Tree.goToParentNode();
            }
        } // _TreeNodeToGrid()