How to limit the set of items in a property drop-down menu [message #55116] |
Mon, 25 September 2006 14:00 |
Eclipse User |
|
|
|
Originally posted by: Jochen.Becher.ovsag.de
I am developing a little Datamodel editor to learn GMF. I have EClasses
Table, Column and Relation. Of course Table aggregates Columns. A Relation
has two assoziations to Table and two assoziations to Column (the "key"
column of the a bidirectional relation). I provide a Link Mapping for
Relation between two Tables. The columns properties are selected manually
after the creation of the realtion.
I wrote some audit rules to validate that the two columns of a relation
are aggregated by the two tables. That works fine using some OCL exist()
statements.
The problem: the drop-down menu for the columns shows all columns of the
model. How may I reduce the number of displayed columns in the drop-down
menu to that columns of the linked table? I expected that should be
possible by adding some mapping / constraint for each property of a class
but that seems not to be possible with the current GMF version. Do I have
to write some custom Java code?
Regards, Jochen
|
|
|
|
Re: How to limit the set of items in a property drop-down menu [message #55226 is a reply to message #55116] |
Mon, 25 September 2006 14:35 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------010902010105090305020004
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Jochen,
Here's an example from EReferenceItemProvider where we modify the
property descriptor for EReference.eOpposite so that only features which
can validly be an opposite are shown (and so that both ends of the
opposite are set with either end is set):
/**
* This adds a property descriptor for the EOpposite feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected void addEOppositePropertyDescriptor(Object object)
{
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterF actory(),
getResourceLocator(),
getString("_UI_EReference_eOpposite_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_EReference_eOpposite_feature", "_UI_EReference_type"),
EcorePackage.eINSTANCE.getEReference_EOpposite(),
true,
false,
true,
null,
null,
null)
{
public Collection getChoiceOfValues(Object object)
{
EReference eReference = (EReference)object;
EClass eContainingClass = eReference.getEContainingClass();
EClass eReferenceType = eReference.getEReferenceType();
if (eContainingClass == null || eReferenceType == null)
{
return Collections.EMPTY_LIST;
}
Collection result = new
ArrayList(super.getChoiceOfValues(object));
for (Iterator i = result.iterator(); i.hasNext(); )
{
EReference eOpposite = (EReference)i.next();
if (eOpposite != null)
{
if (eOpposite == eReference)
{
i.remove();
}
else
{
EClass eOppositeContainingClass =
eOpposite.getEContainingClass();
EClass eOppositeReferenceType =
eOpposite.getEReferenceType();
if (eOppositeContainingClass == null ||
!eOppositeContainingClass.isSuperTypeOf(eReferenceType) ||
!eContainingClass.isSuperTypeOf(eOppositeReferenceType))
{
i.remove();
}
}
}
}
return result;
}
public void resetPropertyValue(Object object)
{
setPropertyValue(object, null);
}
public void setPropertyValue(Object object, Object value)
{
EReference eReference = (EReference)object;
EReference eOpposite = (EReference)value;
EditingDomain editingDomain = getEditingDomain(eReference);
if (editingDomain == null)
{
EReference oldReferenceOpposite =
eReference.getEOpposite();
if (oldReferenceOpposite != null)
{
oldReferenceOpposite.setEOpposite(null);
}
if (eOpposite != null)
{
EReference oldOppositeOpposite =
eOpposite.getEOpposite();
if (oldOppositeOpposite != null)
{
oldOppositeOpposite.setEOpposite(null);
}
eOpposite.setEOpposite(eReference);
}
eReference.setEOpposite(eOpposite);
}
else
{
CompoundCommand compoundCommand = new
CompoundCommand(CompoundCommand.LAST_COMMAND_ALL);
EReference oldReferenceOpposite =
eReference.getEOpposite();
if (oldReferenceOpposite != null)
{
compoundCommand.append(SetCommand.create(editingDomain,
getCommandOwner(oldReferenceOpposite), feature, null));
}
if (eOpposite != null)
{
EReference oldOppositeOpposite =
eOpposite.getEOpposite();
if (oldOppositeOpposite != null)
{
compoundCommand.append(SetCommand.create(editingDomain,
getCommandOwner(oldOppositeOpposite), feature, null));
}
compoundCommand.append(SetCommand.create(editingDomain,
getCommandOwner(eOpposite), feature, eReference));
}
compoundCommand.append(SetCommand.create(editingDomain,
getCommandOwner(eReference), feature, eOpposite));
editingDomain.getCommandStack().execute(compoundCommand);
}
}
});
}
Jochen Becher wrote:
> I am developing a little Datamodel editor to learn GMF. I have
> EClasses Table, Column and Relation. Of course Table aggregates
> Columns. A Relation has two assoziations to Table and two assoziations
> to Column (the "key" column of the a bidirectional relation). I
> provide a Link Mapping for Relation between two Tables. The columns
> properties are selected manually after the creation of the realtion.
>
> I wrote some audit rules to validate that the two columns of a
> relation are aggregated by the two tables. That works fine using some
> OCL exist() statements.
>
> The problem: the drop-down menu for the columns shows all columns of
> the model. How may I reduce the number of displayed columns in the
> drop-down menu to that columns of the linked table? I expected that
> should be possible by adding some mapping / constraint for each
> property of a class but that seems not to be possible with the current
> GMF version. Do I have to write some custom Java code?
>
> Regards, Jochen
>
--------------010902010105090305020004
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jochen,<br>
<br>
Here's an example from EReferenceItemProvider where we modify the
property descriptor for EReference.eOpposite so that only features
which can validly be an opposite are shown (and so that both ends of
the opposite are set with either end is set):<br>
<blockquote><small>
|
|
|
Powered by
FUDForum. Page generated in 0.03208 seconds