Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Keyword final on StandardXmlValueBindingImpl
Keyword final on StandardXmlValueBindingImpl [message #1239917] Wed, 05 February 2014 10:19 Go to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Is there a special reason why StandardXmlValueBindingImpl is final, while all other StandardXml*BindingImpl are not and can be extended for usage with @CustomXml*Binding .

I wanted to add a custom xml value binding that sets a 'null'-value in some cases, but right now I must copy the StandardXmlValueBindingImpl implementation, as it can not be extended.
Re: Keyword final on StandardXmlValueBindingImpl [message #1240076 is a reply to message #1239917] Wed, 05 February 2014 16:48 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
If there is a usecase where it would be advantageous to extend StandardXmlValueBindingImpl, we can certainly make that class non-final. Please open an enhancement request.
Re: Keyword final on StandardXmlValueBindingImpl [message #1240095 is a reply to message #1240076] Wed, 05 February 2014 17:30 Go to previous messageGo to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
My use case is: Show an implicit default value in the presentation, that is derived dynamically. So when the value is empty, the property editor should show the default value according to some heuristic. A custom binding implementation could look like this:

public class ImplicitDefaultXmlValueBinding extends StandardXmlValueBindingImpl {

	@Override
	public String read() {
		String value = super.read();
		if (value != null && !value.equals(XmlUtil.EMPTY_STRING))
			return value;
		else
			return defaultValue();
	}

	@Override
	public void write(String value) {
		final String defaultValue = defaultValue();
		if (defaultValue.equals(value)) {
			super.write(null);
		} else {
			super.write(value);
		}
	}

	private String defaultValue() {
		...
	}

}
Re: Keyword final on StandardXmlValueBindingImpl [message #1240102 is a reply to message #1240095] Wed, 05 February 2014 17:59 Go to previous messageGo to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Is that use case above worth opening the enhancement request? The topic was discussed (offline) in https://bugs.eclipse.org/bugs/show_bug.cgi?id=421378 and then closed. I don't want to spam bugzilla.
Re: Keyword final on StandardXmlValueBindingImpl [message #1240132 is a reply to message #1240102] Wed, 05 February 2014 19:26 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
My use case is: Show an implicit default value in the presentation, that is derived dynamically. So when the value is empty, the property editor should show the default value according to some heuristic.


For default values, you should use @DefaultValue or DefaultValueService instead of trying to solve this in the binding.

Quote:
Is that use case above worth opening the enhancement request? The topic was discussed (offline) in https://bugs.eclipse.org/bugs/show_bug.cgi?id=421378 and then closed.


It all depends on the usecase as that would drive how the class is setup to be extended. For instance, StandardXmlListBindingImpl there is a protected initBindingMetadata() method so that subclasses can replace the standard behavior of reading annotations... etc.
Re: Keyword final on StandardXmlValueBindingImpl [message #1240417 is a reply to message #1240132] Thu, 06 February 2014 12:01 Go to previous messageGo to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Another use-case:

We have several value properties of type Boolean. The value is bound against a Xml Attribute, which is optional in the Xml Schema. Now we want to remove the attribute in case of value 'false'.

The UI presentation is a checkbox that of course only has two states, checked & unchecked.

Right now the StandardXmlValueBinding always maps the unchecked state to false.

Also with @XmlValueBinding.mapExistanceToValue this can not be achieved.
@XmlValueBinding(path = "@MyBooleanAttribute", mapExistanceToValue = "true;")


results in
'checked':
<Element MyBooleanAttribute="">


'unchecked':
<Element>
Re: Keyword final on StandardXmlValueBindingImpl [message #1240520 is a reply to message #1240417] Thu, 06 February 2014 17:11 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
The checkbox presentation actually has three state: default (either false or true depending on model), explicit false and explicit true. You can tell the difference between the default state and explicit state via the light bulb near the checkbox, which is only present if the state is explicit.

What you are talking about essentially removes explicit false state. I wouldn't advise doing this, but I do not see any harm in accommodating this. If extending StandardXmlValueBindingImpl would be helpful in this case, either re-open the existing enhancement request or open a new one.
Re: Keyword final on StandardXmlValueBindingImpl [message #1240527 is a reply to message #1240520] Thu, 06 February 2014 17:25 Go to previous message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
Quote:
You can tell the difference between the default state and explicit state via the light bulb near the checkbox, which is only present if the state is explicit.


For tables containing checkboxes there are only 2 states, as there is no bulb available.

I've opened a new enhancement request, as I could not reopen the old one. https://bugs.eclipse.org/bugs/show_bug.cgi?id=427585

[Updated on: Thu, 06 February 2014 17:26]

Report message to a moderator

Previous Topic:Enable row level validation markers
Next Topic:Expression in PossibleValues.invalidValueMessage()
Goto Forum:
  


Current Time: Wed Dec 11 22:33:35 GMT 2024

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

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

Back to the top