Example #1
0
        /// <summary>
        /// Generate the nodes that the constructor arguments indicate.
        /// </summary>
        /// <returns></returns>
        public virtual XmlNode[] Generate()
        {
            List <int> ids    = FieldIds;
            var        result = new XmlNode[ids.Count];

            for (int iresult = 0; iresult < result.Length; iresult++)
            {
                XmlNode output = m_source.Clone();
                result[iresult] = output;
                int    fieldId   = ids[iresult];
                string labelName = m_mdc.GetFieldLabel(fieldId);
                string fieldName = m_mdc.GetFieldName(fieldId);
                string className = m_mdc.GetOwnClsName(fieldId);
                if (string.IsNullOrEmpty(labelName))
                {
                    labelName = fieldName;
                }
                // generate parts for any given custom layout
                GeneratePartsFromLayouts(m_rootClassId, fieldName, fieldId, ref output);
                ReplaceParamsInAttributes(output, labelName, fieldName, fieldId, className);
                // LT-6956 : custom fields have the additional attribute "originalLabel", so add it here.
                XmlUtils.AppendAttribute(output, "originalLabel", labelName);
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// This is invoked when a generated part ref (<part ref="Custom" param="fieldName"/>)
        /// invokes the standard slice (<slice editor="autoCustom".../>). It comes up with the
        /// appropriate default slice for the custom field indicated in the param attribute of
        /// the caller.
        /// </summary>
        static Slice MakeAutoCustomSlice(FdoCache cache, ICmObject obj, XmlNode caller)
        {
            IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache;
            int flid             = GetCustomFieldFlid(caller, mdc, obj);

            if (flid == 0)
            {
                return(null);
            }
            Slice slice = null;
            var   type  = (CellarPropertyType)mdc.GetFieldType(flid);

            switch (type)
            {
            case CellarPropertyType.String:
            case CellarPropertyType.MultiUnicode:
            case CellarPropertyType.MultiString:
                int ws = mdc.GetFieldWs(flid);
                switch (ws)
                {
                case 0:                                 // a desperate default.
                case WritingSystemServices.kwsAnal:
                    slice = new StringSlice(obj, flid, cache.DefaultAnalWs);
                    break;

                case WritingSystemServices.kwsVern:
                    slice = new StringSlice(obj, flid, cache.DefaultVernWs);
                    break;

                case WritingSystemServices.kwsAnals:
                case WritingSystemServices.kwsVerns:
                case WritingSystemServices.kwsAnalVerns:
                case WritingSystemServices.kwsVernAnals:
                    slice = new MultiStringSlice(obj, flid, ws, 0, false, true, true);
                    break;

                default:
                    throw new Exception("unhandled ws code in MakeAutoCustomSlice");
                }
                break;

            case CellarPropertyType.Integer:
                slice = new IntegerSlice(cache, obj, flid);
                break;

            case CellarPropertyType.GenDate:
                slice = new GenDateSlice(cache, obj, flid);
                break;

            case CellarPropertyType.OwningAtomic:
                int dstClsid = mdc.GetDstClsId(flid);
                if (dstClsid == StTextTags.kClassId)
                {
                    slice = new StTextSlice(obj, flid, cache.DefaultAnalWs);
                }
                break;

            case CellarPropertyType.ReferenceAtomic:
                slice = new AtomicReferenceSlice(cache, obj, flid);
                break;

            case CellarPropertyType.ReferenceCollection:
            case CellarPropertyType.ReferenceSequence:
                slice = new ReferenceVectorSlice(cache, obj, flid);
                break;
            }
            if (slice == null)
            {
                throw new Exception("unhandled field type in MakeAutoCustomSlice");
            }
            slice.Label = mdc.GetFieldLabel(flid);
            return(slice);
        }