]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListener.java
1. Restructure some folders and files
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / iCheckBoxList / ICheckBoxListener.java
CommitLineData
a13899c5 1/** @file\r
2 \r
3 The file is used to create listener for Checkbox List\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
15package org.tianocore.frameworkwizard.common.ui.iCheckBoxList;\r
16\r
17import java.awt.event.*;\r
18\r
19class ICheckBoxListener implements MouseListener, KeyListener {\r
20\r
21 protected ICheckBoxList iCheckboxlist;\r
22\r
23 /**\r
24 This is the default constructor\r
25 \r
26 @param parent\r
27 \r
28 **/\r
29 public ICheckBoxListener(ICheckBoxList parent) {\r
30 iCheckboxlist = parent;\r
31 }\r
32\r
33 /* (non-Javadoc)\r
34 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)\r
35 * Override to deal with keyReleased event\r
36 * \r
37 *\r
38 */\r
39 public void keyReleased(KeyEvent e) {\r
40 Object[] selectedValues = iCheckboxlist.getSelectedValues();\r
41 int[] selectedIndices = iCheckboxlist.getSelectedIndices();\r
42\r
43 for (int index = 0; index < selectedValues.length; index++) {\r
44 ICheckBoxListItem item = (ICheckBoxListItem) selectedValues[index];\r
45\r
46 if (iCheckboxlist.isEnabled()) {\r
47 if (e.getKeyCode() == KeyEvent.VK_SPACE) {\r
48 //\r
49 //if press space key, then reverse all selected item.\r
50 //\r
51 item.invertChecked();\r
52 }\r
53 ((ICheckBoxListModel) iCheckboxlist.getModel()).setElementAt(item, selectedIndices[index]);\r
54 }\r
55 }\r
56 }\r
57\r
58\r
59 /* (non-Javadoc)\r
60 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)\r
61 * Override to deal with mouse clicked event\r
62 * \r
63 */\r
64 public void mouseClicked(MouseEvent e) {\r
65 int index = iCheckboxlist.locationToIndex(e.getPoint());\r
66 ICheckBoxListItem item = null;\r
67 item = (ICheckBoxListItem) iCheckboxlist.getModel().getElementAt(index);\r
68 \r
69 if (item != null && iCheckboxlist.isEnabled()) {\r
70 item.invertChecked();\r
71 ((ICheckBoxListModel) iCheckboxlist.getModel()).setElementAt(item, index);\r
72 }\r
73 }\r
74\r
75 public void mousePressed(MouseEvent arg0) {\r
76 // TODO Auto-generated method stub\r
77 \r
78 }\r
79\r
80 public void mouseReleased(MouseEvent arg0) {\r
81 // TODO Auto-generated method stub\r
82 \r
83 }\r
84\r
85 public void mouseEntered(MouseEvent arg0) {\r
86 // TODO Auto-generated method stub\r
87 \r
88 }\r
89\r
90 public void mouseExited(MouseEvent arg0) {\r
91 // TODO Auto-generated method stub\r
92 \r
93 }\r
94\r
95 public void keyPressed(KeyEvent arg0) {\r
96 // TODO Auto-generated method stub\r
97 \r
98 }\r
99\r
100 public void keyTyped(KeyEvent arg0) {\r
101 // TODO Auto-generated method stub\r
102 \r
103 }\r
104}\r