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);
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations