Skip to main content



      Home
Home » Modeling » EMF » Custom editor help needed on adapter factories and item providers
Custom editor help needed on adapter factories and item providers [message #390339] Tue, 04 January 2005 12:19 Go to next message
Eclipse UserFriend
I'm working on a custom editor and need some help with adapter
factories and item providers. My data model is simply a map of key,
value pairs where value is of type java.lang.Object. The editor will
not use JFace, so I'm a bit lost on how to work with the adapter
factories and item providers.

The details ...

Assume the model contains a single entry in the map, and the value is a
String. Now assume my custom editor has two
org.eclipse.swt.widgets.Text widgets for editing the value. When the
user changes the value in one widget, the model needs to be updated,
and the second Text widget somehow needs to listen to the model so that
the display can be updated.

The simplistic approach would be to create a helper class that
registers itself as a change listener on the Text widget so that it can
set the value in the model whenever the user types in a new value. The
helper class could also register as a notify listener on the data model
to populate the Text widget. This approach does not allow for undo and
redo, so I'd like to use emf edit.

The helper class could create a SetCommand instead of directly setting
the value, and still listen directly to the model. This would mean
that I would not use an item provider. Remember that the value is type
Object (the helper class would cast it to String for a Text widget, a
Boolean for a Checkbox widget, etc). Is this a good way to go?

If I'm not using any item providers, how do I set up the adapter
factory for the editing domain? Could I simply use the default factory
generated in the edit plugin?

I'm starting to wonder if this helper class is basically a custom item
provider ... any thoughts?


Bryan
Re: Custom editor help needed on adapter factories and item providers [message #390347 is a reply to message #390339] Tue, 04 January 2005 17:19 Go to previous messageGo to next message
Eclipse UserFriend
On 2005-01-04 11:19:10 -0600, Bryan Hunt <bhunt@mac.com> said:

>
> The helper class could create a SetCommand instead of directly setting
> the value, and still listen directly to the model. This would mean
> that I would not use an item provider. Remember that the value is type
> Object (the helper class would cast it to String for a Text widget, a
> Boolean for a Checkbox widget, etc). Is this a good way to go?
>
> If I'm not using any item providers, how do I set up the adapter
> factory for the editing domain? Could I simply use the default factory
> generated in the edit plugin?
>

After looking at this all day, I'm starting to think that I'm going to
try to create my helper class and use a BasicCommandStack without an
editing domain. If anyone knows a reason why this won't work, please
let me know.

Bryan
Re: Custom editor help needed on adapter factories and item providers [message #390368 is a reply to message #390347] Wed, 05 January 2005 14:36 Go to previous message
Eclipse UserFriend
Bryan Hunt wrote:
> On 2005-01-04 11:19:10 -0600, Bryan Hunt <bhunt@mac.com> said:
> After looking at this all day, I'm starting to think that I'm going to
> try to create my helper class and use a BasicCommandStack without an
> editing domain. If anyone knows a reason why this won't work, please
> let me know.

Hi Bryan,

Have you read chapter 3 of the EMF book? Page 58 lists the three main
functions of an editing domain:

1. Creating commands, optionally deducing some of their arguments.
2. Managing the command undo stack.
3. Providing access to the EMF resources being used.

The command creation function is done via an adapter factory and the
item providers, which gives a nice override point for owner-type-based
tweaking of commands as they're created.

But, using the generated item providers also pulls other functions into
the same place: they can also act as label providers, content providers,
property source providers, and change notification forwarders.

If you don't need all of this, it might very well be worth taking a
simpler approach to creating commands, as you suggested. You certainly
don't need an adapter factory or item providers to execute commands on a
command stack.

Cheers,
Dave
Previous Topic:Re: EMF-Editor Plugin generates invalid XML-(instance)-documents
Next Topic:Extending the SDO API
Goto Forum:
  


Current Time: Thu Sep 25 16:28:16 EDT 2025

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

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

Back to the top