Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ComboBoxPropertyDescriptor
ComboBoxPropertyDescriptor [message #161573] Wed, 15 December 2004 13:57 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Cannot get editor to display my model
Next Topic:refresh child
Goto Forum:
  


Current Time: Fri Apr 26 12:00:36 GMT 2024

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

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

Back to the top