Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » VE: More about 'get methods' when I select a variable for a property.
VE: More about 'get methods' when I select a variable for a property. [message #17801] Wed, 04 February 2004 10:55 Go to next message
David is currently offline DavidFriend
Messages: 34
Registered: July 2009
Member
Hi again!

After modify the .override files (see another threads in this newsgroup) I
did that a property shows variables names in the property sheet.
For example. If I've a JavaBean with a property that receives a JButton
object, when I click this property in the preoperties sheet, it shows all
the variables that I've declared as JButton.

But... VE don't generate my code correctly. All my JavaBeans are
instantiated in a init() method, instead 'get methods' that VE uses when
creates new code.
The problem (that I comment in other thread but that I rewrite now to be
more clean in a new thread) is:

* As class variable I declare a JButon

JButton myJButton = null;

* In the init method I initialize the JButton.

myJButton = new JButton();

* Then, I drag my JavaBean (that implemets get/set methods with a JButton
object as parameter and named, for example, javabean) and when I select
this property it shows 'myJButton').

* Then, VE writes code similar to:
javabean.setJButton(myJButton());

instead of:

javabean.setJButton(myJButton);

It writes a name of a method that doesn't exists.

Joe Winchester (thanks for you) comments me some about this problem and
the form that VE generates the code with get methods but I'm experimenting
and
I found a case that use variables names:

If I create a JPanel and set the layout to CardLayout, VE writes:

jPanel.setLayout(new java.awt.CardLayout());

but, if I change the property 'horizontal grap' of the layout to 1, VE
writes now:

java.awt.CardLayout layCardLayout2 = new java.awt.CardLayout();
layCardLayout2.setHgap(1);
jPanel.setLayout(layCardLayout2);

It's use a variable name instead create a 'get method' that initializes
the layout and set his 'hgap property' to 1 and then uses this method as
parameter of setLayout method.

How I do this with my setJButton property?
If VE can do this with setLayout property it must do this whith anyone
property.

Many thanks.
Re: VE: More about 'get methods' when I select a variable for a property. [message #17807 is a reply to message #17801] Wed, 04 February 2004 15:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mendelgili.netscape.net

David Díaz wrote:
> Hi again!
>
> After modify the .override files (see another threads in this newsgroup) I
> did that a property shows variables names in the property sheet.
> For example. If I've a JavaBean with a property that receives a JButton
> object, when I click this property in the preoperties sheet, it shows all
> the variables that I've declared as JButton.
>
> But... VE don't generate my code correctly. All my JavaBeans are
> instantiated in a init() method, instead 'get methods' that VE uses when
> creates new code.
> The problem (that I comment in other thread but that I rewrite now to be
> more clean in a new thread) is:
>
> * As class variable I declare a JButon
>
> JButton myJButton = null;
>
> * In the init method I initialize the JButton.
>
> myJButton = new JButton();
>
> * Then, I drag my JavaBean (that implemets get/set methods with a JButton
> object as parameter and named, for example, javabean) and when I select
> this property it shows 'myJButton').
>
> * Then, VE writes code similar to:
> javabean.setJButton(myJButton());
>
> instead of:
>
> javabean.setJButton(myJButton);
>
> It writes a name of a method that doesn't exists.
>
> Joe Winchester (thanks for you) comments me some about this problem and
> the form that VE generates the code with get methods but I'm experimenting
> and
> I found a case that use variables names:
>
> If I create a JPanel and set the layout to CardLayout, VE writes:
>
> jPanel.setLayout(new java.awt.CardLayout());
>
> but, if I change the property 'horizontal grap' of the layout to 1, VE
> writes now:
>
> java.awt.CardLayout layCardLayout2 = new java.awt.CardLayout();
> layCardLayout2.setHgap(1);
> jPanel.setLayout(layCardLayout2);
>
> It's use a variable name instead create a 'get method' that initializes
> the layout and set his 'hgap property' to 1 and then uses this method as
> parameter of setLayout method.
>
> How I do this with my setJButton property?
> If VE can do this with setLayout property it must do this whith anyone
> property.
>
> Many thanks.
>

This is a bug.

The code you are trying to generate uses the
ChildRelationshipDecoderHelper helper. This particular helper (with our
current pattenrs) would never generate a reference to an instance field
though it should be able to handle it.

See ChildRelationshipDecoderHelper.getSourceCodeArg():
It will try to get the arguments for the method invocation.

It did figure out that there is no return method, and hence uses the
bean's name. Unfortunately it will add the "()" no matter what at the
end of that argument:
if (fAddedPart.isInstanceVar())
st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);

It should have been
if (fAddedPart.getReturnedMethod() != null)
st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);


.... added this support in the v1.0.0 stream

You can create your own decoder that uses your (fixed) helper and
override the decoders that are used in the override files - but as Joe
(I beleive) mentioned before ... you are threading where only angels can ;-)

In any case, I must admit that you have managed to dive deep into the VE
plumbing land and push the envelope significantly. Many kudos to you
and thanks.

Gili
Re: VE: More about 'get methods' when I select a variable for a property. [message #18165 is a reply to message #17807] Fri, 06 February 2004 08:39 Go to previous message
David is currently offline DavidFriend
Messages: 34
Registered: July 2009
Member
Many Thanks.
I made this changes and now everything works OK.










Gili Mendel wrote:

> David Díaz wrote:
> > Hi again!
> >
> > After modify the .override files (see another threads in this newsgroup) I
> > did that a property shows variables names in the property sheet.
> > For example. If I've a JavaBean with a property that receives a JButton
> > object, when I click this property in the preoperties sheet, it shows all
> > the variables that I've declared as JButton.
> >
> > But... VE don't generate my code correctly. All my JavaBeans are
> > instantiated in a init() method, instead 'get methods' that VE uses when
> > creates new code.
> > The problem (that I comment in other thread but that I rewrite now to be
> > more clean in a new thread) is:
> >
> > * As class variable I declare a JButon
> >
> > JButton myJButton = null;
> >
> > * In the init method I initialize the JButton.
> >
> > myJButton = new JButton();
> >
> > * Then, I drag my JavaBean (that implemets get/set methods with a JButton
> > object as parameter and named, for example, javabean) and when I select
> > this property it shows 'myJButton').
> >
> > * Then, VE writes code similar to:
> > javabean.setJButton(myJButton());
> >
> > instead of:
> >
> > javabean.setJButton(myJButton);
> >
> > It writes a name of a method that doesn't exists.
> >
> > Joe Winchester (thanks for you) comments me some about this problem and
> > the form that VE generates the code with get methods but I'm experimenting
> > and
> > I found a case that use variables names:
> >
> > If I create a JPanel and set the layout to CardLayout, VE writes:
> >
> > jPanel.setLayout(new java.awt.CardLayout());
> >
> > but, if I change the property 'horizontal grap' of the layout to 1, VE
> > writes now:
> >
> > java.awt.CardLayout layCardLayout2 = new java.awt.CardLayout();
> > layCardLayout2.setHgap(1);
> > jPanel.setLayout(layCardLayout2);
> >
> > It's use a variable name instead create a 'get method' that initializes
> > the layout and set his 'hgap property' to 1 and then uses this method as
> > parameter of setLayout method.
> >
> > How I do this with my setJButton property?
> > If VE can do this with setLayout property it must do this whith anyone
> > property.
> >
> > Many thanks.
> >

> This is a bug.

> The code you are trying to generate uses the
> ChildRelationshipDecoderHelper helper. This particular helper (with our
> current pattenrs) would never generate a reference to an instance field
> though it should be able to handle it.

> See ChildRelationshipDecoderHelper.getSourceCodeArg():
> It will try to get the arguments for the method invocation.

> It did figure out that there is no return method, and hence uses the
> bean's name. Unfortunately it will add the "()" no matter what at the
> end of that argument:
> if (fAddedPart.isInstanceVar())
> st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);

> It should have been
> if (fAddedPart.getReturnedMethod() != null)
> st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);


> .... added this support in the v1.0.0 stream

> You can create your own decoder that uses your (fixed) helper and
> override the decoders that are used in the override files - but as Joe
> (I beleive) mentioned before ... you are threading where only angels can ;-)

> In any case, I must admit that you have managed to dive deep into the VE
> plumbing land and push the envelope significantly. Many kudos to you
> and thanks.

> Gili
Re: VE: More about 'get methods' when I select a variable for a property. [message #580181 is a reply to message #17801] Wed, 04 February 2004 15:00 Go to previous message
Gili Mendel is currently offline Gili MendelFriend
Messages: 338
Registered: July 2009
Senior Member
David Díaz wrote:
> Hi again!
>
> After modify the .override files (see another threads in this newsgroup) I
> did that a property shows variables names in the property sheet.
> For example. If I've a JavaBean with a property that receives a JButton
> object, when I click this property in the preoperties sheet, it shows all
> the variables that I've declared as JButton.
>
> But... VE don't generate my code correctly. All my JavaBeans are
> instantiated in a init() method, instead 'get methods' that VE uses when
> creates new code.
> The problem (that I comment in other thread but that I rewrite now to be
> more clean in a new thread) is:
>
> * As class variable I declare a JButon
>
> JButton myJButton = null;
>
> * In the init method I initialize the JButton.
>
> myJButton = new JButton();
>
> * Then, I drag my JavaBean (that implemets get/set methods with a JButton
> object as parameter and named, for example, javabean) and when I select
> this property it shows 'myJButton').
>
> * Then, VE writes code similar to:
> javabean.setJButton(myJButton());
>
> instead of:
>
> javabean.setJButton(myJButton);
>
> It writes a name of a method that doesn't exists.
>
> Joe Winchester (thanks for you) comments me some about this problem and
> the form that VE generates the code with get methods but I'm experimenting
> and
> I found a case that use variables names:
>
> If I create a JPanel and set the layout to CardLayout, VE writes:
>
> jPanel.setLayout(new java.awt.CardLayout());
>
> but, if I change the property 'horizontal grap' of the layout to 1, VE
> writes now:
>
> java.awt.CardLayout layCardLayout2 = new java.awt.CardLayout();
> layCardLayout2.setHgap(1);
> jPanel.setLayout(layCardLayout2);
>
> It's use a variable name instead create a 'get method' that initializes
> the layout and set his 'hgap property' to 1 and then uses this method as
> parameter of setLayout method.
>
> How I do this with my setJButton property?
> If VE can do this with setLayout property it must do this whith anyone
> property.
>
> Many thanks.
>

This is a bug.

The code you are trying to generate uses the
ChildRelationshipDecoderHelper helper. This particular helper (with our
current pattenrs) would never generate a reference to an instance field
though it should be able to handle it.

See ChildRelationshipDecoderHelper.getSourceCodeArg():
It will try to get the arguments for the method invocation.

It did figure out that there is no return method, and hence uses the
bean's name. Unfortunately it will add the "()" no matter what at the
end of that argument:
if (fAddedPart.isInstanceVar())
st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);

It should have been
if (fAddedPart.getReturnedMethod() != null)
st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);


.... added this support in the v1.0.0 stream

You can create your own decoder that uses your (fixed) helper and
override the decoders that are used in the override files - but as Joe
(I beleive) mentioned before ... you are threading where only angels can ;-)

In any case, I must admit that you have managed to dive deep into the VE
plumbing land and push the envelope significantly. Many kudos to you
and thanks.

Gili
Re: VE: More about 'get methods' when I select a variable for a property. [message #580354 is a reply to message #17807] Fri, 06 February 2004 08:39 Go to previous message
David is currently offline DavidFriend
Messages: 34
Registered: July 2009
Member
Many Thanks.
I made this changes and now everything works OK.










Gili Mendel wrote:

> David Díaz wrote:
> > Hi again!
> >
> > After modify the .override files (see another threads in this newsgroup) I
> > did that a property shows variables names in the property sheet.
> > For example. If I've a JavaBean with a property that receives a JButton
> > object, when I click this property in the preoperties sheet, it shows all
> > the variables that I've declared as JButton.
> >
> > But... VE don't generate my code correctly. All my JavaBeans are
> > instantiated in a init() method, instead 'get methods' that VE uses when
> > creates new code.
> > The problem (that I comment in other thread but that I rewrite now to be
> > more clean in a new thread) is:
> >
> > * As class variable I declare a JButon
> >
> > JButton myJButton = null;
> >
> > * In the init method I initialize the JButton.
> >
> > myJButton = new JButton();
> >
> > * Then, I drag my JavaBean (that implemets get/set methods with a JButton
> > object as parameter and named, for example, javabean) and when I select
> > this property it shows 'myJButton').
> >
> > * Then, VE writes code similar to:
> > javabean.setJButton(myJButton());
> >
> > instead of:
> >
> > javabean.setJButton(myJButton);
> >
> > It writes a name of a method that doesn't exists.
> >
> > Joe Winchester (thanks for you) comments me some about this problem and
> > the form that VE generates the code with get methods but I'm experimenting
> > and
> > I found a case that use variables names:
> >
> > If I create a JPanel and set the layout to CardLayout, VE writes:
> >
> > jPanel.setLayout(new java.awt.CardLayout());
> >
> > but, if I change the property 'horizontal grap' of the layout to 1, VE
> > writes now:
> >
> > java.awt.CardLayout layCardLayout2 = new java.awt.CardLayout();
> > layCardLayout2.setHgap(1);
> > jPanel.setLayout(layCardLayout2);
> >
> > It's use a variable name instead create a 'get method' that initializes
> > the layout and set his 'hgap property' to 1 and then uses this method as
> > parameter of setLayout method.
> >
> > How I do this with my setJButton property?
> > If VE can do this with setLayout property it must do this whith anyone
> > property.
> >
> > Many thanks.
> >

> This is a bug.

> The code you are trying to generate uses the
> ChildRelationshipDecoderHelper helper. This particular helper (with our
> current pattenrs) would never generate a reference to an instance field
> though it should be able to handle it.

> See ChildRelationshipDecoderHelper.getSourceCodeArg():
> It will try to get the arguments for the method invocation.

> It did figure out that there is no return method, and hence uses the
> bean's name. Unfortunately it will add the "()" no matter what at the
> end of that argument:
> if (fAddedPart.isInstanceVar())
> st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);

> It should have been
> if (fAddedPart.getReturnedMethod() != null)
> st.append (ExpressionTemplate.LPAREN+ExpressionTemplate.RPAREN);


> .... added this support in the v1.0.0 stream

> You can create your own decoder that uses your (fixed) helper and
> override the decoders that are used in the override files - but as Joe
> (I beleive) mentioned before ... you are threading where only angels can ;-)

> In any case, I must admit that you have managed to dive deep into the VE
> plumbing land and push the envelope significantly. Many kudos to you
> and thanks.

> Gili
Previous Topic:Eclipse C# IDE (does it exist?)
Next Topic:1.0.0 Stream
Goto Forum:
  


Current Time: Sat Oct 19 17:47:36 GMT 2024

Powered by FUDForum. Page generated in 0.03780 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top