Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 205432 - Support to easily provide custom cell editors
Summary: Support to easily provide custom cell editors
Status: CLOSED DUPLICATE of bug 438123
Alias: None
Product: EMF
Classification: Modeling
Component: Edit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-04 09:21 EDT by Andreas Haufler CLA
Modified: 2018-02-09 06:40 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Haufler CLA 2007-10-04 09:21:24 EDT
Currently it's really difficult to provide a custom cell editor for a property/feature. One has to subclass AdapterFactoryContentProvider, PropertySource and PropertyDescriptor and add that manually to every editor which uses the model (directly or referenced).

One way to solve the problem would be to add a createCellEditor to IItemDescriptor and make PropertyDescritptor delegate to it. However, since the edit-code shouln't be dependent on org.eclipse.ui.views and swt (createCellEditor takes Composite as parameter and returns CellEditor) the method would need to use Object as input and return values. This would make things very easy but is still quite "hacky".

Another apporach would be to simply add 2 callbacks in IItemPropertyDescriptor:

boolean hasExtendedCellEditor(Object object) and 
void runExtendedCellEditor(Object object)

So if the first method returns true, the "..." button is rendered in the cell  and runExtendedCellEditor() is invoked if the user clicks on it. This method can then open a dialog (which most of the custom editors will do anyway). This would at least have worked for me (We needed a FileSelection dialog which stores the result in a string property and a special Date+Time selector).

best regards
Andreas
Comment 1 Ed Merks CLA 2008-01-07 06:39:42 EST
I'm not really happy with either approach.  Perhaps a better approach would be to add a method like

  /**
   * Returns an object that describes the type of editor to be used.
   */
  public Object getEditorType(Object object);

And then have some type of registry where you can register an instance of some API that will be called to create the cell editor for this type of property.  If this returns null, we'd do what we always do. But if it doesn't, we'd have some something similar to the imagine (font, or color) registry to fetch a corresponding object that in turn will be used to create a cell editor. We might even have a GenFeature  property for specifying this editor type value.

This approach seems more extensible and in keeping with separating the item providers from the specifics of a particular rendering mechanism like JFace.
Comment 2 Dave Steinberg CLA 2008-01-07 17:05:39 EST
I agree with Ed's approach. It's definitely cleaner.
Comment 3 Mickael Istria CLA 2008-07-28 10:36:55 EDT
Hello,

I've been working on adding extensibility for PropertyDescriptor in JWT project (such as replace TextArea by Combo Box for a cell editor...).
I wrote a piece of code that returns a custom IPropertyDescriptor for a specified feature when an extension is present. My job was simplified by the fact that JWT already contains a "CustomAdapterFactoryContentProvider", that is an entry to get a content provider for any of our EMF objects.

You can get more details looking at bug 240499.

There are probably a lot of imperfections in that code, but it may contain some interesting things to implement such a feature in EMF.

Regards,
Mickael Istria
Comment 4 Ed Merks CLA 2018-02-09 06:40:29 EST
In https://bugs.eclipse.org/bugs/show_bug.cgi?id=438123 I've implemented a fully general solution for reusable customized cell editors.

*** This bug has been marked as a duplicate of bug 438123 ***