public void EssentiallyEquals_ThisTagZeroLength()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("myTool", newGuid, string.Empty);

            Assert.IsTrue(args1.EssentiallyEquals(new FwLinkArgs("myTool", newGuid, "myTag")));
        }
        public void Equals_NullParameter()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("myTool", newGuid, "myTag");

            Assert.IsFalse(args1.Equals(null));
        }
        public void Equals_ExactlyTheSame()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("myTool", newGuid, "myTag");

            Assert.IsTrue(args1.Equals(new FwLinkArgs("myTool", newGuid, "myTag")));
        }
        public void Equals_SameObject()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("myTool", newGuid, "myTag");

            Assert.IsTrue(args1.Equals(args1));
        }
        public void Equals_DifferByToolName()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("myTool", newGuid, "myTag");

            Assert.IsFalse(args1.Equals(new FwLinkArgs("myOtherTool", newGuid, "myTag")));
        }
Exemple #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Copy the link-related information to a new FwLinkArgs. Currently this does NOT
        /// yield an FwAppArgs even if the recipient is one.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public FwLinkArgs CopyLinkArgs()
        {
            FwLinkArgs result = new FwLinkArgs(m_toolName, TargetGuid, m_tag);

            result.m_propertyTableEntries.AddRange(m_propertyTableEntries);
            return(result);
        }
        public void Equals_TagOfArgumentZeroLength()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("myTool", newGuid, "myTag");

            Assert.IsFalse(args1.Equals(new FwLinkArgs("myTool", newGuid, string.Empty)));
        }
        public void Equals_ToolNameDiffersByCase()
        {
            Guid       newGuid = Guid.NewGuid();
            FwLinkArgs args1   = new FwLinkArgs("MyTool", newGuid, "myTag");

            Assert.IsFalse(args1.Equals(new FwLinkArgs("mytool", newGuid, "myTag")));
        }
Exemple #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Some comparisons don't care about the content of the property table, so we provide a
        /// method similar to Equals but not quite as demanding.
        /// </summary>
        /// <param name="lnk">The link to compare.</param>
        /// ------------------------------------------------------------------------------------
        public override bool EssentiallyEquals(FwLinkArgs lnk)
        {
            FwAppArgs appArgs = lnk as FwAppArgs;

            if (appArgs == null || !base.EssentiallyEquals(lnk))
            {
                return(false);
            }
            return(appArgs.Database == Database);
        }
Exemple #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="T:System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        /// ------------------------------------------------------------------------------------
        public override bool Equals(object obj)
        {
            FwLinkArgs link = obj as FwLinkArgs;

            if (link == null)
            {
                return(false);
            }
            if (link == this)
            {
                return(true);
            }
            //just compare the URLs
            return(ToString() == link.ToString());
        }
Exemple #11
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Some comparisons don't care about the content of the property table, so we provide a
 /// method similar to Equals but not quite as demanding.
 /// </summary>
 /// <param name="lnk">The link to compare.</param>
 /// ------------------------------------------------------------------------------------
 public virtual bool EssentiallyEquals(FwLinkArgs lnk)
 {
     if (lnk == null)
     {
         return(false);
     }
     if (lnk == this)
     {
         return(true);
     }
     if (lnk.ToolName != ToolName)
     {
         return(false);
     }
     if (lnk.TargetGuid != TargetGuid)
     {
         return(false);
     }
     // tag is optional, but if a tool uses it with content, it should consistently provide content.
     // therefore if one of these links does not have content, and the other does then
     // we'll assume they refer to the same link
     // (one link simply comes from a control with more knowledge then the other one)
     return(lnk.Tag.Length == 0 || Tag.Length == 0 || lnk.Tag == Tag);
 }
Exemple #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Applications should override this method to handle incoming links. This method is
		/// called from FieldWorks when a link is requested. It is guaranteed to be on the
		/// correct thread (the thread this application is on) so invoking should not be needed.
		/// Overridden in FwXApp.
		/// See the class comment on FwLinkArgs for details on how all the parts of hyperlinking work.
		/// </summary>
		/// <param name="link">The link to handle.</param>
		/// ------------------------------------------------------------------------------------
		public virtual void HandleIncomingLink(FwLinkArgs link)
		{
			throw new NotImplementedException();
		}
		private static void ListNewPossibilities(StreamWriter writer, string sMsg,
			List<ICmPossibility> list, string tool)
		{
			if (list.Count > 0)
			{
				tool = null;		// FIXME when FwLink starts working again...
				writer.WriteLine("<h3>{0}</h3>", String.Format(sMsg, list.Count));
				writer.WriteLine("<ul>");
				foreach (ICmPossibility poss in list)
				{
					if (String.IsNullOrEmpty(tool))
					{
						writer.WriteLine("<li>{0}</li>", poss.AbbrAndName);
					}
					else
					{
						FwLinkArgs link = new FwLinkArgs(tool, poss.Guid);
						string href = link.ToString();
						writer.WriteLine("<li><a href=\"{0}\">{1}</a></li>", href, poss.AbbrAndName);
					}
				}
				writer.WriteLine("</ul>");
			}
		}
Exemple #14
0
		public void Equals_ExactlyTheSame()
		{
			Guid newGuid = Guid.NewGuid();
			FwLinkArgs args1 = new FwLinkArgs("myTool", newGuid, "myTag");
			Assert.IsTrue(args1.Equals(new FwLinkArgs("myTool", newGuid, "myTag")));
		}
        public void EssentiallyEquals_DiffereByGuid()
        {
            FwLinkArgs args1 = new FwLinkArgs("myTool", Guid.NewGuid(), "myTag");

            Assert.IsFalse(args1.EssentiallyEquals(new FwLinkArgs("myTool", Guid.NewGuid(), "myTag")));
        }
Exemple #16
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 virtual void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (m_isDisposed)
                return;

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_mediator != null)
                {
                    m_mediator.RemoveColleague(this);
                    m_mediator.PropertyTable.SetProperty("LinkListener", null, false);
                    m_mediator.PropertyTable.SetPropertyPersistence("LinkListener", false);
                }
                if (m_backStack != null)
                    m_backStack.Clear();
                if (m_forwardStack != null)
                    m_forwardStack.Clear();
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mediator = null;
            m_currentContext = null;
            m_backStack = null;
            m_forwardStack = null;

            m_isDisposed = true;
        }
Exemple #17
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkListener"/> class.
 /// </summary>
 /// -----------------------------------------------------------------------------------
 public LinkListener()
 {
     m_backStack = new LinkedList<FwLinkArgs>();
     m_forwardStack = new LinkedList<FwLinkArgs>();
     m_currentContext = null;
 }
Exemple #18
0
		public void Equals_SameObject()
		{
			Guid newGuid = Guid.NewGuid();
			FwLinkArgs args1 = new FwLinkArgs("myTool", newGuid, "myTag");
			Assert.IsTrue(args1.Equals(args1));
		}
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool OnHistoryBack(object unused)
        {
            CheckDisposed();

            if (m_backStack.Count > 0)
            {
                if (m_currentContext!= null)
                {
                    Push(m_forwardStack, m_currentContext);
                }
                m_fUsingHistory = true;
                m_lnkActive = Pop(m_backStack);
                FollowActiveLink();
            }

            return true;
        }
Exemple #20
0
		public void Equals_DifferByToolName()
		{
			Guid newGuid = Guid.NewGuid();
			FwLinkArgs args1 = new FwLinkArgs("myTool", newGuid, "myTag");
			Assert.IsFalse(args1.Equals(new FwLinkArgs("myOtherTool", newGuid, "myTag")));
		}
Exemple #21
0
		public void Equals_NullParameter()
		{
			Guid newGuid = Guid.NewGuid();
			FwLinkArgs args1 = new FwLinkArgs("myTool", newGuid, "myTag");
			Assert.IsFalse(args1.Equals(null));
		}
Exemple #22
0
		public void Equals_ToolNameDiffersByCase()
		{
			Guid newGuid = Guid.NewGuid();
			FwLinkArgs args1 = new FwLinkArgs("MyTool", newGuid, "myTag");
			Assert.IsFalse(args1.Equals(new FwLinkArgs("mytool", newGuid, "myTag")));
		}
Exemple #23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy the link-related information to a new FwLinkArgs. Currently this does NOT
		/// yield an FwAppArgs even if the recipient is one.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FwLinkArgs CopyLinkArgs()
		{
			FwLinkArgs result = new FwLinkArgs(m_toolName, TargetGuid, m_tag);
			result.m_propertyTableEntries.AddRange(m_propertyTableEntries);
			return result;
		}
Exemple #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Some comparisons don't care about the content of the property table, so we provide a
		/// method similar to Equals but not quite as demanding.
		/// </summary>
		/// <param name="lnk">The link to compare.</param>
		/// ------------------------------------------------------------------------------------
		public virtual bool EssentiallyEquals(FwLinkArgs lnk)
		{
			if (lnk == null)
				return false;
			if (lnk == this)
				return true;
			if (lnk.ToolName != ToolName)
				return false;
			if (lnk.TargetGuid != TargetGuid)
				return false;
			// tag is optional, but if a tool uses it with content, it should consistently provide content.
			// therefore if one of these links does not have content, and the other does then
			// we'll assume they refer to the same link
			// (one link simply comes from a control with more knowledge then the other one)
			return lnk.Tag.Length == 0 || Tag.Length == 0 || lnk.Tag == Tag;
		}
Exemple #25
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool OnAddContextToHistory(object _link)
        {
            CheckDisposed();

            //Debug.WriteLineIf(RuntimeSwitches.linkListenerSwitch.TraceInfo, "OnAddContextToHistory(" + m_currentContext + ")", RuntimeSwitches.linkListenerSwitch.DisplayName);
            FwLinkArgs lnk = (FwLinkArgs)_link;
            if (lnk.EssentiallyEquals(m_currentContext))
            {
                //Debug.WriteLineIf(RuntimeSwitches.linkListenerSwitch.TraceInfo, "   Link equals current context.", RuntimeSwitches.linkListenerSwitch.DisplayName);
                return true;
            }
            if (m_currentContext != null &&
                //not where we just came from via a "Back" call
                ((m_forwardStack.Count == 0) || (m_currentContext != m_forwardStack.Last.Value)))
            {
                //Debug.WriteLineIf(RuntimeSwitches.linkListenerSwitch.TraceInfo, "  Pushing current to back: " + m_currentContext, RuntimeSwitches.linkListenerSwitch.DisplayName);
                Push(m_backStack, m_currentContext);
            }
            // Try to omit intermediate targets which are added to the stack when switching
            // tools.  This doesn't work in OnFollowLink() because the behavior of following
            // the link is not synchronous even when SendMessage is used at the first two
            // levels of handling.
            if (m_fFollowingLink && lnk.EssentiallyEquals(m_lnkActive))
            {
                int howManyAdded = m_backStack.Count - m_cBackStackOrig;
                for( ; howManyAdded > 1; --howManyAdded)
                {
                    m_backStack.RemoveLast();
                }
                m_fFollowingLink = false;
                m_cBackStackOrig = 0;
                m_lnkActive = null;
            }
            // The forward stack should be cleared by jump operations that are NOT spawned by
            // a Back or Forward (ie, history) operation.  This is the standard behavior in
            // browsers, for example (as far as I know).
            if (m_fUsingHistory)
            {
                if (lnk.EssentiallyEquals(m_lnkActive))
                {
                    m_fUsingHistory = false;
                    m_lnkActive = null;
                }
            }
            else
            {
                m_forwardStack.Clear();
            }

            m_currentContext = lnk;
            return true;
        }
		protected override void HandleChooser()
		{
			VectorReferenceLauncher vrl = null;
			using (FeatureSystemInflectionFeatureListDlg dlg = new FeatureSystemInflectionFeatureListDlg())
			{
				IFsFeatStruc originalFs = m_obj as IFsFeatStruc;

				Slice parentSlice = Slice;
				if (originalFs == null)
				{
					int owningFlid;
					ILexEntryInflType leit = parentSlice.Object as ILexEntryInflType;
					owningFlid = (parentSlice as FeatureSystemInflectionFeatureListDlgLauncherSlice).Flid;
					dlg.SetDlgInfo(m_cache, m_mediator, leit, owningFlid);
				}
				else
				{
					dlg.SetDlgInfo(m_cache, m_mediator, originalFs,
						(parentSlice as FeatureSystemInflectionFeatureListDlgLauncherSlice).Flid);
				}

				const string ksPath = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='FeatureChooser']/";
				dlg.Text = m_mediator.StringTbl.GetStringWithXPath("InflectionFeatureTitle", ksPath);
				dlg.Prompt = m_mediator.StringTbl.GetStringWithXPath("InflectionFeaturesPrompt", ksPath);
				dlg.LinkText = m_mediator.StringTbl.GetStringWithXPath("InflectionFeaturesLink", ksPath);
				DialogResult result = dlg.ShowDialog(parentSlice.FindForm());
				if (result == DialogResult.OK)
				{
					if (dlg.FS != null)
						m_obj = dlg.FS;
					m_msaInflectionFeatureListDlgLauncherView.Init(m_mediator, dlg.FS);
				}
				else if (result == DialogResult.Yes)
				{
					/*
										// Get the VectorReferenceLauncher for the Inflection Features slice.
										// Since we're not changing tools, we want to change the chooser dialog.
										// See LT-5913 for motivation.
										Control ctl = this.Parent;
										while (ctl != null && !(ctl is Slice))
											ctl = ctl.Parent;
										Slice slice = ctl as Slice;
										if (slice != null)
										{
											DataTree dt = slice.ContainingDataTree;
											for (int i = 0; i < dt.Slices.Count; ++i)
											{
												Slice sliceT = dt.FieldOrDummyAt(i);
												vrl = sliceT.Control as VectorReferenceLauncher;
												if (vrl != null)
												{
													if (vrl.Flid == PartOfSpeechTags.kflidInflectableFeats)
														break;
													vrl = null;
												}
											}
										}
										if (vrl == null)
										{
											// We do, too, need to change tools! Sometimes this slice shows up in a different context,
											// such as the main data entry view. See LT-7167.
											// go to m_highestPOS in editor
											// TODO: this should be reviewed by someone who knows how these links should be done
											// I'm just guessing.
											// Also, is there some way to know the application name and tool name without hard coding them?
					*/
					var linkJump = new FwLinkArgs("featuresAdvancedEdit", m_cache.LanguageProject.MsFeatureSystemOA.Guid);
					m_mediator.PostMessage("FollowLink", linkJump);
					/*}
					else
					{
						vrl.HandleExternalChooser();
					}*/
				}
			}
		}
Exemple #27
0
        /// <summary>
        /// NOTE: This will not handle link requests for other databases/applications. To handle other
        /// databases or applications, pass a FwAppArgs to the IFieldWorksManager.HandleLinkRequest method.
        /// </summary>
        /// <returns></returns>
        public bool OnFollowLink(object lnk)
        {
            CheckDisposed();

            m_fFollowingLink = true;
            m_cBackStackOrig = m_backStack.Count;
            m_lnkActive = lnk as FwLinkArgs;

            return FollowActiveLink();
        }
		private void btnAdd_Click(object sender, EventArgs e)
		{
			// Get the checked occurrences;
			List<int> occurrences = m_rbv.CheckedItems;
			if (occurrences == null || occurrences.Count == 0)
			{
				// do nothing.
				return;
			}
			List<int> uniqueSegments =
				(from fake in occurrences
				 select m_clerk.VirtualListPublisher.get_ObjectProp(fake, ConcDecorator.kflidSegment)).Distinct().ToList
					();
			int insertIndex = m_owningSense.ExamplesOS.Count; // by default, insert at the end.
			if (m_les != null)
			{
				// we were given a LexExampleSentence, so set our insertion index after the given one.
				insertIndex = m_owningSense.ExamplesOS.IndexOf(m_les) + 1;
			}

			UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoAddExamples, LexEdStrings.ksRedoAddExamples,
				m_cache.ActionHandlerAccessor,
				() =>
					{
						int cNewExamples = 0;
						ILexExampleSentence newLexExample = null;
						foreach (int segHvo in uniqueSegments)
						{
							var seg = m_cache.ServiceLocator.GetObject(segHvo) as ISegment;
							if (cNewExamples == 0 && m_les != null &&
								m_les.Example.BestVernacularAlternative.Text == "***" &&
								(m_les.TranslationsOC == null || m_les.TranslationsOC.Count == 0) &&
								m_les.Reference.Length == 0)
							{
								// we were given an empty LexExampleSentence, so use this one for our first new Example.
								newLexExample = m_les;
							}
							else
							{
								// create a new example sentence.
								newLexExample =
									m_cache.ServiceLocator.GetInstance<ILexExampleSentenceFactory>().Create();
								m_owningSense.ExamplesOS.Insert(insertIndex + cNewExamples, newLexExample);
								cNewExamples++;
							}
							// copy the segment string into the new LexExampleSentence
							// Enhance: bold the relevant occurrence(s).
							newLexExample.Example.VernacularDefaultWritingSystem = seg.BaselineText;
							if (seg.FreeTranslation.AvailableWritingSystemIds.Length > 0)
							{
								var trans = m_cache.ServiceLocator.GetInstance<ICmTranslationFactory>().Create(newLexExample,
									m_cache.ServiceLocator.GetInstance<ICmPossibilityRepository>().GetObject(
										CmPossibilityTags.kguidTranFreeTranslation));
								trans.Translation.CopyAlternatives(seg.FreeTranslation);
							}
							if (seg.LiteralTranslation.AvailableWritingSystemIds.Length > 0)
							{
								var trans = m_cache.ServiceLocator.GetInstance<ICmTranslationFactory>().Create(newLexExample,
									m_cache.ServiceLocator.GetInstance<ICmPossibilityRepository>().GetObject(
										CmPossibilityTags.kguidTranLiteralTranslation));
								trans.Translation.CopyAlternatives(seg.LiteralTranslation);
							}
						   // copy the reference.
							ITsString tssRef = seg.Paragraph.Reference(seg, seg.BeginOffset);
							// convert the plain reference string into a link.
							ITsStrBldr tsb = tssRef.GetBldr();
							FwLinkArgs fwl = new FwLinkArgs("interlinearEdit", seg.Owner.Owner.Guid);
							// It's not clear how to focus in on something smaller than the text when following
							// a link.
							//fwl.PropertyTableEntries.Add(new Property("LinkSegmentGuid", seg.Guid.ToString()));
							tsb.SetStrPropValue(0, tsb.Length, (int)FwTextPropType.ktptObjData,
								(char)FwObjDataTypes.kodtExternalPathName + fwl.ToString());
							tsb.SetStrPropValue(0, tsb.Length, (int)FwTextPropType.ktptNamedStyle,
								"Hyperlink");
							newLexExample.Reference = tsb.GetString();
						}
					});
		}
Exemple #29
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool OnHistoryForward(object unused)
        {
            CheckDisposed();

            if (m_forwardStack.Count > 0)
            {
                m_fUsingHistory = true;
                m_lnkActive = Pop(m_forwardStack);
                FollowActiveLink();
            }
            return true;
        }
Exemple #30
0
		public void EssentiallyEquals_ThisTagZeroLength()
		{
			Guid newGuid = Guid.NewGuid();
			FwLinkArgs args1 = new FwLinkArgs("myTool", newGuid, string.Empty);
			Assert.IsTrue(args1.EssentiallyEquals(new FwLinkArgs("myTool", newGuid, "myTag")));
		}
Exemple #31
0
        private bool FollowActiveLink()
        {
            try
            {
                //Debug.Assert(!(m_lnkActive is FwAppArgs), "Beware: This will not handle link requests for other databases/applications." +
                //	" To handle other databases or applications, pass the FwAppArgs to the IFieldWorksManager.HandleLinkRequest method.");
                if (m_lnkActive.ToolName == "default")
                {
                    // Need some smarts here. The link creator was not sure what tool to use.
                    // The object may also be a child we don't know how to jump to directly.
                    var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                    ICmObject target;
                    if (!cache.ServiceLocator.ObjectRepository.TryGetObject(m_lnkActive.TargetGuid, out target))
                        return false; // or message?
                    var realTarget = GetObjectToShowInTool(target);
                    string realTool;
                    var majorObject = realTarget.Owner ?? realTarget;
                    var app = FwUtils.ksFlexAbbrev;
                    switch (majorObject.ClassID)
                    {
                        case ReversalIndexTags.kClassId:
                            realTool = "reversalToolEditComplete";
                            break;
                        case TextTags.kClassId:
                            realTool = "interlinearEdit";
                            break;
                        case LexEntryTags.kClassId:
                            realTool = "lexiconEdit";
                            break;
                        case ScriptureTags.kClassId:
                            ShowCantJumpMessage(xWorksStrings.ksCantJumpToScripture);
                            return false; // Todo: don't know how to handle this yet.
                            //app = FwUtils.ksTeAbbrev;
                            //realTool = "reversalToolEditComplete";
                            //break;
                        case CmPossibilityListTags.kClassId:
                            // The area listener knows about the possible list tools.
                            // Unfortunately AreaListener is in an assembly we can't reference.
                            // But there may be custom ones, so just listing them all here does not seem to be an option,
                            // and anyway it would be hard to maintain.
                            // Thus we've created this method (on AreaListener) which we call awkwardly throught the mediator.
                            var parameters = new object[2];
                            parameters[0] = majorObject;
                            m_mediator.SendMessage("GetToolForList", parameters);
                            realTool = (string)parameters[1];
                            break;
                        case RnResearchNbkTags.kClassId:
                            realTool = "notebookEdit";
                            break;
                        case DsConstChartTags.kClassId:
                            realTarget = ((IDsConstChart) majorObject).BasedOnRA;
                            realTool = "interlinearEdit";
                            // Enhance JohnT: do something to make it switch to Discourse tab
                            break;
                        case LexDbTags.kClassId: // other things owned by this??
                        case LangProjectTags.kClassId:
                            ShowCantJumpMessage(xWorksStrings.ksCantJumpToLangProj);
                            return false;
                        default:
                            var msg = string.Format(xWorksStrings.ksCantJumpToObject,
                                cache.MetaDataCacheAccessor.GetClassName(majorObject.ClassID));
                            ShowCantJumpMessage(msg);
                            return false; // can't jump to it.
                    }
                    m_lnkActive = new FwLinkArgs(realTool, realTarget.Guid);
                    // Todo JohnT: need to do something special here if we c
                }
                // It's important to do this AFTER we set the real tool name if it is "default". Otherwise, the code that
                // handles the jump never realizes we have reached the desired tool (as indicated by the value of
                // SuspendLoadingRecordUntilOnJumpToRecord) and we stop recording context history and various similar problems.
                if (m_lnkActive.TargetGuid != Guid.Empty)
                {
                    // allow tools to skip loading a record if we're planning to jump to one.
                    // interested tools will need to reset this "JumpToRecord" property after handling OnJumpToRecord.
                    m_mediator.PropertyTable.SetProperty("SuspendLoadingRecordUntilOnJumpToRecord",
                        m_lnkActive.ToolName + "," + m_lnkActive.TargetGuid.ToString(),
                        PropertyTable.SettingsGroup.LocalSettings);
                    m_mediator.PropertyTable.SetPropertyPersistence("SuspendLoadingRecordUntilOnJumpToRecord", false);
                }
                m_mediator.SendMessage("SetToolFromName", m_lnkActive.ToolName);
                // Note: It can be Guid.Empty in cases where it was never set,
                // or more likely, when the HVO was set to -1.
                if (m_lnkActive.TargetGuid != Guid.Empty)
                {
                    FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                    ICmObject obj = cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(m_lnkActive.TargetGuid);
                    if (obj is IReversalIndexEntry && m_lnkActive.ToolName == "reversalToolEditComplete")
                    {
                        // For the reversal index tool, just getting the tool right isn't enough.  We
                        // also need to be showing the proper index.  (See FWR-1105.)
                        var guid = ReversalIndexEntryUi.GetObjectGuidIfValid(m_mediator, "ReversalIndexGuid");
                        if (!guid.Equals(obj.Owner.Guid))
                            m_mediator.PropertyTable.SetProperty("ReversalIndexGuid", obj.Owner.Guid.ToString());
                    }
                    // Allow this to happen after the processing of the tool change above by using the Broadcast
                    // method on the mediator, the SendMessage would process it before the above msg and it would
                    // use the wrong RecordList.  (LT-3260)
                    m_mediator.BroadcastMessageUntilHandled("JumpToRecord", obj.Hvo);
                }

                foreach (Property property in m_lnkActive.PropertyTableEntries)
                {
                    m_mediator.PropertyTable.SetProperty(property.name, property.value);
                    //TODO: I can't think at the moment of what to do about setting
                    //the persistence or ownership of the property...at the moment the only values we're putting
                    //in there are strings or bools
                }
                m_mediator.BroadcastMessageUntilHandled("LinkFollowed", m_lnkActive);
            }
            catch(Exception err)
            {
                string s;
                if (err.InnerException != null && !string.IsNullOrEmpty(err.InnerException.Message))
                    s = String.Format(xWorksStrings.UnableToFollowLink0, err.InnerException.Message);
                else
                    s = xWorksStrings.UnableToFollowLink;
                MessageBox.Show(s, xWorksStrings.FailedJump, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                return false;
            }
            return true;	//we handled this.
        }
Exemple #32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Attempt to show the most appropriate passage for the object indicated in the link.
		/// </summary>
		/// <param name="link"></param>
		/// ------------------------------------------------------------------------------------
		public override void HandleIncomingLink(FwLinkArgs link)
		{
			ICmObject target;
			if (!Cache.ServiceLocator.ObjectRepository.TryGetObject(link.TargetGuid, out target))
				return; // can't even get the target object!

			var targetRef = GetTargetRef(target);
			if (targetRef == null)
				return; // don't know how to go there yet.

			var mainWnd = this.ActiveMainWindow as TeMainWnd;
			if (mainWnd == null)
			{
				throw new Exception("life stinks");
			}
			mainWnd.GotoVerse(targetRef);
		}
Exemple #33
0
 private void Push(LinkedList<FwLinkArgs> stack, FwLinkArgs context)
 {
     stack.AddLast(context);
     while (stack.Count > kmaxDepth)
         stack.RemoveFirst();
 }
Exemple #34
0
		internal string LinkRef(int hvo)
		{
			ICmObjectRepository repo = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
			if (!repo.IsValidObjectId(hvo))
				return null;
			Guid guid = repo.GetObject(hvo).Guid;
			FwLinkArgs link = new FwLinkArgs("lexiconEdit", guid);
			return link.ToString();
		}
		private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			Guid guid = m_cache.LangProject.PhFeatureSystemOA.Guid;
			m_link = new FwLinkArgs("phonologicalFeaturesAdvancedEdit", guid);
			m_btnCancel.PerformClick();
			DialogResult = DialogResult.Ignore;
		}
Exemple #36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Some comparisons don't care about the content of the property table, so we provide a
		/// method similar to Equals but not quite as demanding.
		/// </summary>
		/// <param name="lnk">The link to compare.</param>
		/// ------------------------------------------------------------------------------------
		public override bool EssentiallyEquals(FwLinkArgs lnk)
		{
			FwAppArgs appArgs = lnk as FwAppArgs;
			if (appArgs == null || !base.EssentiallyEquals(lnk))
				return false;
			return (appArgs.AppAbbrev == AppAbbrev && appArgs.Database == Database &&
				appArgs.Server == Server);
		}
Exemple #37
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Construct a new form
		/// </summary>
		/// <param name="app">The app.</param>
		/// <param name="wndCopyFrom">Source window to copy from</param>
		/// <param name="iconStream">The icon stream.</param>
		/// <param name="configFile">The config file.</param>
		/// <param name="startupLink">The link to follow once the window is initialized.</param>
		/// <param name="inAutomatedTest">if set to <c>true</c>, (well behaved) code will avoid
		/// bringing up dialogs that we cannot respond to (like confirmation and error dialogs)
		/// and it should cause the system to avoid saving the settings to a file (or at least
		/// saving them in some special way so as not to mess up the user.)</param>
		/// ------------------------------------------------------------------------------------
		public FwXWindow(FwApp app, Form wndCopyFrom, Stream iconStream,
			string configFile, FwLinkArgs startupLink, bool inAutomatedTest)
		{
			BasicInit(app);
			m_startupLink = startupLink;

			Debug.Assert(File.Exists(configFile));
			m_app = app;
			m_configFile = configFile;

			Init(iconStream, wndCopyFrom, app.Cache);
			if(inAutomatedTest)
			{
				Mediator.PropertyTable.SetProperty("DoingAutomatedTest", true);
				Mediator.PropertyTable.SetPropertyPersistence("DoingAutomatedTest", false);
			}

			// The order of the next two lines has been changed because the loading of the UI
			// properly depends on m_viewHelper being initialized.  Why this was not so with DNB
			// I do not know.
			// Here is the orginal order (along with a comment between them that seemed to imply this
			// new order could be a problem, but no obvious ones have appeared in my testing.

		   /*
			* LoadUI(configFile);
			* // Reload additional property settings that depend on knowing the database name.
			* m_viewHelper = new ActiveViewHelper(this);
			*/

			m_viewHelper = new ActiveViewHelper(this);
			LoadUI(configFile);

			m_viewHelper.ActiveViewChanged += new EventHandler<EventArgs>(ActiveViewChanged);
		}
Exemple #38
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the TeMainWnd class
		/// </summary>
		/// <param name="app"></param>
		/// <param name="wndCopyFrom"></param>
		/// <param name="startupLink">Optional link to jump to in OnFinishedInit</param>
		/// -----------------------------------------------------------------------------------
		public TeMainWnd(FwApp app, Form wndCopyFrom, FwLinkArgs startupLink)
			: base(app, wndCopyFrom)
		{
			m_startupLink = startupLink;
			Init();
		}
		/// <summary>
		/// Handle launching of the MSA editor.
		/// </summary>
		protected override void HandleChooser()
		{
			VectorReferenceLauncher vrl = null;
			using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
			{
				IFsFeatStruc originalFs = m_obj as IFsFeatStruc;

				Slice parentSlice = Slice;
				if (originalFs == null)
				{
					int owningFlid;
					int parentSliceClass = (int)parentSlice.Object.ClassID;
					switch (parentSliceClass)
					{
						case MoAffixAllomorphTags.kClassId:
							IMoAffixAllomorph allo = parentSlice.Object as IMoAffixAllomorph;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, allo, owningFlid);
							break;
						/*case LexEntryInflTypeTags.kClassId:
							ILexEntryInflType leit = parentSlice.Object as ILexEntryInflType;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, leit, owningFlid);
							break;*/
						default:
							IMoMorphSynAnalysis msa = parentSlice.Object as IMoMorphSynAnalysis;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, msa, owningFlid);
							break;
					}
				}
				else
				{
					dlg.SetDlgInfo(m_cache, m_mediator, originalFs,
						(parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid);
				}

				const string ksPath = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='FeatureChooser']/";
				dlg.Text = m_mediator.StringTbl.GetStringWithXPath("InflectionFeatureTitle", ksPath);
				dlg.Prompt = m_mediator.StringTbl.GetStringWithXPath("InflectionFeaturePrompt", ksPath);
				dlg.LinkText = m_mediator.StringTbl.GetStringWithXPath("InflectionFeatureLink", ksPath);
				DialogResult result = dlg.ShowDialog(parentSlice.FindForm());
				if (result == DialogResult.OK)
				{
					// Note that this may set m_obj to null. dlg.FS will be null if all inflection features have been
					// removed. That is a valid state for this slice; m_obj deleted is not.
					m_obj = dlg.FS;
					m_msaInflectionFeatureListDlgLauncherView.Init(m_mediator, dlg.FS);
				}
				else if (result == DialogResult.Yes)
				{
					// Get the VectorReferenceLauncher for the Inflection Features slice.
					// Since we're not changing tools, we want to change the chooser dialog.
					// See LT-5913 for motivation.
					Control ctl = this.Parent;
					while (ctl != null && !(ctl is Slice))
						ctl = ctl.Parent;
					Slice slice = ctl as Slice;
					if (slice != null)
					{
						DataTree dt = slice.ContainingDataTree;
						for (int i = 0; i < dt.Slices.Count; ++i)
						{
							Slice sliceT = dt.FieldOrDummyAt(i);
							vrl = sliceT.Control as VectorReferenceLauncher;
							if (vrl != null)
							{
								if (vrl.Flid == PartOfSpeechTags.kflidInflectableFeats)
									break;
								vrl = null;
							}
						}
					}
					if (vrl == null)
					{
						// We do, too, need to change tools! Sometimes this slice shows up in a different context,
						// such as the main data entry view. See LT-7167.
						// go to m_highestPOS in editor
						// TODO: this should be reviewed by someone who knows how these links should be done
						// I'm just guessing.
						// Also, is there some way to know the application name and tool name without hard coding them?
						var linkJump = new FwLinkArgs("posEdit", dlg.HighestPOS.Guid);
						m_mediator.PostMessage("FollowLink", linkJump);
					}
					else
					{
						vrl.HandleExternalChooser();
					}
				}
			}
		}
Exemple #40
0
		public virtual bool OnJumpToTool(object commandObject)
		{
			XCore.Command cmd = (XCore.Command)commandObject;
			string tool = SIL.Utils.XmlUtils.GetManditoryAttributeValue(cmd.Parameters[0], "tool");
			string className = SIL.Utils.XmlUtils.GetManditoryAttributeValue(cmd.Parameters[0], "className");
			string concordOn = SIL.Utils.XmlUtils.GetOptionalAttributeValue(cmd.Parameters[0], "concordOn", "");

			if (CurrentAnalysisTree.Analysis != null)
			{
				// If the user selects a concordance on gloss or analysis, we want the current one,
				// not what we started with. We would save anyway as we switched views, so do it now.
				var parent = Controller;
				if (parent != null)
					parent.UpdateRealFromSandbox(null, false, null);
				// This leaves the parent in a bad state, but maybe it would be good if all this is
				// happening in some other parent, such as the words analysis view?
				//m_hvoAnalysisGuess = GetRealAnalysis(false);
				int hvo = GetHvoForJumpToToolClass(className);
				if (hvo != 0)
				{
					FdoCache cache = m_caches.MainCache;
					ICmObject co = cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo);
					var fwLink = new FwLinkArgs(tool, co.Guid);
					List<Property> additionalProps = fwLink.PropertyTableEntries;
					if (!String.IsNullOrEmpty(concordOn))
						additionalProps.Add(new Property("ConcordOn", concordOn));
					m_mediator.PostMessage("FollowLink", fwLink);
					return true;
				}
			}
			return false;
		}
Exemple #41
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the incoming link, after the right window of the right application on the right
        /// project has been activated.
        /// See the class comment on FwLinkArgs for details on how all the parts of hyperlinking work.
        /// </summary>
        /// <param name="link">The link.</param>
        /// ------------------------------------------------------------------------------------
        public override void HandleIncomingLink(FwLinkArgs link)
        {
            CheckDisposed();

            // Get window that uses the given DB.
            FwXWindow fwxwnd = m_rgMainWindows.Count > 0 ? (FwXWindow)m_rgMainWindows[0] : null;
            if (fwxwnd != null)
            {
                fwxwnd.Mediator.SendMessage("FollowLink", link);
                bool topmost = fwxwnd.TopMost;
                fwxwnd.TopMost = true;
                fwxwnd.TopMost = topmost;
                fwxwnd.Activate();
            }
        }
Exemple #42
0
		public void EssentiallyEquals_DiffereByGuid()
		{
			FwLinkArgs args1 = new FwLinkArgs("myTool", Guid.NewGuid(), "myTag");
			Assert.IsFalse(args1.EssentiallyEquals(new FwLinkArgs("myTool", Guid.NewGuid(), "myTag")));
		}