예제 #1
0
        /// <summary>
        /// read the passed in list of additional fields (should be custom ones)
        /// and add them to the list of fields.
        /// </summary>
        /// <param name="customFields"></param>
        /// <returns></returns>
        public bool AddCustomImportFields(Sfm2Xml.ILexImportFields customFields)
        {
            //foreach (LexImportField field in customFields)
            //{

            //}
            return(true);
        }
예제 #2
0
		private bool EnableNextButton()
		{
			AllowQuickFinishButton();	// this should be done atleast before each step
			bool rval = false;
			using (new WaitCursor(this))
			{
				switch (CurrentStepNumber)
				{
				case 1: // has to have a dictionary file to allow 'next'
					if (m_isPhaseInputFile || (m_DatabaseFileName.Text.Length > 0 &&
						System.IO.File.Exists(m_DatabaseFileName.Text) &&
						m_SaveAsFileName.Text != m_sMDFImportMap))		// not same as MDFImport.map file
					{
						rval = true;
					}
					break;

				case 2:	// preparing to display the languages info
					if (m_dirtyMapFile)
					{
						ReadLanguageInfoFromMapFile();
						m_processedMapFile = m_SettingsFileName.Text;
//						m_dirtyMapFile = false;
					}
					rval = true;

					// make sure there is a value for the 'Save as:' entry
					if (m_SaveAsFileName.Text.Length <= 0 && !m_isPhaseInputFile)
					{
						m_SaveAsFileName.Text = RemoveTheFileExtension(m_DatabaseFileName.Text) + "-import-settings.map";
					}
					break;

				case 3:
					// current technique for getting the custom fields in the DB
					bool customFieldsChanged = false;
					m_CustomFields = LexImportWizard.Wizard().ReadCustomFieldsFromDB(out customFieldsChanged);

					UpdateIfInputFileContentsChanged();
					if (m_dirtyInputFile || m_dirtyMapFile)
					{
						ReadMarkersFromDataFile();
						ReadIFMFromMapFile();	// do it now before setting the dirty map flag to false
						m_processedInputFile = m_DatabaseFileName.Text;
						m_lastDateTime = System.IO.File.GetLastWriteTime(m_processedInputFile);	// used to keep track of the last write date on the data file
						m_crcOfInputFile = m_crcObj.FileCRC(m_processedInputFile);		// the computed crc of the data file
						m_dirtyInputFile = false;
						m_dirtyMapFile = false;
						string topAnalysisWS = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(m_cache.DefaultAnalWs);
						m_MappingMgr = new MarkerPresenter( /*m_cache,*/FwDirectoryFinder.CodeDirectory,
							LexImportWizard.Wizard().GetUILanguages(),
							topAnalysisWS,
							m_SettingsFileName.Text,
							m_DatabaseFileName.Text,
							m_sImportFields, 6);	// number of columns
						DisplayMarkerStep();
						m_FeasabilityReportGenerated = false;	// reset when intputs change
					}
					rval = true;
					break;

				case 4:
					UpdateIfInputFileContentsChanged();
					if (m_DirtyStep5 || true)
					{
						DisplayBeginMarkers();
						m_DirtyStep5 = false;
					}
					rval = Step5NextButtonEnabled();
					break;

				case 5:	// preparing to display the inline markers
//					if (true || m_hasShownIFMs)
					{
						//ReadIFMFromMapFile();
						DisplayInlineMarkers();
//						m_hasShownIFMs = true;
					}
					rval = true;
					break;

				case 6:
					rval = m_FeasabilityReportGenerated;
					break;

				default:
					rval = true;
					break;
				}
			}
			return rval;
		}
예제 #3
0
		/// <summary>
		/// From IFwExtension
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		void IFwExtension.Init(FdoCache cache, XCore.Mediator mediator)
		{
			CheckDisposed();

			m_wizard = this;
			m_cache = cache;
			m_mediator = mediator;
			if (mediator != null)
			{
				m_app = (IApp) mediator.PropertyTable.GetValue("App");
				m_stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			}
			m_dirtyInputFile = true;
			m_dirtyMapFile = true;
//			m_hasShownIFMs = false;
			m_processedInputFile = m_processedMapFile = string.Empty;	// no files processed yet
//			m_autoImportFields = new Hashtable();
			m_isPhaseInputFile = false;

			InitOutputFiles();
			SetDatabaseNameIntoLabel();

			// read in the Lex Import Fields
			m_LexFields = new Sfm2Xml.LexImportFields();
			m_LexFields.ReadLexImportFields(m_sImportFields);

			// now read in any custom fields
			// m_CustomFields = new Sfm2Xml.LexImportFields();
			bool customFieldsChanged = false;
			m_CustomFields = ReadCustomFieldsFromDB(out customFieldsChanged);	// compare with map file before showing the UI and before the Import

			// set up default button states
			NextButtonEnabled = true;
			AcceptButton = null;
			btnModifyMappingLanguage.Enabled = false;
			btnModifyContentMapping.Enabled = false;
			string dictFileToImport = string.Empty;
			m_SettingsFileName.Items.Clear();
			m_SettingsFileName.Items.Add(m_sMDFImportMap);

			if (GetLastImportFile(out dictFileToImport))
			{
				FindFilesForDatabaseFile(dictFileToImport);
				m_DatabaseFileName.Text = dictFileToImport;

				HandleDBFileNameChanges();
			}
			else
			{
				m_SaveAsFileName.Text = string.Empty;	// empty if not found already
			}
			AllowQuickFinishButton();	// show it if it's valid

			// Copied from the previous LexImport dlg constructor (ImportLexicon.cs)
			// Ensure that we have the default encoding converter (to/from MS Windows Code Page
			// for Western European languages)
			EnsureWindows1252ConverterExists();

			ShowSaveButtonOrNot();
		}
예제 #4
0
//		private int getSelIndexForSFM(string sfm)
//		{
//			foreach (ListViewItem lvi in listViewContentMapping.Items)
//			{
//				MarkerPresenter.ContentMapping contentMapping = lvi.Tag as MarkerPresenter.ContentMapping;
//				if (sfm == contentMapping.Marker)
//					return lvi.Index;
//			}
//			return -1;
//		}

		private void btnModifyContentMapping_Click(object sender, System.EventArgs e)
		{
			ListView.SelectedIndexCollection selIndexes = listViewContentMapping.SelectedIndices;
			if (selIndexes.Count < 1 || selIndexes.Count > 1)
				return;	// only handle single selection at this time

			int selIndex = selIndexes[0];	// only support 1
			Hashtable langDescs = GetUILanguages();

			MarkerPresenter.ContentMapping contentMapping;
			contentMapping = listViewContentMapping.Items[selIndex].Tag as MarkerPresenter.ContentMapping;
			using (LexImportWizardMarker dlg = new LexImportWizardMarker(m_LexFields))
			{
			dlg.Init(contentMapping, langDescs, m_cache, m_mediator.HelpTopicProvider, m_app, m_stylesheet);
			DialogResult dr = dlg.ShowDialog(this);

			// Custom fields have to be handled independantly of the dialogresult being ok sense they
			// can change the custom fields and still select cancel in the dlg

			m_CustomFields = dlg.CustomFields;
			m_MappingMgr.UpdateLexFieldsWithCustomFields(m_CustomFields);
			//m_MappingMgr.RemoveAnyDeletedCustomFieldsNOTWORKINGYET();

			// make sure the display is made correct by compairing to the memory list (could have deleted custom fields that were ref'd)
			ListView.ListViewItemCollection uiItems = listViewContentMapping.Items;
			foreach (ListViewItem lvi in uiItems)
			{
				MarkerPresenter.ContentMapping content = lvi.Tag as MarkerPresenter.ContentMapping;

				if (content.LexImportField is Sfm2Xml.ILexImportCustomField)
				{
					Sfm2Xml.LexImportCustomField customField = content.LexImportField as Sfm2Xml.LexImportCustomField;
					MarkerPresenter.CFChanges cfChange = m_MappingMgr.TESTTESTTEST(customField);
					if (cfChange == MarkerPresenter.CFChanges.NoChanges)
						continue;

					if (cfChange == MarkerPresenter.CFChanges.DoesntExist)
					{
						// default to the same as if field didn't exist when map was first read
						content = this.m_MappingMgr.DefaultContent(content.Marker);
//						content.AutoImport = true;
//						content.FwId = "";
						//content.ClsFieldDescription = null;

						int index = lvi.Index;
						listViewContentMapping.Items.RemoveAt(index);
						m_MappingMgr.ReplaceContentMappingItem(content);

						ListViewItem lvItem = new ListViewItem(content.ListViewStrings());
						lvItem.Tag = content;
						//lvItem.Selected = true;
						//lvItem.Focused = true;
						listViewContentMapping.Items.Add(lvItem);
						//listViewContentMapping.Focus();
						SetListViewItemColor(ref lvItem);
						continue;
					}
					// make sure it still exists

					if (!m_MappingMgr.IsValidCustomField(customField))
					{
						//// it's possible that the ui name was edited, so see if the guid still is valid and use it if so
						//if (m_MappingMgr.IsValidCustomField(customField.CustomFieldID.ToString()))
						//{
						//    // just update the LexImportField with the current one
						//    //content.LexImportField = m_MappingMgr.LexImportFields
						//}
//										ListViewItem lvItem = new ListViewItem(contentMapping.ListViewStrings());
						//content = m_MappingMgr.ContentMappingItem(customField.SFM);
						content = m_MappingMgr.ContentMappingItem(content.Marker);

						ListViewItem lvItem = new ListViewItem(content.ListViewStrings());
						lvItem.Tag = content;
						lvItem.Selected = true;
						lvItem.Focused = true;
						listViewContentMapping.Items.Add(lvItem);
						listViewContentMapping.Focus();
						SetListViewItemColor(ref lvItem);
					}
				}
			}

			if (dr == DialogResult.OK)
			{
				// have to reset the contentMapping variable as it is still set from the last one, and
				// in the case that I'm investigating the RefFunc is still set when it should be off -
				// other fields may need to be revised too.
				//contentMapping.IsRefField = dlg.IsFuncField;
				if (dlg.IsFuncField)
				{
					contentMapping.RefField = dlg.FuncField;
					contentMapping.RefFieldWS = dlg.FuncFieldWS;
				}
				else
				{
					contentMapping.ClearRef(); // = contentMapping.RefFieldWS = "";
				}
//				contentMapping = listViewContentMapping.Items[selIndex].Tag as MarkerPresenter.ContentMapping;

				m_dirtySenseLastSave = true;
				// remove the old from the treeview display
				//listViewContentMapping.Items[selIndex].
				listViewContentMapping.Items[selIndex].Selected = false;
				listViewContentMapping.Items[selIndex].Focused = false;
				listViewContentMapping.Items.RemoveAt(selIndex);

				// now update the item and add it again and then select it
				contentMapping.Exclude = dlg.ExcludeFromImport;

				if (!contentMapping.Exclude)
				{
					contentMapping.AutoImport = dlg.AutoImport;
					// get the language values
					string userKey = dlg.LangDesc;
					string ws = dlg.WritingSystem;
					// it is possible through the GUI to have more UILanguages now, so get a fresh list
					langDescs = GetUILanguages();

					Sfm2Xml.LanguageInfoUI langInfo = langDescs[userKey] as Sfm2Xml.LanguageInfoUI;
					string shortName = langInfo.ICUName;
					contentMapping.UpdateLangaugeValues(ws, shortName, userKey);

					if (!contentMapping.AutoImport)	// auto import only allows lang so skip the following
					{
						contentMapping.FwId = dlg.FWDestID;

						string cname, fname;
						cname = dlg.FWDestinationClass;
						//contentMapping.ClsFieldDescription
						//						contentMapping.AddLexImportField(m_CustomFields.GetField(cname, contentMapping.FwId));
						//						bool isCustomField = false;
						if (dlg.IsCustomField)
						{
							string cnameTmp;
							m_CustomFields.GetDestinationForName(contentMapping.FwId, out cnameTmp, out fname);
							contentMapping.AddLexImportCustomField(m_CustomFields.GetField(cname, contentMapping.FwId), cname);
							// Need to make sure the clscustom... member of the contentMapping object is a custom one now
							// this is needed for the modify dlg that comes up.
						}
						else
						{
							string cnameTmp;
							m_LexFields.GetDestinationForName(contentMapping.FwId, out cnameTmp, out fname);
							contentMapping.AddLexImportField(m_LexFields.GetField(cname, contentMapping.FwId));
							// need to make sure the clscustom... isn't set on the contentMapping object.
						}

						contentMapping.DestinationClass = cname;
						contentMapping.rawDestinationField = fname;
						if (contentMapping.IsAbbrvField)
						{
							// save the selection 'name' or 'abbreviation' from the dialog
							contentMapping.UpdateAbbrValue(dlg.IsAbbrNotName);
						}

						// update some more underlying fields now that we are associated with a destination:
						// datatype, etc...

						//// update the func value to either empty, or the proper abbr
						//contentMapping.RefField = dlg.FuncField;
						//contentMapping.RefFieldWS = dlg.FuncFieldWS;
						contentMapping.LexImportField.ClsFieldDescriptionWith(contentMapping.ClsFieldDescription);
					}
					else
					{
						contentMapping.DestinationClass = "";
						// is autoimport field, so empty out LexImportField and ClsFieldDescription from the contentMapping
						contentMapping.DoAutoImportWork();
					}
				}

				ListViewItem lvItem = new ListViewItem(contentMapping.ListViewStrings());
				lvItem.Tag = contentMapping;
				lvItem.Selected = true;
				lvItem.Focused = true;
				listViewContentMapping.Items.Add(lvItem);
				listViewContentMapping.Focus();
				SetListViewItemColor(ref lvItem);
			}
		}
		}
예제 #5
0
		/// <summary>
		/// From IFwExtension
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		void IFwExtension.Init(FdoCache cache, XCore.Mediator mediator)
		{
			CheckDisposed();

			m_wizard = this;
			m_cache = cache;
			m_mediator = mediator;
			m_dirtyInputFile = true;
			m_dirtyMapFile = true;
			m_hasShownIFMs = false;
			m_processedInputFile = m_processedMapFile = string.Empty;	// no files processed yet
			m_autoImportFields = new Hashtable();
			m_isPhaseInputFile = false;

			InitOutputFiles();
			SetDatabaseNameIntoLabel();

			// read in the Lex Import Fields
			m_LexFields = new Sfm2Xml.LexImportFields();
			m_LexFields.ReadLexImportFields(m_sImportFields);

			// now read in any custom fields
			// m_CustomFields = new Sfm2Xml.LexImportFields();
			bool customFieldsChanged = false;
			m_CustomFields = ReadCustomFieldsFromDB(out customFieldsChanged);	// compare with map file before showing the UI and before the Import

			// set up default button states
			NextButtonEnabled = true;
			AcceptButton = null;
			btnModifyMappingLanguage.Enabled = false;
			btnModifyContentMapping.Enabled = false;
			string dictFileToImport = string.Empty;
			m_SettingsFileName.Items.Clear();
			m_SettingsFileName.Items.Add(m_sMDFImportMap);

			if (GetLastImportFile(out dictFileToImport))
			{
				FindFilesForDatabaseFile(dictFileToImport);
				m_DatabaseFileName.Text = dictFileToImport;

				HandleDBFileNameChanges();
			}
			else
			{
				m_SaveAsFileName.Text = string.Empty;	// empty if not found already
			}
			AllowQuickFinishButton();	// show it if it's valid

			// Copied from the previous LexImport dlg constructor (ImportLexicon.cs)
			// Ensure that we have the default encoding converter (to/from MS Windows Code Page
			// for Western European languages)
			SilEncConverters31.EncConverters encConv = new SilEncConverters31.EncConverters();
			System.Collections.IDictionaryEnumerator de = encConv.GetEnumerator();
			// REVIEW: SHOULD THIS NAME BE LOCALIZED?
			string sEncConvName = "Windows1252<>Unicode";
			bool fMustCreateEncCnv = true;
			while (de.MoveNext())
			{
				if ((string)de.Key != null && (string)de.Key == sEncConvName)
				{
					fMustCreateEncCnv = false;
					break;
				}
			}
			if (fMustCreateEncCnv)
			{
				try
				{
					encConv.AddConversionMap(sEncConvName, "1252",
						ECInterfaces.ConvType.Legacy_to_from_Unicode, "cp", "", "",
						ECInterfaces.ProcessTypeFlags.CodePageConversion);
				}
				catch (SilEncConverters31.ECException exception)
				{
					MessageBox.Show(exception.Message, LexTextControls.ksConvMapError,
						MessageBoxButtons.OK);
				}
			}

			ShowSaveButtonOrNot();
		}
예제 #6
0
		private void btnAddCustomField_Click(object sender, EventArgs e)
		{
			// Mediator accessor in the LexImportWizard now checks to make sure that
			// it's not disposed - if it is it creates a new one.
			XCore.Mediator med = null;
			LexImportWizard wiz = LexImportWizard.Wizard();
			if (wiz != null)
				med = wiz.Mediator;
			if (med == null)
			{
				// See LT-9100 and LT-9266.  Apparently this condition can happen.
				MessageBox.Show(LexTextControls.ksCannotSoTryAgain, LexTextControls.ksInternalProblem,
								MessageBoxButtons.OK, MessageBoxIcon.Information);
				return;
			}
			med.SendMessage("AddCustomField", null);

			// The above call can cause the Mediator to 'go away', so check it and
			// restore the member variable for everyone else who may be surprised
			// that it is gone ... or not

			// At this point there could be custom fields added or removed, so we have to
			// recalculate the customfields and populate the TVcontrol based on the currently
			// defined custom fields.

			bool customFieldsChanged = false;
			m_customFields = wiz.ReadCustomFieldsFromDB(out customFieldsChanged);

			// if the custom fields have changed any, then update the display with the changes
			if (customFieldsChanged)
				AddCustomFieldsToPossibleFields();
		}