/// <summary> /// saves the new setting into configuration /// </summary> /// <param name="seconds">new refresh interval in seconds</param> private void SaveRecentChangesRefreshInterval(int seconds) { AnkhConfig cfg = Config; cfg.RecentChangesRefreshInterval = seconds; ConfigSvc.SaveConfig(cfg); }
public void OnConflict(object sender, SvnConflictEventArgs e) { if (_synchronizer != null && _synchronizer.InvokeRequired) { // If needed marshall the call to the UI thread e.Detach(); // Make this instance thread safe! _synchronizer.Invoke(new EventHandler <SvnConflictEventArgs>(OnConflict), new object[] { sender, e }); return; } AnkhConfig config = GetService <IAnkhConfigurationService>().Instance; if (config.InteractiveMergeOnConflict) { // Only call interactive merge if the user opted in on it if (_currentMergeConflictHandler == null) { _currentMergeConflictHandler = CreateMergeConflictHandler(); } _currentMergeConflictHandler.OnConflict(e); } }
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 override void OnExecute(CommandEventArgs e) { AnkhConfig config = e.GetService <IAnkhConfigurationService>().Instance; ICollection <SvnItem> targets; if (!e.DontPrompt && (e.PromptUser || (!Shift && !config.SuppressLockingUI))) { using (PendingChangeSelector selector = new PendingChangeSelector()) { selector.Text = CommandStrings.UnlockTitle; selector.PreserveWindowPlacement = true; selector.LoadItems(new List <SvnItem>(e.Selection.GetSelectedSvnItems(true)), delegate(SvnItem i) { return(i.IsLocked); }, delegate(SvnItem i) { return(i.IsLocked); }); if (selector.ShowDialog(e.Context) != DialogResult.OK) { return; } targets = new List <SvnItem>(selector.GetSelectedItems()); } } else { List <SvnItem> toUnlock = new List <SvnItem>(); foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.IsLocked) { toUnlock.Add(item); } } targets = toUnlock; } if (targets.Count == 0) { return; } List <string> files = new List <string>(SvnItem.GetPaths(targets)); if (files.Count == 0) { return; } e.GetService <IProgressRunner>().RunModal( CommandStrings.UnlockTitle, delegate(object sender, ProgressWorkerArgs ee) { SvnUnlockArgs ua = new SvnUnlockArgs(); ee.Client.Unlock(files, ua); }); }
public override void OnExecute(CommandEventArgs e) { IEnumerable <SvnItem> items = e.Argument as IEnumerable <SvnItem>; if (e.Command == AnkhCommand.SccLock && items == null) { return; } if (items == null) { List <SvnItem> choices = new List <SvnItem>(); foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsFile && item.IsVersioned && !item.IsNewAddition && !item.IsLocked) { choices.Add(item); } } items = choices; } if (EnumTools.IsEmpty(items)) { return; } bool stealLocks = false; string comment = ""; AnkhConfig config = e.GetService <IAnkhConfigurationService>().Instance; if (!e.DontPrompt && (e.PromptUser || !(Shift || config.SuppressLockingUI))) { using (LockDialog dlg = new LockDialog()) { dlg.Context = e.Context; dlg.LoadItems(items); if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return; } items = new List <SvnItem>(dlg.GetCheckedItems()); stealLocks = dlg.StealLocks; comment = dlg.Message; } } ICollection <string> files = SvnItem.GetPaths(items); if (files.Count == 0) { return; } SortedList <string, string> alreadyLockedFiles = new SortedList <string, string>(StringComparer.OrdinalIgnoreCase); e.GetService <IProgressRunner>().RunModal( CommandStrings.LockingTitle, delegate(object sender, ProgressWorkerArgs ee) { SvnLockArgs la = new SvnLockArgs(); la.StealLock = stealLocks; la.Comment = comment; la.AddExpectedError(SvnErrorCode.SVN_ERR_FS_PATH_ALREADY_LOCKED); la.Notify += delegate(object nSender, SvnNotifyEventArgs notifyArgs) { if (notifyArgs.Action == SvnNotifyAction.LockFailedLock) { string userName; if (notifyArgs.Lock != null && !string.IsNullOrEmpty(notifyArgs.Lock.Owner)) { userName = notifyArgs.Lock.Owner; } else { userName = GuessUserFromError(notifyArgs.Error.Message) ?? "?"; } alreadyLockedFiles.Add(notifyArgs.FullPath, userName); } }; ee.Client.Lock(files, la); }); if (alreadyLockedFiles.Count == 0) { return; } StringBuilder msg = new StringBuilder(); msg.AppendLine(CommandStrings.ItemsAlreadyLocked); msg.AppendLine(); foreach (KeyValuePair <string, string> kv in alreadyLockedFiles) { if (!string.IsNullOrEmpty(kv.Value)) { msg.AppendFormat(CommandStrings.ItemFileLocked, kv.Key, kv.Value); } else { msg.Append(kv.Key); } msg.AppendLine(); } // TODO: Create a dialog where the user can select what locks to steal, and also what files are already locked. AnkhMessageBox box = new AnkhMessageBox(e.Context); DialogResult rslt = box.Show( msg.ToString().TrimEnd(), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (rslt == DialogResult.Yes) { e.GetService <IProgressRunner>().RunModal( CommandStrings.LockingTitle, delegate(object sender, ProgressWorkerArgs ee) { SvnLockArgs la = new SvnLockArgs(); la.StealLock = true; la.Comment = comment; ee.Client.Lock(files, la); }); } }