/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
- package com.emis.caesarui.webccr.listener;
- import com.emis.caesar.emisComponents;
- import com.emis.caesarui.webccr.webccr;
- import com.vaadin.event.Action;
- import com.vaadin.event.ShortcutAction;
- import com.vaadin.ui.Button;
- import com.vaadin.ui.CheckBox;
- import com.vaadin.ui.UI;
- /**
- * 門號申辦 / 固網申辦 鍵盤監聽
- */
- public class TPhoneNumberKeyPressHandler implements Action.Handler {
- Action F1 = new ShortcutAction("F1", ShortcutAction.KeyCode.F1, null);
- Action F2 = new ShortcutAction("F2", ShortcutAction.KeyCode.F2, null);
- Action AlphaX = new ShortcutAction("X", 88,new int[]{ShortcutAction.ModifierKey.ALT});
- Action AlphaS = new ShortcutAction("S", 83,new int[]{ShortcutAction.ModifierKey.ALT});
- private emisComponents bindComponent = null;
- public TPhoneNumberKeyPressHandler() {
- }
- /**
- * 綁定當鍵盤輸入資料時,同步顯示的元件
- *
- * @param bindcomponent 同步顯示的元件物件
- */
- public void bindComponent(emisComponents bindcomponent) {
- bindComponent = bindcomponent;
- }
- @Override
- public Action[] getActions(Object target, Object sender) {
- return new Action[] {
- F1, F2, AlphaX, AlphaS
- };
- }
- @Override
- public void handleAction(Action action, Object sender, Object target) {
- try {
- ((webccr) UI.getCurrent()).getlog().info(webccr.class, "PhoneNumber HotKey Action = " + action.getCaption());
- onFunction(action.getCaption());
- } catch (Exception e) {
- ((webccr) UI.getCurrent()).getlog().error(webccr.class, e);
- }
- }
- private void onFunction(String caption) throws Exception {
- if (bindComponent == null) return;
- Button _oBtn = null;
- //X單銷卡片
- CheckBox _oChk = null;
- if ("F1".equalsIgnoreCase(caption)) {
- _oBtn = (Button) bindComponent.getComponent("btnOK");
- if (_oBtn != null) {
- _oBtn.click();
- return;
- }
- }
- if ("F2".equalsIgnoreCase(caption)) {
- _oBtn = (Button) bindComponent.getComponent("btnOldRenewal");
- if (_oBtn != null) {
- _oBtn.click();
- return;
- }
- }
- if ("X".equalsIgnoreCase(caption)) {
- _oChk = (CheckBox) bindComponent.getComponent("chkCard");
- if (_oChk != null) {
- _oChk.setValue(!_oChk.getValue());
- return;
- }
- }
- if ("S".equalsIgnoreCase(caption)) {
- _oBtn = (Button) bindComponent.getComponent("btnQueryPno");
- if (_oBtn != null) {
- _oBtn.click();
- return;
- }
- }
- }
- }