Exemplo n.º 1
0
		public override void FixtureSetup()
		{
			string partDirectory = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FwSourceDirectory,
				@"common\controls\detailcontrols\detailcontrolstests");
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] {"class", "type", "name" };
			keyAttrs["group"] = new string[] {"label"};
			keyAttrs["part"] = new string[] {"ref"};

			string configurationDir = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory,
				@"Language Explorer\Configuration");
			m_stringTable = new SIL.Utils.StringTable(configurationDir);

			m_layouts = new Inventory(new string[] {partDirectory},
				"*Layouts.xml", "/LayoutInventory/*", keyAttrs);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new string[] {"id"};

			m_parts = new Inventory(new string[] {partDirectory},
				"*Parts.xml", "/PartInventory/bin/*", keyAttrs);

			m_cache = FdoCache.Create("TestLangProj");

			m_entry = new LexEntry();
			m_cache.LangProject.LexDbOA.EntriesOC.Add(m_entry);
			m_entry.CitationForm.VernacularDefaultWritingSystem = "rubbish";
			// We set both alternatives because currently the default part for Bibliography uses vernacular,
			// but I think this will probably get fixed. Anyway, this way the test is robust.
			m_entry.Bibliography.SetAnalysisDefaultWritingSystem("My rubbishy bibliography");
			m_entry.Bibliography.SetVernacularDefaultWritingSystem("My rubbishy bibliography");
		}
Exemplo n.º 2
0
		public void Setup()
		{
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] {"class", "type", "mode", "name" };
			keyAttrs["group"] = new string[] {"label"};
			keyAttrs["part"] = new string[] {"ref"};

			m_inventory = new Inventory(new string[] {m_sTestPathBase, m_sTestPathLater},
				"*Layouts.xml", "/layoutInventory/*", keyAttrs);
		}
Exemplo n.º 3
0
		private void InitializeDynamically(IFwMetaDataCache mdc, bool fLoadFlexLayouts, string sDatabase)
		{
			m_mdc = mdc;
			m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
			m_partInventory = Inventory.GetInventory("parts", sDatabase);
			if (m_layoutInventory == null || m_partInventory == null)
			{
				InitializePartInventories(fLoadFlexLayouts, sDatabase);
				m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
				m_partInventory = Inventory.GetInventory("parts", sDatabase);
			}
		}
Exemplo n.º 4
0
		public AddCustomFieldDlg(XCore.Mediator mediator, int defaultClid)
		{
			// create member variables
			m_mediator = mediator;
			m_cache = (FDO.FdoCache)m_mediator.PropertyTable.GetValue("cache");
			m_layouts = Inventory.GetInventory("layouts", m_cache.DatabaseName);
			m_customFields = new List<FDWrapper>();

			InitializeComponent();		// form required method

			//lbCustomFields.Hide();
			//listViewCustomFields.Hide(); //for now hide this control until I figure out
									//how to convert everything from lbCustomFields
									//to this control type.

			this.labelCustomFieldsList.Tag = this.labelCustomFieldsList.Text;	// Localizes Tag!

			this.helpProvider = new System.Windows.Forms.HelpProvider();
			this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
			this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
			this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
			this.helpProvider.SetShowHelp(this, true);

			// Initialize array of setting controls
			m_settingControls = new Control[8]
						{
							lblName,
							CustomFieldName,
							lblDescription,
							rtbDescription,
							lblWritingSystems,
							cbWritingSystem,
							label1,
							cbCreateIn
						};


			SetReadyToAddOrDelete();    //get the buttons in their initial proper state that
										//we want when we start up this dialog
										// this also calls EnableSettingsControlsNew(false);

			LoadDBCustomFields();			// get custom fields from DB

			// Initialize the Writing Systems combo box.  This must be initialized before setting the
			// selected item in cbCreateIn.
			cbWritingSystem.Items.Add(new IdAndString(LangProject.kwsAnal, xWorksStrings.FirstAnalysisWs));
			cbWritingSystem.Items.Add(new IdAndString(LangProject.kwsVern, xWorksStrings.FirstVernacularWs));
			cbWritingSystem.Items.Add(new IdAndString(LangProject.kwsAnals, xWorksStrings.AllAnalysisWs));
			cbWritingSystem.Items.Add(new IdAndString(LangProject.kwsVerns, xWorksStrings.AllVernacularWs));
			cbWritingSystem.Items.Add(new IdAndString(LangProject.kwsAnalVerns, xWorksStrings.AllAnalysisVernacularWs));
			cbWritingSystem.Items.Add(new IdAndString(LangProject.kwsVernAnals, xWorksStrings.AllVernacularAnalysisWs));
			cbWritingSystem.SelectedIndex = 0;



			// initialize the 'Create in' combo box with the names and class id's
			cbCreateIn.Items.Add(m_entry);
			cbCreateIn.Items.Add(m_sense);
			cbCreateIn.Items.Add(m_exampleSent);
			cbCreateIn.Items.Add(m_allomorph);

			// Set the default item in the class combo box. (cf. LT-4404)
			switch (defaultClid)
			{
				case MoForm.kclsidMoForm:
					cbCreateIn.SelectedItem = m_allomorph;
					break;
				case LexExampleSentence.kclsidLexExampleSentence:
					cbCreateIn.SelectedItem = m_exampleSent;
					break;
				case LexSense.kclsidLexSense:
					cbCreateIn.SelectedItem = m_sense;
					break;
				case LexEntry.kclsidLexEntry:
				default:
					cbCreateIn.SelectedItem = m_entry;
					break;
			}

			UpdateCustomFieldsListView();   //load the items from m_customfields into the ListView

			buttonAdd.Select();

			//if there is at least one existing Custom field then set the controls
			//to the settings it has.
			if (listViewCustomFields.Items.Count > 0)
			{
				m_NoCustomFields = false;
				listViewCustomFields.Items[0].Selected = true;
			}
			else
			//********
			//I need to handle the situation where there are no custom fields in
			//existance yet. After discussion with Susanna we decided to open the dialog
			  //with the CustomFieldName and Description controls disabled.
			{
				SetStateNoCustomFields();
				m_fOpeningDialog = false;
				return;
			}

			//when opening the dialog we do not want to take any action
			//for events like TextChange or SelectedIndexChanged on controls
			//Once the this method is completed we can set this flag to false.
			m_fOpeningDialog = false;

			m_modifyingField = true; //Initially the state is to be modifying
								//the current field
		}
Exemplo n.º 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create the client windows and add correspnding stuff to the sidebar, View menu,
		/// etc. Subclasses must override this.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void InitAndShowClient()
		{
			CheckDisposed();

			m_dataEntryForm = new DataTree();
			SuspendLayout();
			string partDirectory = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory,
				@"Language Explorer\Configuration\Parts");
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] {"class", "type", "mode", "name" };
			keyAttrs["group"] = new string[] {"label"};
			keyAttrs["part"] = new string[] {"ref"};


			Inventory layouts = new Inventory(new string[] {partDirectory},
				"*Parts.xml", "/layoutInventory/*", keyAttrs);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new string[] {"id", "type", "mode"};

			Inventory parts = new Inventory(new string[] {partDirectory},
				"*Layouts.xml", "/PartInventory/*", keyAttrs);
			m_dataEntryForm.Initialize(m_cache, true, layouts, parts);
			m_dataEntryForm.Dock = System.Windows.Forms.DockStyle.Fill;
			Controls.Add(m_dataEntryForm);
			ResumeLayout(false);
		}
Exemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:LayoutCache"/> class.
		/// </summary>
		/// <param name="mdc">The MDC.</param>
		/// <param name="layouts">The layouts.</param>
		/// <param name="parts">The parts.</param>
		/// ------------------------------------------------------------------------------------
		public LayoutCache(IFwMetaDataCache mdc, Inventory layouts, Inventory parts)
		{
			m_mdc = mdc;
			m_layoutInventory = layouts;
			m_partInventory = parts;
		}
Exemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize the part inventories.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void InitializePartInventories(bool fLoadFlexLayouts, string sDatabase,
			bool fLoadUserOverrides)
		{
			string partDirectory = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory,
				@"Language Explorer\Configuration\Parts");
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] {"class", "type", "name" };
			keyAttrs["group"] = new string[] {"label"};
			keyAttrs["part"] = new string[] {"ref"};


			Inventory layoutInventory = new Inventory(new string[] {partDirectory},
				"*Layouts.xml", "/LayoutInventory/*", keyAttrs);
			layoutInventory.Merger = new LayoutMerger();
			// Holding shift key means don't use extant preference file, no matter what.
			// This includes user overrides of layouts.
			if (fLoadUserOverrides &&
				System.Windows.Forms.Control.ModifierKeys != System.Windows.Forms.Keys.Shift)
			{
				layoutInventory.LoadUserOverrides(LayoutVersionNumber, sDatabase);
				if (fLoadFlexLayouts)
					layoutInventory.LoadFlexUserOverrides(LayoutVersionNumber, sDatabase);
			}
			else
			{
				layoutInventory.DeleteUserOverrides(sDatabase);
			}
			Inventory.SetInventory("layouts", sDatabase, layoutInventory);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new string[] {"id"};

			Inventory.SetInventory("parts", sDatabase, new Inventory(new string[] {partDirectory},
				"*Parts.xml", "/PartInventory/bin/*", keyAttrs));
		}
Exemplo n.º 8
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)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_map != null)
					m_map.Clear();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_mdc = null;
			m_layoutInventory = null;
			m_partInventory = null;
			m_map = null;

			m_isDisposed = true;
		}
Exemplo n.º 9
0
		/// <summary>
		/// Used to set up a shared inventory.
		/// </summary>
		/// <param name="key"></param>
		/// <param name="val"></param>
		static public void SetInventory(string key, string sDatabase, Inventory val)
		{
			if (key == null || key == String.Empty)
				throw new ArgumentException("Invalid key argument.");
			if (val == null)
				throw new ArgumentNullException("'val' argument is null.");
			Debug.Assert(val.m_sDatabase == null || val.m_sDatabase == sDatabase);
			if (val.m_sDatabase == null)
				val.m_sDatabase = sDatabase;
			string sKey;
			if (!String.IsNullOrEmpty(sDatabase))
				sKey = String.Format("{0}${1}", key, sDatabase);
			else
				sKey = key;
			s_inventories[sKey] = val;
		}
Exemplo n.º 10
0
		public void Setup()
		{
			// Create the following:
			// - part and layout inventories
			// - metadata cache
			// - DataAccess cache
			// - collection of columns to display.

			// We want a MetaDataCache that knows about
			// - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
			// - LexSense.SemanticDomains, SenseType, Status, gloss
			// - CmPossibility Name, abbr
			// - MoMorphSynAnalysis
			// - MoStemMsa
			// - MoDerivationalMsa
			m_mdc = FwMetaDataCacheClass.Create();
			string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests\SampleCm.xml");
			m_mdc.InitXml(m_sTestPath, true);

			// We want ISilDataAccess with:
			// - LexEntry (1) with no senses and one MSA (2)
			// - LexEntry (4) with one sense (5) and no MSA
			// - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
			// - sense(5) with no semantic domains
			// - senses with one SD (7->30, 8->31)
			// - sense with three SDs, one the same as the first (9->30, 31, 32)
			// - MoStemMsa (2, 11)
			// - MoDerivationalMsa (10)
			m_cda = VwCacheDaClass.Create();
			m_sda = m_cda as ISilDataAccess;
			m_wsf = LgWritingSystemFactoryClass.Create();
			m_sda.WritingSystemFactory = m_wsf;
			SimpleDataParser parser = new SimpleDataParser(m_mdc, m_cda);

			parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests\SampleData.xml"));
			int wsEn = m_wsf.GetWsFromStr("en");
			// These are mainly to check out the parser.
			Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
			Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
			Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
			Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
			Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");

			// Columns includes
			// - CitationForm (string inside span)
			// - Bibliography (string not in span)
			// - Sense glosses (string in para in seq, nested in column element)
			// - Semantic domains (pair of strings in para in seq in seq, using layout refs)
			// - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
			XmlDocument docColumns = new XmlDocument();
			docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests\TestColumns.xml"));
			m_columnList = docColumns.DocumentElement.ChildNodes;

			// Parts just has what those columns need.
			string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests");
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] {"class", "type", "name" };
			keyAttrs["group"] = new string[] {"label"};
			keyAttrs["part"] = new string[] {"ref"};


			// Currently there are no specialized layout files that match.
			m_layoutInventory = new Inventory(new string[] {partDirectory},
				"*Layouts.xml", "/LayoutInventory/*", keyAttrs);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new string[] {"id"};

			m_partInventory = new Inventory(new string[] {partDirectory},
				"TestParts.xml", "/PartInventory/bin/*", keyAttrs);
			if (m_layouts != null)
				m_layouts.Dispose();
			m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
		}
Exemplo n.º 11
0
		public void Teardown()
		{
			if (m_wsf != null && Marshal.IsComObject(m_wsf))
			{
				m_wsf.Shutdown();
				Marshal.ReleaseComObject(m_wsf);
			}
			m_wsf = null;

			if (Marshal.IsComObject(m_cda))
			{
				Marshal.ReleaseComObject(m_cda);
			}
			m_cda = null;

			if (Marshal.IsComObject(m_mdc))
			{
				Marshal.ReleaseComObject(m_mdc);
			}
			m_mdc = null;

			if (Marshal.IsComObject(m_sda))
			{
				Marshal.ReleaseComObject(m_sda);
			}
			m_sda = null;

			m_layoutInventory = null;
			m_columnList = null;
			m_layouts = null;
			m_partInventory = null;
		}