Class DefaultKeyboardSupportService
- java.lang.Object
-
- com.hybris.cockpitng.keyboard.impl.DefaultKeyboardSupportService
-
- All Implemented Interfaces:
KeyboardSupportService
public class DefaultKeyboardSupportService extends java.lang.Object implements KeyboardSupportService
Default implementation of keyboard support service.KeyboardSupportService
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringFUNCTION_KEYSprotected static java.util.regex.PatternPATTERNPatter should find for given @0@b@#ins^1^c^#del$2$d$#bak#f10 following groups "@0", "@b", "@#ins", "^1", "^c", "^#del", "$2", "$d", "$#bak", "#f10".protected static java.lang.StringPREFIX_FUNCTION_KEYSprotected static java.util.regex.PatternPREFIX_PATTERNPatter should check if prefix has only !^@ without duplicatesprotected static java.lang.StringPREFIX_SIMPLE_KEYSprotected static java.lang.StringSIMPLE_KEYS
-
Constructor Summary
Constructors Constructor Description DefaultKeyboardSupportService()Initialize binding between key codes and it's string representations
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKeyEvent(java.lang.String ctrlKeys, org.zkoss.zk.ui.event.KeyEvent keyEvent)Checks if given ctrlKeys contains given keyEventprotected java.lang.StringconvertPrefix(java.lang.String prefix)protected java.lang.StringconvertToKeyEventCode(int key)Converts given key code to it's string representation.java.lang.StringconvertToKeyEventCode(org.zkoss.zk.ui.event.KeyEvent keyEvent)Converts given keyEvent to string representation.protected java.lang.StringgetLabel(java.lang.String key)java.lang.StringgetToolTip(java.lang.String ctrlKeys)Returns a tool tip text for given ctrl keysprotected booleankeyCodesMatch(java.lang.String keyCodeOne, java.lang.String keyCodeTwo)Tells if two keyCodes are equal where modifiers can be in random order.java.lang.StringmergeCtrlKeys(java.lang.String... ctrlKeysArg)Merges given control keys into one string with no duplicates.protected java.util.Set<java.lang.String>splitCtrlKeys(java.lang.String ctrlKeys)Splits given triggerOnKeys in key codesbooleanvalidateCtrlKeys(java.lang.String ctrlKeys)Checks if all ctrl keys are valid
-
-
-
Field Detail
-
PREFIX_SIMPLE_KEYS
protected static final java.lang.String PREFIX_SIMPLE_KEYS
- See Also:
- Constant Field Values
-
PREFIX_FUNCTION_KEYS
protected static final java.lang.String PREFIX_FUNCTION_KEYS
- See Also:
- Constant Field Values
-
FUNCTION_KEYS
protected static final java.lang.String FUNCTION_KEYS
- See Also:
- Constant Field Values
-
SIMPLE_KEYS
protected static final java.lang.String SIMPLE_KEYS
- See Also:
- Constant Field Values
-
PATTERN
protected static final java.util.regex.Pattern PATTERN
Patter should find for given @0@b@#ins^1^c^#del$2$d$#bak#f10 following groups "@0", "@b", "@#ins", "^1", "^c", "^#del", "$2", "$d", "$#bak", "#f10".
-
PREFIX_PATTERN
protected static final java.util.regex.Pattern PREFIX_PATTERN
Patter should check if prefix has only !^@ without duplicates
-
-
Method Detail
-
splitCtrlKeys
protected java.util.Set<java.lang.String> splitCtrlKeys(java.lang.String ctrlKeys)
Splits given triggerOnKeys in key codes- Parameters:
ctrlKeys- triggerOnKeys e.g. "@0^c$#del#f10"- Returns:
- set with following values "@0", "^c","$#del", "#f10"
-
containsKeyEvent
public boolean containsKeyEvent(java.lang.String ctrlKeys, org.zkoss.zk.ui.event.KeyEvent keyEvent)Description copied from interface:KeyboardSupportServiceChecks if given ctrlKeys contains given keyEvent- Specified by:
containsKeyEventin interfaceKeyboardSupportService- Parameters:
ctrlKeys- ctrl keyskeyEvent- key event- Returns:
- true if ctrlKeys contains keyEventCode
KeyboardSupportService.convertToKeyEventCode(KeyEvent)
-
keyCodesMatch
protected boolean keyCodesMatch(java.lang.String keyCodeOne, java.lang.String keyCodeTwo)Tells if two keyCodes are equal where modifiers can be in random order. E.g. @$^#del is equal to $@^#del- Parameters:
keyCodeOne-keyCodeTwo- $@^#del- Returns:
- true
-
mergeCtrlKeys
public java.lang.String mergeCtrlKeys(java.lang.String... ctrlKeysArg)
Description copied from interface:KeyboardSupportServiceMerges given control keys into one string with no duplicates. All ctrl keys are transformed to lowercase- Specified by:
mergeCtrlKeysin interfaceKeyboardSupportService- Parameters:
ctrlKeysArg- list of triggerOnKeys e.g. @0@b@#ins and @1@c@#ins- Returns:
- merged control keys e.g. @0@b@#ins@1@c
-
validateCtrlKeys
public boolean validateCtrlKeys(java.lang.String ctrlKeys)
Description copied from interface:KeyboardSupportServiceChecks if all ctrl keys are valid- Specified by:
validateCtrlKeysin interfaceKeyboardSupportService- Parameters:
ctrlKeys- ctrl keys valid.- Returns:
- true if ctrl keys are valid.
-
convertToKeyEventCode
protected java.lang.String convertToKeyEventCode(int key)
Converts given key code to it's string representation.- Parameters:
key-KeyEvent.DELETEwhich is represented by 46- Returns:
- string representation of key e.g. #del
-
convertToKeyEventCode
public java.lang.String convertToKeyEventCode(org.zkoss.zk.ui.event.KeyEvent keyEvent)
Description copied from interface:KeyboardSupportServiceConverts given keyEvent to string representation. It will contain one of prefixesKeyboardSupportService.SHIFT_PREFIX,KeyboardSupportService.ALT_PREFIXorKeyboardSupportService.CTRL_PREFIXdepending on modifiers inKeyEvent.isShiftKey(),KeyEvent.isAltKey(),KeyEvent.isCtrlKey()e.g.
KeyEvent.DELETEwhich is represented by 46 and SHIFT pressed it should return $#del- Specified by:
convertToKeyEventCodein interfaceKeyboardSupportService- Parameters:
keyEvent- key event- Returns:
- string representation with modifier
-
getToolTip
public java.lang.String getToolTip(java.lang.String ctrlKeys)
Description copied from interface:KeyboardSupportServiceReturns a tool tip text for given ctrl keys- Specified by:
getToolTipin interfaceKeyboardSupportService- Parameters:
ctrlKeys- control keys- Returns:
- tool tip text
-
convertPrefix
protected java.lang.String convertPrefix(java.lang.String prefix)
-
getLabel
protected java.lang.String getLabel(java.lang.String key)
-
-