Re: [spring-desktop] Re: [Desktop] @Command style

View: New views
10 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [spring-desktop] Re: [Desktop] @Command style

by Kevin Day :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here are my thoughts on jsr 296:
 
1.  The @action annotation is extremely convenient
2.  Resource injection from properties files (both for control properties, and Action properties) is convenient
3.  Their approach to long running tasks is a good start - although I'm not sure that the JSR 296 implementation is as feature rich as it should be (for example, how do we make sure that tasks can get registered with a monitoring sub-system?)
 
The centralized caching mechanisms and singletons are not at all good (but the jsr 296 implementation doesn't force you to actually use those singletons - you can create the injectors individually).
 
 
I think that it is desirable to make Spring-Desktop be *compatible* with the JSR 296 approach to resource injection (i.e. use the same properties file, naming convention and file locations) so that users of 296 will find it easier to transition.
 
I'm a bit less certain of the importance of compatability on the @action annotation side of things (i.e. using the same annotation tags, etc...) - although having similar capabilities will be important (including bound Action properties in the annotations).
 
 
- K
 
----------------------- Original Message -----------------------
  
From: "Peter De Bruycker" peter.de.bruycker@...
Cc: 
Date: Thu, 17 Jul 2008 18:48:29 +0200
Subject: [spring-desktop] Re: [Desktop] @Command style
  
You're correct when you say we need to take a look at jsr 296, but we must also realize that the swing app framework is not very active for the moment (and I also doubt it will become active again in the near future).

The jsr has some great ideas, but also some serious limitations (singletons, etc).

regards,

Peter

On Thu, Jul 17, 2008 at 4:39 PM, Larry Streepy <lstreepy@...> wrote:
I can't applaud this effort enough.  I think it's really important that we take a look at JSR 296 and see how we can interoperate with it.  There's no reason to create our own solutions if they've already done something good in 296.  Mainly, let's not be different just because we didn't take a look.

Thanks Claudio.

Larry.


Claudio Romano wrote:
While looking at the new code in the adi-based-views branch I was
wondering whether it would function with JSR 296.
(https://appframework.dev.java.net/).
So I started a little prototype based on the adi-based-views branch. I
uploaded the prototype so everybody can get an idea how it could work:
http://groups.google.com/group/spring-desktop/web/adi-based-views-jsr296.zip

I'm not sure if it makes sense to try to adopt JSR 296 as there are
some limitation on the current (JSR 296) codebase. Although I'm sure
that most of them will be fixed in future releases. I was just curious
to see
if it could work for a prototype. I also wanted to figure out how they
solved the issues Action/Resources/Views/Livecycle...

One of the most disturbing things on JSR 296 are the singletons for
the ActionManager and the ResourceManager in the ApplicationContext,
this looks like spring-rcp singleton implementation. But I think this
could be avoided somehow.

I managed to make it work almost like the adi-base-views, the only
feature I was not able to develop is the possibility to attach the
View as a parameter to the action methods. But looking at the code it
seems as they have such a feature, but it only supports one parameter
per action method. the allowed parameter types are like: ActionEvent,
Action, ActionMap, ResourceMap, Application, ApplicationContext ...

The hole action/task part seems to be very robust and easy to
understand. It may help for the initial jump on the spring-deskop
action.

I now will try to make the current spring-desktop trunk work with JSR
296. If there is some interest I can post the results here. .... If I
will get any results actually ... ;)

I hope this little prototype will help to understand the similarities
and differences between spring-desktop and the JSR 296.
Claudio

On Jul 16, 11:29 pm, "Peter De Bruycker" peter.de.bruyc...@...
wrote:
  
On Wed, Jul 16, 2008 at 12:33 AM, Jim Moore moore....@... wrote:
    
Thanks for the link, Kevin.  I like parts of what I glanced at, and am not
crazy about others, but it's certainly worth a much closer look.  I
definitely like the Task support.
      
This definitely looks nice! I think it can be implemented using Spin (http://spin.sourceforge.net/).



    
The primary reason for not using javax.swing.Action is really ignorance of
JSR 296.  That kind of functionality is known as Commands in Spring RC, so
just going with that terminology.  It looks like there may be reasons for
not using @Action (such as using Spring's auto-detection support), but it
will take closer investigation before making that determination.  (It's well
worth the bother of trying to be JSR 296 compliant as much as possible.)
      
Right now -- if I'm understanding it correctly -- @Action would be more of
a replacement for what we are currently using @Invoker for inside of views,
not for defining external general commands/actions (such as "help" or
"exit").  How does JSR 296 handle running view-external events?
      
-Jim Moore
      
On Tue, Jul 15, 2008 at 3:21 PM, Kevin Day ke...@... wrote:
      
 If anyone hasn't taken a look at JSR 296, I recommend reading (
http://java.sun.com/developer/technicalArticles/javase/swingappfr/) - the
Actions and Tasks section of that page is pertinent to the current
discussion.  Especially the ability of a declared action to return a
background processing thread...
        
Also, is there any reason that we are using Command instead of
javax.swing.Action ?  I'm sure there is historical significance, and I
wanted to make sure I understood.
        
- K
        
  





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spring-Desktop" group.
To post to this group, send email to spring-desktop@...
To unsubscribe from this group, send email to spring-desktop-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/spring-desktop?hl=en
-~----------~----~----~----~------~----~------~--~---


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev

Re: [spring-desktop] Re: [Desktop] @Command style

by Peter De Bruycker-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, Jul 17, 2008 at 7:10 PM, Kevin Day <kevin@...> wrote:
Here are my thoughts on jsr 296:
 
1.  The @action annotation is extremely convenient

Indeed! This is definitely the road we need to take: we need to make it extremely convenient for developers to create feature rich desktop applications.
 
2.  Resource injection from properties files (both for control properties, and Action properties) is convenient

This is what I'm working on now. Anything is "resource-injectable", as long as the correct interfaces are implemented. Perhaps we can try to apply annotations in this domain also?
 
3.  Their approach to long running tasks is a good start - although I'm not sure that the JSR 296 implementation is as feature rich as it should be (for example, how do we make sure that tasks can get registered with a monitoring sub-system?)
 
The centralized caching mechanisms and singletons are not at all good (but the jsr 296 implementation doesn't force you to actually use those singletons - you can create the injectors individually).
 
 
I think that it is desirable to make Spring-Desktop be *compatible* with the JSR 296 approach to resource injection (i.e. use the same properties file, naming convention and file locations) so that users of 296 will find it easier to transition.
 

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)

 
I'm a bit less certain of the importance of compatability on the @action annotation side of things (i.e. using the same annotation tags, etc...) - although having similar capabilities will be important (including bound Action properties in the annotations).
 

I agree, we need our own annotation, but being similar (in appearance and behaviour) would be a good thing.

regards,

Peter
 
 
- K
 
----------------------- Original Message -----------------------
  
From: "Peter De Bruycker" peter.de.bruycker@...
Cc: 
Date: Thu, 17 Jul 2008 18:48:29 +0200
Subject: [spring-desktop] Re: [Desktop] @Command style
  
You're correct when you say we need to take a look at jsr 296, but we must also realize that the swing app framework is not very active for the moment (and I also doubt it will become active again in the near future).

The jsr has some great ideas, but also some serious limitations (singletons, etc).

regards,

Peter

On Thu, Jul 17, 2008 at 4:39 PM, Larry Streepy <lstreepy@...> wrote:
I can't applaud this effort enough.  I think it's really important that we take a look at JSR 296 and see how we can interoperate with it.  There's no reason to create our own solutions if they've already done something good in 296.  Mainly, let's not be different just because we didn't take a look.

Thanks Claudio.

Larry.


Claudio Romano wrote:
While looking at the new code in the adi-based-views branch I was
wondering whether it would function with JSR 296.
(https://appframework.dev.java.net/).
So I started a little prototype based on the adi-based-views branch. I
uploaded the prototype so everybody can get an idea how it could work:
http://groups.google.com/group/spring-desktop/web/adi-based-views-jsr296.zip

I'm not sure if it makes sense to try to adopt JSR 296 as there are
some limitation on the current (JSR 296) codebase. Although I'm sure
that most of them will be fixed in future releases. I was just curious
to see
if it could work for a prototype. I also wanted to figure out how they
solved the issues Action/Resources/Views/Livecycle...

One of the most disturbing things on JSR 296 are the singletons for
the ActionManager and the ResourceManager in the ApplicationContext,
this looks like spring-rcp singleton implementation. But I think this
could be avoided somehow.

I managed to make it work almost like the adi-base-views, the only
feature I was not able to develop is the possibility to attach the
View as a parameter to the action methods. But looking at the code it
seems as they have such a feature, but it only supports one parameter
per action method. the allowed parameter types are like: ActionEvent,
Action, ActionMap, ResourceMap, Application, ApplicationContext ...

The hole action/task part seems to be very robust and easy to
understand. It may help for the initial jump on the spring-deskop
action.

I now will try to make the current spring-desktop trunk work with JSR
296. If there is some interest I can post the results here. .... If I
will get any results actually ... ;)

I hope this little prototype will help to understand the similarities
and differences between spring-desktop and the JSR 296.
Claudio

On Jul 16, 11:29 pm, "Peter De Bruycker" peter.de.bruyc...@...
wrote:
  
On Wed, Jul 16, 2008 at 12:33 AM, Jim Moore moore....@... wrote:
    
Thanks for the link, Kevin.  I like parts of what I glanced at, and am not
crazy about others, but it's certainly worth a much closer look.  I
definitely like the Task support.
      
This definitely looks nice! I think it can be implemented using Spin (http://spin.sourceforge.net/).



    
The primary reason for not using javax.swing.Action is really ignorance of
JSR 296.  That kind of functionality is known as Commands in Spring RC, so
just going with that terminology.  It looks like there may be reasons for
not using @Action (such as using Spring's auto-detection support), but it
will take closer investigation before making that determination.  (It's well
worth the bother of trying to be JSR 296 compliant as much as possible.)
      
Right now -- if I'm understanding it correctly -- @Action would be more of
a replacement for what we are currently using @Invoker for inside of views,
not for defining external general commands/actions (such as "help" or
"exit").  How does JSR 296 handle running view-external events?
      
-Jim Moore
      
On Tue, Jul 15, 2008 at 3:21 PM, Kevin Day ke...@... wrote:
      
 If anyone hasn't taken a look at JSR 296, I recommend reading (
http://java.sun.com/developer/technicalArticles/javase/swingappfr/) - the
Actions and Tasks section of that page is pertinent to the current
discussion.  Especially the ability of a declared action to return a
background processing thread...
        
Also, is there any reason that we are using Command instead of
javax.swing.Action ?  I'm sure there is historical significance, and I
wanted to make sure I understood.
        
- K
        
  





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spring-Desktop" group.
To post to this group, send email to spring-desktop@...
To unsubscribe from this group, send email to spring-desktop-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/spring-desktop?hl=en
-~----------~----~----~----~------~----~------~--~---


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev

Re: [spring-desktop] Re: [Desktop] @Command style

by Kevin Day :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.
 
 
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:
 
<name>.Action.<propertyname>=<value>
 
So, there would be:
 
save.Action.label=Save
save.Action.mnemonic=S
 
 
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.
 
 
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).
 
- K 
 
----------------------- Original Message -----------------------
  
From: "Peter De Bruycker" peter.de.bruycker@...
Cc: 
Date: Thu, 17 Jul 2008 20:12:39 +0200
Subject: Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop] @Command style
  



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)

 

 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev

Re: [spring-desktop] Re: [Desktop] @Command style

by Kevin Day :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
After I wrote this, I did some more research, and I now see that Action actually has built in property strings for ACCELERATOR_KEY, ACTION_COMMAND_KEY, MNEMONIC_KEY.  I don't know that the JSR296 resource injector takes care of translating values for this (for example, the ACCELERATOR_KEY property needs to be set to an instance of the KeyStroke class).  It does some types of conversion (colors, for example), but maybe not at that level.
 
 
 
The javax.swing.text.KeyMap class is what takes care of mapping actual keystrokes to actions - it appears that they do *not* translate between keystrokes and actionmap entry names (I implied otherwise in my post below).  They map directly between keystrokes and actions.  And the KeyMap is generally held by a container object.  Oh yes, and KeyMaps can chain up the component hierarchy, delegating to parent containers, etc... as necessary.
 
The Action's property (for MNEMONIC_KEY, for example) is a bound property, so when it changes, it fires a change into the ButtonModel.  The ButtonModel has a similar property, which is bound to the parent container when the button is added to the parent.  So the parent maintains the KeyMap, and it can respond to changes in the properties of the Action by re-arranging the KeyMap when property change events are fired.
 
 
So this raises an interesting question in my mind:  It seems like Swing has done a huge amount of the heavy lifting here - and AbstractAction has pretty much all of the functionality that is being discussed.  Is it just a matter of extending the resource injection to support these additional properties, or is there something about Swing's approach that is lacking?
 
- K
 
----------------------- Original Message -----------------------
  
From: Kevin Day kevin@...
Cc: 
Date: Thu, 17 Jul 2008 13:53:48 -0700
Subject: Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop] @Command style
  
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.
 
 
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:
 
<name>.Action.<propertyname>=<value>
 
So, there would be:
 
save.Action.label=Save
save.Action.mnemonic=S
 
 
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.
 
 
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).
 
- K 
 
----------------------- Original Message -----------------------
  
From: "Peter De Bruycker" peter.de.bruycker@...
Cc: 
Date: Thu, 17 Jul 2008 20:12:39 +0200
Subject: Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop] @Command style
  



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)

 

 
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev

Re: [spring-desktop] Re: [Desktop] @Command style

by Claudio Romano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kevin Day wrote:

>
> After I wrote this, I did some more research, and I now see that Action
> actually has built in property strings for ACCELERATOR_KEY,
> ACTION_COMMAND_KEY, MNEMONIC_KEY.  I don't know that the JSR296 resource
> injector takes care of translating values for this (for example, the
> ACCELERATOR_KEY property needs to be set to an instance of the KeyStroke
> class).  It does some types of conversion (colors, for example), but
> maybe not at that level.
>  
>  

Hi Kevin,

hope i understood you correctly. JSR 296 supports accelerator injected by
resource files: <name>.Action.accelerator=<value> (control O)

this is done in org.jdesktop.application.ApplicationAction that extends
.javax.swing.AbstractAction

Just a little note, i looks like the resource injection in JSR 296 was inspired
by the fuse framework:

- https://fuse.dev.java.net/
- http://www.javalobby.org/articles/swing-fuse/

In previous post there was the idea to make the anything "resource-injectable"
perhaps with the use of annotations.

Fuse give us really good hints on about it could be achieved:

[Quote from fuse.dev.java.net]

By default, Fuse generates a key to reference each resource and looks up this
key in the resource set. This key uses the following format: ClassName.fieldName
where ClassName is the name of the object's class without the package prefix.
This default behavior might provoke namespace collisions if two of your
components have the same name in different packages. You may also want to map a
resource to a name of your own. To do this, you can use one of the two naming
parameters offered by the @InjectedResource  annotation:

* key: Defines the key that maps the resource value in the properties set.
* name: Defines the name used in lieu of the field name to map the resource
value in the properties set.

Here is an example of how to use those two parameters:

class RectangleComponent extends JComponent {
  @InjectedResource(key="Common.backgroundColor")
  private Color rectColor;
       
  @InjectedResource(name="text")
  private Color textColor;
}

These resources will map to the following entries in the resource file (using
the PropertiesResourceLoader):

 Common.backgroundColor=#FF0000
 RectangleComponent.text=#00FF00

As you can see, the parameter name affects only the right part of the key name.
If you define both parameters at the same time, only the key parameter will be
taken into account and the name parameter ignored, since the key value also
contains the name in it.

When a property name cannot be found and a key parameter is not declared, Fuse
will try to fall back to a resource named *.id where id is either the field name
or the name parameter. This lets you create global resources very easily:

class RectangleComponent extends JComponent {
  @InjectedResource
  private Color background;
               
  @InjectedResource(name="foreground")
  private Color foregroundColor;
}

[End of Quote from fuse.dev.java.net]

The support for resources references is also helpfull:
 Common.textColor=#000000
 TitleComponent.textColor={Common.textColor}

Another nice idea in fuse is to have an interface to encapsulate the loading of
resource properties from within various formats (such as XML, properties, JDBC,
etc...)


It looks like there is pretty much no activity on the fuse project, so I don't
think spring-desktop should support and or use fuse_ (We never used it on a real
live project in our company), but the ideas on naming resources ,resources
references and resource loaders are quite nice.

hope it helps

_
Claudio



>  
> The javax.swing.text.KeyMap class is what takes care of mapping actual
> keystrokes to actions - it appears that they do *not* translate between
> keystrokes and actionmap entry names (I implied otherwise in my post
> below).  They map directly between keystrokes and actions.  And the
> KeyMap is generally held by a container object.  Oh yes, and KeyMaps can
> chain up the component hierarchy, delegating to parent containers,
> etc... as necessary.
>  
> The Action's property (for MNEMONIC_KEY, for example) is a bound
> property, so when it changes, it fires a change into the ButtonModel.  
> The ButtonModel has a similar property, which is bound to the parent
> container when the button is added to the parent.  So the parent
> maintains the KeyMap, and it can respond to changes in the properties of
> the Action by re-arranging the KeyMap when property change events are fired.
>  
>  
> So this raises an interesting question in my mind:  It seems like Swing
> has done a huge amount of the heavy lifting here - and AbstractAction
> has pretty much all of the functionality that is being discussed.  Is it
> just a matter of extending the resource injection to support these
> additional properties, or is there something about Swing's approach that
> is lacking?
>  
> - K
>  
> ----------------------- *Original Message* -----------------------
>  
> *From:* Kevin Day <kevin@...> <mailto:kevin@...>
> *To:*  springframework-rcp-dev-request@...
> <mailto:springframework-rcp-dev-request@...>
> <springframework-rcp-dev@...>
> <mailto:springframework-rcp-dev@...>
> *Cc:*
> *Date:* Thu, 17 Jul 2008 13:53:48 -0700
> *Subject:  Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]
> @Command style *
>  
> 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.
>  
>  
> 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:
>  
> <name>.Action.<propertyname>=<value>
>  
> So, there would be:
>  
> save.Action.label=Save
> save.Action.mnemonic=S
>  
>  
> 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.
>  
>  
> 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).
>  
> - K
>  
> ----------------------- *Original Message* -----------------------
>  
> *From:* "Peter De Bruycker" <peter.de.bruycker@...>
> <mailto:peter.de.bruycker@...>
> *To:*  springframework-rcp-dev@...
> <mailto:springframework-rcp-dev@...>
> *Cc:*
> *Date:* Thu, 17 Jul 2008 20:12:39 +0200
> *Subject:  Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]
> @Command style *
>  
>
>
>
> 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)
>
>  
>
>
>      
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>
> _______________________________________________
> Springframework-rcp-dev mailing list
> Springframework-rcp-dev@...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Springframework-rcp-dev mailing list
> Springframework-rcp-dev@...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev

Re: [spring-desktop] Re: [Desktop] @Command style

by luano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

And with Hans Muller's move to Adobe it looks like JSR 296 is dead in
the water too.

2008/7/18 Claudio Romano <claudio.romano@...>:

> Kevin Day wrote:
>>
>> After I wrote this, I did some more research, and I now see that Action
>> actually has built in property strings for ACCELERATOR_KEY,
>> ACTION_COMMAND_KEY, MNEMONIC_KEY.  I don't know that the JSR296 resource
>> injector takes care of translating values for this (for example, the
>> ACCELERATOR_KEY property needs to be set to an instance of the KeyStroke
>> class).  It does some types of conversion (colors, for example), but
>> maybe not at that level.
>>
>>
>
> Hi Kevin,
>
> hope i understood you correctly. JSR 296 supports accelerator injected by
> resource files: <name>.Action.accelerator=<value> (control O)
>
> this is done in org.jdesktop.application.ApplicationAction that extends
> .javax.swing.AbstractAction
>
> Just a little note, i looks like the resource injection in JSR 296 was inspired
> by the fuse framework:
>
> - https://fuse.dev.java.net/
> - http://www.javalobby.org/articles/swing-fuse/
>
> In previous post there was the idea to make the anything "resource-injectable"
> perhaps with the use of annotations.
>
> Fuse give us really good hints on about it could be achieved:
>
> [Quote from fuse.dev.java.net]
>
> By default, Fuse generates a key to reference each resource and looks up this
> key in the resource set. This key uses the following format: ClassName.fieldName
> where ClassName is the name of the object's class without the package prefix.
> This default behavior might provoke namespace collisions if two of your
> components have the same name in different packages. You may also want to map a
> resource to a name of your own. To do this, you can use one of the two naming
> parameters offered by the @InjectedResource  annotation:
>
> * key: Defines the key that maps the resource value in the properties set.
> * name: Defines the name used in lieu of the field name to map the resource
> value in the properties set.
>
> Here is an example of how to use those two parameters:
>
> class RectangleComponent extends JComponent {
>  @InjectedResource(key="Common.backgroundColor")
>  private Color rectColor;
>
>  @InjectedResource(name="text")
>  private Color textColor;
> }
>
> These resources will map to the following entries in the resource file (using
> the PropertiesResourceLoader):
>
>  Common.backgroundColor=#FF0000
>  RectangleComponent.text=#00FF00
>
> As you can see, the parameter name affects only the right part of the key name.
> If you define both parameters at the same time, only the key parameter will be
> taken into account and the name parameter ignored, since the key value also
> contains the name in it.
>
> When a property name cannot be found and a key parameter is not declared, Fuse
> will try to fall back to a resource named *.id where id is either the field name
> or the name parameter. This lets you create global resources very easily:
>
> class RectangleComponent extends JComponent {
>  @InjectedResource
>  private Color background;
>
>  @InjectedResource(name="foreground")
>  private Color foregroundColor;
> }
>
> [End of Quote from fuse.dev.java.net]
>
> The support for resources references is also helpfull:
>  Common.textColor=#000000
>  TitleComponent.textColor={Common.textColor}
>
> Another nice idea in fuse is to have an interface to encapsulate the loading of
> resource properties from within various formats (such as XML, properties, JDBC,
> etc...)
>
>
> It looks like there is pretty much no activity on the fuse project, so I don't
> think spring-desktop should support and or use fuse_ (We never used it on a real
> live project in our company), but the ideas on naming resources ,resources
> references and resource loaders are quite nice.
>
> hope it helps
>
> _
> Claudio
>
>
>
>>
>> The javax.swing.text.KeyMap class is what takes care of mapping actual
>> keystrokes to actions - it appears that they do *not* translate between
>> keystrokes and actionmap entry names (I implied otherwise in my post
>> below).  They map directly between keystrokes and actions.  And the
>> KeyMap is generally held by a container object.  Oh yes, and KeyMaps can
>> chain up the component hierarchy, delegating to parent containers,
>> etc... as necessary.
>>
>> The Action's property (for MNEMONIC_KEY, for example) is a bound
>> property, so when it changes, it fires a change into the ButtonModel.
>> The ButtonModel has a similar property, which is bound to the parent
>> container when the button is added to the parent.  So the parent
>> maintains the KeyMap, and it can respond to changes in the properties of
>> the Action by re-arranging the KeyMap when property change events are fired.
>>
>>
>> So this raises an interesting question in my mind:  It seems like Swing
>> has done a huge amount of the heavy lifting here - and AbstractAction
>> has pretty much all of the functionality that is being discussed.  Is it
>> just a matter of extending the resource injection to support these
>> additional properties, or is there something about Swing's approach that
>> is lacking?
>>
>> - K
>>
>> ----------------------- *Original Message* -----------------------
>>
>> *From:* Kevin Day <kevin@...> <mailto:kevin@...>
>> *To:*  springframework-rcp-dev-request@...
>> <mailto:springframework-rcp-dev-request@...>
>> <springframework-rcp-dev@...>
>> <mailto:springframework-rcp-dev@...>
>> *Cc:*
>> *Date:* Thu, 17 Jul 2008 13:53:48 -0700
>> *Subject:  Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]
>> @Command style *
>>
>> 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.
>>
>>
>> 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:
>>
>> <name>.Action.<propertyname>=<value>
>>
>> So, there would be:
>>
>> save.Action.label=Save
>> save.Action.mnemonic=S
>>
>>
>> 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.
>>
>>
>> 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).
>>
>> - K
>>
>> ----------------------- *Original Message* -----------------------
>>
>> *From:* "Peter De Bruycker" <peter.de.bruycker@...>
>> <mailto:peter.de.bruycker@...>
>> *To:*  springframework-rcp-dev@...
>> <mailto:springframework-rcp-dev@...>
>> *Cc:*
>> *Date:* Thu, 17 Jul 2008 20:12:39 +0200
>> *Subject:  Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]
>> @Command style *
>>
>>
>>
>>
>> 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)
>>
>>
>>
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>
>> _______________________________________________
>> Springframework-rcp-dev mailing list
>> Springframework-rcp-dev@...
>> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Springframework-rcp-dev mailing list
>> Springframework-rcp-dev@...
>> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Springframework-rcp-dev mailing list
> Springframework-rcp-dev@...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev

Re: [spring-desktop] Re: [Desktop] @Command style

by Kevin Day :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
From what I see here, it looks like Fuse is geared towards injection into fields that have been annotated.  What I like about the JSR 296 implementation is that these tags are not necessary for the setting of properties on UI components and Actions.  It uses convention instead of explicit annotations, and that makes things much cleaner.  Interestingly, the ability to inject resources into object fields using explicit tags (which is supported by JSR 296) is the one area that I thought wasn't all that useful.  This may be short-sited on my part, but I just don't see myself specifying a color in a resource file and injecting it into an object, but not make that color be exposed as a property of the object.
 
 
Now back to my comment about type conversion during resource injection:  The JSR 296 approach works fine for Strings.  And it has some special String->Object handling for certain types of objects (for example, it can convert a string of form '##RRGGBB' into a Color object).  I'm not sure that they have created support for converting the string 'S' from a resource file into a KeyStroke object (which would be required for setting the various *_KEY properties of Action - these properties don't accept simple strings - they need to be KeyStroke objects).  I'll have to do some digging into their code to tell for sure.
 
This isn't that hard to implement, but it would require intelligent parsing (i.e. if the key is of form *.Action.acceleratorKey, then convert the value to KeyStroke prior to setting the value on the Action.
 
 
As I see it, the trick to auto-injection of resource properties is always in determining the object ID.  For JComponents, we can use the name property.  For actions that are created from annotations, we can create a name or id property on the generated action.  For the general case, if the resource injection is the same for all instances of a given class, then an id can be specified in an annotation on the class.  For object instances that need to have different resource injection, some form of id/name property will be required - OR the object will need to be registered in such a way that id/name meta data can be associated with the object.
 
 
The bigger design question on all of this is how to get those resources injected automagically.  Right now JSR 296 requires explicit injection calls - and the temptation to put those calls directly into the object itself via the Application singleton is high.  I've already seen that the Jigloo GUI builder does this.  This may be one of those scenarios where whiteboard comes into play:
 
Create object
Register the object with the service manager (possibly with an optional name/id property specified???)
Service manager notifies listeners that an object of class Foo has been registered
A resource injector service (which set itself up to listen for registration of classes that it should be doing injections for) gets notified, and does it's work
 
 
There's still the trick of locating the service manager - perhaps a discussion for another post...
 
- K
 
----------------------- Original Message -----------------------
  
From: Claudio Romano claudio.romano@...
Cc: 
Date: Fri, 18 Jul 2008 09:49:50 +0000 (UTC)
Subject: Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]    @Command style
  
Kevin Day wrote:

>
> After I wrote this, I did some more research, and I now see that Action
> actually has built in property strings for ACCELERATOR_KEY,
> ACTION_COMMAND_KEY, MNEMONIC_KEY.  I don't know that the JSR296 resource
> injector takes care of translating values for this (for example, the
> ACCELERATOR_KEY property needs to be set to an instance of the KeyStroke
> class).  It does some types of conversion (colors, for example), but
> maybe not at that level.
>  
>  

Hi Kevin,

hope i understood you correctly. JSR 296 supports accelerator injected by
resource files: <name>.Action.accelerator=<value> (control O)

this is done in org.jdesktop.application.ApplicationAction that extends
.javax.swing.AbstractAction

Just a little note, i looks like the resource injection in JSR 296 was inspired
by the fuse framework:

- https://fuse.dev.java.net/
- http://www.javalobby.org/articles/swing-fuse/

In previous post there was the idea to make the anything "resource-injectable"
perhaps with the use of annotations.

Fuse give us really good hints on about it could be achieved:

[Quote from fuse.dev.java.net]

By default, Fuse generates a key to reference each resource and looks up this
key in the resource set. This key uses the following format: ClassName.fieldName
where ClassName is the name of the object's class without the package prefix.
This default behavior might provoke namespace collisions if two of your
components have the same name in different packages. You may also want to map a
resource to a name of your own. To do this, you can use one of the two naming
parameters offered by the @InjectedRes ource  annotation:

* key: Defines the key that maps the resource value in the properties set.
* name: Defines the name used in lieu of the field name to map the resource
value in the properties set.

Here is an example of how to use those two parameters:

class RectangleComponent extends JComponent {
 @InjectedResource(key="Common.backgroundColor")
 private Color rectColor;
    
 @InjectedResource(name="text")
 private Color textColor;
}

These resources will map to the following entries in the resource file (using
the PropertiesResourceLoader):

Common.backgroundColor=#FF0000
RectangleComponent.text=#00FF00

As you can see, the parameter name affects only the right part of the key name.
If you define both parameters at the same time, only the key parameter will be
taken into account and the name parameter ignored, since the key value also
contains the nam e in it.

When a property name cannot be found and a key parameter is not declared, Fuse
will try to fall back to a resource named *.id where id is either the field name
or the name parameter. This lets you create global resources very easily:

class RectangleComponent extends JComponent {
 @InjectedResource
 private Color background;
        
 @InjectedResource(name="foreground")
 private Color foregroundColor;
}

[End of Quote from fuse.dev.java.net]

The support for resources references is also helpfull:
Common.textColor=#000000
TitleComponent.textColor={Common.textColor}

Another nice idea in fuse is to have an interface to encapsulate the loading of
resource properties from within various formats (such as XML, properties, JDBC,
etc...)


It looks like there is pretty much no activity on the fuse project, so I don't
think spring-deskto p should support and or use fuse_ (We never used it on a real
live project in our company), but the ideas on naming resources ,resources
references and resource loaders are quite nice.

hope it helps

_
Claudio



>  
> The javax.swing.text.KeyMap class is what takes care of mapping actual
> keystrokes to actions - it appears that they do *not* translate between
> keystrokes and actionmap entry names (I implied otherwise in my post
> below).  They map directly between keystrokes and actions.  And the
> KeyMap is generally held by a container object.  Oh yes, and KeyMaps can
> chain up the component hierarchy, delegating to parent containers,
> etc... as necessary.
>  
> The Action's property (for MNEMONIC_KEY, for example) is a bound
> property, so when it changes, it fires a change into the ButtonModel.  
> The ButtonModel has a similar property, which is bound to the parent
> container when the button is added to the parent.  So the parent
> maintains the KeyMap, and it can respond to changes in the properties of
> the Action by re-arranging the KeyMap when property change events are fired.
>  
>  
> So this raises an interesting question in my mind:  It seems like Swing
> has done a huge amount of the heavy lifting here - and AbstractAction
> has pretty much all of the functionality that is being discussed.  Is it
> just a matter of extending the resource injection to support these
> additional properties, or is there something about Swing's approach that
> is lacking?
>  
> - K
>  
> ----------------------- *Original Message* -----------------------
>   
> *From:* Kevin Day kevin@... kevin@...
> *To:*  springframework-rcp-dev-request@...
> springframework-rcp-dev-request@...
> springframework-rcp-dev@...
> springframework-rcp-dev@...
> *Cc:*
> *Date:* Thu, 17 Jul 2008 13:53:48 -0700
> *Subject:  Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]
> @Command style *
>   
> One thing that may not be immediatel y 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.
>  
>  
> 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:
>  
> <name>.Action.<propertyname>=<value>
>  
> So, there would be:
>  
> save.Action.label=Save
> save.Action.mnemonic=S
>  
>  
> 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.
& gt;  

>  
> 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).
>  
> - K
>  < BR>> ----------------------- *Original Message* -----------------------
>   
> *From:* "Peter De Bruycker" peter.de.bruycker@...
> peter.de.bruycker@...
> *To:*  springframework-rcp-dev@...
> springframework-rcp-dev@...
> *Cc:*
> *Date:* Thu, 17 Jul 2008 20:12:39 +0200
> *Subject:  Re: [Springframework-rcp-dev] [spring-desktop] Re: [Desktop]
> @Command style *
>   
>
>
>
> 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@... => label = Save, mnemonic=S,
> accelerator = Ctrl-S)
>
>  
>
>
>       
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>
> _______________________________________________
> Springframework-rcp-dev m ailing list
> Springframework-rcp-dev@...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> < BR>>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Springframework-rcp-dev mailing list
> Springframework-rcp-dev@...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest .org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Springframework-rcp-dev mailing list
Springframework-rcp-dev@...
https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev