Search in sources :

Example 1 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project intellij-community by JetBrains.

the class DesignerEditorPanel method addErrorMessage.

protected void addErrorMessage(final FixableMessageInfo message, Icon icon) {
    if (message.myLinkText.length() > 0 || message.myAfterLinkText.length() > 0) {
        HyperlinkLabel warnLabel = new HyperlinkLabel();
        warnLabel.setOpaque(false);
        warnLabel.setHyperlinkText(message.myBeforeLinkText, message.myLinkText, message.myAfterLinkText);
        warnLabel.setIcon(icon);
        if (message.myQuickFix != null) {
            warnLabel.addHyperlinkListener(new HyperlinkListener() {

                public void hyperlinkUpdate(final HyperlinkEvent e) {
                    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        message.myQuickFix.run();
                    }
                }
            });
        }
        myErrorMessages.add(warnLabel);
    } else {
        JBLabel warnLabel = new JBLabel();
        warnLabel.setOpaque(false);
        warnLabel.setText("<html><body>" + message.myBeforeLinkText.replace("\n", "<br>") + "</body></html>");
        warnLabel.setIcon(icon);
        myErrorMessages.add(warnLabel);
    }
    if (message.myAdditionalFixes != null && message.myAdditionalFixes.size() > 0) {
        JPanel fixesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
        fixesPanel.setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 10, 0));
        fixesPanel.setOpaque(false);
        fixesPanel.add(Box.createHorizontalStrut(icon.getIconWidth()));
        for (Pair<String, Runnable> pair : message.myAdditionalFixes) {
            HyperlinkLabel fixLabel = new HyperlinkLabel();
            fixLabel.setOpaque(false);
            fixLabel.setHyperlinkText(pair.getFirst());
            final Runnable fix = pair.getSecond();
            fixLabel.addHyperlinkListener(new HyperlinkListener() {

                @Override
                public void hyperlinkUpdate(HyperlinkEvent e) {
                    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        fix.run();
                    }
                }
            });
            fixesPanel.add(fixLabel);
        }
        myErrorMessages.add(fixesPanel);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) HyperlinkListener(javax.swing.event.HyperlinkListener) JBLabel(com.intellij.ui.components.JBLabel) ThrowableRunnable(com.intellij.util.ThrowableRunnable) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Example 2 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel 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 3 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project intellij-community by JetBrains.

the class DiffNotifications method createNotification.

@NotNull
public static JPanel createNotification(@NotNull String text, @Nullable final Color background, boolean showHideAction) {
    final EditorNotificationPanel panel = new EditorNotificationPanel(background);
    panel.text(text);
    if (showHideAction) {
        HyperlinkLabel link = panel.createActionLabel("Hide", () -> panel.setVisible(false));
        link.setToolTipText("Hide this notification");
    }
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project intellij-community by JetBrains.

the class TooltipUtil method createTooltip.

public static HyperlinkLabel createTooltip(final String message) {
    final HyperlinkLabel link = new HyperlinkLabel("");
    link.setIcon(AllIcons.General.Help_small);
    link.setUseIconAsLink(true);
    link.setIconTextGap(0);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final JLabel label = new JLabel(message);
            label.setBorder(HintUtil.createHintBorder());
            label.setBackground(HintUtil.getInformationColor());
            label.setOpaque(true);
            HintManager.getInstance().showHint(label, RelativePoint.getSouthEastOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
        }
    });
    return link;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 5 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project android by JetBrains.

the class InstantRunConfigurable method createUIComponents.

private void createUIComponents() {
    myOldVersionLabel = new HyperlinkLabel();
    setSyncLinkMessage("");
    myOldVersionLabel.addHyperlinkListener(this);
}
Also used : HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Aggregations

HyperlinkLabel (com.intellij.ui.HyperlinkLabel)25 HyperlinkEvent (javax.swing.event.HyperlinkEvent)9 NotNull (org.jetbrains.annotations.NotNull)7 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)5 HyperlinkListener (javax.swing.event.HyperlinkListener)4 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 DataContext (com.intellij.openapi.actionSystem.DataContext)2 FileChooser.chooseFile (com.intellij.openapi.fileChooser.FileChooser.chooseFile)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 File (java.io.File)2 IOException (java.io.IOException)2 ScreenOrientation (com.android.resources.ScreenOrientation)1 SystemImage (com.android.sdklib.repository.targets.SystemImage)1 LabelWithEditLink (com.android.tools.adtui.LabelWithEditLink)1 TabularLayout (com.android.tools.adtui.TabularLayout)1 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)1 Function (com.google.common.base.Function)1 ImmutableList (com.google.common.collect.ImmutableList)1