Heterogeneous list with no common property [message #1060618] |
Mon, 27 May 2013 10:59  |
kon f Messages: 152 Registered: March 2012 |
Senior Member |
|
|
Hey,
I'm trying to implement a list storing different types. The gallery examples presents a running implementation. I copied the example and adjusted it for my requirements that slightly differ. My sub types do not have any attributes in common. So my base type does not contain any property, as it is for IChildElement interface. IChildElement contains the StringValue property that is inherited to all subtypes and used to shown in the UI (table).
@GenerateImpl
public interface Base extends IModelElement {
ModelElementType TYPE = new ModelElementType(Empty.class);
}
Text, Image and Pdf extend Base.
@Type(base = Base.class, possible = { Text.class, Image.class, Pdf.class })
@XmlListBinding
(
path = "description",
mappings =
{
@XmlListBinding.Mapping(element = "text", type = Text.class),
@XmlListBinding.Mapping(element = "image", type = Image.class),
@XmlListBinding.Mapping(element = "pdf", type = Pdf.class)
}
)
ListProperty PROP_DESCRIPTION = new ListProperty(TYPE, "Description");
ModelElementList<Empty> getDescription();
The table that shows the types in the UI just executes the toString() method from java.lang.Object and prints the memory address from org.eclipse.sapphire.ui.renderers.swt.DefaultListPropertyEditorRenderer$TableRow. Is there a straightforward way I could provide a label/content provider? I provided editing support in the detail area, but it would be nice if the user could directly change one property of a certain subtype in the table (that I would had to define per type e.g. for Image the URI and for Text the content). Is that possible?
Thank you!
Kon
|
|
|
|
Re: Heterogeneous list with no common property [message #1060846 is a reply to message #1060842] |
Tue, 28 May 2013 15:54   |
Konstantin Komissarchik Messages: 1077 Registered: July 2009 |
Senior Member |
|
|
The table editor for list properties requires at least one property in the base type, but the property does not need to be defined the same across all sub-types. You can vary, XML binding, validation, etc. For instance, you can definite property Content in base type, then bind it to "URI" element for one sub-type, to "Text" element for another sub-type, etc.
For an example, see how ContactAddress type overrides properties in its parent type Address to add XML binding specification.
- Konstantin
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01324 seconds