[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.ve] VE Code Generation: Who generates global variable declarations?

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