Skip to main content



      Home
Home » Archived » Sapphire » Determining whether an element contains a certain property
Determining whether an element contains a certain property [message #761237] Tue, 06 December 2011 01:55 Go to next message
Eclipse UserFriend
Hi,
I'm in the need of a condition which checks whether an element has a certain property.
At the moment, I'm doing the following:
property = element.getModelElementType().getProperty(this.property);
return property != null;

It works.
But for every failed getProperty() call, the host console shows the following message (in red nonetheless):
ERROR : Invalid model path "List" evaluated on my.package.IConstant.

Is there a better way?
Many thanks,
Roded

[Updated on: Tue, 06 December 2011 03:44] by Moderator

Re: Determining whether an element contains certain property [message #761281 is a reply to message #761237] Tue, 06 December 2011 03:32 Go to previous messageGo to next message
Eclipse UserFriend
Could you show me a snippet of sdef where this condition is used and "List" is referenced?

- Konstantin
Re: Determining whether an element contains certain property [message #761286 is a reply to message #761281] Tue, 06 December 2011 03:41 Go to previous messageGo to next message
Eclipse UserFriend
<if>
    <condition>
        <class>PropertyExistsCondition</class>
        <parameter>List</parameter>
    </condition>
    <then>
        <include>@composite.value.list</include>
    </then>
    <else>...</else>
</if>

I might be doing this is a bit of a non-standard way:
I have an basic IValue with no properties which IList (for example) extends and adds a List property.
My composite then determines the type of content to show based on which property exists.
Roded
Re: Determining whether an element contains certain property [message #761303 is a reply to message #761286] Tue, 06 December 2011 04:02 Go to previous messageGo to next message
Eclipse UserFriend
That doesn't show what could possibly be causing that error. There must be other references to "List" somewhere else. ModelElementType.getProperty() doesn't cause this error...

    public ModelProperty getProperty( final String propertyName )
    {
        for( ModelProperty property : getProperties() )
        {
            if( property.getName().equalsIgnoreCase( propertyName ) )
            {
                return property;
            }
        }
        
        return null;
    }
Re: Determining whether an element contains certain property [message #761311 is a reply to message #761303] Tue, 06 December 2011 04:21 Go to previous message
Eclipse UserFriend
Right.
It was my initCondition()'s
super.initCondition(part, parameter);

Removed it as there's no listener relevance here.
Thanks.

[Updated on: Tue, 06 December 2011 04:21] by Moderator

Previous Topic:Property content based content assist
Next Topic:Persisting the generated implemented class in Sapphire
Goto Forum:
  


Current Time: Sun Nov 09 14:58:17 EST 2025

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

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

Back to the top