Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sapphire-dev] New topic in forum Sapphire, called What is the best way to add tree node for an optional xml child element?, by Slava Kabanovich

Title: Eclipse Community Forums
Subject: What is the best way to add tree node for an optional xml child element? Author: Slava Kabanovich Date: Mon, 01 December 2014 15:07
Consider xml:
<my-node>
  <my-optional-child required-attribute="x">
     <my-optional-grandchild required-attribute="y"/>
  </my-optional-child>
</my-node>

Element <my-optional-child> is optional in <my-node> and element <my-optional-grandchild> is optional in <my-optional-child>. Once one or both of these elements are present, attribute 'required-attribute' must be set.

In interface MyNode I added ImpliedElementProperty PROP_MY_OPTIONAL_CHILD.
In editor definition (.sdef file) I described node as
	<node>
		<id>MyOptionalChildNode</id>
		<property>MyOptionalChild</property>
...
       </node>

and included it to children of MyNode tree node.
The same approach is implemented for my-optional-grandchild.

Editor works fine when child nodes are available in xml. When I remove them, nodes in tree remain, which is ok as a handle to add the child element just by editing its form.
What is bad, is that when there are no child elements in xml, nodes in tree and forms display a validation error about missing required attribute.

The node in xml can be hidden by
<visible-when>${RequiredAttribute != null}</visible-when>
Then everything is ok but one: I do not have the handle to add the child element.

I tried to add a form section to parent node as such a handle. But again, it displays a validation error when the child element is missing.

What is the best practice to treat this case?
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]

Back to the top