Thanks for response!
So, as I se the main issue is with
"this".
To avoid usage of "this" I could use
slightly
different pattern instead of
ivjActSend.setOwner(this);
I could call something like:
addAction(ivjActSend)
The method
addAction will be implemented in the MyPanel class
extendig JPanel
which I'll use instead of JPanel. The
addAction will
call setOwner(this) inside. The
mechanism is very similar
to adding comonents to a container. The difference
is that
in this case the ActSend is not derived from
java.awt.Component class.
So in this case it is required that VE must
generate
private sample.vep.SendAction
getIvjActSend() {
if (ivjActSend == null) { ivjActSend = new
sample.vep.SendAction(); addAction(ivjActSend);
// this code must be inserted automatically
//for all classes
derived from MyGenericAction after I put action to Panel
ivjActSend.setEnabled(true); ivjActSend.setName("Hello"); } return ivjActSend; }
Is it possible to use such approach?
Please, help me also with instructions describing
the places I need to make
changes implement the described
functionality.
Maxim
----- Original Message -----
Sent: Tuesday, July 06, 2004 5:09
PM
Subject: Re: [ve-dev] How to extend VE in
the following situation:
There are a few options to do this
with VE.
The main inhibition in
your example is the "this" part. VE can not instantiate the "this"
part, as it is the class that you are working on. The target VM works
with (saved) compiled files. If you
will use a "this" in the constructor or setting, VE will give you "too
complicated to evaluate".
... so
you have two options. Let me start with a high level description for
now, and we can dive into detail as we go along:
1. ivjActSend = new
sample.vep.SendAction(this); // The "this" must be in the
constructor for all
//classes derived from
MyGenericAction after I put action to Panel
The constructor statement is typically generated by a
method template. You can use the VE override files to specify a
different method generation template that will use the proper constructor
for the sample.vep.SendAction class
hierarchy. ... but you will also have to change the BeanProxyAdapter
classes so that on the target VM a new sample.vep.SendAction(this) will be invoked as new sample.vep.SendAction(); null
constructor. This
will enable the target VM to instantiate the SendAction bean, and still
generate the proper run time code (WYSIWYG issues here)
2. ivjActSend = new sample.vep.SendAction();
ivjActSend.setOwner(this); // this code must be inserted
automatically
//for all classes derived from MyGenericAction after I put
action to Panel
You can
extend VE to generate the setOwner setting as you drop the component ....
but as noted above if you use a "this" for the setting, VE will generate an
error.
Rather than this, VE can work with static element
within your "this" class; if this is an option for you can avoid the "this"
problems.
------------ Dr. Gili Mendel IBM Software
Development RTP Raleigh, NC (919)543 6408, tie: 441
6408
"Max"
<max@xxxxxxxx> Sent
by: ve-dev-admin@xxxxxxxxxxx
07/05/2004 09:40 AM
|
To
| <ve-dev@xxxxxxxxxxx>
|
cc
|
|
Subject
| Re: [ve-dev] How to
extend VE in the following situation: |
|
Dear VE developers, I've asked the question (see below) two times and
unfortunately have no any response.
Probably this is not the right place for asking such questions?
Please, give me any feedback. Where I should ask
such questions? Or give any information
source I could figure out answer from. Sorry, if this is not the right place for such questions.
Thanks,
Maxim
----- Original Message ----- From: Max To:
ve-dev@xxxxxxxxxxx Sent: Friday, July 02, 2004 5:31 PM Subject: [ve-dev] How to extend VE in the following
situation:
Hi, I'd like to
change/extend VE to generate a slightly different code in getter method
for a particular class. (SWING based)
1.
In my application I have class: class
MyGenericAction extends javax.swing.AbstractAction { public void setOwner(Jpanel
owner) {
....
} } And I have
different particular implementations of MyGenericAction e.g: class SendAction extends MyGenericAction { }
2. I create JPanel in VE and put my
SendAction into the panel and set properties Enabled and Name. VE generates the following code:
private sample.vep.SendAction
getIvjActSend() {
if (ivjActSend == null) { ivjActSend = new
sample.vep.SendAction(); ivjActSend.setEnabled(true);
ivjActSend.setName("Hello"); }
return ivjActSend; } 3. The issue is that I know
that any MyGenericAction instance always requires also Owner property to be specified and the user can forget to specify
it explicitly. So I need to override code
generation for all classes extending MyGenericAction in the following way: 1st option
private sample.vep.SendAction
getIvjActSend() {
if (ivjActSend == null) { ivjActSend = new
sample.vep.SendAction(this); // The "this" must be in the
constructor for all
//classes derived from
MyGenericAction after I put action to Panel
ivjActSend.setEnabled(true); ivjActSend.setName("Hello");
} return ivjActSend; } 2nd option
private sample.vep.SendAction
getIvjActSend() {
if (ivjActSend == null) { ivjActSend = new
sample.vep.SendAction(); ivjActSend.setOwner(this); // this
code must be inserted automatically
//for all classes derived
from MyGenericAction after I put action to Panel
ivjActSend.setEnabled(true); ivjActSend.setName("Hello");
} return ivjActSend; }
Questions Could you please
provide some recommendations for implementig such or similar
functionality? Which extension points I
need to implement to add the functionality? Thanks in advance,
Maxim
|