]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to create cell renderer for CheckBoxList Item \r | |
4 | \r | |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | package org.tianocore.frameworkwizard.common.ui.iCheckBoxList;\r | |
16 | \r | |
17 | import java.awt.*;\r | |
18 | import javax.swing.*;\r | |
19 | import javax.swing.border.*;\r | |
20 | \r | |
21 | class ICheckBoxListCellRenderer extends JCheckBox implements ListCellRenderer {\r | |
22 | ///\r | |
23 | /// Define class Serial Version UID\r | |
24 | ///\r | |
25 | private static final long serialVersionUID = -1718072217181674870L;\r | |
26 | \r | |
27 | protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);\r | |
28 | \r | |
29 | /**\r | |
30 | This is the default Constructor\r | |
31 | \r | |
32 | **/\r | |
33 | public ICheckBoxListCellRenderer() {\r | |
34 | super();\r | |
35 | setOpaque(true);\r | |
36 | setBorder(noFocusBorder);\r | |
37 | }\r | |
38 | \r | |
39 | /* (non-Javadoc)\r | |
40 | * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)\r | |
41 | * Override to get attribute of the ICheckListCellRenderer\r | |
42 | * \r | |
43 | */\r | |
44 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,\r | |
45 | boolean cellHasFocus) {\r | |
46 | ICheckBoxListItem item = (ICheckBoxListItem) value;\r | |
47 | \r | |
48 | setComponentOrientation(list.getComponentOrientation());\r | |
49 | \r | |
50 | if (item.isChecked()) {\r | |
51 | setBackground(list.getSelectionBackground());\r | |
52 | setForeground(list.getSelectionForeground());\r | |
53 | } else {\r | |
54 | if (isSelected) {\r | |
55 | setBackground(Color.LIGHT_GRAY); \r | |
56 | setForeground(list.getForeground()); \r | |
57 | } else {\r | |
58 | setBackground(list.getBackground());\r | |
59 | setForeground(list.getForeground());\r | |
60 | }\r | |
61 | }\r | |
62 | \r | |
63 | if (value instanceof ICheckBoxListItem) {\r | |
64 | setText(item.getText());\r | |
65 | setSelected(item.isChecked());\r | |
66 | } else {\r | |
67 | setIcon(null);\r | |
68 | setText((value == null) ? "" : value.toString());\r | |
69 | }\r | |
70 | \r | |
71 | setEnabled(list.isEnabled());\r | |
72 | setFont(list.getFont());\r | |
73 | \r | |
74 | return this;\r | |
75 | }\r | |
76 | }\r |