Skip to main content



      Home
Home » Modeling » EMF » Easy way of Filtering in EMF List Dialogs(EMF Default List Value Editors)
Easy way of Filtering in EMF List Dialogs [message #1758879] Tue, 04 April 2017 02:48 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Easy way of Filtering in EMF List Dialogs [message #1759017 is a reply to message #1758887] Wed, 05 April 2017 05:28 Go to previous message
Eclipse UserFriend
Ed, thank you very much this fast and perfect answer!
That was exactly what I was looking for.
So I added your proposed method (modified for my model) into the generated ItemProviders.
Also using super.getChoiceOfValues (object) was helpful.
Previous Topic:custom labels
Next Topic:is there a way to ignore an EPackage during the java code generation ?
Goto Forum:
  


Current Time: Wed Jul 23 11:12:37 EDT 2025

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

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

Back to the top