|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alee.managers.hotkey.HotkeyManager
public class HotkeyManager
This manager allows you to quickly register global hotkeys (like accelerators on menu items in menubar menus) for any Swing component. Additionally you can specify a component which will limit hotkey events to its area (meaning that hotkey event will occur only if this component or any of its childs is focused when hotkey pressed).
TooltipManager is integrated with this manager to automatically show component hotkeys in its tooltip if needed/allowed by tooltip and hotkey settings. All hotkeys are stored into WeakHashMap so hotkeys will be removed as soon as the component for which hotkey is registered gets finalized. HotkeyInfo also keeps a weak reference to both top and hotkey components.
Field Summary | |
---|---|
static java.lang.String |
COMPONENT_HOTKEYS_LIST_KEY
Keys used to store custom data in JComponent. |
static java.lang.String |
CONTAINER_HOTKEY_CONDITIONS_LIST_KEY
|
protected static java.util.Map<javax.swing.JComponent,java.lang.ref.WeakReference<java.util.List<HotkeyCondition>>> |
containerConditions
Conditions for top components which might. |
protected static java.util.List<HotkeyInfo> |
globalHotkeys
Global hotkeys list. |
protected static Filter<HotkeyInfo> |
HOTKEY_DISPLAY_FILTER
Displayed hotkeys filter. |
protected static TextProvider<HotkeyInfo> |
HOTKEY_TEXT_PROVIDER
HotkeyInfo text provider. |
protected static java.util.Map<javax.swing.JComponent,java.lang.ref.WeakReference<java.util.List<HotkeyInfo>>> |
hotkeys
Added hotkeys. |
protected static java.lang.String |
HOTKEYS_SEPARATOR
Separator used between multiply hotkeys displayed in a single line. |
protected static boolean |
hotkeysEnabled
Global hotkeys block flag. |
protected static boolean |
initialized
Initialization mark. |
protected static java.lang.Object |
sync
Synchronization object. |
protected static boolean |
transferFocus
Pass focus to fired hotkey component. |
Constructor Summary | |
---|---|
HotkeyManager()
|
Method Summary | |
---|---|
static void |
addContainerHotkeyCondition(javax.swing.JComponent container,
HotkeyCondition hotkeyCondition)
Sets top component additional hotkey trigger condition |
protected static void |
cacheHotkey(HotkeyInfo hotkeyInfo)
Hotkeys cache methods |
protected static void |
clearHotkeyCache(HotkeyInfo hotkeyInfo)
|
protected static void |
clearHotkeysCache(javax.swing.JComponent component)
|
protected static void |
clearHotkeysCache(java.util.List<HotkeyInfo> hotkeysInfo)
|
protected static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> |
copyComponentHotkeys()
Returns a full copy of hotkeys map. |
protected static java.util.Map<javax.swing.JComponent,java.util.List<HotkeyCondition>> |
copyContainerConditions()
Returns a full copy of container conditions map. |
protected static HotkeyRunnable |
createAction(javax.swing.AbstractButton forComponent)
|
static void |
disableHotkeys()
Global hotkey block |
static void |
enableHotkeys()
|
static java.util.List<HotkeyInfo> |
getComponentHotkeys(javax.swing.JComponent component)
|
protected static java.util.List<HotkeyInfo> |
getComponentHotkeysCache(javax.swing.JComponent forComponent)
|
static java.lang.String |
getComponentHotkeysString(javax.swing.JComponent component)
All component hotkeys list |
static java.util.List<HotkeyCondition> |
getContainerHotkeyConditions(javax.swing.JComponent container)
|
protected static java.util.List<HotkeyCondition> |
getContainerHotkeyConditionsCache(javax.swing.JComponent container)
|
protected static boolean |
hotkeyForEventExists(java.awt.event.KeyEvent keyEvent)
Returns whether at least one hotkey for the specified key event exists or not. |
static void |
initialize()
Initializes hotkey manager. |
static void |
installShowAllHotkeysAction(javax.swing.JComponent topComponent)
Installs "show all hotkeys" action on window or component |
static void |
installShowAllHotkeysAction(javax.swing.JComponent topComponent,
HotkeyData hotkeyData)
|
static boolean |
isTransferFocus()
Should transfer focus to fired hotkey component or not |
protected static boolean |
meetsParentConditions(java.awt.Component forComponent)
|
protected static void |
processHotkey(java.awt.event.KeyEvent e,
HotkeyInfo hotkeyInfo)
Processes single hotkey. |
protected static void |
processHotkeys(java.awt.event.KeyEvent e)
Processes all available registered hotkeys. |
static HotkeyInfo |
registerHotkey(javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData)
Button-specific hotkey register methods |
static HotkeyInfo |
registerHotkey(javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.JComponent forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.JComponent forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.JComponent forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
boolean hidden,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.JComponent forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(HotkeyData hotkeyData,
HotkeyRunnable action)
Hotkey register methods |
static HotkeyInfo |
registerHotkey(javax.swing.JComponent forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action)
|
static HotkeyInfo |
registerHotkey(javax.swing.JComponent forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
boolean hidden)
|
static void |
removeContainerHotkeyCondition(javax.swing.JComponent container,
HotkeyCondition hotkeyCondition)
|
static void |
removeContainerHotkeyConditions(javax.swing.JComponent container)
|
static void |
removeContainerHotkeyConditions(javax.swing.JComponent container,
java.util.List<HotkeyCondition> hotkeyConditions)
|
static void |
setComponentHotkeyDisplayWay(javax.swing.JComponent component,
TooltipWay tooltipWay)
Sets component hotkey tip way |
static void |
setTransferFocus(boolean transferFocus)
|
static void |
showComponentHotkeys()
Shows all visible components hotkeys |
static void |
showComponentHotkeys(java.awt.Component component)
|
protected static void |
showComponentHotkeys(java.awt.Window window)
|
static void |
unregisterHotkey(HotkeyInfo hotkeyInfo)
Hotkey removal methods |
static void |
unregisterHotkeys(javax.swing.JComponent component)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMPONENT_HOTKEYS_LIST_KEY
public static final java.lang.String CONTAINER_HOTKEY_CONDITIONS_LIST_KEY
protected static final java.lang.String HOTKEYS_SEPARATOR
protected static final TextProvider<HotkeyInfo> HOTKEY_TEXT_PROVIDER
protected static final Filter<HotkeyInfo> HOTKEY_DISPLAY_FILTER
protected static final java.lang.Object sync
protected static boolean hotkeysEnabled
protected static boolean transferFocus
protected static java.util.Map<javax.swing.JComponent,java.lang.ref.WeakReference<java.util.List<HotkeyInfo>>> hotkeys
protected static java.util.List<HotkeyInfo> globalHotkeys
protected static java.util.Map<javax.swing.JComponent,java.lang.ref.WeakReference<java.util.List<HotkeyCondition>>> containerConditions
protected static boolean initialized
Constructor Detail |
---|
public HotkeyManager()
Method Detail |
---|
public static void initialize()
protected static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> copyComponentHotkeys()
protected static java.util.Map<javax.swing.JComponent,java.util.List<HotkeyCondition>> copyContainerConditions()
protected static boolean hotkeyForEventExists(java.awt.event.KeyEvent keyEvent)
keyEvent
- key event to search hotkeys for
protected static void processHotkeys(java.awt.event.KeyEvent e)
e
- key eventprotected static void processHotkey(java.awt.event.KeyEvent e, HotkeyInfo hotkeyInfo)
e
- key eventhotkeyInfo
- hotkey informationprotected static boolean meetsParentConditions(java.awt.Component forComponent)
public static HotkeyInfo registerHotkey(HotkeyData hotkeyData, HotkeyRunnable action)
public static HotkeyInfo registerHotkey(javax.swing.JComponent forComponent, HotkeyData hotkeyData, HotkeyRunnable action)
public static HotkeyInfo registerHotkey(javax.swing.JComponent forComponent, HotkeyData hotkeyData, HotkeyRunnable action, boolean hidden)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.JComponent forComponent, HotkeyData hotkeyData, HotkeyRunnable action)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.JComponent forComponent, HotkeyData hotkeyData, HotkeyRunnable action, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.JComponent forComponent, HotkeyData hotkeyData, HotkeyRunnable action, boolean hidden)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.JComponent forComponent, HotkeyData hotkeyData, HotkeyRunnable action, boolean hidden, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(javax.swing.AbstractButton forComponent, HotkeyData hotkeyData)
public static HotkeyInfo registerHotkey(javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, boolean hidden)
public static HotkeyInfo registerHotkey(javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.AbstractButton forComponent, HotkeyData hotkeyData)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, boolean hidden)
protected static HotkeyRunnable createAction(javax.swing.AbstractButton forComponent)
public static void setComponentHotkeyDisplayWay(javax.swing.JComponent component, TooltipWay tooltipWay)
public static void addContainerHotkeyCondition(javax.swing.JComponent container, HotkeyCondition hotkeyCondition)
public static void removeContainerHotkeyCondition(javax.swing.JComponent container, HotkeyCondition hotkeyCondition)
public static void removeContainerHotkeyConditions(javax.swing.JComponent container, java.util.List<HotkeyCondition> hotkeyConditions)
public static void removeContainerHotkeyConditions(javax.swing.JComponent container)
protected static java.util.List<HotkeyCondition> getContainerHotkeyConditionsCache(javax.swing.JComponent container)
public static java.util.List<HotkeyCondition> getContainerHotkeyConditions(javax.swing.JComponent container)
public static void unregisterHotkey(HotkeyInfo hotkeyInfo)
public static void unregisterHotkeys(javax.swing.JComponent component)
protected static void cacheHotkey(HotkeyInfo hotkeyInfo)
protected static void clearHotkeyCache(HotkeyInfo hotkeyInfo)
protected static void clearHotkeysCache(java.util.List<HotkeyInfo> hotkeysInfo)
protected static void clearHotkeysCache(javax.swing.JComponent component)
protected static java.util.List<HotkeyInfo> getComponentHotkeysCache(javax.swing.JComponent forComponent)
public static java.util.List<HotkeyInfo> getComponentHotkeys(javax.swing.JComponent component)
public static void showComponentHotkeys()
public static void showComponentHotkeys(java.awt.Component component)
protected static void showComponentHotkeys(java.awt.Window window)
public static void installShowAllHotkeysAction(javax.swing.JComponent topComponent)
public static void installShowAllHotkeysAction(javax.swing.JComponent topComponent, HotkeyData hotkeyData)
public static java.lang.String getComponentHotkeysString(javax.swing.JComponent component)
public static void disableHotkeys()
public static void enableHotkeys()
public static boolean isTransferFocus()
public static void setTransferFocus(boolean transferFocus)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |