use of com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI in project intellij-community by JetBrains.
the class NotificationsManagerImpl method createButtons.
@Nullable
private static JPanel createButtons(@NotNull Notification notification, @NotNull final JPanel content, @Nullable HyperlinkListener listener) {
if (notification instanceof NotificationActionProvider) {
JPanel buttons = new JPanel(new HorizontalLayout(5));
buttons.setOpaque(false);
content.add(BorderLayout.SOUTH, buttons);
final Ref<JButton> defaultButton = new Ref<>();
NotificationActionProvider provider = (NotificationActionProvider) notification;
for (NotificationActionProvider.Action action : provider.getActions(listener)) {
JButton button = new JButton(action) {
@Override
public void setUI(ButtonUI ui) {
boolean isDarcula = ui instanceof DarculaButtonUI && UIUtil.isUnderDarcula();
if (isDarcula) {
ui = new DarculaButtonUI() {
@Override
protected Color getButtonColor1() {
return new ColorUIResource(0x464b4c);
}
@Override
protected Color getButtonColor2() {
return new ColorUIResource(0x383c3d);
}
};
}
super.setUI(ui);
if (isDarcula) {
setBorder(new DarculaButtonPainter() {
@Override
protected Color getBorderColor() {
return new ColorUIResource(0x616263);
}
});
}
}
};
button.setOpaque(false);
if (action.isDefaultAction()) {
defaultButton.setIfNull(button);
}
buttons.add(HorizontalLayout.RIGHT, button);
}
if (!defaultButton.isNull()) {
UIUtil.addParentChangeListener(content, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getOldValue() == null && event.getNewValue() != null) {
UIUtil.removeParentChangeListener(content, this);
JRootPane rootPane = UIUtil.getRootPane(content);
if (rootPane != null) {
rootPane.setDefaultButton(defaultButton.get());
}
}
}
});
}
return buttons;
}
return null;
}
Aggregations