Beispiel #1
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.
				//ResetStatusBarPanel("StatusPanelRecordNumber", "");
				//ResetStatusBarPanel("StatusPanelMessage", "");
				m_list.ListChanged -= new ListChangedEventHandler(OnListChanged);
				m_list.AboutToReload -= new EventHandler(m_list_AboutToReload);
				m_list.DoneReload -= new EventHandler(m_list_DoneReload);
				m_list.Dispose();
				if (m_mediator != null)
				{
					m_mediator.RemoveColleague(this);
				}
				if (m_filterProvider != null)
					m_filterProvider.Dispose();
				if (m_rch != null && m_rch is IDisposable)
					(m_rch as IDisposable).Dispose();
				if (m_recordBarHandler != null)
					m_recordBarHandler.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_mediator = null; // This has to be done after the calls to ResetStatusBarPanel in the 'true' section.
			m_list = null;
			m_id = null;
			m_clerkProvidingRootObject = null;
			m_recordBarHandler = null;
			m_filterProvider = null;
			m_activeMenuBarFilter = null;
			m_rch = null;
			m_fIsActiveInGui = false;

			m_isDisposed = true;
		}
Beispiel #2
0
		/// <summary>
		/// Record Filters that can contain more than one filter (e.g. AndFilter) should override this.
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public virtual bool Contains(RecordFilter other)
		{
			return SameFilter(other);
		}
Beispiel #3
0
		/// <summary>
		///
		/// </summary>
		/// <param name="filter"></param>
		/// <returns>True if one of our filters can be found in the given filter.</returns>
		private bool ContainsOurFilter(RecordFilter filter, out RecordFilter matchingFilter)
		{
			matchingFilter = null;
			if (filter == null)
				return false;
			for (int i = 0; i < Filters.Count; ++i)
			{
				if (filter.Contains(Filters[i] as RecordFilter))
				{
					matchingFilter = (RecordFilter)Filters[i];
					return true;
				}
			}
			return false;
		}
Beispiel #4
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the specified f.
		/// </summary>
		/// <param name="f">The f.</param>
		/// ------------------------------------------------------------------------------------------
		public void Add(RecordFilter f)
		{
			Debug.Assert(!this.Contains(f), "This filter (" + f.ToString() + ") has already been added to the list.");
			m_filters.Add(f);
		}
Beispiel #5
0
		/// <summary>
		/// Does our AndFilter Contain the other recordfilter?
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public override bool Contains(RecordFilter other)
		{
			for (int i = 0; i < this.Count; ++i)
			{
				RecordFilter filter = this.Filters[i] as RecordFilter;
				if (filter.Contains(other))
					return true;
			}
			return false;
		}
Beispiel #6
0
		/// <summary>
		/// Does our AndFilter Contain the other recordfilter or one equal to it? If so answer the equal one.
		/// </summary>
		public override RecordFilter EqualContainedFilter(RecordFilter other)
		{
			for (int i = 0; i < Count; ++i)
			{
				RecordFilter filter = this.Filters[i] as RecordFilter;
				var result = filter.EqualContainedFilter(other);
				if (result != null)
					return result;
			}
			return null;
		}
Beispiel #7
0
		/// <summary>
		/// If this or a contained filter is considered equal to the argument, answer the filter
		/// or subfilter that is consiered equal.
		/// Record Filters that can contain more than one filter (e.g. AndFilter) should override this.
		/// </summary>
		public virtual RecordFilter EqualContainedFilter(RecordFilter other)
		{
			return SameFilter(other) ? this : null;
		}
Beispiel #8
0
		/// <summary>
		/// Given the current record filter of the clerk, determine whether any of the active
		/// filters could have been created by any of your filter sort items, and if so,
		/// update the filter bar to show they are active.
		/// </summary>
		/// <param name="currentFilter"></param>
		public void UpdateActiveItems(RecordFilter currentFilter)
		{
			CheckDisposed();

			try
			{
				m_fInUpdateActive = true;
				if (currentFilter is AndFilter)
				{
					// We have to copy the list, because the internal operation of this loop
					// may change the original list, invalidating the (implicit) enumerator.
					// See LT-1133 for an example of what happens without making this copy.
					ArrayList filters = (ArrayList)(currentFilter as AndFilter).Filters.Clone();
					foreach (RecordFilter filter in filters)
					{
						ActivateCompatibleFilter(filter);
					}
				}
				else
				{
					// Try to activate the single filter itself.
					ActivateCompatibleFilter(currentFilter);
				}
			}
			finally
			{
				//Adjust the FilterBar height and combo box heights to accomodate the
				//strings in the filter comboBoxes
				AdjustBarHeights();
				m_fInUpdateActive = false;
			}
		}
Beispiel #9
0
		/// <summary>
		/// Given a filter bar cell filter which is (part of) the active filter for your
		/// clerk, if one of your cells understands it install it as the active filter
		/// for that cell. Otherwise, remove it from the clerk filter.
		/// </summary>
		/// <param name="filter"></param>
		/// <returns>true if compatible filter is found and activated, false if
		/// a match was not found and signal clerk to deactivate.</returns>
		private bool ActivateCompatibleFilter(RecordFilter filter)
		{
			foreach (FilterSortItem fsi in m_items)
			{
				if (fsi != null && fsi.SetFromFilter(filter))
					return true;
			}
			// we couldn't find a match in the active columns.
			// if we've already fully initialized the filters, then remove it from the clerk filter.
			if (FilterChanged != null)
				FilterChanged(this, new FilterChangeEventArgs(null, filter));
			return false;
		}
Beispiel #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine whether this combo item could have produced the specified filter.
		/// If so, return the string that should be displayed as the value of the combo box
		/// when this filter is active. Otherwise return null.
		/// By default, if the filter is exactly the same, just return your label.
		/// </summary>
		/// <param name="recordFilter">The record filter.</param>
		/// <param name="item">The item.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public override ITsString SetFromFilter(RecordFilter recordFilter, FilterSortItem item)
		{
			CheckDisposed();

			ListChoiceFilter filter = recordFilter as ListChoiceFilter;
			if (filter == null)
				return null;
			if (!filter.CompatibleFilter(m_colSpec))
				return null;
			return MakeLabel(filter);
		}
Beispiel #11
0
		/// <summary>
		/// If this filter could have been created from this FSI, set it as your active
		/// filter and update your display accordingly, and answer true. Otherwise
		/// answer false.
		/// </summary>
		/// <param name="filter"></param>
		/// <returns></returns>
		public bool SetFromFilter(RecordFilter filter)
		{
			CheckDisposed();

			if (filter == m_filter)
				return true;  // we're already set.
			if (m_combo == null)
				return false; // probably can't happen, but play safe
			foreach (FilterComboItem fci in m_combo.Items)
			{
				if (fci == null)
					continue; // for safety, probably can't happen
				ITsString tssLabel = fci.SetFromFilter(filter, this);
				if (tssLabel == null)
					continue;
				m_combo.SelectedIndex = -1; // prevents failure of setting Tss if not in list.
				m_combo.Tss = tssLabel;
				m_filter = filter; // remember this filter is active!
				return true;
			}
			return false;
		}
Beispiel #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine whether this combo item could have produced the specified filter.
		/// If so, return the string that should be displayed as the value of the combo box
		/// when this filter is active. Otherwise return null.
		/// By default, if the filter is exactly the same, just return your label.
		/// </summary>
		/// <param name="recordFilter">The record filter.</param>
		/// <param name="item">The item.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public virtual ITsString SetFromFilter(RecordFilter recordFilter, FilterSortItem item)
		{
			CheckDisposed();

			FilterBarCellFilter filter = recordFilter as FilterBarCellFilter;
			if (filter == null)
				return null; // combo items that don't produce FilterBarCellFilters should override.
			if (!filter.Finder.SameFinder(item.Finder))
				return null;
			IMatcher matcher = filter.Matcher;
			ITsString result = SetFromMatcher(matcher);
			if (result != null)
				m_matcher = matcher;
			return result;
		}
Beispiel #13
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.
				// We didn't make these either, but we need to deal with them.
				// No. These belong to the RecordList.
				//if (m_finder != null && (m_finder is IDisposable))
				//	(m_finder as IDisposable).Dispose();
				//if (m_sorter != null && (m_sorter is IDisposable))
				//	(m_sorter as IDisposable).Dispose();
				//if (m_filter != null)
				//	(m_filter as IDisposable).Dispose();
				//if (m_matcher != null && m_matcher is IDisposable)
				//	(m_matcher as IDisposable).Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_viewSpec = null;
			m_combo = null; // We didn't create it, so let whoever did dispose it.
			m_finder = null;
			m_sorter = null;
			m_filter = null;
			m_matcher = null;

			m_isDisposed = true;
		}
Beispiel #14
0
		/// <summary>
		/// display the given record
		/// </summary>
		/// <param name="argument">the hvo of the record</param>
		/// <returns></returns>
		public bool OnJumpToRecord(object argument)
		{
			CheckDisposed();

			bool fHandled = false;
			try
			{
				int hvoTarget = (int)argument;
				int index = IndexOfObjOrChild(hvoTarget);
				if (index == -1)
				{
					// See if base property is a virtual handler that knows how to add items.
					IAddItemToVirtualProperty adder =
						m_list.Cache.VwCacheDaAccessor.GetVirtualHandlerId(m_list.Flid) as IAddItemToVirtualProperty;
					if (adder != null && adder.Add(m_list.OwningObject.Hvo, hvoTarget))
						index = IndexOfObjOrChild(hvoTarget);
				}
				if (m_list.Filter != null && index == -1)
				{
					// We can get here with an irrelevant target hvo, for example by inserting a new
					// affix allomorph in an entry (see LT-4025).  So make sure we have a suitable
					// target before complaining to the user about a filter being on.
					FdoCache cache = m_list.Cache;
					IFwMetaDataCache mdc = cache.MetaDataCacheAccessor;
					uint clidList = mdc.GetDstClsId((uint)m_list.Flid);
					int clidObj = cache.GetClassOfObject(hvoTarget);

					// If (int) clidList is -1, that means it was for a virtual property and the IsSameOrSubclassOf
					// test won't be valid.
					// Enhance JohnT/CurtisH: It would be better to if virtual properties actually knew about their
					// destination class.
					bool fSuitableTarget;
					if ((int)clidList == -1)
						fSuitableTarget = true;
					else
						fSuitableTarget = cache.IsSameOrSubclassOf(clidObj, (int)clidList);

					if (fSuitableTarget)
					{
						DialogResult dr = MessageBox.Show(
							xWorksStrings.LinkTargetNotAvailableDueToFilter,
							xWorksStrings.TargetNotFound, MessageBoxButtons.YesNo);
						if (dr == DialogResult.Yes)
						{
							// We had changed from OnChangeFilter to SendMessage("RemoveFilters") to solve a filterbar
							// update issue reported in (LT-2448). However, that message only works in the context of a
							// BrowseViewer, not a document view (e.g. Dictionary) (see LT-7298). So, I've
							// tested OnChangeFilterClearAll, and it seems to solve both problems now.
							OnChangeFilterClearAll(null);
							m_activeMenuBarFilter = null;
							index = IndexOfObjOrChild(hvoTarget);
						}
						else
						{
							fHandled = true; // user wants to give up
							return fHandled;
						}
					}
				}

				if (index == -1)
				{
					// May be the item was just created by another program or tool (e.g., LT-8827)
					m_list.ReloadList();
					index = IndexOfObjOrChild(hvoTarget);
				}

				if (index == -1)
				{
					// It may be the wrong clerk, so just bail out.
					//MessageBox.Show("The list target is no longer available. It may have been deleted.",
					//	"Target not found", MessageBoxButtons.OK);
					return false;
				}
				else
				{
					JumpToIndex(index);
				}
				fHandled = true;
				return fHandled;	//we handled this.
			}
			finally
			{
				// Even if we didn't handle it, that might just be because something prevented us from
				// finding the object. But if we leave load-record suspended, a pane may never again get
				// drawn this whole session!
				this.SuspendLoadingRecordUntilOnJumpToRecord = false;
			}
		}
Beispiel #15
0
		/// <summary>
		/// Initialize the IxCoreColleague
		/// </summary>
		/// <param name="mediator"></param>
		/// <param name="viewConfiguration"></param>
		public virtual void Init(Mediator mediator, XmlNode viewConfiguration)
		{
			CheckDisposed();

			XmlNode clerkConfiguration = ToolConfiguration.GetClerkNodeFromToolParamsNode(viewConfiguration);
			m_mediator = mediator;
			m_clerkConfiguration = clerkConfiguration;
			m_id = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "id", "missingId");
			m_clerkProvidingRootObject = XmlUtils.GetOptionalAttributeValue(clerkConfiguration,"clerkProvidingOwner");
			m_shouldHandleDeletion = XmlUtils.GetOptionalBooleanAttributeValue(clerkConfiguration, "shouldHandleDeletion", true);
			m_fAllowDeletions = XmlUtils.GetOptionalBooleanAttributeValue(clerkConfiguration, "allowDeletions", true);
			var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
			m_list = RecordList.Create(cache, mediator, clerkConfiguration.SelectSingleNode("recordList"));
			m_list.Clerk = this;
			m_relatedClerk = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "relatedClerk");
			m_relationToRelatedClerk = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "relationToRelatedClerk");

			TryRestoreSorter(mediator, clerkConfiguration, cache);
			TryRestoreFilter(mediator, clerkConfiguration, cache);
			m_list.ListChanged += OnListChanged;
			m_list.AboutToReload += m_list_AboutToReload;
			m_list.DoneReload += m_list_DoneReload;

			XmlNode recordFilterListProviderNode = ToolConfiguration.GetDefaultRecordFilterListProvider(clerkConfiguration);
			bool fSetFilterMenu = false;
			if (recordFilterListProviderNode != null)
			{
				m_filterProvider = RecordFilterListProvider.Create(m_mediator, recordFilterListProviderNode);
				if (m_filterProvider != null && m_list.Filter != null)
				{
					// find any matching persisted menubar filter
					// NOTE: for now assume we can only set/persist one such menubar filter at a time.
					foreach (RecordFilter menuBarFilterOption in m_filterProvider.Filters)
					{
						if (m_list.Filter.Contains(menuBarFilterOption))
						{
							m_activeMenuBarFilter = menuBarFilterOption;
							m_filterProvider.OnAdjustFilterSelection(m_activeMenuBarFilter);
							m_mediator.PropertyTable.SetDefault(CurrentFilterPropertyTableId, m_activeMenuBarFilter.id, false, PropertyTable.SettingsGroup.LocalSettings);
							fSetFilterMenu = true;
							break;
						}
					}
				}
			}
			if (!fSetFilterMenu)
			{
				OnAdjustFilterSelection(null);
			}

			// we never want to persist this value, since it is dependent upon the filter property.
			m_mediator.PropertyTable.SetPropertyPersistence(CurrentFilterPropertyTableId, false, PropertyTable.SettingsGroup.LocalSettings);

			//we handled the tree bar only if we are the root clerk
			if (m_clerkProvidingRootObject == null)
			{
				m_recordBarHandler = RecordBarHandler.Create(m_mediator, clerkConfiguration);//,m_flid);
			}
			else
			{
				RecordClerk clerkProvidingRootObject;
				Debug.Assert(TryClerkProvidingRootObject(out clerkProvidingRootObject),
					"We expected to find clerkProvidingOwner '" + m_clerkProvidingRootObject +  "'. Possibly misspelled.");
			}

			//mediator. TraceLevel = TraceLevel.Info;

			//we do not want to be a top-level colleague, because
			//if we were, we would always receive events, for example navigation events
			//which might be intended for another RecordClerk, specifically the RecordClerk
			//being used by the currently active vector editor, browse view, etc.

			//so, instead, we let the currently active view include us as a "child" colleague.
			//NO! mediator.AddColleague(this);



			// Install this object in the PropertyTable so that others can find it.
			// NB: This *must* be done before the call to SetupDataContext,
			// or we are asking for an infinite loop, has SetupDataContext()
			// causes user interface widgets to wake up and look for this object.
			// If we have not registered the existence of this object yet in the property table,
			// those widgets will be inclined to try to create us.  Hence, the infinite loop.

			//Note that, on the downside, this means that we need to be careful
			//not to broadcast any record changes until we are actually initialize enough
			//to deal with the resulting request that will come from those widgets.

			StoreClerkInPropertyTable(clerkConfiguration);

			SetupDataContext(false);

		}
Beispiel #16
0
		/// <summary>
		/// Determine if the given filter (or subfilter) can be activated for the given
		/// column specification.
		/// </summary>
		/// <param name="filter">target filter</param>
		/// <param name="colSpec">column node spec </param>
		/// <returns>true, if the column node spec can use the filter.</returns>
		public bool CanActivateFilter(RecordFilter filter, XmlNode colSpec)
		{
			CheckDisposed();

			if (filter is AndFilter)
			{
				ArrayList filters = (ArrayList)(filter as AndFilter).Filters;
				foreach (RecordFilter rf in filters)
				{
					if ((rf is FilterBarCellFilter || rf is ListChoiceFilter) &&
						CanActivateFilter(rf, colSpec))
					{
						return true;
					}
				}
			}
			else if (filter is FilterBarCellFilter)
			{
				FilterBarCellFilter fbcf = filter as FilterBarCellFilter;
				IStringFinder colFinder = LayoutFinder.CreateFinder(m_cache, colSpec, m_bv.BrowseView.Vc);
				if (fbcf.Finder.SameFinder(colFinder))
					return true;
			}
			else if (filter is ListChoiceFilter)
			{
				return (filter as ListChoiceFilter).CompatibleFilter(colSpec);
			}
			return false;
		}
Beispiel #17
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Removes the specified f.
		/// </summary>
		/// <param name="f">The f.</param>
		/// ------------------------------------------------------------------------------------------
		public void Remove(RecordFilter f)
		{
			for (int i = 0; i < m_filters.Count; ++i)
			{
				if (((RecordFilter)m_filters[i]).SameFilter(f))
				{
					var filterToRemove = m_filters[i];
					m_filters.RemoveAt(i);
					break;
				}
			}
		}
Beispiel #18
0
		/// <summary>
		///
		/// </summary>
		/// <param name="filter"></param>
		/// <returns>True if one of our filters can be found in the given filter.</returns>
		private bool ContainsOurFilter(RecordFilter filter)
		{
			if (filter == null)
				return false;
			for (int i = 0; i < Filters.Count; ++i)
			{
				if (filter.Contains(Filters[i] as RecordFilter))
					return true;
			}
			return false;
		}
Beispiel #19
0
		/// <summary>
		/// If this or a contained filter is considered equal to the argument, answer true
		/// </summary>
		public bool Contains(RecordFilter other)
		{
			return EqualContainedFilter(other) != null;
		}
Beispiel #20
0
		/// <summary>
		/// display the given record
		/// </summary>
		/// <param name="argument">the hvo of the record</param>
		/// <returns></returns>
		public bool OnJumpToRecord(object argument)
		{
			CheckDisposed();

			try
			{
				var hvoTarget = (int) argument;

				int index = IndexOfObjOrChildOrParent(hvoTarget);
				if (index == -1)
				{
					// See if this is a subclass that knows how to add items.
					if (AddItemToList(hvoTarget))
						index = IndexOfObjOrChildOrParent(hvoTarget);
				}
				if (m_list.Filter != null && index == -1)
				{
					// We can get here with an irrelevant target hvo, for example by inserting a new
					// affix allomorph in an entry (see LT-4025).  So make sure we have a suitable
					// target before complaining to the user about a filter being on.
					var mdc = (IFwMetaDataCacheManaged)m_list.VirtualListPublisher.MetaDataCache;
					int clidList = mdc.FieldExists(m_list.Flid) ? mdc.GetDstClsId(m_list.Flid) : -1;
					int clidObj = m_list.Cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvoTarget).ClassID;

					// If (int) clidList is -1, that means it was for a decorator property and the IsSameOrSubclassOf
					// test won't be valid.
					// Enhance JohnT/CurtisH: It would be better to if decorator properties were recorded in the MDC, or
					// if we could access the decorator MDC.
					bool fSuitableTarget = clidList == -1 || DomainObjectServices.IsSameOrSubclassOf(mdc, clidObj, clidList);

					if (fSuitableTarget)
					{
						DialogResult dr = MessageBox.Show(
							xWorksStrings.LinkTargetNotAvailableDueToFilter,
							xWorksStrings.TargetNotFound, MessageBoxButtons.YesNo);
						if (dr == DialogResult.Yes)
						{
							// We had changed from OnChangeFilter to SendMessage("RemoveFilters") to solve a filterbar
							// update issue reported in (LT-2448). However, that message only works in the context of a
							// BrowseViewer, not a document view (e.g. Dictionary) (see LT-7298). So, I've
							// tested OnChangeFilterClearAll, and it seems to solve both problems now.
							OnChangeFilterClearAll(null);
							m_activeMenuBarFilter = null;
							index = IndexOfObjOrChildOrParent(hvoTarget);
						}
						else
						{
							// user wants to give up
							return true;
						}
					}
				}

				if (index == -1)
				{
					// May be the item was just created by another program or tool (e.g., LT-8827)
					m_list.ReloadList();
					index = IndexOfObjOrChildOrParent(hvoTarget);
					if (index == -1)
					{
						// It may be the wrong clerk, so just bail out.
						//MessageBox.Show("The list target is no longer available. It may have been deleted.",
						//	"Target not found", MessageBoxButtons.OK);
						return false;
					}
				}
				JumpToIndex(index);
				return true;	//we handled this.
			}
			finally
			{
				// Even if we didn't handle it, that might just be because something prevented us from
				// finding the object. But if we leave load-record suspended, a pane may never again get
				// drawn this whole session!
				SuspendLoadingRecordUntilOnJumpToRecord = false;
			}
		}
Beispiel #21
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// This is the start of an equality test for filters, but for now I (JohnT) am not
		/// making it an actual Equals function, since it may not be robust enough to
		/// satisfy all the functions of Equals, and I don't want to mess with changing the
		/// hash function. It is mainly for FilterBarRecordFilters, so for now other classes
		/// just answer false.
		/// </summary>
		/// <param name="other">The other.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------------
		public override bool SameFilter(RecordFilter other)
		{
			FilterBarCellFilter fbcOther = other as FilterBarCellFilter;
			if (fbcOther == null)
				return false;
			return fbcOther.m_finder.SameFinder(m_finder) && fbcOther.m_matcher.SameMatcher(m_matcher);
		}
Beispiel #22
0
		/// <summary>
		/// Change the list filter to the currently selected (checked) FilterList item.
		/// This selection is stored in the property table based on the name of the filter
		/// associated with the current clerk.
		/// </summary>
		private void OnChangeFilterToCheckedListPropertyChoice()
		{
			string filterName = m_mediator.PropertyTable.GetStringProperty(CurrentFilterPropertyTableId, "", PropertyTable.SettingsGroup.LocalSettings);
			RecordFilter addf = null;
			RecordFilter remf = null;
			var nof = new NoFilters();
			// Check for special cases.
			if (filterName == (new UncheckAll()).Name)
			{
				// we're simply unselecting all items in the list.
				// no need for further changes.
				return;
			}

			if (filterName == nof.Name)
			{
				OnChangeFilterClearAll(null); // get rid of all the ones we're allowed to.
				return;
			}
			else if (m_filterProvider != null)
			{
				addf = (RecordFilter)m_filterProvider.GetFilter(filterName);
				if (addf == null || addf is NullFilter)
				{
					// If we have no filter defined for this name, it is effectively another way to turn
					// filters off. Turn off all we can.
					OnChangeFilterClearAll(null); // get rid of all the ones we're allowed to.
					return;
				}
				// If we have a menu-type filter active, remove it. Otherwise don't remove anything.
				remf = m_activeMenuBarFilter;
				m_activeMenuBarFilter = addf is NullFilter ? null : addf;
			}
			OnChangeFilter(new FilterChangeEventArgs(addf, remf));
		}
Beispiel #23
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Removes the specified f.
		/// </summary>
		/// <param name="f">The f.</param>
		/// ------------------------------------------------------------------------------------------
		public void Remove(RecordFilter f)
		{
			for (int i = 0; i < m_filters.Count; ++i)
			{
				if ((m_filters[i] as RecordFilter).SameFilter(f))
				{
					m_filters.RemoveAt(i);
					break;
				}
			}
		}
Beispiel #24
0
		private static void AddFilterChoice(RecordFilter filter, UIListDisplayProperties display)
		{
			string value = filter.id;
			string imageName = filter.imageName;
			// Since we are storing actual, instantiated filter objects, there's no point in also keeping
			// their configuration information separately. Any configuration information they had would
			// have already been sucked in when the filter was created.
			display.List.Add(filter.Name, value, imageName, null);
		}
Beispiel #25
0
		/// ---------------------------------------------------------------------------------------
		/// <summary>
		/// This is the start of an equality test for filters, but for now I (JohnT) am not
		/// making it an actual Equals function, since it may not be robust enough to
		/// satisfy all the functions of Equals, and I don't want to mess with changing the
		/// hash function. It is mainly for FilterBarRecordFilters, so for now other classes
		/// just answer false.
		/// </summary>
		/// <param name="other">The other.</param>
		/// <returns></returns>
		/// ---------------------------------------------------------------------------------------
		public virtual bool SameFilter(RecordFilter other)
		{
			return other == this;
		}
Beispiel #26
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)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (m_isDisposed)
				return;


			if (disposing)
			{
				// Dispose managed resources here.
				//ResetStatusBarPanel("StatusPanelRecordNumber", "");
				//ResetStatusBarPanel("StatusPanelMessage", "");
				m_list.ListChanged -= OnListChanged;
				m_list.AboutToReload -= m_list_AboutToReload;
				m_list.DoneReload -= m_list_DoneReload;
				RemoveNotification(); // before disposing list, we need it to get to the Cache.
				m_list.Dispose();
				if (m_mediator != null)
				{
					m_mediator.RemoveColleague(this);
				}
				if (m_rch != null)
					m_rch.Dispose();
				if (m_recordBarHandler != null)
					m_recordBarHandler.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_mediator = null; // This has to be done after the calls to ResetStatusBarPanel in the 'true' section.
			m_list = null;
			m_id = null;
			m_clerkProvidingRootObject = null;
			m_recordBarHandler = null;
			m_filterProvider = null;
			m_activeMenuBarFilter = null;
			m_rch = null;
			m_fIsActiveInGui = false;

			m_isDisposed = true;
		}
Beispiel #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FilterChangeEventArgs"/> class.
		/// </summary>
		/// <param name="added">The added RecordFilter.</param>
		/// <param name="removed">The removed RecordFilter.</param>
		/// ------------------------------------------------------------------------------------
		public FilterChangeEventArgs(RecordFilter added, RecordFilter removed)
		{
			m_added = added;
			m_removed = removed;
		}
Beispiel #28
0
		public void OnChangeFilterClearAll(object commandObject)
		{
			CheckDisposed();

			m_activeMenuBarFilter = null; // there won't be a menu bar filter after this.
			if (Filter is AndFilter)
			{
				// If some parts are not user visible we should not remove them.
				var af = (AndFilter) Filter;
				var children = af.Filters;
				var childrenToKeep = from RecordFilter filter in children where !filter.IsUserVisible select filter;
				var count = childrenToKeep.Count();
				if (count == 1)
				{
					OnChangeFilter(new FilterChangeEventArgs(childrenToKeep.First(), af));
					return;
				}
				else if (count > 0)
				{
					var af2 = m_list.CreateNewAndFilter(childrenToKeep.ToArray());
					OnChangeFilter(new FilterChangeEventArgs(af2, Filter));
					return;
				}
				// Otherwise none of the children need to be kept, get rid of the whole filter.
			}

			OnChangeFilter(new FilterChangeEventArgs(null, Filter));
		}
Beispiel #29
0
		/// <summary>
		/// Test to see if this filter matches the other filter.
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public override bool SameFilter(RecordFilter other)
		{
			return (other != null && other is WordSetFilter &&
					other.id == this.id && other.Name == this.Name);
		}
Beispiel #30
0
		/// <summary>
		/// Change the list filter to the currently selected (checked) FilterList item.
		/// This selection is stored in the property table based on the name of the filter
		/// associated with the current clerk.
		/// </summary>
		private void OnChangeFilterToCheckedListPropertyChoice()
		{
			string filterName = m_mediator.PropertyTable.GetStringProperty(this.CurrentFilterPropertyTableId, "", PropertyTable.SettingsGroup.LocalSettings);
			RecordFilter addf = null;
			RecordFilter remf = null;
			NoFilters nof = new NoFilters();
			// Check for special cases.
			if (filterName == (new Filters.UncheckAll()).Name)
			{
				// we're simply unselecting all items in the list.
				// no need for further changes.
				return;
			}
			else if (filterName == nof.Name)
			{
				remf = Filter;
				m_activeMenuBarFilter = null;
			}
			else if (m_filterProvider != null)
			{
				addf = (RecordFilter)m_filterProvider.GetFilter(filterName);
				// If we have a filter defined for this filterName, then only remove the activeMenuBarFilter.
				// Otherwise remove all filters.
				if (addf != null)
					remf = m_activeMenuBarFilter;
				else
					remf = Filter;
				m_activeMenuBarFilter = addf is NullFilter ? null : addf;
			}
			OnChangeFilter(new FilterChangeEventArgs(addf, remf));
		}