Re: Allow to register a converter for actions

List for Users of Carlsbad Cubes' Technologies and Products <[email protected]> Tue, 01 Nov 2005 07:37:20 +0200
Newsgroups gmane.comp.embedded.carlsbad-cubes
Organization http://freemail.web.de/
Message-ID <[email protected]>

List for Users of Carlsbad Cubes' Technologies and Products <[email protected]> schrieb am 31.10.05 22:40:35:
> 
> Hi Frank,
> 
> Thanks for your answer, i have the following questions/comments if you 
> have the time to answer,
> 
> List for Users of Carlsbad Cubes' Technologies and Products wrote:
> 
> >while I see some sense in your code, there are a few things I would
> >like to point out to consider them.
> >
> >- Since the last Swixml release, the action fields do not need to be public anymore
> >  
> >
> Okay but i don't want to have a field - even private - in my client 
> class to be allowed to bind an action to a gui component. Potentially 
> the client class is totally unrelated with the actions i want to bind to 
> my gui objects, so i would prefer to not be mandatory to declare field 
> for this actions in the client class of the swing engine.

Hello Ludo,

I agree, I use the action-field approach only for selected components as
well. 

> 
> >- To init construct a (Abstract)Button from an action, there is the initclass-attribute
> >  along with the possibility to invoke a singleton on the desired class (public
> >  static Action getInstance())
> >  
> >
> It's okay but i have a priori no will to model and add singleton for my 
> module, apart this case ;-). I pass an argument in the constructor of 
> the actions returned by my action manager, and although i can perhaps 
> retrieve the argument object via a singleton i would prefer to not be 
> mandatory to do that.

Agreed as well.

> 
> >Your code, allthough it allows converters to construct actions, lacks some of
> >the flexibilty Swixml allows with the things I mentioned above: you have to know
> >at *compile time* which actions are available at *runtime*.
> >
> I'm not sure to understand, because the action manager is a first 
> iteration, we can imagine to instantiate new action when they are asked 
> by the swingengine, instead of returning the action i had initially put 
> in the hashmap.
> How and what the action converter return depend on what 
> we put in the convert method. The convert method allow to possibly 
> instantiate new action and/or configure them before returning them to 
> the swing engine. The configuration is the thing that i cannot emulate 
> with the actual implementation IMHO.

True, I was refering to your example. Of course you may retrieve every
action you want, whether they are mentioned/available at compile time
or not. I even thought about some kind of indirection through (perhaps)
the localization feature of swixml:
# property file for "simple customers":
some.action.to.do.things = com.example.MySimpleAction

# property file for some "advanced customers":
some.action.to.do.things = com.example.MyAdvancedAction

This way, you can even ask the localizer for the action (which does'nt
need to be a classname)


> 
> > On the other hand,
> >the code does not remove nor limit these flexibilty.
> >
> >  
> >
> It's why i was wondering if it is possible to include it in the source 
> pool so i can work with the regular distribution and not my patched one 
> [especially because this will be distributed as part of one [possibly 
> two] modules of argouml, if the license of swiml doesn't forbid it - 
> AFAIK it doesn't forbid it].
> 
> >Did you consider using initclass along with the singleton for your actions or
> >is this something you are not able to do, because the components you use
> >lack constructors accepting a single Action object or you have other
> >objections?
> >
> >  
> >
> A priori i would like to avoid singletons, my objects lacks of 
> constructors accepting a single action object and i would like to 
> configure the object in my action manager before returning them.
> So if you can address my possible misunderstandings it would be great,
> Best regards,
> Ludo

I agree completly with you. I only wanted to point out existing
possibilities to achieve your goal.

Wolf, any objections about using this code?

Frank


> 
> >Yours,
> >
> >Frank
> >
> >List for Users of Carlsbad Cubes' Technologies and Products <[email protected]> schrieb am 30.10.05 17:50:03:
> >  
> >
> >>Hi all,
> >>
> >>I had done a little change in Parser.applyAttributes(Object, Factory, 
> >>List) and i would like to know if it is safe and if potentially it could 
> >>be included in the source pool eventually.
> >>The purpose is to allow to register Converters for Action and so allow 
> >>us to inject any action which match the value of the action attribute 
> >>from the converter.
> >>For instance i have (but perhaps this is a bad design) a ActionManager 
> >>into which i register actions by name (this is a sort of HashMap) and 
> >>that i use to fetch actions when the parser encounter them.
> >>This allow to not be mandatory to declare the actions as public fields 
> >>in the client object of the SwingEngine.
> >>Attached to this mail are the patch and an example converter. To use it, 
> >>i add the following lines before parsing the xml ui descriptor:
> >>...
> >>                swingEngine = new SwingEngine(this);
> >>                actionManager = new AndroMDAModuleActionManager( this );
> >>                ConverterLibrary.getInstance().register(Action.class,
> >>                        actionManager);
> >>                URL uiDef = ClassLoader.getSystemResource(UI_DESCRIPTOR);
> >>                File f = new File(uiDef.getFile());
> >>                swingEngine.render(f);
> >>...
> >>(i work on a module for argouml which integrate andromda into it - this 
> >>explain the name of the classes)
> >>Thanks for any feedback,
> >>Best regards,
> >>
> >>-- 
> >>Cordialement,
> >>Ludo - http://www.ubik-products.com
> >>---
> >>"L'amour pour principe et l'ordre pour base; le progres pour but" (A.Comte) 
> >>
> >>
> >><hr>
> >>_______________________________________________
> >>Forum mailing list
> >>[email protected]
> >>http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
> >>
> >>    
> >>
> >
> >
> >
> >_______________________________________________
> >Forum mailing list
> >[email protected]
> >http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
> >
> >
> >  
> >
> 
> 
> -- 
> Cordialement,
> Ludo - http://www.ubik-products.com
> ---
> "L'amour pour principe et l'ordre pour base; le progres pour but" (A.Comte) 
> 
> 
> _______________________________________________
> Forum mailing list
> [email protected]
> http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com