public static DialogResult Show(P4.P4Exception ex, bool showCancel, bool suppressUI) { P4VsProviderService p4vs = (P4VsProviderService)P4VsProvider.Service(typeof(P4VsProviderService)); if ((suppressUI) && (ex.ErrorLevel < P4.ErrorSeverity.E_FATAL)) { return(DialogResult.OK); } if (p4vs.ScmProvider != null && p4vs.ScmProvider.Connection != null) { if (p4vs.ScmProvider.Connection.isLoggedIn() == false) { MessageBox.Show(Resources.P4ErrorDlg_LoggedOutMsg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return(DialogResult.Cancel); } } if (ex is P4.P4CommandCanceledException) { // this command was canceled by the user, so no need to show an error. return(DialogResult.OK); } P4ErrorDlg dlg = new P4ErrorDlg(ex, showCancel); return(dlg.ShowDialog()); }
public static DialogResult Show(SwarmApi.SwarmServer.SwarmException ex, bool showCancel, bool suppressUI) { if (suppressUI) { return(DialogResult.OK); } P4ErrorDlg dlg = new P4ErrorDlg(ex, showCancel); return(dlg.ShowDialog()); }
public static DialogResult Show(string errorMsg, bool showCancel, bool suppressUI) { if (suppressUI) { return(DialogResult.OK); } P4ErrorDlg dlg = new P4ErrorDlg(errorMsg, showCancel); return(dlg.ShowDialog()); }
private void ConnectBtn_Click(object sender, EventArgs e) { try { Uri url = new Uri(SwarmUrlCB.Text); SwarmBrowser.Navigate(url, null, null, null); } catch (Exception ex) { P4VsOutputWindow.AppendMessage("[E_ERROR] " + ex.Message); FileLogger.LogException("Swarm Connection Error", ex); DialogResult res = P4ErrorDlg.Show(ex.Message, false, false); } }
public static DialogResult Show(P4.P4CommandResult results, bool showCancel) { if ((results == null) || (results.ErrorList == null) || (results.ErrorList.Count <= 0)) { return(DialogResult.Ignore); } int numWarnings = 0; List <string> WarningMsgs = new List <string>(); foreach (P4.P4ClientError error in results.ErrorList) { if (error.SeverityLevel <= P4.ErrorSeverity.E_WARN) { numWarnings++; } WarningMsgs.Add(string.Format("{0}: {1}", error.SeverityLevel, error.ErrorMessage)); } if ((results.ErrorList.Count - numWarnings) <= 0) { if (WarningMsgs.Count > 0) { // error dlialog will not display, so list any warning in the output pane foreach (string msg in WarningMsgs) { P4VsOutputWindow.AppendMessage(msg); } } return(DialogResult.Ignore); } P4ErrorDlg dlg = new P4ErrorDlg(results, showCancel); dlg.PromptLbl.Text = Resources.P4ErrorDlg_PromptLabel; dlg.TopMost = true; return(dlg.ShowDialog()); }
public static DialogResult Show(IList <P4.P4Exception> errors, bool showCancel) { P4ErrorDlg dlg = new P4ErrorDlg(errors, showCancel); return(dlg.ShowDialog()); }
private void InitFileListView() #region single pass initialization of the list { this.FileList.Items.Clear(); // itemMap = null; if (_files == null) { return; } // itemMap = new Dictionary<string, FileListViewItem>(); resolveCallback = new P4.Client.ResolveFileDelegate(ResolveCallBackHandler); P4.Options options = new P4.ResolveCmdOptions( P4.ResolveFilesCmdFlags.ForceTextualMerge | P4.ResolveFilesCmdFlags.DisplayBaseFile, -1); int itemCnt = 0; IList <P4.P4Exception> errors = null; IList <string> filesNotListed = new List <string>(); foreach (string file in _files) { IList <P4.FileResolveRecord> records = null; try { records = _scm.Connection.Repository.Connection.Client.ResolveFiles( resolveCallback, options, P4.FileSpec.LocalSpec(file)); } catch (P4.P4Exception ex) { if (errors == null) { errors = new List <P4.P4Exception>(); } errors.Add(ex); } P4.P4CommandResult results = _scm.Connection.Repository.Connection.LastResults; int subItemIdx = 0; FileListViewItem firstItem = null; if ((records != null) && (records.Count > 0)) { foreach (P4.FileResolveRecord record in records) { string path = null; if (record.LocalFilePath != null) { path = record.LocalFilePath.Path; } else if ((record.FromFileSpec != null) && (record.FromFileSpec.LocalPath != null)) { path = record.FromFileSpec.LocalPath.Path; } else { continue; } CurrentItem = new FileListViewItem(path, subItemIdx); if (subItemIdx == 0) { firstItem = CurrentItem; } else { CurrentItem.FirstItem = firstItem; } subItemIdx++; // string key = string.Format("<{0}>{1}", record.ResolveType, path.ToLower()); // itemMap.Add(key, CurrentItem); this.FileList.Items.Add(CurrentItem); CurrentItem.ResolveRecord = record; CurrentItem.Source = record.FromFileSpec; if (record.ResolveType != P4.ResolveType.None) { CurrentItem.ResolveType = record.ResolveType; } else if ((record.Analysis != null) && (record.Analysis.ResolveType != P4.ResolveType.None)) { CurrentItem.ResolveType = record.Analysis.ResolveType; } CurrentItem.ResolveAnalysis = record.Analysis; CurrentItem = null; } } else { filesNotListed.Add(file); } } if (errors != null) { P4ErrorDlg.Show(errors, false); } // clean out files that do not need to be resolved foreach (string file in filesNotListed) { _files.Remove(file); } if (RefreshUICallback != null) { RefreshUICallback(); } if ((_files == null) || (_files.Count <= 0)) { // no files to resolve if (bFirstInit) { MessageBox.Show(Resources.ResolveFileDlg_NoFileToResolveWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.DialogResult = DialogResult.OK; Close(); return; } } bFirstInit = false; SelectionCountLbl.Text = string.Format(SelectionCountLblTxt, 0, itemCnt); resolveCallback = null; AutoResolveRB_CheckedChanged(null, null); }
public void CheckoutResource(IList <string> sel) { IList <VSITEMSELECTION> nodes = SccService.SelectedNodes; IList <string> lockedFiles = new List <string>(); IList <string> lockUsers = new List <string>(); IList <string> staleFiles = new List <string>(); IList <string> checkoutFiles = new List <string>(); for (int idx = 0; idx < sel.Count; idx++) { string file = sel[idx]; bool isWildcard = file.EndsWith("...") || file.EndsWith("*"); if (isWildcard == false) { P4.FileMetaData fmd = null; if (string.IsNullOrEmpty(file) == false) { fmd = SccService.ScmProvider.Fetch(file); } if (fmd != null && fmd.HeadType.Modifiers.HasFlag(P4.FileTypeModifier.ExclusiveOpen) && fmd.OtherOpen > 0) { // Show the error for exclusive open file and continue // without adding file to list of files to checkout P4ErrorDlg.Show(Resources.P4VsProvider_ExclusiveOpenError, false, false); continue; } if ((fmd == null) || (fmd.HeadAction == P4.FileAction.Delete)) { sel.RemoveAt(idx--); continue; } if (fmd.OtherLock) { lockedFiles.Add(fmd.LocalPath.Path); string otherlocks = string.Empty; foreach (string otherLock in fmd.OtherLockUserClients) { if (string.IsNullOrEmpty(otherlocks) == false) { otherlocks += ","; } otherlocks += otherLock; } lockUsers.Add(otherlocks); } if (fmd.IsStale) { staleFiles.Add(fmd.LocalPath.Path); } } else { IList <P4.FileMetaData> fmdList = SccService.ScmProvider.GetFileMetaData(null, file); foreach (P4.FileMetaData fmd in fmdList) { if (fmd.OtherLock) { lockedFiles.Add(fmd.LocalPath.Path); string otherlocks = string.Empty; foreach (string otherLock in fmd.OtherLockUserClients) { if (string.IsNullOrEmpty(otherlocks) == false) { otherlocks += ","; } otherlocks += otherLock; } lockUsers.Add(otherlocks); } if (fmd.IsStale) { staleFiles.Add(fmd.LocalPath.Path); } } } checkoutFiles.Add(file); } if ((lockedFiles != null) && (lockedFiles.Count > 0)) { string lockWarning = Resources.WarningStyle_Locked_Prompt; if (FileListWarningDlg.Show(lockedFiles, lockUsers, FileListWarningDlg.WarningStyle.Locked) == DialogResult.Cancel) { return; } } if ((staleFiles != null) && (staleFiles.Count > 0)) { DialogResult answer = FileListWarningDlg.Show(staleFiles, null, FileListWarningDlg.WarningStyle.GetLatest); if (answer == DialogResult.Cancel) { return; } if (answer == DialogResult.OK) { if (!SccService.SyncFiles(null, staleFiles)) { return; } } } if (checkoutFiles.Count < 1) { return; } P4.Changelist getDesc = SccService.ScmProvider.GetChangelist(-1); if (getDesc == null) { return; } string newChangeDescription = getDesc.Description; if (newChangeDescription == Resources.DefaultChangeListDescription) { newChangeDescription = Resources.P4VsProvider_CheckoutFilesDefaultChangelistDescription; } IList <P4.Changelist> changes = SccService.ScmProvider.GetAvailibleChangelists(-1); int changeListId = -1; string prompt = Resources.P4VsProvider_CheckoutFilePrompt; if (sel.Count >= 2) { prompt = Resources.P4VsProvider_CheckoutFilesPrompt; } changeListId = SelectChangelistDlg2.ShowChooseChangelistYesNo(prompt, checkoutFiles, changes, ref newChangeDescription); if (changeListId < -1) { // user hit cancel return; } if (string.IsNullOrEmpty(newChangeDescription)) { newChangeDescription = Resources.P4VsProvider_CheckoutFilesDefaultChangelistDescription; } SelectChangelistDlg.CurrentChangeList = SccService.CheckoutFiles(sel, changeListId, newChangeDescription); // now refresh the selected nodes' glyphs Glyphs.RefreshNodesGlyphs(nodes, sel); }
// Get Revision button click private void newOKBtn_Click(object sender, EventArgs e) { bool updateSolution = false; IVsSolution solution = null; string path = _scm.SolutionFile; IList <IVsHierarchy> projectsUpdating = new List <IVsHierarchy>(); IList <string> projectsClosed = new List <string>(); IList <Guid> projectsGuidsClosed = new List <Guid>(); if (_isSolutionIncluded) { // Figure out a better test //updateSolution = _scm.SyncFile( // new P4.SyncFilesCmdOptions(P4.SyncFilesCmdFlags.Preview, 1), // path); updateSolution = true; } if (updateSolution) { if (DialogResult.Cancel == MessageBox.Show( Resources.GetRevisionDlg_UpdatingSlnWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } solution = (IVsSolution)P4VsProvider.Instance.GetService(typeof(SVsSolution)); P4VsProvider.Instance.SuppressConnection = true; if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, null, 0)) { MessageBox.Show(Resources.Error_ClosingSolution, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else if (P4VsProvider.Instance.SccService.SelectedNodes != null) { bool needToAsk = true; foreach (VSITEMSELECTION pItem in P4VsProvider.Instance.SccService.SelectedNodes) { if ((pItem.itemid == VSConstants.VSITEMID_ROOT) && (P4VsProvider.Instance.SccService.IsProjectControlled(pItem.pHier))) { #if VS2008 if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_UpdatingProjWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } updateSolution = true; solution = (IVsSolution)GetService(typeof(SVsSolution)); P4VsProvider.Instance.SuppressConnection = true; if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, null, 0)) { MessageBox.Show(Resources.Error_ClosingSolution, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } break; #else IVsProject3 pProj = pItem.pHier as IVsProject3; if (pProj != null) { if (needToAsk == true) { if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_UpdatingProjWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } needToAsk = false; } projectsUpdating.Add(pItem.pHier); if (solution == null) { solution = (IVsSolution)P4VsProvider.Instance.GetService(typeof(SVsSolution)); } Guid projGuid; solution.GetGuidOfProject(pItem.pHier, out projGuid); projectsGuidsClosed.Add(projGuid); if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, pItem.pHier, 0)) { MessageBox.Show(Resources.Error_ClosingProject, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } #endif } } } List <string> refreshItems = new List <string>(); try { //change this to a better global validator int test = 0; bool num = int.TryParse(ValueTB.Text, out test); if (specifierRB.Checked == true && num == false && specifierCB.SelectedIndex == 0 && ValueTB.Text != "head" && ValueTB.Text != "have" && ValueTB.Text != "none" ) { MessageBox.Show(string.Format(Resources.GetRevisionDlg_InvalidRevisionSpecifierWarninig, ValueTB.Text)); ValueTB.Text = string.Empty; return; } //////// _files = new List <P4.FileSpec>(); foreach (ListViewItem item in filesListView.Items) { P4.FileSpec file = new P4.FileSpec(); P4.FileMetaData fmd = new P4.FileMetaData(); if (item.Text.EndsWith("/...")) { fmd.DepotPath = new P4.DepotPath(item.Text); } else { fmd = _scm.GetFileMetaData(item.Text); } if (fmd.LocalPath != null) { file.LocalPath = fmd.LocalPath; } if (fmd.ClientPath != null) { file.ClientPath = fmd.ClientPath; } if (fmd.DepotPath != null) { file.DepotPath = fmd.DepotPath; } _files.Add(file); refreshItems.Add(item.Text.ToString()); } P4.SyncFilesCmdFlags flags = new P4.SyncFilesCmdFlags(); flags = P4.SyncFilesCmdFlags.None; if (forceChk.Checked == true) { flags = P4.SyncFilesCmdFlags.Force; } P4.Options options = new P4.Options(flags, -1); // set up the list of paths with specifiers that we will sync to IList <P4.FileSpec> files = new List <P4.FileSpec>(); //int idx = 0; if (specifierRB.Checked == true) { // #revision if (specifierCB.SelectedIndex == 0) { bool disconnectAfterSync = false; int number = 0; bool isnum = int.TryParse(Value, out number); if (isnum == true) { if (number == 0) { if (_isSolutionIncluded) { if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_RemovingSlnWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { this.DialogResult = DialogResult.Cancel; return; } disconnectAfterSync = true; } else { if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_RemovingProjWarninig, Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { this.DialogResult = DialogResult.Cancel; return; } } } } foreach (P4.FileSpec file in _files) { if (isnum == true) { // skip meta data check for rev 0 there is none, but we dtill want to allow // this as a way to remove the local copy of the file, but still keep checking // to make sure other bad revisions are not fetched such as file that was moved if (number != 0) { IList <P4.FileSpec> fs = new List <FileSpec>(); file.Version = new P4.Revision(number); fs.Add(file); IList <P4.FileMetaData> fmd = _scm.GetFileMetaData(fs, null); if (fmd == null) { if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { if (_files.Count == 1) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); } P4VsOutputWindow.AppendMessage(_scm.Connection.Repository.Connection.LastResults.ErrorList[0].ToString()); } continue; } } file.Version = new P4.Revision(number); } else if (Value == "head") { file.Version = new P4.HeadRevision(); } else if (Value == "have") { file.Version = new P4.HaveRevision(); } else if (Value == "none") { file.Version = new P4.NoneRevision(); } files.Add(file); } if (files.Count > 0) { _scm.SyncFiles(options, files); } if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } if (_scm.SccService == null) { return; } this.DialogResult = DialogResult.OK; } else { if (_scm.SccService == null) { return; } this.DialogResult = DialogResult.OK; } if (disconnectAfterSync) { P4VsProvider.Instance.SccService.Dispose(); } } // @workspace if (specifierCB.SelectedIndex == 4) { foreach (P4.FileSpec file in _files) { file.Version = new P4.ClientNameVersion(Value.ToString()); files.Add(file); } _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } // @date/time if (specifierCB.SelectedIndex == 2) { DateTime value = dateTimePicker.Value; string timestamp = value.Date.ToShortDateString() + ":" + value.TimeOfDay.ToString(); foreach (P4.FileSpec file in _files) { file.Version = new P4.DateTimeVersion(value); files.Add(file); } _scm.SyncFiles(options, _files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } // @changelist if (specifierCB.SelectedIndex == 1) { if (changelistFilesChk.Checked == true) { foreach (P4.FileSpec file in _files) { file.Version = new P4.VersionRange(new P4.ChangelistIdVersion(Convert.ToInt16(Value)), new P4.ChangelistIdVersion(Convert.ToInt32(Value))); files.Add(file); } } else { foreach (P4.FileSpec file in _files) { file.Version = new P4.ChangelistIdVersion(Convert.ToInt32(Value)); files.Add(file); } } _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } // @label if (specifierCB.SelectedIndex == 3) { if (removeChk.Checked == true) { foreach (P4.FileSpec file in _files) { file.Version = new P4.LabelNameVersion(Value.ToString()); files.Add(file); } } else { foreach (P4.FileSpec file in _files) { file.Version = new P4.VersionRange(new P4.LabelNameVersion(Value.ToString()), new P4.LabelNameVersion(Value.ToString())); files.Add(file); } } _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } } else if (getLatestRB.Checked == true) { files = _files; _scm.SyncFiles(options, files); if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null) { IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList(); foreach (P4.P4ClientError error in errors) { if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED | error.SeverityLevel == P4.ErrorSeverity.E_FATAL) { P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false); return; } } this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.OK; } } } finally { if (updateSolution) { if (path != null) { solution.OpenSolutionFile(0, path); } if (_scm.SccService != null) { _scm.SccService.ResetSelection(); } } #if !VS2008 else if (projectsUpdating.Count > 0) { foreach (Guid projGuid in projectsGuidsClosed) { Guid rProjGuid = projGuid; var vsSolution4 = (IVsSolution4)solution; if (vsSolution4 != null) { int res = vsSolution4.ReloadProject(ref rProjGuid); } } } #endif // now refresh the selected nodes' glyphs if (_scm.SccService != null) { _scm.SccService.UpdateProjectGlyphs(refreshItems, true); } } }