Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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

Back to the top