public void OnExecute(CommandEventArgs e) { IAnkhConfigurationService configSvc = e.GetService <IAnkhConfigurationService>(); if (configSvc != null) { AnkhConfig cfg = configSvc.Instance; using (ConfigureRecentChangesPageDialog dlg = new ConfigureRecentChangesPageDialog()) { int seconds = Math.Max(0, cfg.RecentChangesRefreshInterval); dlg.RefreshInterval = seconds / 60; if (dlg.ShowDialog(e.Context) == System.Windows.Forms.DialogResult.OK) { cfg.RecentChangesRefreshInterval = Math.Max(dlg.RefreshInterval * 60, 0); configSvc.SaveConfig(cfg); RecentChangesPage rcPage = e.GetService <RecentChangesPage>(); if (rcPage != null) { rcPage.RefreshIntervalConfigModified(); } } } } }
public void OnExecute(CommandEventArgs e) { IAnkhSolutionSettings slnSettings = e.GetService <IAnkhSolutionSettings>(); List <ISvnLogItem> logItems = new List <ISvnLogItem>(e.Selection.GetSelection <ISvnLogItem>()); if (logItems.Count != 1) { return; } using (EditLogMessageDialog dialog = new EditLogMessageDialog()) { dialog.Context = e.Context; dialog.LogMessage = logItems[0].LogMessage; if (dialog.ShowDialog(e.Context) == DialogResult.OK) { if (dialog.LogMessage == logItems[0].LogMessage) { return; // No changes } IAnkhConfigurationService config = e.GetService <IAnkhConfigurationService>(); if (config != null) { if (dialog.LogMessage != null && dialog.LogMessage.Trim().Length > 0) { config.GetRecentLogMessages().Add(dialog.LogMessage); } } using (SvnClient client = e.GetService <ISvnClientPool>().GetClient()) { SvnSetRevisionPropertyArgs sa = new SvnSetRevisionPropertyArgs(); sa.AddExpectedError(SvnErrorCode.SVN_ERR_REPOS_DISABLED_FEATURE); client.SetRevisionProperty(logItems[0].RepositoryRoot, logItems[0].Revision, SvnPropertyNames.SvnLog, dialog.LogMessage, sa); if (sa.LastException != null && sa.LastException.SvnErrorCode == SvnErrorCode.SVN_ERR_REPOS_DISABLED_FEATURE) { AnkhMessageBox mb = new AnkhMessageBox(e.Context); mb.Show(sa.LastException.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>(); if (logWindow != null) { // TODO: Somehow repair scroll position/number of items loaded logWindow.Restart(); } } } }
/// <see cref="Ankh.Commands.ICommandHandler.OnExecute" /> public void OnExecute(CommandEventArgs e) { List <SvnItem> svnItems = new List <SvnItem>(); ISvnStatusCache cache = e.GetService <ISvnStatusCache>(); switch (e.Command) { case AnkhCommand.ItemMerge: // TODO: Check for solution and/or project selection to use the folder instead of the file foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { svnItems.Add(item); } break; case AnkhCommand.ProjectMerge: foreach (SccProject p in e.Selection.GetSelectedProjects(false)) { IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); ISccProjectInfo info = pfm.GetProjectInfo(p); if (info != null && info.ProjectDirectory != null) { svnItems.Add(cache[info.ProjectDirectory]); } } break; case AnkhCommand.SolutionMerge: svnItems.Add(cache[e.GetService <IAnkhSolutionSettings>().ProjectRoot]); break; default: throw new InvalidOperationException(); } IEnumerable <string> selectedFiles = e.Selection.GetSelectedFiles(true); IAnkhOpenDocumentTracker tracker = e.GetService <IAnkhOpenDocumentTracker>(); using (DocumentLock lck = tracker.LockDocuments(selectedFiles, DocumentLockType.ReadOnly)) using (lck.MonitorChangesForReload()) using (MergeWizard dialog = new MergeWizard(e.Context, svnItems[0])) { DialogResult result = dialog.ShowDialog(e.Context); //result = uiService.ShowDialog(dialog); if (result == DialogResult.OK) { using (MergeResultsDialog mrd = new MergeResultsDialog()) { mrd.MergeActions = dialog.MergeActions; mrd.ResolvedMergeConflicts = dialog.ResolvedMergeConflicts; mrd.ShowDialog(e.Context); } } } }
private static void AutoOpenCommand(CommandEventArgs e, SvnOrigin origin) { IAnkhCommandService svc = e.GetService <IAnkhCommandService>(); IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); if (svc == null || solutionSettings == null) { return; } // Ok, we can assume we have a file string filename = origin.Target.FileName; string ext = Path.GetExtension(filename); if (string.IsNullOrEmpty(ext)) { // No extension -> Open as text svc.PostExecCommand(AnkhCommand.ViewInVsText); return; } foreach (string projectExt in solutionSettings.AllProjectExtensionsFilter.Split(';')) { if (projectExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase)) { // We found a project or solution, use Open from Subversion to create a checkout svc.PostExecCommand(AnkhCommand.FileFileOpenFromSubversion, origin); return; } } bool odd = false; foreach (string block in solutionSettings.OpenFileFilter.Split('|')) { odd = !odd; if (odd) { continue; } foreach (string itemExt in block.Split(';')) { if (itemExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase)) { svc.PostExecCommand(AnkhCommand.ViewInVsNet); return; } } } // Ultimate fallback: Just ask the user what to do (don't trust the repository!) svc.PostExecCommand(AnkhCommand.ViewInWindowsWith); }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); _pendingChanges = e.GetService <PendingChangeManager>(typeof(IPendingChangesManager)); } _commandService.TockCommand(e.Command); _pendingChanges.OnTickRefresh(); }
public override void OnExecute(CommandEventArgs e) { IUIShell shell = e.GetService<IUIShell>(); Uri info; if (e.Argument is string) { string arg = (string)e.Argument; info = null; if (SvnItem.IsValidPath(arg, true)) { SvnItem item = e.GetService<IFileStatusCache>()[arg]; if (item.IsVersioned) { info = item.Uri; if (item.IsFile) info = new Uri(info, "./"); } } if (info == null) info = new Uri((string)e.Argument); } else if (e.Argument is Uri) info = (Uri)e.Argument; else using (AddRepositoryRootDialog dlg = new AddRepositoryRootDialog()) { if (dlg.ShowDialog(e.Context) != DialogResult.OK || dlg.Uri == null) return; info = dlg.Uri; } if (info != null) { RepositoryExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl; if (ctrl == null) { IAnkhPackage pkg = e.GetService<IAnkhPackage>(); pkg.ShowToolWindow(AnkhToolWindow.RepositoryExplorer); } ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl; if (ctrl != null) ctrl.AddRoot(info); } }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); } if (_projectNotifier == null) { _projectNotifier = e.GetService <ProjectNotifier>(typeof(IFileStatusMonitor)); } _commandService.TockCommand(e.Command); _projectNotifier.HandleEvent(e.Command); }
public void OnExecute(CommandEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (_control == null) { return; // Can never happen as update already checked this } if (e.Command == AnkhCommand.SvnInfoAlphabetical) { _control.Grid.PropertySort = PropertySort.Alphabetical; } else { _control.Grid.PropertySort = PropertySort.CategorizedAlphabetical; } // And tell VS that the state of other commands changed to // avoid an ugly delay in updating the other toolbar button IVsUIShell shell = e.GetService <IVsUIShell>(); if (shell != null) { shell.UpdateCommandUI(1); // Force an immediate update } }
public override void OnExecute(CommandEventArgs e) { using (ExportDialog dlg = new ExportDialog(e.Context)) { dlg.OriginPath = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)).FullPath; if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return; } SvnDepth depth = dlg.NonRecursive ? SvnDepth.Empty : SvnDepth.Infinity; e.GetService <IProgressRunner>().RunModal(CommandStrings.Exporting, delegate(object sender, ProgressWorkerArgs wa) { SvnExportArgs args = new SvnExportArgs(); args.Depth = depth; args.Revision = dlg.Revision; args.Overwrite = true; wa.Client.Export(dlg.ExportSource, dlg.LocalPath, args); }); } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (item == null) { return; } string newName = item.Origin.Target.FileName; if (e.Argument != null) { string[] items = e.Argument as string[]; if (items != null) { if (items.Length == 1) { newName = items[0]; } else if (items.Length > 1) { newName = items[1]; } } } string logMessage; using (RenameDialog dlg = new RenameDialog()) { dlg.Context = e.Context; dlg.OldName = item.Origin.Target.FileName; dlg.NewName = newName; if (DialogResult.OK != dlg.ShowDialog(e.Context)) { return; } newName = dlg.NewName; logMessage = dlg.LogMessage; } try { Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri); e.GetService <IProgressRunner>().RunModal(CommandStrings.RenamingNodes, delegate(object sender, ProgressWorkerArgs we) { SvnMoveArgs ma = new SvnMoveArgs(); ma.LogMessage = logMessage; we.Client.RemoteMove(itemUri, new Uri(itemUri, newName), ma); }); } finally { item.RefreshItem(true); } }
void ExecuteDiff(CommandEventArgs e, ICollection <SvnOrigin> targets, SvnRevisionRange range) { if (targets.Count != 1) { return; } SvnTarget diffTarget = EnumTools.GetSingle(targets).Target; IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>(); AnkhDiffArgs da = new AnkhDiffArgs(); string[] files = diff.GetTempFiles(diffTarget, range.StartRevision, range.EndRevision, true); if (files == null) { return; } da.BaseFile = files[0]; da.MineFile = files[1]; da.BaseTitle = diff.GetTitle(diffTarget, range.StartRevision); da.MineTitle = diff.GetTitle(diffTarget, range.EndRevision); da.ReadOnly = true; diff.RunDiff(da); }
public override void OnExecute(CommandEventArgs e) { List <SvnOrigin> items = new List <SvnOrigin>(); List <ISvnRepositoryItem> refresh = new List <ISvnRepositoryItem>(); foreach (ISvnRepositoryItem i in e.Selection.GetSelection <ISvnRepositoryItem>()) { if (i.Origin == null || i.Origin.Target.Revision != SvnRevision.Head || i.Origin.IsRepositoryRoot) { break; } items.Add(i.Origin); refresh.Add(i); } if (items.Count == 0) { return; } string logMessage; Uri[] uris; using (ConfirmDeleteDialog d = new ConfirmDeleteDialog()) { d.Context = e.Context; d.SetUris(items); if (!e.DontPrompt && d.ShowDialog(e.Context) != System.Windows.Forms.DialogResult.OK) { return; } logMessage = d.LogMessage; uris = d.Uris; } try { e.GetService <IProgressRunner>().RunModal(CommandStrings.Deleting, delegate(object sender, ProgressWorkerArgs a) { SvnDeleteArgs da = new SvnDeleteArgs(); da.LogMessage = logMessage; a.Client.RemoteDelete(uris, da); }); } finally { // TODO: Don't refresh each item; refresh each parent! foreach (ISvnRepositoryItem r in refresh) { r.RefreshItem(true); } } }
public override void OnExecute(CommandEventArgs e) { IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>(); ISvnRepositoryItem reposItem = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (reposItem == null) { return; } SvnRevision from; SvnRevision to; if (reposItem.Revision == SvnRevision.Working) { from = SvnRevision.Base; to = SvnRevision.Working; } else if (e.Command == AnkhCommand.RepositoryCompareWithWc) { from = reposItem.Revision; to = SvnRevision.Working; } else { from = reposItem.Revision.Revision - 1; to = reposItem.Revision; } AnkhDiffArgs da = new AnkhDiffArgs(); if (to == SvnRevision.Working) { da.BaseFile = diff.GetTempFile(reposItem.Origin.Target, from, true); if (da.BaseFile == null) { return; // User canceled } da.MineFile = ((SvnPathTarget)reposItem.Origin.Target).FullPath; } else { string[] files = diff.GetTempFiles(reposItem.Origin.Target, from, to, true); if (files == null) { return; // User canceled } da.BaseFile = files[0]; da.MineFile = files[1]; System.IO.File.SetAttributes(da.MineFile, System.IO.FileAttributes.ReadOnly | System.IO.FileAttributes.Normal); } da.BaseTitle = diff.GetTitle(reposItem.Origin.Target, from); da.MineTitle = diff.GetTitle(reposItem.Origin.Target, to); diff.RunDiff(da); }
public void OnExecute(CommandEventArgs e) { string info; if (e.Argument is string) { // Allow opening from info = (string)e.Argument; } else if (e.Command == AnkhCommand.WorkingCopyAdd) { using (AddWorkingCopyExplorerRootDialog dlg = new AddWorkingCopyExplorerRootDialog()) { DialogResult dr = dlg.ShowDialog(e.Context); if (dr != DialogResult.OK || string.IsNullOrEmpty(dlg.NewRoot)) { return; } info = dlg.NewRoot; } } else { throw new InvalidOperationException("WorkingCopyBrowse was called without a path"); } if (!string.IsNullOrEmpty(info)) { WorkingCopyExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as WorkingCopyExplorerControl; if (ctrl == null) { IAnkhPackage pkg = e.GetService <IAnkhPackage>(); pkg.ShowToolWindow(AnkhToolWindow.WorkingCopyExplorer); } ctrl = e.Selection.ActiveDialogOrFrameControl as WorkingCopyExplorerControl; if (ctrl != null) { switch (e.Command) { case AnkhCommand.WorkingCopyAdd: ctrl.AddRoot(info); break; case AnkhCommand.WorkingCopyBrowse: ctrl.BrowsePath(e.Context, info); break; } } } }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); } if (_projectTracker == null) { _projectTracker = e.GetService <ProjectTracker>(); } if (_sccProvider == null) { _sccProvider = e.GetService <SvnSccProvider>(typeof(IAnkhSccService)); } _commandService.TockCommand(e.Command); _projectTracker.OnSccCleanup(e); _sccProvider.OnSccCleanup(e); }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>()); if (item == null) return; string newName = item.Origin.Target.FileName; if (e.Argument != null) { string[] items = e.Argument as string[]; if (items != null) { if (items.Length == 1) newName = items[0]; else if (items.Length > 1) newName = items[1]; } } string logMessage; using (RenameDialog dlg = new RenameDialog()) { dlg.Context = e.Context; dlg.OldName = item.Origin.Target.FileName; dlg.NewName = newName; if (DialogResult.OK != dlg.ShowDialog(e.Context)) { return; } newName = dlg.NewName; logMessage = dlg.LogMessage; } try { Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri); e.GetService<IProgressRunner>().RunModal(CommandStrings.RenamingNodes, delegate(object sender, ProgressWorkerArgs we) { SvnMoveArgs ma = new SvnMoveArgs(); ma.LogMessage = logMessage; we.Client.RemoteMove(itemUri, new Uri(itemUri, newName), ma); }); } finally { item.RefreshItem(true); } }
public void OnExecute(CommandEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); SvnSccProvider scc = e.GetService <SvnSccProvider>(); SccHierarchy hier = EnumTools.GetSingle(e.Selection.GetSelectedHierarchies()); if (hier == null) { throw new InvalidOperationException(); } switch (e.Command) { case AnkhCommand.SccSccReCheckoutFailedProject: { scc.EnlistAndCheckout(hier.Hierarchy, hier.Name); IVsSolution s = e.GetService <IVsSolution>(typeof(SVsSolution)); ISccHelper helper = e.GetService <ISccHelper>(); if (s == null || helper == null) { return; } Guid projectGuid; if (!VSErr.Succeeded(s.GetGuidOfProject(hier.Hierarchy, out projectGuid))) { return; } helper.EnsureProjectLoaded(projectGuid, false); break; } case AnkhCommand.SccEditFailedProjectLocation: scc.EditEnlistment(hier.Hierarchy, hier.Name); break; } }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); } if (_fileCache == null) { _fileCache = e.GetService <GitStatusCache>(typeof(IGitStatusCache)); } _commandService.TockCommand(e.Command); if (e.Command == AnkhCommand.GitCacheFinishTasks) { _fileCache.OnCleanup(); } else { _fileCache.BroadcastChanges(); } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem selected = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (selected == null) { return; } Uri uri = selected.Uri; string name = selected.Origin.Target.FileName; IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); using (CheckoutDialog dlg = new CheckoutDialog()) { dlg.Context = e.Context; dlg.Uri = uri; dlg.RepositoryRoot = selected.Origin.RepositoryRoot; dlg.LocalPath = System.IO.Path.Combine(ss.NewProjectLocation, name); if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return; } e.GetService <IProgressRunner>().RunModal(CommandStrings.CheckingOut, delegate(object sender, ProgressWorkerArgs a) { SvnCheckOutArgs args = new SvnCheckOutArgs(); args.Revision = dlg.Revision; args.Depth = dlg.Recursive ? SvnDepth.Infinity : SvnDepth.Files; args.IgnoreExternals = dlg.IgnoreExternals; a.Client.CheckOut(dlg.Uri, dlg.LocalPath, args); }); } }
public override void OnExecute(CommandEventArgs e) { List<SvnOrigin> items = new List<SvnOrigin>(); List<ISvnRepositoryItem> refresh = new List<ISvnRepositoryItem>(); foreach (ISvnRepositoryItem i in e.Selection.GetSelection<ISvnRepositoryItem>()) { if (i.Origin == null || i.Origin.Target.Revision != SvnRevision.Head || i.Origin.IsRepositoryRoot) break; items.Add(i.Origin); refresh.Add(i); } if(items.Count == 0) return; string logMessage; Uri[] uris; using(ConfirmDeleteDialog d = new ConfirmDeleteDialog()) { d.Context = e.Context; d.SetUris(items); if (!e.DontPrompt && d.ShowDialog(e.Context) != System.Windows.Forms.DialogResult.OK) return; logMessage = d.LogMessage; uris = d.Uris; } try { e.GetService<IProgressRunner>().RunModal("Deleting", delegate(object sender, ProgressWorkerArgs a) { SvnDeleteArgs da = new SvnDeleteArgs(); da.LogMessage = logMessage; a.Client.RemoteDelete(uris, da); }); } finally { // TODO: Don't refresh each item; refresh each parent! foreach(ISvnRepositoryItem r in refresh) { r.RefreshItem(true); } } }
public void OnExecute(CommandEventArgs e) { SvnItem firstVersioned = null; ISvnStatusCache cache = e.GetService <ISvnStatusCache>(); IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); if (solutionSettings != null) { firstVersioned = cache[solutionSettings.ProjectRoot]; } if (firstVersioned == null) { return; // exceptional case } using (IssueTrackerConfigDialog dialog = new IssueTrackerConfigDialog(e.Context)) { if (dialog.ShowDialog(e.Context) == System.Windows.Forms.DialogResult.OK) { IIssueTrackerSettings currentSettings = e.GetService <IIssueTrackerSettings>(); IssueRepository newRepository = dialog.NewIssueRepository; if (newRepository == null || string.IsNullOrEmpty(newRepository.ConnectorName) || newRepository.RepositoryUri == null) { DeleteIssueRepositoryProperties(e.Context, firstVersioned); } else if (currentSettings == null || currentSettings.ShouldPersist(newRepository)) { SetIssueRepositoryProperties(e.Context, firstVersioned, newRepository); } } } }
public override void OnExecute(CommandEventArgs e) { // Refresh all global states on the selected files // * File Status Cache // * Glyph cache (in VS Projects) // * Pending changes // * Editor dirty state // Don't handle individual windows here, they can just override the refresh handler // See WorkingCopyExplorerControl.OnFrameCreated() for some examples on how to do that IFileStatusMonitor monitor = e.GetService <IFileStatusMonitor>(); monitor.ScheduleSvnStatus(e.Selection.GetSelectedFiles(true)); IAnkhOpenDocumentTracker dt = e.GetService <IAnkhOpenDocumentTracker>(); dt.RefreshDirtyState(); IPendingChangesManager pm = e.GetService <IPendingChangesManager>(); pm.Refresh((string)null); // Perform a full incremental refresh on the PC window }
public override void OnExecute(CommandEventArgs e) { IAnkhDiffHandler diff = e.GetService<IAnkhDiffHandler>(); ISvnRepositoryItem reposItem = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>()); if (reposItem == null) return; SvnRevision from; SvnRevision to; if (e.Command == AnkhCommand.RepositoryCompareWithWc) { from = reposItem.Revision; to = SvnRevision.Working; } else { from = reposItem.Revision.Revision - 1; to = reposItem.Revision; } AnkhDiffArgs da = new AnkhDiffArgs(); if (to == SvnRevision.Working) { da.BaseFile = diff.GetTempFile(reposItem.Origin.Target, from, true); if (da.BaseFile == null) return; // User canceled da.MineFile = ((SvnPathTarget)reposItem.Origin.Target).FullPath; } else { string[] files = diff.GetTempFiles(reposItem.Origin.Target, from, to, true); if (files == null) return; // User canceled da.BaseFile = files[0]; da.MineFile = files[1]; System.IO.File.SetAttributes(da.MineFile, System.IO.FileAttributes.ReadOnly | System.IO.FileAttributes.Normal); } da.BaseTitle = diff.GetTitle(reposItem.Origin.Target, from); da.MineTitle = diff.GetTitle(reposItem.Origin.Target, to); diff.RunDiff(da); }
public override void OnExecute(CommandEventArgs e) { IAnkhPackage package = e.Context.GetService <IAnkhPackage>(); AnkhToolWindow toolWindow; switch (e.Command) { case AnkhCommand.ShowPendingChanges: toolWindow = AnkhToolWindow.PendingChanges; break; case AnkhCommand.ShowWorkingCopyExplorer: toolWindow = AnkhToolWindow.WorkingCopyExplorer; break; case AnkhCommand.ShowRepositoryExplorer: toolWindow = AnkhToolWindow.RepositoryExplorer; break; case AnkhCommand.ShowSubversionInfo: toolWindow = AnkhToolWindow.SvnInfo; break; default: return; } package.ShowToolWindow(toolWindow); if (e.Command == AnkhCommand.ShowRepositoryExplorer) { IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); if (ss.ProjectRootUri != null) { RepositoryExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl; if (ctrl != null) { ctrl.AddRoot(ss.ProjectRootUri); } } } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem selected = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); string directoryName = ""; using (CreateDirectoryDialog dlg = new CreateDirectoryDialog()) { DialogResult result = dlg.ShowDialog(e.Context); directoryName = dlg.NewDirectoryName; if (result != DialogResult.OK || string.IsNullOrEmpty(directoryName)) { return; } string log = dlg.LogMessage; // Handle special characters like on local path Uri uri = SvnTools.AppendPathSuffix(selected.Uri, directoryName); ProgressRunnerResult prResult = e.GetService <IProgressRunner>().RunModal( CommandStrings.CreatingDirectories, delegate(object sender, ProgressWorkerArgs ee) { SvnCreateDirectoryArgs args = new SvnCreateDirectoryArgs(); args.ThrowOnError = false; args.CreateParents = true; args.LogMessage = log; ee.Client.RemoteCreateDirectory(uri, args); } ); if (prResult.Succeeded) { selected.RefreshItem(false); } } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem selected = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>()); string directoryName = ""; using (CreateDirectoryDialog dlg = new CreateDirectoryDialog()) { DialogResult result = dlg.ShowDialog(e.Context); directoryName = dlg.NewDirectoryName; if (result != DialogResult.OK || string.IsNullOrEmpty(directoryName)) return; string log = dlg.LogMessage; // Handle special characters like on local path Uri uri = SvnTools.AppendPathSuffix(selected.Uri, directoryName); ProgressRunnerResult prResult = e.GetService<IProgressRunner>().RunModal( CommandStrings.CreatingDirectories, delegate(object sender, ProgressWorkerArgs ee) { SvnCreateDirectoryArgs args = new SvnCreateDirectoryArgs(); args.ThrowOnError = false; args.CreateParents = true; args.LogMessage = log; ee.Client.RemoteCreateDirectory(uri, args); } ); if (prResult.Succeeded) { selected.RefreshItem(false); } } }
public void OnExecute(CommandEventArgs e) { // All checked in OnUpdate ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>(); SvnOrigin origin = EnumTools.GetSingle(logWindow.Origins); ISvnLogItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>()); IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>(); AnkhDiffArgs da = new AnkhDiffArgs(); da.BaseFile = diff.GetTempFile(origin.Target, item.Revision, true); if (da.BaseFile == null) { return; // User cancel } da.MineFile = ((SvnPathTarget)origin.Target).FullPath; da.BaseTitle = string.Format("Base (r{0})", item.Revision); da.MineTitle = "Working"; diff.RunDiff(da); }
void OnExecuteFill(CommandEventArgs e) { if (ProjectRootUri != null) { e.Result = new string[] { ProjectRootUri.ToString(), "Other..." } } ; } void OnExecuteSet(CommandEventArgs e) { string value = (string)e.Argument; IAnkhCommandService cs = e.GetService <IAnkhCommandService>(); if (value != null && value == "Other...") { cs.PostExecCommand(AnkhCommand.SolutionSwitchDialog); } else { cs.PostExecCommand(AnkhCommand.SolutionSwitchDialog, new Uri(value)); } } void OnExecuteGet(CommandEventArgs e) { if (ProjectRootUri != null) { e.Result = ProjectRootUri.ToString(); } } void OnExecuteFilter(CommandEventArgs e) { // Not called on us; but empty handler would tell: pass through } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem ri = null; foreach (ISvnRepositoryItem i in e.Selection.GetSelection<ISvnRepositoryItem>()) { if (i.Origin == null) continue; ri = i; break; } if (ri == null) return; string toFile = e.GetService<IAnkhTempFileManager>().GetTempFileNamed(ri.Origin.Target.FileName); string ext = Path.GetExtension(toFile); if (!SaveFile(e, ri, toFile)) return; if (e.Command == AnkhCommand.ViewInVsNet) VsShellUtilities.OpenDocument(e.Context, toFile); else if (e.Command == AnkhCommand.ViewInVsText) { IVsUIHierarchy hier; IVsWindowFrame frame; uint id; VsShellUtilities.OpenDocument(e.Context, toFile, VSConstants.LOGVIEWID_TextView, out hier, out id, out frame); } else { Process process = new Process(); process.StartInfo.UseShellExecute = true; if (e.Command == AnkhCommand.ViewInWindowsWith && !string.Equals(ext, ".zip", StringComparison.OrdinalIgnoreCase)) { // TODO: BH: I tested with adding quotes around {0} but got some error // BH: Don't call this on .zip files in vista, as it will break the builtin // zip file support in the Windows Explorer (as that isn't available in the list) process.StartInfo.FileName = "rundll32.exe"; process.StartInfo.Arguments = string.Format("Shell32,OpenAs_RunDLL {0}", toFile); } else process.StartInfo.FileName = toFile; try { process.Start(); } catch (Win32Exception ex) { // no application is associated with the file type if (ex.NativeErrorCode == NOASSOCIATEDAPP) e.GetService<IAnkhDialogOwner>() .MessageBox.Show("Windows could not find an application associated with the file type", "No associated application", MessageBoxButtons.OK); else throw; } } }
public void OnExecute(CommandEventArgs e) { ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>(); IProgressRunner progressRunner = e.GetService <IProgressRunner>(); if (logWindow == null) { return; } List <SvnRevisionRange> revisions = new List <SvnRevisionRange>(); if (e.Command == AnkhCommand.LogRevertTo) { ISvnLogItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>()); if (item == null) { return; } // Revert to revision, is revert everything after revisions.Add(new SvnRevisionRange(SvnRevision.Working, item.Revision)); } else { foreach (ISvnLogItem item in e.Selection.GetSelection <ISvnLogItem>()) { revisions.Add(new SvnRevisionRange(item.Revision, item.Revision - 1)); } } if (revisions.Count == 0) { return; } IAnkhOpenDocumentTracker tracker = e.GetService <IAnkhOpenDocumentTracker>(); HybridCollection <string> nodes = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase); foreach (SvnOrigin o in logWindow.Origins) { SvnPathTarget pt = o.Target as SvnPathTarget; if (pt == null) { continue; } foreach (string file in tracker.GetDocumentsBelow(pt.FullPath)) { if (!nodes.Contains(file)) { nodes.Add(file); } } } if (nodes.Count > 0) { tracker.SaveDocuments(nodes); // Saves all open documents below all specified origins } using (DocumentLock dl = tracker.LockDocuments(nodes, DocumentLockType.NoReload)) using (dl.MonitorChangesForReload()) { SvnMergeArgs ma = new SvnMergeArgs(); progressRunner.RunModal(LogStrings.Reverting, delegate(object sender, ProgressWorkerArgs ee) { foreach (SvnOrigin item in logWindow.Origins) { SvnPathTarget target = item.Target as SvnPathTarget; if (target == null) { continue; } ee.Client.Merge(target.FullPath, target, revisions, ma); } }); } }
void OnDelete(object sender, CommandEventArgs e) { e.GetService <IAnkhCommandService>().PostExecCommand(AnkhCommand.SvnNodeDelete); }
public override void OnExecute(CommandEventArgs e) { Uri target = null; Uri root = null; bool up = false; List <SvnUriTarget> copyFrom = new List <SvnUriTarget>(); foreach (ISvnRepositoryItem item in e.Selection.GetSelection <ISvnRepositoryItem>()) { SvnUriTarget utt = item.Origin.Target as SvnUriTarget; if (utt == null) { utt = new SvnUriTarget(item.Origin.Uri, item.Origin.Target.Revision); } copyFrom.Add(utt); if (root == null) { root = item.Origin.RepositoryRoot; } if (target == null) { target = item.Origin.Uri; } else { Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri); Uri r = item.Origin.Uri.MakeRelativeUri(target); if (r.IsAbsoluteUri) { target = null; break; } string rs = r.ToString(); if (r.ToString().StartsWith("/", StringComparison.Ordinal)) { target = new Uri(target, "/"); break; } if (!up && r.ToString().StartsWith("../")) { target = new Uri(target, "../"); up = true; } } } bool isMove = e.Command == AnkhCommand.ReposMoveTo; Uri toUri; string logMessage; using (CopyToDialog dlg = new CopyToDialog()) { dlg.RootUri = root; dlg.SelectedUri = target; dlg.Text = isMove ? "Move to Url" : "Copy to Url"; if (dlg.ShowDialog(e.Context) != System.Windows.Forms.DialogResult.OK) { return; } toUri = dlg.SelectedUri; logMessage = dlg.LogMessage; } // TODO: BH: Make sure the 2 attempts actually make sense e.GetService <IProgressRunner>().RunModal(isMove ? CommandStrings.Moving : CommandStrings.Copying, delegate(object snd, ProgressWorkerArgs a) { if (isMove) { List <Uri> uris = new List <Uri>(); foreach (SvnUriTarget ut in copyFrom) { uris.Add(ut.Uri); } SvnMoveArgs ma = new SvnMoveArgs(); ma.LogMessage = logMessage; ma.CreateParents = true; try { // First try with the full new name a.Client.RemoteMove(uris, toUri, ma); } catch (SvnFileSystemException fs) { if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS) { throw; } // If exists retry below this directory with the existing name ma.AlwaysMoveAsChild = true; a.Client.RemoteMove(uris, toUri, ma); } } else { SvnCopyArgs ca = new SvnCopyArgs(); ca.LogMessage = logMessage; ca.CreateParents = true; try { // First try with the full new name a.Client.RemoteCopy(copyFrom, toUri, ca); } catch (SvnFileSystemException fs) { if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS) { throw; } // If exists retry below this directory with the existing name ca.AlwaysCopyAsChild = true; a.Client.RemoteCopy(copyFrom, toUri, ca); } } }); // TODO: Send some notification to the repository explorer on this change? }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (item == null) { return; } string copyTo; bool copyBelow = false; bool suggestExport = false; ISvnStatusCache cache = e.GetService <ISvnStatusCache>(); if (item.NodeKind == SharpSvn.SvnNodeKind.Directory) { using (FolderBrowserDialog fd = new FolderBrowserDialog()) { fd.ShowNewFolderButton = false; if (DialogResult.OK != fd.ShowDialog(e.Context.DialogOwner)) { return; } copyTo = fd.SelectedPath; copyBelow = true; SvnItem dirItem = cache[copyTo]; if (dirItem == null || !dirItem.IsVersioned) { suggestExport = true; } } } else { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.CheckPathExists = true; sfd.OverwritePrompt = true; string name = item.Origin.Target.FileName; string ext = Path.GetExtension(item.Origin.Target.FileName); sfd.Filter = string.Format("{0} files|*.{0}|All files (*.*)|*", ext.TrimStart('.')); sfd.FileName = name; if (DialogResult.OK != sfd.ShowDialog(e.Context.DialogOwner)) { return; } copyTo = SvnTools.GetNormalizedFullPath(sfd.FileName); SvnItem fileItem = cache[copyTo]; if (File.Exists(copyTo)) { // We prompted to confirm; remove the file! if (fileItem.IsVersioned) { e.GetService <IProgressRunner>().RunModal(CommandStrings.Copying, delegate(object sender, ProgressWorkerArgs a) { SvnDeleteArgs da = new SvnDeleteArgs(); da.Force = true; a.Client.Delete(copyTo, da); }); } else { SvnItem.DeleteNode(copyTo); } } SvnItem dir = fileItem.Parent; if (dir == null || !(dir.IsVersioned && dir.IsVersionable)) { suggestExport = true; } } } if (!suggestExport) { e.GetService <IProgressRunner>().RunModal(CommandStrings.Copying, delegate(object sender, ProgressWorkerArgs a) { SvnCopyArgs ca = new SvnCopyArgs(); ca.CreateParents = true; if (copyBelow) { ca.AlwaysCopyAsChild = true; } a.Client.Copy(item.Origin.Target, copyTo, ca); }); } else { AnkhMessageBox mb = new AnkhMessageBox(e.Context); if (DialogResult.Yes == mb.Show(CommandStrings.NotInWorkingCopyExportInstead, CommandStrings.NotInWorkingCopyTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { e.GetService <IProgressRunner>().RunModal(CommandStrings.Exporting, delegate(object sender, ProgressWorkerArgs a) { SvnExportArgs ea = new SvnExportArgs(); ea.Revision = item.Revision; ea.Overwrite = true; a.Client.Export(item.Origin.Target, copyTo, ea); }); } } }
public override void OnExecute(CommandEventArgs e) { ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>()); if (item == null) return; string copyTo; bool copyBelow = false; bool suggestExport = false; IFileStatusCache cache = e.GetService<IFileStatusCache>(); if (item.NodeKind == SharpSvn.SvnNodeKind.Directory) { using (FolderBrowserDialog fd = new FolderBrowserDialog()) { fd.ShowNewFolderButton = false; if (DialogResult.OK != fd.ShowDialog(e.Context.DialogOwner)) return; copyTo = fd.SelectedPath; copyBelow = true; SvnItem dirItem = cache[copyTo]; if (dirItem == null || !dirItem.IsVersioned) suggestExport = true; } } else { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.CheckPathExists = true; sfd.OverwritePrompt = true; string name = item.Origin.Target.FileName; string ext = Path.GetExtension(item.Origin.Target.FileName); sfd.Filter = string.Format("{0} files|*.{0}|All files (*.*)|*", ext.TrimStart('.')); sfd.FileName = name; if (DialogResult.OK != sfd.ShowDialog(e.Context.DialogOwner)) return; copyTo = SvnTools.GetNormalizedFullPath(sfd.FileName); SvnItem fileItem = cache[copyTo]; if (File.Exists(copyTo)) { // We prompted to confirm; remove the file! if (fileItem.IsVersioned) e.GetService<IProgressRunner>().RunModal("Copying", delegate(object sender, ProgressWorkerArgs a) { SvnDeleteArgs da = new SvnDeleteArgs(); da.Force = true; a.Client.Delete(copyTo, da); }); else File.Delete(copyTo); } SvnItem dir = fileItem.Parent; if (dir == null || !(dir.IsVersioned && dir.IsVersionable)) suggestExport = true; } } if (!suggestExport) { e.GetService<IProgressRunner>().RunModal("Copying", delegate(object sender, ProgressWorkerArgs a) { SvnCopyArgs ca = new SvnCopyArgs(); ca.CreateParents = true; if (copyBelow) ca.AlwaysCopyAsChild = true; a.Client.Copy(item.Origin.Target, copyTo, ca); }); } else { AnkhMessageBox mb = new AnkhMessageBox(e.Context); if (DialogResult.Yes == mb.Show("The specified path is not in a workingcopy; would you like to export the file instead?", "No Working Copy", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { e.GetService<IProgressRunner>().RunModal("Exporting", delegate(object sender, ProgressWorkerArgs a) { SvnExportArgs ea = new SvnExportArgs(); ea.Revision = item.Revision; a.Client.Export(item.Origin.Target, copyTo, ea); }); } } }
void OnRename(object sender, CommandEventArgs e) { e.GetService <IAnkhCommandService>().PostExecCommand(AnkhCommand.RenameRepositoryItem); }
public void DoBlame(CommandEventArgs e, SvnOrigin origin, SvnRevision revisionStart, SvnRevision revisionEnd, bool ignoreEols, SvnIgnoreSpacing ignoreSpacing, bool retrieveMergeInfo) { // There are two SVN related operations: // [1] Getting the file at revisionEnd, which will be displayed in the editor // [2] Getting the blame information, which will be displayed in the margin // This is the parameter structure for [1] getting the file SvnWriteArgs wa = new SvnWriteArgs(); wa.Revision = revisionEnd; // This is the parameter structure for [2] getting the blame information SvnBlameArgs ba = new SvnBlameArgs(); ba.Start = revisionStart; ba.End = revisionEnd; ba.IgnoreLineEndings = ignoreEols; ba.IgnoreSpacing = ignoreSpacing; ba.RetrieveMergedRevisions = retrieveMergeInfo; SvnTarget target = origin.Target; // Can we make this an MEF service? IAnkhTempFileManager tempMgr = e.GetService <IAnkhTempFileManager>(); string tempFile = tempMgr.GetTempFileNamed(target.FileName); Collection <SvnBlameEventArgs> blameResult = null; bool retry = false; ProgressRunnerResult r = e.GetService <IProgressRunner>().RunModal("Annotating", delegate(object sender, ProgressWorkerArgs ee) { // Here we [1] get the file at revisionEnd using (FileStream fs = File.Create(tempFile)) { ee.Client.Write(target, fs, wa); } // Here we [2] get the blame information ba.SvnError += delegate(object errorSender, SvnErrorEventArgs errorEventArgs) { if (errorEventArgs.Exception is SvnClientBinaryFileException) { retry = true; errorEventArgs.Cancel = true; } }; ee.Client.GetBlame(target, ba, out blameResult); }); if (retry) { using (AnkhMessageBox mb = new AnkhMessageBox(e.Context)) { // Move to resources later :) if (DialogResult.Yes != mb.Show("You are trying to annotate a binary file. Are you sure you want to continue?", "Binary file detected", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { return; } r = e.GetService <IProgressRunner>() .RunModal("Annotating", delegate(object sender, ProgressWorkerArgs ee) { ba.IgnoreMimeType = true; ee.Client.GetBlame(target, ba, out blameResult); }); } } if (!r.Succeeded) { return; } // Create a parameter struture and add it to our internal map. // Creating the actual view model class is now deferred to the GetModel method. var annParam = new AnnotateMarginParameters { Context = e.Context, Origin = origin, BlameResult = blameResult }; _ViewModelMap.Add(tempFile, annParam); // Open the editor. // ToDo: Open files like resx as code. var dte = e.GetService <DTE> (typeof(SDTE)); dte.ItemOperations.OpenFile(tempFile, EnvDTE.Constants.vsViewKindTextView); }
public void OnExecute(CommandEventArgs e) { Uri info; if (e.Argument is string) { string arg = (string)e.Argument; info = null; if (SvnItem.IsValidPath(arg, true)) { SvnItem item = e.GetService <ISvnStatusCache>()[arg]; if (item.IsVersioned) { info = item.Uri; if (item.IsFile) { info = new Uri(info, "./"); } } } if (info == null) { info = new Uri((string)e.Argument); } } else if (e.Argument is Uri) { info = (Uri)e.Argument; } else { using (RepositorySelectionWizard wizard = new RepositorySelectionWizard(e.Context)) { if (wizard.ShowDialog(e.Context) != DialogResult.OK) { return; } info = wizard.GetSelectedRepositoryUri(); } } if (info != null) { RepositoryExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl; if (ctrl == null) { IAnkhPackage pkg = e.GetService <IAnkhPackage>(); pkg.ShowToolWindow(AnkhToolWindow.RepositoryExplorer); } ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl; if (ctrl != null) { ctrl.AddRoot(info); } } }
public override void OnExecute(CommandEventArgs e) { Uri target = null; Uri root = null; List<SvnUriTarget> copyFrom = new List<SvnUriTarget>(); foreach (ISvnRepositoryItem item in e.Selection.GetSelection<ISvnRepositoryItem>()) { SvnUriTarget utt = item.Origin.Target as SvnUriTarget; if(utt == null) utt = new SvnUriTarget(item.Origin.Uri, item.Origin.Target.Revision); copyFrom.Add(utt); if(root == null) root = item.Origin.RepositoryRoot; if (target == null) target = item.Origin.Uri; else { Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri); Uri r = item.Origin.Uri.MakeRelativeUri(target); if(r.IsAbsoluteUri) { target = null; break; } string rs = r.ToString(); if(r.ToString().StartsWith("/", StringComparison.Ordinal)) { target = new Uri(target, "/"); break; } while(r.ToString().StartsWith("../")) { target = new Uri(target, "../"); r = item.Origin.Uri.MakeRelativeUri(target); } } } bool isMove = e.Command == AnkhCommand.ReposMoveTo; Uri toUri; string logMessage; using (CopyToDialog dlg = new CopyToDialog()) { dlg.RootUri = root; dlg.SelectedUri = target; dlg.Text = isMove ? "Move to Url" : "Copy to Url"; if (dlg.ShowDialog(e.Context) != System.Windows.Forms.DialogResult.OK) return; toUri = dlg.SelectedUri; logMessage = dlg.LogMessage; } // TODO: BH: Make sure the 2 attempts actually make sense e.GetService<IProgressRunner>().RunModal(isMove ? "Moving" : "Copying", delegate(object snd, ProgressWorkerArgs a) { if (isMove) { List<Uri> uris = new List<Uri>(); foreach (SvnUriTarget ut in copyFrom) uris.Add(ut.Uri); SvnMoveArgs ma = new SvnMoveArgs(); ma.LogMessage = logMessage; ma.CreateParents = true; try { // First try with the full new name a.Client.RemoteMove(uris, toUri, ma); } catch (SvnFileSystemException fs) { if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS) throw; // If exists retry below this directory with the existing name ma.AlwaysMoveAsChild = true; a.Client.RemoteMove(uris, toUri, ma); } } else { SvnCopyArgs ca = new SvnCopyArgs(); ca.LogMessage = logMessage; ca.CreateParents = true; try { // First try with the full new name a.Client.RemoteCopy(copyFrom, toUri, ca); } catch (SvnFileSystemException fs) { if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS) throw; // If exists retry below this directory with the existing name ca.AlwaysCopyAsChild = true; a.Client.RemoteCopy(copyFrom, toUri, ca); } } }); // TODO: Send some notification to the repository explorer on this change? }