Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Limit selection of candidates for association(... might be off topic ...)
Limit selection of candidates for association [message #1244400] Wed, 12 February 2014 09:27 Go to next message
Wilbert Alberts is currently offline Wilbert Alberts
Messages: 91
Registered: June 2010
Member
Hi,

In short: are there ways to limit the selection of an element from a group of alternatives?

Suppose that I have a model that allows definition of Car configurations by adding a number of Options to a Car object. A CarConfiguration is made for a specific country (it has a Country attribute). Not all Options are allowed in each Country. Therefore, an OptionGroup has been defined that specifies which options are allowed for a certain Country.

Whenever a CarConfiguration is edited, a user has the ability to select a number of options. However, the user should only select options that are valid for the country the CarConfiguration is made for.

When editing the options attribute in a standard properties editor, a dialog is shown holding all Options present in the Model. This list could be limited by only showing the Options valid for the country the CarConfiguration is made for. Are there ways to filter the content of the list (maybe by specifying an OCL constraint)?

I know that this is a more general question (then being Sirius specific) but maybe Sirius provides additional means and on the other hand, this group is read by experts creating sophisticated editors...

For sake of completeness, the example is created using the following meta model:

package example : example = 'http://www.example.org/example'
{
	class Model
	{
		property configs : CarConfig[*] { ordered composes };
		property options : Option[*] { ordered composes };
		property optiongroups : OptionGroup[*] { ordered composes };
	}
	class CarConfig
	{
		attribute id : String;
		attribute country : Country;
		property options : Option[*] { ordered };
		
		invariant validOptions: 
			let og: OptionGroup =  self.oclContainer().oclAsType(Model).optiongroups->select(g| g.country = self.country) 
			in og->includesAll(options);
	}
	class Option
	{
		attribute id : String;
	}
	class OptionGroup
	{
		property options : Option[*] { ordered };
		attribute id : String;
		attribute country : Country;
	}
	enum Country { serializable }
	{
		literal NL;
		literal UK;
		literal GE;
	}
}


Greetings,
Wilbert
Re: Limit selection of candidates for association [message #1244441 is a reply to message #1244400] Wed, 12 February 2014 10:47 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles David
Messages: 128
Registered: July 2009
Senior Member
Le 12/02/2014 10:27, Wilbert Alberts a écrit :
> Hi,

Hi.

> In short: are there ways to limit the selection of an element from a
> group of alternatives?

This is not a Sirius-specific question (the general EMF forum would be a
better place), but I believe what you need is to provide your own
ItemPropertyDescriptor and override the getChoiceOfValues() method. The
default implementation finds all type-compatible values in the whole
ResourceSet (see ItemPropertyDescriptor.getReachableObjectsOfType()),
but you can filter that to only return the elements matching some
additional criterion.


Regards,
Pierre-Charles David
Previous Topic:Textual Editor Integration
Next Topic:String concatenation using Accelo
Goto Forum:
  


Current Time: Mon Sep 15 02:09:13 GMT 2014

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

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