Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Overriding Edit command in Application.e4xmi from fragment.e4xmi
Overriding Edit command in Application.e4xmi from fragment.e4xmi [message #1211185] Tue, 26 November 2013 10:00 Go to next message
maarten meijer is currently offline maarten meijerFriend
Messages: 146
Registered: July 2009
Senior Member
I have a fairly generic e4 application with an edit menu that includes
Copy, Paste, Delete items. These menu items map to the standard ID's for
commands:
org.eclipse.ui.edit.copy
org.eclipse.ui.edit.paste
org.eclipse.ui.edit.delete

I also have default handlers in the application.e4xmi

I also have a Part with a special viewer in a separate plugin with an
fragment.e4xmi
I have view menus and context menus working.

Now I want to override the Delete command for this special viewer:
when something is selected in the viewer, the Delete menu item is
attached to the context menu.

I want the special handler to be active when the MPart with special
viewer is active, so I create the handler under the Part:

+ Model Fragment (children)
+-+ Part
+-+ Menus
+-+ Handlers
+-+ Handler - special delete handler

I can create class and ID etc for the handler, but I cannot specify the
command!!
So I import the command to override org.eclipse.ui.edit.delete in the
header of the fragment.
The I can add the org.eclipse.ui.edit.delete to the Handler so all
appears well.

When I run I cannot start the application with this error:

java.lang.ClassCastException:
org.eclipse.e4.ui.model.application.ui.menu.impl.HandledMenuItemImpl
cannot be cast to org.eclipse.e4.ui.model.application.commands.MCommand
at
org.eclipse.e4.ui.model.application.commands.impl.HandlerImpl.eSet(HandlerImpl.java:127)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1071)
at
org.eclipse.e4.ui.internal.workbench.ModelAssembler$1.run(ModelAssembler.java:289)
at
org.eclipse.e4.ui.internal.workbench.ModelAssembler.resolveImports(ModelAssembler.java:298)
at
org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:197)
at
org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:219)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:395)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:238)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:144)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

What am I doing wrong?
Re: Overriding Edit command in Application.e4xmi from fragment.e4xmi [message #1211201 is a reply to message #1211185] Tue, 26 November 2013 10:07 Go to previous messageGo to next message
Eclipse UserFriend
It is complaining that you are setting a MHandledMenuItem while you should set a MCommand. This occurs while the fragments are merged that's why get it on startup. If you can't figure it out yourself through the relevant e4xmi part here so we can take a look.
Re: Overriding Edit command in Application.e4xmi from fragment.e4xmi [message #1212433 is a reply to message #1211201] Tue, 26 November 2013 22:33 Go to previous message
maarten meijer is currently offline maarten meijerFriend
Messages: 146
Registered: July 2009
Senior Member
Sopot Cela wrote:
> It is complaining that you are setting a MHandledMenuItem while you
> should set a MCommand. This occurs while the fragments are merged that's
> why get it on startup. If you can't figure it out yourself through the
> relevant e4xmi part here so we can take a look.

Hypothesis:
Can it be caused because menu items and commands have the same ID?
Answer:
Yes when removing duplicate ID's the problem disappeared.
Is it time for a application/fragment.e4xmi builder that check for
duplicate ID's and gives a Problem?
Previous Topic:Howto add a closelistener to a MPart?
Next Topic:replacing WorkbenchLogger
Goto Forum:
  


Current Time: Thu Apr 25 09:56:28 GMT 2024

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

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

Back to the top