This is a blog of Eclipse enthusiasts from Poznań (Poland) who would like to share their knowledge of Eclipse. We work for the IBM Support Center for Eclipse at Poznań University of Technology.

Tuesday, October 2, 2007

Custom Property Source for EMF generated RCP application

Have you ever tried to generate your application using EMF? If yes, you have probably noticed, that EMF puts standard editors for properties. For testing purposes this is enough, but for commercial application... well... answer yourself.

In this post I will show you how to generate simple date editor for the EMF application.Here is the model:

As you see, it is not very complicated. If we generate RCP appliaction we will receive something like that:

and additional three plugins in your workspace (.edit, .editor, and .tests).

So we start to work.

In the pluging .editor we open our application Editor, and then, in the method getPropertySheetPage() we replace the

We do not have CustomizedPropertySource yet, so we create one, and overridecreatePropertyDescriptor() method:protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { return new CustomizedPropertyDescriptor(object, itemPropertyDescriptor);}

In this method we provide date property editor, but also we have to check, if the property is editable and if it is really a date, because our method will take care about all properties. So, if this is not a date, we pass everything to the super implementation.

And voila :) Here it is:

So, to sum up: you modify your editor to use subclassed AdapterFactoryContentProvider that will return subclassed PropertySource that will return subclassed PropertyDescriptor that will create your desired cell editor.