Java Code Examples for com.intellij.util.ui.UIUtil#HTML_MIME

The following examples show how to use com.intellij.util.ui.UIUtil#HTML_MIME . 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: VcsCommitInfoBalloon.java    From consulo with Apache License 2.0 6 votes vote down vote up
public VcsCommitInfoBalloon(@Nonnull 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));
}
 
Example 2
Source File: Browser.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Browser(@Nonnull InspectionResultsView view) {
  super(new BorderLayout());
  myView = view;

  myCurrentEntity = null;
  myCurrentDescriptor = null;

  myHTMLViewer = new JEditorPane(UIUtil.HTML_MIME, InspectionsBundle.message("inspection.offline.view.empty.browser.text"));
  myHTMLViewer.setEditable(false);
  myHyperLinkListener = new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      Browser.this.hyperlinkUpdate(e);
    }
  };
  myHTMLViewer.addHyperlinkListener(myHyperLinkListener);

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(myHTMLViewer);
  pane.setBorder(null);
  add(pane, BorderLayout.CENTER);
  setupStyle();
}
 
Example 3
Source File: ConflictsDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new BorderLayout(0, 2));

  panel.add(new JLabel(RefactoringBundle.message("the.following.problems.were.found")), BorderLayout.NORTH);

  @NonNls StringBuilder buf = new StringBuilder();
  for (String description : myConflictDescriptions) {
    buf.append(description);
    buf.append("<br><br>");
  }
  JEditorPane messagePane = new JEditorPane(UIUtil.HTML_MIME, buf.toString());
  messagePane.setEditable(false);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(messagePane,
                                                              ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                                                              ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setPreferredSize(new Dimension(500, 400));
  panel.add(scrollPane, BorderLayout.CENTER);

  if (getOKAction().isEnabled()) {
    panel.add(new JLabel(RefactoringBundle.message("do.you.wish.to.ignore.them.and.continue")), BorderLayout.SOUTH);
  }

  return panel;
}
 
Example 4
Source File: UnsafeUsagesDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new BorderLayout());
  myMessagePane = new JEditorPane(UIUtil.HTML_MIME, "");
  myMessagePane.setEditable(false);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myMessagePane);
  scrollPane.setPreferredSize(new Dimension(500, 400));
  panel.add(new JLabel(RefactoringBundle.message("the.following.problems.were.found")), BorderLayout.NORTH);
  panel.add(scrollPane, BorderLayout.CENTER);

  @NonNls StringBuffer buf = new StringBuffer();
  for (String description : myConflictDescriptions) {
    buf.append(description);
    buf.append("<br><br>");
  }
  myMessagePane.setText(buf.toString());
  return panel;
}
 
Example 5
Source File: ShowBaseRevisionAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public NotificationPanel() {
  super(new BorderLayout());

  myLabel = new JEditorPane(UIUtil.HTML_MIME, "");
  myLabel.setEditable(false);
  myLabel.setFont(UIUtil.getToolTipFont());

  setBorder(BorderFactory.createEmptyBorder(1, 15, 1, 15));

  add(myLabel, BorderLayout.CENTER);
  myLabel.setBackground(getBackground());
}
 
Example 6
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 7
Source File: DependenciesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent e) {
  @NonNls final String delim = "&nbsp;-&gt;&nbsp;";
  final StringBuffer buf = new StringBuffer();
  processDependencies(getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() {
    @Override
    public boolean process(final List<PsiFile> path) {
      if (buf.length() > 0) buf.append("<br>");
      buf.append(StringUtil.join(path, new Function<PsiFile, String>() {
        @Override
        public String fun(final PsiFile psiFile) {
          return psiFile.getName();
        }
      }, delim));
      return true;
    }
  });
  final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, XmlStringUtil.wrapInHtml(buf));
  pane.setForeground(JBColor.foreground());
  pane.setBackground(HintUtil.INFORMATION_COLOR);
  pane.setOpaque(true);
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
  final Dimension dimension = pane.getPreferredSize();
  scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20));
  scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20));
  JBPopupFactory.getInstance().createComponentPopupBuilder(scrollPane, pane).setTitle("Dependencies")
    .setMovable(true).createPopup().showInBestPositionFor(e.getDataContext());
}
 
Example 8
Source File: ShowFeatureUsageStatisticsDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected JComponent createCenterPanel() {
  Splitter splitter = new Splitter(true);
  splitter.setShowDividerControls(true);

  ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
  ArrayList<FeatureDescriptor> features = new ArrayList<FeatureDescriptor>();
  for (String id : registry.getFeatureIds()) {
    features.add(registry.getFeatureDescriptor(id));
  }
  final TableView table = new TableView<FeatureDescriptor>(new ListTableModel<FeatureDescriptor>(COLUMNS, features, 0));
  new TableViewSpeedSearch<FeatureDescriptor>(table) {
    @Override
    protected String getItemText(@Nonnull FeatureDescriptor element) {
      return element.getDisplayName();
    }
  };

  JPanel controlsPanel = new JPanel(new VerticalFlowLayout());


  Application app = ApplicationManager.getApplication();
  long uptime = System.currentTimeMillis() - app.getStartTime();
  long idleTime = app.getIdleTime();

  final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime",
                                                         ApplicationNamesInfo.getInstance().getFullProductName(),
                                                         DateFormatUtil.formatDuration(uptime));

  final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time",
                                                           DateFormatUtil.formatDuration(idleTime));

  String labelText = uptimeS + ", " + idleTimeS;
  CompletionStatistics stats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getCompletionStatistics();
  if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
    String total = formatCharacterCount(stats.sparedCharacters, true);
    String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
    labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) +
                 " (~" + perDay + " per working day)";
  }

  CumulativeStatistics fstats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats();
  if (fstats.dayCount > 0 && fstats.invocations > 0) {
    labelText +=
      "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) +
      " (~" + fstats.invocations / fstats.dayCount + " per working day)";
  }

  controlsPanel.add(new JLabel("<html><body>" + labelText + "</body></html>"), BorderLayout.NORTH);

  JPanel topPanel = new JPanel(new BorderLayout());
  topPanel.add(controlsPanel, BorderLayout.NORTH);
  topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);

  splitter.setFirstComponent(topPanel);

  final JEditorPane browser = new JEditorPane(UIUtil.HTML_MIME, "");
  browser.setEditable(false);
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));

  table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      Collection selection = table.getSelection();
      try {
        if (selection.isEmpty()) {
          browser.read(new StringReader(""), null);
        }
        else {
          FeatureDescriptor feature = (FeatureDescriptor)selection.iterator().next();
          TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
        }
      }
      catch (IOException ex) {
        LOG.info(ex);
      }
    }
  });

  return splitter;
}
 
Example 9
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 10
Source File: SingleInspectionProfilePanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
private JPanel createInspectionProfileSettingsPanel() {

    myBrowser = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
    myBrowser.setEditable(false);
    myBrowser.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
    myBrowser.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);

    initToolStates();
    fillTreeData(myProfileFilter != null ? myProfileFilter.getFilter() : null, true);

    JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.setBorder(IdeBorderFactory.createTitledBorder(InspectionsBundle.message("inspection.description.title"), false,
                                                                   new Insets(2, 0, 0, 0)));
    descriptionPanel.add(ScrollPaneFactory.createScrollPane(myBrowser), BorderLayout.CENTER);

    myRightSplitter = new Splitter(true);
    myRightSplitter.setFirstComponent(descriptionPanel);
    myRightSplitter.setProportion(myProperties.getFloat(HORIZONTAL_DIVIDER_PROPORTION, 0.5f));

    myOptionsPanel = new JPanel(new GridBagLayout());
    initOptionsAndDescriptionPanel();
    myRightSplitter.setSecondComponent(myOptionsPanel);
    myRightSplitter.setHonorComponentsMinimumSize(true);

    final JScrollPane tree = initTreeScrollPane();

    final JPanel northPanel = new JPanel(new GridBagLayout());
    northPanel.setBorder(IdeBorderFactory.createEmptyBorder(2, 0, 2, 0));
    myProfileFilter.setPreferredSize(new Dimension(20, myProfileFilter.getPreferredSize().height));
    northPanel.add(myProfileFilter, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    northPanel.add(createTreeToolbarPanel().getComponent(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    myMainSplitter = new Splitter(false, myProperties.getFloat(VERTICAL_DIVIDER_PROPORTION, 0.5f), 0.01f, 0.99f);
    myMainSplitter.setFirstComponent(tree);
    myMainSplitter.setSecondComponent(myRightSplitter);
    myMainSplitter.setHonorComponentsMinimumSize(false);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(northPanel, BorderLayout.NORTH);
    panel.add(myMainSplitter, BorderLayout.CENTER);
    return panel;
  }