コード例 #1
0
		public bool OnMoveReversalPOS(object cmd)
		{
			FdoCache cache = Cache;
			var labels = new List<ObjectLabel>();
			foreach (IPartOfSpeech pos in MergeOrMoveCandidates)
			{
				if (!pos.SubPossibilitiesOS.Contains(POS))
				{
					labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos, "ShortNameTSS", "best analysis"));
				}
			}
			using (SimpleListChooser dlg = new SimpleListChooser(cache, null, m_mediator.HelpTopicProvider, labels, null,
				LexEdStrings.ksCategoryToMoveTo, null))
			{
				dlg.SetHelpTopic("khtpChoose-CategoryToMoveTo");
				if (dlg.ShowDialog() == DialogResult.OK)
				{
					IPartOfSpeech currentPOS = POS;
					IPartOfSpeech newOwner = (IPartOfSpeech)dlg.ChosenOne.Object;
					UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMoveRevCategory,
						LexEdStrings.ksRedoMoveRevCategory, cache.ActionHandlerAccessor,
						() =>
							{
								newOwner.MoveIfNeeded(currentPOS); //important when an item is moved into it's own subcategory
								if (!newOwner.SubPossibilitiesOS.Contains(currentPOS)) //this is also prevented in the interface, but I'm paranoid
								{
									newOwner.SubPossibilitiesOS.Add(currentPOS);
								}
							});
					// Note: PropChanged should happen on the old owner and the new in the 'Add" method call.
					// Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories.
					m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainPossibility.Hvo);
				}
			}

			return true;
		}
コード例 #2
0
        /// <summary>
        /// Handle launching of the standard chooser.
        /// </summary>
        /// <remarks>
        /// Subclasses should override this method, if the SimpleListChooser is not suitable.
        /// </remarks>
        protected override void HandleChooser()
        {
            string displayWs = "analysis vernacular";
            //string displayWs = "best analysis";
            string postDialogMessageTrigger = null;

            if (m_configurationNode != null)
            {
                XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                if (node != null)
                {
                    displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                    postDialogMessageTrigger = XmlUtils.GetAttributeValue(node, "postChangeMessageTrigger", null);
                }
            }
            var labels = ObjectLabel.CreateObjectLabels(m_cache, m_obj.ReferenceTargetCandidates(m_flid),
                                                        m_displayNameProperty, displayWs);

            // I (JH) started down this road to sorting the object labels... it proved bumpy
            // and I bailed out and just turned on the "sorted" property of the chooser,
            // which gives us a dumb English sort.
            // but when it is time to get back to this... what I was doing what is misguided
            // because this sorter wants FdoObjects, but object labels don't have those on the
            // surface.  instead, they can readily give a string, through ToString().which is
            // what made me realize that until we have a way to sort something based on ICU, I
            // might as well let .net do the sorting.

            // I'm thinking there's a good chance we will eventually use FieldWorks controls for
            // the chooser in fact we will probably just using normal browse view. Then, that
            // chooser can just do the normal sorting that browse view stew, including letting
            // the user sort based on different properties.

            // however, we need a TreeView in many cases... I think there's also a FieldWorks
            // one of those that probably doesn't have sorting built-in yet...in which case we
            // might want to do the sorting here.

            //SIL.FieldWorks.Filters.RecordSorter sorter =
            //	new SIL.FieldWorks.Filters.PropertyRecordSorter("ShortName");
            //sorter.Sort ((ArrayList) labels);

            using (SimpleListChooser chooser = GetChooser(labels))
            {
                chooser.Cache = m_cache;
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);                    // may set TextParamHvo
                if (m_configurationNode != null)
                {
                    // Handle the default case ("owner") for text parameters.

                    // This (old approach) works only if
                    // all of the list items are owned by the same object as the first one in the
                    // list.  (Later elements can be owned by elements owned by that first owner,
                    // if you know what I mean.)
                    //if (candidates.Count != 0)
                    //    chooser.TextParamHvo = m_cache.GetOwnerOfObject((int)candidates[0]);
                    // JohnT: this approach depends on a new FDO method.
                    ICmObject referenceTargetOwner = m_obj.ReferenceTargetOwner(m_flid);
                    if (referenceTargetOwner != null)
                    {
                        chooser.TextParamHvo = referenceTargetOwner.Hvo;
                    }
                    chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
                    chooser.InitializeExtras(m_configurationNode, Mediator, m_propertyTable);
                }

                var res = chooser.ShowDialog(MainControl.FindForm());
                if (DialogResult.Cancel == res)
                {
                    return;
                }

                if (m_configurationNode != null)
                {
                    chooser.HandleAnyJump();
                }

                if (chooser.ChosenOne != null)
                {
                    AddItem(chooser.ChosenOne.Object);
                }
                else if (chooser.ChosenObjects != null)
                {
                    SetItems(chooser.ChosenObjects);
                }
            }

            //if the configuration file says that we should put up a message dialog after a change has been made,
            //do that now.
            if (postDialogMessageTrigger != null)
            {
                XCore.XMessageBoxExManager.Trigger(postDialogMessageTrigger);
            }
            // If the configuration file says to refresh the slice list, do that now.
            if (ChoicesMade != null)
            {
                ChoicesMade(this, new EventArgs());
            }
        }
コード例 #3
0
		private SimpleListChooser MakeChooserWithExtantSlots(bool fIsPrefixSlot)
		{
			int slotFlid;
			if (fIsPrefixSlot)
				slotFlid = MoInflAffixTemplateTags.kflidPrefixSlots;
			else
				slotFlid = MoInflAffixTemplateTags.kflidSuffixSlots;
			var labels = ObjectLabel.CreateObjectLabels(Cache, m_template.ReferenceTargetCandidates(slotFlid), null);
			PersistenceProvider persistProvider =
				new PersistenceProvider(m_mediator.PropertyTable);
			SimpleListChooser chooser = new SimpleListChooser(persistProvider, labels,
				m_ChooseSlotHelpTopic, m_mediator.HelpTopicProvider);
			chooser.SetHelpTopic("khtpChoose-Grammar-InflAffixTemplateControl");
			chooser.Cache = Cache;
			chooser.TextParamHvo = m_template.Owner.Hvo;
			chooser.Title = m_sSlotChooserTitle;
			chooser.InstructionalText = m_sSlotChooserInstructionalText;
			string sTopPOS;
			var pos = GetHighestPOS(m_template.OwnerOfClass<IPartOfSpeech>(), out sTopPOS);
			string sLabel = String.Format(m_sObligatorySlot, sTopPOS);
			chooser.AddLink(sLabel, SimpleListChooser.LinkType.kSimpleLink,
				new MakeInflAffixSlotChooserCommand(Cache, true, sLabel, pos.Hvo,
				false, m_mediator));
			sLabel = String.Format(m_sOptionalSlot, sTopPOS);
			chooser.AddLink(sLabel, SimpleListChooser.LinkType.kSimpleLink,
				new MakeInflAffixSlotChooserCommand(Cache, true, sLabel, pos.Hvo, true,
				m_mediator));
			chooser.SetObjectAndFlid(pos.Hvo, MoInflAffixTemplateTags.kflidSlots);
			return chooser;
		}
コード例 #4
0
		private SimpleListChooser MakeChooserWithExtantMsas(IMoInflAffixSlot slot, XCore.Command cmd)
		{
			// Want the list of all lex entries which have an infl affix Msa
			// Do not want to list the infl affix Msas that are already assigned to the slot.
			var candidates = new HashSet<ICmObject>();
			bool fIsPrefixSlot = m_template.PrefixSlotsRS.Contains(slot);
			foreach (var lex in slot.OtherInflectionalAffixLexEntries)
			{
				bool fInclude = EntryHasAffixThatMightBeInSlot(lex, fIsPrefixSlot);
				if (fInclude)
				{
					foreach (var msa in lex.MorphoSyntaxAnalysesOC)
					{
						if (msa is IMoInflAffMsa)
						{
							candidates.Add(msa);
							break;
						}
					}
				}
			}
			var labels = ObjectLabel.CreateObjectLabels(Cache, candidates.OrderBy(iafmsa => iafmsa.Owner.ShortName), null);
			XCore.PersistenceProvider persistProvider = new PersistenceProvider(m_mediator.PropertyTable);
			var aiForceMultipleChoices = new ICmObject[0];
			var chooser = new SimpleListChooser(persistProvider, labels,
				m_ChooseInflectionalAffixHelpTopic, Cache, aiForceMultipleChoices,
				m_mediator.HelpTopicProvider);
			chooser.SetHelpTopic("khtpChoose-Grammar-InflAffixTemplateControl");
			chooser.SetFontForDialog(new int[] { Cache.DefaultVernWs, Cache.DefaultAnalWs }, StyleSheet, WritingSystemFactory);
			chooser.Cache = Cache;
			// We don't want the ()'s indicating optionality since the text spells it out.
			chooser.TextParam = slot.Name.AnalysisDefaultWritingSystem.Text;
			chooser.Title = m_sInflAffixChooserTitle;
			if (slot.Optional)
				chooser.InstructionalText = m_sInflAffixChooserInstructionalTextOpt;
			else
				chooser.InstructionalText = m_sInflAffixChooserInstructionalTextReq;
			chooser.AddLink(m_sInflAffix, SimpleListChooser.LinkType.kDialogLink,
				new MakeInflAffixEntryChooserCommand(Cache, true, m_sInflAffix, fIsPrefixSlot, slot, m_mediator));
			chooser.SetObjectAndFlid(slot.Hvo, slot.OwningFlid);
			string sGuiControl = XmlUtils.GetOptionalAttributeValue(cmd.ConfigurationNode, "guicontrol");
			if (!String.IsNullOrEmpty(sGuiControl))
			{
				chooser.ReplaceTreeView(m_mediator, sGuiControl);
			}
			return chooser;
		}
コード例 #5
0
        protected override void HandleChooser()
        {
            // YAGNI: may eventually need to make configurable how it comes up with the list of candidates.
            // Currently this is used only for properties of a ghost notebook record.
            var candidateList = (ICmPossibilityList)ReferenceTargetServices.RnGenericRecReferenceTargetOwner(m_cache, m_flid);
            var candidates    = candidateList == null ? null : candidateList.PossibilitiesOS.Cast <ICmObject>();
            // YAGNI: see ReferenceLauncher implementation of this method for a possible approach to
            // making the choice of writing system configurable.
            var labels = ObjectLabel.CreateObjectLabels(m_cache, candidates,
                                                        m_displayNameProperty, "analysis vernacular");
            var chooser = new SimpleListChooser(m_persistProvider,
                                                labels,
                                                m_fieldName,
                                                m_cache,
                                                new ICmObject[0],
                                                m_mediator.HelpTopicProvider);

            chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());

            chooser.SetObjectAndFlid(0, m_flid);
            if (Slice.ConfigurationNode != null)
            {
                // Review JohnT: can any of this be made relevant without an object?
                //    // Handle the default case ("owner") for text parameters.

                //    // This (old approach) works only if
                //    // all of the list items are owned by the same object as the first one in the
                //    // list.  (Later elements can be owned by elements owned by that first owner,
                //    // if you know what I mean.)
                //    //if (candidates.Count != 0)
                //    //    chooser.TextParamHvo = m_cache.GetOwnerOfObject((int)candidates[0]);
                //    // JohnT: this approach depends on a new FDO method.
                //    ICmObject referenceTargetOwner = m_obj.ReferenceTargetOwner(m_flid);
                //    if (referenceTargetOwner != null)
                //        chooser.TextParamHvo = referenceTargetOwner.Hvo;
                //    chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
                chooser.InitializeExtras(Slice.ConfigurationNode, Mediator);
            }
            var res = chooser.ShowDialog(FindForm());

            if (DialogResult.Cancel == res)
            {
                return;
            }

            if (chooser.HandleAnyJump())
            {
                return;
            }

            if (chooser.ChosenObjects != null && chooser.ChosenObjects.Count() > 0)
            {
                UndoableUnitOfWorkHelper.Do(string.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                                            string.Format(DetailControlsStrings.ksRedoSet, m_fieldName), m_obj,
                                            () =>
                {
                    // YAGNI: creating the real object may eventually need to be configurable,
                    // perhaps by indicating in the configuration node what class of object to create
                    // and so forth, or perhaps by just putting a "doWhat" attribute on the configuration node
                    // and making a switch here to control what is done. For now this slice is only used
                    // in one situation, where we need to create a notebook record, associate the current object
                    // with it, and add the values to it.
                    ((IText)m_obj).AssociateWithNotebook(false);
                    IRnGenericRec notebookRec;
                    DataTree.NotebookRecordRefersToThisText(m_obj as IText, out notebookRec);
                    var recHvo   = notebookRec.Hvo;
                    var values   = (from obj in chooser.ChosenObjects select obj.Hvo).ToArray();
                    var listFlid = m_flid;
                    if (m_flid == RnGenericRecTags.kflidParticipants)
                    {
                        var defaultRoledParticipant = notebookRec.MakeDefaultRoledParticipant();
                        recHvo   = defaultRoledParticipant.Hvo;
                        listFlid = RnRoledParticTags.kflidParticipants;
                    }
                    m_cache.DomainDataByFlid.Replace(recHvo, listFlid, 0, 0, values, values.Length);
                    // We don't do anything about updating the display because creating the real object
                    // will typically destroy this slice altogether and replace it with a real one.
                });
                // Structure has changed drastically, start over.
                var index    = Slice.IndexInContainer;
                var dataTree = Slice.ContainingDataTree;
                dataTree.RefreshList(false);                 // Slice will be destroyed!!
                if (index <= dataTree.Slices.Count - 1)
                {
                    dataTree.CurrentSlice = dataTree.FieldAt(index);
                }
            }
        }
コード例 #6
0
		internal int DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, Set<int> candidates)
		{
			int hvo = 0;

			ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates);

			using (SimpleListChooser chooser = new SimpleListChooser(m_persistenceProvider, labels, fieldName))
			{
				chooser.Cache = m_cache;
				chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOAHvo;
				chooser.AddLink(linkText, SimpleListChooser.LinkType.kGotoLink,
					FwLink.Create(toolName, m_cache.GetGuidFromId(chooser.TextParamHvo), m_cache.ServerName,
					m_cache.DatabaseName));
				chooser.ReplaceTreeView(m_mediator, guiControl);
				if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.RegRuleFormulaControl)
					chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-RegRuleFormulaControl");
				else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl)
					chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-MetaRuleFormulaControl");
				else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl)
					chooser.SetHelpTopic("khtpChoose-LexiconEdit-PhonFeats-AffixRuleFormulaControl");

				DialogResult res = chooser.ShowDialog();
				if (res != DialogResult.Cancel)
				{
					chooser.HandleAnyJump();

					if (chooser.ChosenOne != null)
						hvo = chooser.ChosenOne.Hvo;
				}
			}

			return hvo;
		}
コード例 #7
0
		protected override void HandleChooser()
		{
			// YAGNI: may eventually need to make configurable how it comes up with the list of candidates.
			// Currently this is used only for properties of a ghost notebook record.
			var candidateList = (ICmPossibilityList) ReferenceTargetServices.RnGenericRecReferenceTargetOwner(m_cache, m_flid);
			var candidates = candidateList == null ? null : candidateList.PossibilitiesOS.Cast<ICmObject>();
			// YAGNI: see ReferenceLauncher implementation of this method for a possible approach to
			// making the choice of writing system configurable.
			var labels = ObjectLabel.CreateObjectLabels(m_cache, candidates,
				m_displayNameProperty, "analysis vernacular");
			var chooser = new SimpleListChooser(m_persistProvider,
				labels,
				m_fieldName,
				m_cache,
				new ICmObject[0],
				m_mediator.HelpTopicProvider);
			chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());

			chooser.SetObjectAndFlid(0, m_flid);
			if (Slice.ConfigurationNode != null)
			{
				// Review JohnT: can any of this be made relevant without an object?
				//    // Handle the default case ("owner") for text parameters.

				//    // This (old approach) works only if
				//    // all of the list items are owned by the same object as the first one in the
				//    // list.  (Later elements can be owned by elements owned by that first owner,
				//    // if you know what I mean.)
				//    //if (candidates.Count != 0)
				//    //    chooser.TextParamHvo = m_cache.GetOwnerOfObject((int)candidates[0]);
				//    // JohnT: this approach depends on a new FDO method.
				//    ICmObject referenceTargetOwner = m_obj.ReferenceTargetOwner(m_flid);
				//    if (referenceTargetOwner != null)
				//        chooser.TextParamHvo = referenceTargetOwner.Hvo;
				//    chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
				chooser.InitializeExtras(Slice.ConfigurationNode, Mediator);
			}
			var res = chooser.ShowDialog(FindForm());
			if (DialogResult.Cancel == res)
				return;

			if (chooser.HandleAnyJump())
				return;

			if (chooser.ChosenObjects != null && chooser.ChosenObjects.Count() > 0)
			{
				UndoableUnitOfWorkHelper.Do(string.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
				string.Format(DetailControlsStrings.ksRedoSet, m_fieldName), m_obj,
					() =>
					{
						// YAGNI: creating the real object may eventually need to be configurable,
						// perhaps by indicating in the configuration node what class of object to create
						// and so forth, or perhaps by just putting a "doWhat" attribute on the configuration node
						// and making a switch here to control what is done. For now this slice is only used
						// in one situation, where we need to create a notebook record, associate the current object
						// with it, and add the values to it.
						((IText)m_obj).AssociateWithNotebook(false);
						IRnGenericRec notebookRec;
						DataTree.NotebookRecordRefersToThisText(m_obj as IText, out notebookRec);
						var recHvo = notebookRec.Hvo;
						var values = (from obj in chooser.ChosenObjects select obj.Hvo).ToArray();
						var listFlid = m_flid;
						if (m_flid == RnGenericRecTags.kflidParticipants)
						{
							var defaultRoledParticipant = notebookRec.MakeDefaultRoledParticipant();
							recHvo = defaultRoledParticipant.Hvo;
							listFlid = RnRoledParticTags.kflidParticipants;
						}
						m_cache.DomainDataByFlid.Replace(recHvo, listFlid, 0, 0, values, values.Length);
						// We don't do anything about updating the display because creating the real object
						// will typically destroy this slice altogether and replace it with a real one.
					});
				// Structure has changed drastically, start over.
				var index = Slice.IndexInContainer;
				var dataTree = Slice.ContainingDataTree;
				dataTree.RefreshList(false); // Slice will be destroyed!!
				if (index <= dataTree.Slices.Count - 1)
					dataTree.CurrentSlice = dataTree.FieldAt(index);
			}
		}
コード例 #8
0
		public bool OnMergeReversalPOS(object cmd)
		{
			FdoCache cache = Cache;
			var labels = new List<ObjectLabel>();
			foreach (IPartOfSpeech pos in MergeOrMoveCandidates)
				labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos, "ShortNameTSS", "best analysis"));
			using (SimpleListChooser dlg = new SimpleListChooser(cache, null, m_mediator.HelpTopicProvider, labels, null,
				LexEdStrings.ksCategoryToMergeInto, null))
			{
				dlg.SetHelpTopic("khtpMergeCategories");
				if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
				{
					var currentPOS = POS;
					var survivor = (IPartOfSpeech)dlg.ChosenOne.Object;
					// Pass false to MergeObject, since we really don't want to merge the string info.
					UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMergeRevCategory,
						LexEdStrings.ksRedoMergeRevCategory, cache.ActionHandlerAccessor,
						()=> survivor.MergeObject(currentPOS, false));
					// Note: PropChanged should happen on the old owner and the new in the 'Add" method call.
					// Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories.
					m_mediator.BroadcastMessageUntilHandled("JumpToRecord", survivor.MainPossibility.Hvo);
				}
			}

			return true;
		}
コード例 #9
0
		protected ICmObject DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, IEnumerable<ICmObject> candidates)
		{
			ICmObject obj = null;

			IEnumerable<ObjectLabel> labels = ObjectLabel.CreateObjectLabels(m_cache, candidates);

			using (var chooser = new SimpleListChooser(m_persistProvider, labels, fieldName, m_mediator.HelpTopicProvider))
			{
				chooser.Cache = m_cache;
				chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOA.Hvo;
				Guid guidTextParam = m_cache.LangProject.PhonologicalDataOA.Guid;
				chooser.AddLink(linkText, ReallySimpleListChooser.LinkType.kGotoLink,
					new FwLinkArgs(toolName, guidTextParam));
				chooser.ReplaceTreeView(m_mediator, guiControl);
				chooser.SetHelpTopic(FeatureChooserHelpTopic);

				DialogResult res = chooser.ShowDialog();
				if (res != DialogResult.Cancel)
				{
					chooser.HandleAnyJump();

					if (chooser.ChosenOne != null)
						obj = chooser.ChosenOne.Object;
				}
			}

			return obj;
		}
コード例 #10
0
		/// <summary>
		/// Handle launching of the environment chooser.
		/// </summary>
		/// <remarks>
		/// Subclasses should override this method, if the SimpleListChooser is not suitable.
		/// </remarks>
		protected override void HandleChooser()
		{
			// get all valid environments
			var candidates = new HashSet<ICmObject>();
			foreach (var env in m_cache.LangProject.PhonologicalDataOA.EnvironmentsOS)
			{
				ConstraintFailure failure;
				if (env.CheckConstraints(PhEnvironmentTags.kflidStringRepresentation, false, out failure))
					candidates.Add(env);
			}

			string displayWs = "analysis vernacular";
			IPhEnvironment selectedEnv = null;
			if (m_configurationNode != null)
			{
				XmlNode node = m_configurationNode.SelectSingleNode("deParams");
				if (node != null)
					displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
			}

			var labels = ObjectLabel.CreateObjectLabels(m_cache, candidates.OrderBy(e => e.ShortName), null, displayWs);

			using (var chooser = new SimpleListChooser(m_persistProvider, labels,
				m_fieldName, m_mediator.HelpTopicProvider))
			{
				chooser.Cache = m_cache;
				chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOA.Hvo;
				chooser.SetHelpTopic(Slice.GetChooserHelpTopicID(Slice.HelpTopicID));
				chooser.InitializeExtras(m_configurationNode, m_mediator);

				DialogResult res = chooser.ShowDialog();
				if (res != DialogResult.Cancel)
				{
					chooser.HandleAnyJump();

					if (chooser.ChosenOne != null)
						selectedEnv = chooser.ChosenOne.Object as IPhEnvironment;
				}
			}

			// return focus to the view
			m_view.Select();
			if (selectedEnv != null)
			{
				int cellId = -1;
				UndoableUnitOfWorkHelper.Do(MEStrings.ksRuleUndoUpdateEnv, MEStrings.ksRuleRedoUpdateEnv, selectedEnv, () =>
				{
					cellId = UpdateEnvironment(selectedEnv);
				});

				ReconstructView(cellId, -1, true);
			}
		}
コード例 #11
0
		private void AddParticipants(object sender, EventArgs e)
		{
			var item = (ToolStripMenuItem) sender;
			var role = (ICmPossibility) item.Tag;
			string roleName = role.Name.BestAnalysisAlternative.Text;
			string displayWs = "analysis vernacular";
			if (m_configurationNode != null)
			{
				XmlNode node = m_configurationNode.SelectSingleNode("deParams");
				if (node != null)
					displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
			}
			IEnumerable<ObjectLabel> labels = ObjectLabel.CreateObjectLabels(m_cache, m_cache.LanguageProject.PeopleOA.PossibilitiesOS,
				DisplayNameProperty, displayWs);

			using (var chooser = new SimpleListChooser(m_persistenceProvider, labels, m_fieldName,
				m_cache, null, m_mediator.HelpTopicProvider))
			{
				chooser.TextParamHvo = m_cache.LanguageProject.PeopleOA.Hvo;
				chooser.SetHelpTopic(GetChooserHelpTopicID());
				if (m_configurationNode != null)
					chooser.InitializeExtras(m_configurationNode, Mediator);

				DialogResult res = chooser.ShowDialog();
				if (DialogResult.Cancel == res)
					return;

				if (m_configurationNode != null)
					chooser.HandleAnyJump();

				if (chooser.ChosenObjects != null)
				{
					IRnRoledPartic roledPartic = null;
					UndoableUnitOfWorkHelper.Do(string.Format(LexEdStrings.ksUndoAddParticipants, roleName),
						string.Format(LexEdStrings.ksRedoAddParticipants, roleName), role, () =>
					{
						roledPartic = m_cache.ServiceLocator.GetInstance<IRnRoledParticFactory>().Create();
						Record.ParticipantsOC.Add(roledPartic);
						roledPartic.RoleRA = role;
						foreach (ICmPerson person in chooser.ChosenObjects)
							roledPartic.ParticipantsRC.Add(person);
					});
					ExpandNewNode(roledPartic);
				}
			}
		}