Property Table: row separators, correct icons indentation

This commit is contained in:
Anton Makeev
2012-08-03 16:35:17 +02:00
parent 6816fe2f17
commit fb46d31f29
3 changed files with 17 additions and 11 deletions
@@ -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;
@@ -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() {
@@ -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() {