Skip to content

Commit

Permalink
Add menu to project nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Mar 28, 2017
1 parent d39b61f commit 11b8a51
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
10 changes: 9 additions & 1 deletion TSVN/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EnvDTE;
using System.IO;
using EnvDTE;
using Microsoft.Win32;

namespace SamirBoulema.TSVN.Helpers
Expand All @@ -21,5 +22,12 @@ public static void SaveAllFiles()
{
Dte.ExecuteCommand("File.SaveAll");
}

public static string GetPath()
{
return Dte.SelectedItems.Item(1).ProjectItem == null
? Path.GetDirectoryName(Dte.SelectedItems.Item(1).Project.FullName)
: Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
}
}
}
8 changes: 8 additions & 0 deletions TSVN/TSVN.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<CommandName>TSVN</CommandName>
</Strings>
</Menu>
<Menu guid="guidTSVNCmdSet" id="TSVNContextMenu" priority="0x0200" type="Menu">
<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_BUILD" />
<CommandFlag>TextChanges</CommandFlag>
<Strings>
<ButtonText>TSVN</ButtonText>
<CommandName>TSVN</CommandName>
</Strings>
</Menu>

<!--Toolbar-->
<Menu guid="guidTSVNCmdSet" id="Toolbar" type="Toolbar">
Expand Down
26 changes: 13 additions & 13 deletions TSVN/TSVNPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void UpdateCommand(object sender, EventArgs e)

private void UpdateFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
Dte.ActiveDocument?.Save();
StartProcess(_tortoiseProc, $"/command:update /path:\"{_currentFilePath}\" /closeonend:0");
Expand All @@ -149,15 +149,15 @@ private void UpdateToRevisionCommand(object sender, EventArgs e)

private void UpdateToRevisionFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
Dte.ActiveDocument?.Save();
StartProcess(_tortoiseProc, $"/command:update /path:\"{_currentFilePath}\" /rev /closeonend:0");
}

private void PropertiesCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:properties /path:\"{_currentFilePath}\" /closeonend:0");
}
Expand All @@ -172,7 +172,7 @@ private void CommitCommand(object sender, EventArgs e)

private void CommitFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
Dte.ActiveDocument?.Save();
StartProcess(_tortoiseProc, $"/command:commit /path:\"{_currentFilePath}\" /closeonend:0");
Expand All @@ -187,7 +187,7 @@ private void ShowLogCommand(object sender, EventArgs e)

private void ShowLogFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:log /path:\"{_currentFilePath}\" /closeonend:0");
}
Expand Down Expand Up @@ -225,14 +225,14 @@ private void RevertCommand(object sender, EventArgs e)

private void RevertFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:revert /path:\"{_currentFilePath}\" /closeonend:0");
}

private void AddFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
Dte.ActiveDocument?.Save();
StartProcess(_tortoiseProc, $"/command:add /path:\"{_currentFilePath}\" /closeonend:0");
Expand All @@ -246,7 +246,7 @@ private void DiskBrowserCommand(object sender, EventArgs e)
}
private void DiskBrowserFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess("explorer.exe", _currentFilePath);
}
Expand All @@ -260,7 +260,7 @@ private void RepoBrowserCommand(object sender, EventArgs e)

private void RepoBrowserFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:repobrowser /path:\"{_currentFilePath}\"");
}
Expand Down Expand Up @@ -288,7 +288,7 @@ private void MergeCommand(object sender, EventArgs e)

private void MergeFileCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:merge /path:\"{_currentFilePath}\"");
}
Expand All @@ -302,21 +302,21 @@ private void CleanupCommand(object sender, EventArgs e)

private void DifferencesCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:diff /path:\"{_currentFilePath}\"");
}

private void DiffPreviousCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:prevdiff /path:\"{_currentFilePath}\"");
}

private void BlameCommand(object sender, EventArgs e)
{
_currentFilePath = Dte.SelectedItems.Item(1).ProjectItem.FileNames[0];
_currentFilePath = FileHelper.GetPath();
var currentLineIndex = ((TextDocument) Dte.ActiveDocument?.Object(string.Empty))?.Selection.CurrentLine ?? 0;
if (string.IsNullOrEmpty(_currentFilePath)) return;
StartProcess(_tortoiseProc, $"/command:blame /path:\"{_currentFilePath}\" /line:{currentLineIndex}");
Expand Down

0 comments on commit 11b8a51

Please sign in to comment.