示例#1
0
        private void UpdateChildProviders()
        {
            //prefer a linked repository with both
            if (RepositoryLocator.DataExportRepository != null)
            {
                try
                {
                    CoreChildProvider = new DataExportChildProvider(RepositoryLocator, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier);
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show(e);
                }
            }

            //there was an error generating a data export repository or there was no repository specified

            //so just create a catalogue one
            if (CoreChildProvider == null)
            {
                CoreChildProvider = new CatalogueChildProvider(RepositoryLocator.CatalogueRepository, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier);
            }


            CoreChildProvider.GetPluginChildren();
            RefreshBus.ChildProvider = CoreChildProvider;
        }
示例#2
0
        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();
                }
            }
        }
示例#3
0
        private IEnumerable ChildrenGetter(object model)
        {
            if (AxeChildren != null && AxeChildren.Contains(model.GetType()))
            {
                return(new object[0]);
            }

            return(CoreChildProvider.GetChildren(model));
        }
示例#4
0
        public virtual void SelectAnythingThen(DialogArgs args, Action <IMapsDirectlyToDatabaseTable> callback)
        {
            var selected = SelectOne(args, CoreChildProvider.GetAllSearchables().Keys.ToArray());

            if (selected != null)
            {
                callback(selected);
            }
        }
示例#5
0
        /// <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);
        }
示例#6
0
        protected override ICoreChildProvider GetChildProvider()
        {
            //constructor call in base class
            if (PluginUserInterfaces == null)
            {
                return(null);
            }

            //Dispose the old one
            ICoreChildProvider temp = null;

            //prefer a linked repository with both
            if (RepositoryLocator.DataExportRepository != null)
            {
                try
                {
                    temp = new DataExportChildProvider(RepositoryLocator, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier, CoreChildProvider as DataExportChildProvider);
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show(e);
                }
            }

            //there was an error generating a data export repository or there was no repository specified

            //so just create a catalogue one
            if (temp == null)
            {
                temp = new CatalogueChildProvider(RepositoryLocator.CatalogueRepository, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier, CoreChildProvider as CatalogueChildProvider);
            }

            // first time
            if (CoreChildProvider == null)
            {
                CoreChildProvider = temp;
            }
            else
            {
                CoreChildProvider.UpdateTo(temp);
            }

            return(CoreChildProvider);
        }
示例#7
0
        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);
        }
示例#8
0
        protected virtual ICoreChildProvider GetChildProvider()
        {
            // Build new CoreChildProvider in a temp then update to it to avoid stale references
            ICoreChildProvider temp = null;

            //prefer a linked repository with both
            if (RepositoryLocator.DataExportRepository != null)
            {
                try
                {
                    temp = new DataExportChildProvider(RepositoryLocator, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier, CoreChildProvider as DataExportChildProvider);
                }
                catch (Exception e)
                {
                    ShowException("Error constructing DataExportChildProvider", e);
                }
            }

            //there was an error generating a data export repository or there was no repository specified

            //so just create a catalogue one
            if (temp == null)
            {
                temp = new CatalogueChildProvider(RepositoryLocator.CatalogueRepository, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier, CoreChildProvider as CatalogueChildProvider);
            }

            // first time
            if (CoreChildProvider == null)
            {
                CoreChildProvider = temp;
            }
            else
            {
                CoreChildProvider.UpdateTo(temp);
            }

            return(CoreChildProvider);
        }
示例#9
0
        /// <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);
                        }
                    }
                }
            }
        }
示例#10
0
        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);
        }
示例#11
0
        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();
        }
示例#12
0
 /// <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)
 {
     return(CoreChildProvider.GetRootObjectOrSelf(objectToEmphasise));
 }
示例#13
0
        /// <inheritdoc/>
        public virtual void Publish(DatabaseEntity databaseEntity)
        {
            var fresh = GetChildProvider();

            CoreChildProvider.UpdateTo(fresh);
        }
示例#14
0
 /// <inheritdoc/>
 public virtual IEnumerable <IMapsDirectlyToDatabaseTable> GetAll(Type t)
 {
     return(CoreChildProvider.GetAllSearchables()
            .Keys.Where(t.IsInstanceOfType));
 }
示例#15
0
 /// <inheritdoc/>
 public virtual IEnumerable <T> GetAll <T>()
 {
     return(CoreChildProvider.GetAllSearchables()
            .Keys.OfType <T>());
 }
示例#16
0
        /// <inheritdoc/>
        public virtual void Publish(IMapsDirectlyToDatabaseTable databaseEntity)
        {
            var fresh = GetChildProvider();

            CoreChildProvider.UpdateTo(fresh);
        }