|
|
|
Re: Apply read.only to cells at runtime [message #1239217 is a reply to message #1239068] |
Mon, 03 February 2014 17:08 |
Konstantin Komissarchik Messages: 1077 Registered: July 2009 |
Senior Member |
|
|
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.
|
|
|
|
|
Re: Apply read.only to cells at runtime [message #1239314 is a reply to message #1239306] |
Mon, 03 February 2014 23:08 |
Andreas Weise Messages: 37 Registered: January 2014 |
Member |
|
|
Ok. Unfortunatly a Filter added on the Property Editor of the List with the following code, does not filter it out:
@Override
public boolean check(SapphireActionHandler handler) {
return !handler.getAction().getId().equals("Sapphire.Add");
}
I also debugged, and it did not even invoke the check method. Adding it programmatically however works.
And another issue came up, but that more seems like a bug. After disabling the delete button (like described in the last reply) entries can still be deleted using the DEL key on the keyboard.
[Updated on: Mon, 03 February 2014 23:24] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04990 seconds