com.intellij.ui.BrowserHyperlinkListener Java Examples

The following examples show how to use com.intellij.ui.BrowserHyperlinkListener. 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: MultiSelectDialog.java    From AndroidStringsOneTabTranslation with Apache License 2.0 5 votes vote down vote up
@NotNull
public static JTextPane configureMessagePaneUi(JTextPane messageComponent,
                                               String message,
                                               final boolean addBrowserHyperlinkListener) {
    messageComponent.setFont(UIUtil.getLabelFont());
    if (BasicHTML.isHTMLString(message)) {
        final HTMLEditorKit editorKit = new HTMLEditorKit();
        editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(UIUtil.getLabelFont(), UIUtil.getLabelForeground()));
        messageComponent.setEditorKit(editorKit);
        messageComponent.setContentType(UIUtil.HTML_MIME);
        if (addBrowserHyperlinkListener) {
            messageComponent.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
        }
    }
    messageComponent.setText(message);
    messageComponent.setEditable(false);
    if (messageComponent.getCaret() != null) {
        messageComponent.setCaretPosition(0);
    }

    if (UIUtil.isUnderNimbusLookAndFeel()) {
        messageComponent.setOpaque(false);
        messageComponent.setBackground(UIUtil.TRANSPARENT_COLOR);
    } else {
        messageComponent.setBackground(UIUtil.getOptionPaneBackground());
    }

    messageComponent.setForeground(UIUtil.getLabelForeground());
    return messageComponent;
}
 
Example #2
Source File: ChangeListViewerDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initCommitMessageArea(final Project project, final CommittedChangeList changeList) {
  myCommitMessageArea = new JEditorPane(UIUtil.HTML_MIME, "");
  myCommitMessageArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
  myCommitMessageArea.setEditable(false);
  @NonNls final String text = IssueLinkHtmlRenderer.formatTextIntoHtml(project, changeList.getComment().trim());
  myCommitMessageArea.setBackground(UIUtil.getComboBoxDisabledBackground());
  myCommitMessageArea.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  commitMessageScroll = ScrollPaneFactory.createScrollPane(myCommitMessageArea);
  myCommitMessageArea.setText(text);
  myCommitMessageArea.setCaretPosition(0);
}
 
Example #3
Source File: DesktopAlertImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public JTextPane configureMessagePaneUi(JTextPane messageComponent, String message) {
  JTextPane pane = configureMessagePaneUi(messageComponent, message, null);
  if (UIUtil.HTML_MIME.equals(pane.getContentType())) {
    pane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  }
  return pane;
}
 
Example #4
Source File: WithBrowserHyperlinkExecutionException.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public final void hyperlinkUpdate(HyperlinkEvent e) {
  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    BrowserHyperlinkListener.INSTANCE.hyperlinkUpdate(e);
  }
}
 
Example #5
Source File: ChangeListDetailsAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void showDetailsPopup(final Project project, final CommittedChangeList changeList) {
  StringBuilder detailsBuilder = new StringBuilder("<html><head>");
  detailsBuilder.append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())).append("</head><body>");
  final AbstractVcs vcs = changeList.getVcs();
  CachingCommittedChangesProvider provider = null;
  if (vcs != null) {
    provider = vcs.getCachingCommittedChangesProvider();
    if (provider != null && provider.getChangelistTitle() != null) {
      detailsBuilder.append(provider.getChangelistTitle()).append(" #").append(changeList.getNumber()).append("<br>");
    }
  }
  @NonNls String committer = "<b>" + changeList.getCommitterName() + "</b>";
  detailsBuilder.append(VcsBundle.message("changelist.details.committed.format", committer,
                                          DateFormatUtil.formatPrettyDateTime(changeList.getCommitDate())));
  detailsBuilder.append("<br>");

  if (provider != null) {
    final CommittedChangeList originalChangeList;
    if (changeList instanceof ReceivedChangeList) {
      originalChangeList = ((ReceivedChangeList) changeList).getBaseList();
    }
    else {
      originalChangeList = changeList;
    }
    for(ChangeListColumn column: provider.getColumns()) {
      if (ChangeListColumn.isCustom(column)) {
        String value = column.getValue(originalChangeList).toString();
        if (value.length() == 0) {
          value = "<none>";
        }
        detailsBuilder.append(column.getTitle()).append(": ").append(XmlStringUtil.escapeString(value)).append("<br>");
      }
    }
  }

  detailsBuilder.append(IssueLinkHtmlRenderer.formatTextWithLinks(project, changeList.getComment()));
  detailsBuilder.append("</body></html>");

  JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, detailsBuilder.toString());
  editorPane.setEditable(false);
  editorPane.setBackground(HintUtil.INFORMATION_COLOR);
  editorPane.select(0, 0);
  editorPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(editorPane);
  final JBPopup hint =
    JBPopupFactory.getInstance().createComponentPopupBuilder(scrollPane, editorPane)
      .setDimensionServiceKey(project, "changelist.details.popup", false)
      .setResizable(true)
      .setMovable(true)
      .setRequestFocus(true)
      .setTitle(VcsBundle.message("changelist.details.title"))
      .createPopup();
  hint.showInBestPositionFor(DataManager.getInstance().getDataContext());
}
 
Example #6
Source File: HtmlPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
  BrowserHyperlinkListener.INSTANCE.hyperlinkUpdate(e);
}