Search in sources :

Example 16 with HyperlinkEvent

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;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) CodeStyleSchemesConfigurable(com.intellij.application.options.CodeStyleSchemesConfigurable) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Consumer(com.intellij.util.Consumer) HyperlinkListener(javax.swing.event.HyperlinkListener) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) Settings(com.intellij.openapi.options.ex.Settings) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with HyperlinkEvent

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);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener)

Example 18 with HyperlinkEvent

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);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) Balloon(com.intellij.openapi.ui.popup.Balloon)

Example 19 with HyperlinkEvent

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;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener)

Example 20 with HyperlinkEvent

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);
            }
        }
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Version(com.intellij.openapi.util.Version) File(java.io.File) JdkBundle(com.intellij.util.JdkBundle)

Aggregations

HyperlinkEvent (javax.swing.event.HyperlinkEvent)90 NotNull (org.jetbrains.annotations.NotNull)36 Notification (com.intellij.notification.Notification)33 NotificationListener (com.intellij.notification.NotificationListener)31 HyperlinkListener (javax.swing.event.HyperlinkListener)30 Project (com.intellij.openapi.project.Project)14 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)14 File (java.io.File)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 HyperlinkLabel (com.intellij.ui.HyperlinkLabel)9 IOException (java.io.IOException)7 URL (java.net.URL)5 AnAction (com.intellij.openapi.actionSystem.AnAction)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 IdeFrame (com.intellij.openapi.wm.IdeFrame)3 MultiMap (com.intellij.util.containers.MultiMap)3 NonNls (org.jetbrains.annotations.NonNls)3 Nullable (org.jetbrains.annotations.Nullable)3 UISettings (com.intellij.ide.ui.UISettings)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2