public void paintComponent(Graphics g) { if (getFrame() != null) { setState(getFrame().getExtendedState()); } JRootPane rootPane = getRootPane(); Window window = getWindow(); boolean leftToRight = (window == null) ? rootPane.getComponentOrientation().isLeftToRight() : window.getComponentOrientation().isLeftToRight(); boolean isSelected = (window == null) ? true : window.isActive(); int width = getWidth(); int height = getHeight(); Color background; Color foreground; Color darkShadow; if (isSelected) { background = UIUtil.getPanelBackground(); // myActiveBackground; foreground = myActiveForeground; darkShadow = Gray._73; // myActiveShadow; } else { background = UIUtil.getPanelBackground(); // myInactiveBackground; foreground = myInactiveForeground; darkShadow = myInactiveShadow; } g.setColor(background); g.fillRect(0, 0, width, height); // g.setColor(darkShadow); // g.drawLine(0, height - 1, width, height - 1); // g.drawLine(0, 0, 0, 0); // g.drawLine(width - 1, 0, width - 1, 0); int xOffset = leftToRight ? 5 : width - 5; if (getWindowDecorationStyle() == JRootPane.FRAME) { xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5; } String theTitle = getTitle(); if (theTitle != null) { FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g); g.setColor(foreground); int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent(); Rectangle rect = new Rectangle(0, 0, 0, 0); if (myIconifyButton != null && myIconifyButton.getParent() != null) { rect = myIconifyButton.getBounds(); } int titleW; if (leftToRight) { if (rect.x == 0) { rect.x = window.getWidth() - window.getInsets().right - 2; } titleW = rect.x - xOffset - 4; theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW); } else { titleW = xOffset - rect.x - rect.width - 4; theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW); xOffset -= SwingUtilities2.stringWidth(rootPane, fm, theTitle); } int titleLength = SwingUtilities2.stringWidth(rootPane, fm, theTitle); if (myIdeMenu == null) { SwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset); xOffset += leftToRight ? titleLength + 5 : -5; } } int w = width; int h = height; h--; g.setColor(UIManager.getColor("MenuBar.darcula.borderColor")); g.drawLine(0, h, w, h); h--; g.setColor(UIManager.getColor("MenuBar.darcula.borderShadowColor")); g.drawLine(0, h, w, h); }
private void buildInInlineIndicator(@NotNull final InlineProgressIndicator inline) { removeAll(); setLayout(new InlineLayout()); add(myRefreshAndInfoPanel); final JPanel inlinePanel = new JPanel(new BorderLayout()); inline.getComponent().setBorder(new EmptyBorder(1, 0, 0, 2)); final JComponent inlineComponent = inline.getComponent(); inlineComponent.setOpaque(false); inlinePanel.add(inlineComponent, BorderLayout.CENTER); // myProgressIcon.setBorder(new IdeStatusBarImpl.MacStatusBarWidgetBorder()); inlinePanel.add(myProgressIcon, BorderLayout.WEST); inline.updateProgressNow(); inlinePanel.setOpaque(false); add(inlinePanel); myRefreshAndInfoPanel.revalidate(); myRefreshAndInfoPanel.repaint(); if (UISettings.getInstance().PRESENTATION_MODE) { final JRootPane pane = myInfoPanel.getRootPane(); final RelativePoint point = new RelativePoint(pane, new Point(pane.getWidth() - 250, 60)); final PresentationModeProgressPanel panel = new PresentationModeProgressPanel(inline); final MyInlineProgressIndicator delegate = new MyInlineProgressIndicator(true, inline.getInfo(), inline) { @Override protected void updateProgress() { super.updateProgress(); panel.update(); } }; Disposer.register(inline, delegate); JBPopupFactory.getInstance() .createBalloonBuilder(panel.getRootPanel()) .setFadeoutTime(0) .setFillColor(Gray.TRANSPARENT) .setShowCallout(false) .setBorderColor(Gray.TRANSPARENT) .setBorderInsets(new Insets(0, 0, 0, 0)) .setAnimationCycle(0) .setCloseButtonEnabled(false) .setHideOnClickOutside(false) .setDisposable(inline) .setHideOnFrameResize(false) .setHideOnKeyOutside(false) .setBlockClicksThroughBalloon(true) .setHideOnAction(false) .createBalloon() .show( new PositionTracker<Balloon>(pane) { @Override public RelativePoint recalculateLocation(Balloon object) { final EditorComponentImpl editorComponent = UIUtil.findComponentOfType(pane, EditorComponentImpl.class); if (editorComponent != null) { return new RelativePoint( editorComponent.getParent().getParent(), new Point( editorComponent.getParent().getParent().getWidth() - 150, editorComponent.getParent().getParent().getHeight() - 70)); } return point; } }, Balloon.Position.above); } }
private void setState(int state, boolean updateRegardless) { Window wnd = getWindow(); if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) { if (myState == state && !updateRegardless) { return; } Frame frame = getFrame(); if (frame != null) { JRootPane rootPane = getRootPane(); if (((state & Frame.MAXIMIZED_BOTH) != 0) && (rootPane.getBorder() == null || (rootPane.getBorder() instanceof UIResource)) && frame.isShowing()) { rootPane.setBorder(null); } else if ((state & Frame.MAXIMIZED_BOTH) == 0) { // This is a croak, if state becomes bound, this can // be nuked. rootPaneUI.installBorder(rootPane); } if (frame.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { updateToggleButton(myRestoreAction, myMinimizeIcon); myMaximizeAction.setEnabled(false); myRestoreAction.setEnabled(true); } else { updateToggleButton(myMaximizeAction, myMaximizeIcon); myMaximizeAction.setEnabled(true); myRestoreAction.setEnabled(false); } if (myToggleButton.getParent() == null || myIconifyButton.getParent() == null) { add(myToggleButton); add(myIconifyButton); revalidate(); repaint(); } myToggleButton.setText(null); } else { myMaximizeAction.setEnabled(false); myRestoreAction.setEnabled(false); if (myToggleButton.getParent() != null) { remove(myToggleButton); revalidate(); repaint(); } } } else { // Not contained in a Frame myMaximizeAction.setEnabled(false); myRestoreAction.setEnabled(false); myIconifyAction.setEnabled(false); remove(myToggleButton); remove(myIconifyButton); revalidate(); repaint(); } myCloseAction.setEnabled(true); myState = state; } }