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
Highlighting row under mouse
This commit is contained in:
+8
-1
@@ -25,6 +25,7 @@ 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 com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -61,7 +62,8 @@ public class ArrangementListRowDecorator extends JPanel implements ArrangementMa
|
||||
int diameter = Math.max(maxWidth, height) * 5 / 3;
|
||||
myRowIndexControl = new ArrangementRuleIndexControl(diameter, height);
|
||||
|
||||
setOpaque(false);
|
||||
setOpaque(true);
|
||||
setBackground(UIUtil.getListBackground());
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -122,6 +124,10 @@ public class ArrangementListRowDecorator extends JPanel implements ArrangementMa
|
||||
myDelegate.setSelected(selected);
|
||||
}
|
||||
|
||||
public void onMouseEntered() {
|
||||
setBackground(UIUtil.getDecoratedRowColor());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Rectangle onMouseMove(@NotNull MouseEvent event) {
|
||||
@@ -136,6 +142,7 @@ public class ArrangementListRowDecorator extends JPanel implements ArrangementMa
|
||||
@Nullable
|
||||
@Override
|
||||
public Rectangle onMouseExited() {
|
||||
setBackground(UIUtil.getListBackground());
|
||||
return myDelegate.onMouseExited();
|
||||
}
|
||||
|
||||
|
||||
+14
-10
@@ -144,18 +144,20 @@ public class ArrangementMatchingRulesList extends JBList {
|
||||
}
|
||||
|
||||
ArrangementListRowDecorator decorator = myComponents.get(myRowUnderMouse);
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle rectangle = decorator.onMouseExited();
|
||||
if (rectangle != null) {
|
||||
repaintScreenBounds(rectangle);
|
||||
if (decorator != null) {
|
||||
decorator.onMouseExited();
|
||||
repaintRows(myRowUnderMouse, myRowUnderMouse, false);
|
||||
}
|
||||
myRowUnderMouse = -1;
|
||||
}
|
||||
|
||||
private void onMouseEntered(@NotNull MouseEvent e) {
|
||||
myRowUnderMouse = locationToIndex(e.getPoint());
|
||||
ArrangementListRowDecorator decorator = myComponents.get(myRowUnderMouse);
|
||||
if (decorator != null) {
|
||||
decorator.onMouseEntered();
|
||||
repaintRows(myRowUnderMouse, myRowUnderMouse, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void onSelectionChange(@NotNull ListSelectionEvent e) {
|
||||
@@ -183,10 +185,12 @@ public class ArrangementMatchingRulesList extends JBList {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void repaintRows(int first, int last) {
|
||||
public void repaintRows(int first, int last, boolean rowStructureChanged) {
|
||||
Rectangle bounds = getCellBounds(first, last);
|
||||
for (int i = first; i <= last; i++) {
|
||||
myComponents.remove(i);
|
||||
if (rowStructureChanged) {
|
||||
for (int i = first; i <= last; i++) {
|
||||
myComponents.remove(i);
|
||||
}
|
||||
}
|
||||
if (bounds != null) {
|
||||
repaint(bounds);
|
||||
|
||||
+4
-4
@@ -59,7 +59,7 @@ public class ArrangementMatchNodeComponentFactory {
|
||||
|
||||
ArrangementMatchCondition existingCondition = rule.getMatcher().getCondition();
|
||||
if (existingCondition.equals(condition)) {
|
||||
myList.repaintRows(i, model.getSize() - 1);
|
||||
myList.repaintRows(i, model.getSize() - 1, true);
|
||||
model.remove(i);
|
||||
return;
|
||||
}
|
||||
@@ -69,15 +69,15 @@ public class ArrangementMatchNodeComponentFactory {
|
||||
operands.remove(condition);
|
||||
|
||||
if (operands.isEmpty()) {
|
||||
myList.repaintRows(i, model.getSize() - 1);
|
||||
myList.repaintRows(i, model.getSize() - 1, true);
|
||||
model.remove(i);
|
||||
}
|
||||
else if (operands.size() == 1) {
|
||||
model.set(i, new StdArrangementMatchRule(new StdArrangementEntryMatcher(operands.iterator().next()), rule.getOrderType()));
|
||||
myList.repaintRows(i, i);
|
||||
myList.repaintRows(i, i, true);
|
||||
}
|
||||
else {
|
||||
myList.repaintRows(i, i);
|
||||
myList.repaintRows(i, i, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user