NonEmptyTargetControl is a small reusable piece currently used in the BulkEditBar. It allows three options to be chosen between for dealing with non-empty target fields in bulk copy and transduce. Additionally a separator can be chosen for the append option.
Inheritance: System.Windows.Forms.UserControl, IFWDisposable
Example #1
0
		//public const int kDoitHeight = 20;

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create one
		/// </summary>
		/// <param name="bv">The BrowseViewer that it is part of.</param>
		/// <param name="spec">The parameters element of the BV, containing the
		/// 'columns' elements that specify the BE bar (among other things).</param>
		/// <param name="mediator">The mediator.</param>
		/// <param name="cache">The cache.</param>
		/// ------------------------------------------------------------------------------------
		public BulkEditBar(BrowseViewer bv, XmlNode spec, Mediator mediator, FdoCache cache)
			: this()
		{
			m_mediator = mediator;
			m_bv = bv;
			m_bv.FilterChanged += BrowseViewFilterChanged;
			m_bv.RefreshCompleted += BrowseViewSorterChanged;
			m_cache = cache;
			m_configurationNode = spec;
			// (EricP) we should probably try find someway to get these classes from the RecordClerk/List
			string bulkEditListItemsClassesValue = XmlUtils.GetManditoryAttributeValue(spec, "bulkEditListItemsClasses");
			string[] bulkEditListItemsClasses = bulkEditListItemsClassesValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string className in bulkEditListItemsClasses)
			{
				int classId = cache.MetaDataCacheAccessor.GetClassId(className);
				m_bulkEditListItemsClasses.Add((int)classId);
			}
			// get any fields that have ghosts we may want to edit (see also "ghostListField" in columnSpecs)
			string bulkEditListItemsGhostFieldsValue = XmlUtils.GetOptionalAttributeValue(spec, "bulkEditListItemsGhostFields");
			if (!String.IsNullOrEmpty(bulkEditListItemsGhostFieldsValue))
			{
				string[] bulkEditListItemsGhostFields = bulkEditListItemsGhostFieldsValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (string classAndField in bulkEditListItemsGhostFields)
					m_bulkEditListItemsGhostFields.Add(GhostParentHelper.Create(m_cache.ServiceLocator, classAndField));
			}
			MakeItems();

			m_sBulkDeleteIfZero = XmlUtils.GetOptionalAttributeValue(spec, "bulkDeleteIfZero");
			this.AccessibilityObject.Name = "BulkEditBar";

			m_listChoiceTargetCombo.SelectedIndexChanged += new EventHandler(m_listChoiceTargetCombo_SelectedIndexChanged);

			// Finish init of the FwTextBox
			m_clickCopySepBox.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_clickCopySepBox.WritingSystemCode = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
			m_clickCopySepBox.Text = " "; // default (maybe should persist?)
			m_clickCopySepBox.GotFocus += new EventHandler(m_clickCopySepBox_GotFocus);

			// Add NonBlankTargetControl as needed.
			m_bcNonEmptyTargetControl = new NonEmptyTargetControl();
			m_bcNonEmptyTargetControl.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_bcNonEmptyTargetControl.Separator = " "; // persist?
			// Set WritingSystemCode when destination field is set
			m_bcNonEmptyTargetControl.Location = new Point(170, 50);
			m_bcNonEmptyTargetControl.Name = "m_bcNonEmptyTargetControl";
			// Its size should be correctly preset.
			// todo: give it a tab stop.
			m_bulkCopyTab.Controls.Add(m_bcNonEmptyTargetControl);
			m_bulkCopyTargetCombo.SelectedIndexChanged += new EventHandler(m_bulkCopyTargetCombo_SelectedIndexChanged);

			// And for the transduce tab...  (Process Tab)
			m_trdNonEmptyTargetControl = new NonEmptyTargetControl();
			m_trdNonEmptyTargetControl.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_trdNonEmptyTargetControl.Separator = " "; // persist?
			// Set WritingSystemCode when destination field is set
			m_trdNonEmptyTargetControl.Location = new Point(170, 50);
			m_trdNonEmptyTargetControl.Name = "m_trdNonEmptyTargetControl";
			// Its size should be correctly preset.
			// todo: give it a tab stop.
			m_transduceTab.Controls.Add(m_trdNonEmptyTargetControl);
			m_transduceTargetCombo.SelectedIndexChanged += new EventHandler(m_transduceTargetCombo_SelectedIndexChanged);
			m_enableBulkEditTabsNode = XmlUtils.FindNode(spec, "enableBulkEditTabs");
			if (m_enableBulkEditTabsNode != null)
			{
				m_bulkCopyTab.Enabled = XmlUtils.GetOptionalBooleanAttributeValue(m_enableBulkEditTabsNode, "enableBEBulkCopy", true);
				m_clickCopyTab.Enabled = XmlUtils.GetOptionalBooleanAttributeValue(m_enableBulkEditTabsNode, "enableBEClickCopy", true);
				m_transduceTab.Enabled = XmlUtils.GetOptionalBooleanAttributeValue(m_enableBulkEditTabsNode, "enableBEProcess", true);
				m_findReplaceTab.Enabled = XmlUtils.GetOptionalBooleanAttributeValue(m_enableBulkEditTabsNode, "enableBEFindReplace", true);
				m_deleteTab.Enabled = XmlUtils.GetOptionalBooleanAttributeValue(m_enableBulkEditTabsNode, "enableBEOther", true);
			}
			else
			{
				m_bulkCopyTab.Enabled =
					m_clickCopyTab.Enabled = m_transduceTab.Enabled =
					m_findReplaceTab.Enabled = m_deleteTab.Enabled = true;
			}

			m_operationsTabControl.SelectedIndexChanged += new EventHandler(m_operationsTabControl_SelectedIndexChanged);
			m_operationsTabControl.Deselecting += new TabControlCancelEventHandler(m_operationsTabControl_Deselecting);

			BulkCopyTabPageSettings.TrySwitchToLastSavedTab(this);
			// events like SelectedIndexChanged do not fire until after initialization,
			// so do it explicitly here now.
			m_operationsTabControl_SelectedIndexChanged(null, new EventArgs());
			m_setupOrRestoredBulkEditBarTab = true;

			m_previewButton.Click += new EventHandler(m_previewButton_Click);
			m_ApplyButton.Click += new EventHandler(m_ApplyButton_Click);
			m_closeButton.Click += new EventHandler(m_closeButton_Click);

			m_findReplaceSummaryLabel.WritingSystemFactory = m_cache.WritingSystemFactory;
		}