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

HicServices / RDMP / 19853488435

02 Dec 2025 09:18AM UTC coverage: 57.212% (+0.02%) from 57.196%
19853488435

push

github

JFriel
remove theme settings

11494 of 21581 branches covered (53.26%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

2 existing lines in 2 files now uncovered.

32571 of 55440 relevant lines covered (58.75%)

17823.7 hits per line

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

0.0
/Application/ResearchDataManagementPlatform/WindowManagement/TopBar/RDMPTaskBarUI.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;
8
using System.Windows.Forms;
9
using Rdmp.Core;
10
using Rdmp.Core.CommandExecution.AtomicCommands;
11
using Rdmp.Core.Curation.Data;
12
using Rdmp.Core.Icons.IconProvision;
13
using Rdmp.Core.MapsDirectlyToDatabaseTable;
14
using Rdmp.Core.ReusableLibraryCode.Checks;
15
using Rdmp.Core.ReusableLibraryCode.Settings;
16
using Rdmp.UI;
17
using Rdmp.UI.SimpleDialogs;
18
using Rdmp.UI.Theme;
19

20
namespace ResearchDataManagementPlatform.WindowManagement.TopBar;
21

22
/// <summary>
23
/// Allows you to access the main object collections that make up the RDMP.  These include
24
/// </summary>
25
public partial class RDMPTaskBarUI : UserControl
26
{
27
    private WindowManager _manager;
28

29
    private const string CreateNewLayout = "<<New Layout>>";
30

31
    public RDMPTaskBarUI()
×
32
    {
33
        InitializeComponent();
×
34

35
        btnHome.Image = FamFamFamIcons.application_home.ImageToBitmap();
×
36
        btnCatalogues.Image = CatalogueIcons.Catalogue.ImageToBitmap();
×
37
        btnCatalogues.BackgroundImage =
×
38
            BackColorProvider.GetBackgroundImage(btnCatalogues.Size, RDMPCollection.Catalogue);
×
39

40
        btnCohorts.Image = CatalogueIcons.CohortIdentificationConfiguration.ImageToBitmap();
×
41
        btnCohorts.BackgroundImage = BackColorProvider.GetBackgroundImage(btnCohorts.Size, RDMPCollection.Cohort);
×
42

43
        btnSavedCohorts.Image = CatalogueIcons.AllCohortsNode.ImageToBitmap();
×
44
        btnSavedCohorts.BackgroundImage =
×
45
            BackColorProvider.GetBackgroundImage(btnSavedCohorts.Size, RDMPCollection.SavedCohorts);
×
46

47
        btnDataExport.Image = CatalogueIcons.Project.ImageToBitmap();
×
48
        btnDataExport.BackgroundImage =
×
49
            BackColorProvider.GetBackgroundImage(btnDataExport.Size, RDMPCollection.DataExport);
×
50

51
        btnTables.Image = CatalogueIcons.TableInfo.ImageToBitmap();
×
52
        btnTables.BackgroundImage = BackColorProvider.GetBackgroundImage(btnTables.Size, RDMPCollection.Tables);
×
53

54
        btnConfiguration.Image = FamFamFamIcons.pencil_go.ImageToBitmap();
×
55
        btnConfiguration.BackgroundImage = BackColorProvider.GetBackgroundImage(btnConfiguration.Size, RDMPCollection.Datasets);
×
56

57
        btnLoads.Image = CatalogueIcons.LoadMetadata.ImageToBitmap();
×
58
        btnLoads.BackgroundImage = BackColorProvider.GetBackgroundImage(btnConfiguration.Size, RDMPCollection.DataLoad);
×
59

60
        btnFavourites.Image = CatalogueIcons.Favourite.ImageToBitmap();
×
61
        btnDeleteLayout.Image = FamFamFamIcons.delete.ImageToBitmap();
×
62

63
        cbCommits.Image = CatalogueIcons.Commit.ImageToBitmap();
×
64
        cbCommits.Checked = UserSettings.EnableCommits;
×
65
        cbCommits.CheckedChanged += (s, e) => UserSettings.EnableCommits = cbCommits.Checked;
×
66
        cbCommits.CheckOnClick = true;
×
67
    }
×
68

69
    public void SetWindowManager(WindowManager manager)
70
    {
71
        _manager = manager;
×
72

73
        //Update task bar buttons enabledness when the user navigates somewhere
74
        _manager.Navigation.Changed += (s, e) => UpdateForwardBackEnabled();
×
75

76
        btnDataExport.Enabled = manager.RepositoryLocator.DataExportRepository != null;
×
77

78
        ReCreateDropDowns();
×
79

80
        SetupToolTipText();
×
81

82
        // if we don't support commit system then disable the task bar button for it
UNCOV
83
        if (!_manager.ActivateItems.RepositoryLocator.CatalogueRepository.SupportsCommits)
×
84
        {
85
            cbCommits.Enabled = false;
×
86
            cbCommits.Text = "Repository does not support commits";
×
87
        }
88
    }
×
89

90
    /// <summary>
91
    /// Updates the enabled status (greyed out) of the Forward/Back buttons based on the current <see cref="_manager"/> <see cref="NavigationTrack{T}"/>
92
    /// </summary>
93
    private void UpdateForwardBackEnabled()
94
    {
95
        btnBack.Enabled = _manager.Navigation.CanBack();
×
96
        btnForward.Enabled = _manager.Navigation.CanForward();
×
97
    }
×
98

99

100
    private void SetupToolTipText()
101
    {
102
        try
103
        {
104
            btnHome.ToolTipText = "Home screen, shows recent objects etc";
×
105
            btnCatalogues.ToolTipText = "All datasets configured for access by RDMP";
×
106
            btnCohorts.ToolTipText = "Built queries for creating cohorts";
×
107
            btnSavedCohorts.ToolTipText = "Finalised identifier lists, ready for linkage and extraction";
×
108
            btnDataExport.ToolTipText = "Show Projects and Extractable Dataset Packages allowing data extraction";
×
109
            btnTables.ToolTipText = "Advanced features e.g. logging, credentials, dashboards etc";
×
110
            btnLoads.ToolTipText = "Load configurations for reading data into your databases";
×
111
            btnFavourites.ToolTipText = "Collection of all objects that you have favourited";
×
112
            btnConfiguration.ToolTipText = "All external datasets that have been configured for use in RDMP";
×
113
        }
×
114
        catch (Exception e)
×
115
        {
116
            _manager.ActivateItems.GlobalErrorCheckNotifier.OnCheckPerformed(
×
117
                new CheckEventArgs("Failed to setup tool tips", CheckResult.Fail, e));
×
118
        }
×
119
    }
×
120

121
    private void ReCreateDropDowns()
122
    {
123
        CreateDropDown<WindowLayout>(cbxLayouts, CreateNewLayout);
×
124
    }
×
125

126
    private void CreateDropDown<T>(ToolStripComboBox cbx, string createNewDashboard)
127
        where T : IMapsDirectlyToDatabaseTable, INamed
128
    {
129
        const int xPaddingForComboText = 10;
130

131
        if (cbx.ComboBox == null)
×
132
            throw new Exception("Expected combo box!");
×
133

134
        cbx.ComboBox.Items.Clear();
×
135

136
        var objects = _manager.RepositoryLocator.CatalogueRepository.GetAllObjects<T>();
×
137

138
        cbx.ComboBox.Items.Add("");
×
139

140
        //minimum size that it will be (same width as the combo box)
141
        var proposedComboBoxWidth = cbx.Width - xPaddingForComboText;
×
142

143
        foreach (var o in objects)
×
144
        {
145
            //add dropdown item
146
            cbx.ComboBox.Items.Add(o);
×
147

148
            //will that label be too big to fit in text box? if so expand the max width
149
            proposedComboBoxWidth = Math.Max(proposedComboBoxWidth, TextRenderer.MeasureText(o.Name, cbx.Font).Width);
×
150
        }
151

152
        cbx.DropDownWidth = Math.Min(400, proposedComboBoxWidth + xPaddingForComboText);
×
153
        cbx.ComboBox.SelectedItem = "";
×
154

155
        cbx.Items.Add(createNewDashboard);
×
156
    }
×
157

158
    private void btnHome_Click(object sender, EventArgs e)
159
    {
160
        _manager.PopHome();
×
161
    }
×
162

163
    private void ToolboxButtonClicked(object sender, EventArgs e)
164
    {
165
        var collection = ButtonToEnum(sender);
×
166

167
        if (_manager.IsVisible(collection))
×
168
            _manager.Pop(collection);
×
169
        else
170
            _manager.Create(collection);
×
171
    }
×
172

173
    private RDMPCollection ButtonToEnum(object button)
174
    {
175
        RDMPCollection collectionToToggle;
176

177
        if (button == btnCatalogues)
×
178
            collectionToToggle = RDMPCollection.Catalogue;
×
179
        else if (button == btnCohorts)
×
180
            collectionToToggle = RDMPCollection.Cohort;
×
181
        else if (button == btnDataExport)
×
182
            collectionToToggle = RDMPCollection.DataExport;
×
183
        else if (button == btnTables)
×
184
            collectionToToggle = RDMPCollection.Tables;
×
185
        else if (button == btnLoads)
×
186
            collectionToToggle = RDMPCollection.DataLoad;
×
187
        else if (button == btnSavedCohorts)
×
188
            collectionToToggle = RDMPCollection.SavedCohorts;
×
189
        else if (button == btnFavourites)
×
190
            collectionToToggle = RDMPCollection.Favourites;
×
191
        else if (button == btnConfiguration)
×
192
            collectionToToggle = RDMPCollection.Configurations;
×
193
        else
194
            throw new ArgumentOutOfRangeException(nameof(button));
×
195

196
        return collectionToToggle;
×
197
    }
198

199

200
    private void cbx_DropDownClosed(object sender, EventArgs e)
201
    {
202
        var cbx = (ToolStripComboBox)sender;
×
203

204
        if (ReferenceEquals(cbx.SelectedItem, CreateNewLayout))
×
205
            AddNewLayout();
×
206

207
        if (cbx.SelectedItem is INamed toOpen)
×
208
        {
209
            var cmd = new ExecuteCommandActivate(_manager.ActivateItems, toOpen);
×
210
            cmd.Execute();
×
211
        }
212

213
        UpdateButtonEnabledness();
×
214
    }
×
215

216

217
    private void cbx_SelectedIndexChanged(object sender, EventArgs e)
218
    {
219
        UpdateButtonEnabledness();
×
220
    }
×
221

222
    private void UpdateButtonEnabledness()
223
    {
224
        btnSaveWindowLayout.Enabled = cbxLayouts.SelectedItem is WindowLayout;
×
225
        btnDeleteLayout.Enabled = cbxLayouts.SelectedItem is WindowLayout;
×
226
    }
×
227

228
    private void AddNewLayout()
229
    {
230
        var xml = _manager.MainForm.GetCurrentLayoutXml();
×
231

232
        var dialog = new TypeTextOrCancelDialog("Layout Name", "Name", 100, null, false);
×
233
        if (dialog.ShowDialog() == DialogResult.OK)
×
234
        {
235
            var layout = new WindowLayout(_manager.RepositoryLocator.CatalogueRepository, dialog.ResultText, xml);
×
236

237
            var cmd = new ExecuteCommandActivate(_manager.ActivateItems, layout);
×
238
            cmd.Execute();
×
239

240
            ReCreateDropDowns();
×
241
        }
242
    }
×
243

244

245
    public void InjectButton(ToolStripButton button)
246
    {
247
        toolStrip1.Items.Add(button);
×
248
    }
×
249

250
    private void btnDelete_Click(object sender, EventArgs e)
251
    {
252
        ToolStripComboBox cbx;
253
        if (sender == btnDeleteLayout)
×
254
            cbx = cbxLayouts;
×
255
        else
256
            throw new Exception("Unexpected sender");
×
257

258
        if (cbx.SelectedItem is IDeleteable d)
×
259
        {
260
            _manager.ActivateItems.DeleteWithConfirmation(d);
×
261
            ReCreateDropDowns();
×
262
        }
263
    }
×
264

265
    private void btnSaveWindowLayout_Click(object sender, EventArgs e)
266
    {
267
        if (cbxLayouts.SelectedItem is WindowLayout layout)
×
268
        {
269
            var xml = _manager.MainForm.GetCurrentLayoutXml();
×
270

271
            layout.LayoutData = xml;
×
272
            layout.SaveToDatabase();
×
273
        }
274
    }
×
275

276
    private void btnBack_ButtonClick(object sender, EventArgs e)
277
    {
278
        _manager.Navigation.Back(true);
×
279
    }
×
280

281
    private void btnForward_Click(object sender, EventArgs e)
282
    {
283
        _manager.Navigation.Forward(true);
×
284
    }
×
285

286
    private void btnBack_DropDownOpening(object sender, EventArgs e)
287
    {
288
        btnBack.DropDownItems.Clear();
×
289

290
        var backIndex = 1;
×
291

292
        foreach (var history in _manager.Navigation.GetHistory(16))
×
293
        {
294
            var i = backIndex++;
×
295
            btnBack.DropDownItems.Add(history.ToString(), null, (a, b) => _manager.Navigation.Back(i, true));
×
296
        }
297
    }
×
298
}
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