Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add open ignore file function
  • Loading branch information
yysun committed Aug 23, 2011
1 parent f0d83d1 commit 5e538be
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
10 changes: 10 additions & 0 deletions BasicSccProvider.cs
Expand Up @@ -103,6 +103,10 @@ protected override void Initialize()
menu = new MenuCommand(new EventHandler(OnInitCommand), cmd);
mcs.AddCommand(menu);

cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandEditIgnore);
menu = new MenuCommand(new EventHandler(OnEditIgnore), cmd);
mcs.AddCommand(menu);

cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdSccCommandGitTortoise);
menu = new MenuCommand(new EventHandler(OnTortoiseGitCommand), cmd);
mcs.AddCommand(menu);
Expand Down Expand Up @@ -225,6 +229,7 @@ int IOleCommandTarget.QueryStatus(ref Guid guidCmdGroup, uint cCmds, OLECMD[] pr
if (sccService.CanCompareSelectedFile) cmdf |= OLECMDF.OLECMDF_ENABLED;
break;

case CommandId.icmdSccCommandEditIgnore:
case CommandId.icmdSccCommandPendingChanges:
if (sccService.IsSolutionGitControlled) cmdf |= OLECMDF.OLECMDF_ENABLED;
break;
Expand Down Expand Up @@ -313,6 +318,11 @@ private void OnGitBashCommand(object sender, EventArgs e)
RunDetatched("cmd.exe", string.Format("/c \"{0}\" --login -i", gitBashPath));
}

private void OnEditIgnore(object sender, EventArgs e)
{
sccService.EditIgnore();
}

private void OnGitExtensionCommand(object sender, EventArgs e)
{
var gitExtensionPath = GitSccOptions.Current.GitExtensionPath;
Expand Down
2 changes: 1 addition & 1 deletion CommandId.cs
Expand Up @@ -19,6 +19,7 @@ static class CommandId
public const int icmdSccCommandPendingChanges = 0x107;
public const int icmdSccCommandHistory = 0x108;
public const int icmdSccCommandGitTortoise = 0x109;
public const int icmdSccCommandEditIgnore = 0x110;

public const int icmdPendingChangesCommit = 0x111;
public const int icmdPendingChangesAmend = 0x112;
Expand All @@ -39,7 +40,6 @@ static class CommandId
// Glyph indexes in the bitmap used for toolwindows (ibmpToolWindowsImages)
public const int iconSccProviderToolWindow = 0;


public const int icmdGitExtCommand1 = 0x811;
public const int icmdGitTorCommand1 = 0x911;

Expand Down
8 changes: 4 additions & 4 deletions PendingChangesView.xaml
Expand Up @@ -79,11 +79,11 @@
<MenuItem Header="Compare ..." Name="menuCompare" Click="menuCompare_Click" />
<MenuItem Header="Undo File Changes" Name="menuUndo" Click="menuUndo_Click"/>
<!--<MenuItem Header="Delete File" Name="menuDeleteFile" Click="menuDeleteFile_Click"/>-->
<MenuItem Header="Open .gitignore file" Name="menuOpenIgnoreFile" Click="menuOpenIgnoreFile_Click" >
<!--<MenuItem Header="Add File to .gitignore" Name="menuIgnoreFile" Click="menuIgnoreFile_Click"/>
<!--<MenuItem Header="Open .gitignore file" Name="menuOpenIgnoreFile" Click="menuOpenIgnoreFile_Click" >
<MenuItem Header="Add File to .gitignore" Name="menuIgnoreFile" Click="menuIgnoreFile_Click"/>
<MenuItem Header="Add File Path to .gitignore" Name="menuIgnoreFilePath" Click="menuIgnoreFilePath_Click"/>
<MenuItem Header="Add File Extensions to .gitignore" Name="menuIgnoreFileExt" Click="menuIgnoreFileExt_Click"/>-->
</MenuItem>
<MenuItem Header="Add File Extensions to .gitignore" Name="menuIgnoreFileExt" Click="menuIgnoreFileExt_Click"/>
</MenuItem>-->
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
Expand Down
10 changes: 0 additions & 10 deletions PendingChangesView.xaml.cs
Expand Up @@ -329,8 +329,6 @@ private void textBoxDiff_MouseDoubleClick(object sender, MouseButtonEventArgs e)

private void dataGrid1_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
menuOpenIgnoreFile.IsEnabled = (tracker != null && tracker.HasGitRepository);

if (this.dataGrid1.SelectedCells.Count == 0) return;
var selectedItem = this.dataGrid1.SelectedCells[0].Item as GitFile;
if (selectedItem == null) return;
Expand Down Expand Up @@ -373,14 +371,6 @@ private void menuUndo_Click(object sender, RoutedEventArgs e)
});
}

private void menuOpenIgnoreFile_Click(object sender, RoutedEventArgs e)
{
if(tracker!=null && tracker.HasGitRepository)
{
var dte = BasicSccProvider.GetServiceEx<EnvDTE.DTE>();
dte.ItemOperations.OpenFile(Path.Combine(tracker.GitWorkingDirectory, ".gitignore"));
}
}
#endregion
}
}
25 changes: 19 additions & 6 deletions PkgCmd.vsct
Expand Up @@ -111,9 +111,20 @@
<Strings>
<ButtonText>Undo File Changes</ButtonText>
</Strings>
</Button>

<Button guid="guidSccProviderCmdSet" id="icmdSccCommandRefresh" priority="0x0103" type="Button">
</Button>

<Button guid="guidSccProviderCmdSet" id="icmdSccCommandEditIgnore" priority="0x0103" type="Button">
<Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
<Icon guid="guidSccProviderImages" id="iconOpenIgnoreFile" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<Strings>
<ButtonText>Open .gitignore</ButtonText>
</Strings>
</Button>

<Button guid="guidSccProviderCmdSet" id="icmdSccCommandRefresh" priority="0x0104" type="Button">
<Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
<Icon guid="guidSccProviderImages" id="iconRefresh" />
<CommandFlag>DynamicVisibility</CommandFlag>
Expand All @@ -123,7 +134,7 @@
<ButtonText>Refresh</ButtonText>
</Strings>
</Button>

<Button guid="guidSccProviderCmdSet" id="icmdSccCommandInit" priority="0x0000" type="Button">
<!--<Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>-->
<Icon guid="guidSccProviderImages" id="iconGitInit" />
Expand Down Expand Up @@ -202,7 +213,7 @@

<Bitmaps>
<Bitmap guid="guidSccProviderImages" href="Resources\Images_32bit.bmp"
usedList="iconGitBash, iconGitExt, iconUncheckout, iconCompare, iconRefresh, iconPendingChanges, iconGitTor, iconGitInit"/>
usedList="iconGitBash, iconGitExt, iconUncheckout, iconCompare, iconRefresh, iconOpenIgnoreFile, iconGitTor, iconGitInit"/>
</Bitmaps>
</Commands>

Expand Down Expand Up @@ -269,6 +280,8 @@
<IDSymbol name="icmdSccCommandPendingChanges" value="0x107"/>
<IDSymbol name="icmdSccCommandHistory" value="0x108"/>
<IDSymbol name="icmdSccCommandGitTortoise" value="0x109"/>
<IDSymbol name="icmdSccCommandEditIgnore" value="0x110"/>

<IDSymbol name="imnuGitSourceControlMenu" value="0x205"/>
<IDSymbol name="igrpSourceControlCommands" value="0x301"/>

Expand Down Expand Up @@ -296,7 +309,7 @@
<IDSymbol name="iconUncheckout" value="3"/>
<IDSymbol name="iconCompare" value="4"/>
<IDSymbol name="iconRefresh" value="5"/>
<IDSymbol name="iconPendingChanges" value="6"/>
<IDSymbol name="iconOpenIgnoreFile" value="6"/>
<IDSymbol name="iconGitTor" value="7"/>
<IDSymbol name="iconGitInit" value="8"/>
</GuidSymbol>
Expand Down
10 changes: 9 additions & 1 deletion SccProviderService.cs
Expand Up @@ -762,6 +762,15 @@ internal void UndoFileChanges(string fileName)
}
}

internal void EditIgnore()
{
if (this.CurrentTracker != null && this.CurrentTracker.HasGitRepository)
{
var dte = BasicSccProvider.GetServiceEx<EnvDTE.DTE>();
dte.ItemOperations.OpenFile(Path.Combine(this.CurrentTracker.GitWorkingDirectory, ".gitignore"));
}
}

#endregion

#region IVsUpdateSolutionEvents2 Members
Expand Down Expand Up @@ -1115,6 +1124,5 @@ private void RefreshToolWindows()
as PendingChangesToolWindow;
if (window != null) window.Refresh(this.CurrentTracker);
}

}
}

0 comments on commit 5e538be

Please sign in to comment.