use of javax.swing.event.HyperlinkListener in project intellij-community by JetBrains.
the class SearchForUsagesRunnable method notifyByFindBalloon.
private static void notifyByFindBalloon(@Nullable final HyperlinkListener listener, @NotNull final MessageType info, @NotNull FindUsagesProcessPresentation processPresentation, @NotNull final Project project, @NotNull final List<String> lines) {
// in case tool window not registered
com.intellij.usageView.UsageViewManager.getInstance(project);
final Collection<VirtualFile> largeFiles = processPresentation.getLargeFiles();
List<String> resultLines = new ArrayList<>(lines);
HyperlinkListener resultListener = listener;
if (!largeFiles.isEmpty()) {
String shortMessage = "(<a href='" + LARGE_FILES_HREF_TARGET + "'>" + UsageViewBundle.message("large.files.were.ignored", largeFiles.size()) + "</a>)";
resultLines.add(shortMessage);
resultListener = addHrefHandling(resultListener, LARGE_FILES_HREF_TARGET, () -> {
String detailedMessage = detailedLargeFilesMessage(largeFiles);
List<String> strings = new ArrayList<>(lines);
strings.add(detailedMessage);
//noinspection SSBasedInspection
ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener);
});
}
Runnable searchIncludingProjectFileUsages = processPresentation.searchIncludingProjectFileUsages();
if (searchIncludingProjectFileUsages != null) {
resultLines.add("Occurrences in project configuration files are skipped. " + "<a href='" + SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET + "'>Include them</a>");
resultListener = addHrefHandling(resultListener, SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET, searchIncludingProjectFileUsages);
}
//noinspection SSBasedInspection
ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(resultLines), AllIcons.Actions.Find, resultListener);
}
use of javax.swing.event.HyperlinkListener in project intellij-community by JetBrains.
the class HoverHyperlinkLabel method setupListener.
private void setupListener() {
addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
HoverHyperlinkLabel.super.setText(underlineTextInHtml(myOriginalText));
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
public void mouseExited(MouseEvent e) {
HoverHyperlinkLabel.super.setText(myOriginalText);
setCursor(Cursor.getDefaultCursor());
}
});
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
HyperlinkEvent event = new HyperlinkEvent(HoverHyperlinkLabel.this, HyperlinkEvent.EventType.ACTIVATED, null);
for (HyperlinkListener listener : myListeners) {
listener.hyperlinkUpdate(event);
}
return true;
}
}.installOn(this);
}
use of javax.swing.event.HyperlinkListener in project ChatGameFontificator by GlitchCog.
the class ControlWindow method constructAboutPopup.
/**
* Construct the popup dialog containing the About message
*/
private void constructAboutPopup() {
aboutPane = new JEditorPane("text/html", ABOUT_CONTENTS);
aboutPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (EventType.ACTIVATED.equals(e.getEventType())) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(URI.create("https://" + e.getDescription()));
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
});
aboutPane.setEditable(false);
}
use of javax.swing.event.HyperlinkListener in project intellij-plugins by JetBrains.
the class JstdServerStatusView method installLinkHandler.
private static void installLinkHandler(@NotNull JEditorPane pane) {
final Ref<String> urlRef = Ref.create(null);
pane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
urlRef.set(null);
} else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
urlRef.set(e.getDescription());
} else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
BrowserUtil.browse(e.getDescription());
}
}
});
final CopyLinkAction copyLinkAction = new CopyLinkAction();
final OpenLinkInBrowser openLinkInBrowserAction = new OpenLinkInBrowser();
final DefaultActionGroup group = new DefaultActionGroup(openLinkInBrowserAction, copyLinkAction);
pane.addMouseListener(new PopupHandler() {
public void invokePopup(Component comp, int x, int y) {
String url = urlRef.get();
copyLinkAction.setUrl(url);
openLinkInBrowserAction.setUrl(url);
if (url != null) {
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
popupMenu.getComponent().show(comp, x, y);
}
}
});
}
use of javax.swing.event.HyperlinkListener in project processdash by dtuma.
the class AutoUpdateManager method displayUpdateMessage.
/** Display a message box, telling the user that various packages are
* now available for download.
*/
protected void displayUpdateMessage(Component parent, int numUpdatesFound) {
HashSet urlsSeen = new HashSet();
DashPackage pkg;
StringBuffer html = new StringBuffer();
html.append("<html><head><style>" + "UL { margin-top: 0pt; margin-bottom: 0pt }" + "</style></head><body>");
for (int i = 0; i < packages.size(); i++) {
pkg = (DashPackage) packages.get(i);
if (!pkg.updateAvailable)
continue;
String userURL = pkg.userURL;
if (userURL == null || urlsSeen.contains(userURL))
continue;
urlsSeen.add(userURL);
ArrayList updates = new ArrayList();
updates.add(pkg.name);
for (int j = i + 1; j < packages.size(); j++) {
pkg = (DashPackage) packages.get(j);
if (pkg.updateAvailable && userURL.equals(pkg.userURL))
updates.add(pkg.name);
}
Collections.sort(updates, String.CASE_INSENSITIVE_ORDER);
html.append("<p>");
String hyperlink = "<a href=\"" + userURL + "\">" + HTMLUtils.escapeEntities(userURL) + "</a>";
html.append(resources.format("Updates_Available_Message_FMT", hyperlink, new Integer(updates.size())));
html.append("<ul>");
Iterator u = updates.iterator();
while (u.hasNext()) {
String updateName = Translator.translate((String) u.next());
html.append("<li>").append(HTMLUtils.escapeEntities(updateName));
}
html.append("</ul>");
}
JEditorPane message = new JEditorPane();
message.setContentType("text/html");
message.setEditable(false);
message.setBackground(null);
message.setText(html.toString());
message.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
Browser.launch(e.getURL().toString());
}
});
JCheckBox disable = new JCheckBox(resources.getString("Do_Not_Check_Label"));
Object[] messageDisplay = new Object[2];
messageDisplay[0] = message;
messageDisplay[1] = disable;
String[] updateOptions = { resources.getString("Remind_Label"), resources.getString("Close_Label") };
int choice = JOptionPane.showOptionDialog(parent, messageDisplay, resources.getString("Updates_Available_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, updateOptions, updateOptions[0]);
if (choice == 0)
InternalSettings.set(AUTO_UPDATE_SETTING + REMIND, "true");
if (disable.isSelected())
InternalSettings.set(AUTO_UPDATE_SETTING + DISABLED, "true");
}
Aggregations