Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345340

Summary: element property should be optional
Product: z_Archived Reporter: Ling Hao <ling.hao>
Component: SapphireAssignee: Project Inbox <sapphire.ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: konstantin
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Ling Hao CLA 2011-05-10 17:22:53 EDT
In the sapphire-gallery.xml sample -> element properties -> heterogeneous node. 
Would it be possible to show only child node for only <child-element-with-enum>, but not <child-element>? Currently if I remove the case statement for the following:

<model-element-type>IChildElement</model-element-type>

I got a RuntimeException:
java.lang.RuntimeException
	at org.eclipse.sapphire.ui.form.editors.masterdetails.MasterDetailsContentNode$NodeFactory.node(MasterDetailsContentNode.java:901)
	at org.eclipse.sapphire.ui.form.editors.masterdetails.MasterDetailsContentNode$NodeFactory.nodes(MasterDetailsContentNode.java:854)
Comment 1 Konstantin Komissarchik CLA 2011-05-10 17:34:56 EDT
Since this is a question rather than a problem statement, this would have been better started on the forum or the mailing list.

The answer to the question is, yes, this is possible. If you look at the definition of IElementPropertiesGallery.Heterogeneous property, you will see this:

@Type( base = IChildElement.class, possible = { IChildElement.class, IChildElementWithInteger.class, IChildElementWithEnum.class } )

Note that IChildElement is listed among possible types. There is no requirement that the base type is among possible types. Simply remove it from the possible list and you will no longer need to specify a case for it.
Comment 2 Ling Hao CLA 2011-05-10 17:44:49 EDT
Sorry my statement was not clear. I would like the child node <child-with-enum> node to show up as it is now. But if the user selected "child element" or "child element with integer" radio button, that the <child> or <child-with-integer> node not show up.
Comment 3 Konstantin Komissarchik CLA 2011-05-10 18:04:17 EDT
Sorry, that is making no sense. Can you better outline a case where the behavior you describe is desirable?
Comment 4 Ling Hao CLA 2011-05-10 19:08:29 EDT
Let say the "Child element with enum" has a lot of value properties which does not fit into a single page. I suppose the following is viable:

Heterogeneous
    <child-with-enum>
        more-child-with-enum

But instead of duplicating the properties in the <child-with-enum> node, display it in the RHS of the Heterogeneous node and have the following:

Heterogeneous
    more-child-with-enum

Instead of duplicating the content of "child element" in the Heterogeneous and the <child>, eliminate the <child> node

Perhaps a UI review of my code is better.
Comment 5 Konstantin Komissarchik CLA 2011-05-10 21:30:03 EDT
I think I now understand what you are trying to accomplish. You are trying to use the with construct to control the child element's lifecycle while simultaneously using node-factory to display additional content. 

That is not what node-factory is designed to handle. It isn't even the issue of making it possible to not specify cases. The add and delete actions cease to make sense when used in this manner. The fundamental assumption of the node-factory construct is you should be able to add an element that will correspond to a node, which you can then delete, which will delete an element. In your case, some add operations will not result in a node while others will result in a node that users will not necessarily associate with the element that would be deleted if the node delete action is invoked.

I do not at this point know how we would support what you are trying to accomplish.
Comment 6 Ling Hao CLA 2011-05-11 13:01:45 EDT
I was trying to eliminate one extra node, but the supported feature works fine. Closing bug.