public void RequestItemEmphasis(object sender, EmphasiseRequest request) { //ensure a relevant Toolbox is available var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(request.ObjectToEmphasise); object root = null; if (descendancy != null) { root = descendancy.Parents.FirstOrDefault(); } else { root = request.ObjectToEmphasise; //assume maybe o is a root object itself? } if (root != null) { _windowManager.ShowCollectionWhichSupportsRootObjectType(root); } //really should be a listener now btw since we just launched the relevant Toolbox if it wasn't there before var h = Emphasise; if (h != null) { var args = new EmphasiseEventArgs(request); h(this, args); var content = args.FormRequestingActivation as DockContent; if (content != null) { content.Activate(); } } }
/// <summary> /// Returns the root tree object which hosts the supplied object. If the supplied object has no known descendancy it is assumed /// to be the root object itself so it is returned /// </summary> /// <param name="objectToEmphasise"></param> /// <returns></returns> public object GetRootObjectOrSelf(IMapsDirectlyToDatabaseTable objectToEmphasise) { var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(objectToEmphasise); if (descendancy != null && descendancy.Parents.Any()) { return(descendancy.Parents[0]); } return(objectToEmphasise); }
public override void RequestItemEmphasis(object sender, EmphasiseRequest request) { //ensure a relevant Toolbox is available var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(request.ObjectToEmphasise); object root = null; if (descendancy != null) { root = descendancy.Parents.FirstOrDefault(); } else { root = request.ObjectToEmphasise; //assume maybe o is a root object itself? } if (root is CohortIdentificationConfiguration cic) { Activate <CohortIdentificationConfigurationUI, CohortIdentificationConfiguration>(cic); } else if (root != null) { _windowManager.ShowCollectionWhichSupportsRootObjectType(root); } //really should be a listener now btw since we just launched the relevant Toolbox if it wasn't there before //Look at assignments to Sender, the invocation list can change the Sender! var args = new EmphasiseEventArgs(request); base.OnEmphasise(this, args); //might be different than sender that was passed in if (args.Sender is DockContent content) { content.Activate(); } //user is being shown the given object so track it as a recent (e.g. GoTo etc) HistoryProvider.Add(args.Request.ObjectToEmphasise); }
/// <inheritdoc/> public void PublishNearest(object publish) { if (publish != null) { if (publish is DatabaseEntity d) { Publish(d); } else { var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(publish); if (descendancy != null) { var parent = descendancy.Parents.OfType <DatabaseEntity>().LastOrDefault(); if (parent != null) { Publish(parent); } } } } }
public override bool DeleteWithConfirmation(IDeleteable deleteable) { var databaseObject = deleteable as DatabaseEntity; //If there is some special way of describing the effects of deleting this object e.g. Selected Datasets var customMessageDeletable = deleteable as IDeletableWithCustomMessage; if (databaseObject is Catalogue c) { if (c.GetExtractabilityStatus(RepositoryLocator.DataExportRepository).IsExtractable) { if (YesNo("Catalogue must first be made non extractable before it can be deleted, mark non extractable?", "Make Non Extractable")) { var cmd = new ExecuteCommandChangeExtractability(this, c); cmd.Execute(); } else { return(false); } } } if (databaseObject is AggregateConfiguration ac && ac.IsJoinablePatientIndexTable()) { var users = ac.JoinableCohortAggregateConfiguration?.Users?.Select(u => u.AggregateConfiguration); if (users != null) { users = users.ToArray(); if (users.Any()) { WideMessageBox.Show("Cannot Delete", $"Cannot Delete '{ac.Name}' because it is linked to by the following AggregateConfigurations:{Environment.NewLine}{string.Join(Environment.NewLine,users)}"); return(false); } } } string overrideConfirmationText = null; if (customMessageDeletable != null) { overrideConfirmationText = "Are you sure you want to " + customMessageDeletable.GetDeleteMessage() + "?"; } //it has already been deleted before if (databaseObject != null && !databaseObject.Exists()) { return(false); } string idText = ""; if (databaseObject != null) { idText = " ID=" + databaseObject.ID; } if (databaseObject != null) { var exports = RepositoryLocator.CatalogueRepository.GetReferencesTo <ObjectExport>(databaseObject).ToArray(); if (exports.Any(e => e.Exists())) { if (YesNo("This object has been shared as an ObjectExport. Deleting it may prevent you loading any saved copies. Do you want to delete the ObjectExport definition?", "Delete ObjectExport")) { foreach (ObjectExport e in exports) { e.DeleteInDatabase(); } } else { return(false); } } } if ( YesNo( overrideConfirmationText ?? ("Are you sure you want to delete '" + deleteable + "'?") + Environment.NewLine + "(" + deleteable.GetType().Name + idText + ")", "Delete " + deleteable.GetType().Name)) { deleteable.DeleteInDatabase(); if (databaseObject == null) { var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(deleteable); if (descendancy != null) { databaseObject = descendancy.Parents.OfType <DatabaseEntity>().LastOrDefault(); } } if (deleteable is IMasqueradeAs) { databaseObject = databaseObject ?? ((IMasqueradeAs)deleteable).MasqueradingAs() as DatabaseEntity; } if (databaseObject == null) { throw new NotSupportedException("IDeletable " + deleteable + " was not a DatabaseObject and it did not have a Parent in it's tree which was a DatabaseObject (DescendancyList)"); } RefreshBus.Publish(this, new RefreshObjectEventArgs(databaseObject) { DeletedObjectDescendancy = CoreChildProvider.GetDescendancyListIfAnyFor(databaseObject) }); return(true); } return(false); }
void _activator_Emphasise(object sender, EmphasiseEventArgs args) { var rootObject = _activator.GetRootObjectOrSelf(args.Request.ObjectToEmphasise); // unpin first if there is somthing pinned, so we find our object! if (_pinFilter != null && _activator.IsRootObjectOfCollection(_collection, rootObject)) { _pinFilter.UnApplyToTree(); } //get the parental hierarchy var decendancyList = CoreChildProvider.GetDescendancyListIfAnyFor(args.Request.ObjectToEmphasise); if (decendancyList != null) { //for each parent in the decendandy list foreach (var parent in decendancyList.Parents) { //parent isn't in our tree if (Tree.IndexOf(parent) == -1) { return; } //parent is in our tree so make sure it's expanded Tree.Expand(parent); } } //tree doesn't contain object even after expanding parents int index = Tree.IndexOf(args.Request.ObjectToEmphasise); if (index == -1) { return; } if (args.Request.ExpansionDepth > 0) { try { Tree.BeginUpdate(); ExpandToDepth(args.Request.ExpansionDepth, args.Request.ObjectToEmphasise); } finally { Tree.EndUpdate(); } } if (args.Request.Pin && Settings.AllowPinning) { Pin(args.Request.ObjectToEmphasise, decendancyList); } //update index now pin filter is applied index = Tree.IndexOf(args.Request.ObjectToEmphasise); //select the object and ensure it's visible Tree.SelectedObject = args.Request.ObjectToEmphasise; Tree.EnsureVisible(index); args.Sender = Tree.FindForm(); }