Class CachingKeyboardShortcutManager
- All Implemented Interfaces:
KeyboardShortcutManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.plugin.keyboardshortcut.KeyboardShortcutManager
KeyboardShortcutManager.Context, KeyboardShortcutManager.Operation -
Constructor Summary
ConstructorsConstructorDescriptionCachingKeyboardShortcutManager(BuildUtilsInfo buildUtilsInfo, com.atlassian.plugin.PluginAccessor pluginAccessor, com.atlassian.plugin.webresource.WebResourceIntegration webResourceIntegration, JiraAuthenticationContext authenticationContext, UserPreferencesManager userPreferencesManager) -
Method Summary
Modifier and TypeMethodDescriptionReturns an ordered list of allKeyboardShortcuts available using the plugin descriptor's 'order' attribute for sorting.Returns a URL to be used to include the currently registered keyboard shortcuts in a page.booleanReturns if the user has keyboard shortcuts enabled.listActiveShortcutsUniquePerContext(Map<String, Object> userContext) Returns an ordered list of activeKeyboardShortcuts, sorted using the plugin descriptor'sorderattribute.voidonClearCache(ClearCacheEvent event) voidregisterShortcut(String pluginModuleKey, KeyboardShortcut shortcut) Given a complete plugin module key, this method registers a keyboard shortcut with the manager, which will make it available in the UI to end-users.voidRegister that the keyboard shortcuts for the context should be included byKeyboardShortcutManager.includeShortcuts()(in addition to theglobalshortcuts, which are always included).voidunregisterShortcut(String pluginModuleKey) Removes a keyboard shortcut by its complete plugin module key.
-
Constructor Details
-
CachingKeyboardShortcutManager
public CachingKeyboardShortcutManager(BuildUtilsInfo buildUtilsInfo, com.atlassian.plugin.PluginAccessor pluginAccessor, com.atlassian.plugin.webresource.WebResourceIntegration webResourceIntegration, JiraAuthenticationContext authenticationContext, UserPreferencesManager userPreferencesManager)
-
-
Method Details
-
onClearCache
-
registerShortcut
Description copied from interface:KeyboardShortcutManagerGiven a complete plugin module key, this method registers a keyboard shortcut with the manager, which will make it available in the UI to end-users.- Specified by:
registerShortcutin interfaceKeyboardShortcutManager- Parameters:
pluginModuleKey- the complete plugin module key for this keyboard shortcutshortcut- the shortcut to register
-
unregisterShortcut
Description copied from interface:KeyboardShortcutManagerRemoves a keyboard shortcut by its complete plugin module key.- Specified by:
unregisterShortcutin interfaceKeyboardShortcutManager- Parameters:
pluginModuleKey- the key to remove
-
listActiveShortcutsUniquePerContext
Description copied from interface:KeyboardShortcutManagerReturns an ordered list of activeKeyboardShortcuts, sorted using the plugin descriptor'sorderattribute.A shortcut is considered active if
- All conditions attached to the keyboard shortcut are fulfilled, so that the current user is allowed to use it.
- It has not been overridden by another shortcut of the same
KeyboardShortcutManager.Contextthat uses the same key combination and has a greater value in itsorderattribute (see the keyboard shortcut plugin module documentation). Thus this list can contain multiple shortcuts with the same key combination, which all belong to a different context.
Be aware, that this operation is potentially expensive, depending on the number and type of conditions attached to the keyboard shortcuts. So store the result in favour of recalculating it.
- Specified by:
listActiveShortcutsUniquePerContextin interfaceKeyboardShortcutManager- Parameters:
userContext- the context to be used when evaluating, whether the user is allowed to use the shortcut; notnull- Returns:
- ordered list of all active keyboard shortcuts, no duplicate shortcuts per
KeyboardShortcutManager.Context; notnull
-
getAllShortcuts
Description copied from interface:KeyboardShortcutManagerReturns an ordered list of allKeyboardShortcuts available using the plugin descriptor's 'order' attribute for sorting. Implementations should take care to implement this method as quickly as possible since it will be called very often.Note this method returns all registered shortcuts, even if they are not in effect (e.g. they have been overridden). This means that this method may return duplicate shortcuts.
- Specified by:
getAllShortcutsin interfaceKeyboardShortcutManager- Returns:
- ordered list of all registered keyboard shortcuts
- See Also:
-
requireShortcutsForContext
Description copied from interface:KeyboardShortcutManagerRegister that the keyboard shortcuts for the context should be included byKeyboardShortcutManager.includeShortcuts()(in addition to theglobalshortcuts, which are always included).- Specified by:
requireShortcutsForContextin interfaceKeyboardShortcutManager- Parameters:
context- the context whose keyboard shortcuts should be included (in addition toglobal).
-
includeShortcuts
Description copied from interface:KeyboardShortcutManagerReturns a URL to be used to include the currently registered keyboard shortcuts in a page. The URL should point to the Keyboard Shortcut REST resource. Generally this URL will look something like:/rest/api/1.0/shortcuts/500/f1e3b05a6e6db41e5b77fb8afd7ddde9/shortcuts.jsIt has been suggested that webresources (with say the systemcounter) would be a good fit for this, however the problem is that the systemcounter would have to be updated everytime a plugin is enabled/disabled (so everytime JIRA is started up), which would have some adverse side effects:
- The system counter would get really large eventually
- All webresources would no longer be cached after a restart of JIRA and would have to be downloaded again.
It does not contain the applications context path. Also, the hash included at the end of the URL should be a hash of all keyboard shortcuts currently available such that the resource can be cached indefinitely. If a new shortcut is registered (or an old shortcut unregistered), then the hash should obviously change.
- Specified by:
includeShortcutsin interfaceKeyboardShortcutManager- Returns:
- URL pointing to a REST resource to included keyboard shortcuts. The URL will be correctly URL-escaped, but it is not HTML escaped.
- See Also:
-
isKeyboardShortcutsEnabled
public boolean isKeyboardShortcutsEnabled()Description copied from interface:KeyboardShortcutManagerReturns if the user has keyboard shortcuts enabled. If the user is not logged in this will default to true- Specified by:
isKeyboardShortcutsEnabledin interfaceKeyboardShortcutManager- Returns:
- boolean indicating if the user has keyboard shortcuts enabled. Defaults to true if the user is not logged in.
-