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