r1130 - in trunk: . src/main/java/org/ourproject/kune/app src/main/java/org/ourproject/kune/blogs src/main/java/org/ourproject/kune/chat src/main/java/org/ourproject/kune/chat/client src/main/java/org/ourproject/kune/docs src/main/java/org/ourproject/kune/gallery src/main/java/org/ourproject/kune/platf src/main/java/org/ourproject/kune/platf/client/actions src/main/java/org/ourproject/kune/platf/client/actions/toolbar src/main/java/org/ourproject/kune/platf/client/dto src/main/java/org/ourpro
Author: vjrj Date: 2009-06-25 16:55:19 +0200 (Thu, 25 Jun 2009) New Revision: 1130 Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/Shortcut.java trunk/src/test/java/org/ourproject/kune/platf/client/actions/ShortcutTest.java Removed: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java Modified: trunk/TODO trunk/pom.xml trunk/src/main/java/org/ourproject/kune/app/Kune.gwt.xml trunk/src/main/java/org/ourproject/kune/blogs/KuneBlogs.gwt.xml trunk/src/main/java/org/ourproject/kune/chat/KuneChat.gwt.xml trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java trunk/src/main/java/org/ourproject/kune/docs/KuneDocs.gwt.xml trunk/src/main/java/org/ourproject/kune/gallery/KuneGallery.gwt.xml trunk/src/main/java/org/ourproject/kune/platf/KunePlatform.gwt.xml trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/dto/ExtMediaDescripDTO.java trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kimg.css trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java trunk/src/main/java/org/ourproject/kune/wiki/KuneWiki.gwt.xml trunk/src/main/java/org/ourproject/kune/workspace/KuneWorkspace.gwt.xml trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java Log: Complete - taskShortcuts refactorization Modified: trunk/TODO =================================================================== --- trunk/TODO 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/TODO 2009-06-25 14:55:19 UTC (rev 1130) @@ -140,6 +140,11 @@ ** vjrj <v> IconHyperlink.java and IconLabel.java to gwt1.5 * MID-TERM +** TODO <v> karma, reputation, trust metrics: +http://wiki.couchsurfing.com/en/Trust +http://p2pfoundation.net/Trust_Metrics +http://en.wikipedia.org/wiki/Trust_metric +http://www.advogato.org/trust-metric.html ** TODO <v> use guice 2.0 http://google-code-updates.blogspot.com/2009/05/guice-deuce.html http://code.google.com/docreader/#p=google-guice&s=google-guice @@ -152,6 +157,7 @@ ** TODO <v,s> harden our privacy policy. Goals: - permit user/projects/contents how much private or public are - APIs public only to associated sites (in study) ( http://oauth.net ? ) +http://raibledesigns.com/rd/entry/implementing_oauth_with_gwt - the social net info (xmpp ids) must follow the mobile numbers/email info interchange mode (if I don't have yor email/mobile, I can't contact you) - keep always the user informed - consider integration of chryptopgraphy (keyczar.org ? ) Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/pom.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -470,8 +470,8 @@ <version>2.0-RC1</version> <configuration> <logLevel>INFO</logLevel> - <style>OBF</style> - <!-- <style>OBF PRETTY</style> --> + <!-- <style>OBF or PRETTY</style> --> + <style>PRETTY</style> <!-- <output>${project.build.directory}/gwt/www</output> --> Modified: trunk/src/main/java/org/ourproject/kune/app/Kune.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/Kune.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/app/Kune.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module rename-to='ws'> <inherits name='com.google.gwt.i18n.I18N' /> <inherits name='com.google.gwt.user.User' /> Modified: trunk/src/main/java/org/ourproject/kune/blogs/KuneBlogs.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/blogs/KuneBlogs.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/blogs/KuneBlogs.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <inherits name='org.ourproject.kune.platf.KunePlatform' /> <inherits name='org.ourproject.kune.workspace.KuneWorkspace' /> Modified: trunk/src/main/java/org/ourproject/kune/chat/KuneChat.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/KuneChat.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/chat/KuneChat.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <inherits name='org.ourproject.kune.platf.KunePlatform' /> <inherits name='org.ourproject.kune.workspace.KuneWorkspace' /> Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -22,13 +22,16 @@ import java.util.Collection; import java.util.Date; +import org.ourproject.kune.platf.client.actions.AbstractExtendedAction; +import org.ourproject.kune.platf.client.actions.ActionEvent; +import org.ourproject.kune.platf.client.actions.KeyStroke; +import org.ourproject.kune.platf.client.actions.Shortcut; import org.ourproject.kune.platf.client.app.Application; import org.ourproject.kune.platf.client.dto.InitDataDTO; import org.ourproject.kune.platf.client.dto.StateToken; import org.ourproject.kune.platf.client.dto.UserInfoDTO; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister; -import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor; import org.ourproject.kune.platf.client.state.Session; import org.ourproject.kune.platf.client.ui.WindowUtils; import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils; @@ -61,28 +64,29 @@ class ChatEngineDefault implements ChatEngine { private ChatConnectionOptions chatOptions; private final I18nTranslationService i18n; - private final WorkspaceSkeleton ws; + private final WorkspaceSkeleton wskel; private ToolbarButton traybarButton; private final Provider<EmiteUIDialog> emiteUIProvider; private final Provider<FileDownloadUtils> downloadUtils; private Collection<RosterItem> roster; private final Event0 onRosterChanged; - private final ShortcutDescriptor shortcut; + private final KeyStroke shortcut; - public ChatEngineDefault(final I18nTranslationService i18n, final WorkspaceSkeleton ws, + public ChatEngineDefault(final I18nTranslationService i18n, final WorkspaceSkeleton wskel, final Application application, final Session session, final Provider<EmiteUIDialog> emiteUIProvider, - final Provider<FileDownloadUtils> downloadUtils, final GlobalShortcutRegister globalShortcutRegister) { + final Provider<FileDownloadUtils> downloadUtils, final GlobalShortcutRegister shortcutRegister) { this.i18n = i18n; - this.ws = ws; + this.wskel = wskel; this.emiteUIProvider = emiteUIProvider; this.downloadUtils = downloadUtils; this.onRosterChanged = new Event0("onRosterChanged"); - shortcut = new ShortcutDescriptor(false, true, false, 'C'); - globalShortcutRegister.put(shortcut, new Listener0() { - public void onEvent() { + shortcut = Shortcut.getShortcut(false, true, false, false, Character.valueOf('C')); + shortcutRegister.put(shortcut, new AbstractExtendedAction() { + public void actionPerformed(final ActionEvent event) { if (isDialogStarted()) { toggleShow(); } + } }); session.onInitDataReceived(new Listener<InitDataDTO>() { @@ -177,7 +181,7 @@ }); } } else { - ws.showAlertMessage(i18n.t("Error"), i18n.t("To join a chatroom you need to be 'online'")); + wskel.showAlertMessage(i18n.t("Error"), i18n.t("To join a chatroom you need to be 'online'")); } } @@ -220,7 +224,7 @@ toggleShow(); } }); - ws.getSiteTraybar().addButton(traybarButton); + wskel.getSiteTraybar().addButton(traybarButton); emiteUIProvider.get().onChatAttended(new Listener<String>() { public void onEvent(final String parameter) { traybarButton.setIcon("images/e-icon.gif"); Modified: trunk/src/main/java/org/ourproject/kune/docs/KuneDocs.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/KuneDocs.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/docs/KuneDocs.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <inherits name='org.ourproject.kune.platf.KunePlatform' /> <inherits name='org.ourproject.kune.workspace.KuneWorkspace' /> Modified: trunk/src/main/java/org/ourproject/kune/gallery/KuneGallery.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/gallery/KuneGallery.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/gallery/KuneGallery.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <inherits name='org.ourproject.kune.platf.KunePlatform' /> <inherits name='org.ourproject.kune.workspace.KuneWorkspace' /> Modified: trunk/src/main/java/org/ourproject/kune/platf/KunePlatform.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/KunePlatform.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/KunePlatform.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User' /> Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/Shortcut.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/Shortcut.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/Shortcut.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -0,0 +1,25 @@ +package org.ourproject.kune.platf.client.actions; + +import org.ourproject.kune.platf.client.shortcuts.Keyboard; + +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 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); + } + + private Shortcut() { + } + +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -39,7 +39,7 @@ this.view = toolbar; } - public void addActions(final ActionItemCollection<T> actions, ActionToolbarPosition position) { + public void addActions(final ActionItemCollection<T> actions, final ActionToolbarPosition position) { for (final ActionItem<T> actionItem : actions) { final ActionDescriptor<T> action = actionItem.getAction(); if (actionItem.mustBeAdded()) { @@ -82,11 +82,11 @@ view.clear(); } - public int getLeftPosition(ActionDescriptor<T> action) { + public int getLeftPosition(final ActionDescriptor<T> action) { return view.getLeftPosition(action); } - public int getTopPosition(ActionDescriptor<T> action) { + public int getTopPosition(final ActionDescriptor<T> action) { return view.getTopPosition(action); } @@ -98,7 +98,7 @@ view.hideAllMenus(); } - public void setButtonEnable(ActionDescriptor<T> action, boolean enable) { + public void setButtonEnable(final ActionDescriptor<T> action, final boolean enable) { view.setButtonEnable(action, enable); } @@ -110,15 +110,16 @@ view.setNormalStyle(); } - public void setParentMenuTitle(ActionToolbarPosition position, String origTitle, String origTooltip, String newTitle) { + public void setParentMenuTitle(final ActionToolbarPosition position, final String origTitle, + final String origTooltip, final String newTitle) { view.setParentMenuTitle(position, origTitle, origTooltip, newTitle); } - public void setPushButtonPressed(ActionDescriptor<T> action, boolean pressed) { + public void setPushButtonPressed(final ActionDescriptor<T> action, final boolean pressed) { view.setPushButtonPressed(action, pressed); } - private boolean addInPosition(ActionDescriptor<T> action, ActionToolbarPosition position) { + private boolean addInPosition(final ActionDescriptor<T> action, final ActionToolbarPosition position) { if (position.equals(IN_ANY) || ((ActionToolbarDescriptor<T>) action).getActionPosition().equals(position)) { return true; } @@ -126,15 +127,15 @@ } private boolean isToolbarButton(final ActionDescriptor<T> action) { - return action instanceof ActionToolbarButtonDescriptor - || action instanceof ActionToolbarButtonAndItemDescriptor; + return action instanceof ActionToolbarButtonDescriptor<?> + || action instanceof ActionToolbarButtonAndItemDescriptor<?>; } private boolean isToolbarMenu(final ActionDescriptor<T> action) { return action instanceof ActionToolbarMenuDescriptor || action instanceof ActionToolbarMenuAndItemDescriptor; } - private boolean isToolbarPushButton(ActionDescriptor<T> action) { + private boolean isToolbarPushButton(final ActionDescriptor<T> action) { return action instanceof ActionToolbarPushButtonDescriptor; } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ExtMediaDescripDTO.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ExtMediaDescripDTO.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ExtMediaDescripDTO.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -14,15 +14,14 @@ private String idRegex; private String embedTemplate; private int width; - private int height; public ExtMediaDescripDTO() { this(null, null, null, null, null, 0, 0); } - public ExtMediaDescripDTO(final String name, final String siteurl, final String detectRegex, - final String idRegex, final String embedTemplate, final int defWidth, final int defHeight) { + public ExtMediaDescripDTO(final String name, final String siteurl, final String detectRegex, final String idRegex, + final String embedTemplate, final int defWidth, final int defHeight) { this.name = name; this.siteurl = siteurl; this.detectRegex = detectRegex; @@ -37,7 +36,7 @@ } public String getEmbed(final String url) { - String id = getId(url); + final String id = getId(url); String result = embedTemplate.replaceAll(URL, id); result = result.replaceAll(HEIGHT, "" + height); result = result.replaceAll(WIDTH, "" + width); @@ -53,7 +52,7 @@ } public String getId(final String url) { - String id = url.replaceFirst(idRegex, "$1"); + final String id = url.replaceFirst(idRegex, "$1"); return id; } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,32 +1,35 @@ package org.ourproject.kune.platf.client.shortcuts; -import org.ourproject.kune.platf.client.actions.ActionItem; -import org.ourproject.kune.platf.client.actions.ActionManager; +import org.ourproject.kune.platf.client.actions.AbstractAction; +import org.ourproject.kune.platf.client.actions.ActionEvent; +import org.ourproject.kune.platf.client.actions.InputMap; +import org.ourproject.kune.platf.client.actions.Shortcut; +import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.event.dom.client.KeyDownEvent; 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 GlobalShortcutRegister extends ShortcutRegister { +public class GlobalShortcutRegister extends InputMap { private final NativePreviewHandler eventHandler; private HandlerRegistration handlerReg; - public GlobalShortcutRegister(final ActionManager actionManager) { + public GlobalShortcutRegister() { super(); eventHandler = new NativePreviewHandler() { - @SuppressWarnings("unchecked") public void onPreviewNativeEvent(final NativePreviewEvent nativeEventPrev) { - final NativeEvent event = nativeEventPrev.getNativeEvent(); - if (nativeEventPrev.getAssociatedType().equals(KeyDownEvent.getType())) { - final ActionItem actionItem = get(event); - if (actionItem != null) { - // Log.debug("Not propagating event"); - event.stopPropagation(); - actionManager.doAction(actionItem); + 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"); + nativeEvent.stopPropagation(); + action.actionPerformed(new ActionEvent(nativeEvent.getCurrentEventTarget(), event)); nativeEventPrev.cancel(); } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kimg.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kimg.css 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kimg.css 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,3 +1,19 @@ @sprite div .k-icon-info { gwt-image: 'info'; } + +@sprite div .k-icon-language { + gwt-image: 'language'; +} + +@sprite div .k-icon-kuneIcon16 { + gwt-image: 'kuneIcon16'; +} + +@sprite div .k-icon-prefs { + gwt-image: 'prefs'; +} + +@sprite div .k-icon-groupHome { + gwt-image: 'groupHome'; +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -41,7 +41,7 @@ KuneUiUtils.setUnselectable(actionLabel.getElement()); actionLabel.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { - item.fire(new ActionEvent(actionLabel, (Event) event.getNativeEvent())); + item.fire(new ActionEvent(actionLabel, Event.as(event.getNativeEvent()))); } }); hpanel.insert(actionLabel, 0); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -15,6 +15,7 @@ import org.ourproject.kune.platf.client.actions.ActionEvent; import org.ourproject.kune.platf.client.actions.InputMap; import org.ourproject.kune.platf.client.actions.KeyStroke; +import org.ourproject.kune.platf.client.actions.Shortcut; import org.ourproject.kune.platf.client.actions.ui.AbstractActionExtensiblePresenter; import org.ourproject.kune.platf.client.actions.ui.ButtonDescriptor; import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection; @@ -29,7 +30,6 @@ import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor; import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor.Type; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; -import org.ourproject.kune.platf.client.shortcuts.Keyboard; import org.ourproject.kune.platf.client.state.Session; import org.ourproject.kune.platf.client.ui.img.ImgConstants; import org.ourproject.kune.platf.client.ui.noti.NotifyUser; @@ -901,71 +901,71 @@ final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractExtendedAction.NO_TEXT, imgResources.selectall()); final MenuItemDescriptor select = new MenuItemDescriptor(editMenu, selectAllAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('A'), Keyboard.MODIFIER_CTRL), selectAllAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('A')), selectAllAction); final BoldAction boldAction = new BoldAction(NO_TEXT, i18n.t("Bold"), imgResources.bold()); bold = new PushButtonDescriptor(boldAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('B'), Keyboard.MODIFIER_CTRL), boldAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('B')), boldAction); final ItalicAction italicAction = new ItalicAction(NO_TEXT, i18n.t("Italic"), imgResources.italic()); italic = new PushButtonDescriptor(italicAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_CTRL), italicAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('I')), italicAction); final UnderlineAction underlineAction = new UnderlineAction(NO_TEXT, i18n.t("Underline"), imgResources.underline()); underline = new PushButtonDescriptor(underlineAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('U'), Keyboard.MODIFIER_CTRL), underlineAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('U')), underlineAction); final SubscriptAction subscriptAction = new SubscriptAction(i18n.t("Subscript"), NO_TEXT, imgResources.subscript()); final MenuItemDescriptor subscript = new MenuItemDescriptor(formatMenu, subscriptAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(','), Keyboard.MODIFIER_CTRL), subscriptAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf(',')), subscriptAction); final SuperscriptAction superscriptAction = new SuperscriptAction(i18n.t("Superscript"), NO_TEXT, imgResources.superscript()); final MenuItemDescriptor superscript = new MenuItemDescriptor(formatMenu, superscriptAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('.'), Keyboard.MODIFIER_CTRL), superscriptAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('.')), superscriptAction); final JustifyLeftAction jfyLeftAction = new JustifyLeftAction(NO_TEXT, i18n.t("Left Justify"), imgResources.alignleft()); final ButtonDescriptor justifyLeft = new ButtonDescriptor(jfyLeftAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('L'), Keyboard.MODIFIER_CTRL), jfyLeftAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('L')), jfyLeftAction); final JustifyCentreAction jfyCentreAction = new JustifyCentreAction(NO_TEXT, i18n.t("Centre Justify"), imgResources.centerpara()); final ButtonDescriptor justifyCentre = new ButtonDescriptor(jfyCentreAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('E'), Keyboard.MODIFIER_CTRL), jfyCentreAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('E')), jfyCentreAction); final JustifyRightAction jfyRightAction = new JustifyRightAction(NO_TEXT, i18n.t("Right Justify"), imgResources.alignright()); final ButtonDescriptor justifyRight = new ButtonDescriptor(jfyRightAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('R'), Keyboard.MODIFIER_CTRL), jfyRightAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('R')), jfyRightAction); final UndoAction undoAction = new UndoAction(i18n.t("Undo"), NO_TEXT, imgResources.undo()); final UndoAction undoActionBtn = new UndoAction(NO_TEXT, i18n.t("Undo"), imgResources.undo()); final MenuItemDescriptor undo = new MenuItemDescriptor(editMenu, undoAction); final ButtonDescriptor undoBtn = new ButtonDescriptor(undoActionBtn); undoBtn.setPosition(0); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('Z'), Keyboard.MODIFIER_CTRL), undoAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('Z')), undoAction); final RedoAction redoAction = new RedoAction(i18n.t("Redo"), NO_TEXT, imgResources.redo()); final RedoAction redoActionBtn = new RedoAction(NO_TEXT, i18n.t("Redo"), imgResources.redo()); final MenuItemDescriptor redo = new MenuItemDescriptor(editMenu, redoAction); final ButtonDescriptor redoBtn = new ButtonDescriptor(redoActionBtn); redoBtn.setPosition(1); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('Y'), Keyboard.MODIFIER_CTRL), redoAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('Y')), redoAction); final CopyAction copyAction = new CopyAction(i18n.t("Copy"), NO_TEXT, imgResources.copy()); final MenuItemDescriptor copy = new MenuItemDescriptor(editMenu, copyAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('C'), Keyboard.MODIFIER_CTRL), copyAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('C')), copyAction); final CutAction cutAction = new CutAction(i18n.t("Cut"), NO_TEXT, imgResources.cut()); final MenuItemDescriptor cut = new MenuItemDescriptor(editMenu, cutAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('X'), Keyboard.MODIFIER_CTRL), cutAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('X')), cutAction); final PasteAction pasteAction = new PasteAction(i18n.t("Paste"), NO_TEXT, imgResources.paste()); final MenuItemDescriptor paste = new MenuItemDescriptor(editMenu, pasteAction); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('V'), Keyboard.MODIFIER_CTRL), pasteAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('V')), pasteAction); final EditHtmlAction editHtmlAction = new EditHtmlAction(i18n.t("Edit HTML"), NO_TEXT, imgResources.edithtml()); final MenuItemDescriptor editHtml = new MenuItemDescriptor(editMenu, editHtmlAction); @@ -974,7 +974,7 @@ final CommentAction commentAction = new CommentAction(i18n.t("Comment"), NO_TEXT, NO_ICON); final MenuItemDescriptor comment = new MenuItemDescriptor(insertMenu, commentAction); comment.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('M'), Keyboard.MODIFIER_CTRL), commentAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('M')), commentAction); final HrAction hlineAction = new HrAction(i18n.t("Horizontal line"), NO_TEXT, imgResources.hfixedline()); final HrAction hlineBtnAction = new HrAction(NO_TEXT, i18n.t("Horizontal line"), imgResources.hfixedline()); @@ -982,8 +982,7 @@ final ButtonDescriptor hlineBtn = new ButtonDescriptor(hlineBtnAction); hline.setAddCondition(extendedAddCond); hlineBtn.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(' '), Keyboard.MODIFIER_CTRL - + Keyboard.MODIFIER_SHIFT), hlineAction); + setActionShortcut(Shortcut.getShortcut(true, true, Character.valueOf(' ')), hlineAction); final BlockquoteAction blockquoteAction = new BlockquoteAction(i18n.t("Block Quotation"), NO_TEXT, NO_ICON); final MenuItemDescriptor blockquote = new MenuItemDescriptor(formatMenu, blockquoteAction); @@ -1007,12 +1006,12 @@ final OlAction olistAction = new OlAction(NO_TEXT, i18n.t("Numbered List"), imgResources.defaultnumbering()); final ButtonDescriptor olist = new ButtonDescriptor(olistAction); olist.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('7'), Keyboard.MODIFIER_CTRL), olistAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('7')), olistAction); final UlAction ulistAction = new UlAction(NO_TEXT, i18n.t("Bullet List"), imgResources.defaultbullet()); final ButtonDescriptor ulist = new ButtonDescriptor(ulistAction); ulist.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('8'), Keyboard.MODIFIER_CTRL), ulistAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('8')), ulistAction); final ImgAction imgAction = new ImgAction(i18n.t("Image..."), NO_TEXT, imgResources.images()); final ImgAction imgBtnAction = new ImgAction(NO_TEXT, i18n.t("Insert Image"), imgResources.images()); @@ -1038,11 +1037,9 @@ editLink.setAddCondition(extendedAddCond); editLinkBtn.setAddCondition(extendedAddCond); editLinkCtx.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('K'), Keyboard.MODIFIER_CTRL), editLinkAction, - editLinkBtnAction); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf('K')), editLinkAction, editLinkBtnAction); - final KeyStroke key_SK = KeyStroke.getKeyStroke(Character.valueOf('K'), Keyboard.MODIFIER_CTRL - + Keyboard.MODIFIER_SHIFT); + final KeyStroke key_SK = Shortcut.getShortcut(true, true, Character.valueOf('K')); final RemoveLinkAction delLinkBtnAction = new RemoveLinkAction(NO_TEXT, i18n.t("Remove Link"), imgResources.linkbreak()); final RemoveLinkAction delLinkCtxAction = new RemoveLinkAction(i18n.t("Remove"), NO_TEXT, @@ -1061,8 +1058,7 @@ final ButtonDescriptor removeFormatBtn = new ButtonDescriptor(remFormatBtnAc); removeFormat.setAddCondition(extendedAddCond); removeFormatBtn.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(' '), Keyboard.MODIFIER_CTRL), remFormatAction, - remFormatBtnAc); + setActionShortcut(Shortcut.getShortcut(true, Character.valueOf(' ')), remFormatAction, remFormatBtnAc); final InsertSpecialCharAction insCharAction = new InsertSpecialCharAction(i18n.t("Special characters..."), NO_TEXT, imgResources.specialchars()); @@ -1092,7 +1088,7 @@ imgResources.specialchars()); final MenuItemDescriptor devInfo = new MenuItemDescriptor(formatMenu, devInfoAction); devInfo.setAddCondition(extendedAddCond); - setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_ALT), devInfoAction); + setActionShortcut(Shortcut.getShortcut(false, true, false, false, Character.valueOf('I')), devInfoAction); actions = new GuiActionDescCollection(); addActions(fileMenu, editMenu, formatMenu, insertMenu, undo, redo, editMenuSep, copy, cut, paste, editMenuSep, @@ -1138,8 +1134,9 @@ final MenuRadioItemDescriptor fontSizeItem = new MenuRadioItemDescriptor(fontSizeMenu, fontSizeAction, FONT_SIZEGROUP); fontSizeItem.setAddCondition(basicAddCond); - // setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char) - // (48 + fontSize))), Keyboard.MODIFIER_CTRL), + // setActionShortcut(Shortcut.getShortcut(true, + // Character.valueOf(((char) + // (48 + fontSize)))), // fontSizeAction); fontSizeItem.setLocation(SNDBAR); actions.add(fontSizeItem); Modified: trunk/src/main/java/org/ourproject/kune/wiki/KuneWiki.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/wiki/KuneWiki.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/wiki/KuneWiki.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <inherits name='org.ourproject.kune.platf.KunePlatform' /> <inherits name='org.ourproject.kune.workspace.KuneWorkspace' /> Modified: trunk/src/main/java/org/ourproject/kune/workspace/KuneWorkspace.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/KuneWorkspace.gwt.xml 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/workspace/KuneWorkspace.gwt.xml 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,4 +1,4 @@ -<!DOCTYPE document SYSTEM "src/main/java/gwt-module.dtd"> +<!DOCTYPE document SYSTEM "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <inherits name='org.ourproject.kune.platf.KunePlatform' /> <inherits name="com.google.gwt.core.Core" /> Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -995,7 +995,7 @@ register(ApplicationComponentGroup.class, new Factory<GlobalShortcutRegister>(GlobalShortcutRegister.class) { @Override public GlobalShortcutRegister create() { - return new GlobalShortcutRegister(i(ActionManager.class)); + return new GlobalShortcutRegister(); } }); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -21,8 +21,10 @@ import org.ourproject.kune.platf.client.View; import org.ourproject.kune.platf.client.actions.AbstractAction; +import org.ourproject.kune.platf.client.actions.AbstractExtendedAction; import org.ourproject.kune.platf.client.actions.Action; import org.ourproject.kune.platf.client.actions.ActionEvent; +import org.ourproject.kune.platf.client.actions.Shortcut; import org.ourproject.kune.platf.client.actions.ui.MenuCheckItemDescriptor; import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor; import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor; @@ -33,7 +35,6 @@ import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked; import org.ourproject.kune.platf.client.services.AbstractExtendedModule; import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister; -import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor; import org.ourproject.kune.platf.client.ui.img.ImgResources; import org.ourproject.kune.platf.client.ui.noti.NotifyUser; import org.ourproject.kune.workspace.client.editor.ContentEditor; @@ -41,7 +42,6 @@ import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; import com.allen_sauer.gwt.log.client.Log; -import com.calclab.suco.client.events.Listener0; import com.calclab.suco.client.ioc.Provider; import com.calclab.suco.client.ioc.decorator.Singleton; import com.calclab.suco.client.ioc.module.Factory; @@ -294,11 +294,12 @@ /** * Global shortcut sample definition */ - i(GlobalShortcutRegister.class).put(new ShortcutDescriptor(false, true, false, 'S'), new Listener0() { - public void onEvent() { - NotifyUser.info("Global Ctrl+S pressed"); - } - }); + i(GlobalShortcutRegister.class).put(Shortcut.getShortcut(true, Character.valueOf('S')), + new AbstractExtendedAction() { + public void actionPerformed(final ActionEvent event) { + NotifyUser.info("Global Ctrl+S pressed"); + } + }); // And because nobody use this module, we get the class (to force the // creation of the Helloworld instance): Deleted: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -1,63 +0,0 @@ -package org.ourproject.kune.platf.client.actions; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; -import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked; -import org.ourproject.kune.platf.client.i18n.Resources; -import org.ourproject.kune.platf.client.shortcuts.Keyboard; -import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor; - -public class ActionShortcutTest { - - @Test - public void altS() { - final ShortcutDescriptor shortcut = new ShortcutDescriptor(false, true, false, 'S', null); - assertEquals(" (Alt+S)", shortcut.toString()); - assertTrue(shortcut.is('S', Keyboard.MODIFIER_ALT)); - assertTrue(!shortcut.is('S', Keyboard.MODIFIER_CTRL)); - assertTrue(!shortcut.is('S', Keyboard.MODIFIER_SHIFT)); - } - - @Before - public void before() { - new Resources(new I18nTranslationServiceMocked()); - } - - @Test - public void ctrlComa() { - final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, ','); - assertEquals(" (Ctrl+,)", shortcut.toString()); - assertTrue(shortcut.is(',', Keyboard.MODIFIER_CTRL)); - assertTrue(!shortcut.is(',', Keyboard.MODIFIER_ALT)); - assertTrue(!shortcut.is(',', Keyboard.MODIFIER_SHIFT)); - } - - @Test - public void ctrlS() { - final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, 's'); - assertEquals(" (Ctrl+S)", shortcut.toString()); - assertTrue(shortcut.is('s', Keyboard.MODIFIER_CTRL)); - assertTrue(!shortcut.is('s', Keyboard.MODIFIER_ALT)); - assertTrue(!shortcut.is('s', Keyboard.MODIFIER_SHIFT)); - } - - @Test - public void ctrlSCapital() { - final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, 'S'); - assertEquals(" (Ctrl+S)", shortcut.toString()); - assertTrue(shortcut.is('S', Keyboard.MODIFIER_CTRL)); - assertTrue(!shortcut.is('S', Keyboard.MODIFIER_ALT)); - assertTrue(!shortcut.is('S', Keyboard.MODIFIER_SHIFT)); - } - - @Test - public void ctrlShiftS() { - final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, false, true, 'S', null); - assertEquals(" (Ctrl+Shift+S)", shortcut.toString()); - assertTrue(!shortcut.is('S', Keyboard.MODIFIER_ALT)); - assertTrue(shortcut.is('S', Keyboard.MODIFIER_SHIFT | Keyboard.MODIFIER_CTRL)); - } -} Added: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ShortcutTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ShortcutTest.java 2009-06-14 20:00:52 UTC (rev 1129) +++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ShortcutTest.java 2009-06-25 14:55:19 UTC (rev 1130) @@ -0,0 +1,39 @@ +package org.ourproject.kune.platf.client.actions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked; +import org.ourproject.kune.platf.client.i18n.Resources; + +public class ShortcutTest { + @Test + public void altS() { + final KeyStroke shortcut = Shortcut.getShortcut(false, true, false, false, 'S'); + assertEquals(" (Alt+S)", shortcut.toString()); + } + + @Before + public void before() { + new Resources(new I18nTranslationServiceMocked()); + } + + @Test + public void ctrlComa() { + final KeyStroke shortcut = Shortcut.getShortcut(true, ','); + assertEquals(" (Ctrl+,)", shortcut.toString()); + } + + @Test + public void ctrlSCapital() { + final KeyStroke shortcut = Shortcut.getShortcut(true, 'S'); + assertEquals(" (Ctrl+S)", shortcut.toString()); + } + + @Test + public void ctrlShiftS() { + final KeyStroke shortcut = Shortcut.getShortcut(true, false, true, false, 'S'); + assertEquals(" (Ctrl+Shift+S)", shortcut.toString()); + } +}
participants (1)
-
vjrj