Subject: How to programmatically add elements to a Sapphire list? |
Author: Dmitri Pisarenko |
Date: Wed, 03 December 2014 13:10 |
Hello!
I have following model:
public interface IMyModel extends Element {
ElementType TYPE = new ElementType(IMyModel.class);
@Type(base=ISomeElement.class)
@Label( standard = "Some element" )
ListProperty PROP_SOME_ELEMENTS = new ListProperty( TYPE, "SomeElements" );
ElementList<ISomeElement> getSomeElements();
void setSomeElements(final ElementList<ISomeElement> value);
}
public interface ISomeElement extends Element {
ElementType TYPE = new ElementType(ISomeElement.class);
// Name
@Label(standard = "Name")
@Required
ValueProperty PROP_NAME = new ValueProperty(TYPE, "Name");
Value<String> getName();
void setName(String name);
}
When I try to create an instance of IMyModel and then a ISomeElement instance to it, I get an error.
final IMyModel sample = IMyModel.TYPE.instantiate();
final ISomeElement someElement = ISomeElement.TYPE.instantiate();
someElement.setName("Some name");
sample.getSomeElements().add(someElement);
The error is caused by this piece of code in org.eclipse.sapphire.ElementList.add(T):
public boolean add( final T object )
{
throw new UnsupportedOperationException();
}
How am I supposed to add elements to a list programmatically?
Note that I need this to be able to run tests on classes, which use IMyModel as input.
Thanks in advance
Dmitri Pisarenko
|
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]
|