Re: Swingactions
Mauro Talevi <[email protected]> Mon, 30 Jun 2003 09:20:22 +0100
| Newsgroups | gmane.comp.java.spice.devel |
|---|---|
| Message-ID | <[email protected]> |
peter-4lf8KW9E9MLMqX/[email protected] wrote: > Hi, > > I just started to have a look at the swing action framework. > Have you checked it all in or is it not yet finished? If it is not > yet finished maybe we should move it into the sandbox hierarchy > to reflect that. nope - not finished just an initial commit(see comment on jira) but since I'm actively working on it - with a fairly defined designed, I thought it could go in components. I thought sandbox was more for less clearly defined or not actively developed comps. but if we opt to leave comps only for stable and released we can move it to sandbox. > Anyways the way I was originally thinking about doing it is different > from how you have started. I will describe what I was thinking and > see what you think. I was thinking that the design of the package > would essentially have 4 parts > this design not very different with what done so far - in general I tend not to create a separate package until I see real need for it (in particular I tend not to have one class packages) > * metadata: the metadata that represents each action we could separate the action metadata in an ActionMetaData class, but AbstractAction and ActionAdapter do much of that. > * reader: the package that reads from XML file and builds metadata I had planned to call it xml and have different packages for different readers but having a reader package would also work. > * runtime: the package that creates and manages the action instances the managing is done by the ActionManager itself and creation by the configuration. > * ui: the package that creates the UI elements for actions Here I was thinking of single class UIFactory or better yet JFactory of some action-related JComponents. You'd pass in the ActionManager and get back the JComponent with the appropriate actions. > If you want to have a look at what I meant you can probably look in > the spice-xmlpolicy and spice-classman components which follow a > similar pattern. They different slightly in naming of packages and also > because they have a "verifier" package that is probably not necessary > for swingactions. > > The advantags of this design is that it is very easy to replace each of the > different stages except metadata with a different implementation. ie I could > have a reader that generated metadata from properties files or from a > database. I could also replace the runtime or UI to be web-based or use > AWT or SWT without too much hassle. It is also MUCH easier to unit test. > I agree on the need of extensibility - hence the design to support different type of file configurations or no configuration at all (user subclasses AbstractActionManager). But what I would resist is the temptation to make it too generic 'cause it would evolve into a real framework and not a component to manage swing actions. In particular I would stick with swing actions (Action is in javax.swing package) and with swing components. If we see the use case for something more generic we should refactor later. in particular I'm not sure this should become a web-based on SWT action toolkit. There already are some out there of that sort and should we decide to, we'd have to change name too ;-) Do you find so much easier to unit test code only because split in different packages. As someone who used to always create new packages I've somewhat gone back and slightly curbed my attitude and create them on demand. > The disadvantage is the slight increase in complexity when setting up the > system > but to avoid that we could easily add in a Configurator like utility class. > yep - see comment on jira again. > Anyways - what do you think ? need to think more about it - but I'm not sure the added complexity necessarily adds to the benefits. apart from having different implementations of the configuration (which is already cared for) can you provide an example of how the new package layout would be beneficial? Cheers ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01