Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » CountConstraint does not show any error message
CountConstraint does not show any error message [message #1064089] Mon, 17 June 2013 14:51 Go to next message
kon f is currently offline kon fFriend
Messages: 112
Registered: March 2012
Senior Member
Hey,

trying to use some count constraint on my root element - somehow it does not show any error message if the constraint is violated.

import org.eclipse.sapphire.modeling.IModelElement;
import org.eclipse.sapphire.modeling.ListProperty;
import org.eclipse.sapphire.modeling.ModelElementList;
import org.eclipse.sapphire.modeling.ModelElementType;
import org.eclipse.sapphire.modeling.annotations.CountConstraint;
import org.eclipse.sapphire.modeling.annotations.GenerateImpl;
import org.eclipse.sapphire.modeling.annotations.Label;
import org.eclipse.sapphire.modeling.annotations.Type;
import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding;
import org.eclipse.sapphire.modeling.xml.annotations.XmlListBinding;
import org.eclipse.sapphire.modeling.xml.annotations.XmlNamespace;
import org.eclipse.sapphire.modeling.xml.annotations.XmlSchema;

@GenerateImpl
@XmlNamespace(uri = "http://www.example.org/TestSystem")
@XmlSchema(namespace = "http://www.example.org/TestSystem", location = "http://www.example.org/TestSystem/1.0")
@XmlBinding(path = "root")
public interface Root extends IModelElement {

    ModelElementType TYPE = new ModelElementType(Root.class);

    // *** Description ***
    // @formatter:off
    @CountConstraint(min = 1)
    @Type(base = DescriptionBase.class, possible = { DescriptionA.class, DescriptionB.class, DescriptionC.class, DescriptionD.class })
    @XmlListBinding
    (
        path = "descriptions", 
        mappings = 
        {
                @XmlListBinding.Mapping(element = "a", type = DescriptionA.class),
                @XmlListBinding.Mapping(element = "b", type = DescriptionB.class), 
                @XmlListBinding.Mapping(element = "c", type = DescriptionC.class),
                @XmlListBinding.Mapping(element = "d", type = DescriptionD.class)
        }
    )
    
    ListProperty PROP_DESCRIPTION_BASE = new ListProperty(TYPE, "DescriptionBase");
    
    ModelElementList<DescriptionBase> getDescriptionBase();
    // @formatter:on

    // *** Item ***
    @Type(base = Item.class)
    @Label(standard = "items")
    @CountConstraint(min = 1)
    @XmlListBinding(mappings = @XmlListBinding.Mapping(element = "item", type = Item.class))
    ListProperty PROP_ITEMS = new ListProperty(TYPE, "Items");

    ModelElementList<Item> getItems();
}


If I start with some plain xml file, no error message is given. Both list properties violate the constraint since both have zero children.

http://img843.imageshack.us/img843/9696/m1n.png

The strange part is, that I already use the count constraint on list properties in my application. It is further down in the hierarchy (in the Item.class). Apparently, the count constraint just doesn't work on the root element. Or am I doing something wrong? Thank you.

Best regards,

Kon
Re: CountConstraint does not show any error message [message #1064104 is a reply to message #1064089] Mon, 17 June 2013 16:14 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Strange. Could you open a bug report and attached a zip of a project showing the problem?
Re: CountConstraint does not show any error message [message #1064211 is a reply to message #1064104] Tue, 18 June 2013 09:35 Go to previous messageGo to next message
kon f is currently offline kon fFriend
Messages: 112
Registered: March 2012
Senior Member
Hey Konstantin,

I added a bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=410998

Thank you.

Kon
Re: CountConstraint does not show any error message [message #1074166 is a reply to message #1064211] Fri, 26 July 2013 08:09 Go to previous messageGo to next message
kon f is currently offline kon fFriend
Messages: 112
Registered: March 2012
Senior Member
Hey,

I'm updated my editor to Sapphire 0.7 having still the same issue. I was wondering if I could use EL to validate the min size of a list property on the root element. I tried the following update on the items property:

// *** Item ***
@Type(base = Item.class)
@Label(standard = "items")
//@CountConstraint(min = 1)
@Validation(rule = "${Items.Size > 0}", message = "Min. one elemente!", severity = Severity.ERROR)
@XmlListBinding(mappings = @XmlListBinding.Mapping(element = "item", type = Item.class))
ListProperty PROP_ITEMS = new ListProperty(TYPE, "Items");

ModelElementList<Item> getItems();


My problem remains Sad Am I using it right? Thank you.

Best regards,

Kon
Re: CountConstraint does not show any error message [message #1112347 is a reply to message #1074166] Thu, 19 September 2013 13:18 Go to previous messageGo to next message
kon f is currently offline kon fFriend
Messages: 112
Registered: March 2012
Senior Member
Hey Konstantin,

thank you for the bug fix. With the latest version the error messages are shown as expected.

With the change to 0.7 I noticed that the bundle org.eclipse.sapphire.ui.swt.xml.editor now lists the following dependency:

org.eclipse.jdt.core;bundle-version="[3.7.0,4.0.0)"

I was wondering why this jdt dependencies is required? So far, I was able to avoid any jdt bundles in my application Smile

Thank you.

Kon
Re: CountConstraint does not show any error message [message #1112378 is a reply to message #1112347] Thu, 19 September 2013 15:25 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Could you open a bug for this? I am sure the jdt dependency can be factored out.
Re: CountConstraint does not show any error message [message #1112395 is a reply to message #1064089] Thu, 19 September 2013 16:26 Go to previous messageGo to next message
kon f is currently offline kon fFriend
Messages: 112
Registered: March 2012
Senior Member
Hey Konstantin,

I created a bug request:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=417610

Best regards,

Kon

[Updated on: Thu, 19 September 2013 16:26]

Report message to a moderator

Re: CountConstraint does not show any error message [message #1112400 is a reply to message #1112395] Thu, 19 September 2013 16:32 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 962
Registered: July 2009
Senior Member
Oops. I had already opened a bug since I had a fix in hand. Was about to post a link. Smile

https://bugs.eclipse.org/bugs/show_bug.cgi?id=417608

Please verify.
Previous Topic:Expensive @NoDuplicates
Next Topic:using combobox for non-enums fields
Goto Forum:
  


Current Time: Sun Dec 21 04:53:59 GMT 2014

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

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