• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 6245535001

20 Sep 2023 07:44AM UTC coverage: 57.013%. First build
6245535001

push

github

web-flow
8.1.0 Release (#1628)

* Bump Newtonsoft.Json from 13.0.1 to 13.0.2

Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 13.0.1 to 13.0.2.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/13.0.1...13.0.2)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump NLog from 5.0.5 to 5.1.0

Bumps [NLog](https://github.com/NLog/NLog) from 5.0.5 to 5.1.0.
- [Release notes](https://github.com/NLog/NLog/releases)
- [Changelog](https://github.com/NLog/NLog/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/NLog/NLog/compare/v5.0.5...v5.1.0)

---
updated-dependencies:
- dependency-name: NLog
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump NLog from 5.0.5 to 5.1.0

* Fix -r flag - should have been --results-directory all along

* Bump Newtonsoft.Json from 13.0.1 to 13.0.2

* Bump YamlDotNet from 12.0.2 to 12.1.0

Bumps [YamlDotNet](https://github.com/aaubry/YamlDotNet) from 12.0.2 to 12.1.0.
- [Release notes](https://github.com/aaubry/YamlDotNet/releases)
- [Commits](https://github.com/aaubry/YamlDotNet/compare/v12.0.2...v12.1.0)

---
updated-dependencies:
- dependency-name: YamlDotNet
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump Moq from 4.18.2 to 4.18.3

Bumps [Moq](https://github.com/moq/moq4) from 4.18.2 to 4.18.3.
- [Release notes](https://github.com/moq/moq4/releases)
- [Changelog](https://github.com/moq/moq4/blob/main/CHANGELOG.md)
- [Commits](https://github.com/moq/moq4/compare/v4.18.2...v4.18.3)

---
updated-dependencies:
- dependency-name: Moq
... (continued)

10732 of 20257 branches covered (0.0%)

Branch coverage included in aggregate %.

48141 of 48141 new or added lines in 1086 files covered. (100.0%)

30685 of 52388 relevant lines covered (58.57%)

7387.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Application/ResearchDataManagementPlatform/WindowManagement/WindowFactory.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System.Windows.Forms;
8
using Rdmp.Core;
9
using Rdmp.Core.Curation.Data;
10
using Rdmp.Core.Curation.Data.Dashboarding;
11
using Rdmp.Core.MapsDirectlyToDatabaseTable;
12
using Rdmp.Core.Repositories;
13
using Rdmp.UI;
14
using Rdmp.UI.Collections;
15
using Rdmp.UI.ItemActivation;
16
using Rdmp.UI.Refreshing;
17
using Rdmp.UI.SimpleControls;
18
using Rdmp.UI.SingleControlForms;
19
using Rdmp.UI.TestsAndSetup.ServicePropogation;
20
using ResearchDataManagementPlatform.WindowManagement.ContentWindowTracking.Persistence;
21
using ResearchDataManagementPlatform.WindowManagement.TabPageContextMenus;
22
using SixLabors.ImageSharp;
23
using SixLabors.ImageSharp.PixelFormats;
24
using WeifenLuo.WinFormsUI.Docking;
25

26
namespace ResearchDataManagementPlatform.WindowManagement;
27

28
/// <summary>
29
/// Translates Controls into docked tabs (DockContent).  Provides overloads for the two main control Types IRDMPSingleDatabaseObjectControl and
30
/// IObjectCollectionControl (for <see cref="RDMPCollectionUI"/> see <see cref="WindowManager"/>).
31
/// </summary>
32
public class WindowFactory
33
{
34
    private readonly WindowManager _windowManager;
35

36
    /// <summary>
37
    /// Location of the Catalogue / Data export repository databases (and allows access to repository objects)
38
    /// </summary>
39
    public IRDMPPlatformRepositoryServiceLocator RepositoryLocator { get; set; }
×
40

41
    private readonly IconFactory _iconFactory = IconFactory.Instance;
×
42

43

44
    public WindowFactory(IRDMPPlatformRepositoryServiceLocator repositoryLocator, WindowManager windowManager)
×
45
    {
46
        _windowManager = windowManager;
×
47
        RepositoryLocator = repositoryLocator;
×
48
    }
×
49

50
    public PersistableToolboxDockContent Create(IActivateItems activator, Control control, string label,
51
        Image<Rgba32> image, RDMPCollection collection)
52
    {
53
        var content = new PersistableToolboxDockContent(collection);
×
54

55
        AddControlToDockContent(activator, control, content, label, image);
×
56

57
        return content;
×
58
    }
59

60
    public PersistableSingleDatabaseObjectDockContent Create(IActivateItems activator, RefreshBus refreshBus,
61
        IRDMPSingleDatabaseObjectControl control, Image<Rgba32> image, IMapsDirectlyToDatabaseTable databaseObject)
62
    {
63
        var content = new PersistableSingleDatabaseObjectDockContent(control, databaseObject, refreshBus);
×
64
        _windowManager.AddWindow(content);
×
65

66
        AddControlToDockContent(activator, (Control)control, content, "Loading...", image);
×
67

68
        if (!RDMPMainForm.Loading)
×
69
            activator.HistoryProvider.Add(databaseObject);
×
70

71
        return content;
×
72
    }
73

74
    public PersistableObjectCollectionDockContent Create(IActivateItems activator, IObjectCollectionControl control,
75
        IPersistableObjectCollection objectCollection, Image<Rgba32> image)
76
    {
77
        //create a new persistable docking tab
78
        var content = new PersistableObjectCollectionDockContent(activator, control, objectCollection);
×
79

80
        //add the control to the tab
81
        AddControlToDockContent(activator, (Control)control, content, content.TabText, image);
×
82

83
        //add to the window tracker
84
        _windowManager.AddWindow(content);
×
85

86
        //return the tab
87
        return content;
×
88
    }
89

90
    public PersistableSingleDatabaseObjectDockContent Create(IActivateItems activator,
91
        IRDMPSingleDatabaseObjectControl control, DatabaseEntity entity)
92
    {
93
        var content = new PersistableSingleDatabaseObjectDockContent(control, entity, activator.RefreshBus);
×
94

95
        var img = activator.CoreIconProvider.GetImage(entity);
×
96
        AddControlToDockContent(activator, (Control)control, content, entity.ToString(), img);
×
97

98
        if (!RDMPMainForm.Loading)
×
99
            activator.HistoryProvider.Add(entity);
×
100

101
        return content;
×
102
    }
103

104

105
    public DockContent Create(IActivateItems activator, Control control, string label, Image<Rgba32> image)
106
    {
107
        DockContent content = new RDMPSingleControlTab(activator.RefreshBus, control);
×
108

109
        AddControlToDockContent(activator, control, content, label, image);
×
110

111
        _windowManager.AddAdhocWindow(content);
×
112

113
        return content;
×
114
    }
115

116
    private void AddControlToDockContent(IActivateItems activator, Control control, DockContent content, string label,
117
        Image<Rgba32> image)
118
    {
119
        control.Dock = DockStyle.Fill;
×
120
        content.Controls.Add(control);
×
121
        content.TabText = label;
×
122

123
        if (image != null) content.Icon = _iconFactory.GetIcon(image);
×
124

125

126
        if (control is IConsultableBeforeClosing consult)
×
127
            content.FormClosing += consult.ConsultAboutClosing;
×
128

129
        if (control is ISaveableUI saveable)
×
130
            content.FormClosing += (s, e) => saveable.GetObjectSaverButton()?.CheckForUnsavedChangesAnOfferToSave();
×
131

132
        content.KeyPreview = true;
×
133

134
        if (content is RDMPSingleControlTab tab)
×
135
        {
136
            content.TabPageContextMenuStrip = new RDMPSingleControlTabMenu(activator, tab, _windowManager);
×
137

138
            //Create handler for AfterPublish
139
            void Handler(object s, RefreshObjectEventArgs e)
140
            {
141
                // After global changes, rebuild the context menu
142

143
                if (!content.IsDisposed)
144
                    content.TabPageContextMenuStrip = new RDMPSingleControlTabMenu(activator, tab, _windowManager);
145
                else activator.RefreshBus.AfterPublish -= Handler; //don't leak handlers
146
            }
147

148
            //register the event handler
149
            activator.RefreshBus.AfterPublish += Handler;
×
150
        }
151
    }
×
152
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc