From 197db1aae9df2875b414883b1f35fc3ad5d10420 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Tue, 26 Sep 2017 18:15:26 +0300 Subject: [PATCH] Changes for UI spec at IDEA-175743 (draft) - Show "default" colum --- .../fileStatus/FileStatusColorsTable.java | 24 ++++++++++++++++++- .../FileStatusColorsTableModel.java | 5 +++- .../src/messages/ApplicationBundle.properties | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTable.java b/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTable.java index 39e7968f5a14..0035744fa219 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTable.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTable.java @@ -55,6 +55,7 @@ public class FileStatusColorsTable extends JBTable { setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setDefaultRenderer(Color.class, new MyColorCellRenderer()); setDefaultRenderer(String.class, new MyStatusCellRenderer()); + setDefaultRenderer(Boolean.class, new MyDefaultStatusRenderer()); setTableHeader(null); registerKeyboardAction(new ActionListener() { @Override @@ -76,9 +77,9 @@ public class FileStatusColorsTable extends JBTable { private void initPopup() { mySetColorMenu = new JBPopupMenu(); mySetColorMenu.add(new JBMenuItem(new DropColorAction())); - mySetColorMenu.add(new JBMenuItem(new ChooseColorAction())); myResetItem = new JBMenuItem(new ResetToDefaultAction()); mySetColorMenu.add(myResetItem); + mySetColorMenu.add(new JBMenuItem(new ChooseColorAction())); } private class ChooseColorAction extends AbstractAction { @@ -254,6 +255,27 @@ public class FileStatusColorsTable extends JBTable { } } + private static class MyDefaultStatusRenderer extends DefaultTableCellRenderer { + private final JLabel myLabel = new JLabel(); + private final Color myLabelColor; + + public MyDefaultStatusRenderer() { + myLabel.setOpaque(true); + myLabelColor = ColorUtil.withAlpha(myLabel.getForeground(), 0.5); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (value instanceof Boolean) { + myLabel.setForeground(isSelected ? UIUtil.getTableSelectionForeground() : myLabelColor); + myLabel.setBackground(UIUtil.getTableBackground(isSelected)); + myLabel.setText((Boolean)value ? "(default)" : ""); + return myLabel; + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } + } + private static class MyColorIcon extends EmptyIcon { public static final int COLOR_HEIGHT = 14; diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTableModel.java b/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTableModel.java index e642572eb325..b25e5b9ff52c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTableModel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/fileStatus/FileStatusColorsTableModel.java @@ -40,7 +40,10 @@ public class FileStatusColorsTableModel extends AbstractTableModel { new ColumnInfo( String.class, ApplicationBundle.message("file.status.colors.header.status"), descriptor -> descriptor.getStatus().getText()), new ColumnInfo( - Color.class, ApplicationBundle.message("file.status.colors.header.color"), descriptor -> descriptor.getColor()) + Color.class, ApplicationBundle.message("file.status.colors.header.color"), descriptor -> descriptor.getColor()), + new ColumnInfo( + Boolean.class, "", descriptor -> descriptor.isDefault() + ) }; private static class ColumnInfo { diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index dbbc5f744994..9472ffc6b3f9 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -585,7 +585,7 @@ file.status.colors.header.color=Color file.status.color.none=UI Font Color file.status.color.menu.choose.color=Custom... file.status.color.menu.normal.text=UI Font Color -file.status.color.menu.reset.to.default=Restore Default +file.status.color.menu.reset.to.default=Default title.scope.based=By Scope title.colors.and.fonts=Color Scheme progress.analysing.font=Analysing font: {0}