private void ExecuteCommand(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { if (command.CommandID.ID == PackageCommanddIDs.CreateSnippet) { } else { using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { return; } var selectionLineRange = GetSelectionLineRange(); var type = ToGiteaUrlType(command.CommandID.ID); var GiteaUrl = git.BuildGiteaUrl(type, selectionLineRange); System.Diagnostics.Process.Start(GiteaUrl); // open browser } } } catch (Exception ex) { Debug.Write(ex.ToString()); } }
internal DeployToOpenShiftModel() { ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => { return(true); }; Masters = OpenShiftMastersModel.Instance.Masters; SelectedMaster = new ReactiveProperty <OpenShiftMasterModel>(Masters.FirstOrDefault()); Projects = SelectedMaster .Where(m => !string.IsNullOrWhiteSpace(m.MasterUrl.Value) && !string.IsNullOrWhiteSpace(m.Token.Value)) .Select(m => { //TODO あとでasync var client = new OpenShiftAPIwithKubernetes(new Uri(m.MasterUrl.Value), new TokenCredentials(m.Token.Value)); var projects = client.ListProject(); return(projects.Items.Select(p => p.Metadata.Name).ToList()); }) .SelectMany(x => x) // .SelectMany(t => t.Result) .ToReadOnlyReactiveCollection(); SelectedProject = new ReactiveProperty <string>(); Name = new ReactivePropertySlim <string>("vssdk-test"); string branch = ""; string gitUrl = "https://github.com/redhat-developer/s2i-dotnetcore-ex.git"; string startupProject = "app"; try { //DTE.ActiveSolutionProjects?.Cast<Project>().FirstOrDefault()?.FullName var project = DTE.SelectedItems.Item(1).Project; startupProject = project.Name; var git = new GitAnalysis(project.FullName); if (git.IsDiscoveredGitRepository) { branch = git.BranchName; gitUrl = git.RemoteURL; } } catch (Exception ex) { //Debug.Write(ex.ToString()); } MemoryLimit = new ReactivePropertySlim <string>("512Mi"); GitSource = new ReactivePropertySlim <string>(gitUrl); GitRef = new ReactivePropertySlim <string>(branch); //デフォルト値はNameから自動生成 Host = new ReactivePropertySlim <string>("vssdk-test.52.175.232.56.xip.io"); StartupProject = new ReactivePropertySlim <string>(startupProject); }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; Debug.WriteLine($"MenuItem_BeforeQueryStatus {command.Text} {command.CommandID.ID} "); try { switch ((uint)command.CommandID.ID) { case PackageIds.OpenCreateSnippet: command.Text = Strings.OpenOnGitLabPackage_CreateSnippet; var selectionLineRange = GetSelectionLineRange(); command.Enabled = selectionLineRange.Item1 < selectionLineRange.Item2; break; case PackageIds.IssuesToolWindowCommandId: command.Enabled = true; break; case PackageIds.OpenFromUrl: command.Enabled = Clipboard.ContainsText(TextDataFormat.Text) && Regex.IsMatch(Clipboard.GetText(TextDataFormat.Text), "[a-zA-z]+://[^\\s]*"); command.Text = Strings.OpenFormURL; break; default: // TODO:is should avoid create GitAnalysis every call? var git = GitAnalysis.GetBy(GetActiveFilePath()); if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGitLabUrlType(command.CommandID.ID); var targetPath = git.GetGitLabTargetPath(type); if (type == GitLabUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGitLabTargetDescription(type); command.Enabled = true; } break; } } catch (Exception ex) { var exstr = ex.ToString(); OutputWindowHelper.ExceptionWriteLine(exstr, ex); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; } }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; Debug.WriteLine($"MenuItem_BeforeQueryStatus {command.Text} {command.CommandID.ID} "); try { switch ((uint)command.CommandID.ID) { case PackageCommanddIDs.CreateSnippet: command.Text = Strings.OpenOnGitLabPackage_CreateSnippet; var selectionLineRange = GetSelectionLineRange(); command.Enabled = selectionLineRange.Item1 < selectionLineRange.Item2; break; case PackageCommanddIDs.IssuesToolWindows: command.Enabled = true; break; default: // TODO:is should avoid create GitAnalysis every call? using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGitLabUrlType(command.CommandID.ID); var targetPath = git.GetGitLabTargetPath(type); if (type == GitLabUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGitLabTargetDescription(type); command.Enabled = true; } } break; } } catch (Exception ex) { var exstr = ex.ToString(); Debug.Write(exstr); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; } }
private void ExecuteCommand(object sender, EventArgs e) { var command = (OleMenuCommand)sender; Debug.WriteLine($"ExecuteCommand {command.Text} {command.CommandID.ID} "); try { switch ((uint)command.CommandID.ID) { case PackageCommanddIDs.CreateSnippet: var selection = DTE.ActiveDocument.Selection as TextSelection; if (selection != null) { var dialog = _viewFactory.GetView <Dialog>(ViewTypes.CreateSnippet); var cs = (CreateSnippet)dialog; var csm = cs.DataContext as CreateSnippetViewModel; csm.Code = selection.Text; csm.FileName = new System.IO.FileInfo(DTE.ActiveDocument.FullName).Name; _shell.ShowDialog(Strings.OpenOnGitLabPackage_CreateSnippet, dialog); } else { Debug.Write("未选择任何内容"); } break; default: using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { return; } var selectionLineRange = GetSelectionLineRange(); var type = ToGitLabUrlType(command.CommandID.ID); var GitLabUrl = git.BuildGitLabUrl(type, selectionLineRange); System.Diagnostics.Process.Start(GitLabUrl); // open browser } break; } } catch (Exception ex) { Debug.Write(ex.ToString()); } }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { if (command.CommandID.ID == PackageCommanddIDs.CreateSnippet) { command.Text = Strings.OpenOnGiteaPackage_CreateSnippet; var selectionLineRange = GetSelectionLineRange(); command.Enabled = selectionLineRange.Item1 < selectionLineRange.Item2; } else { // TODO:is should avoid create GitAnalysis every call? using (var git = GitAnalysis.GetBy(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGiteaUrlType(command.CommandID.ID); var targetPath = git.GetGiteaTargetPath(type); if (type == GiteaUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGiteaTargetDescription(type); command.Enabled = true; } } } } catch (Exception ex) { var exstr = ex.ToString(); Debug.Write(exstr); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; } }
public void TryOpenFile(string url) { Uri uri = new Uri(url); using (var git = new GitAnalysis(GetActiveFilePath())) { if (git.IsDiscoveredGitRepository) { var blob = Regex.Match(url, "/blob/(?<treeish>[^/]*)/"); if (blob.Success) { string p1 = uri.GetComponents(UriComponents.Path, UriFormat.UriEscaped).ToString(); string p2 = p1.Substring(p1.IndexOf(blob.Value) + blob.Value.Length); var path = System.IO.Path.Combine(System.IO.Path.GetFullPath(System.IO.Path.Combine(git.RepositoryPath, "../")), p2); var textView = OpenDocument(path); } } } }
private void ExecuteCommand(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { switch ((uint)command.CommandID.ID) { case PackageIds.OpenFromUrl: if (Clipboard.ContainsText(TextDataFormat.Text)) { var match = Regex.Match(Clipboard.GetText(TextDataFormat.Text), "[a-zA-z]+://[^\\s]*"); if (match.Success) { try { TryOpenFile(match.Value); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(string.Format("Can't Open {0},Exception:{1}", match.Value, ex.Message), ex); } } } break; case PackageIds.OpenBlame: case PackageIds.OpenBranch: case PackageIds.OpenCommits: case PackageIds.OpenMaster: case PackageIds.OpenRevision: case PackageIds.OpenRevisionFull: { try { using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { return; } var selectionLineRange = GetSelectionLineRange(); var type = ToGiteaUrlType(command.CommandID.ID); var GiteaUrl = git.BuildGiteaUrl(type, selectionLineRange); System.Diagnostics.Process.Start(GiteaUrl); // open browser } } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(string.Format("ExecuteCommand {0}", command.CommandID.ID, ex.Message), ex); } } break; default: break; } } catch (Exception ex) { Debug.Write(ex.ToString()); } }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { switch ((uint)command.CommandID.ID) { case PackageIds.OpenFromUrl: try { var match = Regex.Match(Clipboard.GetText(TextDataFormat.Text), "[a-zA-z]+://[^\\s]*"); command.Enabled = match.Success; if (command.Enabled) { Uri uri = new Uri(match.Value); command.Text = string.Format(Strings.OpenFrom0, uri.Host); } else { command.Text = Strings.OpenFromURL; } } catch (Exception ex) { OutputWindowHelper.WarningWriteLine($"QueryStatus:{command.CommandID.ID},{ex.Message}"); } break; case PackageIds.OpenBlame: case PackageIds.OpenBranch: case PackageIds.OpenCommits: case PackageIds.OpenMaster: case PackageIds.OpenRevision: case PackageIds.OpenRevisionFull: { try { var git = GitAnalysis.GetBy(GetActiveFilePath()); if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGiteaUrlType(command.CommandID.ID); var targetPath = git.GetGiteaTargetPath(type); if (type == GiteaUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGiteaTargetDescription(type); command.Enabled = true; } } catch (Exception ex) { OutputWindowHelper.WarningWriteLine($"QueryStatus:{command.CommandID.ID},{ex.Message}"); } } break; default: break; } } catch (Exception ex) { var exstr = ex.ToString(); Debug.Write(exstr); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; OutputWindowHelper.WarningWriteLine(ex.Message); } }
private void ExecuteCommand(object sender, EventArgs e) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); var command = (OleMenuCommand)sender; try { switch ((uint)command.CommandID.ID) { case PackageIds.OpenFromUrl: if (Clipboard.ContainsText(TextDataFormat.Text)) { var match = Regex.Match(Clipboard.GetText(TextDataFormat.Text), "[a-zA-z]+://[^\\s]*"); if (match.Success) { try { TryOpenFile(match.Value); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(string.Format("Can't Open {0},Exception:{1}", match.Value, ex.Message), ex); } } } break; case PackageIds.OpenBlame: case PackageIds.OpenBranch: case PackageIds.OpenCommits: case PackageIds.OpenMaster: case PackageIds.OpenRevision: case PackageIds.OpenRevisionFull: case PackageIds.OpenWebIDE: { try { using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { return; } var selectionLineRange = GetSelectionLineRange(); var type = ToGiteaUrlType(command.CommandID.ID); var GiteaUrl = git.BuildGiteaUrl(type, selectionLineRange); System.Diagnostics.Process.Start(GiteaUrl); // open browser } } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(string.Format("ExecuteCommand {0}", command.CommandID.ID, ex.Message), ex); } } break; case PackageIds.OpenCreateSnippet: var selection = DTE.ActiveDocument.Selection as TextSelection; if (selection != null) { var dialog = _viewFactory.GetView <Dialog>(ViewTypes.CreateSnippet); var cs = (CreateSnippet)dialog; var csm = cs.DataContext as CreateSnippetViewModel; csm.Code = selection.Text; csm.FileName = new FileInfo(DTE.ActiveDocument.FullName).Name; csm.Desc = csm.FileName; _shell.ShowDialog(Strings.CreateSnippet, dialog); } else { OutputWindowHelper.DiagnosticWriteLine(Strings.PleaseSelectCode); } break; default: break; } } catch (Exception ex) { Debug.Write(ex.ToString()); } }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { switch ((uint)command.CommandID.ID) { case PackageIds.OpenFromUrl: try { command.Enabled = false; var match = Regex.Match(Clipboard.GetText(TextDataFormat.Text), "[a-zA-z]+://[^\\s]*"); if (match.Success) { Uri uri = new Uri(match.Value); if (uri.Host.ToLower() == "gitee.com") { command.Enabled = true; } } } catch (Exception ex) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); OutputWindowHelper.WarningWriteLine($"QueryStatus:{command.CommandID.ID},{ex.Message}"); } break; case PackageIds.OpenBlame: case PackageIds.OpenBranch: case PackageIds.OpenCommits: case PackageIds.OpenMaster: case PackageIds.OpenRevision: case PackageIds.OpenRevisionFull: case PackageIds.OpenWebIDE: { try { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); var git = GitAnalysis.GetBy(GetActiveFilePath()); if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGiteaUrlType(command.CommandID.ID); var targetPath = git.GetGiteaTargetPath(type); if (type == GiteeUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGiteaTargetDescription(type); command.Enabled = true; } } catch (Exception ex) { OutputWindowHelper.WarningWriteLine($"QueryStatus:{command.CommandID.ID},{ex.Message}"); } } break; case PackageIds.OpenCreateSnippet: var selectionLineRange = GetSelectionLineRange(); command.Enabled = selectionLineRange != null && selectionLineRange.Item1 < selectionLineRange.Item2; break; default: break; } } catch (Exception ex) { var exstr = ex.ToString(); Debug.Write(exstr); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; OutputWindowHelper.WarningWriteLine(ex.Message); } }
private void ExecuteCommand(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { switch ((uint)command.CommandID.ID) { case PackageIds.OpenCreateSnippet: var selection = DTE.ActiveDocument.Selection as TextSelection; if (selection != null) { var dialog = _viewFactory.GetView <Dialog>(ViewTypes.CreateSnippet); var cs = (CreateSnippet)dialog; var csm = cs.DataContext as CreateSnippetViewModel; csm.Code = selection.Text; csm.FileName = new System.IO.FileInfo(DTE.ActiveDocument.FullName).Name; _shell.ShowDialog(Strings.OpenOnGitLabPackage_CreateSnippet, dialog); } else { OutputWindowHelper.DiagnosticWriteLine(GitLab.VisualStudio.Shared.Strings.PleaseCodes); } break; case PackageIds.OpenFromUrl: if (Clipboard.ContainsText(TextDataFormat.Text)) { var match = Regex.Match(Clipboard.GetText(TextDataFormat.Text), "[a-zA-z]+://[^\\s]*"); if (match.Success) { try { TryOpenFile(match.Value); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine(string.Format(GitLab.VisualStudio.Shared.Strings.Canotopenurl, match.Value, ex.Message), ex); } } } break; default: using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { return; } var selectionLineRange = GetSelectionLineRange(); var type = ToGitLabUrlType(command.CommandID.ID); var GitLabUrl = git.BuildGitLabUrl(type, selectionLineRange); System.Diagnostics.Process.Start(GitLabUrl); // open browser } break; } } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine($"Command:{command.Text},Message:{ex.Message}", ex); } }