Home » Modeling » EMF » GWT EMF reflective editor
| | | | | |
Re: GWT EMF reflective editor [message #1250932 is a reply to message #1250912] |
Wed, 19 February 2014 18:55 |
Bartek K Messages: 9 Registered: February 2014 |
Junior Member |
|
|
Ed,
I've added comments below.
Ed Merks wrote on Wed, 19 February 2014 13:28
>Bartek,
>
>Comments below.
>
>On 19/02/2014 6:27 PM, Bartek K wrote:
>> Ed,
>>
>> OK, I understand, thanks.
>>
>> I have one more question, then. The tutorial talks about generating an
>> editor plug-in for a given model.
>Yes, that just has some registrations in it... Have you looked closely
>at the contents of what's generated?
Yes, I've had a look at what's generated - there's not much but from what I understand the Ecore model is registered (as you just said).
>> However I would like to be able to create new metamodels using the
>> editor in GWT - how would I go about it?
>What do you mean by "new metamodels"? You're not just talking about
>using the editor to create and edit instances of some Ecore model you
>already have?
Yes, that's it. I'm wondering if it's possible to create a new Ecore model using the EMF editor and GWT.
|
|
|
Re: GWT EMF reflective editor [message #1250982 is a reply to message #1250932] |
Wed, 19 February 2014 20:09 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Bartek,
The reflective editor should work for Ecore as well.
On 19/02/2014 7:55 PM, Bartek K wrote:
> Ed,
>
> I've added comments below.
>
> Ed Merks wrote on Wed, 19 February 2014 13:28
>> Bartek,
>>
>> Comments below.
>>
>> On 19/02/2014 6:27 PM, Bartek K wrote:
>>> Ed,
>>>
>>> OK, I understand, thanks.
>>>
>>> I have one more question, then. The tutorial talks about generating
>>> an editor plug-in for a given model.
>> Yes, that just has some registrations in it... Have you looked
>> closely at the contents of what's generated?
>
> Yes, I've had a look at what's generated - there's not much but from
> what I understand the Ecore model is registered (as you just said).
>
>>> However I would like to be able to create new metamodels using the
>>> editor in GWT - how would I go about it?
>> What do you mean by "new metamodels"? You're not just talking about
>> using the editor to create and edit instances of some Ecore model you
>> already have?
>
> Yes, that's it. I'm wondering if it's possible to create a new Ecore
> model using the EMF editor and GWT.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: GWT EMF reflective editor [message #1255160 is a reply to message #1254651] |
Mon, 24 February 2014 06:28 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Bartek,
Comments below.
On 23/02/2014 6:01 PM, Bartek K wrote:
> Hi Ed,
>
> I've tried the following two approaches.
>
> 1. I followed the tutorial and used
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as the path for
> the model. That was fine until I generated the model, edit and editor
> plugins - after that there are over a hundred errors in the model and
> editor plugins. Using Ecore.ecore makes it better but there are still
> 18 errors that don't seem straightforward to solve.
The Ecore model already exists, so you should use the existing model and
edit bundles.
>
> Have you ever attempted this approach? Did it work previously?
>
> 2. I followed the tutorial and edited the LibraryEditorEntryPoint.java
> file in the editor plugin to use the EcorePackage and
> EcoreAdapterFactory (also tried ReflectiveItemProviderAdapterFactory).
> This looks promising though there are a few glitches.
That makes more sense.
> The main one is an "Uncaught exception escaped" which happens when I
> click on (select) an instance of EAttribute, EClass, EDataType, EEnum
> or EReference. Due to that the properties part of the display is not
> rendered correctly.
>
> 16:36:57.838 [ERROR] [org.eclipse.example.library.LibraryEditor]
> Uncaught exception escaped
> com.google.gwt.event.shared.UmbrellaException: Exception caught: null
> at
> com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
> at
> com.google.gwt.view.client.SelectionModel$AbstractSelectionModel.fireEvent(SelectionModel.java:72)
> at
> com.google.gwt.view.client.SelectionChangeEvent.fire(SelectionChangeEvent.java:70)
> at
> com.google.gwt.view.client.SingleSelectionModel.resolveChanges(SingleSelectionModel.java:140)
> at
> com.google.gwt.view.client.SingleSelectionModel.isSelected(SingleSelectionModel.java:82)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.resolvePendingState(HasDataPresenter.java:1221)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.access$3(HasDataPresenter.java:1062)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter$2.execute(HasDataPresenter.java:984)
> at
> com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:279)
> at com.google.gwt.core.client.impl.Impl.exit(Impl.java:266)
> at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:257)
> at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
> at
> com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
> at
> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
> at java.lang.Thread.run(Thread.java:744)
> Caused by: java.lang.NullPointerException: null
> at
> org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(EFactoryImpl.java:689)
> at
> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEJavaObjectToString(EcoreFactoryImpl.java:886)
> at
> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString(EcoreFactoryImpl.java:195)
> at
> org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3350)
> at
> org.eclipse.emf.edit.ui.EditorEntryPoint$10$16.run(EditorEntryPoint.java:1011)
> at
> org.eclipse.emf.edit.ui.EditorEntryPoint$10.onSelectionChange(EditorEntryPoint.java:1018)
> at
> com.google.gwt.view.client.SelectionChangeEvent.dispatch(SelectionChangeEvent.java:99)
> at
> com.google.gwt.view.client.SelectionChangeEvent.dispatch(SelectionChangeEvent.java:1)
> at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
> at
> com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
> at
> com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
> at
> com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
> at
> com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
> at
> com.google.gwt.view.client.SelectionModel$AbstractSelectionModel.fireEvent(SelectionModel.java:72)
> at
> com.google.gwt.view.client.SelectionChangeEvent.fire(SelectionChangeEvent.java:70)
> at
> com.google.gwt.view.client.SingleSelectionModel.resolveChanges(SingleSelectionModel.java:140)
> at
> com.google.gwt.view.client.SingleSelectionModel.isSelected(SingleSelectionModel.java:82)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.resolvePendingState(HasDataPresenter.java:1221)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.access$3(HasDataPresenter.java:1062)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter$2.execute(HasDataPresenter.java:984)
> at
> com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:279)
> at com.google.gwt.core.client.impl.Impl.exit(Impl.java:266)
> at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:257)
> at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
> at
> com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
> at
> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
> at java.lang.Thread.run(Thread.java:744)
> When one of the above objects is created the following error is printed
> 16:55:41.250 [ERROR] [org.eclipse.example.library.LibraryEditor]
> Uncaught exception escaped
> com.google.gwt.event.shared.UmbrellaException: Exception caught: null
> at
> com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
> at
> com.google.gwt.view.client.SelectionModel$AbstractSelectionModel.fireEvent(SelectionModel.java:72)
> at
> com.google.gwt.view.client.SelectionChangeEvent.fire(SelectionChangeEvent.java:70)
> at
> com.google.gwt.view.client.SingleSelectionModel.resolveChanges(SingleSelectionModel.java:140)
> at
> com.google.gwt.view.client.SingleSelectionModel.isSelected(SingleSelectionModel.java:82)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.resolvePendingState(HasDataPresenter.java:1221)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.access$3(HasDataPresenter.java:1062)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter$2.execute(HasDataPresenter.java:984)
> at
> com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:279)
> at com.google.gwt.core.client.impl.Impl.exit(Impl.java:266)
> at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:257)
> at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
> at
> com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
> at
> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
> at java.lang.Thread.run(Thread.java:744)
> Caused by: java.lang.NullPointerException: null
> at
> org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(EFactoryImpl.java:689)
> at
> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEJavaObjectToString(EcoreFactoryImpl.java:886)
> at
> org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString(EcoreFactoryImpl.java:195)
> at
> org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3350)
> at
> org.eclipse.emf.edit.ui.EditorEntryPoint$10$16.run(EditorEntryPoint.java:1011)
> at
> org.eclipse.emf.edit.ui.EditorEntryPoint$10.onSelectionChange(EditorEntryPoint.java:1018)
> at
> com.google.gwt.view.client.SelectionChangeEvent.dispatch(SelectionChangeEvent.java:99)
> at
> com.google.gwt.view.client.SelectionChangeEvent.dispatch(SelectionChangeEvent.java:1)
> at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
> at
> com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
> at
> com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
> at
> com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
> at
> com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
> at
> com.google.gwt.view.client.SelectionModel$AbstractSelectionModel.fireEvent(SelectionModel.java:72)
> at
> com.google.gwt.view.client.SelectionChangeEvent.fire(SelectionChangeEvent.java:70)
> at
> com.google.gwt.view.client.SingleSelectionModel.resolveChanges(SingleSelectionModel.java:140)
> at
> com.google.gwt.view.client.SingleSelectionModel.isSelected(SingleSelectionModel.java:82)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.resolvePendingState(HasDataPresenter.java:1221)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter.access$3(HasDataPresenter.java:1062)
> at
> com.google.gwt.user.cellview.client.HasDataPresenter$2.execute(HasDataPresenter.java:984)
> at
> com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
> at
> com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:279)
> at com.google.gwt.core.client.impl.Impl.exit(Impl.java:266)
> at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:257)
> at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
> at
> com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
> at
> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
> at java.lang.Thread.run(Thread.java:744)
> Do you know what the underlying cause is?
I never figured out a way to support serializing arbitrary Java objects;
the hacked "TODO" code doesn't handle null well. There are no property
descriptor for the Ecore feature's that use EJavaObject, and those
features are transient, so I'm surprised this situation arises...
> I'd be grateful if you could point me in the right direction.
Are you sure that the specialized generated Ecore item providers are
being used, and not the general ReflectiveItemProvider?
>
> Thanks,
> Bartek
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | |
Re: GWT EMF reflective editor [message #1255543 is a reply to message #1255461] |
Mon, 24 February 2014 15:01 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Bartek,
Comments below.
On 24/02/2014 2:13 PM, Bartek K wrote:
> Ed,
>
> Yes (I should've included those lines as well).
>
> You're right, there's no need to edit the plugin, I got a little
> confused.
>
> I already have a derived class and at the moment I add the
> EcoreAdapterFactory which may explain why the errors described in the
> previous post arise.public class LibraryEditorEntryPoint extends
> EditorEntryPoint {
>
> @Override
> public void onModuleLoad() {
> super.onModuleLoad();
> }
>
> @Override
> protected void registerPackages(EPackage.Registry packageRegistry) {
> packageRegistry.put(EcorePackage.eNS_URI,
> EcorePackage.eINSTANCE);
> }
>
> @Override
> protected void
> configureItemProviderAdapterFactories(ComposedAdapterFactory
> adapterFactory) {
> adapterFactory.addAdapterFactory(new EcoreAdapterFactory());
It has to be EcoreItemProviderAdapterFactory...
> }
>
> @Override
> protected String getApplicationTitle() {
> return "Ecore Application";
> }
> }
> I don't seem to be able to use EcoreItemProviderAdapterFactory. I
> can't find it in the list of types that implement
> org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.
Probably because you've not added a dependency on that plugin to any
project in your workspace. If you add org.eclipse.emf.gwt.ecore.edit as
a dependency in the MANIFEST.MF of your editor bundle, you should be
able to use the classes it provided.
>
> I searched for it and the
> http://download.eclipse.org/modeling/emf/emf/javadoc/2.9.0/org/eclipse/emf/ecore/provider/EcoreItemProviderAdapterFactory.html
> is empty whereas documentation for 2.8.0 has all the methods
> described. Further
> http://grepcode.com/search?query=EcoreItemProviderAdapterFactory&n=
> confirmed my doubts - EcoreItemProviderAdapterFactory does not seem to
> be present in 2.9.0.
That's strange.
>
> I changed my target platform to use the 2.8 release site but it did
> not help - I am still unable to use EcoreItemProviderAdapterFactory
> (it cannot be resolved to a type).
Another useful trick is to show the Plug-ins view, select all the
plugins, and then, from the context menu, invoke "Add to Java Search".
Then Ctrl-Shift-T will find any class in any plugin, including in
plugins you don't have any dependencies on yet. It will also show a
more complete type hierarchy to include the classes in those plugins.
It definitely should be there. Be sure to use the versions with "gwt"
in the bundle IDs.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: GWT EMF reflective editor [message #1255668 is a reply to message #1255543] |
Mon, 24 February 2014 17:54 |
Bartek K Messages: 9 Registered: February 2014 |
Junior Member |
|
|
Ed,
Thank you for your help. I've sorted out dependencies now and adding the plugin classes to Java search was really useful.
Unfortunately, using EcoreItemProviderAdapterFactory did not help - the uncaught exception is still there. On top of that, a new problem was introduced.
Namely, when I select a resource and try to create a new object, there are either no class names or "null"s (i.e. "new ", "new null()", "new null" etc). It doesn't happen, though, when an object is selected first.
This is the code that adds items to the list of objects that can be created when a resource is selected (org.eclipse.emf.edit.ui.EditorEntryPoint.class, lines 1204-1225)
final Resource resource = (Resource)selection;
final DialogBox dialogBox = new DialogBox();
dialogBox.setText("Create Object");
final ListBox listBox = new ListBox();
listBox.setVisibleItemCount(1);
Registry packageRegistry = resourceSet.getPackageRegistry();
for (String nsURI : packageRegistry.keySet())
{
EPackage ePackage = packageRegistry.getEPackage(nsURI);
for (EClassifier eClassifier : ePackage.getEClassifiers())
{
if (eClassifier instanceof EClass)
{
EClass eClass = (EClass)eClassifier;
if (!eClass.isAbstract())
{
EObject eObject = EcoreUtil.create(eClass);
listBox.addItem("New " + itemDelegator.getText(eObject), EcoreUtil.getURI(eClass).toString());
}
}
}
}
|
|
|
Re: GWT EMF reflective editor [message #1255679 is a reply to message #1255668] |
Mon, 24 February 2014 18:08 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Bartek,
Comments below.
On 24/02/2014 6:54 PM, Bartek K wrote:
> Ed,
>
> Thank you for your help. I've sorted out dependencies now and adding
> the plugin classes to Java search was really useful.
>
> Unfortunately, using EcoreItemProviderAdapterFactory did not help -
> the uncaught exception is still there.
I assume you're sure you picked the GWT version of that bundle...
It's been so long since I've set up a functional GWT environment I'm not
in a good position to test this myself... The best I can suggest is
setting breakpoints to ensure that the proper delegation is
happening. I.e., in
org.eclipse.emf.edit.ui.EditorEntryPoint.onModuleLoad().new Handler()
{...}.onSelectionChange(SelectionChangeEvent) see what's happening in
the following logic in the debugger
List<IItemPropertyDescriptor> propertyDescriptors =
itemDelegator.getPropertyDescriptors(object);
It should end up in a method like
org.eclipse.emf.ecore.provider.EAttributeItemProvider.getPropertyDescriptors(Object),
assuming you've selected an EAttribute.
> On top of that, a new problem was introduced.
> Namely, when I select a resource and try to create a new object, there
> are either no class names or "null"s (i.e. "new ", "new null()", "new
> null" etc). It doesn't happen, though, when an object is selected first.
>
> This is the code that adds items to the list of objects that can be
> created when a resource is selected
> (org.eclipse.emf.edit.ui.EditorEntryPoint.class, lines 1204-1225)
> final Resource resource = (Resource)selection;
> final DialogBox dialogBox = new DialogBox();
> dialogBox.setText("Create Object");
> final ListBox listBox = new ListBox();
> listBox.setVisibleItemCount(1);
> Registry packageRegistry = resourceSet.getPackageRegistry();
> for (String nsURI : packageRegistry.keySet())
> {
> EPackage ePackage = packageRegistry.getEPackage(nsURI);
> for (EClassifier eClassifier : ePackage.getEClassifiers())
> {
> if (eClassifier instanceof EClass)
> {
> EClass eClass = (EClass)eClassifier;
> if (!eClass.isAbstract())
> {
> EObject eObject = EcoreUtil.create(eClass);
> listBox.addItem("New " + itemDelegator.getText(eObject),
> EcoreUtil.getURI(eClass).toString());
Hmmm. This should still end up delegating to the reflective item
provider as before.
> }
> }
> }
> }
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 05:53:50 GMT 2024
Powered by FUDForum. Page generated in 0.04390 seconds
|