Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.keybindings
Class KeybindingsServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.keybindings.KeybindingsServiceImpl
All Implemented Interfaces:
Observer, KeybindingsService

 class KeybindingsServiceImpl
extends Object
implements KeybindingsService, Observer

Service that concerns keybinding mappings used by various parts of the UI. Persistence is handled as follows when started:

  1. Load default bindings from relative directory
  2. Attempt to load custom bindings and resolve any duplicates
  3. If merged bindings differ from the custom bindings then this attempts to save the merged version
Custom bindings attempt to be written again whenever they're changed if the service is running. Each category of keybindings are stored in its own file.

Author:
Damian Johnson

Constructor Summary
KeybindingsServiceImpl()
           
 
Method Summary
 KeybindingSet getBindings(KeybindingSet.Category category)
          Provides the bindings associated with a given category.
 GlobalKeybindingSet getGlobalBindings()
          Provides the bindings associated with the global category.
 Map<String,List<AWTKeyStroke>> getGlobalShortcutFromConfiguration()
          Returns list of global shortcuts from the configuration file.
 void saveGlobalShortcutFromConfiguration()
          Save the configuration file.
(package private)  void start(org.osgi.framework.BundleContext bc)
          Starts the KeybindingService, for each keybinding category retrieving the default bindings then overwriting them with any custom bindings that can be retrieved.
(package private)  void stop()
          Invalidates references to custom bindings, preventing further writes.
 void update(Observable obs, Object arg)
          Listens for changes in binding sets so changes can be written.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeybindingsServiceImpl

KeybindingsServiceImpl()
Method Detail

start

void start(org.osgi.framework.BundleContext bc)
Starts the KeybindingService, for each keybinding category retrieving the default bindings then overwriting them with any custom bindings that can be retrieved. This writes the merged copy back if it differs from the custom bindings. This is a no-op if the service has already been started.

Parameters:
bc - the currently valid OSGI bundle context.

stop

void stop()
Invalidates references to custom bindings, preventing further writes.


getBindings

public KeybindingSet getBindings(KeybindingSet.Category category)
Provides the bindings associated with a given category. This may be null if the default bindings failed to be loaded.

Specified by:
getBindings in interface KeybindingsService
Parameters:
category - segment of the UI for which bindings should be retrieved
Returns:
mappings of keystrokes to the string representation of their actions
Throws:
UnsupportedOperationException - if the service isn't running

update

public void update(Observable obs,
                   Object arg)
Listens for changes in binding sets so changes can be written.

Specified by:
update in interface Observer

getGlobalShortcutFromConfiguration

public Map<String,List<AWTKeyStroke>> getGlobalShortcutFromConfiguration()
Returns list of global shortcuts from the configuration file.

Specified by:
getGlobalShortcutFromConfiguration in interface KeybindingsService
Returns:
list of global shortcuts.

saveGlobalShortcutFromConfiguration

public void saveGlobalShortcutFromConfiguration()
Save the configuration file.

Specified by:
saveGlobalShortcutFromConfiguration in interface KeybindingsService

getGlobalBindings

public GlobalKeybindingSet getGlobalBindings()
Provides the bindings associated with the global category.

Specified by:
getGlobalBindings in interface KeybindingsService
Returns:
global keybinding set

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.