Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » String values in the property sheet
String values in the property sheet [message #91399] Tue, 17 May 2005 15:08 Go to next message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello,



In the property sheet of the VE it is possible to set properties by
selecting a variable from a combo box. This is not possible if the value
is a string. Here is an example:




Public class MyButton extends JButton {


…


Public void setRessource(String s) { …}


}


In this case there is a line "ressource" in the property sheet and I can
type a string e.g myRessource. The VE inserts a line
myButton.setRessource("myRessource").



I would like to have a possibility to select a variable of String type.


Could you give me a hint how I can find out what String variables exist in
the code in order to give the user a possibility to select one variable
from a combo box. Can a customizer be helpful?


I would like that VE inserts a variable name. Here is an example:

String mRes = "ABC";
myButton.setRessource(mRes);



Thanks in advance
Elena
Re: String values in the property sheet [message #91449 is a reply to message #91399] Tue, 17 May 2005 20:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: no.ddress.here

In article <35b4a192cf60b225714a1cf04271042d$1@www.eclipse.org>,
demeter.elena@freenet.de says...
> Hello,
>
>
>
> In the property sheet of the VE it is possible to set properties by
> selecting a variable from a combo box. This is not possible if the value
> is a string. Here is an example:
>

Example: ComboStringEditor.java from jakarta-jmeter

http://koders.com/java/fid782478001D74264F9D098FE9F0B7A1BC8F 6E0089.aspx?
s=propertyeditor+jcombobox
Re: String values in the property sheet [message #91601 is a reply to message #91449] Wed, 18 May 2005 08:17 Go to previous messageGo to next message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello,


thank you for an answer!

I had a look at your example and I searched for a method that determines
String variables from the code but I did not find it.


Could you give me a hint :-)


Thanks
Elena
Re: String values in the property sheet [message #91630 is a reply to message #91399] Wed, 18 May 2005 09:55 Go to previous messageGo to next message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi Elena,

> Could you give me a hint how I can find out what String variables exist
> in the code in order to give the user a possibility to select one
> variable from a combo box. Can a customizer be helpful?

A customizer won't help here and nor will a java.beans.PropertyEditor
unfortunately. What you want to do is have access to the shape of the
..java file being edited so you can provide a list of its known
variables. Even if you could get a handle to the .class file (which you
can actually by having a constructor on your
java.beans.PropertyEditor(Object) that takes an object argument that
will be the parent the property will be set on, this will be the last
compiled file so its getFields() will be stale. You want a working copy
of the .java file.

What will work is the technique used by the VE for property editor that
appears against the property "fieldName". There is no getter and setter
for this and it's something that we fluff up to represent the field name
. The property descriptor is NameInMemberPropertyDescriptor and if
you debug this you will see how it validates the fieldName as being
unique (i.e. not already used in the file). If you look at the VE
tutotorial on the custom widget you should be able to see how to have
your own ICellEditor against your custom property.

Let me know if this makes any sense.

> I would like that VE inserts a variable name. Here is an example:
>
> String mRes = "ABC";
> myButton.setRessource(mRes);

The VE will do this automatically for you if there are properties on
mRes. To see this just set something to have a property value and press
the + on the property sheet and set a property of the property value.
The VE realizes this and creates the field for you.

Given that the VE already does this automagically on an as-required
basis, what is the actual scenario that means you want to have the field
declared for you ? The way that the property value gets scoped into the
file is actually controlled by a property of the EMF relationship, so
you could do what you want by overriding the relationship and
specificying something like "LOCAL_LOCAL" I think. I'd have to think
about this more and probably run it past Rich and Gili to see what they
think, but before doing that can you sort of back up a bit and describe
the scenario that actually makes you want to have the property value
declared in a separate field ?

Best regards,

Joe Winchester
Re: String values in the property sheet [message #91645 is a reply to message #91630] Wed, 18 May 2005 10:56 Go to previous messageGo to next message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello Joe,


here is the scenario:


1. There is button component "MyButton" that extends JButton


2. The code of button has a method "setRessource(String s){}"


3. I create a visual class "MyFrame" that is derived from JFrame


4. Then I create a String variable "String mRes = "ABC";" in the class
"MyFrame"


5. I drop a button of class "MyButton" on the frame "MyFrame"


6. Then I click on the property "ressource" and see the variable name
"mRes" in the list


7. I select the variable "mRes": the VE inserts a line
"myButton.setRessource(mRes)"





Thanks in advance
Elena
Re: String values in the property sheet [message #91977 is a reply to message #91645] Mon, 23 May 2005 15:09 Go to previous messageGo to next message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello,

was my scenario not detailed enough? Shall I describe it more
understandable ?
Or is there another reason why you did not answer ?


:-)

Elena
Re: String values in the property sheet [message #92051 is a reply to message #91977] Tue, 24 May 2005 18:36 Go to previous message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi Elena,

> was my scenario not detailed enough? Shall I describe it more
> understandable ?

Nope - it all looks OK. Did you get more with looking at the
"fieldName" property. This is fluffed up onto the property sheet and
lets a user specify the Java field name of a bean and it validates
whether this is already used or not. Your property editor should be
just a variant of this, except that you don't want the entry to be
unique and not an existing one, you want it to be an actual existing one
so you could stuff your combo with the available field names.

One problem you might run into is that the VE generally likes things
that point to other things to be part of its model. You want to
generate the method
bean.setResource(mRes);
where mRes is an actual field. For this to work you will need to create
an JavaObjectInsteance that represents the mRes argument and this will
need an allocation. I think if you use a PTName you can just slam the
field name into it.

Let me know how you get on looking at the "fieldName" property and how
it does its cell editing. You will need a .override that associates
your new funky cell editor with the property and once that is in place
you should be OK

Or is there another reason why you did not answer ?

Nope, although we are heads down on M1.2 right now and trying to get the
queue cleared and also the new Star Wars movie just came out.

Best regards,

Joe Winchester
Re: String values in the property sheet [message #607787 is a reply to message #91399] Tue, 17 May 2005 20:42 Go to previous message
Gerald Rosenberg is currently offline Gerald RosenbergFriend
Messages: 106
Registered: July 2009
Senior Member
In article <35b4a192cf60b225714a1cf04271042d$1@www.eclipse.org>,
demeter.elena@freenet.de says...
> Hello,
>
>
>
> In the property sheet of the VE it is possible to set properties by
> selecting a variable from a combo box. This is not possible if the value
> is a string. Here is an example:
>

Example: ComboStringEditor.java from jakarta-jmeter

http://koders.com/java/fid782478001D74264F9D098FE9F0B7A1BC8F 6E0089.aspx?
s=propertyeditor+jcombobox
Re: String values in the property sheet [message #607798 is a reply to message #91449] Wed, 18 May 2005 08:17 Go to previous message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello,


thank you for an answer!

I had a look at your example and I searched for a method that determines
String variables from the code but I did not find it.


Could you give me a hint :-)


Thanks
Elena
Re: String values in the property sheet [message #607800 is a reply to message #91399] Wed, 18 May 2005 09:55 Go to previous message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi Elena,

> Could you give me a hint how I can find out what String variables exist
> in the code in order to give the user a possibility to select one
> variable from a combo box. Can a customizer be helpful?

A customizer won't help here and nor will a java.beans.PropertyEditor
unfortunately. What you want to do is have access to the shape of the
..java file being edited so you can provide a list of its known
variables. Even if you could get a handle to the .class file (which you
can actually by having a constructor on your
java.beans.PropertyEditor(Object) that takes an object argument that
will be the parent the property will be set on, this will be the last
compiled file so its getFields() will be stale. You want a working copy
of the .java file.

What will work is the technique used by the VE for property editor that
appears against the property "fieldName". There is no getter and setter
for this and it's something that we fluff up to represent the field name
. The property descriptor is NameInMemberPropertyDescriptor and if
you debug this you will see how it validates the fieldName as being
unique (i.e. not already used in the file). If you look at the VE
tutotorial on the custom widget you should be able to see how to have
your own ICellEditor against your custom property.

Let me know if this makes any sense.

> I would like that VE inserts a variable name. Here is an example:
>
> String mRes = "ABC";
> myButton.setRessource(mRes);

The VE will do this automatically for you if there are properties on
mRes. To see this just set something to have a property value and press
the + on the property sheet and set a property of the property value.
The VE realizes this and creates the field for you.

Given that the VE already does this automagically on an as-required
basis, what is the actual scenario that means you want to have the field
declared for you ? The way that the property value gets scoped into the
file is actually controlled by a property of the EMF relationship, so
you could do what you want by overriding the relationship and
specificying something like "LOCAL_LOCAL" I think. I'd have to think
about this more and probably run it past Rich and Gili to see what they
think, but before doing that can you sort of back up a bit and describe
the scenario that actually makes you want to have the property value
declared in a separate field ?

Best regards,

Joe Winchester
Re: String values in the property sheet [message #607801 is a reply to message #91630] Wed, 18 May 2005 10:56 Go to previous message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello Joe,


here is the scenario:


1. There is button component "MyButton" that extends JButton


2. The code of button has a method "setRessource(String s){}"


3. I create a visual class "MyFrame" that is derived from JFrame


4. Then I create a String variable "String mRes = "ABC";" in the class
"MyFrame"


5. I drop a button of class "MyButton" on the frame "MyFrame"


6. Then I click on the property "ressource" and see the variable name
"mRes" in the list


7. I select the variable "mRes": the VE inserts a line
"myButton.setRessource(mRes)"





Thanks in advance
Elena
Re: String values in the property sheet [message #607821 is a reply to message #91645] Mon, 23 May 2005 15:09 Go to previous message
Elena Demeter is currently offline Elena DemeterFriend
Messages: 152
Registered: July 2009
Senior Member
Hello,

was my scenario not detailed enough? Shall I describe it more
understandable ?
Or is there another reason why you did not answer ?


:-)

Elena
Re: String values in the property sheet [message #607826 is a reply to message #91977] Tue, 24 May 2005 18:36 Go to previous message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi Elena,

> was my scenario not detailed enough? Shall I describe it more
> understandable ?

Nope - it all looks OK. Did you get more with looking at the
"fieldName" property. This is fluffed up onto the property sheet and
lets a user specify the Java field name of a bean and it validates
whether this is already used or not. Your property editor should be
just a variant of this, except that you don't want the entry to be
unique and not an existing one, you want it to be an actual existing one
so you could stuff your combo with the available field names.

One problem you might run into is that the VE generally likes things
that point to other things to be part of its model. You want to
generate the method
bean.setResource(mRes);
where mRes is an actual field. For this to work you will need to create
an JavaObjectInsteance that represents the mRes argument and this will
need an allocation. I think if you use a PTName you can just slam the
field name into it.

Let me know how you get on looking at the "fieldName" property and how
it does its cell editing. You will need a .override that associates
your new funky cell editor with the property and once that is in place
you should be OK

Or is there another reason why you did not answer ?

Nope, although we are heads down on M1.2 right now and trying to get the
queue cleared and also the new Star Wars movie just came out.

Best regards,

Joe Winchester
Previous Topic:No Visual Class option
Next Topic:Wizard-like Custom Editor
Goto Forum:
  


Current Time: Fri Apr 26 08:51:39 GMT 2024

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

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

Back to the top