VE Code Generation: Who generates global variable declarations? [message #617416] |
Thu, 10 September 2009 14:38 |
Kaspar von Gunten Messages: 21 Registered: July 2009 |
Junior Member |
|
|
Hi all
another question.
We use "Choose Bean" to drop some other visual components of special type
onto a VE visual bean class. In the general case, this generates the
following code:
import x.y.z.SomeSpecialPanel;
...
private SomeSpecialPanel myPanel = null;
...
/**
* This method initializes myPanel
* @return x.y.z.SomeSpecialPanel
*/
private SomeSpecialPanel getMyPanel() {
if (myPanel == null) {
myPanel = new SomeSpecialPanel();
}
return myPanel;
}
What we would like to do, is generate the following code:
import x.y.z.SomeSpecialPanel;
import x.y.z.AbstractPanel
import x.y.z.SpecialAnnotation
...
private @SpecialAnnotation AbstractPanel myPanel = null;
...
/**
* This method initializes myPanel
* @return x.y.z.AbstractPanel
*/
private AbstractPanel getMyPanel() {
if (myPanel == null) {
myPanel = SpecialPanelFactory.create(SomeSpecialPanel.class);
}
return myPanel;
}
Three things should change:
1) Instance variable type (and return type of getter) should be of type
AbstractPanel
2) Instance variable should receive an annotation marking it as special
3) Instead of "new" a factory should be invoked with the panel class
I managed to achieve 3) by installing Decoder and DecoderHelper for
AbstractPanel type (of which special panel is a subtype of) and overriding
the generate/decode methods.
But for 1) and 2) I didn't manage to find a hook. Where I can install my
own Decoder for the instance variable code generation and for the
getter/initialize method, or who is responsible for encoding those
expressions?
Any pointers/hints?
Help would be greatly appreciated,
Kaspar
|
|
|
Powered by
FUDForum. Page generated in 0.02750 seconds