ComboBoxPropertyDescriptor [message #161573] |
Wed, 15 December 2004 13:57 |
Eclipse User |
|
|
|
Originally posted by: seb01016.fh-hagenberg.at
Hi
I'm trying to implement a ComboBoxPropertyDescriptor but it causes me
troubles.
I want to implement a generic PropertySource. I created a class that
implements IPropertySource. Within the method public IPropertyDescriptor[]
getPropertyDescriptors() I check the type of the property. For example if
it is a string: if( type.getInstanceClass() == String.class ) {
descriptors.add( new TextPropertyDescriptor( Integer.toString(
attr.getFeatureID() ), attr.getName() ) );
This works fine for String attributes, but causes toubles if I try to
implement PropertyDescriptors for other values. I want to implement a
ComboBoxPropertyDescriptor for a certain type, therefore I tried following
code:
if(type.getInstanceClass()==CommandType.class){
Iterator iter=CommandType.VALUES.iterator();
String[] values=new String[CommandType.VALUES.size()];
int i=0;
while(iter.hasNext()){
CommandType comType=(CommandType)iter.next();
values[i]=comType.toString();
i++;
System.out.println(comType);
}
descriptors.add(new ComboBoxPropertyDescriptor(Integer.toString(
attr.getFeatureID()),"Command Type",values));
But if i start the application, no values are displayed and if i select
the property, I get the following exception:
org.eclipse.jface.util.Assert$AssertionFailedException: Assertion failed:
at org.eclipse.jface.util.Assert.isTrue(Assert.java:168)
at org.eclipse.jface.util.Assert.isTrue(Assert.java:154)
at
org.eclipse.jface.viewers.ComboBoxCellEditor.doSetValue(Comb oBoxCellEditor.java:209)
at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.jav a:760)
at
org.eclipse.gef.internal.ui.properties.PropertySheetEntry.ge tEditor(PropertySheetEntry.java:358)
at
org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:147)
....
....
Can anybody please tell me, which steps are necessary to implement a
ComboBoxPropertyDescriptor?
thx in advance
Hannes
|
|
|
Re: ComboBoxPropertyDescriptor [message #161777 is a reply to message #161573] |
Thu, 16 December 2004 16:01 |
Eclipse User |
|
|
|
Originally posted by: wdai.cyberwerx.com
Your getPropertyValue() in your PropertySource class needs to return Integer
for combobox choices instead of String. It expects a position of the choice
list instead of a String.
William
"Schoenboeck" <seb01016@fh-hagenberg.at> wrote in message
news:cppfrh$rhg$1@www.eclipse.org...
> Hi
>
> I'm trying to implement a ComboBoxPropertyDescriptor but it causes me
> troubles.
> I want to implement a generic PropertySource. I created a class that
> implements IPropertySource. Within the method public IPropertyDescriptor[]
> getPropertyDescriptors() I check the type of the property. For example if
> it is a string: if( type.getInstanceClass() == String.class ) {
> descriptors.add( new TextPropertyDescriptor( Integer.toString(
> attr.getFeatureID() ), attr.getName() ) );
>
> This works fine for String attributes, but causes toubles if I try to
> implement PropertyDescriptors for other values. I want to implement a
> ComboBoxPropertyDescriptor for a certain type, therefore I tried following
> code:
>
> if(type.getInstanceClass()==CommandType.class){
> Iterator iter=CommandType.VALUES.iterator();
> String[] values=new String[CommandType.VALUES.size()];
> int i=0;
> while(iter.hasNext()){
> CommandType comType=(CommandType)iter.next();
> values[i]=comType.toString();
> i++;
> System.out.println(comType);
> }
>
> descriptors.add(new ComboBoxPropertyDescriptor(Integer.toString(
> attr.getFeatureID()),"Command Type",values));
>
> But if i start the application, no values are displayed and if i select
> the property, I get the following exception:
>
> org.eclipse.jface.util.Assert$AssertionFailedException: Assertion failed:
> at org.eclipse.jface.util.Assert.isTrue(Assert.java:168)
> at org.eclipse.jface.util.Assert.isTrue(Assert.java:154)
> at
>
org.eclipse.jface.viewers.ComboBoxCellEditor.doSetValue(Comb oBoxCellEditor.j
ava:209)
> at org.eclipse.jface.viewers.CellEditor.setValue(CellEditor.jav a:760)
> at
>
org.eclipse.gef.internal.ui.properties.PropertySheetEntry.ge tEditor(Property
SheetEntry.java:358)
> at
>
org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(Prope
rtySheetViewer.java:147)
> ...
> ...
>
> Can anybody please tell me, which steps are necessary to implement a
> ComboBoxPropertyDescriptor?
>
> thx in advance
> Hannes
>
|
|
|
Powered by
FUDForum. Page generated in 0.03043 seconds