mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.ide.util.newProjectWizard;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
@@ -62,11 +63,8 @@ class WizardArrowUI extends BasicButtonUI {
|
||||
|
||||
private String layout(AbstractButton b, FontMetrics fm,
|
||||
int width, int height) {
|
||||
Insets i = b.getInsets();
|
||||
viewRect.x = i.left;
|
||||
viewRect.y = i.top;
|
||||
viewRect.width = width - (i.right + viewRect.x);
|
||||
viewRect.height = height - (i.bottom + viewRect.y);
|
||||
viewRect.setBounds(0, 0, width, height);
|
||||
JBInsets.removeFrom(viewRect, b.getInsets());
|
||||
|
||||
textRect.x = textRect.y = textRect.width = textRect.height = 0;
|
||||
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
|
||||
|
||||
+11
-9
@@ -29,6 +29,7 @@ import com.intellij.ui.components.labels.LinkListener;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.BaseButtonBehavior;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.TimedDeadzone;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -350,28 +351,29 @@ public class ConfigurationErrorsComponent extends JPanel implements Disposable,
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
final Insets insets = getInsets();
|
||||
return new Dimension(myIcon.getIconWidth() + insets.left + insets.right, myIcon.getIconHeight() + insets.top + insets.bottom);
|
||||
Dimension size = new Dimension(myIcon.getIconWidth(), myIcon.getIconHeight());
|
||||
JBInsets.addTo(size, getInsets());
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(final Graphics g) {
|
||||
final Insets insets = getInsets();
|
||||
final Dimension d = getSize();
|
||||
Rectangle bounds = new Rectangle(getWidth(), getHeight());
|
||||
JBInsets.removeFrom(bounds, getInsets());
|
||||
|
||||
int x = (d.width - myIcon.getIconWidth() - insets.left - insets.right) / 2;
|
||||
int y = (d.height - myIcon.getIconHeight() - insets.top - insets.bottom) / 2;
|
||||
bounds.x += (bounds.width - myIcon.getIconWidth()) / 2;
|
||||
bounds.y += (bounds.height - myIcon.getIconHeight()) / 2;
|
||||
|
||||
if (myBehavior.isHovered()) {
|
||||
// todo
|
||||
}
|
||||
|
||||
if (myBehavior.isPressedByMouse()) {
|
||||
x += 1;
|
||||
y += 1;
|
||||
bounds.x++;
|
||||
bounds.y++;
|
||||
}
|
||||
|
||||
myIcon.paintIcon(this, g, x + insets.left, y + insets.top);
|
||||
myIcon.paintIcon(this, g, bounds.x, bounds.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -31,6 +31,7 @@ import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -192,13 +193,8 @@ public abstract class AdvancedSettingsAction extends DumbAwareAction {
|
||||
icon = EmptyIcon.create(20, 18);
|
||||
}
|
||||
if (icon != null) {
|
||||
final Insets i = checkBox.getInsets();
|
||||
final Rectangle r = checkBox.getBounds();
|
||||
final Rectangle r1 = new Rectangle();
|
||||
r1.x = i.left;
|
||||
r1.y = i.top;
|
||||
r1.width = r.width - (i.right + r1.x);
|
||||
r1.height = r.height - (i.bottom + r1.y);
|
||||
final Rectangle r1 = new Rectangle(checkBox.getWidth(), checkBox.getHeight());
|
||||
JBInsets.removeFrom(r1, checkBox.getInsets());
|
||||
final Rectangle iconRect = new Rectangle();
|
||||
SwingUtilities.layoutCompoundLabel(
|
||||
checkBox, checkBox.getFontMetrics(checkBox.getFont()), checkBox.getText(), icon,
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.util.ui.AbstractLayoutManager;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -213,9 +214,9 @@ public class RevisionsList {
|
||||
myLabelPanel.setLayout(new AbstractLayoutManager() {
|
||||
@Override
|
||||
public Dimension preferredLayoutSize(Container parent) {
|
||||
Insets i = parent.getInsets();
|
||||
Dimension pref = myLabelContainer.getPreferredSize();
|
||||
return new Dimension(pref.width + i.left + i.right, pref.height + i.top + i.bottom);
|
||||
Dimension size = myLabelContainer.getPreferredSize();
|
||||
JBInsets.addTo(size, parent.getInsets());
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -125,11 +126,8 @@ public class JBCardLayout extends CardLayout {
|
||||
}
|
||||
linearProgress[0] = Math.min(1, Math.max(0, (float)timePassed / mySwipeTime));
|
||||
double naturalProgress = (1 - Math.cos(Math.PI * linearProgress[0])) / 2;
|
||||
Rectangle bounds = parent.getBounds();
|
||||
Insets insets = parent.getInsets();
|
||||
bounds.setLocation(insets.left, insets.top);
|
||||
bounds.width -= insets.left + insets.right;
|
||||
bounds.height -= insets.top + insets.bottom;
|
||||
Rectangle bounds = new Rectangle(parent.getWidth(), parent.getHeight());
|
||||
JBInsets.removeFrom(bounds, parent.getInsets());
|
||||
Rectangle r = new Rectangle(bounds);
|
||||
int x = (int)((naturalProgress * r.width));
|
||||
r.translate(isForward ? -x : x, 0);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ui;
|
||||
import com.intellij.Patches;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -167,12 +168,9 @@ public class ScreenUtil {
|
||||
}
|
||||
|
||||
private static Rectangle applyInsets(Rectangle rect, Insets i) {
|
||||
return (i == null)
|
||||
? new Rectangle(rect)
|
||||
: new Rectangle(rect.x + i.left,
|
||||
rect.y + i.top,
|
||||
rect.width - (i.left + i.right),
|
||||
rect.height - (i.top + i.bottom));
|
||||
rect = new Rectangle(rect);
|
||||
JBInsets.removeFrom(rect, i);
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static Insets getScreenInsets(final GraphicsConfiguration gc) {
|
||||
@@ -303,10 +301,8 @@ public class ScreenUtil {
|
||||
}
|
||||
|
||||
public static void moveToFit(final Rectangle rectangle, final Rectangle container, @Nullable Insets padding) {
|
||||
Insets insets = padding != null ? padding : new Insets(0, 0, 0, 0);
|
||||
|
||||
Rectangle move = new Rectangle(rectangle.x - insets.left, rectangle.y - insets.top, rectangle.width + insets.left + insets.right,
|
||||
rectangle.height + insets.top + insets.bottom);
|
||||
Rectangle move = new Rectangle(rectangle);
|
||||
JBInsets.addTo(move, padding);
|
||||
|
||||
if (move.getMaxX() > container.getMaxX()) {
|
||||
move.x = (int)container.getMaxX() - move.width;
|
||||
@@ -325,10 +321,8 @@ public class ScreenUtil {
|
||||
move.y = (int)container.getMinY();
|
||||
}
|
||||
|
||||
rectangle.x = move.x + insets.left;
|
||||
rectangle.y = move.y + insets.right;
|
||||
rectangle.width = move.width - insets.left - insets.right;
|
||||
rectangle.height = move.height - insets.top - insets.bottom;
|
||||
JBInsets.removeFrom(move, padding);
|
||||
rectangle.setBounds(move);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -409,9 +410,7 @@ public class SearchTextField extends JPanel {
|
||||
Dimension size = super.getPreferredSize();
|
||||
Border border = super.getBorder();
|
||||
if (border != null && UIUtil.isUnderAquaLookAndFeel()) {
|
||||
Insets insets = border.getBorderInsets(this);
|
||||
size.height += insets.top + insets.bottom;
|
||||
size.width += insets.left + insets.right;
|
||||
JBInsets.addTo(size, border.getBorderInsets(this));
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.ComponentWithEmptyText;
|
||||
import com.intellij.util.ui.StatusText;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -151,11 +148,7 @@ public class JBList extends JList implements ComponentWithEmptyText, ComponentWi
|
||||
public Dimension getPreferredSize() {
|
||||
if (getModel().getSize() == 0 && !StringUtil.isEmpty(getEmptyText().getText())) {
|
||||
Dimension s = getEmptyText().getPreferredSize();
|
||||
Insets insets = getInsets();
|
||||
if (insets != null) {
|
||||
s.width += (insets.left + insets.right);
|
||||
s.height += (insets.top + insets.bottom);
|
||||
}
|
||||
JBInsets.addTo(s, getInsets());
|
||||
return s;
|
||||
} else {
|
||||
return super.getPreferredSize();
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.Weighted;
|
||||
import com.intellij.openapi.wm.IdeGlassPane;
|
||||
import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.ui.ScreenUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
@@ -129,8 +130,8 @@ public class JBOptionButton extends JButton implements MouseMotionListener, Weig
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
final Dimension size = super.getPreferredSize();
|
||||
size.width += (myMoreRec.width + myDownIconInsets.left + myDownIconInsets.right);
|
||||
size.height += (myDownIconInsets.top + myDownIconInsets.bottom);
|
||||
size.width += myMoreRec.width;
|
||||
JBInsets.addTo(size, myDownIconInsets);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ui.Html;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -543,11 +544,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
Dimension s = prefSize.get() != null ? new Dimension(prefSize.get()) : super.getPreferredSize();
|
||||
Border b = getBorder();
|
||||
if (b != null) {
|
||||
Insets insets = b.getBorderInsets(this);
|
||||
if (insets != null) {
|
||||
s.width += insets.left + insets.right;
|
||||
s.height += insets.top + insets.bottom;
|
||||
}
|
||||
JBInsets.addTo(s, b.getBorderInsets(this));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
+2
-5
@@ -18,6 +18,7 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
@@ -56,11 +57,7 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
|
||||
Rectangle iconRect = new Rectangle();
|
||||
Rectangle textRect = new Rectangle();
|
||||
|
||||
Insets i = c.getInsets();
|
||||
viewRect.x += i.left;
|
||||
viewRect.y += i.top;
|
||||
viewRect.width -= (i.right + viewRect.x);
|
||||
viewRect.height -= (i.bottom + viewRect.y);
|
||||
JBInsets.removeFrom(viewRect, c.getInsets());
|
||||
|
||||
String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), getDefaultIcon(),
|
||||
b.getVerticalAlignment(), b.getHorizontalAlignment(),
|
||||
|
||||
+3
-10
@@ -19,6 +19,7 @@ import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.DefaultLookup;
|
||||
@@ -183,10 +184,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
}
|
||||
}
|
||||
|
||||
if (myPadding != null) {
|
||||
display.width += myPadding.left + myPadding.right;
|
||||
display.height += myPadding.top + myPadding.bottom;
|
||||
}
|
||||
JBInsets.addTo(display, myPadding);
|
||||
|
||||
myDisplaySizeCache.setSize(display.width, display.height);
|
||||
myDisplaySizeDirty = false;
|
||||
@@ -267,12 +265,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
}
|
||||
|
||||
Rectangle r = new Rectangle(bounds);
|
||||
if (myPadding != null) {
|
||||
r.x += myPadding.left;
|
||||
r.y += myPadding.top;
|
||||
r.width -= myPadding.left + myPadding.right;
|
||||
r.height -= myPadding.top + myPadding.bottom;
|
||||
}
|
||||
JBInsets.removeFrom(r, myPadding);
|
||||
|
||||
currentValuePane.paintComponent(g, c, comboBox, r.x, r.y, r.width, r.height, shouldValidate);
|
||||
// return opaque for combobox popup items painting
|
||||
|
||||
+2
-10
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import sun.swing.MenuItemLayoutHelper;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
@@ -64,7 +65,7 @@ public class DarculaMenuItemUIBase extends BasicMenuItemUI {
|
||||
g.setFont(mi.getFont());
|
||||
|
||||
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
|
||||
applyInsets(viewRect, mi.getInsets());
|
||||
JBInsets.removeFrom(viewRect, mi.getInsets());
|
||||
|
||||
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
|
||||
arrowIcon, viewRect, defaultTextIconGap, "-", //todo[kb] use protected field BasicMenuItemUI.acceleratorDelimiter when we move to java 1.7
|
||||
@@ -196,13 +197,4 @@ public class DarculaMenuItemUIBase extends BasicMenuItemUI {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyInsets(Rectangle rect, Insets insets) {
|
||||
if(insets != null) {
|
||||
rect.x += insets.left;
|
||||
rect.y += insets.top;
|
||||
rect.width -= (insets.right + rect.x);
|
||||
rect.height -= (insets.bottom + rect.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -18,6 +18,7 @@ package com.intellij.openapi.actionSystem.impl;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionButtonLook;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import sun.swing.SwingUtilities2;
|
||||
@@ -72,11 +73,7 @@ public class ActionButtonWithText extends ActionButton {
|
||||
Icon icon = getIcon();
|
||||
FontMetrics fm = getFontMetrics(getFont());
|
||||
Rectangle viewRect = new Rectangle(getSize());
|
||||
Insets i = getInsets();
|
||||
viewRect.x += i.left;
|
||||
viewRect.y += i.top;
|
||||
viewRect.width -= (i.right + viewRect.x);
|
||||
viewRect.height -= (i.bottom + viewRect.y);
|
||||
JBInsets.removeFrom(viewRect, getInsets());
|
||||
|
||||
Rectangle iconRect = new Rectangle();
|
||||
Rectangle textRect = new Rectangle();
|
||||
|
||||
+1
-6
@@ -128,12 +128,7 @@ final class ActionPopupMenuImpl implements ActionPopupMenu, ApplicationActivatio
|
||||
}
|
||||
|
||||
// Determine real client area of target graphics configuration
|
||||
Insets insets = ScreenUtil.getScreenInsets(targetGraphicsConfiguration);
|
||||
Rectangle targetRectangle = targetGraphicsConfiguration.getBounds();
|
||||
targetRectangle.x += insets.left;
|
||||
targetRectangle.y += insets.top;
|
||||
targetRectangle.width -= insets.left + insets.right;
|
||||
targetRectangle.height -= insets.top + insets.bottom;
|
||||
Rectangle targetRectangle = ScreenUtil.getScreenRectangle(targetGraphicsConfiguration);
|
||||
|
||||
// Fit popup into targetRectangle.
|
||||
// The algorithm is the following:
|
||||
|
||||
+3
-2
@@ -42,6 +42,7 @@ import com.intellij.ui.awt.RelativeRectangle;
|
||||
import com.intellij.ui.switcher.SwitchTarget;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
@@ -784,9 +785,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
}
|
||||
}
|
||||
|
||||
final Insets i = getInsets();
|
||||
JBInsets.addTo(dimension, getInsets());
|
||||
|
||||
return new Dimension(dimension.width + i.left + i.right, dimension.height + i.top + i.bottom);
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,6 +50,7 @@ import com.intellij.ui.mac.foundation.ID;
|
||||
import com.intellij.ui.mac.foundation.MacUtil;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -1055,9 +1056,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
else {
|
||||
myLastMinimumSize = new Dimension(size);
|
||||
Insets insets = window.getInsets();
|
||||
size.width += insets.left + insets.right;
|
||||
size.height += insets.top + insets.bottom;
|
||||
JBInsets.addTo(size, window.getInsets());
|
||||
}
|
||||
window.setMinimumSize(size);
|
||||
}
|
||||
|
||||
@@ -589,15 +589,8 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
}
|
||||
|
||||
private Dimension getContentSizeFor(AbstractPosition position) {
|
||||
Insets insets = position.createBorder(this).getBorderInsets();
|
||||
if (insets == null) {
|
||||
insets = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Dimension size = myContent.getPreferredSize();
|
||||
size.width += insets.left + insets.right;
|
||||
size.height += insets.top + insets.bottom;
|
||||
|
||||
JBInsets.addTo(size, position.createBorder(this).getBorderInsets());
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -1361,12 +1354,10 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
Insets insets = getInsets();
|
||||
if (insets == null) {
|
||||
insets = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
Rectangle bounds = new Rectangle(getWidth(), getHeight());
|
||||
JBInsets.removeFrom(bounds, getInsets());
|
||||
|
||||
myContent.setBounds(insets.left, insets.top, getWidth() - insets.left - insets.right, getHeight() - insets.top - insets.bottom);
|
||||
myContent.setBounds(bounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1380,12 +1371,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
}
|
||||
|
||||
private Dimension addInsets(Dimension size) {
|
||||
final Insets insets = getInsets();
|
||||
if (insets != null) {
|
||||
size.width += insets.left + insets.right;
|
||||
size.height += insets.top + insets.bottom;
|
||||
}
|
||||
|
||||
JBInsets.addTo(size, getInsets());
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowsPane;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -80,8 +81,7 @@ public class BalloonLayoutImpl implements BalloonLayout {
|
||||
private void relayout() {
|
||||
final Dimension size = myLayeredPane.getSize();
|
||||
|
||||
size.width -= myInsets.left + myInsets.right;
|
||||
size.height -= myInsets.top + myInsets.bottom;
|
||||
JBInsets.removeFrom(size, myInsets);
|
||||
|
||||
final Rectangle layoutRec = new Rectangle(new Point(myInsets.left, myInsets.top), size);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ui;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import java.awt.*;
|
||||
@@ -125,13 +126,7 @@ public abstract class CardLayoutPanel<K, UI, V extends Component> extends JCompo
|
||||
@Override
|
||||
public void doLayout() {
|
||||
Rectangle bounds = new Rectangle(getWidth(), getHeight());
|
||||
Insets insets = getInsets();
|
||||
if (insets != null) {
|
||||
bounds.x += insets.left;
|
||||
bounds.y += insets.top;
|
||||
bounds.width -= insets.left + insets.right;
|
||||
bounds.height -= insets.top + insets.bottom;
|
||||
}
|
||||
JBInsets.removeFrom(bounds, getInsets());
|
||||
for (Component component : getComponents()) {
|
||||
component.setBounds(bounds);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -49,10 +51,9 @@ public class CellRendererPanel extends JPanel {
|
||||
@Override
|
||||
public void doLayout() {
|
||||
if (getComponentCount() != 1) return;
|
||||
Insets insets = getInsets();
|
||||
getComponent(0).setBounds(insets.left, insets.top,
|
||||
getWidth() - insets.left - insets.right,
|
||||
getHeight() - insets.top - insets.bottom);
|
||||
Rectangle bounds = new Rectangle(getWidth(), getHeight());
|
||||
JBInsets.removeFrom(bounds, getInsets());
|
||||
getComponent(0).setBounds(bounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextComponentAccessor;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -366,13 +367,7 @@ public class EditorComboBox extends JComboBox implements DocumentListener {
|
||||
}
|
||||
if (myEditorField != null) {
|
||||
final Dimension preferredSize = new Dimension(myEditorField.getComponent().getPreferredSize());
|
||||
final Insets insets = getInsets();
|
||||
if (insets != null) {
|
||||
preferredSize.width += insets.left;
|
||||
preferredSize.width += insets.right;
|
||||
preferredSize.height += insets.top;
|
||||
preferredSize.height += insets.bottom;
|
||||
}
|
||||
JBInsets.addTo(preferredSize, getInsets());
|
||||
return preferredSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -655,13 +656,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
preferredSize.width = myPreferredWidth;
|
||||
}
|
||||
|
||||
final Insets insets = getInsets();
|
||||
if (insets != null) {
|
||||
preferredSize.width += insets.left;
|
||||
preferredSize.width += insets.right;
|
||||
preferredSize.height += insets.top;
|
||||
preferredSize.height += insets.bottom;
|
||||
}
|
||||
JBInsets.addTo(preferredSize, getInsets());
|
||||
size = preferredSize;
|
||||
} else if (myPassivePreferredSize != null) {
|
||||
size = myPassivePreferredSize;
|
||||
@@ -685,8 +680,8 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
if (myEditor != null) {
|
||||
size.height = myEditor.getLineHeight();
|
||||
|
||||
size = UIUtil.addInsets(size, getInsets());
|
||||
size = UIUtil.addInsets(size, myEditor.getInsets());
|
||||
JBInsets.addTo(size, getInsets());
|
||||
JBInsets.addTo(size, myEditor.getInsets());
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
@@ -47,10 +47,7 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.BooleanFunction;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.ChildFocusWatcher;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -1597,11 +1594,7 @@ public class AbstractPopup implements JBPopup {
|
||||
public static Window setSize(JComponent content, final Dimension size) {
|
||||
final Window popupWindow = getContentWindow(content);
|
||||
if (popupWindow == null) return null;
|
||||
Insets insets = content.getInsets();
|
||||
if (insets != null) {
|
||||
size.width += insets.left + insets.right;
|
||||
size.height += insets.top + insets.bottom;
|
||||
}
|
||||
JBInsets.addTo(size, content.getInsets());
|
||||
content.setPreferredSize(size);
|
||||
popupWindow.pack();
|
||||
return popupWindow;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
|
||||
@@ -151,9 +152,7 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable {
|
||||
}
|
||||
dimension.height += dimension1.height;
|
||||
}
|
||||
Insets insets = container.getInsets();
|
||||
dimension.width += insets.left + insets.right + hGap * 2;
|
||||
dimension.height += insets.top + insets.bottom + vGap * 2;
|
||||
addInsets(dimension, container);
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@@ -170,9 +169,13 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable {
|
||||
}
|
||||
dimension.height += dimension1.height;
|
||||
}
|
||||
Insets insets = container.getInsets();
|
||||
dimension.width += insets.left + insets.right + hGap * 2;
|
||||
dimension.height += insets.top + insets.bottom + vGap * 2;
|
||||
addInsets(dimension, container);
|
||||
return dimension;
|
||||
}
|
||||
|
||||
private void addInsets(Dimension dimension, Container container) {
|
||||
JBInsets.addTo(dimension, container.getInsets());
|
||||
dimension.width += hGap + hGap;
|
||||
dimension.height += vGap + vGap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,4 +72,52 @@ public class JBInsets extends Insets {
|
||||
right = insets.right;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dimension the size to increase
|
||||
* @param insets the insets to add
|
||||
*/
|
||||
public static void addTo(@NotNull Dimension dimension, Insets insets) {
|
||||
if (insets != null) {
|
||||
dimension.width += insets.left + insets.right;
|
||||
dimension.height += insets.top + insets.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dimension the size to decrease
|
||||
* @param insets the insets to remove
|
||||
*/
|
||||
public static void removeFrom(@NotNull Dimension dimension, Insets insets) {
|
||||
if (insets != null) {
|
||||
dimension.width -= insets.left + insets.right;
|
||||
dimension.height -= insets.top + insets.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rectangle the size to increase and the location to move
|
||||
* @param insets the insets to add
|
||||
*/
|
||||
public static void addTo(@NotNull Rectangle rectangle, Insets insets) {
|
||||
if (insets != null) {
|
||||
rectangle.x -= insets.left;
|
||||
rectangle.y -= insets.top;
|
||||
rectangle.width += insets.left + insets.right;
|
||||
rectangle.height += insets.top + insets.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rectangle the size to decrease and the location to move
|
||||
* @param insets the insets to remove
|
||||
*/
|
||||
public static void removeFrom(@NotNull Rectangle rectangle, Insets insets) {
|
||||
if (insets != null) {
|
||||
rectangle.x += insets.left;
|
||||
rectangle.y += insets.top;
|
||||
rectangle.width -= insets.left + insets.right;
|
||||
rectangle.height -= insets.top + insets.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3022,16 +3022,6 @@ public class UIUtil {
|
||||
addInsets(component, insets.top, insets.left, insets.bottom, insets.right);
|
||||
}
|
||||
|
||||
public static Dimension addInsets(@NotNull Dimension dimension, @NotNull Insets insets) {
|
||||
Dimension ans = new Dimension(dimension);
|
||||
ans.width += insets.left;
|
||||
ans.width += insets.right;
|
||||
ans.height += insets.top;
|
||||
ans.height += insets.bottom;
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static void adjustWindowToMinimumSize(final Window window) {
|
||||
if (window == null) return;
|
||||
final Dimension minSize = window.getMinimumSize();
|
||||
|
||||
+13
-1
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.compiled.ClsClassImpl;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -347,7 +348,18 @@ public class GrCodeReferenceElementImpl extends GrReferenceElementImpl<GrCodeRef
|
||||
case CLASS: {
|
||||
EnumSet<ClassHint.ResolveKind> kinds = kind == ReferenceKind.CLASS
|
||||
? ClassHint.RESOLVE_KINDS_CLASS : ClassHint.RESOLVE_KINDS_CLASS_PACKAGE;
|
||||
ResolverProcessor processor = new ClassResolverProcessor(refName, ref, kinds);
|
||||
ResolverProcessor processor = new ClassResolverProcessor(refName, ref, kinds) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof ClsClassImpl) {
|
||||
final PsiClass mirrorClass = ((ClsClassImpl)element).getSourceMirrorClass();
|
||||
if (mirrorClass != null) {
|
||||
return super.execute(mirrorClass, state);
|
||||
}
|
||||
}
|
||||
return super.execute(element, state);
|
||||
}
|
||||
};
|
||||
GrCodeReferenceElement qualifier = ref.getQualifier();
|
||||
if (qualifier != null) {
|
||||
PsiElement qualifierResolved = qualifier.resolve();
|
||||
|
||||
Reference in New Issue
Block a user