|
From: Kevin D. <ke...@tr...> - 2008-07-17 20:53:59
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD> <BODY leftMargin=1 topMargin=1 rightMargin=1><FONT face=Arial size=2> <DIV>One thing that may not be immediately evident about the Action class is that it supports any arbtrary 'property' via putValue(). So you can use the Action object as is to add any extra properties.</DIV> <DIV> </DIV> <DIV> </DIV> <DIV>One approach to consider: In JSR 296, the prefered way of setting a label and msemonic for an action would be via resource injection, instead of hard coding those values into the source. The resource file contains entries with the following convention:</DIV> <DIV> </DIV> <DIV><name>.Action.<propertyname>=<value></DIV> <DIV> </DIV> <DIV>So, there would be:</DIV> <DIV> </DIV> <DIV>save.Action.label=Save</DIV> <DIV>save.Action.mnemonic=S</DIV> <DIV> </DIV> <DIV> </DIV> <DIV>This opens the possibility for I18N. I could see where having those properties in the annotation itself would be useful for someone doing quick and dirty work where messing with resource files isn't desirable.</DIV> <DIV> </DIV> <DIV> </DIV> <DIV>Finally, I know that most Swing components already have keyboard accelerator support - I haven't done enough with that to comment on whether their approach is good or not - but it is something that's already there. I believe that they build a map between accelerators and actionmap entry names - so the accelerator looks up the *name* of the action. Then they look the actual action up in the actionmap of the container and invoke it. This decouples the accelerator implementation from the action implementation (separation of concerns and all). The advantage of that separation is that it sets the stage for user defined keyboard mappings, etc... It would be hard to achieve that if the accelerator is associated directly with the action (at least without a lot of close coupling).</DIV> <DIV> </DIV> <DIV>- K </DIV> <DIV> </DIV></FONT> <DIV style="FONT-SIZE: x-small; FONT-FAMILY: Tahoma"> <DIV>----------------------- <B>Original Message</B> -----------------------</DIV> <DIV> </DIV> <DIV><B>From:</B> "Peter De Bruycker" <A href="mailto:pet...@gm..."><FONT color=#0000ff><pet...@gm...></FONT></A></DIV> <DIV><B>To:</B> <A href="mailto:spr...@li..."><FONT color=#0000ff>spr...@li...</FONT></A></DIV> <DIV><B>Cc:</B> </DIV> <DIV><B>Date:</B> Thu, 17 Jul 2008 20:12:39 +0200</DIV> <DIV><B>Subject: <U>Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop] @Command style</U></B></DIV> <DIV> </DIV></DIV> <DIV dir=ltr><BR><BR> <DIV class=gmail_quote> <DIV><BR>Great idea, I'll update my code to reflect this. In addition to being compatible, we also have extra functionality: labels containing mnemonic info and accelerator info (&Save@Ctrl-S => label = Save, mnemonic=S, accelerator = Ctrl-S)<BR><BR> </DIV> <BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"> <DIV><FONT face=Arial size=2> <DIV></DIV> <DIV></FONT><FONT face=Tahoma size=2><BR> </DIV></DIV></BLOCKQUOTE></DIV></DIV></FONT></BODY></HTML> |