Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress Bar for Git solution download #4039

Merged
merged 9 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Ginger/Ginger/DLLs/LibGit2Sharp.dll
Binary file not shown.
3 changes: 0 additions & 3 deletions Ginger/Ginger/Ginger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,6 @@
<Reference Include="JiraRepositoryStd">
<HintPath>..\GingerCoreNET\DLLS\JiraRepositoryStd.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp">
<HintPath>ProjectDll\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.mshtml">
<HintPath>..\GingerCoreNET\DLLS\Microsoft.mshtml.dll</HintPath>
</Reference>
Expand Down
22 changes: 12 additions & 10 deletions Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
xmlns:usercontrols="clr-namespace:Amdocs.Ginger.UserControls"
xmlns:UserControls="clr-namespace:Amdocs.Ginger.UserControls"
mc:Ignorable="d"
Height="600" Width="800"
Height="650" Width="800"
Title="Download Solution">

<Grid Background="{StaticResource $BackgroundColor_White}">
<Grid.RowDefinitions>
<RowDefinition Name="ExpenderDetailsRow" Height="50"/>
Expand All @@ -21,7 +21,7 @@
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Name="DownloadButtonRow" Height="40"/>
<RowDefinition Height="30"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250*"/>
Expand All @@ -45,7 +45,7 @@
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>

</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
Expand All @@ -70,7 +70,7 @@
<Label x:Name="xSelectBranchLabel" Content="Select Branch:" Style="{StaticResource @InputFieldLabelStyle}" Grid.Column="0" Grid.Row="4" Margin="10,5,0,0"/>
<ComboBox x:Name="xBranchesCombo" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="0,5,0,7" HorizontalAlignment="Stretch" Grid.Column="1" Grid.Row="4"></ComboBox>


</Grid>
</Expander.Content>
</Expander>
Expand Down Expand Up @@ -103,7 +103,7 @@
</DockPanel>

<CheckBox x:Name="ConfigureProxyCheckBox" Grid.Row="1" Content="Configure Proxy" ToolTip="Configure Network Proxy For The Repository Access" Checked="ConfigureProxyCheckBoxChecked" Unchecked="ConfigureProxyCheckBoxUnchecked" HorizontalAlignment="Left" Margin="5,10,0,0"/>

<Label x:Name="labelProxyAddress" Content="Proxy Address:" Margin="20,5,0,0" Grid.Column="0" Grid.Row="2" Style="{StaticResource @InputFieldLabelStyle}" />
<TextBox x:Name="ProxyAddressTextBox" Margin="0,5,0,7" Grid.Column="1" Grid.Row="2" Width="200" HorizontalAlignment="Left" Style="{StaticResource @TextBoxStyle}" TextWrapping="Wrap" IsEnabled="false" />

Expand All @@ -112,16 +112,18 @@
</Grid>
</Expander.Content>
</Expander>


<UserControls:ucButton x:Name="xConnectButton" Grid.Row="2" ButtonType="RoundTextAndImageButton" HorizontalAlignment="Left" ButtonText="Connect And Search Repositories" ButtonImageType="Search" ButtonFontImageSize="15" ButtonImageWidth="15" ButtonImageHeight="15" Click="TestConnectionAndSearchRepositories_Click" ButtonStyle="{StaticResource $RoundTextAndImageButtonStyle}" Visibility="Visible" />

<Label x:Name="SourceControlLocalFolderLable" Content="Local Solutions Folder Path:" Grid.Row="3" Grid.ColumnSpan="2" Style="{StaticResource @InputFieldLabelStyle}" HorizontalAlignment="Stretch"/>
<TextBox x:Name="SourceControlLocalFolderTextBox" Grid.Row="4" Grid.Column="0" Text="" Style="{StaticResource @TextBoxStyle}" HorizontalAlignment="Stretch" IsReadOnly="True" IsEnabled="False"/>
<Button x:Name="BrowseButton" Click="BrowseButton_Click" Grid.Row="4" Grid.Column="1" Content="Browse" HorizontalAlignment="Left" Style="{StaticResource @InputButtonStyle}" Height="Auto"/>
<Ginger:ucGrid x:Name="SolutionsGrid" Title="Source Control Solutions" Grid.Row="5" Grid.ColumnSpan="2" ShowEdit="Collapsed" ShowUpDown="Collapsed" Margin="0,10,0,0" ShowAdd="Collapsed" ShowDelete="Collapsed" ShowClearAll="Collapsed" ShowTagsFilter="Collapsed"/>

<Button x:Name="DownloadButton" Click="DownloadButton_Click" Grid.Row="6" Grid.Column="1" Content="Download Solution" HorizontalAlignment="Right" Style="{StaticResource @InputButtonStyle}" Visibility="Collapsed"/>
</Grid>
<Button x:Name="DownloadButton" Click="DownloadButton_Click" Grid.Row="6" Grid.Column="1" Content="Download Solution" HorizontalAlignment="Right" Style="{StaticResource @InputButtonStyle}" Visibility="Collapsed"/>


</Grid>

</Page>
112 changes: 100 additions & 12 deletions Ginger/Ginger/SourceControl/SourceControlProjectsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ limitations under the License.

using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.UIElement;
using Amdocs.Ginger.UserControls;
using Ginger.UserControls;
using GingerCore.SourceControl;
using GingerCoreNET.SourceControl;
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -40,8 +42,10 @@ public partial class SourceControlProjectsPage : Page

SolutionInfo solutionInfo = null;

ImageMakerControl loaderElement = new ImageMakerControl();

ImageMakerControl loaderElement = new();
TextBlock progressText = new();
ProgressBar progressBar = new();
ProgressNotifier progressNotifier = new();
GenericWindow genWin = null;
Button downloadProjBtn = null;

Expand All @@ -63,7 +67,8 @@ public SourceControlProjectsPage(bool IsCalledFromImportPage = false)

IsImportSolution = IsCalledFromImportPage;
Init();

progressNotifier.ProgressText += HandleProgressUpdated;
progressNotifier.ProgressUpdated += HandleProgressBarUpdated;
}

private void Init()
Expand Down Expand Up @@ -258,7 +263,21 @@ private void SetGridView()

private async void GetProject_Click(object sender, RoutedEventArgs e)
{
await DownloadSolution().ConfigureAwait(false);
try
{
if (SourceControlIntegration.BusyInProcessWhileDownloading)
{
StopDownload();
}
else
{
await DownloadSolution().ConfigureAwait(false);
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error Occurred :", ex);
}
}

private void OpenSolution(string Path, string ProjectURI)
Expand Down Expand Up @@ -301,13 +320,23 @@ public string ShowAsWindow(eWindowShowStyle windowStyle = eWindowShowStyle.Free)
};
downloadProjBtn.Click += new RoutedEventHandler(GetProject_Click);

loaderElement.Name = "xProcessingImage";
loaderElement.Height = 30;
loaderElement.Width = 30;
loaderElement.ImageType = Amdocs.Ginger.Common.Enums.eImageType.Processing;
loaderElement.Visibility = Visibility.Collapsed;
progressBar.Name = "progressBar";
progressBar.Height = 16;
progressBar.VerticalAlignment = VerticalAlignment.Top;
progressBar.HorizontalAlignment = HorizontalAlignment.Stretch; // Set to Stretch to use available space
progressBar.Background = System.Windows.Media.Brushes.LightYellow;
progressBar.Foreground = System.Windows.Media.Brushes.ForestGreen;
progressBar.Visibility = Visibility.Collapsed;
progressBar.Margin = new Thickness(5, 5, 5, 0);

progressText.Name = "progressText";
progressText.HorizontalAlignment = HorizontalAlignment.Center;
progressText.Margin = new Thickness(0, 1, 0, 0); // Adjusted margin to add space between progressBar and progressText
progressText.VerticalAlignment = VerticalAlignment.Top; // Changed to Top to align below progressBar
progressText.Visibility = Visibility.Collapsed;
progressText.FontSize = 12;

GingerCore.General.LoadGenericWindow(ref genWin, App.MainWindow, windowStyle, "Download Source Control Solution", this, [downloadProjBtn], true, "Close", null, false, loaderElement);
GingerCore.General.LoadGenericWindow(ref genWin, App.MainWindow, windowStyle, "Download Source Control Solution", this, [downloadProjBtn], true, "Close", null, false, null, progressBar, progressText);

if (solutionInfo != null)
{
Expand Down Expand Up @@ -497,13 +526,15 @@ private async Task DownloadSolution()
try
{
loaderElement.Visibility = Visibility.Visible;
progressText.Visibility = Visibility.Visible;
progressBar.Visibility = Visibility.Visible;
downloadProjBtn.Content = "Cancel Downloading";
if (SourceControlIntegration.BusyInProcessWhileDownloading)
{
Reporter.ToUser(eUserMsgKey.StaticInfoMessage, "Please wait for current process to end.");
return;
}
SourceControlIntegration.BusyInProcessWhileDownloading = true;

if (WorkSpace.Instance.UserProfile.SourceControlLocalFolder == string.Empty)
{
Reporter.ToUser(eUserMsgKey.SourceControlConnMissingLocalFolderInput);
Expand All @@ -526,8 +557,9 @@ private async Task DownloadSolution()
{
ProjectURI = WorkSpace.Instance.UserProfile.SourceControlURL;
}
_cancellationTokenSource = new CancellationTokenSource();
bool getProjectResult = await Task.Run(() => SourceControlIntegration.GetProject(mSourceControl, solutionInfo.LocalFolder, ProjectURI, progressNotifier, _cancellationTokenSource.Token));

bool getProjectResult = await Task.Run(() => SourceControlIntegration.GetProject(mSourceControl, solutionInfo.LocalFolder, ProjectURI));
SourceControlIntegration.BusyInProcessWhileDownloading = false;

if (getProjectResult)
Expand Down Expand Up @@ -555,7 +587,63 @@ private async Task DownloadSolution()
finally
{
SourceControlIntegration.BusyInProcessWhileDownloading = false;
downloadProjBtn.Content = "Download Selected Solution";
progressText.Text = "";
progressBar.Maximum = 100;
progressBar.Value = 0;
loaderElement.Visibility = Visibility.Collapsed;
progressText.Visibility = Visibility.Collapsed;
progressBar.Visibility = Visibility.Collapsed;
_cancellationTokenSource.Dispose();
}
}
/// <summary>
/// Stops the ongoing download process by canceling the associated cancellation token.
/// </summary>
private void StopDownload()
{
_cancellationTokenSource?.Cancel();
}
private CancellationTokenSource _cancellationTokenSource;
/// <summary>
/// Handles the progress update event by updating the progress text on the UI thread.
/// </summary>
/// <param name="sender">The event sender.</param>
/// <param name="message">The progress message.</param>
private void HandleProgressUpdated(object sender, string message)
{
if (string.IsNullOrEmpty(message))
{
return;
}
try
{
Dispatcher.Invoke(() => progressText.Text = message);
}
catch (TaskCanceledException e)
{
Reporter.ToLog(eLogLevel.ERROR, e.Message);
}
}

/// <summary>
/// Handles the progress bar update event by updating the progress bar value on the UI thread.
/// </summary>
/// <param name="sender">The event sender.</param>
/// <param name="progress">A tuple containing the completed steps and total steps.</param>
private void HandleProgressBarUpdated(object sender, (int CompletedSteps, int TotalSteps) progress)
{
try
{
Dispatcher.Invoke(() =>
{
progressBar.Maximum = progress.TotalSteps;
progressBar.Value = progress.CompletedSteps;
});
}
catch (TaskCanceledException e)
{
Reporter.ToLog(eLogLevel.ERROR, e.Message);
}
}
}
Expand Down
Binary file removed Ginger/GingerCore/DLLs/LibGit2Sharp.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Ginger/GingerCore/GeneralLib/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace GingerCore
public class General
{
public static void LoadGenericWindow(ref GenericWindow genWindow, System.Windows.Window owner, eWindowShowStyle windowStyle, string windowTitle, Page windowPage,
ObservableList<Button> windowBtnsList = null, bool showClosebtn = true, string closeBtnText = "Close", RoutedEventHandler closeEventHandler = null, bool startupLocationWithOffset = false, FrameworkElement loaderElement = null)
ObservableList<Button> windowBtnsList = null, bool showClosebtn = true, string closeBtnText = "Close", RoutedEventHandler closeEventHandler = null, bool startupLocationWithOffset = false, FrameworkElement loaderElement = null, FrameworkElement progressBar = null, FrameworkElement progressBarText = null)
{
genWindow = null;
eWindowShowStyle winStyle;
Expand All @@ -70,7 +70,7 @@ public static void LoadGenericWindow(ref GenericWindow genWindow, System.Windows
{
winStyle = windowStyle;
}
genWindow = new GenericWindow(owner, winStyle, windowTitle, windowPage, windowBtnsList, showClosebtn, closeBtnText, closeEventHandler, loaderElement)
genWindow = new GenericWindow(owner, winStyle, windowTitle, windowPage, windowBtnsList, showClosebtn, closeBtnText, closeEventHandler, loaderElement, progressBar, progressBarText)
{
Title = windowPage.Title
};
Expand Down
29 changes: 26 additions & 3 deletions Ginger/GingerCore/GeneralLib/GenericWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public partial class GenericWindow : Window
double mPageOriginalHeight = -1;
private bool OwnerWindowClosing = false;

public GenericWindow(Window Owner, eWindowShowStyle windowStyle, string windowTitle,
Page windowPage, ObservableList<Button> windowBtnsList = null, bool showCloseBtn = true, string closeBtnText = "Close", RoutedEventHandler closeEventHandler = null, FrameworkElement loaderElement = null)
public GenericWindow(Window Owner, eWindowShowStyle windowStyle, string windowTitle, Page windowPage, ObservableList<Button> windowBtnsList = null, bool showCloseBtn = true, string closeBtnText = "Close", RoutedEventHandler closeEventHandler = null, FrameworkElement loaderElement = null, FrameworkElement progressBar = null, FrameworkElement progressBarText = null)
{
InitializeComponent();
this.Owner = Owner;
Expand Down Expand Up @@ -268,11 +267,35 @@ public GenericWindow(Window Owner, eWindowShowStyle windowStyle, string windowTi
}

loaderElement.Margin = margin;
//loaderElement.Style = this.FindResource("$RoundTextButtonStyle_Generic") as Style;
DockPanel.SetDock(loaderElement, Dock.Left);
BottomPanel.Children.Add(loaderElement);

}
if (progressBar != null)
{
Thickness margin = progressBar.Margin;
if (margin.Left < 10)
{
margin.Left = 10;
}

progressBar.Margin = margin;
DockPanel.SetDock(progressBar, Dock.Top); // Changed to Top to stack elements vertically
BottomPanel.Children.Add(progressBar);
}

if (progressBarText != null)
{
Thickness margin = progressBarText.Margin;
if (margin.Left < 10)
{
margin.Left = 10;
}

progressBarText.Margin = margin;
DockPanel.SetDock(progressBarText, Dock.Top); // Changed to Top to stack elements vertically
BottomPanel.Children.Add(progressBarText);
}
}

private void Owner_Closing(object sender, System.ComponentModel.CancelEventArgs e)
Expand Down
3 changes: 2 additions & 1 deletion Ginger/GingerCore/GingerCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,9 @@
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.58</Version>
</PackageReference>
<PackageReference Include="LibGit2Sharp" Version="0.31.0" />
<PackageReference Include="LibGit2Sharp.NativeBinaries">
<Version>2.0.278</Version>
<Version>2.0.323</Version>
</PackageReference>
<PackageReference Include="log4net">
<Version>2.0.15</Version>
Expand Down
8 changes: 7 additions & 1 deletion Ginger/GingerCore/SourceControl/SVNSourceControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.

using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.UIElement;
using GingerCoreNET.SourceControl;
using SharpSvn;
using System;
Expand All @@ -28,6 +29,7 @@ limitations under the License.
using System.Net.Security;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;


Expand Down Expand Up @@ -341,7 +343,6 @@ public override bool GetLatest(string path, ref string error, ref List<string> c
}
return true;
}

public override bool GetProject(string Path, string URI, ref string error)
{
if (client == null)
Expand Down Expand Up @@ -1213,5 +1214,10 @@ public override bool UndoUncommitedChanges(List<SourceControlFileInfo> selectedF
{
throw new NotImplementedException("UndoUncommitedChanges not Implemented");
}

public override bool GetProjectWithProgress(string Path, string URI, ref string error, ProgressNotifier progressNotifier = null, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
GokulBothe99 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading