Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamic combobox property descriptor
Dynamic combobox property descriptor [message #333713] Wed, 24 December 2008 19:16
Greg Mising name is currently offline Greg Mising nameFriend
Messages: 47
Registered: July 2009
Member
I'm trying to implement a combo box property descriptor that allows the
user to either select from the list or enter a new value, which will be
added to the list. Oh, and the list is not static - it's specific to the
target of the connection When a connection initializes, it asks the
target object for a list. If the list is empty then the descriptor gets
fed a list with one empty string.

The problem that I'm having is that when I type a new value and press
enter, the value that I entered is lost somewhere on the way to
setPropertyValue.

Here's the relevant code:

public IPropertyDescriptor[] getPropertyDescriptors() {
List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
descriptors.addAll( ModelElement.descriptors );
descriptors.add( new ComboBoxPropertyDescriptor( IDENTIFYING_PROP,
IDENTIFYING_PROP, IDENTIFYING_VALUES ) );
roleDescriptor = new SystemComboBoxPropertyDescriptor(
REFERENCE_ROLE_PROP, REFERENCE_ROLE_PROP, getRoles() );
descriptors.add( roleDescriptor );
return descriptors.toArray( new IPropertyDescriptor[]{} );
}
...
public void setPropertyValue( Object id, Object value ) {
if ( id.equals( IDENTIFYING_PROP ) ) {
int idx = ( (Integer) value );
if ( idx >= 0 && idx < IDENTIFYING_VALUES.length ) {
setIdentifying( IDENTIFYING_VALUES[idx] );
}
} else if ( id.equals( REFERENCE_ROLE_PROP ) ) {
SystemComboBoxCellEditor cellEditor = (SystemComboBoxCellEditor)
roleDescriptor.getPropertyEditor();
String roleValue = cellEditor.getComboBoxItems()[( (Integer) value
).intValue()];
setRole( roleValue );
} else
super.setPropertyValue( id, value );
}

When it gets to setPropertyValue, the value parameter is always 0 and the
cell editor combo box items contains only the seeded empty string.

BTW, I'm using a SystemComboBoxCellEditor since it allowed a non-readonly
combo box.

Thanks for your help.

Cheers,
Greg
Previous Topic:How to configure "Web Service runtime" JBossWS instead of Apache Axis?
Next Topic:Form problems.
Goto Forum:
  


Current Time: Tue Nov 19 12:12:49 GMT 2024

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

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

Back to the top