Apply read.only to cells at runtime [message #1232138] |
Thu, 16 January 2014 04:52  |
Eclipse User |
|
|
|
I have a table representation of a list property ListFoo, that contains 2 columns ColA and ColB. The cells should be editable in the table which of course works out of the box with sapphire and is great.
ListFoo contains 2 default entries, which must not be removed. I think this can be achieved using a SapphireActionHandlerFilter in conjunction with ListSelectionService for disabling the Remove Action when one of the entry is selected.
Now ColA of both entries should not be editable.
I'm trying to figure out how to implement that. I know that the read.only hint is available in the sdef, but is that applicable to instance elements at runtime somehow? Or do you know another approach. I could not find anything similar in the Sapphire Samples.
Thanks in advance.
|
|
|
|
|
Re: Apply read.only to cells at runtime [message #1239217 is a reply to message #1239068] |
Mon, 03 February 2014 12:08   |
Eclipse User |
|
|
|
I was suggesting that you show the two lists separately on the form, but I think there is a better solution. The @ReadOnly annotation is static, but you can have a heterogeneous list with two element types, such that the property is @ReadOnly in one. Something like this...
public interface ListEntry extends Element
{
ElementType TYPE = new ElementType( ListEntry.class );
// *** Value ***
ValueProperty PROP_VALUE = new ValueProperty( TYPE, "Value" );
Value<String> getValue();
void setValue( String value );
}
public interface ListEntryReadOnly extends ListEntry
{
ElementType TYPE = new ElementType( ListEntry.class );
// *** Value ***
@ReadOnly
ValueProperty PROP_VALUE = new ValueProperty( TYPE, ListEntry.PROP_VALUE );
}
// *** List ***
@Type( base = ListEntry.class, possible = { ListEntry.class, ListEntryReadOnly.class } )
@CustomXmlListBinding( impl = YourCustomBinding.class )
@XmlElementBinding
(
mappings =
{
@XmlElementBinding.Mapping( element = "entry", type = ListEntry.class ),
@XmlElementBinding.Mapping( element = "entry", type = ListEntryReadOnly.class ),
}
)
ListProperty PROP_LIST = new ListProperty( TYPE, "List" );
ElementList<ListEntry> getList();
You'd have to implement a custom binding for this list property since the standard binding can only assign different element types based on different XML element names and you'd have a custom heuristic. If you extend StandardXmlListBindingImpl, you should only need to override the type(Resource) method.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03360 seconds