Search in sources :

Example 31 with JBColor

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);
}
Also used : BalloonLayout(com.intellij.ui.BalloonLayout) BalloonLayoutData(com.intellij.ui.BalloonLayoutData) Balloon(com.intellij.openapi.ui.popup.Balloon) JBColor(com.intellij.ui.JBColor) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 32 with JBColor

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);
}
Also used : Ref(com.intellij.openapi.util.Ref) BalloonLayout(com.intellij.ui.BalloonLayout) NotificationAction(com.intellij.notification.NotificationAction) BalloonLayoutData(com.intellij.ui.BalloonLayoutData) JBColor(com.intellij.ui.JBColor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 33 with JBColor

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);
}
Also used : JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Example 34 with JBColor

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;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Rectangle2D(java.awt.geom.Rectangle2D) NotNull(org.jetbrains.annotations.NotNull) URL(java.net.URL) HyperlinkListener(javax.swing.event.HyperlinkListener) JBColor(com.intellij.ui.JBColor)

Example 35 with JBColor

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);
}
Also used : ShadowRenderer(org.jdesktop.swingx.graphics.ShadowRenderer) JBColor(com.intellij.ui.JBColor) BufferedImage(java.awt.image.BufferedImage)

Aggregations

JBColor (com.intellij.ui.JBColor)51 GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)8 NotNull (org.jetbrains.annotations.NotNull)8 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)4 Rectangle2D (java.awt.geom.Rectangle2D)4 UIUtil (com.intellij.util.ui.UIUtil)3 Project (com.intellij.openapi.project.Project)2 BalloonLayout (com.intellij.ui.BalloonLayout)2 BalloonLayoutData (com.intellij.ui.BalloonLayoutData)2 StudyStatus (com.jetbrains.edu.learning.courseFormat.StudyStatus)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 BasicArrowButton (javax.swing.plaf.basic.BasicArrowButton)2 Nullable (org.jetbrains.annotations.Nullable)2 ItemResourceValue (com.android.ide.common.rendering.api.ItemResourceValue)1 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)1 LegendComponent (com.android.tools.adtui.LegendComponent)1 LegendRenderData (com.android.tools.adtui.LegendRenderData)1 TimelineComponent (com.android.tools.adtui.TimelineComponent)1 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)1 MergedManifest (com.android.tools.idea.model.MergedManifest)1