use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class LongLineInspection method createOptionsPanel.
@Nullable
@Override
public JComponent createOptionsPanel() {
final HyperlinkLabel codeStyleHyperlink = new HyperlinkLabel("Edit Code Style settings");
codeStyleHyperlink.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
@Override
public void consume(DataContext context) {
if (context != null) {
final Settings settings = Settings.KEY.getData(context);
if (settings != null) {
settings.select(settings.find(CodeStyleSchemesConfigurable.class));
} else {
ShowSettingsUtil.getInstance().showSettingsDialog(CommonDataKeys.PROJECT.getData(context), CodeStyleSchemesConfigurable.class);
}
}
}
});
}
});
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(codeStyleHyperlink, BorderLayout.NORTH);
return panel;
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class HyperlinkLabel method setHyperlinkTarget.
public void setHyperlinkTarget(@Nullable final String url) {
if (myHyperlinkListener != null) {
removeHyperlinkListener(myHyperlinkListener);
}
if (url != null) {
myHyperlinkListener = new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
BrowserUtil.browse(url);
}
};
addHyperlinkListener(myHyperlinkListener);
}
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class DiffUtil method showSuccessPopup.
public static void showSuccessPopup(@NotNull String message, @NotNull RelativePoint point, @NotNull Disposable disposable, @Nullable Runnable hyperlinkHandler) {
HyperlinkListener listener = null;
if (hyperlinkHandler != null) {
listener = new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
hyperlinkHandler.run();
}
};
}
Color bgColor = MessageType.INFO.getPopupBackground();
Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, null, bgColor, listener).setAnimationCycle(200).createBalloon();
balloon.show(point, Balloon.Position.below);
Disposer.register(disposable, balloon);
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class SwingHelper method createHtmlLabel.
public static JEditorPane createHtmlLabel(@NotNull final String innerHtml, @Nullable String disabledHtml, @Nullable final Consumer<String> hyperlinkListener) {
disabledHtml = disabledHtml == null ? innerHtml : disabledHtml;
final Font font = UIUtil.getLabelFont();
String html = buildHtml(UIUtil.getCssFontDeclaration(font, UIUtil.getInactiveTextColor(), null, null), innerHtml);
String disabled = buildHtml(UIUtil.getCssFontDeclaration(font, UIUtil.getInactiveTextColor(), null, null), disabledHtml);
final JEditorPane pane = new SwingHelper.HtmlViewerBuilder().setCarryTextOver(false).setFont(UIUtil.getLabelFont()).setDisabledHtml(disabled).create();
pane.setText(html);
pane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (hyperlinkListener != null)
hyperlinkListener.consume(e.getURL() == null ? "" : e.getURL().toString());
else
BrowserUtil.browse(e.getURL());
}
}
});
return pane;
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class SystemHealthMonitor method checkJvm.
private void checkJvm() {
if (StringUtil.endsWithIgnoreCase(System.getProperty("java.version", ""), "-ea")) {
showNotification(new KeyHyperlinkAdapter("unsupported.jvm.ea.message"));
}
JdkBundle bundle = JdkBundle.createBoot();
if (bundle != null && !bundle.isBundled()) {
Version version = bundle.getVersion();
Integer updateNumber = bundle.getUpdateNumber();
if (version != null && updateNumber != null && updateNumber < 112) {
final String bundleVersion = version.toCompactString() + "u" + updateNumber;
boolean showSwitchOption = false;
final File bundledJDKAbsoluteLocation = JdkBundle.getBundledJDKAbsoluteLocation();
if (bundledJDKAbsoluteLocation.exists() && bundle.getBitness() == Bitness.x64) {
if (SystemInfo.isMacIntel64) {
showSwitchOption = true;
} else if (SystemInfo.isWindows || SystemInfo.isLinux) {
JdkBundle bundledJdk = JdkBundle.createBundle(bundledJDKAbsoluteLocation, false, false);
if (bundledJdk != null && bundledJdk.getVersion() != null) {
// Version of bundled jdk is available, so the jdk is compatible with underlying OS
showSwitchOption = true;
}
}
}
if (showSwitchOption) {
showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message1") {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
String url = e.getDescription();
if ("ack".equals(url)) {
myProperties.setValue(getIgnoreKey(), "true");
} else if ("switch".equals(url)) {
ActionManager.getInstance().getAction(SWITCH_JDK_ACTION).actionPerformed(null);
} else {
BrowserUtil.browse(url);
}
}
}, bundleVersion, LATEST_JDK_RELEASE);
} else {
showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message2"), bundleVersion, LATEST_JDK_RELEASE);
}
}
}
}
Aggregations