Example #1
0
		public void SetDlgInfo(FdoCache cache, Mediator mediator, ICmObject owner)
		{
			CheckDisposed();

			m_cache = cache;
			m_owner = owner;

			m_helpTopic = "khtpDataNotebook-InsertRecordDlg";

			m_helpTopicProvider = mediator.HelpTopicProvider;
			if (m_helpTopicProvider != null) // Will be null when running tests
			{
				m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
				m_helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic));
				m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			}

			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			m_titleTextBox.StyleSheet = stylesheet;
			m_titleTextBox.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_titleTextBox.WritingSystemCode = m_cache.DefaultAnalWs;
			AdjustControlAndDialogHeight(m_titleTextBox, m_titleTextBox.PreferredHeight);

			m_typeCombo.StyleSheet = stylesheet;
			m_typeCombo.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_typeCombo.WritingSystemCode = m_cache.DefaultAnalWs;
			AdjustControlAndDialogHeight(m_typeCombo, m_typeCombo.PreferredHeight);

			ICmPossibilityList recTypes = m_cache.LanguageProject.ResearchNotebookOA.RecTypesOA;
			m_typePopupTreeManager = new PossibilityListPopupTreeManager(m_typeCombo, m_cache, mediator,
				recTypes, cache.DefaultAnalWs, false, this);
			m_typePopupTreeManager.LoadPopupTree(m_cache.ServiceLocator.GetObject(RnResearchNbkTags.kguidRecObservation).Hvo);
			// Ensure that we start out focused in the Title text box.  See FWR-2731.
			m_titleTextBox.Select();
		}
		public void Init(Mediator mediator, XmlNode configurationNode, ICmObject sourceObject)
		{
			CheckDisposed();

			m_cache = sourceObject.Cache;

			// Find the sense we want examples for, which depends on the kind of source object.
			if (sourceObject is ILexExampleSentence)
			{
				m_les = sourceObject as ILexExampleSentence;
				m_owningSense = (ILexSense)m_les.Owner;
			}
			else if (sourceObject is ILexSense)
			{
				m_owningSense = sourceObject as ILexSense;
			}
			else
			{
				throw new ArgumentException("Invalid object type for sourceObject.");
			}

			m_mediator = mediator;
			m_configurationNode = configurationNode;

			helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			helpProvider.SetShowHelp(this, true);
			if (m_mediator.HelpTopicProvider != null)
			{
				helpProvider.HelpNamespace = m_mediator.HelpTopicProvider.HelpFile;
				helpProvider.SetHelpKeyword(this, m_mediator.HelpTopicProvider.GetHelpString(m_helpTopic));
				btnHelp.Enabled = true;
			}

			AddConfigurableControls();
		}
Example #3
0
		public void Initialize(ICmObject rootObj, int rootFlid, FdoCache cache, string displayNameProperty,
			XCore.Mediator mediator, string displayWs)
		{
			CheckDisposed();
			m_displayWs = displayWs;
			base.Initialize(rootObj, rootFlid, cache, displayNameProperty, mediator);
		}
Example #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Insert a new check result annotation at its correct position in the list.
		/// </summary>
		/// <param name="startRef">beginning reference note refers to</param>
		/// <param name="endRef">ending reference note refers to</param>
		/// <param name="beginObject">id of beginning object note refers to</param>
		/// <param name="endObject">id of ending object note refers to</param>
		/// <param name="checkId">The check id.</param>
		/// <param name="bldrQuote">Para builder to use for the cited text paragraph</param>
		/// <param name="bldrDiscussion">Para builder to use to build the Discussion
		/// paragraph</param>
		/// <returns>note inserted into annotation list</returns>
		/// ------------------------------------------------------------------------------------
		public IScrScriptureNote InsertErrorAnnotation(BCVRef startRef, BCVRef endRef,
			ICmObject beginObject, ICmObject endObject, Guid checkId,
			StTxtParaBldr bldrQuote, StTxtParaBldr bldrDiscussion)
		{
			return InsertNote(startRef, endRef, beginObject, endObject, checkId, -1,
				0, 0, bldrQuote, bldrDiscussion, null, null, GetInsertIndexForRef(startRef));
		}
Example #5
0
		/// <summary>
		/// Construct one, using the "part ref" element (caller) that
		/// invoked the "slice" node that specified this editor.
		/// </summary>
		/// <param name="caller"></param>
		/// <param name="node"></param>
		public SummarySlice(ICmObject obj, XmlNode caller, XmlNode node, StringTable stringTbl)
			: base()
		{
			string paramType = XmlUtils.GetOptionalAttributeValue(node.ParentNode, "paramType");
			if (paramType == "LiteralString")
			{
				// Instead of the parameter being a layout name, it is literal text which will be
				// the whole contents of the slice, with standard properties.
				string text = XmlUtils.GetManditoryAttributeValue(caller, "label");
				if (stringTbl != null)
					text = stringTbl.LocalizeAttributeValue(text);
				m_view = new LiteralLabelView(text, this);
				m_fLiteralString = true;
			}
			else
			{
				string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
				if (layout == null)
					layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
				m_view = new SummaryXmlView(obj.Hvo, layout, stringTbl, this);
			}
			UserControl mainControl = new UserControl();
			m_view.Dock = DockStyle.Left;
			m_view.LayoutSizeChanged += new EventHandler(m_view_LayoutSizeChanged);
			mainControl.Height = m_view.Height;
			Control = mainControl;

			m_commandControl = new SummaryCommandControl(this);
			m_commandControl.Dock = DockStyle.Fill;
			m_commandControl.Visible = XmlUtils.GetOptionalBooleanAttributeValue(caller, "commandVisible", false);
			mainControl.Controls.Add(m_commandControl);
			mainControl.Dock = DockStyle.Fill;
			mainControl.Controls.Add(m_view);
		}
Example #6
0
		public void RunMacro(ICmObject target, int targetField, int wsId, int startOffset, int length)
		{
			var example = target as ILexExampleSentence ?? target.OwnerOfClass<ILexExampleSentence>();
			var sense = example.OwnerOfClass<ILexSense>();
			var entry = sense.Entry;
			if (!(entry.LexemeFormOA is IMoStemAllomorph))
			{
				MessageBox.Show("This macro only works on stems");
				return;
			}
			var newEntry = entry.Services.GetInstance<ILexEntryFactory>().Create();
			var newSense = entry.Services.GetInstance<ILexSenseFactory>().Create();
			newEntry.SensesOS.Add(newSense);
			newSense.ExamplesOS.Add(example); // moves the chosen example
			// Would be nice to use CopyObject, but currently not public
			newEntry.LexemeFormOA = entry.Services.GetInstance<IMoStemAllomorphFactory>().Create();
			foreach (var ws in entry.LexemeFormOA.Form.AvailableWritingSystemIds)
				newEntry.LexemeFormOA.Form.set_String(ws, entry.LexemeFormOA.Form.get_String(ws));
			foreach (var ws in sense.Gloss.AvailableWritingSystemIds)
				newSense.Gloss.set_String(ws, sense.Gloss.get_String(ws));
			foreach (var ws in sense.Definition.AvailableWritingSystemIds)
				newSense.Definition.set_String(ws, sense.Gloss.get_String(ws));
			// Enhance JohnT: maybe there is more stuff we want to copy?

			//Now make it a subentry
			var ler = entry.Services.GetInstance<ILexEntryRefFactory>().Create();
			newEntry.EntryRefsOS.Add(ler);
			ler.RefType = LexEntryRefTags.krtComplexForm; // must be a complex form to be a subentry
			ler.ComponentLexemesRS.Add(entry);
			ler.PrimaryLexemesRS.Add(entry);
		}
		/// <summary>
		/// Validate the object, before it goes into the collection,
		/// as it may not be in the DB yet.
		/// </summary>
		/// <param name="obj">Object to validate.</param>
		/// <returns>The same object as was being validated, but with a good ID.</returns>
		protected ICmObject ValidateObject(ICmObject obj)
		{
			Debug.Assert(m_fdoCache != null);
			if (obj.Hvo == (int)CmObject.SpecialHVOValues.kHvoOwnerPending)
				(obj as CmObject).InitNew(m_fdoCache);
			return obj;
		}
Example #8
0
		public GhostLexRefLauncher(ICmObject obj, XmlNode configNode)
		{
			m_obj = obj;
			m_configurationNode = configNode;
			// Makes the rest of the control look like content, though empty.
			BackColor = System.Drawing.SystemColors.Window;
		}
Example #9
0
		/// <summary>
		///  Construct one. For the index, pass -1 for a collection and -2 for atomic.
		/// </summary>
		public AddObjectEventArgs(ICmObject newby, int flid, int index)
		{
			if (newby == null) throw new ArgumentNullException("newby");
			ObjectAdded = newby;
			Flid = flid;
			m_index = index;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="cache">FDO cache.</param>
		/// <param name="obj">CmObject that is being displayed.</param>
		/// <param name="flid">The field identifier for the attribute we are displaying.</param>
		/// <param name="persistenceProvider">The persistence provider.</param>
		/// ------------------------------------------------------------------------------------
		public MSAReferenceComboBoxSlice(FdoCache cache, ICmObject obj, int flid,
			IPersistenceProvider persistenceProvider)
			: base(new UserControl(), cache, obj, flid)
		{
			IWritingSystem defAnalWs = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem;
			m_persistProvider = persistenceProvider;
			m_tree = new TreeCombo();
			m_tree.WritingSystemFactory = cache.WritingSystemFactory;
			m_tree.Font = new System.Drawing.Font(defAnalWs.DefaultFontName, 10);
			if (!Application.RenderWithVisualStyles)
				m_tree.HasBorder = false;

			m_tree.WritingSystemCode = defAnalWs.Handle;

			// We embed the tree combo in a layer of UserControl, so it can have a fixed width
			// while the parent window control is, as usual, docked 'fill' to work with the splitter.
			m_tree.Dock = DockStyle.Left;
			m_tree.Width = 240;
			m_tree.DropDown += m_tree_DropDown;

			Control.Controls.Add(m_tree);
			m_tree.SizeChanged += m_tree_SizeChanged;

			if (m_cache != null)
				m_cache.DomainDataByFlid.AddNotification(this);
			m_treeBaseWidth = m_tree.Width;

			// m_tree has sensible PreferredHeight once the text is set, UserControl does not.
			//we need to set the Height after m_tree.Text has a value set to it.
			Control.Height = m_tree.PreferredHeight;
		}
		public void Init(Mediator mediator, XmlNode configurationNode, ICmObject sourceObject)
		{
			CheckDisposed();

			m_cache = sourceObject.Cache;

			// Find the sense owning our LexExampleSentence
			if (sourceObject is LexExampleSentence)
			{
				m_les = sourceObject as LexExampleSentence;
				m_owningSense = LexSense.CreateFromDBObject(m_cache, m_les.OwnerHVO);
			}
			else if (sourceObject is LexSense)
			{
				m_owningSense = sourceObject as ILexSense;
			}
			else
			{
				throw new ArgumentException("Invalid object type for sourceObject.");
			}

			m_mediator = mediator;
			m_configurationNode = configurationNode;
			AddConfigurableControls();

			m_virtFlidReference = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "CmBaseAnnotation", "Reference");
		}
Example #12
0
		public void Initialize(ICmObject rootObj, int rootFlid, string rootFieldName, FdoCache cache, string displayNameProperty,
			Mediator mediator, string displayWs)
		{
			CheckDisposed();
			m_displayWs = displayWs;
			Initialize(rootObj, rootFlid, rootFieldName, cache, displayNameProperty, mediator);
		}
Example #13
0
 protected BsonDocument GetCustomFieldValues(FdoCache cache, ICmObject obj, string objectType = "entry")
 {
     // The objectType parameter is used in the names of the custom fields (and nowhere else).
     var convertCustomField = new ConvertFdoToMongoCustomField(cache, new LfMerge.Logging.NullLogger());
     Dictionary<string, LfConfigFieldBase> lfCustomFieldList = new Dictionary<string, LfConfigFieldBase>();
     return convertCustomField.GetCustomFieldsForThisCmObject(obj, objectType, _listConverters, lfCustomFieldList);
 }
		protected InterlinearExporter(FdoCache cache, XmlWriter writer, ICmObject objRoot,
			InterlinLineChoices lineChoices, InterlinVc vc)
			: base(null, cache.MainCacheAccessor, objRoot.Hvo)
		{
			m_cache = cache;
			m_writer = writer;
			m_flidStTextTitle = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);
			m_flidStTextSource = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Source", false);
			m_vc = vc;
			SetTextTitleAndMetadata(objRoot as IStText);

			// Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
			IMoMorphType mmtStem;
			IMoMorphType mmtPrefix;
			IMoMorphType mmtSuffix;
			IMoMorphType mmtInfix;
			IMoMorphType mmtBoundStem;
			IMoMorphType mmtSimulfix;
			IMoMorphType mmtSuprafix;
			m_cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetMajorMorphTypes(
				out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
				out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic,
				out mmtSimulfix, out mmtSuprafix);

			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_repoObj = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
		}
Example #15
0
		public List<XmlImportData.PendingLink> LinksForField(ICmObject owner, int flid)
		{
			List<XmlImportData.PendingLink> linksForOwner;
			if (!m_lookupLinks.TryGetValue(owner, out linksForOwner))
				return new List<XmlImportData.PendingLink>();  // nothing is linked from this owner.
			return (from link in linksForOwner where link.FieldInformation.FieldId == flid select link).ToList();
		}
		/// <summary>
		/// We want the persistence provider, and the easiest way to get it is to get all
		/// this other stuff we don't need or use.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="editor"></param>
		/// <param name="flid"></param>
		/// <param name="node"></param>
		/// <param name="obj"></param>
		/// <param name="stringTbl"></param>
		/// <param name="persistenceProvider"></param>
		/// <param name="ws"></param>
		public PhEnvStrRepresentationSlice(FdoCache cache, string editor, int flid,
			System.Xml.XmlNode node, ICmObject obj, StringTable stringTbl,
			IPersistenceProvider persistenceProvider, int ws)
			: base(new StringRepSliceView(obj.Hvo), obj, StringRepSliceVc.Flid)
		{
			m_persistenceProvider = persistenceProvider;
		}
Example #17
0
		/// <summary>
		/// The user selected an item; now we actually need a LexEntryRef.
		/// </summary>
		/// <param name="hvoNew"></param>
		private void AddItem(ICmObject newObj)
		{
			CheckDisposed();

			bool fForVariant = XmlUtils.GetOptionalBooleanAttributeValue(m_configurationNode, "forVariant", false);
			string sUndo, sRedo;
			if (fForVariant)
			{
				sUndo = LexEdStrings.ksUndoVariantOf;
				sRedo = LexEdStrings.ksRedoVariantOf;
			}
			else
			{
				sUndo = LexEdStrings.ksUndoAddComponent;
				sRedo = LexEdStrings.ksRedoAddComponent;
			}
			try
			{
				UndoableUnitOfWorkHelper.Do(sUndo, sRedo, m_obj,
				() =>
				{
					ILexEntry ent = m_obj as ILexEntry;

					// Adapted from part of DtMenuHandler.AddNewLexEntryRef.
					ILexEntryRef ler = ent.Services.GetInstance<ILexEntryRefFactory>().Create();
					ent.EntryRefsOS.Add(ler);
					if (fForVariant)
					{
						// The slice this is part of should only be displayed for lex entries with no VariantEntryRefs.
						Debug.Assert(ent.VariantEntryRefs.Count() == 0);
						ler.VariantEntryTypesRS.Add(ent.Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS[0] as ILexEntryType);
						ler.RefType = LexEntryRefTags.krtVariant;
						ler.HideMinorEntry = 0;
					}
					else
					{
						// The slice this is part of should only be displayed for lex entries with no ComplexEntryRefs.
						Debug.Assert(ent.ComplexFormEntryRefs.Count() == 0);
						//ler.ComplexEntryTypesRS.Append(ent.Cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS[0].Hvo);
						ler.RefType = LexEntryRefTags.krtComplexForm;
						ler.HideMinorEntry = 0; // LT-10928
						// Logic similar to this is in EntrySequenceReferenceLauncher.AddNewObjectsToProperty()
						// (when LER already exists so slice is not ghost)
						ler.PrimaryLexemesRS.Add(newObj);
						// Since it's a new LER, we can't know it to be a derivative, so by default it is visible.
						// but do NOT do that here, it's now built into the process of adding it to PrimaryLexemes,
						// and we don't want to do it twice.
						// ler.ShowComplexFormsInRS.Add(newObj);
						ent.ChangeRootToStem();
					}
					// Must do this AFTER setting the RefType (so dependent virtual properties can be updated properly)
					ler.ComponentLexemesRS.Add(newObj);
				});
			}
			catch (ArgumentException)
			{
				MessageBoxes.ReportLexEntryCircularReference((ILexEntry)m_obj, newObj, true);
			}
		}
 /// <summary>
 /// add any subitems to the tree. Note! This assumes that the list has been preloaded
 /// (e.g., using PreLoadList), so it bypasses normal load operations for speed purposes.
 /// Withoug preloading, it took almost 19,000 queries to start FW showing semantic domain
 /// list. With preloading it reduced the number to 200 queries.
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="parentsCollection"></param>
 protected override void AddSubNodes(ICmObject obj, TreeNodeCollection parentsCollection)
 {
     var pss = (ICmPossibility) obj;
     foreach (var subPss in pss.SubPossibilitiesOS)
     {
         AddTreeNode(subPss, parentsCollection);
     }
 }
Example #19
0
		/// <summary>
		/// Report failure to make target a component of parent. If startedFromComplex is true, the user is looking
		/// at parent, and tried to make target a component. Otherwise, the user is looking at target, and
		/// tried to make parent a complex form.
		/// </summary>
		public static void ReportLexEntryCircularReference(ILexEntry parent, ICmObject target, bool startedFromComplex)
		{
			var itemString = target is ILexEntry ? FwCoreDlgs.ksEntry : FwCoreDlgs.ksSense;
			var msgTemplate = startedFromComplex ? FwCoreDlgs.ksComponentIsComponent : FwCoreDlgs.ksComplexFormIsComponent;
			var startedFrom = startedFromComplex ? parent.HeadWord.Text : target.ShortName;
			var msg = String.Format(msgTemplate, itemString, startedFrom);
			MessageBox.Show(Form.ActiveForm, msg, FwCoreDlgs.ksWhichIsComponent, MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
		/// <summary>
		/// Initialize the launcher.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="obj"></param>
		/// <param name="flid"></param>
		/// <param name="fieldName"></param>
		public override void Initialize(FdoCache cache, ICmObject obj, int flid, string fieldName,
			IPersistenceProvider persistProvider, Mediator mediator, string displayNameProperty, string displayWs)
		{
			CheckDisposed();

			base.Initialize(cache, obj, flid, fieldName, persistProvider, mediator, displayNameProperty, displayWs);
			m_msaInflectionFeatureListDlgLauncherView.Init(mediator, obj as IFsFeatStruc);
		}
#pragma warning restore 0414

		public ReversalIndexEntryFormSlice(FdoCache cache, string editor, int flid, XmlNode node,
			ICmObject obj, StringTable stringTbl, IPersistenceProvider persistenceProvider, int ws)
			: base(obj, flid, WritingSystemServices.kwsAllReversalIndex, 0, false, true, true)
		{
			m_configNode = node;
			m_stringTbl = stringTbl;
			m_persistProvider = persistenceProvider;
		}
Example #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new (empty) StFootnote and add it to the owner's collection.
		/// This method provides a way to create a new footnote object in the db for any generic
		/// CmObject owner.
		/// </summary>
		/// <param name="owner">The owner CmObject.</param>
		/// <param name="flid">The flid of the owner's footnote collection.</param>
		/// <param name="footnoteIndex">Index to insert the footnote at in the collection.</param>
		/// <returns>the new footnote object</returns>
		/// ------------------------------------------------------------------------------------
		public StFootnote(ICmObject owner, int flid, int footnoteIndex)
			: this()
		{
			// add this new (empty) footnote to the owner's collection
			FdoOwningSequence<IStFootnote> footnotes = new FdoOwningSequence<IStFootnote>(owner.Cache,
				owner.Hvo, flid);
			footnotes.InsertAt(this, footnoteIndex);
		}
Example #23
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="AtomicReferenceSlice"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public AtomicReferenceSlice(FdoCache cache, ICmObject obj, int flid,
			XmlNode configurationNode, IPersistenceProvider persistenceProvider,
			Mediator mediator, StringTable stringTbl)
			: base(cache, obj, flid, configurationNode, persistenceProvider, mediator, stringTbl)
		{
			m_sda = m_cache.MainCacheAccessor;
			m_sda.AddNotification(this);
		}
Example #24
0
		/// <summary>
		/// Initialize the launcher.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="obj"></param>
		/// <param name="flid"></param>
		/// <param name="fieldName"></param>
		public override void Initialize(FdoCache cache, ICmObject obj, int flid, string fieldName,
			IPersistenceProvider persistProvider, Mediator mediator, string displayNameProperty, string displayWs)
		{
			CheckDisposed();

			base.Initialize(cache, obj, flid, fieldName, persistProvider, mediator, displayNameProperty, displayWs);
			m_msaDlglauncherView.Init(mediator, obj as MoMorphSynAnalysis);
		}
		/// <summary>
		/// Constructor invoked via the editor="customWithParams" slice XML configuration
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="editor"></param>
		/// <param name="flid"></param>
		/// <param name="node"></param>
		/// <param name="obj"></param>
		/// <param name="stringTbl"></param>
		/// <param name="persistenceProvider"></param>
		/// <param name="ws"></param>
		public BasicIPASymbolSlice(FdoCache cache, string editor, int flid,
						System.Xml.XmlNode node, ICmObject obj, StringTable stringTbl,
						IPersistenceProvider persistenceProvider, int ws)
			: base(obj, flid, ws)
		{
			var phoneme = (IPhPhoneme)m_obj;
			phoneme.BasicIPASymbolChanged += UpdatePhoneme;
		}
		private ILexEntry MakeCompound(string lf, string gloss, ICmObject[] components)
		{
			var result = MakeEntry(lf, gloss);
			var ler = MakeLexEntryRef(result, LexEntryRefTags.krtComplexForm);
			foreach (var obj in components)
				ler.ComponentLexemesRS.Add(obj);
			return result;
		}
		public PhoneEnvReferenceSlice(FdoCache cache, ICmObject obj, int flid,
			XmlNode configurationNode, IPersistenceProvider persistenceProvider,
			Mediator mediator, StringTable stringTbl)
			: base(cache, obj, flid,configurationNode, persistenceProvider, mediator, stringTbl)
		{
			Debug.Assert(obj is MoAffixAllomorph || obj is MoStemAllomorph);
			m_persistenceProvider = persistenceProvider;
		}
		public override void Initialize(FdoCache cache, ICmObject obj, int flid,
			string fieldName, IPersistenceProvider persistProvider, Mediator mediator, string displayNameProperty, string displayWs)
		{
			CheckDisposed();

			base.Initialize(cache, obj, flid, fieldName, persistProvider, mediator, displayNameProperty, displayWs);
			m_atomicRefView.Initialize(obj, flid, cache, displayNameProperty, mediator);
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="cache">FDO cache.</param>
		/// <param name="obj">CmObject that is being displayed.</param>
		/// <param name="flid">The field identifier for the attribute we are displaying.</param>
		public MSAReferenceComboBoxSlice(FdoCache cache, ICmObject obj, int flid,
			IPersistenceProvider persistenceProvider, Mediator mediator)
			: base(new UserControl(), cache, obj, flid)
		{
			m_mediator = mediator;
			m_persistProvider = persistenceProvider;
			m_tree = new TreeCombo();
			m_tree.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
			m_tree.Font = new System.Drawing.Font(cache.LangProject.DefaultAnalysisWritingSystemFont, 10);
			if (!Application.RenderWithVisualStyles)
				m_tree.HasBorder = false;

			//Set the stylesheet and writing system information so that the font size for the
			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			m_tree.WritingSystemCode = cache.LangProject.DefaultAnalysisWritingSystem;
			m_tree.StyleSheet = stylesheet;

			// We embed the tree combo in a layer of UserControl, so it can have a fixed width
			// while the parent window control is, as usual, docked 'fill' to work with the splitter.
			m_tree.Dock = DockStyle.Left;
			m_tree.Width = 240;
			m_tree.DropDown += new EventHandler(m_tree_DropDown);

			Control.Controls.Add(m_tree);
			m_tree.SizeChanged += new EventHandler(m_tree_SizeChanged);
			if (m_MSAPopupTreeManager == null)
			{
				ICmPossibilityList list = m_cache.LangProject.PartsOfSpeechOA;
				int ws = m_cache.LangProject.DefaultAnalysisWritingSystem;
				m_tree.WritingSystemCode = ws;
				m_MSAPopupTreeManager = new MSAPopupTreeManager(m_tree, m_cache, list, ws, true,
					mediator, (Form)mediator.PropertyTable.GetValue("window"));
				m_MSAPopupTreeManager.AfterSelect += new TreeViewEventHandler(m_MSAPopupTreeManager_AfterSelect);
				m_MSAPopupTreeManager.Sense = m_obj as ILexSense;
				m_MSAPopupTreeManager.PersistenceProvider = m_persistProvider;
			}
			try
			{
				m_handlingMessage = true;
				m_MSAPopupTreeManager.MakeTargetMenuItem();
				//m_MSAPopupTreeManager.LoadPopupTree(0);
			}
			finally
			{
				m_handlingMessage = false;
			}

			if (m_cache != null)
			{
				m_sda = m_cache.MainCacheAccessor;
				m_sda.AddNotification(this);
			}
			m_treeBaseWidth = m_tree.Width;

			Control.Height = m_tree.PreferredHeight;
						// m_tree has sensible PreferredHeight once the text is set, UserControl does not.
						//we need to set the Height after m_tree.Text has a value set to it.
		}
Example #30
0
		private IPartOfSpeech CheckPos(string guid, ICmObject owner)
		{
			IPartOfSpeech pos;
			Assert.That(Cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().TryGetObject(new Guid(guid), out pos),
				Is.True,
				"expected POS should be created with the right guid");
			Assert.That(pos.Owner, Is.EqualTo(owner), "POS should be created at the right place in the hierarchy");
			return pos;
		}
        /// <summary>
        /// Determine if the object really has data to be shown in the slice
        /// </summary>
        /// <param name="obj">object to check; should be an IFsFeatStruc</param>
        /// <returns>true if the feature structure has content in FeatureSpecs; false otherwise</returns>
        public static bool ShowSliceForVisibleIfData(XmlNode node, ICmObject obj)
        {
            //FDO.Cellar.IFsFeatStruc fs = obj as FDO.Cellar.IFsFeatStruc;
            int          flid = GetFlid(node, obj);
            IFsFeatStruc fs;

            if (flid != 0)
            {
                fs = GetFeatureStructureFromMSA(obj, flid);
            }
            else
            {
                fs = obj as IFsFeatStruc;
            }
            if (fs != null)
            {
                if (fs.FeatureSpecsOC.Count > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #32
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Links to lexicon.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void LinkToLexicon()
        {
            CheckDisposed();
            int hvo = m_hvoSelected;

            if (hvo == 0 && m_rghvo != null && m_rghvo.Count > 0)
            {
                hvo = m_rghvo[0];
            }
            // REVIEW: THIS SHOULD NEVER HAPPEN, BUT IF IT DOES, SHOULD WE TELL THE USER ANYTHING?
            if (hvo == 0)
            {
                return;
            }
            ICmObject cmo  = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo);
            FwAppArgs link = new FwAppArgs(FwUtils.ksFlexAppName, m_cache.ProjectId.Handle,
                                           m_cache.ProjectId.ServerName, "lexiconEdit", cmo.Guid);

            Debug.Assert(m_mediator != null, "The program must pass in a mediator to follow a link in the same application!");
            IApp app = (IApp)m_mediator.PropertyTable.GetValue("App");

            app.HandleOutgoingLink(link);
        }
Example #33
0
        protected override void RemoveFromPropertyAt(int index, ICmObject oldObj)
        {
            string fieldName = m_obj.Cache.MetaDataCacheAccessor.GetFieldName(m_flid);

            switch (fieldName)
            {
            case "VisibleComplexFormEntries":
                ChangeItemsInLexEntryRefs(new [] { oldObj }, ler => ler.ShowComplexFormsInRS.Remove(m_obj));
                break;

            case "Subentries":
                ChangeItemsInLexEntryRefs(new[] { oldObj }, ler => ler.PrimaryLexemesRS.Remove(m_obj));
                break;

            case "VisibleComplexFormBackRefs":
                ((ILexEntryRef)oldObj).ShowComplexFormsInRS.Remove(m_obj);
                break;

            default:
                base.RemoveFromPropertyAt(index, oldObj);
                break;
            }
        }
Example #34
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Inserts a note referencing the currently selected paragraph.
        /// </summary>
        /// <param name="noteType">Type of note</param>
        /// <param name="startRef">reference at beginning of selection</param>
        /// <param name="endRef">reference at end of selection</param>
        /// <param name="topObj">The object where quoted text begins.</param>
        /// <param name="bottomObj">The object where quoted text ends.</param>
        /// <param name="startOffset">The starting character offset.</param>
        /// <param name="endOffset">The ending character offset.</param>
        /// <param name="tssQuote">The text of the quote.</param>
        /// <returns>The inserted note</returns>
        /// ------------------------------------------------------------------------------------
        public virtual IScrScriptureNote InsertNote(ICmAnnotationDefn noteType, BCVRef startRef,
                                                    BCVRef endRef, ICmObject topObj, ICmObject bottomObj,
                                                    int startOffset, int endOffset, ITsString tssQuote)
        {
            CheckDisposed();

            int iPos;

            IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[startRef.Book - 1];

            StTxtParaBldr quoteParaBldr = new StTxtParaBldr(m_cache);

            quoteParaBldr.ParaStyleName = ScrStyleNames.Remark;
            quoteParaBldr.StringBuilder.ReplaceTsString(0, 0, tssQuote);
            IScrScriptureNote annotation = annotations.InsertNote(startRef, endRef, topObj, bottomObj,
                                                                  noteType.Guid, startOffset, endOffset, quoteParaBldr, null, null, null,
                                                                  out iPos);

            RegisterScrollCallBack(startRef.Book, iPos);

            // REVIEW: Do we need to create a synch record?
            return(annotation);
        }
Example #35
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determine where in the annotation list to insert a new annotation having the
        /// specified startRef, beginning object and beginning offset.
        /// </summary>
        /// <param name="startRef">The start ref.</param>
        /// <param name="beginObject">The begin object.</param>
        /// <param name="begOffset">The beg offset.</param>
        /// ------------------------------------------------------------------------------------
        private int GetNewNotesInsertIndex(BCVRef startRef, ICmObject beginObject, int begOffset)
        {
            // Get the index within the book of the section containing the paragraph
            // containing the reference to which the new annotation corresponds.
            int iNewNoteSection;
            int iNewNotePara;

            GetLocationInfoForObj(beginObject, out iNewNoteSection, out iNewNotePara);

            IFdoOwningSequence <IScrScriptureNote> notes = NotesOS;
            int insertIndex = notes.Count;

            // Go backward through the list of existing annotations.
            for (int i = notes.Count - 1; i >= 0; i--)
            {
                IScrScriptureNote note = notes[i];
                int iSect, iPara;
                GetLocationInfoForObj(note.BeginObjectRA, out iSect, out iPara);

                // If the annotation is for text that follows the text associated
                // with the new annotation we're adding, then decrement the index
                // of where to insert the new annotation.
                if (note.BeginRef > startRef ||
                    iSect > iNewNoteSection ||
                    (iSect == iNewNoteSection && iPara > iNewNotePara) ||
                    (iSect == iNewNoteSection && iPara == iNewNotePara && note.BeginOffset > begOffset))
                {
                    insertIndex--;
                }
                else
                {
                    break;                     // found first spot for note
                }
            }

            return(insertIndex);
        }
Example #36
0
        protected void CreateMsaXmlElement(XmlNode node, XmlDocument doc, XmlNode morphNode, string sHvo)
        {
            XmlNode attr;

            // morphname contains the hvo of the msa
            attr = node.SelectSingleNode(sHvo);
            if (attr != null)
            {
                ICmObject obj = CmObject.CreateFromDBObject(m_cache, Convert.ToInt32(attr.Value));
                switch (obj.GetType().Name)
                {
                default:
                    throw new ApplicationException(String.Format("Invalid MSA type: {0}.", obj.GetType().Name));

                case "MoStemMsa":
                    IMoStemMsa stemMsa = obj as IMoStemMsa;
                    CreateStemMsaXmlElement(doc, morphNode, stemMsa);
                    break;

                case "MoInflAffMsa":
                    IMoInflAffMsa inflMsa = obj as IMoInflAffMsa;
                    CreateInflectionClasses(doc, morphNode);
                    CreateInflMsaXmlElement(doc, morphNode, inflMsa);
                    break;

                case "MoDerivAffMsa":
                    IMoDerivAffMsa derivMsa = obj as IMoDerivAffMsa;
                    CreateDerivMsaXmlElement(doc, morphNode, derivMsa);
                    break;

                case "MoUnclassifiedAffixMsa":
                    IMoUnclassifiedAffixMsa unclassMsa = obj as IMoUnclassifiedAffixMsa;
                    CreateUnclassifedMsaXmlElement(doc, morphNode, unclassMsa);
                    break;
                }
            }
        }
Example #37
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Inserts a Scriture annotation for the book currently being imported.
        /// </summary>
        /// <param name="bcvStartReference">The starting BCV reference.</param>
        /// <param name="bcvEndReference">The ending BCV reference.</param>
        /// <param name="obj">The object being annotated (either a paragraph or a IScrBook)</param>
        /// <param name="bldr">The paragraph builder containing the guts of the annotation
        /// description</param>
        /// <param name="guidNoteType">The GUID representing the CmAnnotationDefn to use for
        /// the type</param>
        /// <returns>The newly created annotation</returns>
        /// ------------------------------------------------------------------------------------
        public IScrScriptureNote InsertNote(int bcvStartReference, int bcvEndReference,
                                            ICmObject obj, StTxtParaBldr bldr, Guid guidNoteType)
        {
            bool fOpenedTransaction = false;

            if (m_cache.DatabaseAccessor != null && !m_cache.DatabaseAccessor.IsTransactionOpen())
            {
                fOpenedTransaction = true;
                m_cache.DatabaseAccessor.BeginTrans();
            }
            try
            {
                IScrScriptureNote note = m_annotations.InsertImportedNote(
                    bcvStartReference, bcvEndReference, obj, obj, guidNoteType, bldr);

                m_suppressor.Dispose();
                m_suppressor = null;
                m_cache.ActionHandlerAccessor.AddAction(new UndoImportObjectAction(note));

                if (fOpenedTransaction)
                {
                    m_cache.DatabaseAccessor.CommitTrans();
                }

                m_suppressor = new SuppressSubTasks(m_cache);

                return(note);
            }
            catch
            {
                if (fOpenedTransaction)
                {
                    m_cache.DatabaseAccessor.RollbackTrans();
                }
                throw;
            }
        }
Example #38
0
        protected void ShowDialogAndConvert(int targetClassId)
        {
            // maybe there's a better way, but
            // this creates a temporary LexEntryRef in a temporary LexEntry
            var leFactory  = m_cache.ServiceLocator.GetInstance <ILexEntryFactory>();
            var entry      = leFactory.Create();
            var lerFactory = m_cache.ServiceLocator.GetInstance <ILexEntryRefFactory>();
            var ler        = lerFactory.Create();

            entry.EntryRefsOS.Add(ler);
            m_flid = LexEntryRefTags.kflidVariantEntryTypes;
            m_obj  = ler;
            var labels = ObjectLabel.CreateObjectLabels(m_cache,
                                                        m_obj.ReferenceTargetCandidates(m_flid),
                                                        "LexEntryType" /*"m_displayNameProperty*/,
                                                        "best analysis");

            using (SimpleListChooser chooser = GetChooser(labels, targetClassId))
            {
                chooser.Cache = m_cache;
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);
                chooser.SetHelpTopic(s_helpTopic);
                var tv = chooser.TreeView;
                DisableNodes(tv.Nodes, targetClassId);
                m_dlg.Visible = false;                 // no reason to show the utility dialog, too
                var res = chooser.ShowDialog(m_dlg.FindForm());
                if (res == DialogResult.OK && chooser.ChosenObjects.Any())
                {
                    var itemsToChange = (from lexEntryType in chooser.ChosenObjects
                                         where lexEntryType.ClassID != targetClassId
                                         select lexEntryType).Cast <ILexEntryType>();
                    Convert(itemsToChange);
                }
            }
            entry.Delete();             // remove the temporary LexEntry
            m_dlg.Visible = true;       // now we show the utility dialog again
        }
Example #39
0
        public void SetDlgInfo(FdoCache cache, Mediator mediator, ICmObject owner)
        {
            CheckDisposed();

            m_cache = cache;
            m_owner = owner;

            m_helpTopic = "khtpDataNotebook-InsertRecordDlg";

            m_helpTopicProvider = mediator.HelpTopicProvider;
            if (m_helpTopicProvider != null)             // Will be null when running tests
            {
                m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                m_helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic));
                m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }

            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            m_titleTextBox.StyleSheet           = stylesheet;
            m_titleTextBox.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_titleTextBox.WritingSystemCode    = m_cache.DefaultAnalWs;
            AdjustControlAndDialogHeight(m_titleTextBox, m_titleTextBox.PreferredHeight);

            m_typeCombo.StyleSheet           = stylesheet;
            m_typeCombo.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_typeCombo.WritingSystemCode    = m_cache.DefaultAnalWs;
            AdjustControlAndDialogHeight(m_typeCombo, m_typeCombo.PreferredHeight);

            ICmPossibilityList recTypes = m_cache.LanguageProject.ResearchNotebookOA.RecTypesOA;

            m_typePopupTreeManager = new PossibilityListPopupTreeManager(m_typeCombo, m_cache, mediator,
                                                                         recTypes, cache.DefaultAnalWs, false, this);
            m_typePopupTreeManager.LoadPopupTree(m_cache.ServiceLocator.GetObject(RnResearchNbkTags.kguidRecObservation).Hvo);
            // Ensure that we start out focused in the Title text box.  See FWR-2731.
            m_titleTextBox.Select();
        }
Example #40
0
        //	protected string m_helpId;

        /// <summary>
        /// constructor using a simple string explanation. Also creates an annotation on the object.
        /// </summary>
        public ConstraintFailure(ICmObject problemObject, int flid, string explanation, bool createAnnotation)
        {
            m_cache       = problemObject.Cache;
            m_object      = problemObject;
            m_flid        = flid;
            m_explanation = explanation;
//			m_explanation = new StText();
//			StTxtParaBldr paraBldr = new StTxtParaBldr(m_cache);
//			//review: I have no idea what this is as to be
//			paraBldr.ParaProps = StyleUtils.ParaStyleTextProps("Paragraph");
//			//todo: this pretends that the default analysis writing system is also the user interface 1.
//			//but I don't really know what's the right thing to do.
//			paraBldr.AppendRun(m_explanation, StyleUtils.CharStyleTextProps(null, m_cache.DefaultAnalWs));
//			paraBldr.CreateParagraph(annotation.TextOAHvo);

            //we do this because, if it is missing this annotation, then we really should annotate it
            //so that when the user goes looking to see why something didn't work, the error message
            //is sure to be there.
            //enhance: we are wasting time building an annotation repeatedly, if the correct one is already there
            if (createAnnotation)
            {
                MakeAnnotation();
            }
        }
        protected override void HandleSelectionChange(IVwRootBox rootb, IVwSelection vwselNew)
        {
            ICmObject selected    = SelectedObject;
            int       selectedHvo = 0;

            if (selected != null)
            {
                selectedHvo = selected.Hvo;
            }

            if (selectedHvo != m_prevSelectedHvo)
            {
                if (DeleteItem())
                {
                    m_prevSelectedHvo = selectedHvo;
                    SelectedObject    = selected;
                }
                else
                {
                    m_prevSelectedHvo = selectedHvo;
                    vwselNew.ExtendToStringBoundaries();
                }
            }
        }
Example #42
0
        public void SetAgentOpinion()
        {
            ICmAgent     agent = m_fdoCache.LangProject.DefaultComputerAgent;
            IWfiWordform wf    = new WfiWordform(m_fdoCache, WfiWordform.FindOrCreateWordform(m_fdoCache, "xxxyyyzzz12234", m_fdoCache.DefaultVernWs, true));
            IWfiAnalysis wa    = new WfiAnalysis();

            wf.AnalysesOC.Add(wa);
            ICmObject target = wa;             // can pick anything as target for evaluation!

            m_fdoCache.BeginUndoTask("doit", "undoit");
            wa.SetAgentOpinion(agent, Opinions.approves);
            m_fdoCache.EndUndoTask();
            Assert.AreEqual(Opinions.approves, wa.GetAgentOpinion(agent));
            m_fdoCache.Undo();
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));
            m_fdoCache.Redo();
            Assert.AreEqual(Opinions.approves, wa.GetAgentOpinion(agent));

            m_fdoCache.BeginUndoTask("changeit", "unchangeit");
            wa.SetAgentOpinion(agent, Opinions.disapproves);
            m_fdoCache.EndUndoTask();
            Assert.AreEqual(Opinions.disapproves, wa.GetAgentOpinion(agent));
            m_fdoCache.Undo();
            Assert.AreEqual(Opinions.approves, wa.GetAgentOpinion(agent));
            m_fdoCache.Redo();
            Assert.AreEqual(Opinions.disapproves, wa.GetAgentOpinion(agent));

            m_fdoCache.BeginUndoTask("clearit", "unclearit");
            wa.SetAgentOpinion(agent, Opinions.noopinion);
            m_fdoCache.EndUndoTask();
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));
            m_fdoCache.Undo();
            Assert.AreEqual(Opinions.disapproves, wa.GetAgentOpinion(agent));
            m_fdoCache.Redo();
            Assert.AreEqual(Opinions.noopinion, wa.GetAgentOpinion(agent));
        }
Example #43
0
        /// <summary>
        /// Initialize from the data store (which uses byte arrays).
        /// </summary>
        internal void InitializeFromDataStore(LcmCache cache, ICmObjectId objId, string className, byte[] xmlData)
        {
            if (cache == null)
            {
                throw new ArgumentNullException("cache");
            }
            if (objId == null)
            {
                throw new ArgumentNullException("objId");
            }
            if (xmlData == null)
            {
                throw new ArgumentNullException("xmlData");
            }
            if (string.IsNullOrEmpty(className))
            {
                throw new ArgumentNullException("className");
            }

            lock (SyncRoot)
            {
                m_cache = cache;
                // Don't do this! If it's a new surrogate, the object is already null, and if not,
                // and we've already fluffed it, it's an invalid state for the object of the surrogate
                // to be null when it is fluffed.
                // m_object = null;
                // in fact, if we're re-creating a surrogate that got fluffed and garbage collected,
                // e.g., in Refreshing a surrogate to align it with another client,
                // we might be making a new object, yet the CmObject might already exist!
                m_object    = ((ICmObjectRepositoryInternal)m_cache.ServiceLocator.ObjectRepository).GetObjectIfFluffed(objId);
                RawXmlBytes = xmlData;
                m_guid      = objId is CmObjectIdWithHvo ? objId
                                        : ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(objId.Guid);
                SetClassName(className);
            }
        }
Example #44
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="cache">FDO cache.</param>
        /// <param name="obj">CmObject that is being displayed.</param>
        /// <param name="flid">The field identifier for the attribute we are displaying.</param>
        /// <param name="persistenceProvider">The persistence provider.</param>
        /// ------------------------------------------------------------------------------------
        public MSAReferenceComboBoxSlice(FdoCache cache, ICmObject obj, int flid,
                                         IPersistenceProvider persistenceProvider)
            : base(new UserControl(), cache, obj, flid)
        {
            IWritingSystem defAnalWs = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem;

            m_persistProvider           = persistenceProvider;
            m_tree                      = new TreeCombo();
            m_tree.WritingSystemFactory = cache.WritingSystemFactory;
            m_tree.Font                 = new System.Drawing.Font(defAnalWs.DefaultFontName, 10);
            if (!Application.RenderWithVisualStyles)
            {
                m_tree.HasBorder = false;
            }

            m_tree.WritingSystemCode = defAnalWs.Handle;

            // We embed the tree combo in a layer of UserControl, so it can have a fixed width
            // while the parent window control is, as usual, docked 'fill' to work with the splitter.
            m_tree.Dock      = DockStyle.Left;
            m_tree.Width     = 240;
            m_tree.DropDown += m_tree_DropDown;

            Control.Controls.Add(m_tree);
            m_tree.SizeChanged += m_tree_SizeChanged;

            if (m_cache != null)
            {
                m_cache.DomainDataByFlid.AddNotification(this);
            }
            m_treeBaseWidth = m_tree.Width;

            // m_tree has sensible PreferredHeight once the text is set, UserControl does not.
            //we need to set the Height after m_tree.Text has a value set to it.
            Control.Height = m_tree.PreferredHeight;
        }
Example #45
0
        /// <summary>
        /// This is the primary combo box.
        /// When an item is selected, then the secondary combo box can be
        /// filled with approriate items.
        /// With the selected itme here, we can also populate the
        /// left side control (the one below the combo box).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_cbFind_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cursor oldState = FindForm().Cursor;

            m_selectedFinder  = null;
            FindForm().Cursor = Cursors.WaitCursor;
            FindComboFillerBase fcf = m_cbFind.SelectedItem as FindComboFillerBase;

            m_cbUsedBy.BeginUpdate();
            m_cbUsedBy.Items.Clear();
            m_cbUsedBy.Items.AddRange(fcf.List_UBF.ToArray());
            m_cbUsedBy.EndUpdate();
            fcf.LoadList(m_mediator, m_splitContainer.Panel1);
            if (m_cbUsedBy.Items.Count > 0)
            {
                m_cbUsedBy.SelectedIndex = 0;
            }
            else
            {
                m_cbUsedBy.SelectedItem = null;
            }

            FindForm().Cursor = oldState;
        }
        private void HandlePossibilitySelected(object sender, EventArgs e)
        {
            ICmPossibility poss   = m_autoComplete.SelectedPossibility;
            ICmObject      curObj = m_vectorRefView.SelectedObject;

            if (curObj == null)
            {
                AddItem(poss);
            }
            else if (poss != curObj)
            {
                var newTargets = new List <ICmObject>();
                foreach (ICmObject target in Targets)
                {
                    newTargets.Add(target == curObj ? poss : target);
                }
                SetItems(newTargets);
            }
            else
            {
                UpdateDisplayFromDatabase();
            }
            m_vectorRefView.SelectedObject = poss;
        }
Example #47
0
        private void AddSenseAndTwoSubsensesToEntry(ICmObject entryOrSense, string gloss)
        {
            var senseFactory = Cache.ServiceLocator.GetInstance <ILexSenseFactory>();
            var sense        = senseFactory.Create();
            var entry        = entryOrSense as ILexEntry;

            if (entry != null)
            {
                entry.SensesOS.Add(sense);
            }
            else
            {
                ((ILexSense)entryOrSense).SensesOS.Add(sense);
            }
            sense.Gloss.set_String(m_wsEn, TsStringUtils.MakeString(gloss, m_wsEn));
            var subSensesOne = senseFactory.Create();

            sense.SensesOS.Add(subSensesOne);
            subSensesOne.Gloss.set_String(m_wsEn, TsStringUtils.MakeString(gloss + "2.1", m_wsEn));
            var subSensesTwo = senseFactory.Create();

            sense.SensesOS.Add(subSensesTwo);
            subSensesTwo.Gloss.set_String(m_wsEn, TsStringUtils.MakeString(gloss + "2.2", m_wsEn));
        }
        /// <summary>
        /// Attempts to get the ICmObject with the given Guid.
        /// </summary>
        /// <param name="hvo">The unique id of an object.</param>
        /// <param name="obj">The ICmObject with the given Guid, or null, if not in Identity Map.</param>
        /// <returns>True if the object was found, false otherwise</returns>
        internal bool TryGetObject(int hvo, out ICmObject obj)
        {
            ICmObjectOrId objOrId;
            bool          found;

            lock (SyncRoot)
            {
                found = m_extantObjectsByHvo.TryGetValue(hvo, out objOrId);
            }
            if (found)
            {
                obj = objOrId as ICmObject;
                if (obj != null)
                {
                    return(true);
                }
                if (TryGetObject(objOrId.Id.Guid, out obj))
                {
                    return(true);
                }
            }
            obj = null;
            return(false);
        }
Example #49
0
        /// <summary>
        /// Handle the click event for the launcher button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        protected virtual void OnClick(Object sender, EventArgs arguments)
        {
            bool fValid;

            if (m_obj == null && ObjectCreator != null)
            {
                m_obj = ObjectCreator();
                OnObjectCreated();
            }
            if (m_obj == null)
            {
                MessageBox.Show(DetailControlsStrings.ksNotInitialized);
                fValid = false;
            }
            else
            {
                fValid = m_obj.IsValidObject;
            }

            if (fValid)
            {
                HandleChooser();
            }
        }
Example #50
0
            /// <summary>
            /// Executes in two distinct scenarios.
            ///
            /// 1. If disposing is true, the method has been called directly
            /// or indirectly by a user's code via the Dispose method.
            /// Both managed and unmanaged resources can be disposed.
            ///
            /// 2. If disposing is false, the method has been called by the
            /// runtime from inside the finalizer and you should not reference (access)
            /// other managed objects, as they already have been garbage collected.
            /// Only unmanaged resources can be disposed.
            /// </summary>
            /// <param name="disposing"></param>
            /// <remarks>
            /// If any exceptions are thrown, that is fine.
            /// If the method is being done in a finalizer, it will be ignored.
            /// If it is thrown by client code calling Dispose,
            /// it needs to be handled by fixing the bug.
            ///
            /// If subclasses override this method, they should call the base implementation.
            /// </remarks>
            protected override void Dispose(bool disposing)
            {
                //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
                // Must not be run more than once.
                if (IsDisposed)
                {
                    return;
                }

                base.Dispose(disposing);

                if (disposing)
                {
                    // Dispose managed resources here.
                    if (m_vc != null && m_vc is IDisposable)
                    {
                        (m_vc as IDisposable).Dispose();
                    }
                }

                // Dispose unmanaged resources here, whether disposing is true or false.
                m_obj = null;
                m_vc  = null;
            }
Example #51
0
        /// <summary>
        /// Calls the sort method.
        /// </summary>
        /// <param name="cmo">The object.</param>
        /// <param name="sortedFromEnd">if set to <c>true</c> [sorted from end].</param>
        /// <returns></returns>
        private string CallSortMethod(ICmObject cmo, bool sortedFromEnd)
        {
            Type typeCmo = cmo.GetType();

            try
            {
                MethodInfo mi = typeCmo.GetMethod(m_sMethodName);
                if (mi == null)
                {
                    return(null);
                }

                object obj;
                if (mi.GetParameters().Length == 2)
                {
                    // Enhance JohnT: possibly we should seek to evaluate this every time, in case it is a magic WS like
                    // "best vernacular". But interpreting those requires a flid, and we don't have one; indeed, the
                    // method may retrieve information from several. So we may as well just accept that the fancy ones
                    // won't work.
                    if (m_ws == 0 && WritingSystemName != null)
                    {
                        m_ws = LangProject.InterpretWsLabel(cmo.Cache, WritingSystemName, 0, 0, 0, null);
                    }
                    obj = mi.Invoke(cmo, new object[] { sortedFromEnd, m_ws });
                }
                else
                {
                    obj = mi.Invoke(cmo, new object[] { sortedFromEnd });
                }
                return((string)obj);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #52
0
        /// <summary>
        /// Get the field values as a dict, keyed by field ID, for any CmObject.
        /// </summary>
        /// <returns>A dictionary with integer field ID mapped to values.</returns>
        /// <param name="cache">LCM cache the object lives in.</param>
        /// <param name="obj">Object whose fields we're getting.</param>
        protected IDictionary <int, object> GetFieldValues(LcmCache cache, ICmObject obj)
        {
            IFwMetaDataCacheManaged mdc  = cache.ServiceLocator.MetaDataCache;
            ISilDataAccess          data = cache.DomainDataByFlid;

            int[] fieldIds    = mdc.GetFields(obj.ClassID, false, (int)CellarPropertyTypeFilter.All);
            var   fieldValues = new Dictionary <int, object>();

            foreach (int flid in fieldIds)
            {
                if (mdc.IsCustom(flid))
                {
                    continue;                     // Custom fields get processed differently
                }
                string fieldName = mdc.GetFieldNameOrNull(flid);
                if (String.IsNullOrEmpty(fieldName))
                {
                    continue;
                }
                object value = data.get_Prop(obj.Hvo, flid);
                fieldValues[flid] = value;
            }
            return(fieldValues);
        }
 public PhonologicalFeatureListDlgLauncherSlice(FdoCache cache, ICmObject obj, int flid,
                                                System.Xml.XmlNode node, IPersistenceProvider persistenceProvider, Mediator mediator, StringTable stringTbl)
 {
 }
Example #54
0
 public CheckboxRefreshSlice(LcmCache cache, ICmObject obj, int flid, XmlNode node)
     : base(cache, obj, flid, node)
 {
 }
        private static IFsFeatStruc GetFeatureStructureFromOwner(ICmObject obj, int flid)
        {
            IFsFeatStruc fs = obj.GetObjectInAtomicField(flid) as IFsFeatStruc;

            return(fs);
        }
Example #56
0
 protected SemanticDomainReferenceVectorSlice(Control control, FdoCache cache, ICmObject obj, int flid)
     : base(control, cache, obj, flid)
 {
 }
Example #57
0
 public SemanticDomainReferenceVectorSlice(FdoCache cache, ICmObject obj, int flid)
     : base(new SemanticDomainReferenceLauncher(), cache, obj, flid)
 {
 }
Example #58
0
 /// <summary>
 /// Update the root object. This is currently used when one is created, so it doesn't need to handle null object.
 /// </summary>
 /// <param name="root"></param>
 internal void UpdateRootObject(ICmObject root)
 {
     m_rootObj = root;
     m_rootb.SetRootObject(m_rootObj.Hvo, m_VectorReferenceVc, kfragTargetVector, m_rootb.Stylesheet);
 }
Example #59
0
 public override void AddItem(ICmObject obj)
 {
     AddItem(obj, string.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
             string.Format(DetailControlsStrings.ksRedoSet, m_fieldName));
 }
        /// <summary>
        /// This method is called when we are creating a new lexical relation slice.
        /// If the user selects an item it's hvo is returned.
        /// Otherwise 0 is returned and the lexical relation should not be created.
        /// </summary>
        /// <param name="lrt"></param>
        /// <returns></returns>
        private ICmObject GetChildObject(ILexRefType lrt)
        {
            ICmObject  first  = null;
            EntryGoDlg dlg    = null;
            string     sTitle = string.Empty;

            try
            {
                switch ((LexRefTypeTags.MappingTypes)lrt.MappingType)
                {
                case LexRefTypeTags.MappingTypes.kmtEntryOrSensePair:
                case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair:
                    // Entry or sense pair with different Forward/Reverse
                    dlg = new LinkEntryOrSenseDlg();
                    (dlg as LinkEntryOrSenseDlg).SelectSensesOnly = false;
                    sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense, lrt.Name.BestAnalysisAlternative.Text);
                    break;

                case LexRefTypeTags.MappingTypes.kmtSenseCollection:
                case LexRefTypeTags.MappingTypes.kmtSensePair:
                case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair:
                case LexRefTypeTags.MappingTypes.kmtSenseUnidirectional:
                // Sense pair with different Forward/Reverse names
                case LexRefTypeTags.MappingTypes.kmtSenseSequence:
                case LexRefTypeTags.MappingTypes.kmtSenseTree:
                    dlg = new LinkEntryOrSenseDlg();
                    (dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
                    sTitle = String.Format(LexEdStrings.ksIdentifyXSense, lrt.Name.BestAnalysisAlternative.Text);
                    break;

                case LexRefTypeTags.MappingTypes.kmtEntryCollection:
                case LexRefTypeTags.MappingTypes.kmtEntryPair:
                case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair:
                case LexRefTypeTags.MappingTypes.kmtEntryUnidirectional:
                // Entry pair with different Forward/Reverse names
                case LexRefTypeTags.MappingTypes.kmtEntrySequence:
                case LexRefTypeTags.MappingTypes.kmtEntryTree:
                    dlg    = new EntryGoDlg();
                    sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntry, lrt.Name.BestAnalysisAlternative.Text);
                    break;

                case LexRefTypeTags.MappingTypes.kmtEntryOrSenseCollection:
                case LexRefTypeTags.MappingTypes.kmtEntryOrSenseSequence:
                case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree:
                case LexRefTypeTags.MappingTypes.kmtEntryOrSenseUnidirectional:
                    dlg    = new LinkEntryOrSenseDlg();
                    sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense, lrt.Name.BestAnalysisAlternative.Text);
                    break;

                default:
                    Debug.Assert(lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair || lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree);
                    return(null);
                }
                Debug.Assert(dlg != null);
                var wp = new WindowParams {
                    m_title = sTitle, m_btnText = LexEdStrings.ks_Add
                };

                // Don't display the current entry in the list of matching entries.  See LT-2611.
                ICmObject objEntry = this.Object;
                while (objEntry.ClassID == LexSenseTags.kClassId)
                {
                    objEntry = objEntry.Owner;
                }
                Debug.Assert(objEntry.ClassID == LexEntryTags.kClassId);
                dlg.StartingEntry = objEntry as ILexEntry;

                dlg.SetDlgInfo(m_cache, wp, Mediator);
                dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
                if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    first = dlg.SelectedObject;
                }
                return(first);
            }
            finally
            {
                if (dlg != null)
                {
                    dlg.Dispose();
                }
            }
        }