Home » Modeling » EMF » EMF databinding + undo/redo
EMF databinding + undo/redo [message #426739] |
Mon, 19 January 2009 21:40 |
Kai Schlamp Messages: 344 Registered: July 2009 |
Senior Member |
|
|
Hello.
Inspired by the Blog entry "Eclipse Databinding + Validation +
Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
all my views and dialogs of my RCP application, as I already use EMF for
my models cause of the CDO support.
But let's assume a dialog with an "Ok" and "Cancel" button. When the
user presses the "Cancel" button all modifications to the model have to
be undone.
So I looked further how to solve this problem an came over the EMF Edit
framework and especially the "Datacentric RCP Applications" presentation
by Tom Schindl.
( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
This also has the advantage of full undo/redo support that I like to
have in one of my views.
But even after reading this and looking through many newsgroup messages,
there are still many questions open.
Tom has the following code in his presentation:
Text widget = new Text(parent,SWT.BORDER)
IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
Person p = getPersons();
EditingDomain domain = getEditingDomain();
EStructuralFeature feature = MyPackage.Literals.SURNAME;
IObservableValue mObs = EMFEditObservables.observeValue(domain,p,feature);
EMFDatabindingContext dbc = new EMFDataBindingContext();
dbc.bind(uiObs,mObs,null,null);
But where does the EditingDomain come from?
Do I have to create it myself like on Tom's "Setting up an EditingDomain
by hand" slide?:
ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
ComposedAdapterFactory af = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
BasicCommandStack cs = new BasicCommandStack();
AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af, cs,
set);
Resource res = resourceSet.getResource(....);
And how do I undo all changes from a specific point?
For example ... I pass a "Person" eObject to a dialog that edits the
already set "age" and "name" attributes.
How do I undo all the changes that where done by that dialog when the
user presses "Cancel"?
Get the CommandStack und use undo() method as long as it canUndo()? So
do I have to create a new CommandStack for every Dialog (I think so)? By
creating a new EditingDomain for every dialog, right?
And when I use this Edit Framework, do I have to "Generate Edit Code" of
my GenModel. And if yes, where do I have to use those generated providers?
I hope that someone can enlighten me a bit ... this undo/redo task seems
to be quite complex to me.
Kai
|
|
|
Re: EMF databinding + undo/redo [message #426742 is a reply to message #426739] |
Mon, 19 January 2009 21:59 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi Kai,
Kai Schlamp schrieb:
> Hello.
>
> Inspired by the Blog entry "Eclipse Databinding + Validation +
> Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
> all my views and dialogs of my RCP application, as I already use EMF for
> my models cause of the CDO support.
> But let's assume a dialog with an "Ok" and "Cancel" button. When the
> user presses the "Cancel" button all modifications to the model have to
> be undone.
> So I looked further how to solve this problem an came over the EMF Edit
> framework and especially the "Datacentric RCP Applications" presentation
> by Tom Schindl.
> ( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
> This also has the advantage of full undo/redo support that I like to
> have in one of my views.
> But even after reading this and looking through many newsgroup messages,
> there are still many questions open.
>
> Tom has the following code in his presentation:
>
> Text widget = new Text(parent,SWT.BORDER)
> IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
> Person p = getPersons();
> EditingDomain domain = getEditingDomain();
> EStructuralFeature feature = MyPackage.Literals.SURNAME;
> IObservableValue mObs = EMFEditObservables.observeValue(domain,p,feature);
> EMFDatabindingContext dbc = new EMFDataBindingContext();
> dbc.bind(uiObs,mObs,null,null);
>
> But where does the EditingDomain come from?
If you browse my example code you'll see that you'll have to create it
your own [2] :-)
>
> Do I have to create it myself like on Tom's "Setting up an EditingDomain
> by hand" slide?:
>
> ResourceSet set = new ResourceSetImpl();
> set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
> ComposedAdapterFactory af = new ComposedAdapterFactory(
> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
> BasicCommandStack cs = new BasicCommandStack();
> AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af, cs,
> set);
> Resource res = resourceSet.getResource(....);
>
> And how do I undo all changes from a specific point?
Well undo/redo is done with the CommandStack. Take a look at my example
code (referenced from the slides [1]) [3] it does exactly what you want.
Opening a dialog and undo all changes if cancel is pressed.
Another possibility is to use IPolicy.ON_REQUEST for your bindings so
and only update your model on press of OK.
> For example ... I pass a "Person" eObject to a dialog that edits the
> already set "age" and "name" attributes.
> How do I undo all the changes that where done by that dialog when the
> user presses "Cancel"?
> Get the CommandStack und use undo() method as long as it canUndo()? So
> do I have to create a new CommandStack for every Dialog (I think so)? By
> creating a new EditingDomain for every dialog, right?
Yes see above but not necessarily until you canUndo doesn't return any
more because if your model was already dirty before you'll undo too many
things :-) I already thought about wrapping this and providing a command
stack which allows to set an SQL-Like Savepoint where you can rollback to.
> And when I use this Edit Framework, do I have to "Generate Edit Code" of
> my GenModel. And if yes, where do I have to use those generated providers?
> I hope that someone can enlighten me a bit ... this undo/redo task seems
> to be quite complex to me.
>
I'm not using any generated editing code in my example but all is coded
by hand.
> Kai
Tom
[1] https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48
[2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/
[3] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.playeradmin/src/at/bestso lution/soccer/ui/playeradmin/command/EditPlayerCommandHandle r.java
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Re: EMF databinding + undo/redo [message #426744 is a reply to message #426742] |
Mon, 19 January 2009 22:03 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
By the way its quite likely that my UFaceKit-Project [1] will provide
such an undo/redo feature for EMF-Based-Model-Objects without the need
to understand how all this works internally but wrapped in a very
simplistic API :-)
Tom
[1]http://wiki.eclipse.org/UFaceKit
Tom Schindl schrieb:
> Hi Kai,
>
> Kai Schlamp schrieb:
>> Hello.
>>
>> Inspired by the Blog entry "Eclipse Databinding + Validation +
>> Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
>> all my views and dialogs of my RCP application, as I already use EMF for
>> my models cause of the CDO support.
>> But let's assume a dialog with an "Ok" and "Cancel" button. When the
>> user presses the "Cancel" button all modifications to the model have to
>> be undone.
>> So I looked further how to solve this problem an came over the EMF Edit
>> framework and especially the "Datacentric RCP Applications" presentation
>> by Tom Schindl.
>> ( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
>> This also has the advantage of full undo/redo support that I like to
>> have in one of my views.
>> But even after reading this and looking through many newsgroup messages,
>> there are still many questions open.
>>
>> Tom has the following code in his presentation:
>>
>> Text widget = new Text(parent,SWT.BORDER)
>> IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
>> Person p = getPersons();
>> EditingDomain domain = getEditingDomain();
>> EStructuralFeature feature = MyPackage.Literals.SURNAME;
>> IObservableValue mObs = EMFEditObservables.observeValue(domain,p,feature);
>> EMFDatabindingContext dbc = new EMFDataBindingContext();
>> dbc.bind(uiObs,mObs,null,null);
>>
>> But where does the EditingDomain come from?
>
> If you browse my example code you'll see that you'll have to create it
> your own [2] :-)
>
>> Do I have to create it myself like on Tom's "Setting up an EditingDomain
>> by hand" slide?:
>>
>> ResourceSet set = new ResourceSetImpl();
>> set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
>> ComposedAdapterFactory af = new ComposedAdapterFactory(
>> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>> BasicCommandStack cs = new BasicCommandStack();
>> AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af, cs,
>> set);
>> Resource res = resourceSet.getResource(....);
>>
>> And how do I undo all changes from a specific point?
>
> Well undo/redo is done with the CommandStack. Take a look at my example
> code (referenced from the slides [1]) [3] it does exactly what you want.
> Opening a dialog and undo all changes if cancel is pressed.
>
> Another possibility is to use IPolicy.ON_REQUEST for your bindings so
> and only update your model on press of OK.
>
>> For example ... I pass a "Person" eObject to a dialog that edits the
>> already set "age" and "name" attributes.
>> How do I undo all the changes that where done by that dialog when the
>> user presses "Cancel"?
>> Get the CommandStack und use undo() method as long as it canUndo()? So
>> do I have to create a new CommandStack for every Dialog (I think so)? By
>> creating a new EditingDomain for every dialog, right?
>
> Yes see above but not necessarily until you canUndo doesn't return any
> more because if your model was already dirty before you'll undo too many
> things :-) I already thought about wrapping this and providing a command
> stack which allows to set an SQL-Like Savepoint where you can rollback to.
>
>> And when I use this Edit Framework, do I have to "Generate Edit Code" of
>> my GenModel. And if yes, where do I have to use those generated providers?
>> I hope that someone can enlighten me a bit ... this undo/redo task seems
>> to be quite complex to me.
>>
>
> I'm not using any generated editing code in my example but all is coded
> by hand.
>
>> Kai
>
> Tom
>
> [1] https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48
> [2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/
> [3] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.playeradmin/src/at/bestso lution/soccer/ui/playeradmin/command/EditPlayerCommandHandle r.java
>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Re: EMF databinding + undo/redo [message #426787 is a reply to message #426742] |
Tue, 20 January 2009 15:33 |
Kai Schlamp Messages: 344 Registered: July 2009 |
Senior Member |
|
|
Thanks for all those explanations, Tom. I think for my dialogs I stick
to the ON_REQUEST or better CONVERT policy (as I can still validate the
input then) of the databinding framework, and only use the undo/redo
functionality for the view that really needs this.
I just looked at the source code of your application, as I wanted to
find out what the best place is to create the EditingDomain.
In your code it seems to happen in the initializeEditingDomain() method
of the PersistanceServicesRegistry class.
ComposedAdapterFactory adapterFactory = new
ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
// adapterFactory.addAdapterFactory(new
SoccerItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new
ReflectiveItemProviderAdapterFactory());
The last three lines (.*addAdapterFactory.*) are not mentioned in your
presentation. Are those required? Why did you comment the second line
(the one with SoccerItemProviderAdapterFactory) out?
Kai
Tom Schindl schrieb:
> Hi Kai,
>
> Kai Schlamp schrieb:
>> Hello.
>>
>> Inspired by the Blog entry "Eclipse Databinding + Validation +
>> Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
>> all my views and dialogs of my RCP application, as I already use EMF for
>> my models cause of the CDO support.
>> But let's assume a dialog with an "Ok" and "Cancel" button. When the
>> user presses the "Cancel" button all modifications to the model have to
>> be undone.
>> So I looked further how to solve this problem an came over the EMF Edit
>> framework and especially the "Datacentric RCP Applications" presentation
>> by Tom Schindl.
>> ( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
>> This also has the advantage of full undo/redo support that I like to
>> have in one of my views.
>> But even after reading this and looking through many newsgroup messages,
>> there are still many questions open.
>>
>> Tom has the following code in his presentation:
>>
>> Text widget = new Text(parent,SWT.BORDER)
>> IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
>> Person p = getPersons();
>> EditingDomain domain = getEditingDomain();
>> EStructuralFeature feature = MyPackage.Literals.SURNAME;
>> IObservableValue mObs = EMFEditObservables.observeValue(domain,p,feature);
>> EMFDatabindingContext dbc = new EMFDataBindingContext();
>> dbc.bind(uiObs,mObs,null,null);
>>
>> But where does the EditingDomain come from?
>
> If you browse my example code you'll see that you'll have to create it
> your own [2] :-)
>
>> Do I have to create it myself like on Tom's "Setting up an EditingDomain
>> by hand" slide?:
>>
>> ResourceSet set = new ResourceSetImpl();
>> set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
>> ComposedAdapterFactory af = new ComposedAdapterFactory(
>> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>> BasicCommandStack cs = new BasicCommandStack();
>> AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af, cs,
>> set);
>> Resource res = resourceSet.getResource(....);
>>
>> And how do I undo all changes from a specific point?
>
> Well undo/redo is done with the CommandStack. Take a look at my example
> code (referenced from the slides [1]) [3] it does exactly what you want.
> Opening a dialog and undo all changes if cancel is pressed.
>
> Another possibility is to use IPolicy.ON_REQUEST for your bindings so
> and only update your model on press of OK.
>
>> For example ... I pass a "Person" eObject to a dialog that edits the
>> already set "age" and "name" attributes.
>> How do I undo all the changes that where done by that dialog when the
>> user presses "Cancel"?
>> Get the CommandStack und use undo() method as long as it canUndo()? So
>> do I have to create a new CommandStack for every Dialog (I think so)? By
>> creating a new EditingDomain for every dialog, right?
>
> Yes see above but not necessarily until you canUndo doesn't return any
> more because if your model was already dirty before you'll undo too many
> things :-) I already thought about wrapping this and providing a command
> stack which allows to set an SQL-Like Savepoint where you can rollback to.
>
>> And when I use this Edit Framework, do I have to "Generate Edit Code" of
>> my GenModel. And if yes, where do I have to use those generated providers?
>> I hope that someone can enlighten me a bit ... this undo/redo task seems
>> to be quite complex to me.
>>
>
> I'm not using any generated editing code in my example but all is coded
> by hand.
>
>> Kai
>
> Tom
>
> [1] https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48
> [2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/
> [3] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.playeradmin/src/at/bestso lution/soccer/ui/playeradmin/command/EditPlayerCommandHandle r.java
>
>
|
|
| | | | | | | |
Re: EMF databinding + undo/redo [message #426800 is a reply to message #426744] |
Wed, 21 January 2009 00:11 |
Andrew H Messages: 117 Registered: July 2009 |
Senior Member |
|
|
FWIW this could be quite interesting for us. We are reworking our system
around EMF based domain models. We have a large Swing GUI that we will
evolve over time, not replace so anything that makes the Swing / EMF
integration easier will be very attractive for us.
Tom Schindl wrote:
> By the way its quite likely that my UFaceKit-Project [1] will provide
> such an undo/redo feature for EMF-Based-Model-Objects without the need
> to understand how all this works internally but wrapped in a very
> simplistic API :-)
> Tom
> [1]http://wiki.eclipse.org/UFaceKit
> Tom Schindl schrieb:
>> Hi Kai,
>>
>> Kai Schlamp schrieb:
>>> Hello.
>>>
>>> Inspired by the Blog entry "Eclipse Databinding + Validation +
>>> Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
>>> all my views and dialogs of my RCP application, as I already use EMF for
>>> my models cause of the CDO support.
>>> But let's assume a dialog with an "Ok" and "Cancel" button. When the
>>> user presses the "Cancel" button all modifications to the model have to
>>> be undone.
>>> So I looked further how to solve this problem an came over the EMF Edit
>>> framework and especially the "Datacentric RCP Applications" presentation
>>> by Tom Schindl.
>>>
( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
>>> This also has the advantage of full undo/redo support that I like to
>>> have in one of my views.
>>> But even after reading this and looking through many newsgroup messages,
>>> there are still many questions open.
>>>
>>> Tom has the following code in his presentation:
>>>
>>> Text widget = new Text(parent,SWT.BORDER)
>>> IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
>>> Person p = getPersons();
>>> EditingDomain domain = getEditingDomain();
>>> EStructuralFeature feature = MyPackage.Literals.SURNAME;
>>> IObservableValue mObs = EMFEditObservables.observeValue(domain,p,feature);
>>> EMFDatabindingContext dbc = new EMFDataBindingContext();
>>> dbc.bind(uiObs,mObs,null,null);
>>>
>>> But where does the EditingDomain come from?
>>
>> If you browse my example code you'll see that you'll have to create it
>> your own [2] :-)
>>
>>> Do I have to create it myself like on Tom's "Setting up an EditingDomain
>>> by hand" slide?:
>>>
>>> ResourceSet set = new ResourceSetImpl();
>>> set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
>>> ComposedAdapterFactory af = new ComposedAdapterFactory(
>>> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>>> BasicCommandStack cs = new BasicCommandStack();
>>> AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af, cs,
>>> set);
>>> Resource res = resourceSet.getResource(....);
>>>
>>> And how do I undo all changes from a specific point?
>>
>> Well undo/redo is done with the CommandStack. Take a look at my example
>> code (referenced from the slides [1]) [3] it does exactly what you want.
>> Opening a dialog and undo all changes if cancel is pressed.
>>
>> Another possibility is to use IPolicy.ON_REQUEST for your bindings so
>> and only update your model on press of OK.
>>
>>> For example ... I pass a "Person" eObject to a dialog that edits the
>>> already set "age" and "name" attributes.
>>> How do I undo all the changes that where done by that dialog when the
>>> user presses "Cancel"?
>>> Get the CommandStack und use undo() method as long as it canUndo()? So
>>> do I have to create a new CommandStack for every Dialog (I think so)? By
>>> creating a new EditingDomain for every dialog, right?
>>
>> Yes see above but not necessarily until you canUndo doesn't return any
>> more because if your model was already dirty before you'll undo too many
>> things :-) I already thought about wrapping this and providing a command
>> stack which allows to set an SQL-Like Savepoint where you can rollback to.
>>
>>> And when I use this Edit Framework, do I have to "Generate Edit Code" of
>>> my GenModel. And if yes, where do I have to use those generated providers?
>>> I hope that someone can enlighten me a bit ... this undo/redo task seems
>>> to be quite complex to me.
>>>
>>
>> I'm not using any generated editing code in my example but all is coded
>> by hand.
>>
>>> Kai
>>
>> Tom
>>
>>
[1] https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48
>> [2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/
>>
[3] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.playeradmin/src/at/bestso lution/soccer/ui/playeradmin/command/EditPlayerCommandHandle r.java
>>
>>
|
|
|
Re: EMF databinding + undo/redo [message #426801 is a reply to message #426800] |
Wed, 21 January 2009 00:32 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi Andrew,
The first thing you can already use from UFaceKit are the
SwingObservables [1] we provide. So you could write native Swing-UI and
use EMF-Databinding and the SwingObservables to bind Model and UI just
like you do it nowadays with SWT/JFace and EMF.
If you have in depth knowledge about Swing I'd be happy to get your
comments because none of us (the UFaceKit-Team) is Swing-Guru.
Tom
[1] http://dev.eclipse.org/svnroot/eclipse/org.eclipse.ufacekit/ bundles/proper/org.eclipse.ufacekit/org.eclipse.ufacekit.ui. swing/org.eclipse.ufacekit.ui.swing.databinding/
Andrew H schrieb:
> FWIW this could be quite interesting for us. We are reworking our system
> around EMF based domain models. We have a large Swing GUI that we will
> evolve over time, not replace so anything that makes the Swing / EMF
> integration easier will be very attractive for us.
>
> Tom Schindl wrote:
>
>> By the way its quite likely that my UFaceKit-Project [1] will provide
>> such an undo/redo feature for EMF-Based-Model-Objects without the need
>> to understand how all this works internally but wrapped in a very
>> simplistic API :-)
>
>> Tom
>
>> [1]http://wiki.eclipse.org/UFaceKit
>
>> Tom Schindl schrieb:
>>> Hi Kai,
>>>
>>> Kai Schlamp schrieb:
>>>> Hello.
>>>>
>>>> Inspired by the Blog entry "Eclipse Databinding + Validation +
>>>> Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
>>>> all my views and dialogs of my RCP application, as I already use EMF
>>>> for
>>>> my models cause of the CDO support.
>>>> But let's assume a dialog with an "Ok" and "Cancel" button. When the
>>>> user presses the "Cancel" button all modifications to the model have to
>>>> be undone.
>>>> So I looked further how to solve this problem an came over the EMF Edit
>>>> framework and especially the "Datacentric RCP Applications"
>>>> presentation
>>>> by Tom Schindl.
>>>>
> ( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
>
>>>> This also has the advantage of full undo/redo support that I like to
>>>> have in one of my views.
>>>> But even after reading this and looking through many newsgroup
>>>> messages,
>>>> there are still many questions open.
>>>>
>>>> Tom has the following code in his presentation:
>>>>
>>>> Text widget = new Text(parent,SWT.BORDER)
>>>> IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
>>>> Person p = getPersons();
>>>> EditingDomain domain = getEditingDomain();
>>>> EStructuralFeature feature = MyPackage.Literals.SURNAME;
>>>> IObservableValue mObs =
>>>> EMFEditObservables.observeValue(domain,p,feature);
>>>> EMFDatabindingContext dbc = new EMFDataBindingContext();
>>>> dbc.bind(uiObs,mObs,null,null);
>>>>
>>>> But where does the EditingDomain come from?
>>>
>>> If you browse my example code you'll see that you'll have to create it
>>> your own [2] :-)
>>>
>>>> Do I have to create it myself like on Tom's "Setting up an
>>>> EditingDomain
>>>> by hand" slide?:
>>>>
>>>> ResourceSet set = new ResourceSetImpl();
>>>> set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
>>>> ComposedAdapterFactory af = new ComposedAdapterFactory(
>>>> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>>>> BasicCommandStack cs = new BasicCommandStack();
>>>> AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af,
>>>> cs,
>>>> set);
>>>> Resource res = resourceSet.getResource(....);
>>>>
>>>> And how do I undo all changes from a specific point?
>>>
>>> Well undo/redo is done with the CommandStack. Take a look at my example
>>> code (referenced from the slides [1]) [3] it does exactly what you want.
>>> Opening a dialog and undo all changes if cancel is pressed.
>>>
>>> Another possibility is to use IPolicy.ON_REQUEST for your bindings so
>>> and only update your model on press of OK.
>>>
>>>> For example ... I pass a "Person" eObject to a dialog that edits the
>>>> already set "age" and "name" attributes.
>>>> How do I undo all the changes that where done by that dialog when the
>>>> user presses "Cancel"?
>>>> Get the CommandStack und use undo() method as long as it canUndo()? So
>>>> do I have to create a new CommandStack for every Dialog (I think
>>>> so)? By
>>>> creating a new EditingDomain for every dialog, right?
>>>
>>> Yes see above but not necessarily until you canUndo doesn't return any
>>> more because if your model was already dirty before you'll undo too many
>>> things :-) I already thought about wrapping this and providing a command
>>> stack which allows to set an SQL-Like Savepoint where you can
>>> rollback to.
>>>
>>>> And when I use this Edit Framework, do I have to "Generate Edit
>>>> Code" of
>>>> my GenModel. And if yes, where do I have to use those generated
>>>> providers?
>>>> I hope that someone can enlighten me a bit ... this undo/redo task
>>>> seems
>>>> to be quite complex to me.
>>>>
>>>
>>> I'm not using any generated editing code in my example but all is coded
>>> by hand.
>>>
>>>> Kai
>>>
>>> Tom
>>>
>>>
> [1] https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48
>
>>> [2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/
>>>
> [3] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.playeradmin/src/at/bestso lution/soccer/ui/playeradmin/command/EditPlayerCommandHandle r.java
>
>>>
>>>
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
| | | | |
Re: EMF databinding + undo/redo [message #426826 is a reply to message #426801] |
Wed, 21 January 2009 23:55 |
Andrew H Messages: 117 Registered: July 2009 |
Senior Member |
|
|
Hi Tom
Unfortunately, I have the opposite problem as I have no idea about
SWT/JFace. I do have a fair bit of Swing experience but its pretty rusty
now. A colleague here has much more current experience if you have any
particular questions.
I had a quick look at the code from the link. It looks like you create
Observables from Swing widgets which I presume are then used to integrate
in with EMF models somehow?
When I initially evaluated EMF I had it in the back of my mind that the UI
models generated by EMF (i.e. EMF.edit) looked fairly generic and not
terribly SWT centric. So I had thought it should be possible to write
custom implementations of the Swing models that wrap these somehow. I
didn't look into it further.
Custom model implementations tends to be how I have gone about adapting
other model frameworks into Swing in the past. These days there are a
bunch of binding api's for Swing so that would likely be the way I would
go now.
Our GUI rework is probably a few months off so I will check in with you
then on the status of the UFaceKit work. In the meantime, I'm happy to
provide input if that helps.
cheers
Andrew
Tom Schindl wrote:
> Hi Andrew,
> The first thing you can already use from UFaceKit are the
> SwingObservables [1] we provide. So you could write native Swing-UI and
> use EMF-Databinding and the SwingObservables to bind Model and UI just
> like you do it nowadays with SWT/JFace and EMF.
> If you have in depth knowledge about Swing I'd be happy to get your
> comments because none of us (the UFaceKit-Team) is Swing-Guru.
> Tom
>
[1] http://dev.eclipse.org/svnroot/eclipse/org.eclipse.ufacekit/ bundles/proper/org.eclipse.ufacekit/org.eclipse.ufacekit.ui. swing/org.eclipse.ufacekit.ui.swing.databinding/
> Andrew H schrieb:
>> FWIW this could be quite interesting for us. We are reworking our system
>> around EMF based domain models. We have a large Swing GUI that we will
>> evolve over time, not replace so anything that makes the Swing / EMF
>> integration easier will be very attractive for us.
>>
>> Tom Schindl wrote:
>>
>>> By the way its quite likely that my UFaceKit-Project [1] will provide
>>> such an undo/redo feature for EMF-Based-Model-Objects without the need
>>> to understand how all this works internally but wrapped in a very
>>> simplistic API :-)
>>
>>> Tom
>>
>>> [1]http://wiki.eclipse.org/UFaceKit
>>
>>> Tom Schindl schrieb:
>>>> Hi Kai,
>>>>
>>>> Kai Schlamp schrieb:
>>>>> Hello.
>>>>>
>>>>> Inspired by the Blog entry "Eclipse Databinding + Validation +
>>>>> Decoration" (http://toedter.com/blog/?p=36), I wanted to have this for
>>>>> all my views and dialogs of my RCP application, as I already use EMF
>>>>> for
>>>>> my models cause of the CDO support.
>>>>> But let's assume a dialog with an "Ok" and "Cancel" button. When the
>>>>> user presses the "Cancel" button all modifications to the model have to
>>>>> be undone.
>>>>> So I looked further how to solve this problem an came over the EMF Edit
>>>>> framework and especially the "Datacentric RCP Applications"
>>>>> presentation
>>>>> by Tom Schindl.
>>>>>
>>
( https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48).
>>
>>>>> This also has the advantage of full undo/redo support that I like to
>>>>> have in one of my views.
>>>>> But even after reading this and looking through many newsgroup
>>>>> messages,
>>>>> there are still many questions open.
>>>>>
>>>>> Tom has the following code in his presentation:
>>>>>
>>>>> Text widget = new Text(parent,SWT.BORDER)
>>>>> IObservableValue uiObs = SWTObservables.observeText(widget,SWT.Modify);
>>>>> Person p = getPersons();
>>>>> EditingDomain domain = getEditingDomain();
>>>>> EStructuralFeature feature = MyPackage.Literals.SURNAME;
>>>>> IObservableValue mObs =
>>>>> EMFEditObservables.observeValue(domain,p,feature);
>>>>> EMFDatabindingContext dbc = new EMFDataBindingContext();
>>>>> dbc.bind(uiObs,mObs,null,null);
>>>>>
>>>>> But where does the EditingDomain come from?
>>>>
>>>> If you browse my example code you'll see that you'll have to create it
>>>> your own [2] :-)
>>>>
>>>>> Do I have to create it myself like on Tom's "Setting up an
>>>>> EditingDomain
>>>>> by hand" slide?:
>>>>>
>>>>> ResourceSet set = new ResourceSetImpl();
>>>>> set.getPackageRegistry().put(MyPackage.eNS_URI,MyPackage.eIN STANCE);
>>>>> ComposedAdapterFactory af = new ComposedAdapterFactory(
>>>>> ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>>>>> BasicCommandStack cs = new BasicCommandStack();
>>>>> AdapterFactoryEditingDomain ed = new AdapterFactoryEditingDomain(af,
>>>>> cs,
>>>>> set);
>>>>> Resource res = resourceSet.getResource(....);
>>>>>
>>>>> And how do I undo all changes from a specific point?
>>>>
>>>> Well undo/redo is done with the CommandStack. Take a look at my example
>>>> code (referenced from the slides [1]) [3] it does exactly what you want.
>>>> Opening a dialog and undo all changes if cancel is pressed.
>>>>
>>>> Another possibility is to use IPolicy.ON_REQUEST for your bindings so
>>>> and only update your model on press of OK.
>>>>
>>>>> For example ... I pass a "Person" eObject to a dialog that edits the
>>>>> already set "age" and "name" attributes.
>>>>> How do I undo all the changes that where done by that dialog when the
>>>>> user presses "Cancel"?
>>>>> Get the CommandStack und use undo() method as long as it canUndo()? So
>>>>> do I have to create a new CommandStack for every Dialog (I think
>>>>> so)? By
>>>>> creating a new EditingDomain for every dialog, right?
>>>>
>>>> Yes see above but not necessarily until you canUndo doesn't return any
>>>> more because if your model was already dirty before you'll undo too many
>>>> things :-) I already thought about wrapping this and providing a command
>>>> stack which allows to set an SQL-Like Savepoint where you can
>>>> rollback to.
>>>>
>>>>> And when I use this Edit Framework, do I have to "Generate Edit
>>>>> Code" of
>>>>> my GenModel. And if yes, where do I have to use those generated
>>>>> providers?
>>>>> I hope that someone can enlighten me a bit ... this undo/redo task
>>>>> seems
>>>>> to be quite complex to me.
>>>>>
>>>>
>>>> I'm not using any generated editing code in my example but all is coded
>>>> by hand.
>>>>
>>>>> Kai
>>>>
>>>> Tom
>>>>
>>>>
>>
[1] https://www.gpublication.com/eclipse/#requestedContent=conte ntID://EclipseConferences/ESE2008/48
>>
>>>> [2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/
>>>>
>>
[3] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.playeradmin/src/at/bestso lution/soccer/ui/playeradmin/command/EditPlayerCommandHandle r.java
>>
>>>>
>>>>
>>
|
|
| | |
Re: EMF databinding + undo/redo [message #426868 is a reply to message #426806] |
Thu, 22 January 2009 20:32 |
|
Sebastian, Tom,
Comments inline...
Sebastian Paul schrieb:
> Tom Schindl wrote:
>> Take the following example:
>>
>> View A:
>> - Administration of a List of Countries
>>
>> View B:
>> - Person-Form which let you select from a list of countries.
>>
>> Now let's try the following:
>>
>> - Open View A
>> - Add a new country (Austria)
>> - Open View B
>> - Create a new person
>> - Select the country (Austria)
>> - Open View A
>> - Undo the addition of countries
>> - Open View B
>> - Save (big crash :-)
>>
>> So how can we solve this? Well this is something that just came to my
>> mind. Couldn't we use CDO for this?
>
> Hi, stupid question: Can CDO be used for more than "distributed shared
> EMF models and a fast server-based O/R mapping"? I've been always
> ignoring the CDO stuff, as I thought I won't need.
That was obviously not a wise decision :P
> I assume from your statement that CDO can do much more for me...
I think CDO can already do something here and it's still my dream that
somebody starts work on a file system or workspace based CDO repository
implementation that brings all (or at least many of) the transactional
features of CDO to the otherwise undistributed XML clients. Model
distribution would even be optionally included then. I'm waiting here to
offer my assistence ;-)
In your case it seems as if you would only need a single CDOSession and
then open multiple CDOTransactions on it. In this case you'd even get
transparent data sharing between the same objects in different transactions.
Cheers
/Eike
----
http://thegordian.blogspot.com
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
| |
Re: EMF databinding + undo/redo [message #426881 is a reply to message #426876] |
Fri, 23 January 2009 09:44 |
|
Sebastian,
CDO is not based on EMF Transaction. I think the major difference is
that EMF Transaction transactions are built on top of the command stack
of an editing domain while CDOTransactions are integrated with EMF on a
lower level (no edit dependency). As a consequence CDO transactions are
not relying on the client cooperation and allow a somewhat stronger
statement about transactional isolation. In other words, CDO
Transactions are more transparent to the editor. An editor using CDO
transactions does not need to be modified, but usually you will want to
react to certain events like objects becoming dirty, transaction is
committed or rolled back etc. Our generic CDOEditor demonstrates some
nice ideas like coloring dirty objects.
Cheers
/Eike
----
http://thegordian.blogspot.com
Sebastian Paul schrieb:
>
>> In your case it seems as if you would only need a single CDOSession
>> and then open multiple CDOTransactions on it. In this case you'd even
>> get transparent data sharing between the same objects in different
>> transactions.
>
> Hi,
> what about EMF Model Transaction
> ( http://www.eclipse.org/modeling/emf/?project=transaction#tra nsaction).
> Is CDO based on it? Or are there major differences regarding
> transactions?
>
> Cheers, Sebastian
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: EMF databinding + undo/redo [message #426958 is a reply to message #426837] |
Mon, 26 January 2009 23:36 |
Andrew H Messages: 117 Registered: July 2009 |
Senior Member |
|
|
Hi Ed / Tom
See inline
Ed Merks wrote:
> Guys,
> Comments below.
> Tom Schindl wrote:
>> Andrew H schrieb:
>>
>>> Hi Tom
>>>
>>> Unfortunately, I have the opposite problem as I have no idea about
>>> SWT/JFace. I do have a fair bit of Swing experience but its pretty rusty
>>> now. A colleague here has much more current experience if you have any
>>> particular questions.
>>>
>>> I had a quick look at the code from the link. It looks like you create
>>> Observables from Swing widgets which I presume are then used to
>>> integrate in with EMF models somehow?
>>>
>>
>> Yes you draw the connection between them by creating an Observable for
>> your EMF-Attribute and connect it to your UI-Observable using
>> Eclipse-Databinding.
>>
> Data binding is a general concept that could be used to bind any data
> "model' to any UI "model".
Yeah I think there are a few different binding frameworks that bind
(normally JavaBeans) models into swing UI models. I can't remember their
names.
>>
>>> When I initially evaluated EMF I had it in the back of my mind that the
>>> UI models generated by EMF (i.e. EMF.edit) looked fairly generic and not
>>> terribly SWT centric.
> Absolutely it's designed to be UI technology agnostic so it can be
> applied in many different contexts. For example, getImage returns an
> Object and in the implementation a URL.
Glad to hear you confirm that cause it certainly appeared that way and
that will make our life much easier.
>>> So I had thought it should be possible to write
>>> custom implementations of the Swing models that wrap these somehow. I
>>> didn't look into it further.
>>>
> The EMF.Edit layer is designed to be wrapped by something like the
> EMF.Edit.UI layer, which is Eclipse specific. I could imagine
> EMF.Edit.Swing and I know folks have done exactly that type of thing in
> the past.
That's pretty much what I was hoping. I was thinking along the lines of
for example in order to bind an EMF attribute into a text field
(JTextField in swing) I would create a custom implementation of Document
(the MVC model interface behind a JTextField) which adapts some model that
is part of the EMF.Edit layer, or something along those lines.
Similar tricks for combo's, tabs, lists etc.
>>>
>>
>> Sure you could simply customized the JET-Templates and create Swing-UI
>> instead of SWT/JFace.
>>
> Most of the work is likely generic and requires nothing that is specific
> to any particular instance model. Even the generated EMF Editor has
> almost no model-specific dependencies (and even the ones it has, like
> the item provider adapter factory is redundant now that these are
> available from the registry).
That was what I was thinking too unless there was something useful UI wise
that we could generate. Actually there probably is. We are thinking along
the lines of creating a set of what we are calling application models that
will be EMF models aligning with the user interaction we wish to create.
They will relate to the true domain model we have been creating.
The thought was that we might be able to generate useful UI stuff for
these. For example we might create widgets for all the attributes and add
them to a panel, leaving largely just the layout needed as custom code.
Not sure how that will turn out, but that was the basic idea.
>>
>>> Custom model implementations tends to be how I have gone about adapting
>>> other model frameworks into Swing in the past. These days there are a
>>> bunch of binding api's for Swing so that would likely be the way I would
>>> go now.
>>>
>>
>> You talk about BeanBinding and their friends right. I'm not sure they
>> integrate as good with EMFs notifications as Eclipse-Databinding does.
>>
> EMF's data model is so much more powerful and functionally completely
> that crappy old beans. A great demonstration of the power/completeness
> of EMF's notifications is the fact that they can be used to implement
> undo...
Yes, and this is something I look forward to benefiting from. Over the
years (dating back many years before EMF was conceived of) I have done
things to add some of the things that EMF has in it to JavaBeans models.
e.g. the stuff like lower & upper bounds, plus other constraints like
integer bounds, regexp etc.
Our UI layers would then know about this meta data and made use of it,
e.g. validating etc. We even used it to generate html & java script based
constraints.
It used to be particularly awkward, but Java 5 annotations improved this
somewhat.
However, EMF provides a much cleaner and more comprehensive answer to this
problem, so I am more than happy to no longer need to write that sort of
stuff.
And having the extra stuff in EMF.edit makes this even more convenient,
even for a Swing based product like ours.
cheers
Andy
|
|
|
Re: EMF databinding + undo/redo [message #426960 is a reply to message #426958] |
Tue, 27 January 2009 10:14 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030201090809020209090402
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Andrew,
Both these proposals are likely to be of some interest:
http://www.eclipse.org/proposals/pmf/
http://www.eclipse.org/proposals/eef/
Andrew H wrote:
> Hi Ed / Tom
>
> See inline
>
> Ed Merks wrote:
>
>> Guys,
>
>> Comments below.
>
>> Tom Schindl wrote:
>>> Andrew H schrieb:
>>>
>>>> Hi Tom
>>>>
>>>> Unfortunately, I have the opposite problem as I have no idea about
>>>> SWT/JFace. I do have a fair bit of Swing experience but its pretty
>>>> rusty
>>>> now. A colleague here has much more current experience if you have any
>>>> particular questions.
>>>>
>>>> I had a quick look at the code from the link. It looks like you create
>>>> Observables from Swing widgets which I presume are then used to
>>>> integrate in with EMF models somehow?
>>>>
>>>
>>> Yes you draw the connection between them by creating an Observable for
>>> your EMF-Attribute and connect it to your UI-Observable using
>>> Eclipse-Databinding.
>>>
>> Data binding is a general concept that could be used to bind any data
>> "model' to any UI "model".
>
> Yeah I think there are a few different binding frameworks that bind
> (normally JavaBeans) models into swing UI models. I can't remember
> their names.
>
>>>
>>>> When I initially evaluated EMF I had it in the back of my mind that
>>>> the
>>>> UI models generated by EMF (i.e. EMF.edit) looked fairly generic
>>>> and not
>>>> terribly SWT centric.
>> Absolutely it's designed to be UI technology agnostic so it can be
>> applied in many different contexts. For example, getImage returns an
>> Object and in the implementation a URL.
>
> Glad to hear you confirm that cause it certainly appeared that way and
> that will make our life much easier.
>
>>>> So I had thought it should be possible to write
>>>> custom implementations of the Swing models that wrap these somehow. I
>>>> didn't look into it further.
>>>>
>> The EMF.Edit layer is designed to be wrapped by something like the
>> EMF.Edit.UI layer, which is Eclipse specific. I could imagine
>> EMF.Edit.Swing and I know folks have done exactly that type of thing
>> in the past.
>
> That's pretty much what I was hoping. I was thinking along the lines
> of for example in order to bind an EMF attribute into a text field
> (JTextField in swing) I would create a custom implementation of
> Document (the MVC model interface behind a JTextField) which adapts
> some model that is part of the EMF.Edit layer, or something along
> those lines.
>
> Similar tricks for combo's, tabs, lists etc.
>
>>>>
>>>
>>> Sure you could simply customized the JET-Templates and create Swing-UI
>>> instead of SWT/JFace.
>>>
>> Most of the work is likely generic and requires nothing that is
>> specific to any particular instance model. Even the generated EMF
>> Editor has almost no model-specific dependencies (and even the ones
>> it has, like the item provider adapter factory is redundant now that
>> these are available from the registry).
>
> That was what I was thinking too unless there was something useful UI
> wise that we could generate. Actually there probably is. We are
> thinking along the lines of creating a set of what we are calling
> application models that will be EMF models aligning with the user
> interaction we wish to create. They will relate to the true domain
> model we have been creating.
>
> The thought was that we might be able to generate useful UI stuff for
> these. For example we might create widgets for all the attributes and
> add them to a panel, leaving largely just the layout needed as custom
> code.
>
> Not sure how that will turn out, but that was the basic idea.
>
>>>
>>>> Custom model implementations tends to be how I have gone about
>>>> adapting
>>>> other model frameworks into Swing in the past. These days there are a
>>>> bunch of binding api's for Swing so that would likely be the way I
>>>> would
>>>> go now.
>>>>
>>>
>>> You talk about BeanBinding and their friends right. I'm not sure they
>>> integrate as good with EMFs notifications as Eclipse-Databinding does.
>>>
>> EMF's data model is so much more powerful and functionally completely
>> that crappy old beans. A great demonstration of the
>> power/completeness of EMF's notifications is the fact that they can
>> be used to implement undo...
>
> Yes, and this is something I look forward to benefiting from. Over the
> years (dating back many years before EMF was conceived of) I have done
> things to add some of the things that EMF has in it to JavaBeans
> models. e.g. the stuff like lower & upper bounds, plus other
> constraints like integer bounds, regexp etc.
>
> Our UI layers would then know about this meta data and made use of it,
> e.g. validating etc. We even used it to generate html & java script
> based constraints.
>
> It used to be particularly awkward, but Java 5 annotations improved
> this somewhat.
>
> However, EMF provides a much cleaner and more comprehensive answer to
> this problem, so I am more than happy to no longer need to write that
> sort of stuff.
>
> And having the extra stuff in EMF.edit makes this even more
> convenient, even for a Swing based product like ours.
>
> cheers
>
> Andy
>
--------------030201090809020209090402
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Andrew,<br>
<br>
Both these proposals are likely to be of some interest:<br>
<blockquote><a href="http://www.eclipse.org/proposals/pmf/">http://www.eclipse.org/proposals/pmf/</a><br>
<a href="http://www.eclipse.org/proposals/eef/">http://www.eclipse.org/proposals/eef/</a><br>
</blockquote>
<br>
Andrew H wrote:
<blockquote
cite="mid:7de35d48683c909c571d8cb8db64e15e$1@www.eclipse.org"
type="cite">Hi Ed / Tom
<br>
<br>
See inline
<br>
<br>
Ed Merks wrote:
<br>
<br>
<blockquote type="cite">Guys,
<br>
</blockquote>
<br>
<blockquote type="cite">Comments below.
<br>
</blockquote>
<br>
<blockquote type="cite">Tom Schindl wrote:
<br>
<blockquote type="cite">Andrew H schrieb:
<br>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: EMF databinding + undo/redo [message #427007 is a reply to message #426960] |
Tue, 27 January 2009 23:42 |
Andrew H Messages: 117 Registered: July 2009 |
Senior Member |
|
|
Yes they do sound interesting (at least as far as I can tell from the
proposals). Pity they won't happen within our timelines.
I assume there will be some relationship between the two?
Ed Merks wrote:
> Andrew,
> Both these proposals are likely to be of some interest:
> http://www.eclipse.org/proposals/pmf/
> http://www.eclipse.org/proposals/eef/
> Andrew H wrote:
>> Hi Ed / Tom
>>
>> See inline
>>
>> Ed Merks wrote:
>>
>>> Guys,
>>
>>> Comments below.
>>
>>> Tom Schindl wrote:
>>>> Andrew H schrieb:
>>>>
>>>>> Hi Tom
>>>>>
>>>>> Unfortunately, I have the opposite problem as I have no idea about
>>>>> SWT/JFace. I do have a fair bit of Swing experience but its pretty
>>>>> rusty
>>>>> now. A colleague here has much more current experience if you have any
>>>>> particular questions.
>>>>>
>>>>> I had a quick look at the code from the link. It looks like you create
>>>>> Observables from Swing widgets which I presume are then used to
>>>>> integrate in with EMF models somehow?
>>>>>
>>>>
>>>> Yes you draw the connection between them by creating an Observable for
>>>> your EMF-Attribute and connect it to your UI-Observable using
>>>> Eclipse-Databinding.
>>>>
>>> Data binding is a general concept that could be used to bind any data
>>> "model' to any UI "model".
>>
>> Yeah I think there are a few different binding frameworks that bind
>> (normally JavaBeans) models into swing UI models. I can't remember
>> their names.
>>
>>>>
>>>>> When I initially evaluated EMF I had it in the back of my mind that
>>>>> the
>>>>> UI models generated by EMF (i.e. EMF.edit) looked fairly generic
>>>>> and not
>>>>> terribly SWT centric.
>>> Absolutely it's designed to be UI technology agnostic so it can be
>>> applied in many different contexts. For example, getImage returns an
>>> Object and in the implementation a URL.
>>
>> Glad to hear you confirm that cause it certainly appeared that way and
>> that will make our life much easier.
>>
>>>>> So I had thought it should be possible to write
>>>>> custom implementations of the Swing models that wrap these somehow. I
>>>>> didn't look into it further.
>>>>>
>>> The EMF.Edit layer is designed to be wrapped by something like the
>>> EMF.Edit.UI layer, which is Eclipse specific. I could imagine
>>> EMF.Edit.Swing and I know folks have done exactly that type of thing
>>> in the past.
>>
>> That's pretty much what I was hoping. I was thinking along the lines
>> of for example in order to bind an EMF attribute into a text field
>> (JTextField in swing) I would create a custom implementation of
>> Document (the MVC model interface behind a JTextField) which adapts
>> some model that is part of the EMF.Edit layer, or something along
>> those lines.
>>
>> Similar tricks for combo's, tabs, lists etc.
>>
>>>>>
>>>>
>>>> Sure you could simply customized the JET-Templates and create Swing-UI
>>>> instead of SWT/JFace.
>>>>
>>> Most of the work is likely generic and requires nothing that is
>>> specific to any particular instance model. Even the generated EMF
>>> Editor has almost no model-specific dependencies (and even the ones
>>> it has, like the item provider adapter factory is redundant now that
>>> these are available from the registry).
>>
>> That was what I was thinking too unless there was something useful UI
>> wise that we could generate. Actually there probably is. We are
>> thinking along the lines of creating a set of what we are calling
>> application models that will be EMF models aligning with the user
>> interaction we wish to create. They will relate to the true domain
>> model we have been creating.
>>
>> The thought was that we might be able to generate useful UI stuff for
>> these. For example we might create widgets for all the attributes and
>> add them to a panel, leaving largely just the layout needed as custom
>> code.
>>
>> Not sure how that will turn out, but that was the basic idea.
>>
>>>>
>>>>> Custom model implementations tends to be how I have gone about
>>>>> adapting
>>>>> other model frameworks into Swing in the past. These days there are a
>>>>> bunch of binding api's for Swing so that would likely be the way I
>>>>> would
>>>>> go now.
>>>>>
>>>>
>>>> You talk about BeanBinding and their friends right. I'm not sure they
>>>> integrate as good with EMFs notifications as Eclipse-Databinding does.
>>>>
>>> EMF's data model is so much more powerful and functionally completely
>>> that crappy old beans. A great demonstration of the
>>> power/completeness of EMF's notifications is the fact that they can
>>> be used to implement undo...
>>
>> Yes, and this is something I look forward to benefiting from. Over the
>> years (dating back many years before EMF was conceived of) I have done
>> things to add some of the things that EMF has in it to JavaBeans
>> models. e.g. the stuff like lower & upper bounds, plus other
>> constraints like integer bounds, regexp etc.
>>
>> Our UI layers would then know about this meta data and made use of it,
>> e.g. validating etc. We even used it to generate html & java script
>> based constraints.
>>
>> It used to be particularly awkward, but Java 5 annotations improved
>> this somewhat.
>>
>> However, EMF provides a much cleaner and more comprehensive answer to
>> this problem, so I am more than happy to no longer need to write that
>> sort of stuff.
>>
>> And having the extra stuff in EMF.edit makes this even more
>> convenient, even for a Swing based product like ours.
>>
>> cheers
>>
>> Andy
>>
|
|
|
Re: EMF databinding + undo/redo [message #427010 is a reply to message #427007] |
Wed, 28 January 2009 03:06 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Andrew,
They have a bit different time lines as well with EEF being more
immediately short term. I'm sure it will all converge though...
Andrew H wrote:
> Yes they do sound interesting (at least as far as I can tell from the
> proposals). Pity they won't happen within our timelines.
>
> I assume there will be some relationship between the two?
> Ed Merks wrote:
>
>> Andrew,
>
>> Both these proposals are likely to be of some interest:
>
>> http://www.eclipse.org/proposals/pmf/
>> http://www.eclipse.org/proposals/eef/
>
>
>> Andrew H wrote:
>>> Hi Ed / Tom
>>>
>>> See inline
>>>
>>> Ed Merks wrote:
>>>
>>>> Guys,
>>>
>>>> Comments below.
>>>
>>>> Tom Schindl wrote:
>>>>> Andrew H schrieb:
>>>>>
>>>>>> Hi Tom
>>>>>>
>>>>>> Unfortunately, I have the opposite problem as I have no idea about
>>>>>> SWT/JFace. I do have a fair bit of Swing experience but its
>>>>>> pretty rusty
>>>>>> now. A colleague here has much more current experience if you
>>>>>> have any
>>>>>> particular questions.
>>>>>>
>>>>>> I had a quick look at the code from the link. It looks like you
>>>>>> create
>>>>>> Observables from Swing widgets which I presume are then used to
>>>>>> integrate in with EMF models somehow?
>>>>>>
>>>>>
>>>>> Yes you draw the connection between them by creating an Observable
>>>>> for
>>>>> your EMF-Attribute and connect it to your UI-Observable using
>>>>> Eclipse-Databinding.
>>>>>
>>>> Data binding is a general concept that could be used to bind any
>>>> data "model' to any UI "model".
>>>
>>> Yeah I think there are a few different binding frameworks that bind
>>> (normally JavaBeans) models into swing UI models. I can't remember
>>> their names.
>>>
>>>>>
>>>>>> When I initially evaluated EMF I had it in the back of my mind
>>>>>> that the
>>>>>> UI models generated by EMF (i.e. EMF.edit) looked fairly generic
>>>>>> and not
>>>>>> terribly SWT centric.
>>>> Absolutely it's designed to be UI technology agnostic so it can be
>>>> applied in many different contexts. For example, getImage returns
>>>> an Object and in the implementation a URL.
>>>
>>> Glad to hear you confirm that cause it certainly appeared that way
>>> and that will make our life much easier.
>>>
>>>>>> So I had thought it should be possible to write
>>>>>> custom implementations of the Swing models that wrap these
>>>>>> somehow. I
>>>>>> didn't look into it further.
>>>>>>
>>>> The EMF.Edit layer is designed to be wrapped by something like the
>>>> EMF.Edit.UI layer, which is Eclipse specific. I could imagine
>>>> EMF.Edit.Swing and I know folks have done exactly that type of
>>>> thing in the past.
>>>
>>> That's pretty much what I was hoping. I was thinking along the lines
>>> of for example in order to bind an EMF attribute into a text field
>>> (JTextField in swing) I would create a custom implementation of
>>> Document (the MVC model interface behind a JTextField) which adapts
>>> some model that is part of the EMF.Edit layer, or something along
>>> those lines.
>>>
>>> Similar tricks for combo's, tabs, lists etc.
>>>
>>>>>>
>>>>>
>>>>> Sure you could simply customized the JET-Templates and create
>>>>> Swing-UI
>>>>> instead of SWT/JFace.
>>>>>
>>>> Most of the work is likely generic and requires nothing that is
>>>> specific to any particular instance model. Even the generated EMF
>>>> Editor has almost no model-specific dependencies (and even the ones
>>>> it has, like the item provider adapter factory is redundant now
>>>> that these are available from the registry).
>>>
>>> That was what I was thinking too unless there was something useful
>>> UI wise that we could generate. Actually there probably is. We are
>>> thinking along the lines of creating a set of what we are calling
>>> application models that will be EMF models aligning with the user
>>> interaction we wish to create. They will relate to the true domain
>>> model we have been creating.
>>>
>>> The thought was that we might be able to generate useful UI stuff
>>> for these. For example we might create widgets for all the
>>> attributes and add them to a panel, leaving largely just the layout
>>> needed as custom code.
>>>
>>> Not sure how that will turn out, but that was the basic idea.
>>>
>>>>>
>>>>>> Custom model implementations tends to be how I have gone about
>>>>>> adapting
>>>>>> other model frameworks into Swing in the past. These days there
>>>>>> are a
>>>>>> bunch of binding api's for Swing so that would likely be the way
>>>>>> I would
>>>>>> go now.
>>>>>>
>>>>>
>>>>> You talk about BeanBinding and their friends right. I'm not sure they
>>>>> integrate as good with EMFs notifications as Eclipse-Databinding
>>>>> does.
>>>>>
>>>> EMF's data model is so much more powerful and functionally
>>>> completely that crappy old beans. A great demonstration of the
>>>> power/completeness of EMF's notifications is the fact that they can
>>>> be used to implement undo...
>>>
>>> Yes, and this is something I look forward to benefiting from. Over
>>> the years (dating back many years before EMF was conceived of) I
>>> have done things to add some of the things that EMF has in it to
>>> JavaBeans models. e.g. the stuff like lower & upper bounds, plus
>>> other constraints like integer bounds, regexp etc.
>>>
>>> Our UI layers would then know about this meta data and made use of
>>> it, e.g. validating etc. We even used it to generate html & java
>>> script based constraints.
>>>
>>> It used to be particularly awkward, but Java 5 annotations improved
>>> this somewhat.
>>>
>>> However, EMF provides a much cleaner and more comprehensive answer
>>> to this problem, so I am more than happy to no longer need to write
>>> that sort of stuff.
>>>
>>> And having the extra stuff in EMF.edit makes this even more
>>> convenient, even for a Swing based product like ours.
>>>
>>> cheers
>>>
>>> Andy
>>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Fri Apr 26 20:59:04 GMT 2024
Powered by FUDForum. Page generated in 0.05199 seconds
|