Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit e19f543

Browse files
committed
Added configuration so that debugger path can be set.
1 parent c08df5a commit e19f543

File tree

10 files changed

+666
-8
lines changed

10 files changed

+666
-8
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//
2+
// DotNetCoreDebuggerLocationPanel.cs
3+
//
4+
// Author:
5+
// Matt Ward <matt.ward@microsoft.com>
6+
// Lex Li <support@lextm.com>
7+
//
8+
// Copyright (c) 2018 Microsoft
9+
// Copyright (c) 2019 LeXtudio Inc. (http://www.lextudio.com)
10+
//
11+
// Permission is hereby granted, free of charge, to any person obtaining a copy
12+
// of this software and associated documentation files (the "Software"), to deal
13+
// in the Software without restriction, including without limitation the rights
14+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
// copies of the Software, and to permit persons to whom the Software is
16+
// furnished to do so, subject to the following conditions:
17+
//
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
20+
//
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
// THE SOFTWARE.
28+
29+
30+
using System;
31+
using System.Linq;
32+
using System.Threading.Tasks;
33+
using MonoDevelop.Components;
34+
using MonoDevelop.Core;
35+
using MonoDevelop.Ide;
36+
using MonoDevelop.Ide.Gui.Dialogs;
37+
using MonoDevelop.Projects;
38+
39+
namespace MonoDevelop.Debugger.DotNetCore.Gui
40+
{
41+
class DotNetCoreDebuggerLocationPanel : OptionsPanel
42+
{
43+
DotNetCoreDebuggerLocationWidget widget;
44+
45+
public override Control CreatePanelWidget()
46+
{
47+
widget = new DotNetCoreDebuggerLocationWidget(this);
48+
return widget.ToGtkWidget();
49+
}
50+
51+
public FilePath LoadDebuggerLocationSetting()
52+
{
53+
return DotNetCoreDebuggerRuntime.FileName;
54+
}
55+
56+
public void SaveDebuggerLocationSetting(FilePath location)
57+
{
58+
if (location == DotNetCoreDebuggerRuntime.FileName)
59+
{
60+
return;
61+
}
62+
63+
var path = new DotNetCoreDebuggerPath(location);
64+
65+
DotNetCoreDebuggerRuntime.Update(path);
66+
}
67+
68+
public DotNetCoreDebuggerPath DotNetCoreDebuggerPath { get; private set; }
69+
70+
public void ValidateDebuggerLocation(FilePath location)
71+
{
72+
if (!location.IsNullOrEmpty)
73+
{
74+
DotNetCoreDebuggerPath = new DotNetCoreDebuggerPath(location);
75+
}
76+
else
77+
{
78+
DotNetCoreDebuggerPath = null;
79+
}
80+
}
81+
82+
public override void ApplyChanges()
83+
{
84+
widget.ApplyChanges();
85+
}
86+
}
87+
}
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
//
2+
// DotNetCoreSdkLocationWidget.UI.cs
3+
//
4+
// Author:
5+
// Matt Ward <matt.ward@microsoft.com>
6+
// Lex Li <support@lextm.com>
7+
//
8+
// Copyright (c) 2018 Microsoft
9+
// Copyright (c) 2019 LeXtudio Inc. (http://www.lextudio.com)
10+
//
11+
// Permission is hereby granted, free of charge, to any person obtaining a copy
12+
// of this software and associated documentation files (the "Software"), to deal
13+
// in the Software without restriction, including without limitation the rights
14+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
// copies of the Software, and to permit persons to whom the Software is
16+
// furnished to do so, subject to the following conditions:
17+
//
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
20+
//
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
// THE SOFTWARE.
28+
29+
using System;
30+
using System.Collections.Generic;
31+
using System.Linq;
32+
using MonoDevelop.Components.AtkCocoaHelper;
33+
using MonoDevelop.Components.Extensions;
34+
using MonoDevelop.Core;
35+
using Xwt;
36+
37+
namespace MonoDevelop.Debugger.DotNetCore.Gui
38+
{
39+
partial class DotNetCoreDebuggerLocationWidget : Widget
40+
{
41+
CustomFileSelector locationFileSelector;
42+
Label debuggerFoundLabel;
43+
ImageView debuggerFoundIcon;
44+
Label sdkFoundLabel;
45+
ImageView sdkFoundIcon;
46+
ListBox sdkVersionsListBox;
47+
Label runtimeFoundLabel;
48+
ImageView runtimeFoundIcon;
49+
ListBox runtimeVersionsListBox;
50+
51+
void Build()
52+
{
53+
var mainVBox = new VBox();
54+
mainVBox.Spacing = 12;
55+
56+
// .NET Core command line section.
57+
var titleLabel = new Label();
58+
titleLabel.Markup = GetBoldMarkup(GettextCatalog.GetString("Samsung .NET Core Debugger"));
59+
mainVBox.PackStart(titleLabel);
60+
61+
var debuggerVBox = new VBox();
62+
debuggerVBox.Spacing = 6;
63+
debuggerVBox.MarginLeft = 24;
64+
mainVBox.PackStart(debuggerVBox);
65+
66+
var debuggerFoundHBox = new HBox();
67+
debuggerFoundHBox.Spacing = 6;
68+
debuggerVBox.PackStart(debuggerFoundHBox, false, false);
69+
70+
debuggerFoundIcon = new ImageView();
71+
debuggerFoundHBox.PackStart(debuggerFoundIcon, false, false);
72+
73+
debuggerFoundLabel = new Label();
74+
debuggerFoundHBox.PackStart(debuggerFoundLabel, true, true);
75+
76+
var locationBox = new HBox();
77+
locationBox.Spacing = 6;
78+
debuggerVBox.PackStart(locationBox, false, false);
79+
80+
var locationLabel = new Label();
81+
locationLabel.Text = GettextCatalog.GetString("Location:");
82+
locationBox.PackStart(locationLabel, false, false);
83+
84+
locationFileSelector = new CustomFileSelector();
85+
locationBox.PackStart(locationFileSelector, true, true);
86+
87+
Content = mainVBox;
88+
}
89+
90+
static string GetBoldMarkup(string text)
91+
{
92+
return "<b>" + GLib.Markup.EscapeText(text) + "</b>";
93+
}
94+
95+
void UpdateDebuggerIconAccessibility(bool found)
96+
{
97+
debuggerFoundIcon.SetCommonAccessibilityAttributes(
98+
"DotNetCoreDebuggerFoundImage",
99+
found ? GettextCatalog.GetString("A Tick") : GettextCatalog.GetString("A Cross"),
100+
found ? GettextCatalog.GetString("The Samsung .NET Core debugger was found") : GettextCatalog.GetString("The Samsung .NET Core debugger was not found"));
101+
}
102+
103+
/// <summary>
104+
/// This is slightly different from the standard FileSelector. When the select file
105+
/// dialog is cancelled the current directory is not remembered. This keeps the
106+
/// behaviour consistent with the other SDK pages that use the FileSelector from
107+
/// MonoDevelop.Components.
108+
/// </summary>
109+
class CustomFileSelector : Widget
110+
{
111+
TextEntry entry;
112+
FileDialog dialog;
113+
string currentFolder;
114+
string title;
115+
116+
public CustomFileSelector()
117+
{
118+
var box = new HBox();
119+
entry = new TextEntry();
120+
entry.Changed += EntryChanged;
121+
box.PackStart(entry, true);
122+
123+
var browseButton = new Button("…");
124+
box.PackStart(browseButton);
125+
browseButton.Clicked += BrowseButtonClicked;
126+
127+
Content = box;
128+
}
129+
130+
public string CurrentFolder
131+
{
132+
get
133+
{
134+
return dialog != null ? dialog.CurrentFolder : currentFolder;
135+
}
136+
set
137+
{
138+
if (dialog != null)
139+
dialog.CurrentFolder = value;
140+
141+
currentFolder = value;
142+
}
143+
}
144+
145+
public string FileName
146+
{
147+
get { return dialog != null ? dialog.FileName : entry.Text; }
148+
set { entry.Text = value; }
149+
}
150+
151+
public string Title
152+
{
153+
get
154+
{
155+
return title;
156+
}
157+
158+
set
159+
{
160+
title = value;
161+
if (dialog != null)
162+
dialog.Title = value;
163+
}
164+
}
165+
166+
public event EventHandler FileChanged;
167+
168+
void EntryChanged(object sender, EventArgs e)
169+
{
170+
FileChanged?.Invoke(sender, e);
171+
}
172+
173+
void BrowseButtonClicked(object sender, EventArgs e)
174+
{
175+
dialog = new OpenFileDialog();
176+
177+
try
178+
{
179+
if (!string.IsNullOrEmpty(currentFolder))
180+
dialog.CurrentFolder = currentFolder;
181+
if (!string.IsNullOrEmpty(title))
182+
dialog.Title = title;
183+
if (dialog.Run(ParentWindow))
184+
FileName = dialog.FileName;
185+
}
186+
finally
187+
{
188+
dialog.Dispose();
189+
dialog = null;
190+
}
191+
}
192+
}
193+
}
194+
}

0 commit comments

Comments
 (0)