2020-07-22 05:14:39 -07:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
namespace SourceGit.UI {
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dialog to add new submodule.
|
|
|
|
/// </summary>
|
|
|
|
public partial class AddSubmodule : UserControl {
|
|
|
|
private Git.Repository repo = null;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Submodule's repository URL.
|
|
|
|
/// </summary>
|
|
|
|
public string RepoURL { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Submodule's relative path.
|
|
|
|
/// </summary>
|
|
|
|
public string LocalPath { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Constructor.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="opened"></param>
|
|
|
|
public AddSubmodule(Git.Repository opened) {
|
|
|
|
repo = opened;
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Show this dialog.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="repo"></param>
|
|
|
|
public static void Show(Git.Repository repo) {
|
2020-08-06 00:41:25 -07:00
|
|
|
repo.GetPopupManager()?.Show(new AddSubmodule(repo));
|
2020-07-22 05:14:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#region EVENTS
|
|
|
|
private void SelectFolder(object sender, RoutedEventArgs e) {
|
|
|
|
var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
|
|
dialog.Description = "Select Folder To Clone Repository";
|
|
|
|
dialog.SelectedPath = repo.Path;
|
|
|
|
dialog.ShowNewFolderButton = true;
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
|
|
|
txtPath.Text = dialog.SelectedPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private async void Sure(object sender, RoutedEventArgs e) {
|
|
|
|
txtRepoUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
|
|
|
if (Validation.GetHasError(txtRepoUrl)) return;
|
|
|
|
|
|
|
|
txtPath.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
|
|
|
if (Validation.GetHasError(txtPath)) return;
|
|
|
|
|
|
|
|
var recursive = chkRecursive.IsChecked == true;
|
2020-08-06 00:41:25 -07:00
|
|
|
var popup = repo.GetPopupManager();
|
2020-07-22 05:14:39 -07:00
|
|
|
|
2020-08-03 01:23:00 -07:00
|
|
|
popup?.Lock();
|
|
|
|
await Task.Run(() => repo.AddSubmodule(RepoURL, LocalPath, recursive, msg => {
|
|
|
|
popup?.UpdateStatus(msg);
|
|
|
|
}));
|
|
|
|
popup?.Close(true);
|
2020-07-22 05:14:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Cancel(object sender, RoutedEventArgs e) {
|
2020-08-06 00:41:25 -07:00
|
|
|
repo.GetPopupManager()?.Close();
|
2020-07-22 05:14:39 -07:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|