コード例 #1
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;
		}
コード例 #2
0
		public void Init(MarkerPresenter.ContentMapping currentMarker, Hashtable uiLangsHT, FdoCache cache,
			IHelpTopicProvider helpTopicProvider, IApp app, IVwStylesheet stylesheet)
		{
			CheckDisposed();

			m_uiLangs = uiLangsHT;
			m_cache = cache;
			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			m_stylesheet = stylesheet;
			helpProvider.HelpNamespace = helpTopicProvider.HelpFile;
			helpProvider.SetHelpKeyword(this, helpTopicProvider.GetHelpString(s_helpTopic));
			helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

			// The following call is needed to 'correct' the current behavior of the FwOverrideComboBox control.
			// As the control is currently, it will not allow the space character to be passed to the base
			// control: which means it doesn't get into the edit box portion of the control. We want to allow
			// space characters in our data, so we're enabling it here. This seems like a bug in the control
			// design, but not knowing the history and it's use, we'll just make it work as we think it should
			// be for us here.
			cbFunction.AllowSpaceInEditBox = true;

			// handle processing for the custom fields (CFS)
			// - read the db and get the CFS
			// - remove CFS that are in the TV and not in the CFS list
			// - add CFS that are in the list and not in the TV
			// - handle the case where the current marker is a CF and it's no longer in the list (just throw for now)

			//ReadCustomFieldsFromDB(cache);
			bool customFieldsChanged = false;
			m_customFields = LexImportWizard.Wizard().ReadCustomFieldsFromDB(out customFieldsChanged);

			// Init will only be called the first time, so here we don't have to remove an nodes

			tvDestination.BeginUpdate();
			foreach (TreeNode classNameNode in tvDestination.Nodes)
			{
				string className = classNameNode.Text.Trim(new char[] {'(', ')'});
				if (m_customFields.FieldsForClass(className) == null)
					continue;

				foreach (LexImportField field in m_customFields.FieldsForClass(className))
				{
					TreeNode cnode = new TreeNode(field.UIName + " (Custom Field)");
					cnode.Tag = field;
					classNameNode.Nodes.Add(cnode);
				}
				//tvDestination.Nodes.Add(tnode);
			}
			//tvDestination.ExpandAll();
			tvDestination.EndUpdate();

			// end of CFS processing

			// set the correct marker and number of times it is used
			m_lblMarker.Text = currentMarker.Marker;
			m_lblInstances.Text = String.Format(LexTextControls.ksXInstances, currentMarker.Count);

			if (currentMarker.AutoImport)
			{
				chkbxAutoField.Checked = true;
				tvDestination.Enabled = false;
			}

			// chkbxExclude.Checked = false;
			// tvDestination.Enabled = true;
			// find the node that has the tag.meaningid value the same as the currentmarker
			bool found = false;
			foreach (TreeNode classNode in tvDestination.Nodes)
			{
				if (currentMarker.ClsFieldDescription is ClsCustomFieldDescription &&
					currentMarker.DestinationClass != classNode.Text.Trim(new char[] {'(', ')'}))
					continue;

				foreach (TreeNode fieldNode in classNode.Nodes)
				{
					if ((fieldNode.Tag as LexImportField).ID == currentMarker.FwId)
					{
						tvDestination.SelectedNode = fieldNode;
						found = true;
						break;
					}
				}
				if (found)
					break;
			}
			if (!found && tvDestination.Nodes.Count > 0)	// make first entry topmost and visible
				tvDestination.Nodes[0].EnsureVisible();

			// set the writing system combo box
			foreach (DictionaryEntry lang in m_uiLangs)
			{
				LanguageInfoUI langInfo = lang.Value as LanguageInfoUI;
				// make sure there is only one entry for each writing system (especially 'ignore')
				if (cbLangDesc.FindStringExact(langInfo.ToString()) < 0)
				{
					cbLangDesc.Items.Add(langInfo);
					if (langInfo.FwName == currentMarker.WritingSystem)
						cbLangDesc.SelectedItem = langInfo;
				}
			}
			if (cbLangDesc.SelectedIndex < 0)
			{
				// default to ignore if it's in the list
				int ignorePos = cbLangDesc.FindStringExact(MarkerPresenter.ContentMapping.Ignore());
				if (ignorePos >= 0)
					cbLangDesc.SelectedIndex = ignorePos;
				else
					cbLangDesc.SelectedIndex = 0;	// first item in list as fail safe
			}

			// add the func if it's present
			m_refFuncString = string.Empty;
			if (currentMarker.IsRefField)
			{
				m_refFuncString = currentMarker.RefField;

				cbFunction.Enabled = true;

				TreeNode node = tvDestination.SelectedNode;
				if (node != null)
				{
					LexImportField field = node.Tag as LexImportField;
					if (field != null)
					{
						FillLexicalRefTypesCombo(field);
						// walk the name to abbr list and select the name
						string name = m_refFuncString;
						foreach (DictionaryEntry de in m_htNameToAbbr)
						{
							NameWSandAbbr nwsa = (NameWSandAbbr)de.Value;
							//if (de.Value as string == name)
							if (nwsa.abbr == name)
							{
								//name = de.Key as string;
								name = nwsa.name;	//.abbr;
								break;
							}
						}
						cbFunction.Text = name;
					}
				}
			}
			m_refFuncStringOrig = m_refFuncString;	// save the initial value

			// set the exclude chkbox and select item from FW Destination
			if (currentMarker.Exclude)// currentMarker.IsLangIgnore || // currentMarker.DestinationField == MarkerPresenter.ContentMapping.Ignore() ||
			{
				chkbxExclude.Checked = true;
				chkbxAutoField.Enabled = false;
				tvDestination.Enabled = false;
				EnableLangDesc(false);
			}

			rbAbbrName.Checked = true;
			if (currentMarker.IsAbbrvField)
			{
				// set the proper radio button
				if (currentMarker.ClsFieldDescription.IsAbbr)
					rbAbbrAbbr.Checked = true;
			}

			// LT-4722
			// btnAddCustomField.Visible = false;
		}