Easy way of Filtering in EMF List Dialogs [message #1758879] |
Tue, 04 April 2017 02:48  |
Eclipse User |
|
|
|
Hello,
Is there an recommended / easy way to filter out the elements shown in the default list dialog?
I have a List-relation in my ecore model but I do not want to see all elements from the model in the dialog when assigning the elements of that list.
(As an example you might think of showing only the classes with the same package
compared to shwoing all classes of the complete model as alternatives in the dialog).
Easy would me, some lines of code in adapting the editor, an extension point,..
|
|
|
Re: Easy way of Filtering in EMF List Dialogs [message #1758887 is a reply to message #1758879] |
Tue, 04 April 2017 03:46   |
Eclipse User |
|
|
|
Here's an example from org.eclipse.emf.ecore.provider.EReferenceItemProvider.addEKeysPropertyDescriptor(Object) /**
* This adds a property descriptor for the Keys feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected void addEKeysPropertyDescriptor(Object object)
{
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_EReference_eKeys_feature"),
getString("_UI_EReference_eKeys_description"),
EcorePackage.Literals.EREFERENCE__EKEYS,
true,
false,
false,
null,
null,
null)
{
@Override
public Collection<?> getChoiceOfValues(Object object)
{
EReference eReference = (EReference)object;
List<Object> result = new ArrayList<Object>();
if (eReference.getEType() instanceof EClass)
{
result.addAll(eReference.getEReferenceType().getEAllAttributes());
}
return result;
}
});
} So the idea is just to specialize the item property descriptor's getChoiceOfValues method to return only the choices you want. You might call supergetChoiceOfValues and filter it down to what you want, or, as in this case, gather the choices in some other way.
|
|
|
|
Powered by
FUDForum. Page generated in 0.27287 seconds