Strings in PropertyEditorSupport [message #144341] |
Wed, 02 April 2008 16:07 |
Eclipse User |
|
|
|
Originally posted by: eli_lato.hotmail.com
I have a simple String property named x.
I call xPropertyDescriptor.setPropertyEditorClass(XEditor.class);
XEditor is:
public class XEditor extends PropertyEditorSupport {
private static final String[] CHOICES = {"a", "b", "c"};
public String[] getTags() {
return CHOICES;
}
public String getJavaInitializationString() {
return (String)getValue();
}
}
The combo opens fine. But when I choose a,
VE generates
o.setX(a);
instead of
o.setX("a");
This doesn't compile particularly well.
How do I make it return a String?
Also, what is getJavaInitializationString?
The JavaDocs aren't helpful.
Is there more thorough documentation anywhere?
Thanks,
Eli
|
|
|
Re: Strings in PropertyEditorSupport [message #144361 is a reply to message #144341] |
Wed, 02 April 2008 22:02 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
The javainitializationString has to be the exact syntax of java that you
want to be in the set property statement. So if you return just "a" then
it means the variable a. If you wanted the string "a" then you need to
return "\"a\"".
Being the exact java syntax means you can do expressions and not just a
string, e.g. "\"A\"+Integer.MIN_VALUE" would be turned into
setX("A"+Integer.MIN_VALUE)
--
Thanks,
Rich Kulp
|
|
|
|
Re: Strings in PropertyEditorSupport [message #617026 is a reply to message #144341] |
Wed, 02 April 2008 22:02 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
The javainitializationString has to be the exact syntax of java that you
want to be in the set property statement. So if you return just "a" then
it means the variable a. If you wanted the string "a" then you need to
return "\"a\"".
Being the exact java syntax means you can do expressions and not just a
string, e.g. "\"A\"+Integer.MIN_VALUE" would be turned into
setX("A"+Integer.MIN_VALUE)
--
Thanks,
Rich Kulp
|
|
|
|
Powered by
FUDForum. Page generated in 0.02945 seconds