Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Restricting attribute value choice
Restricting attribute value choice [message #697945] Mon, 18 July 2011 12:45 Go to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Hi !

I would like to know is there is a way to filter attribute choice for a field, instead of letting user choose any value and validating his choise with a constraint after.

What i need is a kind of StateMachine owning States, and i want to be able to choose the initial State of my machine.
I managed to make a constraint to prevent to select a State owned by a different machine, but they are still in the list, and i don't know how to fix it.

Any help is welcome !

Thanks in advance,

Valerian
Re: Restricting attribute value choice [message #698042 is a reply to message #697945] Mon, 18 July 2011 15:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<ul>
<li class="toclevel-2"><a
href="http://wiki.eclipse.org/index.php/EMF-FAQ#How_can_I_control_which_instances_are_available_as_choices_when_editing_a_property_in_the_properties_view.3F"><span
class="tocnumber">2.46</span> <span class="toctext">How can
I control which instances are available as choices when
editing a property in the properties view?</span></a></li>
</ul>
<br>
<br>
On 18/07/2011 5:45 AM, <a class="moz-txt-link-abbreviated" href="mailto:forums-noreply@eclipse.org">forums-noreply@eclipse.org</a> wrote:
<blockquote cite="mid:j019ae$9i5$1@news.eclipse.org" type="cite">Hi
!
<br>
<br>
I would like to know is there is a way to filter attribute choice
for a field, instead of letting user choose any value and
validating his choise with a constraint after.
<br>
<br>
What i need is a kind of StateMachine owning States, and i want to
be able to choose the initial State of my machine. I managed to
make a constraint to prevent to select a State owned by a
different machine, but they are still in the list, and i don't
know how to fix it.
<br>
<br>
Any help is welcome !
<br>
<br>
Thanks in advance, <br>
Valerian
<br>
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Restricting attribute value choice [message #698291 is a reply to message #698042] Tue, 19 July 2011 08:18 Go to previous messageGo to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Nice it works perfectly, thanks a lot !

Re: Restricting attribute value choice [message #821618 is a reply to message #698291] Thu, 15 March 2012 16:02 Go to previous messageGo to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hi, I want to do exactly what this message says, that is, to restrict the choice values in a list. As far as I understand, if I type this, there should not be any option available in the list, because I have not written any "coiceOfValue.add(object);":
  /**
   * This adds a property descriptor for the Foo feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated NOT
   */
  protected void addFooPropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (new ItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Abc_foo_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Abc_foo_feature", "_UI_Abc_type"),
         XyzPackage.Literals.ABC__FOO,
         true,
         false,
         true,
         null,
         null,
         null)
       {
        @Override
        public Collection<?> getChoiceOfValues(Object object)
        {
          List<Object> choiceOfValues = new ArrayList<Object>(super.getChoiceOfValues(object));
          // Filter the choices before returning them.
          return choiceOfValues;
        }
      });
  }


But if I type that still all the options are available, as they were before. What am I missing??

Thanks in advance!
Re: Restricting attribute value choice [message #821700 is a reply to message #821618] Thu, 15 March 2012 17:59 Go to previous messageGo to next message
Tim Schaefer is currently offline Tim SchaeferFriend
Messages: 49
Registered: June 2011
Location: Marburg, Germany
Member
Well, that's because you initialize the arraylist you are returning with
super.getChoiceOfValues(object)
Re: Restricting attribute value choice [message #822464 is a reply to message #821700] Fri, 16 March 2012 17:00 Go to previous message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
You are right. Thanks!
Previous Topic:refreshing/repainting figures in a diagram
Next Topic:Disable tool palette when opening an editor
Goto Forum:
  


Current Time: Thu Mar 28 11:43:14 GMT 2024

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

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

Back to the top