Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Query regarding the Box interface in the net.refractions.udig.printing.model project

Hi Jody

On 2 April 2010 05:07, Jody Garnett <jody.garnett@xxxxxxxxx> wrote:
On 01/04/2010, at 10:24 PM, Stephen wrote:

> Hi List,
> This is Stephen here and have been studying the printing plug-in source for sometime.

Any suggestions you have are welcome; thanks for starting discussion on the email list.

> While going through the source code of Box and BoxImpl in the 'net.refractions.udig.printing.model' project, I noticed that the BoxImpl class provides an implementation for the 'getAdapter()' method, even though the IAdaptable interface is  nowhere present in its nor in the heirarchy of the Box interface.

I suspect the developer started implementing IAdaptable and did not finish; you can throw a patch our way if you like.
 Well Jody, from what I can gather it seems the main intention in the getAdapter() implementation of BoxImpl class is to just forward the call to the getAdapter() method of the BoxPrinter object so that when we implement our own custom components using the boxPrinter extension point, any call on getAdapter() on the Box object or BoxPart object would be directly transferred to our custom BoxPrinter extension which we have implemented.
That is:-
BoxPart.getAdapter() -> Box.getAdapter() -> CustomBoxPrinter.getAdapter()

So that the implementer of the extension can decide to what object his UI container BoxPart can adapt to, by just specifying that behaviour in the getAdapter() of the BoxPrinter object.
Now if thats what the developers had intended, then just adding 'IAdaptable' to the list of interfaces extended by 'Box' (as you mentioned below) should be the only fix that is needed

> Also the BoxPart (package: net.refractions.udig.printing.ui.internal.editor.parts) class in its implementation of getAdapter() checks if the Box object it references is an instance of type 'IAdaptable', (before it forwards the request to getAdapter() of the Box object) but as this interface does not exist in the type hierarchy of the Box interface and the BoxImpl class, the check is always going to fail, so the request is never forwarded to the 'BoxPrinter' object as it seems to be the intent.

Gak that sounds confusing.
Ha Ha ..  have a knack of doing that ... a lot :D.
>
> So what I would like to know is, if I want the getAdapter() request to be forwarded from the BoxElement to my Custom BoxPrinter objects, what exactly should I do, add IAdaptable to type heirarchy of Box or directly to BoxImpl or just remove the 'instanceof' IAdaptable check in the getAdapter() method of BoxPart  ???

Let us think.... I would prefer  to add IAdaptable to the Box hierarchy that seems the most consistent.
Yep perfectly agree on that point as the BoxPrinter interface also extends IAdaptable so the above also makes a lot of sense too.

Jody


_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Thanks for looking into it :).

Regards
Stephen D'Souza


Back to the top