Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] separator

Hi Rich,


>>> Janak >>

2. import stmt for an inner class:

For ULCToolBar life is bit easy in ULC. I can continue to us
ULCToolBar.add(ULCComponent)  method (instead of the convenience method
addSeparator()) because ULCToolBar$ULCSeparator descends from ULCComponent.
But there is one problem.

The separator for ULCToolBar is an inner public class of ULCToolBar nameley
ULCToolBar$ULCSeparator. The codegen generates an import statement:

   import com.ulcjava.base.application.ULCToolBar.ULCSeparator;

>>>>>>

>>> RLK >>>>
    This is a valid import statement. By doing this we can use just
ULCSeparator by itself in the code. If we did just the toolbar then we would
have to use ULCToolBar.ULCSeparator in the code. Now the only error that I
think you could get would be an ambiguous reference if you had two
ULCSeparator classes, one an inner class and the other not an inner class.
Is that is what is happening here? We don't handle ambiguous references.

>>>> RLK >>>


YWe have two ULCSeparator classes: one inner (inside ULCToolBar) and
independent standalone class (used by ULCMenu).

When I put ULCToolBar$ULCSeparator on the canvas:

The BeanFactory.generateInit() method generates:

   import com.ulcjava.base.application.ULCToolBar.ULCSeparator;

    and the instance and getter method:

    private ULCToolBar.ULCSeparator toolBarSep = null;

    ULCToolBar.ULCSeparator getToolBarSep() {

		toolBarSep = new ULCToolBar.ULCSeparator();
    }

And this gives compilation error because it cannot resolve ULCToolBar.

Now I wanted to generate an import statement for ULCToolBar.

For this I defined a decoder in ULCToolBar$ULCSeparator.override.

The decoder extends ObjectDecoder.

It uses a DecoderHelper that extends ConstructorDecoderHelper.

I override the generate() method and in that add the import stmt for
ULCToolBar to the ReqImports of the ExprRef.

But this has no effect on the finally generated code. The import list is the
same as was created by BeanFactory.generateInit().

In fact, this generate() method does not really affect the codegen at all,
the code looks the same as was generated by BeanFactory.generateInit().

What am I doing wrong?

Thanks and regards,

Janak





Back to the top