use of com.intellij.ui.JBColor in project intellij-plugins by JetBrains.
the class DartFeedbackBuilder method showErrorNotification.
private static void showErrorNotification(@NotNull Notification notification, @NotNull Project project) {
// Adapted from IdeMessagePanel.showErrorNotification()
IdeFrame myFrame = WindowManager.getInstance().getIdeFrame(project);
BalloonLayout layout = myFrame.getBalloonLayout();
assert layout != null;
BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
layoutData.fadeoutTime = 5000;
layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
Balloon balloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
layout.add(balloon);
}
use of com.intellij.ui.JBColor in project intellij-community by JetBrains.
the class IdeMessagePanel method showErrorNotification.
private void showErrorNotification(@Nullable String notificationText, @NotNull Project project) {
Notification notification = new Notification("", AllIcons.Ide.FatalError, notificationText == null ? ERROR_TITLE : "", null, notificationText == null ? "" : notificationText, NotificationType.ERROR, null);
if (notificationText == null) {
notification.addAction(new NotificationAction(ERROR_LINK) {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
notification.expire();
_openFatals(null);
}
});
}
BalloonLayout layout = myFrame.getBalloonLayout();
assert layout != null;
BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
layoutData.fadeoutTime = 5000;
layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
assert myBalloon == null;
myBalloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
Disposer.register(myBalloon, () -> myBalloon = null);
layout.add(myBalloon);
}
use of com.intellij.ui.JBColor in project intellij-community by JetBrains.
the class SidePanelCountLabel method paintComponent.
@Override
protected void paintComponent(Graphics g) {
g.setColor(isSelected() ? UIUtil.getListSelectionBackground() : UIUtil.SIDE_PANEL_BACKGROUND);
g.fillRect(0, 0, getWidth(), getHeight());
if (StringUtil.isEmpty(getText()))
return;
final JBColor deepBlue = new JBColor(new Color(0x97A4B2), new Color(92, 98, 113));
g.setColor(isSelected() ? Gray._255.withAlpha(UIUtil.isUnderDarcula() ? 100 : 220) : deepBlue);
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
g.fillRoundRect(0, 3, getWidth() - 6 - 1, getHeight() - 6, getHeight() - 6, getHeight() - 6);
config.restore();
setForeground(isSelected() ? deepBlue.darker() : UIUtil.getListForeground(true));
super.paintComponent(g);
}
use of com.intellij.ui.JBColor in project intellij-community by JetBrains.
the class SheetController method createSheetPanel.
private JPanel createSheetPanel(String title, String message, JButton[] buttons) {
JPanel sheetPanel = new JPanel() {
@Override
protected void paintComponent(@NotNull Graphics g2d) {
final Graphics2D g = (Graphics2D) g2d.create();
super.paintComponent(g);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getSheetAlpha()));
g.setColor(new JBColor(Gray._230, UIUtil.getPanelBackground()));
Rectangle2D dialog = new Rectangle2D.Double(SHADOW_BORDER, 0, SHEET_WIDTH, SHEET_HEIGHT);
paintShadow(g);
// draw the sheet background
if (UIUtil.isUnderDarcula()) {
g.fillRoundRect((int) dialog.getX(), (int) dialog.getY() - 5, (int) dialog.getWidth(), (int) (5 + dialog.getHeight()), 5, 5);
} else {
//todo make bottom corners
g.fill(dialog);
}
paintShadowFromParent(g);
}
};
sheetPanel.setOpaque(false);
sheetPanel.setLayout(null);
JPanel ico = new JPanel() {
@Override
protected void paintComponent(@NotNull Graphics g) {
super.paintComponent(g);
myIcon.paintIcon(this, g, 0, 0);
}
};
JEditorPane headerLabel = new JEditorPane();
headerLabel.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
headerLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
headerLabel.setEditable(false);
headerLabel.setContentType("text/html");
headerLabel.setSize(250, Short.MAX_VALUE);
headerLabel.setText(title);
headerLabel.setSize(250, headerLabel.getPreferredSize().height);
headerLabel.setOpaque(false);
headerLabel.setFocusable(false);
sheetPanel.add(headerLabel);
headerLabel.repaint();
messageTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
Font font = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
messageTextPane.setFont(font);
messageTextPane.setEditable(false);
messageTextPane.setContentType("text/html");
messageTextPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent he) {
if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (Desktop.isDesktopSupported()) {
try {
URL url = he.getURL();
if (url != null) {
Desktop.getDesktop().browse(url.toURI());
} else {
LOG.warn("URL is null; HyperlinkEvent: " + he.toString());
}
} catch (IOException | URISyntaxException e) {
LOG.error(e);
}
}
}
}
});
FontMetrics fontMetrics = sheetPanel.getFontMetrics(font);
int widestWordWidth = 250;
String[] words = (message == null) ? ArrayUtil.EMPTY_STRING_ARRAY : message.split(SPACE_OR_LINE_SEPARATOR_PATTERN);
for (String word : words) {
widestWordWidth = Math.max(fontMetrics.stringWidth(word), widestWordWidth);
}
messageTextPane.setSize(widestWordWidth, Short.MAX_VALUE);
messageTextPane.setText(handleBreaks(message));
messageArea.setSize(widestWordWidth, messageTextPane.getPreferredSize().height);
SHEET_WIDTH = Math.max(LEFT_SHEET_OFFSET + widestWordWidth + RIGHT_OFFSET, SHEET_WIDTH);
messageTextPane.setSize(messageArea);
messageTextPane.setOpaque(false);
messageTextPane.setFocusable(false);
sheetPanel.add(messageTextPane);
messageTextPane.repaint();
ico.setOpaque(false);
ico.setSize(new Dimension(AllIcons.Logo_welcomeScreen.getIconWidth(), AllIcons.Logo_welcomeScreen.getIconHeight()));
ico.setLocation(LEFT_SHEET_PADDING, TOP_SHEET_PADDING);
sheetPanel.add(ico);
headerLabel.setLocation(LEFT_SHEET_OFFSET, TOP_SHEET_PADDING);
messageTextPane.setLocation(LEFT_SHEET_OFFSET, TOP_SHEET_PADDING + headerLabel.getPreferredSize().height + GAP_BETWEEN_LINES);
SHEET_HEIGHT = TOP_SHEET_PADDING + headerLabel.getPreferredSize().height + GAP_BETWEEN_LINES + messageArea.height + GAP_BETWEEN_LINES;
if (myDoNotAskOption != null) {
layoutDoNotAskCheckbox(sheetPanel);
}
layoutWithAbsoluteLayout(buttons, sheetPanel);
int BOTTOM_SHEET_PADDING = 10;
SHEET_HEIGHT += BOTTOM_SHEET_PADDING;
if (SHEET_HEIGHT < SHEET_MINIMUM_HEIGHT) {
SHEET_HEIGHT = SHEET_MINIMUM_HEIGHT;
shiftButtonsToTheBottom(SHEET_MINIMUM_HEIGHT - SHEET_HEIGHT);
}
sheetPanel.setFocusCycleRoot(true);
recalculateShadow();
sheetPanel.setSize(SHEET_NC_WIDTH, SHEET_NC_HEIGHT);
return sheetPanel;
}
use of com.intellij.ui.JBColor in project intellij-community by JetBrains.
the class SheetController method initShadowImage.
private void initShadowImage() {
final BufferedImage mySheetStencil = GraphicsUtilities.createCompatibleTranslucentImage(SHEET_WIDTH, SHEET_HEIGHT);
Graphics2D g2 = mySheetStencil.createGraphics();
g2.setColor(new JBColor(Gray._255, Gray._0));
g2.fillRect(0, 0, SHEET_WIDTH, SHEET_HEIGHT);
g2.dispose();
ShadowRenderer renderer = new ShadowRenderer();
renderer.setSize(SHADOW_BORDER);
renderer.setOpacity(.80f);
renderer.setColor(new JBColor(JBColor.BLACK, Gray._10));
myShadowImage = renderer.createShadow(mySheetStencil);
}
Aggregations