Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:55 Go to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
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 08:44]

Report message to a moderator

Re: Determining whether an element contains certain property [message #761281 is a reply to message #761237] Tue, 06 December 2011 08:32 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
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 08:41 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
<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 09:02 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
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 09:21 Go to previous message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
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 09:21]

Report message to a moderator

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


Current Time: Fri Apr 19 03:33:48 GMT 2024

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

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

Back to the top