[kune-commits] r1803 - in trunk/src: main/java/cc/kune/client main/java/cc/kune/common/client main/java/cc/kune/common/client/actions main/java/cc/kune/common/client/actions/gwtui main/java/cc/kune/common/client/actions/ui/descrip main/java/cc/kune/common/client/events main/java/cc/kune/common/client/log main/java/cc/kune/common/client/shortcuts main/java/cc/kune/common/client/ui/dialogs main/java/cc/kune/common/public main/java/cc/kune/core/client main/java/cc/kune/core/client/sitebar main/java/cc/kune/core/client/sitebar/spaces test/java/cc/kune/common/client
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Wed Mar 28 15:41:51 CEST 2012
Author: vjrj_
Date: 2012-03-28 15:41:51 +0200 (Wed, 28 Mar 2012)
New Revision: 1803
Added:
trunk/src/main/java/cc/kune/common/client/events/
trunk/src/main/java/cc/kune/common/client/events/EventBusInstance.java
trunk/src/main/java/cc/kune/common/client/events/EventBusWithLogging.java
trunk/src/main/java/cc/kune/common/client/events/EventBusWithoutLogging.java
trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcutRegisterDefault.java
trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcuts.java
trunk/src/main/java/cc/kune/common/client/shortcuts/OnEscapePressedEvent.java
trunk/src/test/java/cc/kune/common/client/events/
Removed:
trunk/src/main/java/cc/kune/common/client/log/EventBusWithLogging.java
trunk/src/main/java/cc/kune/common/client/log/EventBusWithoutLogging.java
trunk/src/main/java/cc/kune/common/client/shortcuts/DefaultGlobalShortcutRegister.java
Modified:
trunk/src/main/java/cc/kune/client/KuneGinjector.java
trunk/src/main/java/cc/kune/common/client/SampleGinModule.java
trunk/src/main/java/cc/kune/common/client/actions/KeyStroke.java
trunk/src/main/java/cc/kune/common/client/actions/Shortcut.java
trunk/src/main/java/cc/kune/common/client/actions/gwtui/AbstractGwtMenuItemGui.java
trunk/src/main/java/cc/kune/common/client/actions/ui/descrip/AbstractGuiActionDescrip.java
trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java
trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java
trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java
trunk/src/main/java/cc/kune/common/public/kune-common.css
trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
trunk/src/main/java/cc/kune/core/client/CoreParts.java
trunk/src/main/java/cc/kune/core/client/sitebar/MyGroupsMenu.java
trunk/src/main/java/cc/kune/core/client/sitebar/SiteUserOptionsPresenter.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
Log:
CLOSED - # 226: New global shortcuts
http://kune.ourproject.org/issues/ticket/226
Modified: trunk/src/main/java/cc/kune/client/KuneGinjector.java
===================================================================
--- trunk/src/main/java/cc/kune/client/KuneGinjector.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/client/KuneGinjector.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -27,7 +27,7 @@
import cc.kune.chat.client.ChatGinjector;
import cc.kune.common.client.actions.gwtui.GwtGuiProvider;
import cc.kune.common.client.actions.ui.GuiProvider;
-import cc.kune.common.client.log.EventBusWithLogging;
+import cc.kune.common.client.events.EventBusWithLogging;
import cc.kune.common.client.shortcuts.GlobalShortcutRegister;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.CoreGinModule;
Modified: trunk/src/main/java/cc/kune/common/client/SampleGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/SampleGinModule.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/SampleGinModule.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -23,7 +23,7 @@
import cc.kune.common.client.actions.gxtui.GxtGuiProvider;
import cc.kune.common.client.actions.ui.DefaultGuiProvider;
import cc.kune.common.client.actions.ui.GuiProvider;
-import cc.kune.common.client.shortcuts.DefaultGlobalShortcutRegister;
+import cc.kune.common.client.shortcuts.GlobalShortcutRegisterDefault;
import cc.kune.common.client.shortcuts.GlobalShortcutRegister;
import com.google.gwt.inject.client.AbstractGinModule;
@@ -36,6 +36,6 @@
bind(GuiProvider.class).to(DefaultGuiProvider.class).in(Singleton.class);
bind(GxtGuiProvider.class).in(Singleton.class);
bind(GwtGuiProvider.class).in(Singleton.class);
- bind(GlobalShortcutRegister.class).to(DefaultGlobalShortcutRegister.class).in(Singleton.class);
+ bind(GlobalShortcutRegister.class).to(GlobalShortcutRegisterDefault.class).in(Singleton.class);
}
}
Modified: trunk/src/main/java/cc/kune/common/client/actions/KeyStroke.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/actions/KeyStroke.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/actions/KeyStroke.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -41,6 +41,7 @@
import java.util.Map;
import cc.kune.common.client.shortcuts.Keyboard;
+import cc.kune.core.client.i18n.I18n;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.KeyCodes;
@@ -68,469 +69,471 @@
*/
public class KeyStroke {
- /**
- * The cache of recently created keystrokes. This maps KeyStrokes to
- * KeyStrokes in a cache which removes the least recently accessed entry,
- * under the assumption that garbage collection of a new keystroke is easy
- * when we find the old one that it matches in the cache.
- */
- private static final Map<KeyStroke, KeyStroke> CACHE = new HashMap<KeyStroke, KeyStroke>();
+ /**
+ * The cache of recently created keystrokes. This maps KeyStrokes to
+ * KeyStrokes in a cache which removes the least recently accessed entry,
+ * under the assumption that garbage collection of a new keystroke is easy
+ * when we find the old one that it matches in the cache.
+ */
+ private static final Map<KeyStroke, KeyStroke> CACHE = new HashMap<KeyStroke, KeyStroke>();
- private static final char CHAR_UNDEFINED = '\uffff';
+ private static final char CHAR_UNDEFINED = '\uffff';
- /** The most recently generated keystroke, or null. */
- private static KeyStroke recent;
+ /** The most recently generated keystroke, or null. */
+ private static KeyStroke recent;
- private static final int VK_UNDEFINED = 0;
- /**
- * A table of keyCode names to values. This is package-private to avoid an
- * accessor method.
- *
- * @see #getKeyStroke(String)
- */
- static final Map<String, Object> VKTABLE = new HashMap<String, Object>();
+ private static final int VK_UNDEFINED = 0;
+ /**
+ * A table of keyCode names to values. This is package-private to avoid an
+ * accessor method.
+ *
+ * @see #getKeyStroke(String)
+ */
+ static final Map<String, Object> VKTABLE = new HashMap<String, Object>();
- public static int getKeyboardModifiers(final NativeEvent event) {
- return (event.getShiftKey() ? Keyboard.MODIFIER_SHIFT : 0) | (event.getMetaKey() ? Keyboard.MODIFIER_META : 0)
- | (event.getCtrlKey() ? Keyboard.MODIFIER_CTRL : 0) | (event.getAltKey() ? Keyboard.MODIFIER_ALT : 0);
- }
+ public static int getKeyboardModifiers(final NativeEvent event) {
+ return (event.getShiftKey() ? Keyboard.MODIFIER_SHIFT : 0)
+ | (event.getMetaKey() ? Keyboard.MODIFIER_META : 0)
+ | (event.getCtrlKey() ? Keyboard.MODIFIER_CTRL : 0)
+ | (event.getAltKey() ? Keyboard.MODIFIER_ALT : 0);
+ }
- /**
- * Returns a keystroke representing a typed character.
- *
- * @param keyChar
- * the typed character
- * @return the specified keystroke
- */
- public static KeyStroke getKeyStroke(final char keyChar) {
- return getKeyStroke(keyChar, VK_UNDEFINED, 0, false);
- }
+ /**
+ * Returns a keystroke representing a typed character.
+ *
+ * @param keyChar
+ * the typed character
+ * @return the specified keystroke
+ */
+ public static KeyStroke getKeyStroke(final char keyChar) {
+ return getKeyStroke(keyChar, VK_UNDEFINED, 0, false);
+ }
- /**
- * Gets the appropriate keystroke, creating one if necessary.
- *
- * @param keyChar
- * the keyChar
- * @param keyCode
- * the keyCode
- * @param modifiers
- * the modifiers
- * @param release
- * true for key release
- * @return the specified keystroke
- */
- private static KeyStroke getKeyStroke(final char keyChar, final int keyCode, final int modifiers,
- final boolean release) {
- // Check level 0 cache.
- KeyStroke stroke = recent; // Avoid thread races.
- if (stroke != null && stroke.keyChar == keyChar && stroke.keyCode == keyCode && stroke.modifiers == modifiers
- && stroke.onKeyRelease == release) {
- return stroke;
- }
- stroke = new KeyStroke(keyChar, keyCode, modifiers, release);
- // Check level 1 cache.
- final KeyStroke cached = CACHE.get(stroke);
- if (cached == null) {
- CACHE.put(stroke, stroke);
- } else {
- stroke = cached;
- }
- return recent = stroke;
+ /**
+ * Gets the appropriate keystroke, creating one if necessary.
+ *
+ * @param keyChar
+ * the keyChar
+ * @param keyCode
+ * the keyCode
+ * @param modifiers
+ * the modifiers
+ * @param release
+ * true for key release
+ * @return the specified keystroke
+ */
+ private static KeyStroke getKeyStroke(final char keyChar, final int keyCode, final int modifiers,
+ final boolean release) {
+ // Check level 0 cache.
+ KeyStroke stroke = recent; // Avoid thread races.
+ if (stroke != null && stroke.keyChar == keyChar && stroke.keyCode == keyCode
+ && stroke.modifiers == modifiers && stroke.onKeyRelease == release) {
+ return stroke;
}
-
- /**
- * Returns a keystroke representing a typed character with the given
- * modifiers. Note that keyChar is a <code>Character</code> instead of a
- * <code>char</code> to avoid accidental ambiguity with
- * <code>getKeyStroke(int, int)</code>. The modifiers are the bitwise or of
- * the masks found in InputEvent; the new style (*_DOWN_MASK) is preferred,
- * but the old style will work.
- *
- * @param keyChar
- * the typed character
- * @param modifiers
- * the modifiers, or 0
- * @return the specified keystroke
- * @throws IllegalArgumentException
- * if keyChar is null
- */
- public static KeyStroke getKeyStroke(final Character keyChar, final int modifiers) {
- if (keyChar == null) {
- throw new IllegalArgumentException();
- }
- return getKeyStroke(keyChar.charValue(), VK_UNDEFINED, modifiers, false);
+ stroke = new KeyStroke(keyChar, keyCode, modifiers, release);
+ // Check level 1 cache.
+ final KeyStroke cached = CACHE.get(stroke);
+ if (cached == null) {
+ CACHE.put(stroke, stroke);
+ } else {
+ stroke = cached;
}
+ return recent = stroke;
+ }
- /**
- * Returns a keystroke representing a pressed key event, with the given
- * modifiers. The "virtual key" should be one of the VK_* constants in
- * {@link KeyEvent}. The modifiers are the bitwise or of the masks found in
- * InputEvent; the new style (*_DOWN_MASK) is preferred, but the old style
- * will work.
- *
- * @param keyCode
- * the virtual key
- * @param modifiers
- * the modifiers, or 0
- * @return the specified keystroke
- */
- public static KeyStroke getKeyStroke(final int keyCode, final int modifiers) {
- return getKeyStroke(CHAR_UNDEFINED, keyCode, modifiers, false);
+ /**
+ * Returns a keystroke representing a typed character with the given
+ * modifiers. Note that keyChar is a <code>Character</code> instead of a
+ * <code>char</code> to avoid accidental ambiguity with
+ * <code>getKeyStroke(int, int)</code>. The modifiers are the bitwise or of
+ * the masks found in InputEvent; the new style (*_DOWN_MASK) is preferred,
+ * but the old style will work.
+ *
+ * @param keyChar
+ * the typed character
+ * @param modifiers
+ * the modifiers, or 0
+ * @return the specified keystroke
+ * @throws IllegalArgumentException
+ * if keyChar is null
+ */
+ public static KeyStroke getKeyStroke(final Character keyChar, final int modifiers) {
+ if (keyChar == null) {
+ throw new IllegalArgumentException();
}
+ return getKeyStroke(keyChar.charValue(), VK_UNDEFINED, modifiers, false);
+ }
- /**
- * Returns a keystroke representing a pressed or released key event, with
- * the given modifiers. The "virtual key" should be one of the VK_*
- * constants in {@link KeyEvent}. The modifiers are the bitwise or of the
- * masks found in InputEvent; the new style (*_DOWN_MASK) is preferred, but
- * the old style will work.
- *
- * @param keyCode
- * the virtual key
- * @param modifiers
- * the modifiers, or 0
- * @param release
- * true if this is a key release instead of a key press
- * @return the specified keystroke
- */
- public static KeyStroke getKeyStroke(final int keyCode, final int modifiers, final boolean release) {
- return getKeyStroke(CHAR_UNDEFINED, keyCode, modifiers, release);
- }
+ /**
+ * Returns a keystroke representing a pressed key event, with the given
+ * modifiers. The "virtual key" should be one of the VK_* constants in
+ * {@link KeyEvent}. The modifiers are the bitwise or of the masks found in
+ * InputEvent; the new style (*_DOWN_MASK) is preferred, but the old style
+ * will work.
+ *
+ * @param keyCode
+ * the virtual key
+ * @param modifiers
+ * the modifiers, or 0
+ * @return the specified keystroke
+ */
+ public static KeyStroke getKeyStroke(final int keyCode, final int modifiers) {
+ return getKeyStroke(CHAR_UNDEFINED, keyCode, modifiers, false);
+ }
- /**
- * Returns a keystroke representing what caused the key event.
- *
- * @param event
- * the key event to convert
- * @return the specified keystroke, or null if the event is invalid
- * @throws NullPointerException
- * if event is null
- */
- public static KeyStroke getKeyStrokeForEvent(final Event event) {
- final int eventModif = getKeyboardModifiers(event);
- final int eventKeyCode = event.getKeyCode();
- // Log.info("key: " + eventKeyCode + " modifier: " + eventModif);
- switch (DOM.eventGetType(event)) {
- case Event.ONKEYDOWN:
- return getKeyStroke(CHAR_UNDEFINED, eventKeyCode, eventModif, false);
- case Event.ONKEYPRESS:
- final char charac = (char) eventKeyCode;
- return getKeyStroke(Character.isLowerCase(charac) ? Character.toUpperCase(charac) : charac, VK_UNDEFINED,
- eventModif, false);
- case Event.ONKEYUP:
- return getKeyStroke(CHAR_UNDEFINED, eventKeyCode, eventModif, false);
- default:
- return null;
- }
+ /**
+ * Returns a keystroke representing a pressed or released key event, with the
+ * given modifiers. The "virtual key" should be one of the VK_* constants in
+ * {@link KeyEvent}. The modifiers are the bitwise or of the masks found in
+ * InputEvent; the new style (*_DOWN_MASK) is preferred, but the old style
+ * will work.
+ *
+ * @param keyCode
+ * the virtual key
+ * @param modifiers
+ * the modifiers, or 0
+ * @param release
+ * true if this is a key release instead of a key press
+ * @return the specified keystroke
+ */
+ public static KeyStroke getKeyStroke(final int keyCode, final int modifiers, final boolean release) {
+ return getKeyStroke(CHAR_UNDEFINED, keyCode, modifiers, release);
+ }
+
+ /**
+ * Returns a keystroke representing what caused the key event.
+ *
+ * @param event
+ * the key event to convert
+ * @return the specified keystroke, or null if the event is invalid
+ * @throws NullPointerException
+ * if event is null
+ */
+ public static KeyStroke getKeyStrokeForEvent(final Event event) {
+ final int eventModif = getKeyboardModifiers(event);
+ final int eventKeyCode = event.getKeyCode();
+ // Log.info("key: " + eventKeyCode + " modifier: " + eventModif);
+ switch (DOM.eventGetType(event)) {
+ case Event.ONKEYDOWN:
+ return getKeyStroke(CHAR_UNDEFINED, eventKeyCode, eventModif, false);
+ case Event.ONKEYPRESS:
+ final char charac = (char) eventKeyCode;
+ return getKeyStroke(Character.isLowerCase(charac) ? Character.toUpperCase(charac) : charac,
+ VK_UNDEFINED, eventModif, false);
+ case Event.ONKEYUP:
+ return getKeyStroke(CHAR_UNDEFINED, eventKeyCode, eventModif, false);
+ default:
+ return null;
}
+ }
- /**
- * The typed character, or CHAR_UNDEFINED for key presses and releases.
- *
- * @serial the keyChar
- */
- private final char keyChar;
+ /**
+ * The typed character, or CHAR_UNDEFINED for key presses and releases.
+ *
+ * @serial the keyChar
+ */
+ private final char keyChar;
- /**
- * The virtual key code, or VK_UNDEFINED for key typed. Package visible for
- * use by Component.
- *
- * @serial the keyCode
- */
- int keyCode;
+ /**
+ * The virtual key code, or VK_UNDEFINED for key typed. Package visible for
+ * use by Component.
+ *
+ * @serial the keyCode
+ */
+ int keyCode;
- /**
- * The modifiers in effect. To match Sun, this stores the old style masks
- * for shift, control, alt, meta, and alt-graph (but not button1); as well
- * as the new style of extended modifiers for all modifiers.
- *
- * @serial bitwise or of the *_DOWN_MASK modifiers
- */
- private int modifiers;
+ /**
+ * The modifiers in effect. To match Sun, this stores the old style masks for
+ * shift, control, alt, meta, and alt-graph (but not button1); as well as the
+ * new style of extended modifiers for all modifiers.
+ *
+ * @serial bitwise or of the *_DOWN_MASK modifiers
+ */
+ private int modifiers;
- /**
- * True if this is a key release; should only be true if keyChar is
- * CHAR_UNDEFINED.
- *
- * @serial true to distinguish key pressed from key released
- */
- private boolean onKeyRelease;
+ /**
+ * True if this is a key release; should only be true if keyChar is
+ * CHAR_UNDEFINED.
+ *
+ * @serial true to distinguish key pressed from key released
+ */
+ private boolean onKeyRelease;
- /**
- * Construct a keystroke with default values: it will be interpreted as a
- * key typed event with an invalid character and no modifiers. Client code
- * should use the factory methods instead.
- *
- * @see #getKeyStroke(char)
- * @see #getKeyStroke(Character, int)
- * @see #getKeyStroke(int, int, boolean)
- * @see #getKeyStroke(int, int)
- * @see #getKeyStrokeForEvent(KeyEvent)
- * @see #getKeyStroke(String)
- */
- protected KeyStroke() {
- keyChar = CHAR_UNDEFINED;
- }
+ /**
+ * Construct a keystroke with default values: it will be interpreted as a key
+ * typed event with an invalid character and no modifiers. Client code should
+ * use the factory methods instead.
+ *
+ * @see #getKeyStroke(char)
+ * @see #getKeyStroke(Character, int)
+ * @see #getKeyStroke(int, int, boolean)
+ * @see #getKeyStroke(int, int)
+ * @see #getKeyStrokeForEvent(KeyEvent)
+ * @see #getKeyStroke(String)
+ */
+ protected KeyStroke() {
+ keyChar = CHAR_UNDEFINED;
+ }
- /**
- * Construct a keystroke with the given values. Client code should use the
- * factory methods instead.
- *
- * @param keyChar
- * the character entered, if this is a key typed
- * @param keyCode
- * the key pressed or released, or VK_UNDEFINED for key typed
- * @param modifiers
- * the modifier keys for the keystroke, in old or new style
- * @param onKeyRelease
- * true if this is a key release instead of a press
- * @see #getKeyStroke(char)
- * @see #getKeyStroke(Character, int)
- * @see #getKeyStroke(int, int, boolean)
- * @see #getKeyStroke(int, int)
- * @see #getKeyStrokeForEvent(KeyEvent)
- * @see #getKeyStroke(String)
- */
- protected KeyStroke(final char keyChar, final int keyCode, final int modifiers, final boolean onKeyRelease) {
- this.keyChar = keyChar;
- this.keyCode = keyCode;
- // No need to call extend(), as only trusted code calls this
- // constructor.
- this.modifiers = modifiers;
- this.onKeyRelease = onKeyRelease;
- }
+ /**
+ * Construct a keystroke with the given values. Client code should use the
+ * factory methods instead.
+ *
+ * @param keyChar
+ * the character entered, if this is a key typed
+ * @param keyCode
+ * the key pressed or released, or VK_UNDEFINED for key typed
+ * @param modifiers
+ * the modifier keys for the keystroke, in old or new style
+ * @param onKeyRelease
+ * true if this is a key release instead of a press
+ * @see #getKeyStroke(char)
+ * @see #getKeyStroke(Character, int)
+ * @see #getKeyStroke(int, int, boolean)
+ * @see #getKeyStroke(int, int)
+ * @see #getKeyStrokeForEvent(KeyEvent)
+ * @see #getKeyStroke(String)
+ */
+ protected KeyStroke(final char keyChar, final int keyCode, final int modifiers,
+ final boolean onKeyRelease) {
+ this.keyChar = keyChar;
+ this.keyCode = keyCode;
+ // No need to call extend(), as only trusted code calls this
+ // constructor.
+ this.modifiers = modifiers;
+ this.onKeyRelease = onKeyRelease;
+ }
- /**
- * Tests two keystrokes for equality.
- *
- * @param obj
- * the object to test
- * @return true if it is equal
- */
- @Override
- public final boolean equals(final Object obj) {
- if (!(obj instanceof KeyStroke)) {
- return false;
- }
- final KeyStroke stroke = (KeyStroke) obj;
- return this == obj
- || (keyChar == stroke.keyChar && keyCode == stroke.keyCode && modifiers == stroke.modifiers && onKeyRelease == stroke.onKeyRelease);
+ /**
+ * Tests two keystrokes for equality.
+ *
+ * @param obj
+ * the object to test
+ * @return true if it is equal
+ */
+ @Override
+ public final boolean equals(final Object obj) {
+ if (!(obj instanceof KeyStroke)) {
+ return false;
}
+ final KeyStroke stroke = (KeyStroke) obj;
+ return this == obj
+ || (keyChar == stroke.keyChar && keyCode == stroke.keyCode && modifiers == stroke.modifiers && onKeyRelease == stroke.onKeyRelease);
+ }
- /**
- * Returns the character of this keystroke, if it was typed.
- *
- * @return the character value, or CHAR_UNDEFINED
- * @see #getKeyStroke(char)
- */
- public final char getKeyChar() {
- return keyChar;
- }
+ /**
+ * Returns the character of this keystroke, if it was typed.
+ *
+ * @return the character value, or CHAR_UNDEFINED
+ * @see #getKeyStroke(char)
+ */
+ public final char getKeyChar() {
+ return keyChar;
+ }
- /**
- * Returns the virtual key code of this keystroke, if it was pressed or
- * released. This will be a VK_* constant from KeyEvent.
- *
- * @return the virtual key code value, or VK_UNDEFINED
- * @see #getKeyStroke(int, int)
- */
- public final int getKeyCode() {
- return keyCode;
- }
+ /**
+ * Returns the virtual key code of this keystroke, if it was pressed or
+ * released. This will be a VK_* constant from KeyEvent.
+ *
+ * @return the virtual key code value, or VK_UNDEFINED
+ * @see #getKeyStroke(int, int)
+ */
+ public final int getKeyCode() {
+ return keyCode;
+ }
- /**
- * Returns the AWT event type of this keystroke. This is one of
- * {@link KeyEvent#KEY_TYPED}, {@link KeyEvent#KEY_PRESSED}, or
- * {@link KeyEvent#KEY_RELEASED}.
- *
- * @return the key event type
- */
- public final int getKeyEventType() {
- return keyCode == VK_UNDEFINED ? Event.ONKEYDOWN : onKeyRelease ? Event.ONKEYUP : Event.ONKEYPRESS;
- }
+ /**
+ * Returns the AWT event type of this keystroke. This is one of
+ * {@link KeyEvent#KEY_TYPED}, {@link KeyEvent#KEY_PRESSED}, or
+ * {@link KeyEvent#KEY_RELEASED}.
+ *
+ * @return the key event type
+ */
+ public final int getKeyEventType() {
+ return keyCode == VK_UNDEFINED ? Event.ONKEYDOWN : onKeyRelease ? Event.ONKEYUP : Event.ONKEYPRESS;
+ }
- @SuppressWarnings("deprecation")
- public String getKeyText() {
- switch (keyCode) {
- case KeyCodes.KEY_BACKSPACE:
- return translateKey("Backspace");
- // case KeyCodes.KEY_DELETE:
- // return translateKey("Delete");
- case KeyCodes.KEY_DOWN:
- return translateKey("Down");
- case KeyCodes.KEY_END:
- return translateKey("End");
- case KeyCodes.KEY_ENTER:
- return translateKey("Enter");
- case KeyCodes.KEY_ESCAPE:
- return translateKey("Escape");
- case KeyCodes.KEY_HOME:
- return translateKey("Home");
- case KeyCodes.KEY_LEFT:
- return translateKey("Left");
- case KeyCodes.KEY_PAGEDOWN:
- return translateKey("Page Down");
- case KeyCodes.KEY_PAGEUP:
- return translateKey("Page Up");
- case KeyCodes.KEY_RIGHT:
- return translateKey("Right");
- case KeyCodes.KEY_TAB:
- return translateKey("Tab");
- case KeyCodes.KEY_UP:
- return translateKey("Up");
- case Keyboard.KEY_SPACE:
- return translateKey("Space");
- case Keyboard.KEY_F1:
- case Keyboard.KEY_F2:
- case Keyboard.KEY_F3:
- case Keyboard.KEY_F4:
- case Keyboard.KEY_F5:
- case Keyboard.KEY_F6:
- case Keyboard.KEY_F7:
- case Keyboard.KEY_F8:
- case Keyboard.KEY_F9:
- case Keyboard.KEY_F10:
- case Keyboard.KEY_F11:
- case Keyboard.KEY_F12:
- return translateKey("F" + (keyCode - (Keyboard.KEY_F1 - 1)));
- case Keyboard.KEY_COMMA:
- case Keyboard.KEY_PERIOD:
- case Keyboard.KEY_SLASH:
- case Keyboard.KEY_0:
- case Keyboard.KEY_1:
- case Keyboard.KEY_2:
- case Keyboard.KEY_3:
- case Keyboard.KEY_4:
- case Keyboard.KEY_5:
- case Keyboard.KEY_6:
- case Keyboard.KEY_7:
- case Keyboard.KEY_8:
- case Keyboard.KEY_9:
- case Keyboard.KEY_SEMICOLON:
- case Keyboard.KEY_EQUALS:
- case Keyboard.KEY_A:
- case Keyboard.KEY_B:
- case Keyboard.KEY_C:
- case Keyboard.KEY_D:
- case Keyboard.KEY_E:
- case Keyboard.KEY_F:
- case Keyboard.KEY_G:
- case Keyboard.KEY_H:
- case Keyboard.KEY_I:
- case Keyboard.KEY_J:
- case Keyboard.KEY_K:
- case Keyboard.KEY_L:
- case Keyboard.KEY_M:
- case Keyboard.KEY_N:
- case Keyboard.KEY_O:
- case Keyboard.KEY_P:
- case Keyboard.KEY_Q:
- case Keyboard.KEY_R:
- case Keyboard.KEY_S:
- case Keyboard.KEY_T:
- case Keyboard.KEY_U:
- case Keyboard.KEY_V:
- case Keyboard.KEY_W:
- case Keyboard.KEY_X:
- case Keyboard.KEY_Y:
- case Keyboard.KEY_Z:
- case Keyboard.KEY_OPEN_BRACKET:
- case Keyboard.KEY_BACK_SLASH:
- case Keyboard.KEY_CLOSE_BRACKET:
- return String.valueOf(keyCode).toUpperCase();
- default:
- final String charS = String.valueOf(keyChar);
- if (charS == null) {
- return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode));
- } else {
- if (" ".equals(charS)) {
- return translateKey("Space");
- } else {
- return charS;
- }
- }
+ @SuppressWarnings("deprecation")
+ public String getKeyText() {
+ switch (keyCode) {
+ case KeyCodes.KEY_BACKSPACE:
+ return translateKey("Backspace");
+ // case KeyCodes.KEY_DELETE:
+ // return translateKey("Delete");
+ case KeyCodes.KEY_DOWN:
+ return translateKey("Down");
+ case KeyCodes.KEY_END:
+ return translateKey("End");
+ case KeyCodes.KEY_ENTER:
+ return translateKey("Enter");
+ case KeyCodes.KEY_ESCAPE:
+ return translateKey("Escape");
+ case KeyCodes.KEY_HOME:
+ return translateKey("Home");
+ case KeyCodes.KEY_LEFT:
+ return translateKey("Left");
+ case KeyCodes.KEY_PAGEDOWN:
+ return translateKey("Page Down");
+ case KeyCodes.KEY_PAGEUP:
+ return translateKey("Page Up");
+ case KeyCodes.KEY_RIGHT:
+ return translateKey("Right");
+ case KeyCodes.KEY_TAB:
+ return translateKey("Tab");
+ case KeyCodes.KEY_UP:
+ return translateKey("Up");
+ case Keyboard.KEY_SPACE:
+ return translateKey("Space");
+ case Keyboard.KEY_F1:
+ case Keyboard.KEY_F2:
+ case Keyboard.KEY_F3:
+ case Keyboard.KEY_F4:
+ case Keyboard.KEY_F5:
+ case Keyboard.KEY_F6:
+ case Keyboard.KEY_F7:
+ case Keyboard.KEY_F8:
+ case Keyboard.KEY_F9:
+ case Keyboard.KEY_F10:
+ case Keyboard.KEY_F11:
+ case Keyboard.KEY_F12:
+ return translateKey("F" + (keyCode - (Keyboard.KEY_F1 - 1)));
+ case Keyboard.KEY_COMMA:
+ case Keyboard.KEY_PERIOD:
+ case Keyboard.KEY_SLASH:
+ case Keyboard.KEY_0:
+ case Keyboard.KEY_1:
+ case Keyboard.KEY_2:
+ case Keyboard.KEY_3:
+ case Keyboard.KEY_4:
+ case Keyboard.KEY_5:
+ case Keyboard.KEY_6:
+ case Keyboard.KEY_7:
+ case Keyboard.KEY_8:
+ case Keyboard.KEY_9:
+ case Keyboard.KEY_SEMICOLON:
+ case Keyboard.KEY_EQUALS:
+ case Keyboard.KEY_A:
+ case Keyboard.KEY_B:
+ case Keyboard.KEY_C:
+ case Keyboard.KEY_D:
+ case Keyboard.KEY_E:
+ case Keyboard.KEY_F:
+ case Keyboard.KEY_G:
+ case Keyboard.KEY_H:
+ case Keyboard.KEY_I:
+ case Keyboard.KEY_J:
+ case Keyboard.KEY_K:
+ case Keyboard.KEY_L:
+ case Keyboard.KEY_M:
+ case Keyboard.KEY_N:
+ case Keyboard.KEY_O:
+ case Keyboard.KEY_P:
+ case Keyboard.KEY_Q:
+ case Keyboard.KEY_R:
+ case Keyboard.KEY_S:
+ case Keyboard.KEY_T:
+ case Keyboard.KEY_U:
+ case Keyboard.KEY_V:
+ case Keyboard.KEY_W:
+ case Keyboard.KEY_X:
+ case Keyboard.KEY_Y:
+ case Keyboard.KEY_Z:
+ case Keyboard.KEY_OPEN_BRACKET:
+ case Keyboard.KEY_BACK_SLASH:
+ case Keyboard.KEY_CLOSE_BRACKET:
+ return String.valueOf(keyCode).toUpperCase();
+ default:
+ final String charS = String.valueOf(keyChar);
+ if (charS == null) {
+ return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode));
+ } else {
+ if (" ".equals(charS)) {
+ return translateKey("Space");
+ } else {
+ return charS;
}
+ }
}
+ }
- /**
- * Returns the modifiers for this keystroke. This will be a bitwise or of
- * constants from InputEvent; it includes the old style masks for shift,
- * control, alt, meta, and alt-graph (but not button1); as well as the new
- * style of extended modifiers for all modifiers.
- *
- * @return the modifiers
- * @see #getKeyStroke(Character, int)
- * @see #getKeyStroke(int, int)
- */
- public final int getModifiers() {
- return modifiers;
- }
+ /**
+ * Returns the modifiers for this keystroke. This will be a bitwise or of
+ * constants from InputEvent; it includes the old style masks for shift,
+ * control, alt, meta, and alt-graph (but not button1); as well as the new
+ * style of extended modifiers for all modifiers.
+ *
+ * @return the modifiers
+ * @see #getKeyStroke(Character, int)
+ * @see #getKeyStroke(int, int)
+ */
+ public final int getModifiers() {
+ return modifiers;
+ }
- /**
- * Returns a hashcode for this key event. It is not documented, but appears
- * to be: <code>(getKeyChar() + 1) * (getKeyCode() + 1)
- * * (getModifiers() + 1) * 2 + (isOnKeyRelease() ? 1 : 2)</code>.
- *
- * @return the hashcode
- */
- @Override
- public int hashCode() {
- return (keyChar + 1) * (keyCode + 1) * (modifiers + 1) * 2 + (onKeyRelease ? 1 : 2);
- }
+ /**
+ * Returns a hashcode for this key event. It is not documented, but appears to
+ * be: <code>(getKeyChar() + 1) * (getKeyCode() + 1)
+ * * (getModifiers() + 1) * 2 + (isOnKeyRelease() ? 1 : 2)</code>.
+ *
+ * @return the hashcode
+ */
+ @Override
+ public int hashCode() {
+ return (keyChar + 1) * (keyCode + 1) * (modifiers + 1) * 2 + (onKeyRelease ? 1 : 2);
+ }
- /**
- * Tests if this keystroke is a key release.
- *
- * @return true if this is a key release
- * @see #getKeyStroke(int, int, boolean)
- */
- public final boolean isOnKeyRelease() {
- return onKeyRelease;
- }
+ /**
+ * Tests if this keystroke is a key release.
+ *
+ * @return true if this is a key release
+ * @see #getKeyStroke(int, int, boolean)
+ */
+ public final boolean isOnKeyRelease() {
+ return onKeyRelease;
+ }
- /**
- * Returns a cached version of the deserialized keystroke, if available.
- *
- * @return a cached replacement if something goes wrong
- */
- protected Object readResolve() {
- final KeyStroke s = CACHE.get(this);
- if (s != null) {
- return s;
- }
- CACHE.put(this, this);
- return this;
+ /**
+ * Returns a cached version of the deserialized keystroke, if available.
+ *
+ * @return a cached replacement if something goes wrong
+ */
+ protected Object readResolve() {
+ final KeyStroke s = CACHE.get(this);
+ if (s != null) {
+ return s;
}
+ CACHE.put(this, this);
+ return this;
+ }
- @Override
- public String toString() {
- String s = " (";
- if ((modifiers & Keyboard.MODIFIER_META) != 0) {
- s += translateKey("Meta") + "+";
- }
- if ((modifiers & Keyboard.MODIFIER_CTRL) != 0) {
- s += translateKey("Ctrl") + "+";
- }
- if ((modifiers & Keyboard.MODIFIER_ALT) != 0) {
- s += translateKey("Alt") + "+";
- }
- if ((modifiers & Keyboard.MODIFIER_SHIFT) != 0) {
- s += translateKey("Shift") + "+";
- }
- /*
- * if ((modifiers & Event.BUTTON_LEFT) != 0) { s +=
- * translateKey("Button1") + "+"; } if ((modifiers & Event.BUTTON_RIGHT)
- * != 0) { s += translateKey("Button2") + "+"; } if ((modifiers &
- * Event.BUTTON_MIDDLE) != 0) { s += translateKey("Button3") + "+"; }
- */
- s += getKeyText() + ")";
- return s;
+ @Override
+ public String toString() {
+ String s = " (";
+ if ((modifiers & Keyboard.MODIFIER_META) != 0) {
+ s += translateKey("Meta") + "+";
}
-
- protected String translateKey(final String keyNameToTranslate) {
- // return Resources.i18n.tWithNT(keyNameToTranslate, "The '" +
- // keyNameToTranslate + "' keyboard key");
- return keyNameToTranslate;
+ if ((modifiers & Keyboard.MODIFIER_CTRL) != 0) {
+ s += translateKey("Ctrl") + "+";
}
+ if ((modifiers & Keyboard.MODIFIER_ALT) != 0) {
+ s += translateKey("Alt") + "+";
+ }
+ if ((modifiers & Keyboard.MODIFIER_SHIFT) != 0) {
+ s += translateKey("Shift") + "+";
+ }
+ /*
+ * if ((modifiers & Event.BUTTON_LEFT) != 0) { s += translateKey("Button1")
+ * + "+"; } if ((modifiers & Event.BUTTON_RIGHT) != 0) { s +=
+ * translateKey("Button2") + "+"; } if ((modifiers & Event.BUTTON_MIDDLE) !=
+ * 0) { s += translateKey("Button3") + "+"; }
+ */
+ s += getKeyText() + ")";
+ return s;
+ }
+ protected String translateKey(final String keyNameToTranslate) {
+ return I18n.tWithNT(keyNameToTranslate, "The '" + keyNameToTranslate + "' keyboard key");
+ // return keyNameToTranslate;
+ }
+
} // class KeyStroke
Modified: trunk/src/main/java/cc/kune/common/client/actions/Shortcut.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/actions/Shortcut.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/actions/Shortcut.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -23,22 +23,39 @@
public final class Shortcut {
- public static KeyStroke getShortcut(final boolean ctrl, final boolean alt, final boolean shift, final boolean meta,
- final Character character) {
- return KeyStroke.getKeyStroke(character, (ctrl ? Keyboard.MODIFIER_CTRL : 0)
- + (alt ? Keyboard.MODIFIER_ALT : 0) + (shift ? Keyboard.MODIFIER_SHIFT : 0)
- + (meta ? Keyboard.MODIFIER_META : 0));
- }
+ public static KeyStroke getShortcut(final boolean ctrl, final boolean alt, final boolean shift,
+ final boolean meta, final Character character) {
+ return KeyStroke.getKeyStroke(character, (ctrl ? Keyboard.MODIFIER_CTRL : 0)
+ + (alt ? Keyboard.MODIFIER_ALT : 0) + (shift ? Keyboard.MODIFIER_SHIFT : 0)
+ + (meta ? Keyboard.MODIFIER_META : 0));
+ }
- public static KeyStroke getShortcut(final boolean ctrl, final boolean shift, final Character character) {
- return getShortcut(ctrl, false, shift, false, character);
- }
+ public static KeyStroke getShortcut(final boolean ctrl, final boolean shift, final Character character) {
+ return getShortcut(ctrl, false, shift, false, character);
+ }
- public static KeyStroke getShortcut(final boolean ctrl, final Character character) {
- return getShortcut(ctrl, false, false, false, character);
- }
+ public static KeyStroke getShortcut(final boolean ctrl, final Character character) {
+ return getShortcut(ctrl, false, false, false, character);
+ }
- private Shortcut() {
- }
+ /**
+ * Gets the shortcut using as parameter something like "Alt+A" "Ctrl+M" or
+ * "Meta+Shift+R"
+ *
+ * @param keys
+ * the keys
+ * @return the shortcut
+ */
+ public static KeyStroke getShortcut(final String keys) {
+ final boolean hasCtrl = keys.contains("Ctrl");
+ final boolean hasAlt = keys.contains("Alt");
+ final boolean hasMeta = keys.contains("Meta");
+ final boolean hasShift = keys.contains("Shift");
+ final Character key = keys.charAt(keys.length() - 1);
+ return Shortcut.getShortcut(hasCtrl, hasAlt, hasShift, hasMeta, key);
+ }
+ private Shortcut() {
+ }
+
}
Modified: trunk/src/main/java/cc/kune/common/client/actions/gwtui/AbstractGwtMenuItemGui.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/actions/gwtui/AbstractGwtMenuItemGui.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/actions/gwtui/AbstractGwtMenuItemGui.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -38,8 +38,6 @@
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.MenuItem;
@@ -153,14 +151,6 @@
return checkItem;
}
- private String createShortCut(final KeyStroke key, final String style) {
- // See: https://yui-ext.com/forum/showthread.php?t=5762
- final Element keyLabel = DOM.createSpan();
- keyLabel.setId(style);
- keyLabel.setInnerText(key.toString());
- return keyLabel.getString();
- }
-
public GwtBaseMenuItem getItem() {
return item;
}
@@ -224,9 +214,7 @@
if (key == null) {
iconLabel.setText(text, descriptor.getDirection());
} else {
- iconLabel.setText(
- text + createShortCut(key, "oc-mshortcut-hidden") + createShortCut(key, "oc-mshortcut"),
- descriptor.getDirection());
+ iconLabel.setText(text + " " + key.toString(), descriptor.getDirection());
}
}
layout();
Modified: trunk/src/main/java/cc/kune/common/client/actions/ui/descrip/AbstractGuiActionDescrip.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/actions/ui/descrip/AbstractGuiActionDescrip.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/actions/ui/descrip/AbstractGuiActionDescrip.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -340,12 +340,7 @@
@Override
public GuiActionDescrip withShortcut(final String keys, final GlobalShortcutRegister register) {
- final boolean hasCtrl = keys.contains("Ctrl");
- final boolean hasAlt = keys.contains("Alt");
- final boolean hasMeta = keys.contains("Meta");
- final boolean hasShift = keys.contains("Shift");
- final Character key = keys.charAt(keys.length() - 1);
- final KeyStroke shortcut = Shortcut.getShortcut(hasCtrl, hasAlt, hasShift, hasMeta, key);
+ final KeyStroke shortcut = Shortcut.getShortcut(keys);
putValue(Action.ACCELERATOR_KEY, shortcut);
register.put(shortcut, action);
return this;
Added: trunk/src/main/java/cc/kune/common/client/events/EventBusInstance.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/events/EventBusInstance.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/events/EventBusInstance.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright (C) 2007-2012 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package cc.kune.common.client.events;
+
+import com.google.gwt.event.shared.EventBus;
+import com.google.inject.Inject;
+
+public class EventBusInstance {
+
+ @Inject
+ private static EventBus eventBus;
+
+ public static EventBus get() {
+ return eventBus;
+ }
+}
Copied: trunk/src/main/java/cc/kune/common/client/events/EventBusWithLogging.java (from rev 1797, trunk/src/main/java/cc/kune/common/client/log/EventBusWithLogging.java)
===================================================================
--- trunk/src/main/java/cc/kune/common/client/events/EventBusWithLogging.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/events/EventBusWithLogging.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.common.client.events;
+
+
+import cc.kune.common.client.log.Log;
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.event.shared.SimpleEventBus;
+
+public class EventBusWithLogging extends SimpleEventBus {
+ @Override
+ public void fireEvent(final GwtEvent<?> event) {
+ Log.debug(event.toDebugString() + " " + event.toString());
+ super.fireEvent(event);
+ }
+}
Copied: trunk/src/main/java/cc/kune/common/client/events/EventBusWithoutLogging.java (from rev 1797, trunk/src/main/java/cc/kune/common/client/log/EventBusWithoutLogging.java)
===================================================================
--- trunk/src/main/java/cc/kune/common/client/events/EventBusWithoutLogging.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/events/EventBusWithoutLogging.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.common.client.events;
+
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.event.shared.SimpleEventBus;
+
+public class EventBusWithoutLogging extends SimpleEventBus {
+ @Override
+ public void fireEvent(final GwtEvent<?> event) {
+ super.fireEvent(event);
+ }
+}
Deleted: trunk/src/main/java/cc/kune/common/client/log/EventBusWithLogging.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/log/EventBusWithLogging.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/log/EventBusWithLogging.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -1,32 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.common.client.log;
-
-
-import com.google.gwt.event.shared.GwtEvent;
-import com.google.gwt.event.shared.SimpleEventBus;
-
-public class EventBusWithLogging extends SimpleEventBus {
- @Override
- public void fireEvent(final GwtEvent<?> event) {
- Log.debug(event.toDebugString() + " " + event.toString());
- super.fireEvent(event);
- }
-}
Deleted: trunk/src/main/java/cc/kune/common/client/log/EventBusWithoutLogging.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/log/EventBusWithoutLogging.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/log/EventBusWithoutLogging.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -1,30 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.common.client.log;
-
-import com.google.gwt.event.shared.GwtEvent;
-import com.google.gwt.event.shared.SimpleEventBus;
-
-public class EventBusWithoutLogging extends SimpleEventBus {
- @Override
- public void fireEvent(final GwtEvent<?> event) {
- super.fireEvent(event);
- }
-}
Deleted: trunk/src/main/java/cc/kune/common/client/shortcuts/DefaultGlobalShortcutRegister.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/shortcuts/DefaultGlobalShortcutRegister.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/shortcuts/DefaultGlobalShortcutRegister.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -1,87 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.common.client.shortcuts;
-
-import cc.kune.common.client.actions.AbstractAction;
-import cc.kune.common.client.actions.Action;
-import cc.kune.common.client.actions.ActionEvent;
-import cc.kune.common.client.actions.ChangeableObject;
-import cc.kune.common.client.actions.InputMap;
-import cc.kune.common.client.actions.KeyStroke;
-import cc.kune.common.client.actions.Shortcut;
-import cc.kune.common.client.log.Log;
-
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.Event.NativePreviewHandler;
-
-public class DefaultGlobalShortcutRegister extends InputMap implements GlobalShortcutRegister {
-
- private final NativePreviewHandler eventHandler;
- private HandlerRegistration handlerReg;
-
- public DefaultGlobalShortcutRegister() {
- super();
- eventHandler = new NativePreviewHandler() {
- @Override
- public void onPreviewNativeEvent(final NativePreviewEvent nativeEventPrev) {
- if (nativeEventPrev.getTypeInt() == Event.ONKEYDOWN) {
- final NativeEvent nativeEvent = nativeEventPrev.getNativeEvent();
- final Event event = Event.as(nativeEvent);
- final AbstractAction action = get(Shortcut.getShortcut(event.getCtrlKey(), event.getAltKey(),
- event.getShiftKey(), event.getShiftKey(), (char) event.getKeyCode()));
- if (action != null) {
- Log.debug("Not propagating event for action: " + action.getValue(Action.NAME));
- nativeEvent.stopPropagation();
- action.actionPerformed(new ActionEvent(nativeEvent.getCurrentEventTarget(), event));
- nativeEventPrev.cancel();
- }
- }
- }
- };
- }
-
- @Override
- public void disable() {
- if (handlerReg != null) {
- handlerReg.removeHandler();
- }
- }
-
- @Override
- public void enable() {
- enableImpl();
- }
-
- private void enableImpl() {
- handlerReg = Event.addNativePreviewHandler(eventHandler);
- }
-
- @Override
- public void put(final KeyStroke keystroke, final AbstractAction action) {
- final ChangeableObject previous = super.get(keystroke);
- if (previous != null) {
- Log.info("Shortcut already registed by: " + previous + "(overriding)");
- }
- super.put(keystroke, action);
- }
-}
Copied: trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcutRegisterDefault.java (from rev 1797, trunk/src/main/java/cc/kune/common/client/shortcuts/DefaultGlobalShortcutRegister.java)
===================================================================
--- trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcutRegisterDefault.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcutRegisterDefault.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.common.client.shortcuts;
+
+import cc.kune.common.client.actions.AbstractAction;
+import cc.kune.common.client.actions.Action;
+import cc.kune.common.client.actions.ActionEvent;
+import cc.kune.common.client.actions.ChangeableObject;
+import cc.kune.common.client.actions.InputMap;
+import cc.kune.common.client.actions.KeyStroke;
+import cc.kune.common.client.actions.Shortcut;
+import cc.kune.common.client.log.Log;
+
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Event.NativePreviewEvent;
+import com.google.gwt.user.client.Event.NativePreviewHandler;
+
+public class GlobalShortcutRegisterDefault extends InputMap implements GlobalShortcutRegister {
+
+ private final NativePreviewHandler eventHandler;
+ private HandlerRegistration handlerReg;
+
+ public GlobalShortcutRegisterDefault() {
+ super();
+ eventHandler = new NativePreviewHandler() {
+ @Override
+ public void onPreviewNativeEvent(final NativePreviewEvent nativeEventPrev) {
+ if (nativeEventPrev.getTypeInt() == Event.ONKEYDOWN) {
+ final NativeEvent nativeEvent = nativeEventPrev.getNativeEvent();
+ final Event event = Event.as(nativeEvent);
+ AbstractAction action = get(KeyStroke.getKeyStroke(event.getKeyCode(), 0));
+ if (action == null) {
+ action = get(Shortcut.getShortcut(event.getCtrlKey(), event.getAltKey(),
+ event.getShiftKey(), event.getShiftKey(), (char) event.getKeyCode()));
+ }
+ if (action != null) {
+ Log.debug("Not propagating event for action: " + action.getValue(Action.NAME));
+ nativeEvent.stopPropagation();
+ action.actionPerformed(new ActionEvent(nativeEvent.getCurrentEventTarget(), event));
+ nativeEventPrev.cancel();
+ }
+ }
+ }
+ };
+ }
+
+ @Override
+ public void disable() {
+ if (handlerReg != null) {
+ handlerReg.removeHandler();
+ }
+ }
+
+ @Override
+ public void enable() {
+ enableImpl();
+ }
+
+ private void enableImpl() {
+ handlerReg = Event.addNativePreviewHandler(eventHandler);
+ }
+
+ @Override
+ public void put(final KeyStroke keystroke, final AbstractAction action) {
+ final ChangeableObject previous = super.get(keystroke);
+ if (previous != null) {
+ Log.info("Shortcut already registed by: " + previous + "(overriding)");
+ }
+ super.put(keystroke, action);
+ }
+}
Added: trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcuts.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcuts.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/shortcuts/GlobalShortcuts.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright (C) 2007-2012 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package cc.kune.common.client.shortcuts;
+
+import cc.kune.common.client.actions.AbstractExtendedAction;
+import cc.kune.common.client.actions.ActionEvent;
+import cc.kune.common.client.actions.KeyStroke;
+
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.shared.EventBus;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+ at Singleton
+public class GlobalShortcuts {
+
+ @Inject
+ public GlobalShortcuts(final GlobalShortcutRegister register, final EventBus eventBus) {
+ register.put(KeyStroke.getKeyStroke(KeyCodes.KEY_ESCAPE, 0), new AbstractExtendedAction() {
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ OnEscapePressedEvent.fire(eventBus);
+ }
+ });
+ }
+
+}
Added: trunk/src/main/java/cc/kune/common/client/shortcuts/OnEscapePressedEvent.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/shortcuts/OnEscapePressedEvent.java (rev 0)
+++ trunk/src/main/java/cc/kune/common/client/shortcuts/OnEscapePressedEvent.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -0,0 +1,55 @@
+package cc.kune.common.client.shortcuts;
+
+import com.google.gwt.event.shared.EventHandler;
+import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+public class OnEscapePressedEvent extends GwtEvent<OnEscapePressedEvent.OnEscapePressedHandler> {
+
+ public interface HasOnEscapePressedHandlers extends HasHandlers {
+ HandlerRegistration addOnEscapePressedHandler(OnEscapePressedHandler handler);
+ }
+
+ public interface OnEscapePressedHandler extends EventHandler {
+ public void onOnEscapePressed(OnEscapePressedEvent event);
+ }
+
+ private static final Type<OnEscapePressedHandler> TYPE = new Type<OnEscapePressedHandler>();
+
+ public static void fire(final HasHandlers source) {
+ source.fireEvent(new OnEscapePressedEvent());
+ }
+
+ public static Type<OnEscapePressedHandler> getType() {
+ return TYPE;
+ }
+
+ public OnEscapePressedEvent() {
+ }
+
+ @Override
+ protected void dispatch(final OnEscapePressedHandler handler) {
+ handler.onOnEscapePressed(this);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return super.equals(obj);
+ }
+
+ @Override
+ public Type<OnEscapePressedHandler> getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "OnEscapePressedEvent[" + "]";
+ }
+}
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -19,6 +19,7 @@
*/
package cc.kune.common.client.ui.dialogs;
+import cc.kune.common.client.tooltip.Tooltip;
import cc.kune.common.client.ui.IconLabel;
import cc.kune.common.shared.utils.TextUtils;
@@ -106,6 +107,11 @@
}
@Override
+ public void setCloseBtnTooltip(final String tooltip) {
+ Tooltip.to(closeBtn, tooltip);
+ }
+
+ @Override
public void setCloseBtnVisible(final boolean visible) {
closeBtn.setVisible(visible);
}
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -27,24 +27,26 @@
ForIsWidget getBottomPanel();
+ HasClickHandlers getCloseBtn();
+
HasClickHandlers getFirstBtn();
ForIsWidget getInnerPanel();
HasClickHandlers getSecondBtn();
- HasClickHandlers getCloseBtn();
-
HasDirectionalText getTitleText();
+ void setCloseBtnTooltip(String tooltip);
+
+ void setCloseBtnVisible(boolean visible);
+
void setFirstBtnText(String text);
void setFirstBtnTitle(String title);
void setFirstBtnVisible(boolean visible);
- void setCloseBtnVisible(boolean visible);
-
void setSecondBtnText(String text);
void setSecondBtnTitle(String title);
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -19,9 +19,13 @@
*/
package cc.kune.common.client.ui.dialogs;
+import cc.kune.common.client.events.EventBusInstance;
+import cc.kune.common.client.shortcuts.OnEscapePressedEvent;
+import cc.kune.common.client.shortcuts.OnEscapePressedEvent.OnEscapePressedHandler;
import cc.kune.common.client.tooltip.Tooltip;
import cc.kune.common.client.ui.PopupTopPanel;
import cc.kune.common.shared.utils.TextUtils;
+import cc.kune.core.client.i18n.I18n;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -188,6 +192,15 @@
private void setCloseBtn(final boolean closeBtn) {
setCloseBtnVisible(closeBtn);
if (closeBtn) {
+ setCloseBtnTooltip(I18n.t("Close") + " (Esc)");
+ EventBusInstance.get().addHandler(OnEscapePressedEvent.getType(), new OnEscapePressedHandler() {
+ @Override
+ public void onOnEscapePressed(final OnEscapePressedEvent event) {
+ if (popup.isShowing()) {
+ popup.hide();
+ }
+ }
+ });
if (closeClickHandler == null) {
closeClickHandler = super.getCloseBtn().addClickHandler(new ClickHandler() {
@Override
Modified: trunk/src/main/java/cc/kune/common/public/kune-common.css
===================================================================
--- trunk/src/main/java/cc/kune/common/public/kune-common.css 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/common/public/kune-common.css 2012-03-28 13:41:51 UTC (rev 1803)
@@ -369,6 +369,8 @@
background: #ffffff;
}
+/* shorcuts, only used in gxt guidescriptors */
+
#oc-mshortcut {
position: absolute;
right: 10px;
Modified: trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreGinModule.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/core/client/CoreGinModule.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -22,9 +22,11 @@
import cc.kune.common.client.actions.gxtui.GxtGuiProvider;
import cc.kune.common.client.actions.ui.DefaultGuiProvider;
import cc.kune.common.client.actions.ui.GuiProvider;
-import cc.kune.common.client.log.EventBusWithLogging;
-import cc.kune.common.client.shortcuts.DefaultGlobalShortcutRegister;
+import cc.kune.common.client.events.EventBusInstance;
+import cc.kune.common.client.events.EventBusWithLogging;
import cc.kune.common.client.shortcuts.GlobalShortcutRegister;
+import cc.kune.common.client.shortcuts.GlobalShortcutRegisterDefault;
+import cc.kune.common.client.shortcuts.GlobalShortcuts;
import cc.kune.common.client.ui.MaskWidget;
import cc.kune.common.client.ui.MaskWidgetView;
import cc.kune.common.shared.i18n.HasRTL;
@@ -139,6 +141,8 @@
@Override
protected void configure() {
bind(EventBus.class).to(EventBusWithLogging.class).in(Singleton.class);
+ requestStaticInjection(EventBusInstance.class);
+
bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
bind(RootPresenter.class).asEagerSingleton();
bind(ProxyFailureHandler.class).to(DefaultProxyFailureHandler.class).in(Singleton.class);
@@ -149,7 +153,8 @@
s(I18n.class);
requestStaticInjection(I18n.class);
- bind(GlobalShortcutRegister.class).to(DefaultGlobalShortcutRegister.class).in(Singleton.class);
+ bind(GlobalShortcutRegister.class).to(GlobalShortcutRegisterDefault.class).in(Singleton.class);
+ bind(GlobalShortcuts.class).in(Singleton.class);
s(AnonUsersManager.class);
Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -19,6 +19,7 @@
*/
package cc.kune.core.client;
+import cc.kune.common.client.shortcuts.GlobalShortcuts;
import cc.kune.core.client.auth.AnonUsersManager;
import cc.kune.core.client.auth.Register;
import cc.kune.core.client.auth.SignIn;
@@ -66,7 +67,8 @@
final Provider<SubtitlesManager> subProvider, final EventBus eventBus,
final Provider<VerifyEmailClientManager> verifyManager,
final Provider<UserOptions> userOptionsDialog, final Provider<GroupOptions> groupOptionsDialog,
- final Provider<PasswordResetPanel> passReset, final Provider<AskForPasswordResetPanel> askForPass) {
+ final Provider<PasswordResetPanel> passReset, final Provider<AskForPasswordResetPanel> askForPass,
+ final GlobalShortcuts shortcuts) {
session.onAppStart(true, new AppStartHandler() {
@Override
public void onAppStart(final AppStartEvent event) {
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/MyGroupsMenu.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/MyGroupsMenu.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/MyGroupsMenu.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -70,7 +70,7 @@
withText(I18n.t("Your groups"));
withToolTip(I18n.t("See your groups or create a new one"));
withIcon(res.arrowdownsitebar());
- withShortcut("Alt+G", global);
+ withShortcut("Alt+M", global);
eventBus.addHandler(MyGroupsChangedEvent.getType(),
new MyGroupsChangedEvent.MyGroupsChangedHandler() {
@Override
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SiteUserOptionsPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SiteUserOptionsPresenter.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SiteUserOptionsPresenter.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -22,11 +22,13 @@
import cc.kune.common.client.actions.AbstractExtendedAction;
import cc.kune.common.client.actions.Action;
import cc.kune.common.client.actions.ActionEvent;
+import cc.kune.common.client.actions.Shortcut;
import cc.kune.common.client.actions.ui.descrip.GuiActionDescrip;
import cc.kune.common.client.actions.ui.descrip.MenuDescriptor;
import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
import cc.kune.common.client.actions.ui.descrip.ToolbarSeparatorDescriptor;
import cc.kune.common.client.actions.ui.descrip.ToolbarSeparatorDescriptor.Type;
+import cc.kune.common.client.shortcuts.GlobalShortcutRegister;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.events.UserSignInEvent;
import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
@@ -50,18 +52,21 @@
private final CoreResources res;
private ToolbarSeparatorDescriptor separator;
private final Session session;
+ private final GlobalShortcutRegister shortCutRegister;
private final SitebarActions siteOptions;
private final StateManager stateManager;
@Inject
public SiteUserOptionsPresenter(final Session session, final StateManager stateManager,
- final I18nTranslationService i18n, final CoreResources img, final SitebarActions siteOptions) {
+ final I18nTranslationService i18n, final CoreResources img, final SitebarActions siteOptions,
+ final GlobalShortcutRegister shortCutRegister) {
super();
this.session = session;
this.stateManager = stateManager;
this.i18n = i18n;
this.res = img;
this.siteOptions = siteOptions;
+ this.shortCutRegister = shortCutRegister;
createActions();
separator.setVisible(false);
session.onUserSignIn(true, new UserSignInHandler() {
@@ -106,6 +111,7 @@
userHomeAction.putValue(Action.NAME, i18n.t(CoreMessages.YOUR_HOMEPAGE));
userHomeAction.putValue(Action.SMALL_ICON, res.groupHome());
final MenuItemDescriptor item = new MenuItemDescriptor(userHomeAction);
+ item.withShortcut(Shortcut.getShortcut("Alt+U"), shortCutRegister);
item.setPosition(0);
addActionImpl(item);
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -64,16 +64,19 @@
armor.getSitebar().insert(uiBinder.createAndBindUi(this), 0);
// homeButton.setVisible(false);
final String siteCommonName = i18n.getSiteCommonName();
- homeSpaceTooltip = Tooltip.to(homeButton, i18n.t("Your home page in [%s]", siteCommonName));
+ homeSpaceTooltip = Tooltip.to(homeButton, i18n.t("Your home page in [%s]", siteCommonName)
+ + " (Alt+H)");
userSpaceTooltip = Tooltip.to(
userButton,
i18n.t("User space: it shows a list of all documents and contents " + "in which you participate")
+ " (Alt+I)");
groupSpaceTooltip = Tooltip.to(groupButton, i18n.t("Group and personal space: Where you can create "
- + "and publish contents for your personal or group web spaces"));
+ + "and publish contents for your personal or group web spaces")
+ + " (Alt+G)");
publicSpaceTooltip = Tooltip.to(publicButton,
i18n.t("Public space: Where you can see a preview of how your Personal or "
- + "Group Space looks like on the web"));
+ + "Group Space looks like on the web")
+ + " (Alt+P)");
// homeSpaceTooltip.setWidth(0);
userSpaceTooltip.setWidth(190);
groupSpaceTooltip.setWidth(170);
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2012-03-28 01:02:06 UTC (rev 1802)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2012-03-28 13:41:51 UTC (rev 1803)
@@ -21,7 +21,6 @@
import cc.kune.common.client.actions.AbstractExtendedAction;
import cc.kune.common.client.actions.ActionEvent;
-import cc.kune.common.client.actions.KeyStroke;
import cc.kune.common.client.actions.Shortcut;
import cc.kune.common.client.log.Log;
import cc.kune.common.client.notify.NotifyLevel;
@@ -32,7 +31,6 @@
import cc.kune.core.client.events.AppStartEvent;
import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
import cc.kune.core.client.events.UserSignOutEvent;
-import cc.kune.core.client.events.WindowFocusEvent;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
@@ -115,6 +113,7 @@
private String inboxToken;
private String publicToken;
private final Session session;
+ private final GlobalShortcutRegister shortcutRegister;
private final Provider<SignIn> signIn;
private final StateManager stateManager;
@@ -131,66 +130,86 @@
this.signIn = signIn;
this.backManager = backManager;
this.i18n = i18n;
+ this.shortcutRegister = shortcutRegister;
currentSpace = null;
homeToken = SiteTokens.HOME;
inboxToken = SiteTokens.WAVE_INBOX;
groupToken = SiteTokens.GROUP_HOME;
publicToken = TokenUtils.preview(SiteTokens.GROUP_HOME);
- view.getHomeBtn().addClickHandler(new ClickHandler() {
+ configureClickListeners();
+ configureShortcuts();
+ // eventBus.addHandler(WindowFocusEvent.getType(), new
+ // WindowFocusEvent.WindowFocusHandler() {
+ // @Override
+ // public void onWindowFocus(final WindowFocusEvent event) {
+ // if (event.isHasFocus() && !mask.isShowing()) {
+ // // showTooltipWithDelay();
+ // }
+ // }
+ // });
+ session.onAppStart(true, new AppStartHandler() {
@Override
+ public void onAppStart(final AppStartEvent event) {
+ getView().setPublicVisible(event.getInitData().isPublicSpaceVisible());
+ }
+ });
+ }
+
+ private void configureClickListeners() {
+ getView().getHomeBtn().addClickHandler(new ClickHandler() {
+ @Override
public void onClick(final ClickEvent event) {
- restoreToken(homeToken);
- setDown(Space.homeSpace);
+ onHomeBtnClick();
}
+
});
- view.getUserBtn().addClickHandler(new ClickHandler() {
+ getView().getUserBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- onUserBtnClick(stateManager, session, signIn);
+ onUserBtnClick();
}
});
- view.getGroupBtn().addClickHandler(new ClickHandler() {
+ getView().getGroupBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- if (groupToken.equals(SiteTokens.GROUP_HOME)) {
- // as current home is equal to "no content" token, we shall go to
- // group space def home page
- stateManager.gotoDefaultHomepage();
- } else {
- restoreToken(groupToken);
- }
- setDown(Space.groupSpace);
+ onGroupBtnClick();
}
+
});
- view.getPublicBtn().addClickHandler(new ClickHandler() {
+ getView().getPublicBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
- restoreToken(publicToken);
- setDown(Space.publicSpace);
+ onPublicBtnClick();
}
+ });
+ }
+ private void configureShortcuts() {
+ shortcutRegister.put(Shortcut.getShortcut("Alt+H"), new AbstractExtendedAction() {
+ @Override
+ public void actionPerformed(final ActionEvent event) {
+ onHomeBtnClick();
+ }
});
- eventBus.addHandler(WindowFocusEvent.getType(), new WindowFocusEvent.WindowFocusHandler() {
+ shortcutRegister.put(Shortcut.getShortcut("Alt+I"), new AbstractExtendedAction() {
@Override
- public void onWindowFocus(final WindowFocusEvent event) {
- if (event.isHasFocus() && !mask.isShowing()) {
- // showTooltipWithDelay();
- }
+ public void actionPerformed(final ActionEvent event) {
+ onUserBtnClick();
}
});
- session.onAppStart(true, new AppStartHandler() {
+ shortcutRegister.put(Shortcut.getShortcut("Alt+G"), new AbstractExtendedAction() {
@Override
- public void onAppStart(final AppStartEvent event) {
- getView().setPublicVisible(event.getInitData().isPublicSpaceVisible());
+ public void actionPerformed(final ActionEvent event) {
+ onGroupBtnClick();
}
});
- final KeyStroke shortcut = Shortcut.getShortcut(false, true, false, false, Character.valueOf('I'));
- shortcutRegister.put(shortcut, new AbstractExtendedAction() {
+ shortcutRegister.put(Shortcut.getShortcut("Alt+P"), new AbstractExtendedAction() {
@Override
public void actionPerformed(final ActionEvent event) {
- onUserBtnClick(stateManager, session, signIn);
+ onPublicBtnClick();
}
});
+
}
@ProxyEvent
@@ -198,6 +217,17 @@
showTooltipWithDelay();
}
+ private void onGroupBtnClick() {
+ if (groupToken.equals(SiteTokens.GROUP_HOME)) {
+ // as current home is equal to "no content" token, we shall go to
+ // group space def home page
+ stateManager.gotoDefaultHomepage();
+ } else {
+ restoreToken(groupToken);
+ }
+ setDown(Space.groupSpace);
+ }
+
private void onGroupSpaceSelect(final boolean shouldRestoreToken) {
restoreToken(shouldRestoreToken, groupToken);
armor.selectGroupSpace();
@@ -206,6 +236,11 @@
currentSpace = Space.groupSpace;
}
+ private void onHomeBtnClick() {
+ restoreToken(homeToken);
+ setDown(Space.homeSpace);
+ }
+
private void onHomeSpaceSelect(final boolean shouldRestoreToken) {
restoreToken(shouldRestoreToken, homeToken);
armor.selectHomeSpace();
@@ -215,8 +250,9 @@
getView().setWindowTitle(i18n.t("Home"));
}
- private void onPublicClick() {
-
+ private void onPublicBtnClick() {
+ restoreToken(publicToken);
+ setDown(Space.publicSpace);
}
private void onPublicSpaceSelect(final boolean shouldRestoreToken) {
@@ -271,8 +307,7 @@
}
}
- private void onUserBtnClick(final StateManager stateManager, final Session session,
- final Provider<SignIn> signIn) {
+ private void onUserBtnClick() {
signIn.get().setGotoTokenOnCancel(stateManager.getCurrentToken());
restoreToken(inboxToken);
if (session.isLogged()) {
More information about the kune-commits
mailing list