ComboBox in Properties View [message #236870] |
Tue, 10 July 2007 10:20 |
Eclipse User |
|
|
|
Originally posted by: neliacatarina.portugalmail.pt
Hi
I want to put a combobox in one of the lines of my properties view. I have this:
public static String[] tokens = {"test1","test2"};
static {
descriptors = new IPropertyDescriptor[] {
new TextPropertyDescriptor(NAME, "Name"),
new ComboBoxPropertyDescriptor(TOKEN, "Inicial Place",
tokens),
};
}
...
public Object getPropertyValue(Object propName) {
if (NAME.equals(propName))
return getName();
if (TOKEN.equals(propName)){
return getTokens();
}
return super.getPropertyValue(propName);
}
where getTokens() returns an array of Strings.
I can't see any combobox when I run it. Can you tell me what am I doing wrong?
Thanks
|
|
|
|
Re: ComboBox in Properties View [message #236929 is a reply to message #236870] |
Fri, 13 July 2007 18:15 |
Eclipse User |
|
|
|
Originally posted by: vaceslav.ustinov.gmail.com
Hi,
You have an Error in your getPropertyValue() function.
The return value of getPropertyValue must be an "int"-value, this is the index of your array.
In your example for test1 you must return "0" and for test2 "1".
apply for the function setPropertyValue() the same.
See my example.
public void initProperty(){
.....
.....
String[] values = { "false", "true" };
PropertyDescriptor comboBoxPropertyDescriptor = new ComboBoxPropertyDescriptor("PropertyId", "PropertyLabel", values);
comboBoxPropertyDescriptor.setCategory("Basic");
.....
.....
}
public Object getPropertyValue(Object id) {
if (id.equals("PropertyId"){
if (booleanFunction())
return 1;
else
return 0;
}
}
public void setPropertyValue(Object id, Object value) {
if (id.equals("PropertyId"){
setPropertyValue((Integer)value);
}
}
public void setPropertyValue(Integer value) {
if (value.intValue() == 1)
this.booleanVar = true;
else if (value.intValue() == 0)
this.booleanVar = false;
firePropertyChange("PropertyId", null, value);
}
Regards.
Vaceslav Ustinov
Nelia Santos schrieb:
> Hi
>
> I want to put a combobox in one of the lines of my properties view. I have this:
>
> public static String[] tokens = {"test1","test2"};
>
> static {
> descriptors = new IPropertyDescriptor[] {
> new TextPropertyDescriptor(NAME, "Name"),
> new ComboBoxPropertyDescriptor(TOKEN, "Inicial Place",
> tokens),
> };
> }
>
> ..
>
> public Object getPropertyValue(Object propName) {
> if (NAME.equals(propName))
> return getName();
> if (TOKEN.equals(propName)){
> return getTokens();
> }
> return super.getPropertyValue(propName);
> }
>
> where getTokens() returns an array of Strings.
> I can't see any combobox when I run it. Can you tell me what am I doing wrong?
> Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.02930 seconds