+++ /dev/null
-/** @file\r
- \r
- The file is used to create listener for Checkbox List\r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
- \r
- **/\r
-package org.tianocore.frameworkwizard.common.ui.iCheckBoxList;\r
-\r
-import java.awt.event.*;\r
-\r
-class ICheckBoxListener implements MouseListener, KeyListener {\r
-\r
- protected ICheckBoxList iCheckboxlist;\r
-\r
- /**\r
- This is the default constructor\r
- \r
- @param parent\r
- \r
- **/\r
- public ICheckBoxListener(ICheckBoxList parent) {\r
- iCheckboxlist = parent;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)\r
- * Override to deal with keyReleased event\r
- * \r
- *\r
- */\r
- public void keyReleased(KeyEvent e) {\r
- Object[] selectedValues = iCheckboxlist.getSelectedValues();\r
- int[] selectedIndices = iCheckboxlist.getSelectedIndices();\r
-\r
- for (int index = 0; index < selectedValues.length; index++) {\r
- ICheckBoxListItem item = (ICheckBoxListItem) selectedValues[index];\r
-\r
- if (iCheckboxlist.isEnabled()) {\r
- if (e.getKeyCode() == KeyEvent.VK_SPACE) {\r
- //\r
- //if press space key, then reverse all selected item.\r
- //\r
- item.invertChecked();\r
- }\r
- ((ICheckBoxListModel) iCheckboxlist.getModel()).setElementAt(item, selectedIndices[index]);\r
- }\r
- }\r
- }\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)\r
- * Override to deal with mouse clicked event\r
- * \r
- */\r
- public void mouseClicked(MouseEvent e) {\r
- int index = iCheckboxlist.locationToIndex(e.getPoint());\r
- ICheckBoxListItem item = null;\r
- item = (ICheckBoxListItem) iCheckboxlist.getModel().getElementAt(index);\r
- \r
- if (item != null && iCheckboxlist.isEnabled()) {\r
- item.invertChecked();\r
- ((ICheckBoxListModel) iCheckboxlist.getModel()).setElementAt(item, index);\r
- }\r
- }\r
-\r
- public void mousePressed(MouseEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- public void mouseReleased(MouseEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- public void mouseEntered(MouseEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- public void mouseExited(MouseEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- public void keyPressed(KeyEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- public void keyTyped(KeyEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-}\r