kss = entry.getValue();
+ String path = CONFIGURATION_PATH;
+
+ if(key.equals("answer"))
+ {
+ path += ".answer";
+ }
+ else if(key.equals("hangup"))
+ {
+ path += ".hangup";
+ }
+ else if(key.equals("contactlist"))
+ {
+ path += ".contactlist";
+ }
+
+ shortcut = path + ".1";
+ shortcut2 = path + ".2";
+ configService.setProperty(shortcut, kss.size() > 0 ?
+ kss.get(0) : null);
+ configService.setProperty(shortcut2, kss.size() > 1 ?
+ kss.get(1) : null);
+ }
+ }
+
+ /**
+ * Provides the bindings associated with the global category.
+ *
+ * @return global keybinding set
+ */
+ public GlobalKeybindingSet getGlobalBindings()
+ {
+ return globalBindings;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf b/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf
index dfacbec69..a9634150b 100644
--- a/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf
+++ b/src/net/java/sip/communicator/impl/keybindings/keybindings.manifest.mf
@@ -8,5 +8,6 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
net.java.sip.communicator.service.fileaccess,
net.java.sip.communicator.service.gui,
+ net.java.sip.communicator.service.configuration,
javax.swing
Export-Package: net.java.sip.communicator.service.keybindings
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java
index 39dc4dfee..29e9d1278 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java
@@ -8,7 +8,10 @@
import java.util.*;
+import net.java.sip.communicator.service.configuration.*;
+import net.java.sip.communicator.service.globalshortcut.*;
import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.keybindings.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
@@ -16,7 +19,7 @@
/**
* Enabling and disabling osgi functionality for the keybinding chooser.
- *
+ *
* @author Damian Johnson
*/
public class KeybindingChooserActivator
@@ -38,6 +41,21 @@ public class KeybindingChooserActivator
*/
public static ResourceManagementService resourcesService;
+ /**
+ * Reference to the configuration service
+ */
+ private static ConfigurationService configService;
+
+ /**
+ * Reference to the keybinding service
+ */
+ private static KeybindingsService keybindingService = null;
+
+ /**
+ * Reference to the global shortcut service
+ */
+ private static GlobalShortcutService globalShortcutService = null;
+
/**
* Starts this bundle and adds the
* KeybindingsConfigPanel contained in it to the configuration
@@ -93,4 +111,67 @@ public static ResourceManagementService getResources()
ResourceManagementServiceUtils.getService(bundleContext);
return resourcesService;
}
+
+ /**
+ * Returns a reference to a ConfigurationService implementation currently
+ * registered in the bundle context or null if no such implementation was
+ * found.
+ *
+ * @return a currently valid implementation of the ConfigurationService.
+ */
+ public static ConfigurationService getConfigService()
+ {
+ if(configService == null)
+ {
+ ServiceReference confReference
+ = bundleContext.getServiceReference(
+ ConfigurationService.class.getName());
+ configService
+ = (ConfigurationService) bundleContext.getService(
+ confReference);
+ }
+ return configService;
+ }
+
+ /**
+ * Returns a reference to a KeybindingsService implementation currently
+ * registered in the bundle context or null if no such implementation was
+ * found.
+ *
+ * @return a currently valid implementation of the KeybindingsService.
+ */
+ public static KeybindingsService getKeybindingsService()
+ {
+ if(keybindingService == null)
+ {
+ ServiceReference keybindingReference
+ = bundleContext.getServiceReference(
+ KeybindingsService.class.getName());
+ keybindingService
+ = (KeybindingsService) bundleContext.getService(
+ keybindingReference);
+ }
+ return keybindingService;
+ }
+
+ /**
+ * Returns a reference to a GlobalShortcutService implementation currently
+ * registered in the bundle context or null if no such implementation was
+ * found.
+ *
+ * @return a currently valid implementation of the GlobalShortcutService.
+ */
+ public static GlobalShortcutService getGlobalShortcutService()
+ {
+ if(globalShortcutService == null)
+ {
+ ServiceReference globalShortcutReference
+ = bundleContext.getServiceReference(
+ GlobalShortcutService.class.getName());
+ globalShortcutService
+ = (GlobalShortcutService) bundleContext.getService(
+ globalShortcutReference);
+ }
+ return globalShortcutService;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigPanel.java b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigPanel.java
index 1926b3218..40a2a74d8 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigPanel.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingsConfigPanel.java
@@ -15,13 +15,14 @@
import org.osgi.framework.*;
import net.java.sip.communicator.plugin.keybindingchooser.chooser.*;
+import net.java.sip.communicator.plugin.keybindingchooser.globalchooser.*;
import net.java.sip.communicator.service.keybindings.*;
import net.java.sip.communicator.util.swing.*;
/**
* The ConfigurationForm that would be added to the settings
* configuration to configure the application keybindings.
- *
+ *
* @author Damian Johnson
* @author Lubomir Marinov
*/
@@ -44,6 +45,9 @@ private static KeybindingsService getKeybindingsService()
private final HashMap choosers =
new HashMap();
+ /**
+ * Constructor.
+ */
public KeybindingsConfigPanel()
{
super(new BorderLayout());
@@ -74,7 +78,7 @@ public void focusLost(FocusEvent event)
continue; // defaults failed to load
SIPChooser newChooser = new SIPChooser();
- newChooser.putAllBindings(bindingSet.getBindings());
+ newChooser.putAllBindings(bindingSet);
JPanel chooserWrapper = new TransparentPanel(new BorderLayout());
chooserWrapper.add(newChooser, BorderLayout.NORTH);
@@ -88,25 +92,12 @@ public void focusLost(FocusEvent event)
this.choosers.put(bindingSet, newChooser);
}
- add(chooserPanes);
-
- JButton apply = new JButton(
- KeybindingChooserActivator.getResources()
- .getI18NString("service.gui.APPLY"));
+ // global shortcut
+ GlobalShortcutConfigForm globalBindingPanel =
+ new GlobalShortcutConfigForm();
+ chooserPanes.addTab("Global shortcut", globalBindingPanel);
- apply.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- for (KeybindingSet set : choosers.keySet())
- set.setBindings(choosers.get(set).getBindingMap());
- }
- });
-
- JPanel bottomWrapper =
- new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
- bottomWrapper.add(apply);
- add(bottomWrapper, BorderLayout.SOUTH);
+ add(chooserPanes);
}
/**
@@ -114,7 +105,7 @@ public void actionPerformed(ActionEvent event)
* underscores and this changes the input to lowercase except the first
* letter of each word. For instance, "RARE_CARDS" would become "Rare
* Cards".
- *
+ *
* @param input string to be converted
* @return reader friendly variant of constant name
*/
@@ -188,7 +179,7 @@ public boolean putBinding(BindingEntry newEntry, int index)
* given in its plugin-specific format. The key is translated to the
* global format of the ReouseceManagementService and the translated key
* is used to retrieve the string from the resource files.
- *
+ *
* @param key the key of the string to be retrieved given in its
* plugin-specific format
* @return the internationalized string corresponding to a specific key
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingAdaptor.java b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingAdaptor.java
index fc5d559d6..31f0fb009 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingAdaptor.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingAdaptor.java
@@ -1,3 +1,9 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package net.java.sip.communicator.plugin.keybindingchooser.chooser;
import java.awt.event.*;
@@ -9,7 +15,7 @@
* BindingChooser. This can be added to focused components to provide editing
* functionality for this chooser. This prevents duplicate entries and varies
* how it captures input according to the type of key event its set to capture.
- *
+ *
* @author Damian Johnson (atagar1@gmail.com)
* @version August 19, 2007
*/
@@ -36,7 +42,7 @@ public class BindingAdaptor
/**
* Provides if bindings are currently disableable via generated key adaptors
* or not.
- *
+ *
* @return true if input can disable bindings, false otherwise.
*/
public boolean isBindingDisablingEnabled()
@@ -47,7 +53,7 @@ public boolean isBindingDisablingEnabled()
/**
* Sets if bindings can be disabled via generated key adaptors with the
* disabling key code. By default this is false.
- *
+ *
* @param enable if true then input can disable bindings, otherwise bindings
* may not be disabled
*/
@@ -59,7 +65,7 @@ public void setBindingsDisableable(boolean enable)
/**
* Provides the keycode that can be input to generated key adaptors to
* disable key bindings.
- *
+ *
* @return keycode of disabling input
*/
public int getDisablingKeyCode()
@@ -72,7 +78,7 @@ public int getDisablingKeyCode()
* from returned mappings) via generated key adaptors. This only works if
* the set event type is KEY_PRESSED or KEY_RELEASED since KEY_TYPED events
* fail to provide keycodes. By default this is VK_ESCAPE.
- *
+ *
* @param keycode keycode that sets selected entry to a disabled state
*/
public void setDisablingKeyCode(int keycode)
@@ -83,7 +89,7 @@ public void setDisablingKeyCode(int keycode)
/**
* Provides the type of keystroke registered by input via generated key
* adaptors.
- *
+ *
* @return type of input detected by generated key adaptors
*/
public int getInputEventType()
@@ -95,7 +101,7 @@ public int getInputEventType()
* Sets the type of keystroke registered by input via generated key adaptors
* (by default KeyEvent.KEY_PRESSED). This must be a valid type of key event
* which includes: KEY_PRESSED, KEY_RELEASED, or KEY_TYPED.
- *
+ *
* @param type type of keystroke registered by input
* @throws IllegalArgumentException if type doesn't match a valid key event
*/
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java
index 7ab7ab779..96f52438c 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java
@@ -1,3 +1,9 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package net.java.sip.communicator.plugin.keybindingchooser.chooser;
import java.awt.*;
@@ -6,6 +12,7 @@
import javax.swing.*;
+import net.java.sip.communicator.service.keybindings.*;
import net.java.sip.communicator.util.swing.*;
/**
@@ -17,7 +24,7 @@
* particularly recommended unless automated changes to the appearance (the
* indentation style and color scheme) are disabled since they may be
* unexpectedly reverted or clash any alterations made.
- *
+ *
* @author Damian Johnson (atagar1@gmail.com)
* @version September 1, 2007
*/
@@ -35,13 +42,18 @@ public class BindingChooser
private String selectedText = "Press shortcut...";
+ /**
+ * Keybinding set.
+ */
+ private KeybindingSet set = null;
+
/**
* Displays a dialog allowing the user to redefine the keystroke component
* of key bindings. The top has light blue labels describing the fields and
* the bottom provides an 'OK' and 'Cancel' option. This uses the default
* color scheme and indent style. If no entries are selected then the enter
* key is equivalent to pressing 'OK' and escape is the same as 'Cancel'.
- *
+ *
* @param parent frame to which to apply modal property and center within
* (centers within screen if null)
* @param bindings initial mapping of keystrokes to their actions
@@ -57,6 +69,20 @@ public static LinkedHashMap showDialog(Component parent,
.makeAdaptor());
}
+ /**
+ * Adds a collection of new key binding mappings to the end of the listing.
+ * If any shortcuts are already contained then the previous entries are
+ * replaced (not triggering the onUpdate method). Disabled shortcuts trigger
+ * replacement on duplicate actions instead.
+ *
+ * @param set mapping between keystrokes and actions to be added
+ */
+ public void putAllBindings(KeybindingSet set)
+ {
+ this.set = set;
+ putAllBindings(set.getBindings());
+ }
+
/**
* Displays a dialog allowing the user to redefine the keystroke component
* of key bindings. The bottom provides an 'OK' and 'Cancel' option. If no
@@ -67,7 +93,7 @@ public static LinkedHashMap showDialog(Component parent,
* setting the selected shortcut field. Also note that labels use the
* default entry size and should be omitted if using content with custom
* dimensions.
- *
+ *
* @param parent frame to which to apply modal property and center within
* (centers within screen if null)
* @param display body of the display, containing current bindings and
@@ -185,7 +211,7 @@ protected void onClick(MouseEvent event, BindingEntry entry,
/**
* Sets if the shortcut fields of entries can be selected to provide editing
* functionality or not. If false, any selected entry is deselected.
- *
+ *
* @param editable if true shortcut fields may be selected to have their
* values changed, otherwise user input and calls to the
* setSelected method are ignored
@@ -201,7 +227,7 @@ public void setEditable(boolean editable)
/**
* Provides the indent style used by the chooser.
- *
+ *
* @return type of content in the indent field
*/
public IndentStyle getIndentStyle()
@@ -212,7 +238,7 @@ public IndentStyle getIndentStyle()
/**
* Sets content display in the indent field of entries. This will prompt an
* onUpdate on all entries unless setting the style to NONE.
- *
+ *
* @param style type of content displayed in entry's indent field
*/
public void setIndentStyle(IndentStyle style)
@@ -231,7 +257,7 @@ public void setIndentStyle(IndentStyle style)
/**
* Sets the message of the selected shortcut field when awaiting user input.
* By default this is "Press shortcut...".
- *
+ *
* @param message prompt for user input
*/
public void setSelectedText(String message)
@@ -246,7 +272,7 @@ public void setSelectedText(String message)
/**
* Returns if a binding is currently awaiting input or not.
- *
+ *
* @return true if a binding is awaiting input, false otherwise
*/
public boolean isBindingSelected()
@@ -256,7 +282,7 @@ public boolean isBindingSelected()
/**
* Provides the currently selected entry if awaiting input.
- *
+ *
* @return entry currently awaiting input, if one exists
*/
public BindingEntry getSelected()
@@ -270,7 +296,7 @@ public BindingEntry getSelected()
* currently selected entry is deselected. If null, then this simply reverts
* any selections (leaving no entry selected). The onUpdate method is called
* whenever an entry is either selected or deselected.
- *
+ *
* @param entry binding entry awaiting input for its shortcut field
* @throws IllegalArgumentException if entry is not contained in chooser
*/
@@ -311,7 +337,7 @@ public void setSelected(BindingEntry entry)
/**
* Provides a key adaptor that can provide editing functionality for the
* selected entry.
- *
+ *
* @return binding adaptor configured to this chooser
*/
public BindingAdaptor makeAdaptor()
@@ -363,7 +389,7 @@ else if (field == BindingEntry.Field.SHORTCUT)
/**
* Emulates keyboard input, setting the selected entry's shortcut if an
* entry's currently awaiting input.
- *
+ *
* @param input keystroke input for selected entry
*/
void doInput(KeyStroke input)
@@ -371,6 +397,8 @@ void doInput(KeyStroke input)
if (isBindingSelected())
{
this.selectedEntry.setShortcut(input);
+ //apply configuration
+ set.setBindings(this.getBindingMap());
// TYPE indent can change according to the shortcut
// this.indentStyle.apply(this.selectedEntry,
@@ -408,7 +436,7 @@ public static enum IndentStyle
/**
* Returns the enum representation of a string. This is case sensitive.
- *
+ *
* @param str toString representation of this enum
* @return enum associated with a string
* @throws IllegalArgumentException if argument is not represented by
@@ -480,7 +508,7 @@ public String toString()
* underscores and this changes the input to lowercase except the first
* letter of each word. For instance, "RARE_CARDS" would become
* "Rare Cards".
- *
+ *
* @param input string to be converted
* @return reader friendly variant of constant name
*/
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingEntry.java b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingEntry.java
index 0db0998c8..00abfabe8 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingEntry.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingEntry.java
@@ -1,3 +1,9 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package net.java.sip.communicator.plugin.keybindingchooser.chooser;
import java.awt.*;
@@ -9,7 +15,7 @@
/**
* Display element for a single key binding.
- *
+ *
* @author Damian Johnson (atagar1@gmail.com)
* @version August 7, 2007
*/
@@ -130,7 +136,7 @@ public boolean isDisabled()
/**
* Provides the label associated with a field.
- *
+ *
* @param field element of display to be returned
* @return label associated with field
*/
@@ -165,7 +171,7 @@ public enum Field
* the representation are unspecified and subject to change but the
* following format can be considered to be typical:
* "BindingEntry (" + Shortcut + " \u2192 " + Action + ")"
- *
+ *
* @return string representation of entry
*/
@Override
@@ -188,7 +194,7 @@ public String toString()
* Checks if argument is an instance of this class with the same shortcut
* and associated action. It does not compare aspects of the display
* elements.
- *
+ *
* @param obj element with which to be compared
* @return true if argument is an instance of this class with matching
* shortcut and action, false otherwise
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingPanel.java b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingPanel.java
index f84bca93c..ab9e7ca0f 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingPanel.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingPanel.java
@@ -1,3 +1,9 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package net.java.sip.communicator.plugin.keybindingchooser.chooser;
import java.awt.*;
@@ -22,7 +28,7 @@
* shortcuts aren't supported. An exception is made in the case of disabled
* shortcuts, but to keep mappings unique duplicate actions among disabled
* entries are not permitted.
- *
+ *
* @author Damian Johnson (atagar1@gmail.com)
* @version September 1, 2007
*/
@@ -35,7 +41,7 @@ public abstract class BindingPanel
* Method called whenever an entry is either added or shifts in the display.
* For instance, if the second entry is removed then this is called on the
* third to last elements.
- *
+ *
* @param index newly assigned index of entry
* @param entry entry that has been added or shifted
* @param isNew if true the entry is new to the display, false otherwise
@@ -45,7 +51,7 @@ protected abstract void onUpdate(int index, BindingEntry entry,
/**
* Method called upon any mouse clicks within a BindingEntry in the display.
- *
+ *
* @param event fired mouse event that triggered method call
* @param entry entry on which the click landed
* @param field field of entry on which the click landed, null if not a
@@ -66,13 +72,13 @@ public BindingPanel()
* triggering the onUpdate method). Disabled shortcuts trigger replacement
* on duplicate actions instead. This uses the normal parameters used to
* generate key stokes, such as:
- *
+ *
*
* bindingPanel.putBinding('Y', 0, "Confirm Selection");
* bindingPanel.putBinding(KeyEvent.VK_DELETE, KeyEvent.CTRL_MASK
* | KeyEvent.ALT_MASK, "Kill Process");
*
- *
+ *
* @param keyCode key code of keystroke component of mapping
* @param modifier modifiers of keystroke component of mapping
* @param action string component of mapping
@@ -88,7 +94,7 @@ public boolean putBinding(int keyCode, int modifier, String action)
* contains the shortcut then the previous entry is replaced instead (not
* triggering the onUpdate method). Disabled shortcuts trigger replacement
* on duplicate actions instead.
- *
+ *
* @param shortcut keystroke component of mapping
* @param action string component of mapping
* @return true if contents did not already include shortcut
@@ -103,7 +109,7 @@ public boolean putBinding(KeyStroke shortcut, String action)
* this already contains the shortcut then the previous entry is replaced
* instead (not triggering the onUpdate method). Disabled shortcuts trigger
* replacement on duplicate actions instead.
- *
+ *
* @param shortcut keystroke component of mapping
* @param action string component of mapping
* @param index location in which to insert mapping
@@ -121,7 +127,7 @@ public boolean putBinding(KeyStroke shortcut, String action, int index)
* this already contains the shortcut then the previous entry is replaced
* instead (not triggering the onUpdate method). Disabled shortcuts trigger
* replacement on duplicate actions instead.
- *
+ *
* @param newEntry entry to add to contents
* @param index location in which to insert mapping
* @return true if contents did not already include shortcut
@@ -198,7 +204,7 @@ public boolean putBinding(BindingEntry newEntry, int index)
* If any shortcuts are already contained then the previous entries are
* replaced (not triggering the onUpdate method). Disabled shortcuts trigger
* replacement on duplicate actions instead.
- *
+ *
* @param bindings mapping between keystrokes and actions to be added
*/
public void putAllBindings(Map bindings)
@@ -211,7 +217,7 @@ public void putAllBindings(Map bindings)
/**
* Removes a particular binding from the contents.
- *
+ *
* @param entry binding to be removed
* @return true if binding was in the contents, false otherwise
*/
@@ -226,7 +232,7 @@ public boolean removeBinding(BindingEntry entry)
/**
* Removes the binding at a particular index of the listing.
- *
+ *
* @param index from which to remove entry
* @return the entry that was removed from the contents
* @throws IndexOutOfBoundsException if index is out of range (index < 0 ||
@@ -269,7 +275,7 @@ public void clearBindings()
* Returns if a keystroke is in the panel's current contents. This provides
* a preemptive means of checking if adding a non-disabled shortcut would
* cause a replacement.
- *
+ *
* @param shortcut keystroke to be checked against contents
* @return true if contents includes the shortcut, false otherwise
*/
@@ -293,7 +299,7 @@ public boolean contains(KeyStroke shortcut)
/**
* Provides number of key bindings currently present.
- *
+ *
* @return number of key bindings in the display
*/
public int getBindingCount()
@@ -303,7 +309,7 @@ public int getBindingCount()
/**
* Provides the index of a particular entry.
- *
+ *
* @param entry entry for which the index should be returned
* @return entry index, -1 if not found
*/
@@ -314,7 +320,7 @@ public int getBindingIndex(BindingEntry entry)
/**
* Provides a binding at a particular index.
- *
+ *
* @param index index from which to retrieve binding.
* @return the entry at the specified position in this list
*/
@@ -325,7 +331,7 @@ public BindingEntry getBinding(int index)
/**
* Provides listing of the current keybinding entries.
- *
+ *
* @return list of current entry contents
*/
public ArrayList getBindings()
@@ -336,7 +342,7 @@ public ArrayList getBindings()
/**
* Provides the mapping between keystrokes and actions represented by the
* contents of the display. Disabled entries aren't included in the mapping.
- *
+ *
* @return mapping between contained keystrokes and their associated actions
*/
public LinkedHashMap getBindingMap()
@@ -356,7 +362,7 @@ public LinkedHashMap getBindingMap()
/**
* Provides an input map associating keystrokes to actions according to the
* contents of the display. Disabled entries aren't included in the mapping.
- *
+ *
* @return input mapping between contained keystrokes and their associated
* actions
*/
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutConfigForm.java b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutConfigForm.java
new file mode 100644
index 000000000..7d3806846
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutConfigForm.java
@@ -0,0 +1,311 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.keybindingchooser.globalchooser;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.plugin.keybindingchooser.*;
+import net.java.sip.communicator.service.globalshortcut.*;
+import net.java.sip.communicator.service.keybindings.*;
+import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.util.swing.*;
+
+/**
+ * This ConfigurationForm shows the list of global shortcut
+ *
+ * @author Sebastien Vincent
+ */
+public class GlobalShortcutConfigForm
+ extends TransparentPanel
+ implements ListSelectionListener
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The logger for this class.
+ */
+ private static Logger logger = Logger.getLogger(
+ GlobalShortcutConfigForm.class);
+
+ /**
+ * Displays the registered shortcuts.
+ */
+ private JTable shortcutsTable = new JTable();
+
+ /**
+ * Contains the shortcutsTable.
+ */
+ private JScrollPane scrollPane = new JScrollPane();
+
+ /**
+ * Contains listPanel.
+ */
+ private JPanel mainPanel = this;
+
+ /**
+ * Model for the shortcutsTable
+ */
+ private GlobalShortcutTableModel tableModel =
+ new GlobalShortcutTableModel();
+
+ /**
+ * Current selected row.
+ */
+ private int currentRow = -1;
+
+ /**
+ * Current selected row.
+ */
+ private int currentColumn = -1;
+
+ /**
+ * Constructor
+ */
+ public GlobalShortcutConfigForm()
+ {
+ super(new BorderLayout());
+ logger.trace("New global shortcut configuration form.");
+ this.initComponents();
+ }
+
+ /**
+ * Initialize the swing components.
+ */
+ private void initComponents()
+ {
+ shortcutsTable.setRowHeight(22);
+ shortcutsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ shortcutsTable.setShowHorizontalLines(false);
+ shortcutsTable.setShowVerticalLines(false);
+ shortcutsTable.setModel(tableModel);
+ shortcutsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+ shortcutsTable.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ if(e.getClickCount() >= 1)
+ {
+ int row = GlobalShortcutConfigForm.this.shortcutsTable.
+ getSelectedRow();
+ int column = GlobalShortcutConfigForm.this.shortcutsTable.
+ getSelectedColumn();
+ if(row >= 0 && column >= 1)
+ {
+ currentRow = row;
+ currentColumn = column;
+ }
+ }
+ }
+ });
+
+ shortcutsTable.addKeyListener(new KeyAdapter()
+ {
+ private KeyEvent buffer = null;
+
+ @Override
+ public void keyPressed(KeyEvent event)
+ {
+ // Reports KEY_PRESSED events on release to support modifiers
+ this.buffer = event;
+ }
+
+ @Override
+ public void keyReleased(KeyEvent event)
+ {
+ if (buffer != null)
+ {
+ AWTKeyStroke input = KeyStroke.getKeyStrokeForEvent(buffer);
+ buffer = null;
+
+ if(currentRow != -1)
+ {
+ GlobalShortcutEntry en =
+ GlobalShortcutConfigForm.this.tableModel.getEntryAt(
+ currentRow);
+ List kss = new ArrayList();
+
+ if(currentColumn == 1) // shortcut 1
+ {
+ kss.add(input);
+ kss.add(en.getShortcut2());
+ }
+ else if(currentColumn == 2) // shortcut 2
+ {
+ kss.add(en.getShortcut());
+ kss.add(input);
+ }
+ else
+ {
+ return;
+ }
+
+ en.setShortcuts(kss);
+ GlobalShortcutConfigForm.this.refresh();
+ GlobalShortcutConfigForm.this.saveConfig();
+ }
+ }
+ }
+ });
+
+ scrollPane.getViewport().add(this.shortcutsTable);
+ mainPanel.add(this.scrollPane, BorderLayout.CENTER);
+ mainPanel.setPreferredSize(new Dimension(500, 400));
+ shortcutsTable.getSelectionModel().addListSelectionListener(this);
+ loadConfig();
+ }
+
+ /**
+ * Loads configuration.
+ */
+ private void loadConfig()
+ {
+ KeybindingsService keybindingService =
+ KeybindingChooserActivator.getKeybindingsService();
+
+ GlobalKeybindingSet set = keybindingService.getGlobalBindings();
+
+ for(Map.Entry> entry :
+ set.getBindings().entrySet())
+ {
+ String key = entry.getKey();
+ List kss = entry.getValue();
+ GlobalShortcutEntry gke = null;
+ String desc = null;
+
+ if(key.equals("answer"))
+ {
+ desc = Resources.getString(
+ "plugin.keybindings.globalchooser.ANSWER_CALL");
+ }
+ else if(key.equals("hangup"))
+ {
+ desc = Resources.getString(
+ "plugin.keybindings.globalchooser.HANGUP_CALL");
+ }
+ else if(key.equals("contactlist"))
+ {
+ desc = Resources.getString(
+ "plugin.keybindings.globalchooser.SHOW_CONTACTLIST");
+ }
+ else
+ continue;
+
+ gke = new GlobalShortcutEntry(desc, kss);
+
+ tableModel.addEntry(gke);
+ }
+ refresh();
+ }
+
+ /**
+ * Save configuration.
+ */
+ public void saveConfig()
+ {
+ KeybindingsService keybindingService =
+ KeybindingChooserActivator.getKeybindingsService();
+ GlobalShortcutService globalShortcutService =
+ KeybindingChooserActivator.getGlobalShortcutService();
+ Map> gBindings =
+ keybindingService.getGlobalBindings().getBindings();
+ List entries = tableModel.getEntries();
+ List kss = null;
+
+ for(GlobalShortcutEntry entry : entries)
+ {
+ String desc = null;
+
+ if(entry.getAction().equals(Resources.getString(
+ "plugin.keybindings.globalchooser.ANSWER_CALL")))
+ {
+ desc = "answer";
+ }
+ else if(entry.getAction().equals(Resources.getString(
+ "plugin.keybindings.globalchooser.HANGUP_CALL")))
+ {
+ desc = "hangup";
+ }
+ else if(entry.getAction().equals(Resources.getString(
+ "plugin.keybindings.globalchooser.SHOW_CONTACTLIST")))
+ {
+ desc = "contactlist";
+
+ }
+ else
+ continue;
+
+ kss = gBindings.get(desc);
+ kss.clear();
+ kss.add(entry.getShortcut());
+ kss.add(entry.getShortcut2());
+ gBindings.put(desc, kss);
+ }
+
+ keybindingService.saveGlobalShortcutFromConfiguration();
+ globalShortcutService.reloadGlobalShortcuts();
+ }
+
+ /**
+ * Required by ListSelectionListener.
+ *
+ * @param e event triggered
+ */
+ public void valueChanged(ListSelectionEvent e)
+ {
+ if(shortcutsTable.getSelectedRow() == -1)
+ {
+ currentRow = -1;
+ currentColumn = -1;
+ }
+ }
+
+ /**
+ * refreshes the table display
+ */
+ private void refresh()
+ {
+ tableModel.fireTableStructureChanged();
+ }
+
+ /**
+ * Indicates if this is an advanced configuration form.
+ * @return true if this is an advanced configuration form,
+ * otherwise it returns false
+ */
+ public boolean isAdvanced()
+ {
+ return true;
+ }
+
+ /**
+ * Add bindings.
+ *
+ * @param bindings list of bindings
+ *
+ public void addBindings(Map> bindings)
+ {
+ for(Map.Entry> entry : bindings.entrySet())
+ {
+ GlobalShortcutEntry e = new GlobalShortcutEntry(
+ entry.getKey(), entry.getValue());
+ tableModel.addEntry(e);
+ }
+ refresh();
+ }
+ */
+}
+
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutEntry.java b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutEntry.java
new file mode 100644
index 000000000..b578aec40
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutEntry.java
@@ -0,0 +1,248 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.keybindingchooser.globalchooser;
+
+import java.util.List; //disambiguation
+import java.awt.*;
+import java.awt.event.*;
+
+/**
+ * Entry for a global shortcut.
+ *
+ * @author Sebastien Vincent
+ */
+public class GlobalShortcutEntry
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Disabled keystroke.
+ */
+ private static final AWTKeyStroke DISABLED = null;
+
+ /**
+ * Action name.
+ */
+ private String action = null;
+
+ /**
+ * Primary shortcut.
+ */
+ private AWTKeyStroke shortcut = null;
+
+ /**
+ * Second shortcut.
+ */
+ private AWTKeyStroke shortcut2 = null;
+
+ /**
+ * Constructor.
+ *
+ * @param action action
+ * @param shortcuts list of shortcut for this action
+ */
+ public GlobalShortcutEntry(String action, List shortcuts)
+ {
+ setAction(action);
+ setShortcuts(shortcuts);
+ }
+
+ /**
+ * Returns primary shortcut if it exists.
+ *
+ * @return primary shortcut if it exists.
+ */
+ public AWTKeyStroke getShortcut()
+ {
+ return this.shortcut;
+ }
+
+ /**
+ * Returns second shortcut if it exists.
+ *
+ * @return second shortcut if it exists.
+ */
+ public AWTKeyStroke getShortcut2()
+ {
+ return this.shortcut2;
+ }
+
+ /**
+ * Set the shortcut keystroke and field.
+ *
+ * @param shortcut AWTKeyStroke
+ * @return string representation of the keystroke
+ */
+ public static String getShortcutText(AWTKeyStroke shortcut)
+ {
+ if (shortcut == DISABLED)
+ {
+ return "Disabled";
+ }
+ else
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ if (shortcut.getKeyEventType() == KeyEvent.KEY_TYPED)
+ {
+ buffer.append(shortcut.getKeyChar());
+ }
+ else
+ {
+ int keycode = shortcut.getKeyCode();
+ int modifiers = shortcut.getModifiers();
+
+ // Indicates modifiers of the keystroke
+ boolean shiftMask = (modifiers & InputEvent.SHIFT_MASK) != 0;
+ boolean ctrlMask = (modifiers & InputEvent.CTRL_MASK) != 0;
+ boolean metaMask = (modifiers & InputEvent.META_MASK) != 0;
+ boolean altMask = (modifiers & InputEvent.ALT_MASK) != 0;
+ if (shiftMask && keycode != KeyEvent.VK_SHIFT)
+ buffer.append("Shift + ");
+ if (ctrlMask && keycode != KeyEvent.VK_CONTROL)
+ buffer.append("Ctrl + ");
+ if (metaMask && keycode != KeyEvent.VK_META)
+ buffer.append("Meta + ");
+ if (altMask && keycode != KeyEvent.VK_ALT)
+ buffer.append("Alt + ");
+
+ buffer.append(KeyEvent.getKeyText(keycode));
+ }
+ return buffer.toString();
+ }
+ }
+
+ /**
+ * Set the shortcuts for this action.
+ *
+ * @param shortcuts list of shortcuts
+ */
+ public void setShortcuts(List shortcuts)
+ {
+ if(shortcuts.size() > 0)
+ {
+ this.shortcut = shortcuts.get(0);
+ }
+ if(shortcuts.size() > 1)
+ {
+ this.shortcut2 = shortcuts.get(1);
+ }
+ }
+
+ /**
+ * Returns action string.
+ *
+ * @return action
+ */
+ public String getAction()
+ {
+ return action;
+ }
+
+ /**
+ * Set action string
+ *
+ * @param action action
+ */
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+ /**
+ * If this global keybindings is disabled.
+ *
+ * @return true if this global keybinding is disabled
+ */
+ public boolean isDisabled()
+ {
+ return this.shortcut == DISABLED && this.shortcut2 == DISABLED;
+ }
+
+ /**
+ * Provides the string representation of this mapping. The exact details of
+ * the representation are unspecified and subject to change but the
+ * following format can be considered to be typical:
+ * "BindingEntry (" + Shortcut + " \u2192 " + Action + ")"
+ *
+ * @return string representation of entry
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("GlobalBindingEntry (");
+
+ if (isDisabled())
+ builder.append("Disabled");
+ else
+ builder.append(getShortcut());
+ builder.append(" \u2192 "); // arrow pointing right
+ builder.append(getAction());
+ builder.append(")");
+ return builder.toString();
+ }
+
+ /**
+ * Checks if argument is an instance of this class with the same shortcut
+ * and associated action. It does not compare aspects of the display
+ * elements.
+ *
+ * @param obj element with which to be compared
+ * @return true if argument is an instance of this class with matching
+ * shortcut and action, false otherwise
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ else if (!(obj instanceof GlobalShortcutEntry))
+ return false;
+
+ GlobalShortcutEntry entry = (GlobalShortcutEntry) obj;
+ boolean equals = true;
+
+ String action = this.getAction();
+ if (action == null)
+ equals &= entry.getAction() == null;
+ else
+ equals &= action.equals(entry.getAction());
+
+ AWTKeyStroke shortcut = this.getShortcut();
+ if (shortcut == null)
+ equals &= entry.getShortcut() == null;
+ else
+ equals &= shortcut.equals(entry.getShortcut());
+
+ shortcut = this.getShortcut2();
+ if (shortcut == null)
+ equals &= entry.getShortcut() == null;
+ else
+ equals &= shortcut.equals(entry.getShortcut2());
+
+ return equals;
+ }
+
+ /**
+ * Returns hashcode for this instance.
+ *
+ * @return hashcode for this instance
+ */
+ @Override
+ public int hashCode()
+ {
+ int hash = 17;
+ hash = 37 * hash + (getAction() == null ? 0 : getAction().hashCode());
+ hash =
+ 37 * hash + (getShortcut() == null ? 0 : getShortcut().hashCode());
+ return hash;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutTableModel.java b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutTableModel.java
new file mode 100644
index 000000000..896a03a6a
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutTableModel.java
@@ -0,0 +1,199 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.keybindingchooser.globalchooser;
+
+import java.util.*;
+
+import javax.swing.table.*;
+
+/**
+ * Table model for global shortcuts.
+ *
+ * @author Sebastien Vincent
+ */
+public class GlobalShortcutTableModel
+ extends AbstractTableModel
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * List of shortcuts.
+ */
+ private List shortcuts =
+ new ArrayList();
+
+ /**
+ * Returns the title for this column
+ *
+ * @param column the column
+ *
+ * @return the title for this column
+ *
+ * @see javax.swing.table.AbstractTableModel#getColumnName
+ */
+ public String getColumnName(int column)
+ {
+ switch(column)
+ {
+ case 0:
+ return Resources.getString(
+ "plugin.keybindings.globalchooser.SHORTCUT_NAME");
+ case 1:
+ return Resources.getString(
+ "plugin.keybindings.globalchooser.SHORTCUT_PRIMARY");
+ case 2:
+ return Resources.getString(
+ "plugin.keybindings.globalchooser.SHORTCUT_SECOND");
+ default:
+ throw new IllegalArgumentException("column not found");
+ }
+ }
+
+ /**
+ * Returns the number of rows in the table
+ *
+ * @return the number of rows in the table
+ * @see javax.swing.table.AbstractTableModel#getRowCount
+ */
+ public int getRowCount()
+ {
+ return shortcuts.size();
+ }
+
+ /**
+ * Returns the number of column in the table
+ *
+ * @return the number of columns in the table
+ *
+ * @see javax.swing.table.AbstractTableModel#getColumnCount
+ */
+ public int getColumnCount()
+ {
+ // 3 columns: "name", "primary shortcut", "second shortcut"
+ return 3;
+ }
+
+ /**
+ * Returns the text for the given cell of the table
+ *
+ * @param row cell row
+ * @param column cell column
+ * @return object at the row/column
+ * @see javax.swing.table.AbstractTableModel#getValueAt
+ */
+ public Object getValueAt(int row, int column)
+ {
+ switch(column)
+ {
+ case 0:
+ return getEntryAt(row).getAction();
+ case 1:
+ return GlobalShortcutEntry.getShortcutText(
+ getEntryAt(row).getShortcut());
+ case 2:
+ return GlobalShortcutEntry.getShortcutText(
+ getEntryAt(row).getShortcut2());
+ default:
+ throw new IllegalArgumentException("column not found");
+ }
+ }
+
+ /**
+ * Returns the LdapDirectory at the row 'row'
+ *
+ * @param row the row on which to find the LdapDirectory
+ *
+ * @return the LdapDirectory found
+ */
+ public GlobalShortcutEntry getEntryAt(int row)
+ {
+ int i = 0;
+
+ for(GlobalShortcutEntry entry : shortcuts)
+ {
+ if(i == row)
+ return entry;
+ i++;
+ }
+
+ throw new IllegalArgumentException("row not found");
+ }
+
+ /**
+ * Returns whether a cell is editable.
+ * @param row row of the cell
+ * @param col column of the cell
+ *
+ * @return whether the cell is editable
+ */
+ public boolean isCellEditable(int row, int col)
+ {
+ return false;
+ }
+
+ /**
+ * Overrides a method that always returned Object.class
+ * Now it will return Boolean.class for the first method,
+ * letting the DefaultTableCellRenderer create checkboxes.
+ *
+ * @param columnIndex index of the column
+ * @return Column class
+ */
+ public Class> getColumnClass(int columnIndex)
+ {
+ Object o = getValueAt(0, columnIndex);
+ if(o == null)
+ return String.class;
+ return o.getClass();
+ }
+
+ /**
+ * Sets a value in an editable cell.
+ *
+ * @param aValue value to set
+ * @param rowIndex row index
+ * @param columnIndex column index
+ */
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex)
+ {
+ if(columnIndex != 0)
+ throw new IllegalArgumentException("non editable column!");
+ }
+
+ /**
+ * Adds an entry.
+ *
+ * @param entry entry to add
+ */
+ public void addEntry(GlobalShortcutEntry entry)
+ {
+ shortcuts.add(entry);
+ }
+
+ /**
+ * Adds an entry.
+ *
+ * @param entry entry to add
+ */
+ public void removeEntry(GlobalShortcutEntry entry)
+ {
+ shortcuts.remove(entry);
+ }
+
+ /**
+ * Returns all shortcuts.
+ *
+ * @return all shortcuts.
+ */
+ public List getEntries()
+ {
+ return shortcuts;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/Resources.java b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/Resources.java
new file mode 100644
index 000000000..3b83b718d
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/Resources.java
@@ -0,0 +1,43 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.keybindingchooser.globalchooser;
+
+import net.java.sip.communicator.plugin.keybindingchooser.*;
+
+/**
+ * The Resources class manages the access to the internationalization
+ * properties files and the image resources used in this plugin.
+ *
+ * @author Yana Stamcheva
+ */
+public class Resources
+{
+ /**
+ * Returns an internationalized string corresponding to the given key.
+ *
+ * @param key The key of the string.
+ * @return An internationalized string corresponding to the given key.
+ */
+ public static String getString(String key)
+ {
+ return KeybindingChooserActivator.getResources()
+ .getI18NString(key);
+ }
+
+ /**
+ * Returns an internationalized string corresponding to the given key.
+ *
+ * @param key The key of the string.
+ * @param params additionnal parameters
+ * @return An internationalized string corresponding to the given key.
+ */
+ public static String getString(String key, String[] params)
+ {
+ return KeybindingChooserActivator.getResources()
+ .getI18NString(key, params);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf b/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf
index 32f57fdd5..2746eea74 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/keybindingChooser.manifest.mf
@@ -8,7 +8,10 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.keybindings,
net.java.sip.communicator.service.resources,
+ net.java.sip.communicator.service.configuration,
+ net.java.sip.communicator.service.globalshortcut,
net.java.sip.communicator.util,
net.java.sip.communicator.util.swing,
javax.swing,
- javax.swing.event
+ javax.swing.event,
+ javax.swing.table,
diff --git a/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutEvent.java b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutEvent.java
new file mode 100644
index 000000000..3f613eef7
--- /dev/null
+++ b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutEvent.java
@@ -0,0 +1,42 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.globalshortcut;
+
+import java.awt.*;
+
+/**
+ * Event related to global shortcut.
+ *
+ * @author Sebastien Vincent
+ */
+public class GlobalShortcutEvent
+{
+ /**
+ * Key stroke.
+ */
+ private final AWTKeyStroke keyStroke;
+
+ /**
+ * Initializes a new GlobalShortcutEvent.
+ *
+ * @param keyStroke keystroke
+ */
+ public GlobalShortcutEvent(AWTKeyStroke keyStroke)
+ {
+ this.keyStroke = keyStroke;
+ }
+
+ /**
+ * Returns keyStroke.
+ *
+ * @return keystroke
+ */
+ public AWTKeyStroke getKeyStroke()
+ {
+ return keyStroke;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutListener.java b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutListener.java
new file mode 100644
index 000000000..9a372ce5b
--- /dev/null
+++ b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutListener.java
@@ -0,0 +1,22 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.globalshortcut;
+
+/**
+ * Global shortcut listener.
+ *
+ * @author Sebastien Vincent
+ */
+public interface GlobalShortcutListener
+{
+ /**
+ * Callback when an shortcut is typed
+ *
+ * @param evt GlobalShortcutEvent
+ */
+ public void shortcutReceived(GlobalShortcutEvent evt);
+}
diff --git a/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java
new file mode 100644
index 000000000..17f3e77fe
--- /dev/null
+++ b/src/net/java/sip/communicator/service/globalshortcut/GlobalShortcutService.java
@@ -0,0 +1,41 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.globalshortcut;
+
+import java.awt.*;
+
+/**
+ * This global shortcut service permits to register listeners for global
+ * shortcut (i.e. keystroke even if application is not foreground).
+ *
+ * @author Sebastien Vincent
+ */
+public interface GlobalShortcutService
+{
+ /**
+ * Registers an action to execute when the keystroke is typed.
+ *
+ * @param l listener to notify when keystroke is typed
+ * @param keyStroke keystroke that will trigger the action
+ */
+ public void registerShortcut(GlobalShortcutListener l,
+ AWTKeyStroke keyStroke);
+
+ /**
+ * Unregisters an action to execute when the keystroke is typed.
+ *
+ * @param l listener to remove
+ * @param keyStroke keystroke that will trigger the action
+ */
+ public void unregisterShortcut(GlobalShortcutListener l,
+ AWTKeyStroke keyStroke);
+
+ /**
+ * Reload global shortcuts.
+ */
+ public void reloadGlobalShortcuts();
+}
\ No newline at end of file
diff --git a/src/net/java/sip/communicator/service/keybindings/GlobalKeybindingSet.java b/src/net/java/sip/communicator/service/keybindings/GlobalKeybindingSet.java
new file mode 100644
index 000000000..25d266839
--- /dev/null
+++ b/src/net/java/sip/communicator/service/keybindings/GlobalKeybindingSet.java
@@ -0,0 +1,33 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.keybindings;
+
+import java.util.*;
+import java.util.List; //disambiguation
+import java.awt.*;
+
+/**
+ * Global keybinding set interface.
+ *
+ * @author Sebastien Vincent
+ */
+public interface GlobalKeybindingSet
+{
+ /**
+ * Provides current keybinding mappings.
+ * @return mapping of keystrokes to the string representation of the actions
+ * they perform
+ */
+ public Map> getBindings();
+
+ /**
+ * Resets the bindings and notifies the observer's listeners if they've
+ * changed.
+ * @param bindings new keybindings to be held
+ */
+ public void setBindings(Map> bindings);
+}
diff --git a/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java b/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java
index 7fd31626c..87085fb22 100644
--- a/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java
+++ b/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java
@@ -23,20 +23,20 @@ public abstract class KeybindingSet
* they perform
*/
public abstract HashMap getBindings();
-
+
/**
* Resets the bindings and notifies the observer's listeners if they've
* changed.
* @param newBindings new keybindings to be held
*/
public abstract void setBindings(Map newBindings);
-
+
/**
* Provides the portion of the UI to which the bindings belong.
* @return binding category
*/
public abstract Category getCategory();
-
+
/**
* Keybinding sets available in the Sip Communicator.
*/
@@ -44,16 +44,16 @@ public enum Category
{
CHAT("keybindings-chat", Persistence.SERIAL_HASH),
MAIN("keybindings-main", Persistence.SERIAL_HASH);
-
+
private final String resource;
private final Persistence persistenceFormat;
-
+
Category(String resource, Persistence format)
{
this.resource = resource;
this.persistenceFormat = format;
}
-
+
/**
* Provides the name keybindings are saved and loaded with.
* @return filename used for keybindings
@@ -62,7 +62,7 @@ public String getResource()
{
return this.resource;
}
-
+
/**
* Provides the format used to save and load keybinding resources.
* @return style of persistence used by keybindings
diff --git a/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java b/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java
index 335c84ddb..afc382565 100644
--- a/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java
+++ b/src/net/java/sip/communicator/service/keybindings/KeybindingsService.java
@@ -6,6 +6,10 @@
*/
package net.java.sip.communicator.service.keybindings;
+import java.awt.*;
+import java.util.*;
+import java.util.List;
+
/**
* The KeybindingService handles the distribution of configurable and
* persistent keybinding sets.
@@ -21,4 +25,23 @@ public interface KeybindingsService
* actions
*/
KeybindingSet getBindings(KeybindingSet.Category category);
+
+ /**
+ * Provides the bindings associated with the global category.
+ *
+ * @return global keybinding set
+ */
+ GlobalKeybindingSet getGlobalBindings();
+
+ /**
+ * Returns list of global shortcuts from the configuration file.
+ *
+ * @return list of global shortcuts.
+ */
+ public Map> getGlobalShortcutFromConfiguration();
+
+ /**
+ * Save the configuration file.
+ */
+ public void saveGlobalShortcutFromConfiguration();
}
\ No newline at end of file
|