本文整理汇总了Java中com.intellij.ide.BrowserUtil类的典型用法代码示例。如果您正苦于以下问题:Java BrowserUtil类的具体用法?Java BrowserUtil怎么用?Java BrowserUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrowserUtil类属于com.intellij.ide包,在下文中一共展示了BrowserUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertReference
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Override
protected String convertReference(String root, String href) {
if (BrowserUtil.isAbsoluteURL(href)) {
return href;
}
String reference = JavaDocInfoGenerator.createReferenceForRelativeLink(href, myElement);
if (reference == null) {
if (href.startsWith("#")) {
return root + href;
}
else {
String nakedRoot = ourHTMLFilesuffix.matcher(root).replaceAll("/");
return doAnnihilate(nakedRoot + href);
}
}
else {
return reference;
}
}
示例2: addArgs
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
private static void addArgs(@NotNull GeneralCommandLine command, @Nullable BrowserSpecificSettings settings, @NotNull String[] additional) {
List<String> specific = settings == null ? Collections.<String>emptyList() : settings.getAdditionalParameters();
if (specific.size() + additional.length > 0) {
if (isOpenCommandUsed(command)) {
if (BrowserUtil.isOpenCommandSupportArgs()) {
command.addParameter("--args");
}
else {
LOG.warn("'open' command doesn't allow to pass command line arguments so they will be ignored: " +
StringUtil.join(specific, ", ") + " " + Arrays.toString(additional));
return;
}
}
command.addParameters(specific);
command.addParameters(additional);
}
}
示例3: addBackAndOpenButtons
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
public void addBackAndOpenButtons() {
ApplicationManager.getApplication().invokeLater(() -> {
final JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
final JButton backButton = makeGoButton("Click to go back", AllIcons.Actions.Back, -1);
final JButton forwardButton = makeGoButton("Click to go forward", AllIcons.Actions.Forward, 1);
final JButton openInBrowser = new JButton(AllIcons.Actions.Browser_externalJavaDoc);
openInBrowser.addActionListener(e -> BrowserUtil.browse(myEngine.getLocation()));
openInBrowser.setToolTipText("Click to open link in browser");
addButtonsAvailabilityListeners(backButton, forwardButton);
panel.setMaximumSize(new Dimension(40, getPanel().getHeight()));
panel.add(backButton);
panel.add(forwardButton);
panel.add(openInBrowser);
add(panel, BorderLayout.PAGE_START);
});
}
示例4: getReaderByUrl
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Nullable
public static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi) throws IOException {
if (surl.startsWith(JAR_PROTOCOL)) {
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));
if (file == null) {
return null;
}
return new StringReader(VfsUtil.loadText(file));
}
URL url = BrowserUtil.getURL(surl);
if (url == null) {
return null;
}
httpConfigurable.prepareURL(url.toString());
final URLConnection urlConnection = url.openConnection();
final String contentEncoding = urlConnection.getContentEncoding();
final InputStream inputStream =
pi != null ? UrlConnectionUtil.getConnectionInputStreamWithException(urlConnection, pi) : urlConnection.getInputStream();
//noinspection IOResourceOpenedButNotSafelyClosed
return contentEncoding != null ? new InputStreamReader(inputStream, contentEncoding) : new InputStreamReader(inputStream);
}
示例5: startProcess
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler handler = JavaCommandLineStateUtil.startProcess(createCommandLine());
ProcessTerminatedListener.attach(handler, myProject, JavadocBundle.message("javadoc.generate.exited"));
handler.addProcessListener(new ProcessAdapter() {
public void processTerminated(ProcessEvent event) {
if (myConfiguration.OPEN_IN_BROWSER) {
File url = new File(myConfiguration.OUTPUT_DIRECTORY, INDEX_HTML);
if (url.exists() && event.getExitCode() == 0) {
BrowserUtil.browse(url);
}
}
}
});
return handler;
}
示例6: notifyUser
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
public static void notifyUser(String message) {
final String logFile = PathManager.getLogPath();
/*String createIssuePart = "<br>" +
"<br>" +
"Please attach log files from <a href=\"file\">" + logFile + "</a><br>" +
"to the <a href=\"url\">YouTrack issue</a>";*/
Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
"Local History is broken",
message /*+ createIssuePart*/,
NotificationType.ERROR,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification,
@NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if ("url".equals(event.getDescription())) {
BrowserUtil.browse("http://youtrack.jetbrains.net/issue/IDEA-71270");
}
else {
File file = new File(logFile);
ShowFilePathAction.openFile(file);
}
}
}
}), null);
}
示例7: createTipBrowser
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@NotNull
public static JEditorPane createTipBrowser() {
JEditorPane browser = new JEditorPane();
browser.setEditable(false);
browser.setBackground(UIUtil.getTextFieldBackground());
browser.addHyperlinkListener(
new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
BrowserUtil.browse(e.getURL());
}
}
}
);
URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css");
final StyleSheet styleSheet = UIUtil.loadStyleSheet(resource);
HTMLEditorKit kit = new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return styleSheet != null ? styleSheet : super.getStyleSheet();
}
};
browser.setEditorKit(kit);
return browser;
}
示例8: hyperlinkUpdate
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
JEditorPane pane = (JEditorPane)e.getSource();
if (e instanceof HTMLFrameHyperlinkEvent) {
HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
HTMLDocument doc = (HTMLDocument)pane.getDocument();
doc.processHTMLFrameHyperlinkEvent(evt);
}
else {
URL url = e.getURL();
if (url != null) {
BrowserUtil.browse(url);
}
}
}
}
示例9: VcsCommitInfoBalloon
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
public VcsCommitInfoBalloon(@NotNull JTree tree) {
myTree = tree;
myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "");
myEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
myEditorPane.setEditable(false);
myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
myEditorPane.setFont(UIUtil.getToolTipFont());
myEditorPane.setBorder(HintUtil.createHintBorder());
Border margin = IdeBorderFactory.createEmptyBorder(3, 3, 3, 3);
myEditorPane.setBorder(new CompoundBorder(myEditorPane.getBorder(), margin));
myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
BrowserUtil.browse(e.getURL());
}
});
myWrapper = new Wrapper(myEditorPane);
myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myWrapper, null);
myPopupBuilder.setCancelOnClickOutside(true).setResizable(true).setMovable(true).setRequestFocus(false)
.setMinSize(new Dimension(80, 30));
}
示例10: onClick
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Override
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
if (e.getButton() == 1 && !e.isPopupTrigger()) {
Object tag = getTagAt(e);
if (tag instanceof Runnable) {
((Runnable) tag).run();
return true;
}
if (tag != null && !Object.class.getName().equals(tag.getClass().getName())) {
BrowserUtil.browse(tag.toString());
return true;
}
}
return false;
}
示例11: getAfterTask
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Override
protected Runnable getAfterTask() {
return new Runnable() {
@Override
public void run() {
VirtualFile virtualFile = findOutput();
if (virtualFile != null) {
if (myConfiguration.openInBrowser()) {
BrowserUtil.browse(virtualFile);
}
else {
FileEditorManager.getInstance(myConfiguration.getProject()).openFile(virtualFile, true);
}
}
}
};
}
示例12: DisableAutoImportNotificationPanel
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
DisableAutoImportNotificationPanel(@NotNull final GradleProjectSettings settings) {
setText("Gradle 'auto-import' will considerably slow down the IDE, due to a known bug.");
createActionLabel("Open bug report", new Runnable() {
@Override
public void run() {
BrowserUtil.browse("https://code.google.com/p/android/issues/detail?id=59965");
}
});
createActionLabel("Disable 'auto-import'", new Runnable() {
@Override
public void run() {
settings.setUseAutoImport(false);
myNotifications.updateAllNotifications();
}
});
}
示例13: openInBrowser
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
protected static void openInBrowser(Project project, GitRepository repository, String revisionHash) {
String url = GithubUtil.findGithubRemoteUrl(repository);
if (url == null) {
GithubUtil.LOG.info(String.format("Repository is not under GitHub. Root: %s, Remotes: %s", repository.getRoot(),
GitUtil.getPrintableRemotes(repository.getRemotes())));
return;
}
GithubFullPath userAndRepository = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url);
if (userAndRepository == null) {
GithubNotifications
.showError(project, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER, "Cannot extract info about repository: " + url);
return;
}
String githubUrl = GithubUrlUtil.getGithubHost() + '/' + userAndRepository.getUser() + '/'
+ userAndRepository.getRepository() + "/commit/" + revisionHash;
BrowserUtil.browse(githubUrl);
}
示例14: execute
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Override
protected void execute(final @NotNull SingleItemActionContext actionContext) {
final ServerContext context = actionContext.getServerContext();
// check for null values (it's ok if the server item is null because the URL redirects to the general page in that case
if (context != null && context.getTeamProjectReference() != null && actionContext.getItem() != null) {
final URI urlToBrowseTo = UrlHelper.getTfvcAnnotateURI(context.getUri().toString(),
context.getTeamProjectReference().getName(), actionContext.getItem().getServerItem());
logger.info("Browsing to url " + urlToBrowseTo.getPath());
BrowserUtil.browse(urlToBrowseTo);
} else {
final String issue = context == null ? "context is null" : context.getTeamProjectReference() == null ? "team project is null" : "getItem is null";
logger.warn("Couldn't create annotate url: " + issue);
Messages.showErrorDialog(actionContext.getProject(), TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_ANNOTATE_ERROR_MSG),
TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_ANNOTATE_ERROR_TITLE));
}
}
示例15: doActionPerformed
import com.intellij.ide.BrowserUtil; //导入依赖的package包/类
@Override
public void doActionPerformed(@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).getRepositoryForRoot(commit.getRoot());
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);
}