1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
//
// ManagePackagesDialog.UI.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using ExtendedTitleBarDialog = MonoDevelop.Components.ExtendedTitleBarDialog;
using InformationPopoverWidget = MonoDevelop.Components.InformationPopoverWidget;
using System;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using Xwt;
using Xwt.Drawing;
namespace MonoDevelop.PackageManagement
{
internal partial class ManagePackagesDialog : ExtendedTitleBarDialog
{
ComboBox packageSourceComboBox;
SearchTextEntry packageSearchEntry;
ListView packagesListView;
VBox packageInfoVBox;
HBox packageNameHBox;
Label packageNameLabel;
LinkLabel packageIdLink;
Label packageDescription;
Label packageAuthor;
Label packagePublishedDate;
Label packageDownloads;
LinkLabel packageLicenseLink;
LinkLabel packageProjectPageLink;
Label packageDependenciesList;
HBox packageDependenciesHBox;
HBox packageDependenciesListHBox;
Label packageDependenciesNoneLabel;
CheckBox showPrereleaseCheckBox;
Label packageId;
Button addPackagesButton;
FrameBox loadingSpinnerFrame;
HBox errorMessageHBox;
Label errorMessageLabel;
Label loadingSpinnerLabel;
FrameBox noPackagesFoundFrame;
ComboBox packageVersionComboBox;
HBox packageVersionsHBox;
Label packageVersionsLabel;
Label browseLabel;
Label installedLabel;
Label updatesLabel;
Label consolidateLabel;
VBox projectsListViewVBox;
Label projectsListViewLabel;
ListView projectsListView;
HBox currentPackageVersionHBox;
Label currentPackageVersionLabel;
Label currentPackageVersion;
InformationPopoverWidget currentPackageVersionInfoPopoverWidget;
Button closeButton;
int packageInfoFontSize = 11;
void Build ()
{
Title = GettextCatalog.GetString ("Manage NuGet Packages – Solution");
Width = 840;
Height = 528;
Padding = new WidgetSpacing ();
if (Platform.IsWindows) {
packageInfoFontSize = 9;
}
// Top part of dialog:
// Package sources and search.
var topHBox = new HBox ();
topHBox.Margin = new WidgetSpacing (8, 5, 6, 5);
packageSourceComboBox = new ComboBox ();
packageSourceComboBox.Name = "packageSourceComboBox";
packageSourceComboBox.MinWidth = 200;
topHBox.PackStart (packageSourceComboBox);
int tabLabelMinWidth = 60;
browseLabel = new Label ();
browseLabel.Text = GettextCatalog.GetString ("Browse");
browseLabel.Tag = browseLabel.Text;
browseLabel.MinWidth = tabLabelMinWidth;
browseLabel.MarginLeft = 10;
browseLabel.CanGetFocus = true;
browseLabel.Accessible.Role = Xwt.Accessibility.Role.Button;
topHBox.PackStart (browseLabel);
installedLabel = new Label ();
installedLabel.Text = GettextCatalog.GetString ("Installed");
installedLabel.Tag = installedLabel.Text;
installedLabel.MinWidth = tabLabelMinWidth;
installedLabel.CanGetFocus = true;
installedLabel.Accessible.Role = Xwt.Accessibility.Role.Button;
topHBox.PackStart (installedLabel);
updatesLabel = new Label ();
updatesLabel.Text = GettextCatalog.GetString ("Updates");
updatesLabel.Tag = updatesLabel.Text;
updatesLabel.MinWidth = tabLabelMinWidth;
updatesLabel.CanGetFocus = true;
updatesLabel.Accessible.Role = Xwt.Accessibility.Role.Button;
topHBox.PackStart (updatesLabel);
consolidateLabel = new Label ();
consolidateLabel.Text = GettextCatalog.GetString ("Consolidate");
consolidateLabel.Tag = consolidateLabel.Text;
consolidateLabel.MinWidth = tabLabelMinWidth;
consolidateLabel.CanGetFocus = true;
consolidateLabel.Accessible.Role = Xwt.Accessibility.Role.Button;
topHBox.PackStart (consolidateLabel);
packageSearchEntry = new SearchTextEntry ();
packageSearchEntry.Name = "managePackagesDialogSearchEntry";
packageSearchEntry.WidthRequest = 187;
packageSearchEntry.Accessible.Label = GettextCatalog.GetString ("Package Search");
topHBox.PackEnd (packageSearchEntry);
this.HeaderContent = topHBox;
// Middle of dialog:
// Packages and package information.
var mainVBox = new VBox ();
Content = mainVBox;
var middleHBox = new HBox ();
middleHBox.Spacing = 0;
var middleFrame = new FrameBox ();
middleFrame.Content = middleHBox;
middleFrame.BorderWidth = new WidgetSpacing (0, 0, 0, 1);
middleFrame.BorderColor = Styles.LineBorderColor;
mainVBox.PackStart (middleFrame, true, true);
// Error information.
var packagesListVBox = new VBox ();
packagesListVBox.Spacing = 0;
errorMessageHBox = new HBox ();
errorMessageHBox.Margin = new WidgetSpacing ();
errorMessageHBox.BackgroundColor = Styles.ErrorBackgroundColor;
errorMessageHBox.Visible = false;
var errorImage = new ImageView ();
errorImage.Margin = new WidgetSpacing (10, 0, 0, 0);
errorImage.Image = ImageService.GetIcon (MonoDevelop.Ide.Gui.Stock.Warning, Gtk.IconSize.Menu);
errorImage.HorizontalPlacement = WidgetPlacement.End;
errorMessageHBox.PackStart (errorImage);
errorMessageLabel = new Label ();
errorMessageLabel.TextColor = Styles.ErrorForegroundColor;
errorMessageLabel.Margin = new WidgetSpacing (5, 5, 5, 5);
errorMessageLabel.Wrap = WrapMode.Word;
errorMessageHBox.PackStart (errorMessageLabel, true);
packagesListVBox.PackStart (errorMessageHBox);
// Packages list.
middleHBox.PackStart (packagesListVBox, true, true);
packagesListView = new ListView ();
packagesListView.BorderVisible = false;
packagesListView.HeadersVisible = false;
packagesListVBox.PackStart (packagesListView, true, true);
// Loading spinner.
var loadingSpinnerHBox = new HBox ();
loadingSpinnerHBox.HorizontalPlacement = WidgetPlacement.Center;
var loadingSpinner = new Spinner ();
loadingSpinner.Animate = true;
loadingSpinner.MinWidth = 20;
loadingSpinnerHBox.PackStart (loadingSpinner);
loadingSpinnerLabel = new Label ();
loadingSpinnerLabel.Text = GettextCatalog.GetString ("Loading package list...");
loadingSpinnerHBox.PackEnd (loadingSpinnerLabel);
loadingSpinnerFrame = new FrameBox ();
loadingSpinnerFrame.Visible = false;
loadingSpinnerFrame.BackgroundColor = Styles.BackgroundColor;
loadingSpinnerFrame.Content = loadingSpinnerHBox;
loadingSpinnerFrame.BorderWidth = new WidgetSpacing ();
packagesListVBox.PackStart (loadingSpinnerFrame, true, true);
// No packages found label.
var noPackagesFoundHBox = new HBox ();
noPackagesFoundHBox.HorizontalPlacement = WidgetPlacement.Center;
var noPackagesFoundLabel = new Label ();
noPackagesFoundLabel.Text = GettextCatalog.GetString ("No matching packages found.");
noPackagesFoundHBox.PackEnd (noPackagesFoundLabel);
noPackagesFoundFrame = new FrameBox ();
noPackagesFoundFrame.Visible = false;
noPackagesFoundFrame.BackgroundColor = Styles.BackgroundColor;
noPackagesFoundFrame.Content = noPackagesFoundHBox;
noPackagesFoundFrame.BorderWidth = new WidgetSpacing ();
packagesListVBox.PackStart (noPackagesFoundFrame, true, true);
// Package information
packageInfoVBox = new VBox ();
var packageInfoFrame = new FrameBox ();
packageInfoFrame.BackgroundColor = Styles.PackageInfoBackgroundColor;
packageInfoFrame.BorderWidth = new WidgetSpacing ();
packageInfoFrame.Content = packageInfoVBox;
packageInfoVBox.Margin = new WidgetSpacing (15, 12, 15, 12);
var packageInfoContainerVBox = new VBox ();
packageInfoContainerVBox.WidthRequest = 328;
packageInfoContainerVBox.PackStart (packageInfoFrame, true, true);
var packageInfoScrollView = new ScrollView ();
packageInfoScrollView.BorderVisible = false;
packageInfoScrollView.HorizontalScrollPolicy = ScrollPolicy.Never;
packageInfoScrollView.Content = packageInfoContainerVBox;
packageInfoScrollView.BackgroundColor = Styles.PackageInfoBackgroundColor;
var packageInfoScrollViewFrame = new FrameBox ();
packageInfoScrollViewFrame.BackgroundColor = Styles.PackageInfoBackgroundColor;
packageInfoScrollViewFrame.BorderWidth = new WidgetSpacing (1, 0, 0, 0);
packageInfoScrollViewFrame.BorderColor = Styles.LineBorderColor;
packageInfoScrollViewFrame.Content = packageInfoScrollView;
// Package name and version.
packageNameHBox = new HBox ();
packageInfoVBox.PackStart (packageNameHBox);
packageNameLabel = new Label ();
packageNameLabel.Ellipsize = EllipsizeMode.End;
Font packageInfoSmallFont = packageNameLabel.Font.WithSize (packageInfoFontSize);
Font packageInfoBoldFont = packageInfoSmallFont.WithWeight (FontWeight.Bold);
packageNameLabel.Font = packageInfoSmallFont;
packageNameHBox.PackStart (packageNameLabel, true);
// Projects list view label.
projectsListViewLabel = new Label ();
projectsListViewLabel.Wrap = WrapMode.Word;
projectsListViewLabel.BackgroundColor = Styles.PackageInfoBackgroundColor;
packageInfoVBox.PackStart (projectsListViewLabel);
// Projects list view.
projectsListViewVBox = new VBox ();
projectsListViewVBox.Margin = new WidgetSpacing ();
packageInfoVBox.PackStart (projectsListViewVBox, true, true);
// Package description.
packageDescription = new Label ();
packageDescription.Wrap = WrapMode.Word;
packageDescription.Font = packageNameLabel.Font.WithSize (packageInfoFontSize);
packageDescription.BackgroundColor = Styles.PackageInfoBackgroundColor;
packageInfoVBox.PackStart (packageDescription);
// Package id.
var packageIdHBox = new HBox ();
packageIdHBox.MarginTop = 7;
packageInfoVBox.PackStart (packageIdHBox);
var packageIdLabel = new Label ();
packageIdLabel.Font = packageInfoBoldFont;
packageIdLabel.Text = GettextCatalog.GetString ("Id");
packageIdHBox.PackStart (packageIdLabel);
packageId = new Label ();
packageId.Ellipsize = EllipsizeMode.End;
packageId.TextAlignment = Alignment.End;
packageId.Font = packageInfoSmallFont;
packageIdLink = new LinkLabel ();
packageIdLink.Ellipsize = EllipsizeMode.End;
packageIdLink.TextAlignment = Alignment.End;
packageIdLink.Font = packageInfoSmallFont;
packageIdHBox.PackEnd (packageIdLink, true);
packageIdHBox.PackEnd (packageId, true);
// Package author
var packageAuthorHBox = new HBox ();
packageInfoVBox.PackStart (packageAuthorHBox);
var packageAuthorLabel = new Label ();
packageAuthorLabel.Text = GettextCatalog.GetString ("Author");
packageAuthorLabel.Font = packageInfoBoldFont;
packageAuthorHBox.PackStart (packageAuthorLabel);
packageAuthor = new Label ();
packageAuthor.TextAlignment = Alignment.End;
packageAuthor.Ellipsize = EllipsizeMode.End;
packageAuthor.Font = packageInfoSmallFont;
packageAuthorHBox.PackEnd (packageAuthor, true);
// Package published
var packagePublishedHBox = new HBox ();
packageInfoVBox.PackStart (packagePublishedHBox);
var packagePublishedLabel = new Label ();
packagePublishedLabel.Text = GettextCatalog.GetString ("Published");
packagePublishedLabel.Font = packageInfoBoldFont;
packagePublishedHBox.PackStart (packagePublishedLabel);
packagePublishedDate = new Label ();
packagePublishedDate.Font = packageInfoSmallFont;
packagePublishedHBox.PackEnd (packagePublishedDate);
// Package downloads
var packageDownloadsHBox = new HBox ();
packageInfoVBox.PackStart (packageDownloadsHBox);
var packageDownloadsLabel = new Label ();
packageDownloadsLabel.Text = GettextCatalog.GetString ("Downloads");
packageDownloadsLabel.Font = packageInfoBoldFont;
packageDownloadsHBox.PackStart (packageDownloadsLabel);
packageDownloads = new Label ();
packageDownloads.Font = packageInfoSmallFont;
packageDownloadsHBox.PackEnd (packageDownloads);
// Package license.
var packageLicenseHBox = new HBox ();
packageInfoVBox.PackStart (packageLicenseHBox);
var packageLicenseLabel = new Label ();
packageLicenseLabel.Text = GettextCatalog.GetString ("License");
packageLicenseLabel.Font = packageInfoBoldFont;
packageLicenseHBox.PackStart (packageLicenseLabel);
packageLicenseLink = new LinkLabel ();
packageLicenseLink.Text = GettextCatalog.GetString ("View License");
packageLicenseLink.Font = packageInfoSmallFont;
packageLicenseHBox.PackEnd (packageLicenseLink);
// Package project page.
var packageProjectPageHBox = new HBox ();
packageInfoVBox.PackStart (packageProjectPageHBox);
var packageProjectPageLabel = new Label ();
packageProjectPageLabel.Text = GettextCatalog.GetString ("Project Page");
packageProjectPageLabel.Font = packageInfoBoldFont;
packageProjectPageHBox.PackStart (packageProjectPageLabel);
packageProjectPageLink = new LinkLabel ();
packageProjectPageLink.Text = GettextCatalog.GetString ("Visit Page");
packageProjectPageLink.Font = packageInfoSmallFont;
packageProjectPageHBox.PackEnd (packageProjectPageLink);
// Package dependencies
packageDependenciesHBox = new HBox ();
packageInfoVBox.PackStart (packageDependenciesHBox);
var packageDependenciesLabel = new Label ();
packageDependenciesLabel.Text = GettextCatalog.GetString ("Dependencies");
packageDependenciesLabel.Font = packageInfoBoldFont;
packageDependenciesHBox.PackStart (packageDependenciesLabel);
packageDependenciesNoneLabel = new Label ();
packageDependenciesNoneLabel.Text = GettextCatalog.GetString ("None");
packageDependenciesNoneLabel.Font = packageInfoSmallFont;
packageDependenciesHBox.PackEnd (packageDependenciesNoneLabel);
// Package dependencies list.
packageDependenciesListHBox = new HBox ();
packageDependenciesListHBox.Visible = false;
packageInfoVBox.PackStart (packageDependenciesListHBox);
packageDependenciesList = new Label ();
packageDependenciesList.Wrap = WrapMode.WordAndCharacter;
packageDependenciesList.Margin = new WidgetSpacing (5);
packageDependenciesList.Font = packageInfoSmallFont;
packageDependenciesListHBox.PackStart (packageDependenciesList, true);
// Current package version.
currentPackageVersionHBox = new HBox ();
currentPackageVersionHBox.Spacing = 15;
currentPackageVersionHBox.Visible = false;
currentPackageVersionHBox.BackgroundColor = Styles.PackageInfoBackgroundColor;
currentPackageVersionHBox.Margin = new WidgetSpacing (15, 0, 15, 0);
currentPackageVersionLabel = new Label ();
currentPackageVersionLabel.BoundsChanged += PackageVersionLabelBoundsChanged;
currentPackageVersionLabel.Font = packageInfoSmallFont;
currentPackageVersionLabel.Text = GettextCatalog.GetString ("Current Version:");
currentPackageVersionLabel.TextAlignment = Alignment.End;
currentPackageVersionHBox.PackStart (currentPackageVersionLabel);
var currentPackageVersionWithInfoPopoverHBox = new HBox ();
currentPackageVersionWithInfoPopoverHBox.Margin = new WidgetSpacing ();
currentPackageVersionWithInfoPopoverHBox.Spacing = 0;
currentPackageVersion = new Label ();
currentPackageVersion.Font = packageInfoSmallFont;
currentPackageVersionWithInfoPopoverHBox.PackStart (currentPackageVersion);
currentPackageVersionInfoPopoverWidget = new InformationPopoverWidget ();
currentPackageVersionInfoPopoverWidget.Severity = Ide.Tasks.TaskSeverity.Information;
currentPackageVersionInfoPopoverWidget.Margin = new WidgetSpacing (5, 0, 0, 2);
currentPackageVersionWithInfoPopoverHBox.PackStart (currentPackageVersionInfoPopoverWidget);
currentPackageVersionHBox.PackStart (currentPackageVersionWithInfoPopoverHBox);
// Package versions.
packageVersionsHBox = new HBox ();
packageVersionsHBox.Visible = false;
packageVersionsHBox.BackgroundColor = Styles.PackageInfoBackgroundColor;
packageVersionsHBox.Margin = new WidgetSpacing (15, 0, 15, 12);
packageVersionsLabel = new Label ();
packageVersionsLabel.Font = packageInfoSmallFont;
packageVersionsLabel.Text = GettextCatalog.GetString ("New Version:");
packageVersionsLabel.TextAlignment = Alignment.End;
packageVersionsHBox.PackStart (packageVersionsLabel);
packageVersionComboBox = new ComboBox ();
packageVersionComboBox.Name = "packageVersionComboBox";
packageVersionsHBox.Spacing = 15;
packageVersionsHBox.PackStart (packageVersionComboBox, true, true);
var packageInfoAndVersionsVBox = new VBox ();
packageInfoAndVersionsVBox.Margin = new WidgetSpacing ();
packageInfoAndVersionsVBox.BackgroundColor = Styles.PackageInfoBackgroundColor;
packageInfoAndVersionsVBox.PackStart (packageInfoScrollViewFrame, true, true);
packageInfoAndVersionsVBox.PackStart (currentPackageVersionHBox, false, false);
packageInfoAndVersionsVBox.PackStart (packageVersionsHBox, false, false);
middleHBox.PackEnd (packageInfoAndVersionsVBox);
// Bottom part of dialog:
// Show pre-release packages and Close/Add to Project buttons.
var bottomHBox = new HBox ();
bottomHBox.Margin = new WidgetSpacing (8, 5, 14, 10);
bottomHBox.Spacing = 5;
mainVBox.PackStart (bottomHBox);
showPrereleaseCheckBox = new CheckBox ();
showPrereleaseCheckBox.Name = "managePackagesDialogShowPreReleaseCheckBox";
showPrereleaseCheckBox.Label = GettextCatalog.GetString ("Show pre-release packages");
bottomHBox.PackStart (showPrereleaseCheckBox);
addPackagesButton = new Button ();
addPackagesButton.Name = "managePackagesDialogAddPackageButton";
addPackagesButton.MinWidth = 120;
addPackagesButton.MinHeight = 25;
addPackagesButton.Label = GettextCatalog.GetString ("Add Package");
bottomHBox.PackEnd (addPackagesButton);
closeButton = new Button ();
closeButton.Name = "managePackagesDialogCloseButton";
closeButton.MinWidth = 120;
closeButton.MinHeight = 25;
closeButton.Label = GettextCatalog.GetString ("Close");
bottomHBox.PackEnd (closeButton);
packageSearchEntry.SetFocus ();
packageInfoVBox.Visible = false;
}
double? maxPackageVersionLabelWidth;
void PackageVersionLabelBoundsChanged (object sender, EventArgs e)
{
if (!viewModel.IsUpdatesPageSelected)
return;
double currentPackageVersionLabelWidth = currentPackageVersionLabel.Size.Width;
double packageVersionsLabelWidth = packageVersionsLabel.Size.Width;
if (currentPackageVersionLabelWidth > packageVersionsLabelWidth) {
packageVersionsLabel.WidthRequest = currentPackageVersionLabelWidth;
maxPackageVersionLabelWidth = currentPackageVersionLabelWidth;
} else if (packageVersionsLabelWidth > currentPackageVersionLabelWidth) {
currentPackageVersionLabel.WidthRequest = packageVersionsLabelWidth;
maxPackageVersionLabelWidth = packageVersionsLabelWidth;
}
}
}
}
|