mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-19061 Integrate the Rearranger-plugin into core-IDE
Row index is located at the same baseline as condition text
This commit is contained in:
+15
-1
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionButton;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -67,13 +68,21 @@ public class ArrangementListRowDecorator extends JPanel implements ArrangementMa
|
||||
private void init() {
|
||||
setLayout(new GridBagLayout());
|
||||
GridBag constraints = new GridBag().anchor(GridBagConstraints.CENTER)
|
||||
.insets(0, ArrangementConstants.HORIZONTAL_PADDING, 0, ArrangementConstants.HORIZONTAL_PADDING * 3);
|
||||
.insets(0, ArrangementConstants.HORIZONTAL_PADDING, 0, ArrangementConstants.HORIZONTAL_GAP * 2);
|
||||
add(myRowIndexControl, constraints);
|
||||
add(myDelegate.getUiComponent(), new GridBag().fillCellHorizontally().weightx(1).anchor(GridBagConstraints.WEST));
|
||||
add(myEditButton, new GridBag().anchor(GridBagConstraints.EAST));
|
||||
setBorder(IdeBorderFactory.createEmptyBorder(ArrangementConstants.VERTICAL_GAP));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
int baseLine = SimpleColoredComponent.getTextBaseLine(metrics, metrics.getHeight());
|
||||
myRowIndexControl.setBaseLine(baseLine + ArrangementConstants.VERTICAL_GAP + myDelegate.getUiComponent().getBounds().y - myRowIndexControl.getBounds().y);
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
public void setRowIndex(int row) {
|
||||
myRowIndexControl.setIndex(row);
|
||||
}
|
||||
@@ -129,4 +138,9 @@ public class ArrangementListRowDecorator extends JPanel implements ArrangementMa
|
||||
public void onMouseExited() {
|
||||
myDelegate.onMouseExited();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "list row decorator for " + myDelegate.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -32,6 +32,7 @@ public class ArrangementRuleIndexControl extends JPanel {
|
||||
private int myIndex;
|
||||
private char[] myChars;
|
||||
private int myIndexWidth;
|
||||
private int myBaseLine;
|
||||
|
||||
public ArrangementRuleIndexControl(int diameter, int height) {
|
||||
myDiameter = diameter;
|
||||
@@ -77,9 +78,13 @@ public class ArrangementRuleIndexControl extends JPanel {
|
||||
g.setColor(UIUtil.getBorderColor());
|
||||
Rectangle bounds = getBounds();
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.drawOval(0, (bounds.height - myDiameter) / 2, myDiameter, myDiameter);
|
||||
int y = Math.max(0, myBaseLine - myHeight - (myDiameter - myHeight) / 2);
|
||||
g.drawOval(0, y, myDiameter, myDiameter);
|
||||
|
||||
int y = bounds.height - (bounds.height - myHeight) / 2;
|
||||
g.drawChars(myChars, 0, myChars.length, (bounds.width - myIndexWidth) / 2, y);
|
||||
g.drawChars(myChars, 0, myChars.length, (bounds.width - myIndexWidth) / 2, myBaseLine);
|
||||
}
|
||||
|
||||
public void setBaseLine(int baseLine) {
|
||||
myBaseLine = baseLine;
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -88,7 +88,6 @@ public abstract class ArrangementSettingsPanel2 extends CodeStyleAbstractPanel {
|
||||
@Nullable
|
||||
@Override
|
||||
protected EditorHighlighter createHighlighter(EditorColorsScheme scheme) {
|
||||
// TODO den implement
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -765,7 +765,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
|
||||
myTransparentIconBackground = transparentIconBackground;
|
||||
}
|
||||
|
||||
private static int getTextBaseLine(FontMetrics metrics, final int height) {
|
||||
public static int getTextBaseLine(FontMetrics metrics, final int height) {
|
||||
return (height - metrics.getHeight()) / 2 + metrics.getAscent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user