Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Using ImpliedElementProperties
Using ImpliedElementProperties [message #1172153] Tue, 05 November 2013 18:46 Go to next message
Paul Funyak is currently offline Paul FunyakFriend
Messages: 11
Registered: September 2013
Junior Member
Hi,

I am trying to create a model that is similar to your NestedPropertiesInListGallery example.

In your example, the resulting list is an homogeneous ElementList of Employees.

In my case I am trying to model a heterogeneous ElementList of Actions.

I have an ImpliedElementProperty defined in one of my models as follows:

@Type(base = ActionBase.class, possible = { Subclass1.class, Subclass2.class, Subclass3.class, Subclass4.class, Subclass5.class })
@XmlListBinding(path = "actions")
ImpliedElementProperty PROP_ACTION_LIST = new ImpliedElementProperty( TYPE, "ActionList" );
ActionList getActionList();

When I try to add an item to the list, Sapphire calls StandardImpliedXmlElementBindingImpl.Init which throws an IllegalStateException because the number of types returned by the following call is greater than 1

if( property.service( PossibleTypesService.class ).types().size() > 1 )
{
throw new IllegalStateException();
}

When I step through the above call I get into the PossibleTypesService class.

The comment in this class states :

* Enumerates the possible child element types for a list or an element property. Each
* returned type is required to derive from the property's base type.

All of my subclasses are derived from the ActionBase class which implies to me that what I am doing should work.

Is this the case or am I misunderstanding something?

Thanks in advance for your help
Re: Using ImpliedElementProperties [message #1172332 is a reply to message #1172153] Tue, 05 November 2013 21:34 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
It looks like you've added type metadata meant for a list property onto an ImpliedElementProperty. For an ImpliedElementProperty, @Type should match the return type of the getter method. Since the implied child element is created automatically on first access without an opportunity to specify the type, there is no heterogenous support, but I suspect that's not what you were after...
Re: Using ImpliedElementProperties [message #1173626 is a reply to message #1172332] Wed, 06 November 2013 16:55 Go to previous messageGo to next message
Paul Funyak is currently offline Paul FunyakFriend
Messages: 11
Registered: September 2013
Junior Member
No Message Body
Re: Using ImpliedElementProperties [message #1173703 is a reply to message #1173626] Wed, 06 November 2013 17:57 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Did the message body get lost in transit?
Re: Using ImpliedElementProperties [message #1173760 is a reply to message #1173703] Wed, 06 November 2013 18:47 Go to previous messageGo to next message
Paul Funyak is currently offline Paul FunyakFriend
Messages: 11
Registered: September 2013
Junior Member
What I am after is to display a summary list of actions.

I have this working but I have run into another issue which I believe is caused by differences between ImpliedElementProperty and ElementProperty.

Here's what I have so far:

I fixed my ListProperty definition as follows

    @Type(base = Action.class, possible = { CollectData.class, PromptAndWaitForResponse.class })
    @Label( standard = "Action Summary" )
    ListProperty PROP_ACTION_LIST = new ListProperty( TYPE, "ActionList" );
    ActionList getActionList();


I've create the following models:
Please note the following two lines of code in the Action
    //@Type(base = Instruction.class, possible = {PromptDigits.class, PromptReady.class})
    //ElementProperty PROP_INSTRUCTION = new ElementProperty( TYPE, "Instruction" );



public interface ActionList extends Element {

    ElementType TYPE = new ElementType(ActionList.class);

        interface Action extends Element, HtmlElement
        {
            ElementType TYPE = new ElementType( Action.class );
            @DefaultValue(text = "Default Action Name")
            @Label(standard = "Action Name")
            @Required
            @ReadOnly()
            ValueProperty PROP_ACTION_NAME = new ValueProperty(TYPE, "ActionName");
            Value<String> getActionName();
        
            interface Instruction extends Element
            {
                ElementType TYPE = new ElementType( Instruction.class );
                @DefaultValue(text = "Default Name")
                @Label(standard = "Instruction Name")
                @Required
                @ReadOnly()
                ValueProperty PROP_NAME = new ValueProperty(TYPE, "Name");
                Value<String> getName();
            }

            @Label(standard = "Instruction")
            //@Type(base = Instruction.class, possible = {PromptDigits.class, PromptReady.class})
            //ElementProperty PROP_INSTRUCTION = new ElementProperty( TYPE, "Instruction" );
            @Type(base = Instruction.class)
            ImpliedElementProperty PROP_INSTRUCTION = new ImpliedElementProperty( TYPE, "Instruction" );
            Instruction getInstruction();
        }
        
        @Type( base = Action.class )
        @Label( standard = "actions" )
        ListProperty PROP_ACTIONS = new ListProperty( TYPE, "Actions" );
        ElementList<Action> getActions();
}


public interface PromptDigits extends Instruction, Prompt {

    ElementType TYPE = new ElementType(PromptDigits.class);

    @DefaultValue(text = "Prompt Digits")
    // Name of the Action
    @Label(standard = "Instruction Name")
    ValueProperty PROP_NAME = new ValueProperty(TYPE, "Name");
    @Override
    Value<String> getName();
}



My sdef for the ListProperty looks like:

                    <property-editor>
                        <child-property>ActionName</child-property>
                        <property>ActionList</property>
                        <child-property>Instruction/Name</child-property>
                        <child-property>
                            <hint>
                                <name>read.only</name>
                                <value>true</value>
                            </hint>
                            <property>ElementIdType</property>
                        </child-property>
                        <child-property>
                            <hint>
                                <name>read.only</name>
                                <value>true</value>
                            </hint>
                            <property>ElementIdValue</property>
                        </child-property>
                        <hint>
                            <name>read.only</name>
                            <value>true</value>
                        </hint>
                    </property-editor>



From the definitions above, I get the following list which is what I am after.

index.php/fa/16689/0/


The problem I am running into now seems to be around implied element properties versus element properties.

With the above models, when I add a "CollectData" action to the list, the Instruction property is "unknown" at the time of creating the CollectData property.

I would like to be able to use a "With" part to allow the user to select the type of instruction that will be associated with the CollectData model.

If I change the following lines in the Action model from
   @Type(base = Instruction.class)
   ImpliedElementProperty PROP_INSTRUCTION = new ImpliedElementProperty( TYPE, "Instruction" );

to
    @Type(base = Instruction.class, possible = {PromptDigits.class, PromptReady.class})
    ElementProperty PROP_INSTRUCTION = new ElementProperty( TYPE, "Instruction" );


to make the Instruction Property an ElementProperty instead of an ImpliedElementProperty, I can do the following

index.php/fa/16690/0/


If the instruction is an ImpliedElementProperty, I run into the xml binding issue from the original post for this topic. It also breaks my action summary list because I can no longer use
<child-property>Instruction/Name</child-property>

in the sdef.
Re: Using ImpliedElementProperties [message #1173822 is a reply to message #1173760] Wed, 06 November 2013 19:38 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
The columns in a table property editor are restricted to value properties directly located in the list entry type or accessible through one or more levels of implied element properties. Explicit element properties are not supported here as reading and editing them requires more UI than is available in the table cells. The implied nature of implied element properties means that no additional UI is necessary, so that the table property editor is able to traverse there.
Re: Using ImpliedElementProperties [message #1174966 is a reply to message #1173822] Thu, 07 November 2013 12:34 Go to previous messageGo to next message
Paul Funyak is currently offline Paul FunyakFriend
Messages: 11
Registered: September 2013
Junior Member
Konstantin Komissarchik wrote on Wed, 06 November 2013 14:38
The columns in a table property editor are restricted to value properties directly located in the list entry type or accessible through one or more levels of implied element properties.


Ok. I understand how this works.

Konstantin Komissarchik wrote on Wed, 06 November 2013 14:38

Explicit element properties are not supported here as reading and editing them requires more UI than is available in the table cells. The implied nature of implied element properties means that no additional UI is necessary, so that the table property editor is able to traverse there.


I don't want to edit anything in the the summary table. I just want to display the data, but maybe I'm misunderstanding your reponse.

For us newbies to Sapphire, can you explain the difference between how Sapphire handles Element properties (Explicit?) versus Implied Element properites?

When should you typically use an ElementProperty versus and Implied Element property?
Re: Using ImpliedElementProperties [message #1175126 is a reply to message #1174966] Thu, 07 November 2013 14:45 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Quote:
I don't want to edit anything in the the summary table. I just want to display the data


The cells in the table property editor are themselves property editors. Double click to edit data in place.

Quote:
can you explain the difference between how Sapphire handles Element properties (Explicit?) versus Implied Element properites?


At model-level, a regular (or explicit) element property's child element must be explicitly created by an api call that can specify a type (hence the heterogeneous support); the child element can also be deleted. In contrast, the child of an implied element property is instantiated on first access. There is no api to create it explicitly and there is no way to delete it. Once you access it, it is there.

This has an implication on the matching UI patterns. The best way to understand it is to try the "with" construct on an implied element property and on a regular element property. In the first case you will not see any UI relating to the element property, the context just passes to the child element. In the second case, you will have controls to create and delete the element.

Quote:
When should you typically use an ElementProperty versus and Implied Element property?


Implied element properties are used when the child element has no semantic meaning. That is, the model could be flattened without loosing any semantics. Regular element properties are used when the presense/absence of the child element in itself has a semantic meaning and the model could not be flattened without loosing those semantics.
Previous Topic:Issue with expression in 'visible when' of component
Next Topic:Update on Sapphire 0.7
Goto Forum:
  


Current Time: Sat Dec 20 21:07:42 GMT 2014

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

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