Permalink
Browse files

add option to disable auto refresh (which is triggered by any directo…

…ry change)
  • Loading branch information...
1 parent ca79ee4 commit 53f20c24f5ea4b4528328b559f963df290d7d55e @yysun yysun committed Nov 11, 2011
View
@@ -25,6 +25,9 @@ static class CommandId
public const int icmdPendingChangesAmend = 0x112;
public const int icmdPendingChangesCommitToBranch = 0x113;
+ public const int icmdPendingChangesRefresh = 0x114;
+ public const int icmdHistoryViewRefresh = 0x115;
+
// Define the list of menus (these include toolbars)
public const int imnuHistoryToolWindowToolbarMenu = 0x200;
public const int imnuPendingChangesToolWindowToolbarMenu = 0x202;
View
@@ -21,6 +21,7 @@ public class GitSccOptions
public bool NotExpandTortoiseGit { get; set; }
public bool NotExpandGitExtensions { get; set; }
public bool UseTGitIconSet { get; set; }
+ public bool DisableAutoRefresh { get; set; }
private static GitSccOptions gitSccOptions;
View
@@ -3,12 +3,15 @@
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell;
namespace GitScc
{
[Guid("9175DE5D-630E-4E7B-A352-CFFD6132553C")]
public class HistoryToolWindow : ToolWindowWithEditor
{
+ private SccProviderService sccProviderService;
+
public HistoryToolWindow() : base()
{
// set the window title
@@ -32,28 +35,41 @@ protected override void Initialize()
// the object returned by the Content property.
base.Content = control;
- //var sccProviderService = BasicSccProvider.GetServiceEx<SccProviderService>();
- //if (sccProviderService != null)
- //{
- // Refresh(sccProviderService.CurrentTracker);
- //}
+ OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
+
+ var cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdHistoryViewRefresh);
+ var menu = new MenuCommand(new EventHandler(OnRefreshCommand), cmd);
+ mcs.AddCommand(menu);
+
+ sccProviderService = BasicSccProvider.GetServiceEx<SccProviderService>();
+
+ }
+
+ private void OnRefreshCommand(object sender, EventArgs e)
+ {
+ Refresh(sccProviderService.CurrentTracker, true);
}
- internal void Refresh(GitFileStatusTracker tracker)
+ internal void Refresh(GitFileStatusTracker tracker, bool force = false)
{
//var frame = this.Frame as IVsWindowFrame;
//if (frame == null || frame.IsVisible() == 1) return;
-
+
try
{
- this.Caption = Resources.ResourceManager.GetString("HistoryToolWindowCaption");
-
- ((HistoryView)control).Refresh(tracker);
-
var repository = (tracker == null || !tracker.HasGitRepository) ? "" :
- string.Format(" - {1} - ({0})", tracker.CurrentBranch, tracker.GitWorkingDirectory);
+ string.Format(" - {0}", tracker.CurrentBranch, tracker.GitWorkingDirectory);
this.Caption = Resources.ResourceManager.GetString("HistoryToolWindowCaption") + repository;
+
+ if (!GitSccOptions.Current.DisableAutoRefresh || force || tracker == null)
+ {
+ ((HistoryView)control).Refresh(tracker);
+ }
+ else
+ {
+ this.Caption += " - [AUTO REFRESH DISABLED]";
+ }
}
catch (Exception ex)
{
View
@@ -40,12 +40,11 @@ internal void Refresh(GitFileStatusTracker tracker)
selectedCommits.Clear();
SetSelectedCommitCount();
this.HistoryGraph.Show(tracker);
-
this.tracker = tracker;
if (tracker != null)
{
- double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
- if (delta < 1000) return; //no refresh within 1 second
+ //double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
+ //if (delta < 1000) return; //no refresh within 1 second
this.branchList.ItemsSource = tracker.RepositoryGraph.Refs
.Where(r => r.Type == RefTypes.Branch)
@@ -54,14 +53,14 @@ internal void Refresh(GitFileStatusTracker tracker)
this.tagList.ItemsSource = tracker.RepositoryGraph.Refs
.Where(r => r.Type == RefTypes.Tag)
.Select(r => r.Name);
-
- lastTimeRefresh = DateTime.Now;
}
}
catch (Exception ex)
{
Log.WriteLine("History View Refresh: {0}", ex.ToString());
}
+
+ lastTimeRefresh = DateTime.Now;
}
private void button1_Click(object sender, RoutedEventArgs e)
@@ -13,7 +13,7 @@ namespace GitScc
[Guid("75EDECF4-68D8-4B7B-92A9-5915461DA6D9")]
public class PendingChangesToolWindow : ToolWindowWithEditor
{
- //private PendingChangesView control;
+ private SccProviderService sccProviderService;
public PendingChangesToolWindow()
{
@@ -47,12 +47,12 @@ protected override void Initialize()
cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesAmend);
menu = new MenuCommand(new EventHandler(OnAmendCommitCommand), cmd);
mcs.AddCommand(menu);
-
- var sccProviderService = BasicSccProvider.GetServiceEx<SccProviderService>();
- if (sccProviderService != null)
- {
- Refresh(sccProviderService.CurrentTracker);
- }
+
+ cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesRefresh);
+ menu = new MenuCommand(new EventHandler(OnRefreshCommand), cmd);
+ mcs.AddCommand(menu);
+
+ sccProviderService = BasicSccProvider.GetServiceEx<SccProviderService>();
}
private void OnCommitCommand(object sender, EventArgs e)
@@ -65,21 +65,31 @@ private void OnAmendCommitCommand(object sender, EventArgs e)
((PendingChangesView) control).AmendCommit();
}
- internal void Refresh(GitFileStatusTracker tracker)
+ private void OnRefreshCommand(object sender, EventArgs e)
+ {
+ Refresh(sccProviderService.CurrentTracker, true);
+ }
+
+ internal void Refresh(GitFileStatusTracker tracker, bool force = false)
{
//var frame = this.Frame as IVsWindowFrame;
//if (frame == null || frame.IsVisible() == 1) return;
try
{
- this.Caption = Resources.ResourceManager.GetString("PendingChangesToolWindowCaption");
-
- ((PendingChangesView)control).Refresh(tracker);
-
var repository = (tracker == null || !tracker.HasGitRepository) ? "" :
- string.Format(" - {1} - ({0})", tracker.CurrentBranch, tracker.GitWorkingDirectory);
+ string.Format(" - {0}", tracker.CurrentBranch, tracker.GitWorkingDirectory);
this.Caption = Resources.ResourceManager.GetString("PendingChangesToolWindowCaption") + repository;
+
+ if (!GitSccOptions.Current.DisableAutoRefresh || force || tracker == null)
+ {
+ ((PendingChangesView)control).Refresh(tracker);
+ }
+ else
+ {
+ this.Caption += " - [AUTO REFRESH DISABLED]";
+ }
}
catch (Exception ex)
{
@@ -158,18 +158,17 @@ private void GetSelectedFileFullName(Action<string> action, bool fileMustExists
internal void Refresh(GitFileStatusTracker tracker)
{
this.tracker = tracker;
+
if (tracker == null)
{
service.NoRefresh = true;
- this.dataGrid1.ItemsSource = null;
ClearUI();
service.NoRefresh = false;
return;
}
- double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
+ //double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
//if (delta < 1000) return; //no refresh within 1 second
-
//Debug.WriteLine("==== Pending Changes Refresh {0}", delta);
var dispatcher = Dispatcher.CurrentDispatcher;
@@ -184,6 +183,7 @@ internal void Refresh(GitFileStatusTracker tracker)
this.dataGrid1.BeginInit();
this.dataGrid1.ItemsSource = tracker.ChangedFiles;
+
ICollectionView view = CollectionViewSource.GetDefaultView(this.dataGrid1.ItemsSource);
if (view != null)
{
@@ -208,8 +208,9 @@ internal void Refresh(GitFileStatusTracker tracker)
lastTimeRefresh = DateTime.Now;
}
- private void ClearUI()
+ internal void ClearUI()
{
+ this.dataGrid1.ItemsSource = null;
this.textBoxComments.Document.Blocks.Clear();
this.toolWindow.ClearEditor();
var chk = this.dataGrid1.FindVisualChild<CheckBox>("checkBoxAllStaged");
View
@@ -217,6 +217,28 @@
<ButtonText>Switch Branch</ButtonText>
</Strings>
</Button>
+
+ <Button guid="guidSccProviderCmdSet" id="icmdPendingChangesRefresh" priority="0x0007" type="Button">
+ <Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
+ <Icon guid="guidSccProviderImages" id="iconRefresh" />
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <CommandFlag>IconAndText</CommandFlag>
+ <Strings>
+ <ButtonText>Refresh</ButtonText>
+ </Strings>
+ </Button>
+
+ <Button guid="guidSccProviderCmdSet" id="icmdHistoryViewRefresh" priority="0x0006" type="Button">
+ <Parent guid="guidSccProviderCmdSet" id="igrpHistoryToolWindowToolbarGroup"/>
+ <Icon guid="guidSccProviderImages" id="iconRefresh" />
+ <CommandFlag>DynamicVisibility</CommandFlag>
+ <CommandFlag>DefaultInvisible</CommandFlag>
+ <CommandFlag>IconAndText</CommandFlag>
+ <Strings>
+ <ButtonText>Refresh</ButtonText>
+ </Strings>
+ </Button>
</Buttons>
@@ -271,19 +293,15 @@
<CommandPlacement guid="guidSccProviderCmdSet" id="icmdPendingChangesCommitToBranch" priority="0x0006">
<Parent guid="guidSccProviderCmdSet" id="igrpHistoryToolWindowToolbarGroup"/>
</CommandPlacement>
- <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandRefresh" priority="0x0007">
+ <!--<CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandRefresh" priority="0x0007">
<Parent guid="guidSccProviderCmdSet" id="igrpHistoryToolWindowToolbarGroup"/>
- </CommandPlacement>
+ </CommandPlacement>-->
<CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitBash" priority="0x0008">
<Parent guid="guidSccProviderCmdSet" id="igrpHistoryToolWindowToolbarGroup"/>
</CommandPlacement>
-
- <!--<CommandPlacement guid="guidSccProviderCmdSet" id="icmdPendingChangesCommitToBranch" priority="0x0006">
+ <!--<CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandRefresh" priority="0x0007">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
</CommandPlacement>-->
- <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandRefresh" priority="0x0007">
- <Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
- </CommandPlacement>
<CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitBash" priority="0x0008">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
</CommandPlacement>
@@ -317,6 +335,9 @@
<IDSymbol name="icmdPendingChangesAmend" value="0x112"/>
<IDSymbol name="icmdPendingChangesCommitToBranch" value="0x113"/>
+ <IDSymbol name="icmdPendingChangesRefresh" value="0x114"/>
+ <IDSymbol name="icmdHistoryViewRefresh" value="0x115"/>
+
<IDSymbol name="igrpGitExtCommands" value="0x800"/>
<IDSymbol name="imnuGitExtMenu" value="0x801"/>
<IDSymbol name="igrpGitTorCommands" value="0x900"/>
@@ -49,6 +49,7 @@ public class SccProviderOptionsControl : System.Windows.Forms.UserControl
private CheckBox checkBox1;
private CheckBox checkBox2;
private CheckBox checkBox3;
+ private CheckBox checkBox4;
// The parent page, use to persist data
private SccProviderOptions _customPage;
@@ -100,6 +101,7 @@ private void InitializeComponent()
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
+ this.checkBox4 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// openFileDialog1
@@ -241,11 +243,23 @@ private void InitializeComponent()
this.checkBox3.Text = "Use TortoiseGit Style Icon Set";
this.checkBox3.UseVisualStyleBackColor = true;
//
+ // checkBox4
+ //
+ this.checkBox4.AutoSize = true;
+ this.checkBox4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
+ this.checkBox4.Location = new System.Drawing.Point(244, 264);
+ this.checkBox4.Name = "checkBox4";
+ this.checkBox4.Size = new System.Drawing.Size(126, 17);
+ this.checkBox4.TabIndex = 26;
+ this.checkBox4.Text = "Disable Auto-Refresh";
+ this.checkBox4.UseVisualStyleBackColor = true;
+ //
// SccProviderOptionsControl
//
this.AllowDrop = true;
this.AutoScroll = true;
this.AutoSize = true;
+ this.Controls.Add(this.checkBox4);
this.Controls.Add(this.checkBox3);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
@@ -287,6 +301,7 @@ private void SccProviderOptionsControl_Load(object sender, EventArgs e)
this.checkBox1.Checked = GitSccOptions.Current.NotExpandGitExtensions;
this.checkBox2.Checked = GitSccOptions.Current.NotExpandTortoiseGit;
this.checkBox3.Checked = GitSccOptions.Current.UseTGitIconSet;
+ this.checkBox4.Checked = GitSccOptions.Current.DisableAutoRefresh;
}
private void button1_Click(object sender, EventArgs e)
@@ -327,6 +342,7 @@ internal void Save()
GitSccOptions.Current.NotExpandGitExtensions = this.checkBox1.Checked;
GitSccOptions.Current.NotExpandTortoiseGit = this.checkBox2.Checked;
GitSccOptions.Current.UseTGitIconSet = this.checkBox3.Checked;
+ GitSccOptions.Current.DisableAutoRefresh = this.checkBox4.Checked;
GitSccOptions.Current.SaveConfig();
SccProviderService sccProviderService = (SccProviderService)GetService(typeof(SccProviderService));
@@ -3,7 +3,7 @@
<Identifier Id="C4128D99-2000-41D1-A6C3-704E6C1A3DE2">
<Name>Git Source Control Provider</Name>
<Author>Yiyisun@hotmail.com</Author>
- <Version>0.8.8</Version>
+ <Version>0.8.9</Version>
<Description xml:space="preserve">Git Source Control Provider is a plug-in that integrates git with Visual Studio.</Description>
<Locale>1033</Locale>
<License>License.txt</License>

0 comments on commit 53f20c2

Please sign in to comment.