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