From fb46d31f29b212ad213754a41e020cca92aab3af Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 3 Aug 2012 16:31:03 +0200 Subject: [PATCH] Property Table: row separators, correct icons indentation --- .../designer/propertyTable/PropertyTable.java | 10 ++++++++-- .../src/com/intellij/util/ui/CenteredIcon.java | 14 +++++++------- platform/util/src/com/intellij/util/ui/UIUtil.java | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java index 18a8c04024d7..daf8b14f3c58 100644 --- a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java +++ b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java @@ -78,7 +78,10 @@ public abstract class PropertyTable extends JBTable { setModel(myModel); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); showColumns(false); - setShowGrid(false); + + setShowVerticalLines(false); + setIntercellSpacing(new Dimension(0, 1)); + setGridColor(UIUtil.getSlightlyDarkerColor(getBackground())); setRowSelectionAllowed(true); setColumnSelectionAllowed(false); @@ -1051,7 +1054,10 @@ public abstract class PropertyTable extends JBTable { boolean hasChildren = !getChildren(property).isEmpty(); myRenderer.setIcon(hasChildren ? icon : null); - int indent = (icon.getIconWidth() + myRenderer.getIconTextGap()) * (getDepth(property) + (hasChildren ? 0 : 1)); + + int indent = (UIUtil.getTreeLeftChildIndent() + myRenderer.getIconTextGap()) * getDepth(property); + if (!hasChildren) indent += icon.getIconWidth() + myRenderer.getIconTextGap(); + myRenderer.setIpad(new Insets(0, indent, 0, 0)); return myRenderer; diff --git a/platform/util/src/com/intellij/util/ui/CenteredIcon.java b/platform/util/src/com/intellij/util/ui/CenteredIcon.java index e4c386a27162..4482346aa9d0 100644 --- a/platform/util/src/com/intellij/util/ui/CenteredIcon.java +++ b/platform/util/src/com/intellij/util/ui/CenteredIcon.java @@ -45,19 +45,19 @@ public class CenteredIcon implements Icon { public void paintIcon(Component c, Graphics g, int x, int y) { final Dimension size = c.getSize(); - int actualX; - int actualY; + int offsetX; + int offsetY; if (myCenteredInComponent) { - actualX = size.width / 2 - myIcon.getIconWidth() / 2; - actualY = size.height / 2 - myIcon.getIconHeight() / 2; + offsetX = size.width / 2 - myIcon.getIconWidth() / 2; + offsetY = size.height / 2 - myIcon.getIconHeight() / 2; } else { - actualX = (myWidth - myIcon.getIconWidth()) / 2; - actualY = (myHight - myIcon.getIconHeight()) / 2; + offsetX = (myWidth - myIcon.getIconWidth()) / 2; + offsetY = (myHight - myIcon.getIconHeight()) / 2; } - myIcon.paintIcon(c, g, x + actualX, y + actualY); + myIcon.paintIcon(c, g, x + offsetX, y + offsetY); } public int getIconWidth() { diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index a785bd85373f..feec83018d91 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -821,12 +821,12 @@ public class UIUtil { Icon selectedIcon = getTreeSelectedExpandedIcon(); Icon notSelectedIcon = getTreeExpandedIcon(); - int widht = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); + int width = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); int height = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); return new CenteredIcon(expanded ? (white ? getTreeSelectedExpandedIcon() : getTreeExpandedIcon()) : (white ? getTreeSelectedCollapsedIcon() : getTreeCollapsedIcon()), - widht, height, false); + width, height, false); } public static Icon getTreeCollapsedIcon() {