コード例 #1
0
        public void OnInsertButtonClick(object obj, EventArgs ea)
        {
            CheckDisposed();

            MasterInflectionFeature mif = (MasterInflectionFeature)treeViewGlossListItem.SelectedNode.Tag;

            if (mif == null)
            {
                return;                 // just to be safe
            }
            GlossListBoxItem glbiNew = new GlossListBoxItem(mif.Node,
                                                            treeViewGlossListItem.AfterSeparator, treeViewGlossListItem.ComplexNameSeparator,
                                                            treeViewGlossListItem.ComplexNameFirst);
            GlossListBoxItem glbiConflict;

            if (glossListBoxGloss.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict))
            {
                const string ksPath   = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='MGA']/";
                string       sMsg1    = m_mediator.StringTbl.GetStringWithXPath("ItemConflictDlgMessage", ksPath);
                string       sMsg     = String.Format(sMsg1, glbiConflict.ToString());
                string       sCaption = m_mediator.StringTbl.GetStringWithXPath("ItemConflictDlgCaption", ksPath);
                MessageBox.Show(sMsg, sCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            // raise event
            GlossListEventArgs glea = new GlossListEventArgs(glbiNew);

            OnInsertMGAGlossListItem(glea);
            buttonAcceptGloss.Enabled = true;
            EnableMoveUpDownButtons();
            ShowGloss();
        }
コード例 #2
0
ファイル: MGATests.cs プロジェクト: bbriggs/FieldWorks
		public void GlossListItemConflicts()
		{
			// check another terminal node, but with different parent, so no conflict
			XmlNode node = m_doc.SelectSingleNode("//item[@id='cAdjAgr']/item[@target='tCommonAgr']/item[@target='fGender']/item[@target='vMasc']");
			GlossListBoxItem glbiNew = new GlossListBoxItem(Cache, node, ".", "", false);
			GlossListBoxItem glbiConflict;
			bool fResult = m_LabelGlosses.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict);
			string sMsg;
			if (glbiConflict != null)
				sMsg = String.Format("Masculine gender should not conflict, but did with {0}.", glbiConflict.Abbrev);
			else
				sMsg = "Masculine gender should not conflict";
			Assert.IsFalse(fResult, sMsg);
			// check a non-terminal node, so no conflict
			node = m_doc.SelectSingleNode("//item[@id='fDeg']");
			glbiNew = new GlossListBoxItem(Cache, node, ".", "", false);
			fResult = m_LabelGlosses.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict);
			if (glbiConflict != null)
			sMsg = String.Format("Feature degree should not conflict, but did with {0}", glbiConflict.Abbrev);
			else
				sMsg = "Feature degree should not conflict";
			Assert.IsFalse(fResult, sMsg);
			// check another terminal node with same parent, so there is conflict
			node = m_doc.SelectSingleNode("//item[@id='vComp']");
			glbiNew = new GlossListBoxItem(Cache, node, ".", "", false);
			fResult = m_LabelGlosses.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict);
			Assert.IsTrue(fResult, "Comparative should conflict with positive, but did not");
		}
コード例 #3
0
ファイル: MGATests.cs プロジェクト: sillsdev/WorldPad
		public void Init()
		{
			string sXmlFile = Path.Combine(DirectoryFinder.FWCodeDirectory,
				@"Language Explorer\MGA\GlossLists\EticGlossList.xml");
			m_doc = new XmlDocument();
			m_doc.Load(sXmlFile);
			m_LabelGlosses = new GlossListBox();
			m_LabelGlosses.Sorted = false;
			XmlNode node = m_doc.SelectSingleNode("//item[@id='vPositive']");
			GlossListBoxItem glbi = new GlossListBoxItem(node, ".", "", false);
			m_LabelGlosses.Items.Add(glbi);
		}
コード例 #4
0
ファイル: MGATests.cs プロジェクト: vkarthim/FieldWorks
        public void Init()
        {
            string sXmlFile = Path.Combine(FwDirectoryFinder.CodeDirectory,
                                           @"Language Explorer/MGA/GlossLists/EticGlossList.xml");

            m_doc = new XmlDocument();
            m_doc.Load(sXmlFile);
            m_LabelGlosses        = new GlossListBox();
            m_LabelGlosses.Sorted = false;
            XmlNode          node = m_doc.SelectSingleNode("//item[@id='vPositive']");
            GlossListBoxItem glbi = new GlossListBoxItem(Cache, node, ".", "", false);

            m_LabelGlosses.Items.Add(glbi);
        }
コード例 #5
0
ファイル: GlossListBox.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// See if the selected item conflicts with any item already inserted into the gloss list box
        /// </summary>
        /// <param name="glbiNew">new item to be checked for</param>
        /// <returns>true if there is a conflict; false otherwise</returns>
        /// <remarks>Is public for testing</remarks>
        public bool NewItemConflictsWithExtantItem(GlossListBoxItem glbiNew, out GlossListBoxItem glbiConflict)
        {
            CheckDisposed();

            glbiConflict = null;
            if (!glbiNew.IsValue)
            {
                return(false);                // only terminal nodes will conflict
            }
            foreach (GlossListBoxItem item in Items)
            {
                if (item.IsValue)
                {                 // when they are values and have the same parent, they conflict
                    if (item.XmlNode.ParentNode == glbiNew.XmlNode.ParentNode)
                    {
                        glbiConflict = item;
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #6
0
ファイル: MGATests.cs プロジェクト: vkarthim/FieldWorks
        public void GlossListItemConflicts()
        {
            // check another terminal node, but with different parent, so no conflict
            XmlNode          node    = m_doc.SelectSingleNode("//item[@id='cAdjAgr']/item[@target='tCommonAgr']/item[@target='fGender']/item[@target='vMasc']");
            GlossListBoxItem glbiNew = new GlossListBoxItem(Cache, node, ".", "", false);
            GlossListBoxItem glbiConflict;
            bool             fResult = m_LabelGlosses.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict);
            string           sMsg;

            if (glbiConflict != null)
            {
                sMsg = String.Format("Masculine gender should not conflict, but did with {0}.", glbiConflict.Abbrev);
            }
            else
            {
                sMsg = "Masculine gender should not conflict";
            }
            Assert.IsFalse(fResult, sMsg);
            // check a non-terminal node, so no conflict
            node    = m_doc.SelectSingleNode("//item[@id='fDeg']");
            glbiNew = new GlossListBoxItem(Cache, node, ".", "", false);
            fResult = m_LabelGlosses.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict);
            if (glbiConflict != null)
            {
                sMsg = String.Format("Feature degree should not conflict, but did with {0}", glbiConflict.Abbrev);
            }
            else
            {
                sMsg = "Feature degree should not conflict";
            }
            Assert.IsFalse(fResult, sMsg);
            // check another terminal node with same parent, so there is conflict
            node    = m_doc.SelectSingleNode("//item[@id='vComp']");
            glbiNew = new GlossListBoxItem(Cache, node, ".", "", false);
            fResult = m_LabelGlosses.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict);
            Assert.IsTrue(fResult, "Comparative should conflict with positive, but did not");
        }
コード例 #7
0
 public GlossListEventArgs(XmlNode node, string sAfterSeparator, string sComplexNameSeparator, bool fComplexNameFirst)
 {
     m_glossListBoxItem = new GlossListBoxItem(node, sAfterSeparator, sComplexNameSeparator, fComplexNameFirst);
 }
コード例 #8
0
 public GlossListEventArgs(GlossListBoxItem glbi)
 {
     m_glossListBoxItem = glbi;
 }
コード例 #9
0
        /// <summary>
        /// Fill in the attributes of a MoGlossItem object based on its corresponding XML node in the etic gloss list tree
        /// </summary>
        /// <param name="gi"></param>
        /// <param name="xn"></param>
        /// <param name="glbi"></param>
        private void FillInGlossItemBasedOnXmlNode(MoGlossItem gi, XmlNode xn, GlossListBoxItem glbi)
        {
            XmlNode attr = xn.Attributes.GetNamedItem("term");

            if (attr == null)
            {
                gi.Name.AnalysisDefaultWritingSystem = MGAStrings.ksUnknownTerm;
            }
            else
            {
                gi.Name.AnalysisDefaultWritingSystem = attr.Value;
            }
            attr = xn.Attributes.GetNamedItem("abbrev");
            if (attr == null)
            {
                gi.Abbreviation.AnalysisDefaultWritingSystem = MGAStrings.ksUnknownAbbreviation;
            }
            else
            {
                gi.Abbreviation.AnalysisDefaultWritingSystem = attr.Value;
            }
            attr = xn.Attributes.GetNamedItem("afterSeparator");
            if (attr == null)
            {
                gi.AfterSeparator = this.AfterSeparator;
            }
            else
            {
                gi.AfterSeparator = attr.Value;
            }
            attr = xn.Attributes.GetNamedItem("complexNameSeparator");
            if (attr == null)
            {
                gi.ComplexNameSeparator = this.ComplexNameSeparator;
            }
            else
            {
                gi.ComplexNameSeparator = attr.Value;
            }
            attr = xn.Attributes.GetNamedItem("complexNameFirst");
            if (attr == null)
            {
                gi.ComplexNameFirst = this.ComplexNameFirst;
            }
            else
            {
                gi.ComplexNameFirst = XmlUtils.GetBooleanAttributeValue(attr.Value);
            }
            attr = xn.Attributes.GetNamedItem("type");
            attr = xn.Attributes.GetNamedItem("status");
            if (attr == null)
            {
                gi.Status = true;
            }
            else
            {
                if (attr.Value == "visible")
                {
                    gi.Status = true;
                }
                else
                {
                    gi.Status = false;
                }
            }
            attr = xn.Attributes.GetNamedItem("type");
            if (attr == null)
            {
                gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.unknown;
            }
            else
            {
                switch (attr.Value)
                {
                case "complex":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.complex;
                    break;

                case "deriv":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.deriv;
                    break;

                case "feature":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.feature;
                    break;

                case "fsType":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.fsType;
                    break;

                case "group":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.group;
                    break;

                case "value":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.inflValue;
                    break;

                case "xref":
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.xref;
                    break;

                default:
                    gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.unknown;
                    break;
                }
            }
        }
コード例 #10
0
ファイル: GlossListBox.cs プロジェクト: bbriggs/FieldWorks
		/// <summary>
		/// See if the selected item conflicts with any item already inserted into the gloss list box
		/// </summary>
		/// <param name="glbiNew">new item to be checked for</param>
		/// <returns>true if there is a conflict; false otherwise</returns>
		/// <remarks>Is public for testing</remarks>
		public bool NewItemConflictsWithExtantItem(GlossListBoxItem glbiNew, out GlossListBoxItem glbiConflict)
		{
			CheckDisposed();

			glbiConflict = null;
			if (!glbiNew.IsValue)
				return false; // only terminal nodes will conflict
			foreach (GlossListBoxItem item in Items)
			{
				if (item.IsValue)
				{ // when they are values and have the same parent, they conflict
					if (item.XmlNode.ParentNode == glbiNew.XmlNode.ParentNode)
					{
						glbiConflict = item;
						return true;
					}
				}
			}
			return false;
		}
コード例 #11
0
ファイル: MGADialog.cs プロジェクト: bbriggs/FieldWorks
		public void OnInsertButtonClick(object obj, EventArgs ea)
		{
			CheckDisposed();

			MasterInflectionFeature mif = (MasterInflectionFeature)treeViewGlossListItem.SelectedNode.Tag;
			if (mif == null)
				return; // just to be safe
			GlossListBoxItem glbiNew = new GlossListBoxItem(m_cache, mif.Node,
				treeViewGlossListItem.AfterSeparator, treeViewGlossListItem.ComplexNameSeparator,
				treeViewGlossListItem.ComplexNameFirst);
			GlossListBoxItem glbiConflict;
			if (glossListBoxGloss.NewItemConflictsWithExtantItem(glbiNew, out glbiConflict))
			{
				const string ksPath = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='MGA']/";
				string sMsg1 = m_mediator.StringTbl.GetStringWithXPath("ItemConflictDlgMessage", ksPath);
				string sMsg = String.Format(sMsg1, glbiConflict.ToString());
				string sCaption = m_mediator.StringTbl.GetStringWithXPath("ItemConflictDlgCaption", ksPath);
				MessageBox.Show(sMsg, sCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			// raise event
			GlossListEventArgs glea = new GlossListEventArgs(glbiNew);
			OnInsertMGAGlossListItem(glea);
			buttonAcceptGloss.Enabled = true;
			EnableMoveUpDownButtons();
			ShowGloss();
		}
コード例 #12
0
		public GlossListEventArgs(XmlNode node, string sAfterSeparator, string sComplexNameSeparator, bool fComplexNameFirst)
		{
			m_glossListBoxItem = new GlossListBoxItem(node, sAfterSeparator, sComplexNameSeparator, fComplexNameFirst);
		}
コード例 #13
0
		public GlossListEventArgs(GlossListBoxItem glbi)
		{
			m_glossListBoxItem = glbi;
		}
コード例 #14
0
		/// <summary>
		/// Fill in the attributes of a MoGlossItem object based on its corresponding XML node in the etic gloss list tree
		/// </summary>
		/// <param name="gi"></param>
		/// <param name="xn"></param>
		/// <param name="glbi"></param>
		private void FillInGlossItemBasedOnXmlNode(MoGlossItem gi, XmlNode xn, GlossListBoxItem glbi)
		{
			XmlNode attr = xn.Attributes.GetNamedItem("term");
			if (attr == null)
				gi.Name.AnalysisDefaultWritingSystem = MGAStrings.ksUnknownTerm;
			else
				gi.Name.AnalysisDefaultWritingSystem = attr.Value;
			attr = xn.Attributes.GetNamedItem("abbrev");
			if (attr == null)
				gi.Abbreviation.AnalysisDefaultWritingSystem = MGAStrings.ksUnknownAbbreviation;
			else
				gi.Abbreviation.AnalysisDefaultWritingSystem = attr.Value;
			attr = xn.Attributes.GetNamedItem("afterSeparator");
			if (attr == null)
				gi.AfterSeparator = this.AfterSeparator;
			else
				gi.AfterSeparator = attr.Value;
			attr = xn.Attributes.GetNamedItem("complexNameSeparator");
			if (attr == null)
				gi.ComplexNameSeparator = this.ComplexNameSeparator;
			else
				gi.ComplexNameSeparator= attr.Value;
			attr = xn.Attributes.GetNamedItem("complexNameFirst");
			if (attr == null)
				gi.ComplexNameFirst = this.ComplexNameFirst;
			else
				gi.ComplexNameFirst = XmlUtils.GetBooleanAttributeValue(attr.Value);
			attr = xn.Attributes.GetNamedItem("type");
			attr = xn.Attributes.GetNamedItem("status");
			if (attr == null)
				gi.Status = true;
			else
			{
				if (attr.Value == "visible")
					gi.Status = true;
				else
					gi.Status = false;
			}
			attr = xn.Attributes.GetNamedItem("type");
			if (attr == null)
				gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.unknown;
			else
			{
				switch(attr.Value)
				{
					case "complex":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.complex;
						break;
					case "deriv":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.deriv;
						break;
					case "feature":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.feature;
						break;
					case "fsType":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.fsType;
						break;
					case "group":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.group;
						break;
					case "value":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.inflValue;
						break;
					case "xref":
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.xref;
						break;
					default:
						gi.Type = (int)SIL.FieldWorks.FDO.Ling.MoGlossItem.ItemType.unknown;
						break;
				}
			}
		}