Exemple #1
0
        public ActivateItems(ITheme theme, RefreshBus refreshBus, DockPanel mainDockPanel, IRDMPPlatformRepositoryServiceLocator repositoryLocator, WindowFactory windowFactory, WindowManager windowManager, ICheckNotifier globalErrorCheckNotifier) : base(repositoryLocator, globalErrorCheckNotifier)
        {
            Theme          = theme;
            WindowFactory  = windowFactory;
            _mainDockPanel = mainDockPanel;
            _windowManager = windowManager;
            RefreshBus     = refreshBus;

            ConstructPluginChildProviders();
            CoreChildProvider = GetChildProvider();

            //Shouldn't ever change externally to your session so doesn't need constantly refreshed
            FavouritesProvider = new FavouritesProvider(this, repositoryLocator.CatalogueRepository);
            HistoryProvider    = new HistoryProvider(repositoryLocator);

            //handle custom icons from plugin user interfaces in which
            CoreIconProvider = new DataExportIconProvider(repositoryLocator, PluginUserInterfaces.ToArray());

            SelectIMapsDirectlyToDatabaseTableDialog.ImageGetter = (model) => CoreIconProvider.GetImage(model);

            WindowArranger = new WindowArranger(this, _windowManager, _mainDockPanel);

            CommandFactory          = new RDMPCombineableFactory();
            CommandExecutionFactory = new RDMPCommandExecutionFactory(this);

            ProblemProviders = new List <IProblemProvider>();
            ProblemProviders.Add(new DataExportProblemProvider());
            ProblemProviders.Add(new CatalogueProblemProvider());
            RefreshProblemProviders();

            RefreshBus.Subscribe(this);
        }
Exemple #2
0
        public ActivateItems(ITheme theme, RefreshBus refreshBus, DockPanel mainDockPanel, IRDMPPlatformRepositoryServiceLocator repositoryLocator, WindowFactory windowFactory, WindowManager windowManager, ICheckNotifier globalErrorCheckNotifier) : base(repositoryLocator, globalErrorCheckNotifier)
        {
            Theme = theme;
            InteractiveDeletes = true;
            WindowFactory      = windowFactory;
            _mainDockPanel     = mainDockPanel;
            _windowManager     = windowManager;
            RefreshBus         = refreshBus;

            RefreshBus.ChildProvider = CoreChildProvider;

            HistoryProvider = new HistoryProvider(repositoryLocator);

            WindowArranger = new WindowArranger(this, _windowManager, _mainDockPanel);

            CommandFactory          = new RDMPCombineableFactory();
            CommandExecutionFactory = new RDMPCommandExecutionFactory(this);

            ProblemProviders = new List <IProblemProvider>();
            ProblemProviders.Add(new DataExportProblemProvider());
            ProblemProviders.Add(new CatalogueProblemProvider());
            RefreshProblemProviders();

            RefreshBus.Subscribe(this);
        }
Exemple #3
0
        public TestActivateItems(UITests uiTests, MemoryDataExportRepository repo) : base(new RepositoryProvider(repo), new ToMemoryCheckNotifier())
        {
            _uiTests   = uiTests;
            Results    = new TestActivateItemsResults();
            RefreshBus = new RefreshBus();

            //don't load the comment store for every single test
            if (_commentStore == null)
            {
                _commentStore = new CommentStore();
                _commentStore.ReadComments(TestContext.CurrentContext.TestDirectory);
            }

            CommentStore = _commentStore;

            CoreChildProvider  = new DataExportChildProvider(RepositoryLocator, null, Results);
            CoreIconProvider   = new DataExportIconProvider(RepositoryLocator, null);
            FavouritesProvider = new FavouritesProvider(this, repo.CatalogueRepository);

            _problemProviders = new List <IProblemProvider>(new IProblemProvider[]
            {
                new CatalogueProblemProvider(),
                new DataExportProblemProvider()
            });

            PluginUserInterfaces = new List <IPluginUserInterface>();
        }
Exemple #4
0
 public override void Publish(IMapsDirectlyToDatabaseTable databaseEntity)
 {
     if (databaseEntity is DatabaseEntity de)
     {
         RefreshBus.Publish(this, new RefreshObjectEventArgs(de));
     }
 }
        public override void Publish(IMapsDirectlyToDatabaseTable o)
        {
            base.Publish(o);

            if (o is DatabaseEntity e)
            {
                RefreshBus.Publish(this, new RefreshObjectEventArgs(e));
            }
        }
Exemple #6
0
        public override bool DeleteWithConfirmation(IDeleteable deleteable)
        {
            if (deleteable is DatabaseEntity d && !d.Exists())
            {
                throw new Exception("Attempt made to delete an object which didn't exist");
            }

            deleteable.DeleteInDatabase();
            RefreshBus.Publish(this, new RefreshObjectEventArgs((DatabaseEntity)deleteable));
            return(true);
        }
Exemple #7
0
        public WindowManager(ITheme theme, RDMPMainForm mainForm, RefreshBus refreshBus, DockPanel mainDockPanel, IRDMPPlatformRepositoryServiceLocator repositoryLocator, ICheckNotifier globalErrorCheckNotifier)
        {
            _windowFactory = new WindowFactory(repositoryLocator, this);
            ActivateItems  = new ActivateItems(theme, refreshBus, mainDockPanel, repositoryLocator, _windowFactory, this, globalErrorCheckNotifier);

            _mainDockPanel = mainDockPanel;

            MainForm          = mainForm;
            RepositoryLocator = repositoryLocator;

            Navigation = new NavigationTrack <DockContent>((c) => c.ParentForm != null, (c) => c.Activate());
            mainDockPanel.ActiveDocumentChanged += mainDockPanel_ActiveDocumentChanged;
        }
Exemple #8
0
        public WindowManager(ITheme theme, RDMPMainForm mainForm, RefreshBus refreshBus, DockPanel mainDockPanel, IRDMPPlatformRepositoryServiceLocator repositoryLocator, ICheckNotifier globalErrorCheckNotifier)
        {
            _windowFactory = new WindowFactory(repositoryLocator, this);
            ActivateItems  = new ActivateItems(theme, refreshBus, mainDockPanel, repositoryLocator, _windowFactory, this, globalErrorCheckNotifier);

            GlobalExceptionHandler.Instance.Handler = (e) => globalErrorCheckNotifier.OnCheckPerformed(new CheckEventArgs(e.Message, CheckResult.Fail, e));

            _mainDockPanel = mainDockPanel;

            MainForm          = mainForm;
            RepositoryLocator = repositoryLocator;

            Navigation = new NavigationTrack <INavigation>(c => c.IsAlive, (c) => c.Activate(ActivateItems));
            mainDockPanel.ActiveDocumentChanged += mainDockPanel_ActiveDocumentChanged;
            ActivateItems.Emphasise             += RecordEmphasis;
        }
        public TestActivateItems(UITests uiTests, MemoryDataExportRepository repo) : base(new RepositoryProvider(repo), new ToMemoryCheckNotifier())
        {
            _uiTests   = uiTests;
            Results    = new TestActivateItemsResults();
            RefreshBus = new RefreshBus();

            //don't load the comment store for every single test
            if (_commentStore == null)
            {
                _commentStore = new CommentStore();
                _commentStore.ReadComments(TestContext.CurrentContext.TestDirectory);
            }

            CommentStore = _commentStore;

            HistoryProvider = new HistoryProvider(RepositoryLocator);

            _problemProviders = new List <IProblemProvider>(new IProblemProvider[]
            {
                new CatalogueProblemProvider(),
                new DataExportProblemProvider()
            });
        }
Exemple #10
0
        public PersistableSingleDatabaseObjectDockContent Create(IActivateItems activator, RefreshBus refreshBus,IRDMPSingleDatabaseObjectControl control, Bitmap image, IMapsDirectlyToDatabaseTable databaseObject)
        {
            var content = new PersistableSingleDatabaseObjectDockContent(control, databaseObject,refreshBus);
            _windowManager.AddWindow(content);

            AddControlToDockContent(activator, (Control)control,content,"Loading...",image);
            
            if (!RDMPMainForm.Loading)
                activator.HistoryProvider.Add(databaseObject);

            return content;
        }
Exemple #11
0
 public override void Publish(DatabaseEntity databaseEntity)
 {
     RefreshBus.Publish(this, new RefreshObjectEventArgs(databaseEntity));
 }
Exemple #12
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);
        }
Exemple #13
0
        public PersistableSingleDatabaseObjectDockContent(IRDMPSingleDatabaseObjectControl control, IMapsDirectlyToDatabaseTable databaseObject, RefreshBus refreshBus) : base(refreshBus)
        {
            _control = (Control)control;

            DatabaseObject = databaseObject;
            TabText        = "Loading...";
        }
Exemple #14
0
        public PersistableSingleDatabaseObjectDockContent(IRDMPSingleDatabaseObjectControl control, IMapsDirectlyToDatabaseTable databaseObject, RefreshBus refreshBus) : base(refreshBus)
        {
            Control = (Control)control;

            DatabaseObject = databaseObject;
            TabText        = "Loading...";

            control.UnSavedChanges += OnUnSavedChanges;
            Closing += (s, e) => control.UnSavedChanges -= OnUnSavedChanges;
        }
Exemple #15
0
 protected RDMPSingleControlTab(RefreshBus refreshBus)
 {
     refreshBus.Subscribe(this);
     FormClosed += (s, e) => refreshBus.Unsubscribe(this);
 }
Exemple #16
0
 /// <summary>
 /// Creates instance and sets <see cref="Control"/> to <paramref name="c"/>.  You
 /// will still need to add and Dock the control etc yourself
 /// </summary>
 /// <param name="refreshBus"></param>
 /// <param name="c"></param>
 public RDMPSingleControlTab(RefreshBus refreshBus, Control c)
 {
     refreshBus.Subscribe(this);
     FormClosed += (s, e) => refreshBus.Unsubscribe(this);
     Control     = c;
 }