From 21606a3cfcd442ec66022a51733d31e4a5dfdc5c Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Fri, 2 Nov 2012 14:42:19 +0400 Subject: [PATCH] IDEA-19061 Integrate the Rearranger-plugin into core-IDE Highlighting row under mouse --- .../newui/ArrangementListRowDecorator.java | 9 ++++++- .../newui/ArrangementMatchingRulesList.java | 24 +++++++++++-------- .../ArrangementMatchNodeComponentFactory.java | 8 +++---- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementListRowDecorator.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementListRowDecorator.java index 3f2bc4edba7a..db3c91fae181 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementListRowDecorator.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementListRowDecorator.java @@ -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(); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementMatchingRulesList.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementMatchingRulesList.java index f61b5160557e..604c3b55a16c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementMatchingRulesList.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/newui/ArrangementMatchingRulesList.java @@ -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); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java index 0552f7fa8fb9..83d2e11ea790 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/arrangement/node/match/ArrangementMatchNodeComponentFactory.java @@ -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); } }