make big and small checked icons with respect to selection

This commit is contained in:
Konstantin Bulenkov
2011-04-14 20:19:28 +04:00
parent 43b1f29b4d
commit 53b1b4ddee
7 changed files with 22 additions and 4 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

@@ -621,6 +621,7 @@ public abstract class OptionTableWithPreviewPanel extends MultilanguageCodeStyle
}
});
myBooleanEditor.putClientProperty("JComponent.sizeVariant", "small");
myOptionsEditor.putClientProperty("JComponent.sizeVariant", "small");
}
public Object getCellEditorValue() {
@@ -42,18 +42,32 @@ public class JBComboBoxTableCellEditorComponent extends JBLabel {
private Object myValue;
private ListCellRenderer myRenderer = new DefaultListCellRenderer() {
private Icon myCheckIcon = Icons.CHECK_ICON;
private Icon myEmptyIcon = EmptyIcon.create(Icons.CHECK_ICON.getIconWidth());
public Icon myEmptyIcon;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value == myValue) {
label.setIcon(myCheckIcon);
label.setIcon(getIcon(isSelected));
} else {
label.setIcon(myEmptyIcon);
label.setIcon(getEmptyIcon());
}
return label;
}
private Icon getEmptyIcon() {
if (myEmptyIcon == null) {
myEmptyIcon = EmptyIcon.create(getIcon(true).getIconWidth());
}
return myEmptyIcon;
}
private Icon getIcon(boolean selected) {
final boolean small = "small".equals(JBComboBoxTableCellEditorComponent.this.getClientProperty("JComponent.sizeVariant"));
return small
? selected ? Icons.CHECK_ICON_SMALL_SELECTED : Icons.CHECK_ICON_SMALL
: selected ? Icons.CHECK_ICON_SELECTED : Icons.CHECK_ICON;
}
};
public JBComboBoxTableCellEditorComponent() {
@@ -110,6 +110,9 @@ public abstract class Icons {
public static final Icon SYNCHRONIZE_ICON = IconLoader.getIcon("/actions/sync.png");
public static final Icon CHECK_ICON = IconLoader.getIcon("/actions/checked.png");
public static final Icon CHECK_ICON_SELECTED = IconLoader.getIcon("/actions/checked_selected.png");
public static final Icon CHECK_ICON_SMALL = IconLoader.getIcon("/actions/checked_small.png");
public static final Icon CHECK_ICON_SMALL_SELECTED = IconLoader.getIcon("/actions/checked_small_selected.png");
public static final Icon OPEN_EDIT_DIALOG_ICON = IconLoader.getIcon("/actions/showViewer.png");
public static final Icon FLATTEN_PACKAGES_ICON = IconLoader.getIcon("/objectBrowser/flattenPackages.png");