Summary description for ViewPropertyItem.
Inheritance: ViewPropertySlice
Example #1
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>
        /// <param name="cache"></param>
        /// <param name="node"></param>
        /// <param name="obj"></param>
        /// <param name="caller"></param>
        /// <returns></returns>
        static Slice MakeAutoCustomSlice(FdoCache cache, XmlNode node, ICmObject obj, XmlNode caller)
        {
            IFwMetaDataCache mdc;

            mdc = cache.MetaDataCacheAccessor;
            int flid = GetCustomFieldFlid(caller, mdc, obj);

            if (flid == 0)
            {
                return(null);
            }
            int    ws    = mdc.GetFieldWs((uint)flid);
            string label = mdc.GetFieldLabel((uint)flid);

            Slice slice = null;

            switch (ws)
            {
            case LangProject.kwsAnal:
                slice = new StringSlice(obj.Hvo, flid, cache.DefaultAnalWs);
                break;

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

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

            default:
                throw new Exception("unhandled ws code in MakeAutoCustomSlice");
            }
            slice.Label = label;
            return(slice);
        }
Example #2
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;
		}
Example #3
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;
		}
Example #4
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);
        }
Example #5
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);
        }
Example #6
0
 /// <summary>
 /// This needs to be a static method because typically the ghost slice has been disposed
 /// by the time it is called.
 ///
 /// Note that DataTree.AddAtomicNode either displays a layout of the object, or
 /// displays the ghost slice. If it displays a layout of the object, it adds
 /// to its input path first itself (the "obj" element), then the HVO of the object,
 /// then creates slices for the object. For ghost slice, it simply adds itself.
 /// Therefore, a slice created as part of a layout replacing a ghost slice will
 /// have a key matching the ghost slice's key, and followed by the ID of the new object.
 /// Next, anything in this layout will have the template used to display the object,
 /// and the particular part ref that invoked the part, then (for an interesting target)
 /// a slice node with editor 'string' or 'multistring' as appropriate.
 /// AddSeqNode is similar, except that it may display layouts of multiple objects.
 /// </summary>
 static void RestoreSelection(int ich, DataTree datatree, object[] key, int hvoNewObj, int flidStringProp, int ws)
 {
     // To be written.
     foreach (Slice slice in datatree.Slices)
     {
         if (slice.Key.Length < key.Length + 2)
         {
             continue;
         }
         if (!StartsWith(slice.Key, key))
         {
             continue;
         }
         object nextKeyItem = slice.Key[key.Length];                     // should be hvoNewObj
         if (!(nextKeyItem is int))
         {
             continue;
         }
         if ((int)nextKeyItem != hvoNewObj)
         {
             continue;
         }
         XmlNode lastKeyNode = slice.Key[slice.Key.Length - 1] as XmlNode;
         if (lastKeyNode == null)
         {
             continue;
         }
         if (lastKeyNode.Name != "slice")
         {
             continue;
         }
         if (slice is StringSlice)
         {
             StringSlice ss = slice as StringSlice;
             if (ss.FieldId != flidStringProp)
             {
                 continue;
             }
             if (ss.WritingSystemId != ws)
             {
                 continue;
             }
             // For SelectAt to work, the rootbox must be constructed and visible.
             GetSliceReadyToFocus(ss);
             ss.SelectAt(ich);
             ss.Control.Focus();
             break;
         }
         else if (slice is MultiStringSlice)
         {
             MultiStringSlice mss = slice as MultiStringSlice;
             if (mss.FieldId != flidStringProp)
             {
                 continue;
             }
             // Enhance JohnT: add functions to MultiStringSlice and LabeledMultiStringControl
             // so we can check that it's displaying the right writing systems.
             // For SelectAt to work, the rootbox must be constructed and visible.
             GetSliceReadyToFocus(mss);
             mss.SelectAt(ws, ich);
             mss.Control.Focus();
             break;
         }
         else if (slice is StTextSlice)
         {
             var stslice = (StTextSlice)slice;
             GetSliceReadyToFocus(stslice);
             stslice.SelectAt(ich);
             slice.Control.Focus();
             break;
         }
     }
 }
Example #7
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);
        }
Example #8
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;
		}
Example #9
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>
		/// <param name="cache"></param>
		/// <param name="node"></param>
		/// <param name="obj"></param>
		/// <param name="caller"></param>
		/// <returns></returns>
		static Slice MakeAutoCustomSlice(FdoCache cache, XmlNode node, ICmObject obj, XmlNode caller)
		{
			IFwMetaDataCache mdc;
			mdc = cache.MetaDataCacheAccessor;
			int flid = GetCustomFieldFlid(caller, mdc, obj);
			if (flid == 0)
				return null;
			int ws = mdc.GetFieldWs((uint)flid);
			string label = mdc.GetFieldLabel((uint)flid);

			Slice slice = null;
			switch(ws)
			{
				case LangProject.kwsAnal:
					slice = new StringSlice(obj.Hvo, flid, cache.DefaultAnalWs);
					break;
				case LangProject.kwsVern:
					slice = new StringSlice(obj.Hvo, flid, cache.DefaultVernWs);
					break;
				case LangProject.kwsAnals:
				case LangProject.kwsVerns:
				case LangProject.kwsAnalVerns:
				case LangProject.kwsVernAnals:
					slice = new MultiStringSlice(obj.Hvo, flid, ws, false, true, true);
					break;
				default:
					throw new Exception("unhandled ws code in MakeAutoCustomSlice");
			}
			slice.Label = label;
			return slice;
		}