Exemple #1
0
		public static Slice Create(FdoCache cache, string editor, int flid, XmlNode node, ICmObject obj,
			StringTable stringTbl, IPersistenceProvider persistenceProvider, Mediator mediator, XmlNode caller, ObjSeqHashMap reuseMap)
		{
			Slice slice;
			switch(editor)
			{
				case "multistring": // first, these are the most common slices.
					{
						if (flid == 0)
							throw new ApplicationException("field attribute required for multistring " + node.OuterXml);
						string wsSpec = XmlUtils.GetOptionalAttributeValue(node, "ws");
						int wsMagic = WritingSystemServices.GetMagicWsIdFromName(wsSpec);
						if (wsMagic == 0)
							throw new ApplicationException(
								"ws must be 'all vernacular', 'all analysis', 'analysis vernacular', or 'vernacular analysis'"
								+ " it said '" + wsSpec + "'.");


						bool forceIncludeEnglish = XmlUtils.GetOptionalBooleanAttributeValue(node, "forceIncludeEnglish", false);
						bool spellCheck = XmlUtils.GetOptionalBooleanAttributeValue(node, "spell", true);
						// Either the part or the caller can specify that it isn't editable.
						// (The part may 'know' this, e.g. because it's a virtual attr not capable of editing;
						// more commonly the caller knows there isn't enough context for safe editing.
						bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true)
							&& XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
						string optionalWsSpec = XmlUtils.GetOptionalAttributeValue(node, "optionalWs");
						int wsMagicOptional = WritingSystemServices.GetMagicWsIdFromName(optionalWsSpec);
						MultiStringSlice msSlice = reuseMap.GetSliceToReuse("MultiStringSlice") as MultiStringSlice;
						if (msSlice == null)
							slice = new MultiStringSlice(obj, flid, wsMagic, wsMagicOptional, forceIncludeEnglish, editable, spellCheck);
						else
						{
							slice = msSlice;
							msSlice.Reuse(obj, flid, wsMagic, wsMagicOptional, forceIncludeEnglish, editable, spellCheck);
						}
						break;
					}
				case "defaultvectorreference": // second most common.
					{
						var rvSlice = reuseMap.GetSliceToReuse("ReferenceVectorSlice") as ReferenceVectorSlice;
						if (rvSlice == null)
							slice = new ReferenceVectorSlice(cache, obj, flid);
						else
						{
							slice = rvSlice;
							rvSlice.Reuse(obj, flid);
						}
						break;
					}
				case "possvectorreference":
					{
						var prvSlice = reuseMap.GetSliceToReuse("PossibilityReferenceVectorSlice") as PossibilityReferenceVectorSlice;
						if (prvSlice == null)
							slice = new PossibilityReferenceVectorSlice(cache, obj, flid);
						else
						{
							slice = prvSlice;
							prvSlice.Reuse(obj, flid);
						}
						break;
					}
				case "semdomvectorreference":
					{
						var prvSlice = reuseMap.GetSliceToReuse("SemanticDomainReferenceVectorSlice") as SemanticDomainReferenceVectorSlice;
						if (prvSlice == null)
							slice = new SemanticDomainReferenceVectorSlice(cache, obj, flid);
						else
						{
							slice = prvSlice;
							prvSlice.Reuse(obj, flid);
						}
						break;
					}
				case "string":
				{
					if (flid == 0)
						throw new ApplicationException("field attribute required for basic properties " + node.OuterXml);
					int ws = GetWs(mediator, cache, node);
					if (ws != 0)
						slice = new StringSlice(obj, flid, ws);
					else
						slice = new StringSlice(obj, flid);
					var fShowWsLabel = XmlUtils.GetOptionalBooleanAttributeValue(node, "labelws", false);
					if (fShowWsLabel)
						(slice as StringSlice).ShowWsLabel = true;
					int wsEmpty = GetWs(mediator, cache, node, "wsempty");
					if (wsEmpty != 0)
						(slice as StringSlice).DefaultWs = wsEmpty;
					break;
				}
				case "jtview":
				{
					string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
					if (layout == null)
						layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
					// Editable if BOTH the caller (part ref) AND the node itself (the slice) say so...or at least if neither says not.
					bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true)
						&& XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
					slice = new ViewSlice(new XmlView(obj.Hvo, layout, stringTbl, editable));
					break;
				}
				case "summary":
				{
					slice = new SummarySlice();
					break;
				}
				case "enumcombobox":
				{
					slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]);
					break;
				}
				case "referencecombobox":
				{
					slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider);
					break;
				}
				case "typeaheadrefatomic":
				{
					slice = new AtomicRefTypeAheadSlice(obj, flid);
					break;
				}
				case "msareferencecombobox":
				{
					slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider);
					break;
				}
				case "lit": // was "message"
				{
					string message = XmlUtils.GetManditoryAttributeValue(node, "message");
					if (stringTbl != null)
					{
						string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", "");
						if (sTranslate.Trim().ToLower() != "do not translate")
							message = stringTbl.LocalizeLiteralValue(message);
					}
					slice = new MessageSlice(message);
					break;
				}
				case "picture":
				{
					slice = new PictureSlice((ICmPicture)obj);
					break;
				}
				case "image":
				{
					try
					{
						slice = new ImageSlice(FwDirectoryFinder.CodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1"));
					}
					catch (Exception error)
					{
						slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed,
							error.Message));
					}
					break;
				}
				case "checkbox":
				{
					slice = new CheckboxSlice(cache, obj, flid, node);
					break;
				}
				case "checkboxwithrefresh":
				{
					slice = new CheckboxRefreshSlice(cache, obj, flid, node);
					break;
				}
				case "time":
				{
					slice = new DateSlice(cache, obj, flid);
					break;
				}
				case "integer": // produced in the auto-generated parts from the conceptual model
				case "int": // was "integer"
				{
					slice = new IntegerSlice(cache, obj, flid);
					break;
				}

				case "gendate":
				{
					slice = new GenDateSlice(cache, obj, flid);
					break;
				}

				case "morphtypeatomicreference":
				{
					slice = new MorphTypeAtomicReferenceSlice(cache, obj, flid);
					break;
				}

				case "atomicreferencepos":
				{
					slice = new AtomicReferencePOSSlice(cache, obj, flid, persistenceProvider, mediator);
					break;
				}
				case "possatomicreference":
				{
					slice = new PossibilityAtomicReferenceSlice(cache, obj, flid);
					break;
				}
				case "atomicreferenceposdisabled":
				{
					slice = new AutomicReferencePOSDisabledSlice(cache, obj, flid, persistenceProvider, mediator);
					break;
				}

				case "defaultatomicreference":
				{
					slice = new AtomicReferenceSlice(cache, obj, flid);
					break;
				}
				case "defaultatomicreferencedisabled":
				{
					slice = new AtomicReferenceDisabledSlice(cache, obj, flid);
					break;
				}

				case "derivmsareference":
				{
					slice = new DerivMSAReferenceSlice(cache, obj, flid);
					break;
				}

				case "inflmsareference":
				{
					slice = new InflMSAReferenceSlice(cache, obj, flid);
					break;
				}

				case "phoneenvreference":
				{
					slice = new PhoneEnvReferenceSlice(cache, obj, flid);
					break;
				}

				case "sttext":
				{
					slice = new StTextSlice(obj, flid, GetWs(mediator, cache, node));
					break;
				}

				case "custom":
				{
					slice = (Slice)DynamicLoader.CreateObject(node);
					break;
				}

				case "customwithparams":
				{
					slice = (Slice)DynamicLoader.CreateObject(node,
						new object[]{cache, editor, flid, node, obj, stringTbl,
										persistenceProvider, GetWs(mediator, cache, node)});
					break;
				}
				case "ghostvector":
				{
					slice = new GhostReferenceVectorSlice(cache, obj, node);
					break;
				}

				case "command":
				{
					slice = new CommandSlice(node["deParams"]);
					break;
				}

				case null:	//grouping nodes do not necessarily have any editor
				{
					slice = new Slice();
					break;
				}
				case "message":
					// case "integer": // added back in to behave as "int" above
					throw new Exception("use of obsolete editor type (message->lit, integer->int)");
				case "autocustom":
					slice = MakeAutoCustomSlice(cache, obj, caller);
					if (slice == null)
						return null;
					break;
				case "defaultvectorreferencedisabled": // second most common.
					{
						ReferenceVectorDisabledSlice rvSlice = reuseMap.GetSliceToReuse("ReferenceVectorDisabledSlice") as ReferenceVectorDisabledSlice;
						if (rvSlice == null)
							slice = new ReferenceVectorDisabledSlice(cache, obj, flid);
						else
						{
							slice = rvSlice;
							rvSlice.Reuse(obj, flid);
						}
						break;
					}
				default:
				{
					//Since the editor has not been implemented yet,
					//is there a bitmap file that we can show for this editor?
					//Such bitmaps belong in the distFiles xde directory
					string fwCodeDir = FwDirectoryFinder.CodeDirectory;
					string editorBitmapRelativePath = "xde/" + editor + ".bmp";
					if(File.Exists(Path.Combine(fwCodeDir, editorBitmapRelativePath)))
						slice = new ImageSlice(fwCodeDir, editorBitmapRelativePath);
					else
						slice = new MessageSlice(String.Format(DetailControlsStrings.ksBadEditorType, editor));
					break;
				}
			}
			slice.AccessibleName = editor;

			return slice;
		}
Exemple #2
0
		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;
		}
Exemple #3
0
        /// <summary></summary>
        public static Slice Create(FdoCache cache, string editor, int flid, XmlNode node, ICmObject obj,
                                   StringTable stringTbl, IPersistenceProvider persistenceProvider, Mediator mediator, XmlNode caller, ObjSeqHashMap reuseMap)
        {
            Slice slice;

            switch (editor)
            {
            case "multistring":                     // first, these are the most common slices.
            {
                if (flid == 0)
                {
                    throw new ApplicationException("field attribute required for multistring " + node.OuterXml);
                }
                string wsSpec  = XmlUtils.GetOptionalAttributeValue(node, "ws");
                int    wsMagic = WritingSystemServices.GetMagicWsIdFromName(wsSpec);
                if (wsMagic == 0)
                {
                    throw new ApplicationException(
                              "ws must be 'all vernacular', 'all analysis', 'analysis vernacular', or 'vernacular analysis'"
                              + " it said '" + wsSpec + "'.");
                }


                bool forceIncludeEnglish = XmlUtils.GetOptionalBooleanAttributeValue(node, "forceIncludeEnglish", false);
                bool spellCheck          = XmlUtils.GetOptionalBooleanAttributeValue(node, "spell", true);
                // Either the part or the caller can specify that it isn't editable.
                // (The part may 'know' this, e.g. because it's a virtual attr not capable of editing;
                // more commonly the caller knows there isn't enough context for safe editing.
                bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true) &&
                                XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
                string           optionalWsSpec  = XmlUtils.GetOptionalAttributeValue(node, "optionalWs");
                int              wsMagicOptional = WritingSystemServices.GetMagicWsIdFromName(optionalWsSpec);
                MultiStringSlice msSlice         = reuseMap.GetSliceToReuse("MultiStringSlice") as MultiStringSlice;
                if (msSlice == null)
                {
                    slice = new MultiStringSlice(obj, flid, wsMagic, wsMagicOptional, forceIncludeEnglish, editable, spellCheck);
                }
                else
                {
                    slice = msSlice;
                    msSlice.Reuse(obj, flid, wsMagic, wsMagicOptional, forceIncludeEnglish, editable, spellCheck);
                }
                break;
            }

            case "defaultvectorreference":                     // second most common.
            {
                var rvSlice = reuseMap.GetSliceToReuse("ReferenceVectorSlice") as ReferenceVectorSlice;
                if (rvSlice == null)
                {
                    slice = new ReferenceVectorSlice(cache, obj, flid);
                }
                else
                {
                    slice = rvSlice;
                    rvSlice.Reuse(obj, flid);
                }
                break;
            }

            case "possvectorreference":
            {
                var prvSlice = reuseMap.GetSliceToReuse("PossibilityReferenceVectorSlice") as PossibilityReferenceVectorSlice;
                if (prvSlice == null)
                {
                    slice = new PossibilityReferenceVectorSlice(cache, obj, flid);
                }
                else
                {
                    slice = prvSlice;
                    prvSlice.Reuse(obj, flid);
                }
                break;
            }

            case "semdomvectorreference":
            {
                var prvSlice = reuseMap.GetSliceToReuse("SemanticDomainReferenceVectorSlice") as SemanticDomainReferenceVectorSlice;
                if (prvSlice == null)
                {
                    slice = new SemanticDomainReferenceVectorSlice(cache, obj, flid);
                }
                else
                {
                    slice = prvSlice;
                    prvSlice.Reuse(obj, flid);
                }
                break;
            }

            case "string":
            {
                if (flid == 0)
                {
                    throw new ApplicationException("field attribute required for basic properties " + node.OuterXml);
                }
                int ws = GetWs(mediator, cache, node);
                if (ws != 0)
                {
                    slice = new StringSlice(obj, flid, ws);
                }
                else
                {
                    slice = new StringSlice(obj, flid);
                }
                var fShowWsLabel = XmlUtils.GetOptionalBooleanAttributeValue(node, "labelws", false);
                if (fShowWsLabel)
                {
                    (slice as StringSlice).ShowWsLabel = true;
                }
                int wsEmpty = GetWs(mediator, cache, node, "wsempty");
                if (wsEmpty != 0)
                {
                    (slice as StringSlice).DefaultWs = wsEmpty;
                }
                break;
            }

            case "jtview":
            {
                string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
                if (layout == null)
                {
                    layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
                }
                // Editable if BOTH the caller (part ref) AND the node itself (the slice) say so...or at least if neither says not.
                bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true) &&
                                XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
                slice = new ViewSlice(new XmlView(obj.Hvo, layout, stringTbl, editable));
                break;
            }

            case "summary":
            {
                slice = new SummarySlice();
                break;
            }

            case "enumcombobox":
            {
                slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]);
                break;
            }

            case "referencecombobox":
            {
                slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider);
                break;
            }

            case "typeaheadrefatomic":
            {
                slice = new AtomicRefTypeAheadSlice(obj, flid);
                break;
            }

            case "msareferencecombobox":
            {
                slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider);
                break;
            }

            case "lit":                     // was "message"
            {
                string message = XmlUtils.GetManditoryAttributeValue(node, "message");
                if (stringTbl != null)
                {
                    string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", "");
                    if (sTranslate.Trim().ToLower() != "do not translate")
                    {
                        message = stringTbl.LocalizeLiteralValue(message);
                    }
                }
                slice = new MessageSlice(message);
                break;
            }

            case "picture":
            {
                slice = new PictureSlice((ICmPicture)obj);
                break;
            }

            case "image":
            {
                try
                {
                    slice = new ImageSlice(DirectoryFinder.FWCodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1"));
                }
                catch (Exception error)
                {
                    slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed,
                                                           error.Message));
                }
                break;
            }

            case "checkbox":
            {
                slice = new CheckboxSlice(cache, obj, flid, node);
                break;
            }

            case "checkboxwithrefresh":
            {
                slice = new CheckboxRefreshSlice(cache, obj, flid, node);
                break;
            }

            case "time":
            {
                slice = new DateSlice(cache, obj, flid);
                break;
            }

            case "integer":                 // produced in the auto-generated parts from the conceptual model
            case "int":                     // was "integer"
            {
                slice = new IntegerSlice(cache, obj, flid);
                break;
            }

            case "gendate":
            {
                slice = new GenDateSlice(cache, obj, flid);
                break;
            }

            case "morphtypeatomicreference":
            {
                slice = new MorphTypeAtomicReferenceSlice(cache, obj, flid);
                break;
            }

            case "atomicreferencepos":
            {
                slice = new AtomicReferencePOSSlice(cache, obj, flid, persistenceProvider, mediator);
                break;
            }

            case "possatomicreference":
            {
                slice = new PossibilityAtomicReferenceSlice(cache, obj, flid);
                break;
            }

            case "atomicreferenceposdisabled":
            {
                slice = new AutomicReferencePOSDisabledSlice(cache, obj, flid, persistenceProvider, mediator);
                break;
            }

            case "defaultatomicreference":
            {
                slice = new AtomicReferenceSlice(cache, obj, flid);
                break;
            }

            case "defaultatomicreferencedisabled":
            {
                slice = new AtomicReferenceDisabledSlice(cache, obj, flid);
                break;
            }

            case "derivmsareference":
            {
                slice = new DerivMSAReferenceSlice(cache, obj, flid);
                break;
            }

            case "inflmsareference":
            {
                slice = new InflMSAReferenceSlice(cache, obj, flid);
                break;
            }

            case "phoneenvreference":
            {
                slice = new PhoneEnvReferenceSlice(cache, obj, flid);
                break;
            }

            case "sttext":
            {
                slice = new StTextSlice(obj, flid, GetWs(mediator, cache, node));
                break;
            }

            case "custom":
            {
                slice = (Slice)DynamicLoader.CreateObject(node);
                break;
            }

            case "customwithparams":
            {
                slice = (Slice)DynamicLoader.CreateObject(node,
                                                          new object[] { cache, editor, flid, node, obj, stringTbl,
                                                                         persistenceProvider, GetWs(mediator, cache, node) });
                break;
            }

            case "ghostvector":
            {
                slice = new GhostReferenceVectorSlice(cache, obj, node);
                break;
            }

            case "command":
            {
                slice = new CommandSlice(node["deParams"]);
                break;
            }

            case null:                          //grouping nodes do not necessarily have any editor
            {
                slice = new Slice();
                break;
            }

            case "message":
                // case "integer": // added back in to behave as "int" above
                throw new Exception("use of obsolete editor type (message->lit, integer->int)");

            case "autocustom":
                slice = MakeAutoCustomSlice(cache, obj, caller);
                if (slice == null)
                {
                    return(null);
                }
                break;

            case "defaultvectorreferencedisabled":                     // second most common.
            {
                ReferenceVectorDisabledSlice rvSlice = reuseMap.GetSliceToReuse("ReferenceVectorDisabledSlice") as ReferenceVectorDisabledSlice;
                if (rvSlice == null)
                {
                    slice = new ReferenceVectorDisabledSlice(cache, obj, flid);
                }
                else
                {
                    slice = rvSlice;
                    rvSlice.Reuse(obj, flid);
                }
                break;
            }

            default:
            {
                //Since the editor has not been implemented yet,
                //is there a bitmap file that we can show for this editor?
                //Such bitmaps belong in the distFiles xde directory
                string fwCodeDir = DirectoryFinder.FWCodeDirectory;
                string editorBitmapRelativePath = "xde/" + editor + ".bmp";
                if (File.Exists(Path.Combine(fwCodeDir, editorBitmapRelativePath)))
                {
                    slice = new ImageSlice(fwCodeDir, editorBitmapRelativePath);
                }
                else
                {
                    slice = new MessageSlice(String.Format(DetailControlsStrings.ksBadEditorType, editor));
                }
                break;
            }
            }
            slice.AccessibleName = editor;

            return(slice);
        }
Exemple #4
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);
        }
Exemple #5
0
        public static Slice Create(FdoCache cache, string editor, int flid, XmlNode node, ICmObject obj,
                                   StringTable stringTbl, IPersistenceProvider persistenceProvider, Mediator mediator, XmlNode caller)
        {
            Slice slice = null;

            switch (editor)
            {
            case "string":
            {
                if (flid == 0)
                {
                    throw new ApplicationException("field attribute required for basic properties " + node.OuterXml);
                }
                int ws = GetWs(mediator, cache, node);
                if (ws != 0)
                {
                    slice = new StringSlice(obj.Hvo, flid, ws);
                }
                else
                {
                    slice = new StringSlice(obj.Hvo, flid);
                }
                break;
            }

            case "multistring":
            {
                if (flid == 0)
                {
                    throw new ApplicationException("field attribute required for multistring " + node.OuterXml);
                }
                string wsSpec = XmlUtils.GetOptionalAttributeValue(node, "ws");
                int    wsMagic;
                wsMagic = LangProject.GetMagicWsIdFromName(wsSpec);
                if (wsMagic == 0)
                {
                    throw new ApplicationException(
                              "ws must be 'all vernacular', 'all analysis', 'analysis vernacular', or 'vernacular analysis'"
                              + " it said '" + wsSpec + "'.");
                }

                bool forceIncludeEnglish = XmlUtils.GetOptionalBooleanAttributeValue(node, "forceIncludeEnglish", false);
                bool spellCheck          = XmlUtils.GetOptionalBooleanAttributeValue(node, "spell", true);
                bool editable            = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true);
                slice = new MultiStringSlice(obj.Hvo, flid, wsMagic, forceIncludeEnglish, editable, spellCheck);
                break;
            }

            case "jtview":
            {
                string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
                if (layout == null)
                {
                    layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
                }
                // Editable if BOTH the caller (part ref) AND the node itself (the slice) say so...or at least if neither says not.
                bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true) &&
                                XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
                slice = new ViewSlice(new XmlView(obj.Hvo, layout, stringTbl, editable));
                break;
            }

            case "summary":
            {
                slice = new SummarySlice(obj, caller, node, stringTbl);
                break;
            }

            case "enumcombobox":
            {
                slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]);
                break;
            }

            case "referencecombobox":
            {
                slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator);
                break;
            }

            case "typeaheadrefatomic":
            {
                slice = new AtomicRefTypeAheadSlice(obj.Hvo, flid);
                break;
            }

            case "msareferencecombobox":
            {
                slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator);
                break;
            }

            case "lit":                     // was "message"
            {
                string message = XmlUtils.GetManditoryAttributeValue(node, "message");
                if (stringTbl != null)
                {
                    string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", "");
                    if (sTranslate.Trim().ToLower() != "do not translate")
                    {
                        message = stringTbl.LocalizeLiteralValue(message);
                    }
                }
                slice = new MessageSlice(message);
                break;
            }

            case "picture":
            {
                slice = new PictureSlice((FDO.Cellar.CmPicture)obj);
                break;
            }

            case "image":
            {
                try
                {
                    slice = new ImageSlice(DirectoryFinder.FWCodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1"));
                }
                catch (Exception error)
                {
                    slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed,
                                                           error.Message));
                }
                break;
            }

            case "checkbox":
            {
                slice = new CheckboxSlice(cache, obj, flid, node);
                break;
            }

            case "time":
            {
                slice = new DateSlice(cache, obj, flid);
                break;
            }

            case "integer":                 // produced in the auto-generated parts from the conceptual model
            case "int":                     // was "integer"
            {
                slice = new IntegerSlice(cache, obj, flid);
                break;
            }

            case "morphtypeatomicreference":
            {
                slice = new MorphTypeAtomicReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
                break;
            }

            case "atomicreferencepos":
            {
                slice = new AtomicReferencePOSSlice(cache, obj, flid, persistenceProvider, mediator);
                break;
            }

            case "defaultatomicreference":
            {
                slice = new AtomicReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
                break;
            }

            case "derivmsareference":
            {
                slice = new DerivMSAReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
                break;
            }

            case "inflmsareference":
            {
                slice = new InflMSAReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
                break;
            }

            case "defaultvectorreference":
            {
                slice = new ReferenceVectorSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
                break;
            }

            case "phoneenvreference":
            {
                slice = new PhoneEnvReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
                break;
            }

            case "sttext":
            {
                slice = new StTextSlice(obj.Hvo, flid, GetWs(mediator, cache, node));
                break;
            }

            case "custom":
            {
                slice = (Slice)DynamicLoader.CreateObject(node);
                break;
            }

            case "customwithparams":
            {
                slice = (Slice)DynamicLoader.CreateObject(node,
                                                          new object[] { cache, editor, flid, node, obj, stringTbl,
                                                                         persistenceProvider, GetWs(mediator, cache, node) });
                break;
            }

            case "command":
            {
                slice = new CommandSlice(node["deParams"]);
                break;
            }

            case null:                          //grouping nodes do not necessarily have any editor
            {
                slice = new Slice();
                break;
            }

            case "message":
                // case "integer": // added back in to behave as "int" above
                throw new Exception("use of obsolete editor type (message->lit, integer->int)");

            case "autocustom":
                slice = MakeAutoCustomSlice(cache, node, obj, caller);
                if (slice == null)
                {
                    return(null);
                }
                break;

            default:
            {
                //Since the editor has not been implemented yet,
                //is there a bitmap file that we can show for this editor?
                //Such bitmaps belong in the distFiles xde directory
                string fwCodeDir = DirectoryFinder.FWCodeDirectory;
                string editorBitmapRelativePath = @"xde\" + editor + ".bmp";
                if (System.IO.File.Exists(Path.Combine(fwCodeDir, editorBitmapRelativePath)))
                {
                    slice = new ImageSlice(fwCodeDir, editorBitmapRelativePath);
                }
                else
                {
                    slice = new MessageSlice(String.Format(DetailControlsStrings.ksBadEditorType, editor));
                }
                break;
            }
            }
            slice.AccessibleName = editor;

            return(slice);
        }
Exemple #6
0
		public static Slice Create(FdoCache cache, string editor, int flid, XmlNode node, ICmObject obj,
			StringTable stringTbl, IPersistenceProvider persistenceProvider, Mediator mediator, XmlNode caller)
		{
			Slice slice = null;
			switch(editor)
			{
				case "string":
				{
					if (flid == 0)
						throw new ApplicationException("field attribute required for basic properties " + node.OuterXml);
					int ws = GetWs(mediator, cache, node);
					if (ws != 0)
						slice = new StringSlice(obj.Hvo, flid, ws);
					else
						slice = new StringSlice(obj.Hvo, flid);
					break;
				}
				case "multistring":
				{
					if (flid == 0)
						throw new ApplicationException("field attribute required for multistring " + node.OuterXml);
					string wsSpec = XmlUtils.GetOptionalAttributeValue(node, "ws");
					int wsMagic;
					wsMagic = LangProject.GetMagicWsIdFromName(wsSpec);
					if (wsMagic == 0)
						throw new ApplicationException(
							"ws must be 'all vernacular', 'all analysis', 'analysis vernacular', or 'vernacular analysis'"
							+ " it said '" + wsSpec + "'.");

					bool forceIncludeEnglish = XmlUtils.GetOptionalBooleanAttributeValue(node, "forceIncludeEnglish", false);
					bool spellCheck = XmlUtils.GetOptionalBooleanAttributeValue(node, "spell", true);
					bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true);
					slice = new MultiStringSlice(obj.Hvo, flid, wsMagic, forceIncludeEnglish, editable, spellCheck);
					break;
				}
				case "jtview":
				{
					string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
					if (layout == null)
						layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
					// Editable if BOTH the caller (part ref) AND the node itself (the slice) say so...or at least if neither says not.
					bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true)
						&& XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
					slice = new ViewSlice(new XmlView(obj.Hvo, layout, stringTbl, editable));
					break;
				}
				case "summary":
				{
					slice = new SummarySlice(obj, caller, node, stringTbl);
					break;
				}
				case "enumcombobox":
				{
					slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]);
					break;
				}
				case "referencecombobox":
				{
					slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator);
					break;
				}
				case "typeaheadrefatomic":
				{
					slice = new AtomicRefTypeAheadSlice(obj.Hvo, flid);
					break;
				}
				case "msareferencecombobox":
				{
					slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator);
					break;
				}
				case "lit": // was "message"
				{
					string message = XmlUtils.GetManditoryAttributeValue(node, "message");
					if (stringTbl != null)
					{
						string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", "");
						if (sTranslate.Trim().ToLower() != "do not translate")
							message = stringTbl.LocalizeLiteralValue(message);
					}
					slice = new MessageSlice(message);
					break;
				}
				case "picture":
				{
					slice = new PictureSlice((FDO.Cellar.CmPicture) obj);
					break;
				}
				case "image":
				{
					try
					{
						slice = new ImageSlice(DirectoryFinder.FWCodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1"));
					}
					catch (Exception error)
					{
						slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed,
							error.Message));
					}
					break;
				}
				case "checkbox":
				{
					slice = new CheckboxSlice(cache, obj, flid, node);
					break;
				}
				case "time":
				{
					slice = new DateSlice(cache, obj, flid);
					break;
				}
				case "integer": // produced in the auto-generated parts from the conceptual model
				case "int": // was "integer"
				{
					slice = new IntegerSlice(cache, obj, flid);
					break;
				}

				case "morphtypeatomicreference":
				{
					slice = new MorphTypeAtomicReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
					break;
				}

				case "atomicreferencepos":
				{
					slice = new AtomicReferencePOSSlice(cache, obj, flid, persistenceProvider, mediator);
					break;
				}

				case "defaultatomicreference":
				{
					slice = new AtomicReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
					break;
				}

				case "derivmsareference":
				{
					slice = new DerivMSAReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
					break;
				}

				case "inflmsareference":
				{
					slice = new InflMSAReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
					break;
				}

				case "defaultvectorreference":
				{
					slice = new ReferenceVectorSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
					break;
				}

				case "phoneenvreference":
				{
					slice = new PhoneEnvReferenceSlice(cache, obj, flid, node, persistenceProvider, mediator, stringTbl);
					break;
				}

				case "sttext":
				{
					slice = new StTextSlice(obj.Hvo, flid, GetWs(mediator, cache, node));
					break;
				}

				case "custom":
				{
					slice = (Slice)DynamicLoader.CreateObject(node);
					break;
				}

				case "customwithparams":
				{
					slice = (Slice)DynamicLoader.CreateObject(node,
						new object[]{cache, editor, flid, node, obj, stringTbl,
										persistenceProvider, GetWs(mediator, cache, node)});
					break;
				}

				case "command":
				{
					slice = new CommandSlice(node["deParams"]);
					break;
				}

				case null:	//grouping nodes do not necessarily have any editor
				{
					slice = new Slice();
					break;
				}
				case "message":
					// case "integer": // added back in to behave as "int" above
					throw new Exception("use of obsolete editor type (message->lit, integer->int)");
				case "autocustom":
					slice = MakeAutoCustomSlice(cache, node, obj, caller);
					if (slice == null)
						return null;
					break;
				default:
				{
					//Since the editor has not been implemented yet,
					//is there a bitmap file that we can show for this editor?
					//Such bitmaps belong in the distFiles xde directory
					string fwCodeDir = DirectoryFinder.FWCodeDirectory;
					string editorBitmapRelativePath = @"xde\" + editor + ".bmp";
					if(System.IO.File.Exists(Path.Combine(fwCodeDir, editorBitmapRelativePath)))
						slice = new ImageSlice(fwCodeDir, editorBitmapRelativePath);
					else
						slice = new MessageSlice(String.Format(DetailControlsStrings.ksBadEditorType, editor));
					break;
				}
			}
			slice.AccessibleName = editor;

			return slice;
		}