/webccr/src/com/emis/caesarui/webccr/listener/TPhoneNumberKeyPressHandler.java

https://bitbucket.org/sanliou/synccr · Java · 91 lines · 68 code · 14 blank · 9 comment · 14 complexity · 987122345cb404553e5abff08bf9fdba MD5 · raw file

  1. package com.emis.caesarui.webccr.listener;
  2. import com.emis.caesar.emisComponents;
  3. import com.emis.caesarui.webccr.webccr;
  4. import com.vaadin.event.Action;
  5. import com.vaadin.event.ShortcutAction;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.CheckBox;
  8. import com.vaadin.ui.UI;
  9. /**
  10. * 門號申辦 / 固網申辦 鍵盤監聽
  11. */
  12. public class TPhoneNumberKeyPressHandler implements Action.Handler {
  13. Action F1 = new ShortcutAction("F1", ShortcutAction.KeyCode.F1, null);
  14. Action F2 = new ShortcutAction("F2", ShortcutAction.KeyCode.F2, null);
  15. Action AlphaX = new ShortcutAction("X", 88,new int[]{ShortcutAction.ModifierKey.ALT});
  16. Action AlphaS = new ShortcutAction("S", 83,new int[]{ShortcutAction.ModifierKey.ALT});
  17. private emisComponents bindComponent = null;
  18. public TPhoneNumberKeyPressHandler() {
  19. }
  20. /**
  21. * 綁定當鍵盤輸入資料時,同步顯示的元件
  22. *
  23. * @param bindcomponent 同步顯示的元件物件
  24. */
  25. public void bindComponent(emisComponents bindcomponent) {
  26. bindComponent = bindcomponent;
  27. }
  28. @Override
  29. public Action[] getActions(Object target, Object sender) {
  30. return new Action[] {
  31. F1, F2, AlphaX, AlphaS
  32. };
  33. }
  34. @Override
  35. public void handleAction(Action action, Object sender, Object target) {
  36. try {
  37. ((webccr) UI.getCurrent()).getlog().info(webccr.class, "PhoneNumber HotKey Action = " + action.getCaption());
  38. onFunction(action.getCaption());
  39. } catch (Exception e) {
  40. ((webccr) UI.getCurrent()).getlog().error(webccr.class, e);
  41. }
  42. }
  43. private void onFunction(String caption) throws Exception {
  44. if (bindComponent == null) return;
  45. Button _oBtn = null;
  46. //X單銷卡片
  47. CheckBox _oChk = null;
  48. if ("F1".equalsIgnoreCase(caption)) {
  49. _oBtn = (Button) bindComponent.getComponent("btnOK");
  50. if (_oBtn != null) {
  51. _oBtn.click();
  52. return;
  53. }
  54. }
  55. if ("F2".equalsIgnoreCase(caption)) {
  56. _oBtn = (Button) bindComponent.getComponent("btnOldRenewal");
  57. if (_oBtn != null) {
  58. _oBtn.click();
  59. return;
  60. }
  61. }
  62. if ("X".equalsIgnoreCase(caption)) {
  63. _oChk = (CheckBox) bindComponent.getComponent("chkCard");
  64. if (_oChk != null) {
  65. _oChk.setValue(!_oChk.getValue());
  66. return;
  67. }
  68. }
  69. if ("S".equalsIgnoreCase(caption)) {
  70. _oBtn = (Button) bindComponent.getComponent("btnQueryPno");
  71. if (_oBtn != null) {
  72. _oBtn.click();
  73. return;
  74. }
  75. }
  76. }
  77. }