Java Code Examples for com.intellij.ide.BrowserUtil#browse()
The following examples show how to use
com.intellij.ide.BrowserUtil#browse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenCommitInBrowserAction.java From azure-devops-intellij with MIT License | 6 votes |
@Override public void actionPerformed(@NotNull final AnActionEvent anActionEvent) { final Project project = anActionEvent.getRequiredData(CommonDataKeys.PROJECT); final VcsFullCommitDetails commit = anActionEvent.getRequiredData(VcsLogDataKeys.VCS_LOG).getSelectedDetails().get(0); final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForRootQuick(commit.getRoot()); if (gitRepository == null) return; final GitRemote remote = TfGitHelper.getTfGitRemote(gitRepository); // guard for null so findbugs doesn't complain if (remote == null) { return; } final String remoteUrl = remote.getFirstUrl(); if (remoteUrl == null) { return; } final URI urlToBrowseTo = UrlHelper.getCommitURI(remoteUrl, commit.getId().toString()); logger.info("Browsing to url " + urlToBrowseTo.getPath()); BrowserUtil.browse(urlToBrowseTo); }
Example 2
Source File: SearchAction.java From tutorials with MIT License | 6 votes |
@Override public void actionPerformed(@NotNull AnActionEvent e) { Optional<PsiFile> psiFile = Optional.ofNullable(e.getData(LangDataKeys.PSI_FILE)); String languageTag = psiFile .map(PsiFile::getLanguage) .map(Language::getDisplayName) .map(String::toLowerCase) .map(lang -> "[" + lang + "]") .orElse(""); Editor editor = e.getRequiredData(CommonDataKeys.EDITOR); CaretModel caretModel = editor.getCaretModel(); String selectedText = caretModel.getCurrentCaret().getSelectedText(); BrowserUtil.browse("https://stackoverflow.com/search?q=" + languageTag + selectedText); }
Example 3
Source File: AnnotateActionTest.java From azure-devops-intellij with MIT License | 6 votes |
@Test public void testExecute_Success() { ArgumentCaptor<URI> argCapture = ArgumentCaptor.forClass(URI.class); when(mockTeamProjectReference.getName()).thenReturn("TeamName"); when(mockItemInfo.getServerItem()).thenReturn("$/path/to/file.txt"); when(mockServerContext.getTeamProjectReference()).thenReturn(mockTeamProjectReference); when(mockActionContext.getServerContext()).thenReturn(mockServerContext); when(mockActionContext.getItem()).thenReturn(mockItemInfo); annotateAction.execute(mockActionContext); verifyStatic(times(0)); Messages.showErrorDialog(any(Project.class), anyString(), anyString()); verifyStatic(times(1)); BrowserUtil.browse(argCapture.capture()); assertEquals(serverURI.toString() + "TeamName/_versionControl/?path=%24%2Fpath%2Fto%2Ffile.txt&_a=contents&annotate=true&hideComments=true", argCapture.getValue().toString()); }
Example 4
Source File: WindowsDefenderFixAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e, @Nonnull Notification notification) { int rc = Messages.showDialog(e.getProject(), DiagnosticBundle .message("virus.scanning.fix.explanation", ApplicationNamesInfo.getInstance().getFullProductName(), WindowsDefenderChecker.getInstance().getConfigurationInstructionsUrl()), DiagnosticBundle.message("virus.scanning.fix.title"), new String[]{DiagnosticBundle.message("virus.scanning.fix.automatically"), DiagnosticBundle.message("virus.scanning.fix.manually"), CommonBundle.getCancelButtonText()}, 0, null); switch (rc) { case Messages.OK: notification.expire(); ApplicationManager.getApplication().executeOnPooledThread(() -> { if (WindowsDefenderChecker.getInstance().runExcludePathsCommand(e.getProject(), myPaths)) { UIUtil.invokeLaterIfNeeded(() -> { Notifications.Bus.notifyAndHide(new Notification("System Health", "", DiagnosticBundle.message("virus.scanning.fix.success.notification"), NotificationType.INFORMATION), e.getProject()); }); } }); break; case Messages.CANCEL: BrowserUtil.browse(WindowsDefenderChecker.getInstance().getConfigurationInstructionsUrl()); break; } }
Example 5
Source File: IdeaHelpContentViewUI.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void linkActivated(URL u) { String url = u.toExternalForm(); if (url.startsWith("http") || url.startsWith("ftp")) { BrowserUtil.browse(url); } else { super.linkActivated(u); } }
Example 6
Source File: VcsPullRequestsModel.java From azure-devops-intellij with MIT License | 5 votes |
public void openSelectedItemsLink() { if (isTfGitRepository()) { final ServerContext context = TfGitHelper.getSavedServerContext(gitRepository); final GitPullRequest pullRequest = getSelectedPullRequest(); if (context != null && pullRequest != null) { BrowserUtil.browse(getPullRequestWebLink(context.getGitRepository().getRemoteUrl(), pullRequest.getPullRequestId())); } } }
Example 7
Source File: SearchWebAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { DataContext dataContext = e.getDataContext(); CopyProvider provider = dataContext.getData(PlatformDataKeys.COPY_PROVIDER); if (provider == null) { return; } provider.performCopy(dataContext); String content = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor); if (StringUtil.isNotEmpty(content)) { WebSearchEngine engine = myWebSearchOptions.getEngine(); BrowserUtil.browse(BundleBase.format(engine.getUrlTemplate(), URLUtil.encodeURIComponent(content))); } }
Example 8
Source File: IdeaUtils.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
public static boolean browseURI(final URI uri, final boolean useInternalBrowser) { try { BrowserUtil.browse(uri); } catch (Exception ex) { ex.printStackTrace(); return false; } return true; }
Example 9
Source File: AnnotateActionTest.java From azure-devops-intellij with MIT License | 5 votes |
@Test public void testExecute_NullItem() { when(mockServerContext.getTeamProjectReference()).thenReturn(mockTeamProjectReference); when(mockActionContext.getServerContext()).thenReturn(mockServerContext); when(mockActionContext.getItem()).thenReturn(null); annotateAction.execute(mockActionContext); verifyStatic(times(1)); Messages.showErrorDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_ANNOTATE_ERROR_MSG), TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_ANNOTATE_ERROR_TITLE)); verifyStatic(times(0)); BrowserUtil.browse(any(URI.class)); }
Example 10
Source File: QuarkusCodeEndpointChooserStep.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
QuarkusCodeEndpointChooserStep(WizardContext wizardContext) { this.customUrlWithBrowseButton = new ComponentWithBrowseButton(this.endpointURL, new ActionListener() { public void actionPerformed(ActionEvent e) { try { QuarkusCodeEndpointChooserStep.this.validate(); BrowserUtil.browse(QuarkusCodeEndpointChooserStep.this.endpointURL.getText()); } catch (ConfigurationException var3) { Messages.showErrorDialog(var3.getMessage(), "Cannot Open URL"); } } }); this.wizardContext = wizardContext; String lastServiceUrl = PropertiesComponent.getInstance().getValue(LAST_ENDPOINT_URL, QUARKUS_CODE_URL); if (!lastServiceUrl.equals(QUARKUS_CODE_URL)) { this.endpointURL.setSelectedItem(lastServiceUrl); this.defaultRadioButton.setSelected(false); this.customRadioButton.setSelected(true); } else { this.defaultRadioButton.setSelected(true); } List<String> history = this.endpointURL.getHistory(); history.remove(QUARKUS_CODE_URL); this.endpointURL.setHistory(history); this.updateCustomUrl(); }
Example 11
Source File: FlutterSampleActionsPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void browseTo(FlutterSample sample) { BrowserUtil.browse(sample.getHostedDocsUrl()); }
Example 12
Source File: InstallSdkAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override void perform() { FlutterInitializer.sendAnalyticsAction(ANALYTICS_KEY); BrowserUtil.browse(FlutterConstants.URL_GETTING_STARTED); }
Example 13
Source File: InstallSdkAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override void perform() { FlutterInitializer.sendAnalyticsAction(ANALYTICS_KEY); BrowserUtil.browse(FlutterConstants.URL_GETTING_STARTED); }
Example 14
Source File: BrowserHyperlinkListener.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void hyperlinkActivated(HyperlinkEvent e) { BrowserUtil.browse(e.getDescription()); }
Example 15
Source File: AskQuestionAction.java From tutorials with MIT License | 4 votes |
@Override public void actionPerformed(AnActionEvent e) { BrowserUtil.browse("https://stackoverflow.com/questions/ask"); }
Example 16
Source File: OpenYoutubeAction.java From consulo with Apache License 2.0 | 4 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { BrowserUtil.browse("http://www.youtube.com/user/ConsuloIDE"); }
Example 17
Source File: SelectPackageTemplateDialog.java From PackageTemplates with Apache License 2.0 | 4 votes |
@Override protected void doHelpAction() { BrowserUtil.browse(Const.TUTORIALS_URL); }
Example 18
Source File: ExportToHTMLManager.java From consulo with Apache License 2.0 | 4 votes |
/** * Should be invoked in event dispatch thread */ @RequiredUIAccess public static void executeExport(final DataContext dataContext) throws FileNotFoundException { PsiDirectory psiDirectory = null; PsiElement psiElement = dataContext.getData(LangDataKeys.PSI_ELEMENT); if(psiElement instanceof PsiDirectory) { psiDirectory = (PsiDirectory)psiElement; } final PsiFile psiFile = dataContext.getData(LangDataKeys.PSI_FILE); Project project = dataContext.getData(CommonDataKeys.PROJECT); String shortFileName = null; String directoryName = null; if(psiFile != null || psiDirectory != null) { if(psiFile != null) { shortFileName = psiFile.getVirtualFile().getName(); if(psiDirectory == null) { psiDirectory = psiFile.getContainingDirectory(); } } if(psiDirectory != null) { directoryName = psiDirectory.getVirtualFile().getPresentableUrl(); } } Editor editor = dataContext.getData(PlatformDataKeys.EDITOR); boolean isSelectedTextEnabled = false; if(editor != null && editor.getSelectionModel().hasSelection()) { isSelectedTextEnabled = true; } ExportToHTMLDialog exportToHTMLDialog = new ExportToHTMLDialog(shortFileName, directoryName, isSelectedTextEnabled, project); ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(project); if(exportToHTMLSettings.OUTPUT_DIRECTORY == null) { final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null) { exportToHTMLSettings.OUTPUT_DIRECTORY = baseDir.getPresentableUrl() + File.separator + "exportToHTML"; } else { exportToHTMLSettings.OUTPUT_DIRECTORY = ""; } } exportToHTMLDialog.reset(); exportToHTMLDialog.show(); if(!exportToHTMLDialog.isOK()) { return; } try { exportToHTMLDialog.apply(); } catch (ConfigurationException e) { Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle()); } PsiDocumentManager.getInstance(project).commitAllDocuments(); final String outputDirectoryName = exportToHTMLSettings.OUTPUT_DIRECTORY; if(exportToHTMLSettings.getPrintScope() != PrintSettings.PRINT_DIRECTORY) { if(psiFile == null || psiFile.getText() == null) { return; } final String dirName = constructOutputDirectory(psiFile, outputDirectoryName); HTMLTextPainter textPainter = new HTMLTextPainter(psiFile, project, dirName, exportToHTMLSettings.PRINT_LINE_NUMBERS); if(exportToHTMLSettings.getPrintScope() == PrintSettings.PRINT_SELECTED_TEXT && editor != null && editor.getSelectionModel().hasSelection()) { int firstLine = editor.getDocument().getLineNumber(editor.getSelectionModel().getSelectionStart()); textPainter.setSegment(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), firstLine); } textPainter.paint(null, psiFile.getFileType()); if (exportToHTMLSettings.OPEN_IN_BROWSER) { BrowserUtil.browse(textPainter.getHTMLFileName()); } } else { myLastException = null; ExportRunnable exportRunnable = new ExportRunnable(exportToHTMLSettings, psiDirectory, outputDirectoryName, project); ProgressManager.getInstance().runProcessWithProgressSynchronously(exportRunnable, CodeEditorBundle.message("export.to.html.title"), true, project); if (myLastException != null) { throw myLastException; } } }
Example 19
Source File: OpenInWebAction.java From leetcode-editor with Apache License 2.0 | 4 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent, Config config, Question question) { BrowserUtil.browse(URLUtils.getLeetcodeProblems() + question.getTitleSlug()); }
Example 20
Source File: DevelopPluginsAction.java From consulo with Apache License 2.0 | 4 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull final AnActionEvent e) { BrowserUtil.browse(PLUGIN_WEBSITE); }