use of org.zkoss.zk.ui.event.KeyEvent in project adempiere by adempiere.
the class CWindowToolbar method onCtrlKeyEvent.
private void onCtrlKeyEvent(KeyEvent keyEvent) {
ToolBarButton btn = null;
if (keyEvent.isAltKey() && !keyEvent.isCtrlKey() && !keyEvent.isShiftKey()) {
if (keyEvent.getKeyCode() == VK_X) {
if (windowNo > 0) {
prevKeyEventTime = System.currentTimeMillis();
prevKeyEvent = keyEvent;
keyEvent.stopPropagation();
SessionManager.getAppDesktop().closeWindow(windowNo);
}
} else {
btn = altKeyMap.get(keyEvent.getKeyCode());
}
} else if (!keyEvent.isAltKey() && keyEvent.isCtrlKey() && !keyEvent.isShiftKey())
btn = ctrlKeyMap.get(keyEvent.getKeyCode());
else if (!keyEvent.isAltKey() && !keyEvent.isCtrlKey() && !keyEvent.isShiftKey())
btn = keyMap.get(keyEvent.getKeyCode());
if (btn != null) {
prevKeyEventTime = System.currentTimeMillis();
prevKeyEvent = keyEvent;
keyEvent.stopPropagation();
if (!btn.isDisabled() && btn.isVisible()) {
Events.sendEvent(btn, new Event(Events.ON_CLICK, btn));
}
}
}
use of org.zkoss.zk.ui.event.KeyEvent in project adempiere by adempiere.
the class WPOSQuantityPanel method onEvent.
@Override
public void onEvent(Event e) throws Exception {
try {
if (Events.ON_CTRL_KEY.equals(e.getName())) {
KeyEvent keyEvent = (KeyEvent) e;
//Alt+up == 38
if (keyEvent.getKeyCode() == 38) {
posPanel.moveUp();
}
//Alt+down == 40
if (keyEvent.getKeyCode() == 40) {
posPanel.moveDown();
}
//ctrl+f3 == 114
if (keyEvent.getKeyCode() == 114) {
posPanel.deleteLine(posPanel.getC_OrderLine_ID());
fieldQuantity.setValue(0.0);
fieldPrice.setValue(0.0);
fieldDiscountPercentage.setValue(0.0);
}
//ctrl+1 == 49
if (keyEvent.getKeyCode() == 49) {
fieldQuantity.setValue(fieldQuantity.getValue().add(CurrentQuantity));
}
//ctrl+0 == 48
if (keyEvent.getKeyCode() == 48) {
fieldQuantity.setValue(fieldQuantity.getValue().subtract(CurrentQuantity));
}
}
if (e.getTarget().equals(buttonUp)) {
posPanel.moveUp();
return;
} else if (e.getTarget().equals(buttonDown)) {
posPanel.moveDown();
return;
}
if (e.getTarget().equals(buttonMinus)) {
BigDecimal quantity = fieldQuantity.getValue().subtract(CurrentQuantity);
if (quantity.compareTo(Env.ZERO) == 0) {
if (posPanel.isUserPinValid()) {
posPanel.setQty(quantity);
}
} else {
posPanel.setQty(quantity);
}
} else if (e.getTarget().equals(buttonPlus)) {
posPanel.setQty(fieldQuantity.getValue().add(CurrentQuantity));
} else if (e.getTarget().equals(buttonDelete)) {
if (posPanel.isUserPinValid()) {
posPanel.deleteLine(posPanel.getC_OrderLine_ID());
posPanel.updateLineTable();
posPanel.refreshPanel();
return;
}
}
BigDecimal value = Env.ZERO;
if (Events.ON_OK.equals(e.getName()) || Events.ON_CHANGE.equals(e.getName())) {
value = fieldQuantity.getValue();
if (value == null)
return;
if (e.getTarget().equals(fieldQuantity.getDecimalbox())) {
if (Events.ON_OK.equals(e.getName())) {
posPanel.setQty(value);
} else if (posPanel.isAddQty() || Events.ON_CHANGE.equals(e.getName())) {
// Verify if it add or set
if (posPanel.isAddQty()) {
posPanel.setQtyAdded(value);
} else {
posPanel.setQty(value);
}
}
}
if (e.getTarget().equals(fieldPrice.getDecimalbox())) {
value = fieldPrice.getValue();
if (value == null)
return;
if (posPanel.isUserPinValid()) {
posPanel.setPrice(value);
}
} else if (e.getTarget().equals(fieldDiscountPercentage.getDecimalbox())) {
if (posPanel.isUserPinValid()) {
value = fieldDiscountPercentage.getValue();
if (value == null)
return;
posPanel.setDiscountPercentage(value);
}
}
}
posPanel.updateLineTable();
posPanel.refreshPanel();
posPanel.changeViewPanel();
posPanel.getMainFocus();
} catch (AdempiereException exception) {
FDialog.error(posPanel.getWindowNo(), this, exception.getLocalizedMessage());
}
}
use of org.zkoss.zk.ui.event.KeyEvent in project adempiere by adempiere.
the class WPOSActionPanel method onEvent.
@Override
public void onEvent(Event e) throws Exception {
try {
if (e.getName().equals(Events.ON_CHANGE)) {
if (lookupProduct.getSelectedRecord() >= 0) {
lookupProduct.setText(String.valueOf(lookupProduct.getSelectedRecord()));
lookupProduct.captureProduct();
}
}
if (Events.ON_CTRL_KEY.equals(e.getName())) {
KeyEvent keyEvent = (KeyEvent) e;
//F2 == 113
if (keyEvent.getKeyCode() == 113) {
posPanel.newOrder();
} else //F3 == 114
if (keyEvent.getKeyCode() == 114) {
if (posPanel.isUserPinValid())
deleteOrder();
} else //F4 == 115
if (keyEvent.getKeyCode() == 115) {
payOrder();
return;
} else //F9 == 120
if (keyEvent.getKeyCode() == 120) {
openHistory();
} else //F10 == 121
if (keyEvent.getKeyCode() == 121) {
openDocType();
} else //Alt+b == 66
if (keyEvent.getKeyCode() == 66) {
openBPartner();
} else //Alt+left == 37
if (keyEvent.getKeyCode() == 37) {
previousRecord();
} else //Alt+right == 39
if (keyEvent.getKeyCode() == 39) {
nextRecord();
} else //CTL+L == 76
if (keyEvent.getKeyCode() == 76) {
dispose();
return;
} else //Alt+I == 73
if (keyEvent.getKeyCode() == 73) {
showWindowProduct(null);
return;
} else //Alt+P == 80
if (keyEvent.getKeyCode() == 80) {
actionProcessMenu.getPopUp().setPage(buttonProcess.getPage());
actionProcessMenu.getPopUp().open(150, 150);
return;
}
}
if (e.getTarget().equals(fieldProductName.getComponent(WPOSTextField.SECONDARY)) && e.getName().equals(Events.ON_FOCUS) && !isKeyboard) {
if (posPanel.isDrafted() || posPanel.isInProgress()) {
isKeyboard = true;
if (!fieldProductName.showKeyboard()) {
findProduct(true);
}
fieldProductName.setFocus(true);
}
}
if (e.getTarget().equals(fieldProductName.getComponent(WPOSTextField.PRIMARY)) && e.getName().equals(Events.ON_FOCUS)) {
isKeyboard = false;
}
if (e.getTarget().equals(buttonNew)) {
posPanel.newOrder();
}
if (e.getTarget().equals(buttonPrint)) {
posPanel.printTicket();
} else if (e.getTarget().equals(buttonDocType)) {
if (posPanel.isUserPinValid()) {
openDocType();
}
} else if (e.getTarget().equals(buttonProduct)) {
showWindowProduct("");
} else if (e.getTarget().equals(buttonBPartner)) {
openBPartner();
} else if (e.getTarget().equals(buttonCollect)) {
if (posPanel.isReturnMaterial()) {
completeReturn();
} else {
payOrder();
}
return;
} else if (e.getTarget().equals(buttonProcess)) {
if (posPanel.isUserPinValid()) {
actionProcessMenu.getPopUp().setPage(this.getPage());
actionProcessMenu.getPopUp().open(buttonProcess);
}
return;
} else if (e.getTarget().equals(buttonBack)) {
previousRecord();
} else if (e.getTarget().equals(buttonNext)) {
nextRecord();
} else if (e.getTarget().equals(buttonLogout)) {
dispose();
return;
} else // Cancel
if (e.getTarget().equals(buttonCancel)) {
if (posPanel.isUserPinValid()) {
deleteOrder();
}
}
// History
if (e.getTarget().equals(buttonHistory)) {
openHistory();
}
posPanel.refreshPanel();
} catch (Exception exception) {
FDialog.error(posPanel.getWindowNo(), exception.getLocalizedMessage());
}
}
Aggregations