Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Menu shows only with -clearPersistedState
Menu shows only with -clearPersistedState [message #997140] Thu, 03 January 2013 22:37 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
Hi

when I run my application with compatibility layer with the argument -clearPersistedState it shows the menu, without the menu is no more shown.

I use a TrimmedWindow with Main Menu.

When I look at the
.metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi the "mainMenu" element is missing.

I am using Eclipse 4.2.1 and e4 tools 0.12.
Is this a bug or is there something that I missed?


thanks
Frank
Re: Menu shows only with -clearPersistedState [message #997304 is a reply to message #997140] Sat, 05 January 2013 13:40 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
I tried the same now with eclipse 4.3M4 and e4 tools I20130103-2200


For running on 4.3M4 I added the HandlerProcessingAddon as suggested by Lars Vogel.

This is how the app look with 4.2
index.php/fa/12880/0/

4.3M4, the quickaccess is strange
index.php/fa/12881/0/

4.3M4, this is the resize needed to make the quick access flip so the upper line
index.php/fa/12882/0/

And again without -clearPersistedState the menu disapears
index.php/fa/12883/0/

Any ideas why the UI changes?
Any ideas what I can do about the clerarPersistedState?

thanks Frank







  • Attachment: cv-4.2.PNG
    (Size: 34.73KB, Downloaded 2774 times)
  • Attachment: cv-4.3.PNG
    (Size: 46.54KB, Downloaded 2759 times)
  • Attachment: cv-4.3-2.PNG
    (Size: 49.07KB, Downloaded 2751 times)
  • Attachment: cv-4.3-noarg.PNG
    (Size: 48.43KB, Downloaded 2709 times)
Re: Menu shows only with -clearPersistedState [message #1002382 is a reply to message #997304] Fri, 18 January 2013 13:38 Go to previous messageGo to next message
Eclipse UserFriend
Try inspecting the model with the live editor and see what happens when you run it. Is it any different from your Application.e4xmi?
Re: Menu shows only with -clearPersistedState [message #1002830 is a reply to message #1002382] Sat, 19 January 2013 15:10 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
Hi Sopot,

when I inspect the live editor (now with 4.2.1), I run the appl with -clearPersistedState. Then I see the mainMenu in the model. When the application is ended, I examine the .metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi, which I guess is the persisted model. Here the mainMenu is not contained. This is the reason, why a new start without -clearPersitedState is not working.

Frank
Re: Menu shows only with -clearPersistedState [message #1002832 is a reply to message #1002830] Sat, 19 January 2013 15:17 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
... when I do the same with the wizard generaed e4 app, this works. How can I find the reason, it is not working in my application?
Re: Menu shows only with -clearPersistedState [message #1002932 is a reply to message #1002832] Sat, 19 January 2013 22:14 Go to previous messageGo to next message
Eclipse UserFriend
Are you providing lifecycle hooks to your application? Maybe you are messing something with the lifecycle annotations which are meant to manipulate the model on app shutdown.
Re: Menu shows only with -clearPersistedState [message #1002959 is a reply to message #1002932] Sun, 20 January 2013 00:01 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
Thanks for the suggestion.
Indeed, I had a live cycle hook installed for testing purpose, there hooks where not doing anything. But I remove it from the plugin.xml now. Still the mainMenu is missing from the saved workbench.xmi.

Re: Menu shows only with -clearPersistedState [message #1003179 is a reply to message #1002959] Sun, 20 January 2013 13:55 Go to previous messageGo to next message
Eclipse UserFriend
Well try putting a breakpoint in the MWindow.setMainMenu method and examine the call stack to see who calls it with the null argument when the workbench closes. If no one calls than it is not in the model at startup in the first place. If so you have to examine the model merging code and see where it is left out.

This may get a bit deep but you will get at it eventually.
Re: Menu shows only with -clearPersistedState [message #1003939 is a reply to message #1003179] Tue, 22 January 2013 09:32 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
Hi Sopot,

thanks for the hints. So far I did insert the breakpoint and find that the application break at close.
The MWindowImpl.setMainMenu is called with null, and the workbench.xmi is written afterwards without the main menu element.

At that time, this is the call stack:
Thread [main] (Suspended (breakpoint at line 511 in WindowImpl))	
	TrimmedWindowImpl(WindowImpl).setMainMenu(MMenu) line: 511	
	WorkbenchWindow$1.handleEvent(Event) line: 286	
	UIEventHandler$1.run() line: 41	
	UISynchronizer(Synchronizer).syncExec(Runnable) line: 180	
	UISynchronizer.syncExec(Runnable) line: 150	
	Display.syncExec(Runnable) line: 4687	
	E4Application$1.syncExec(Runnable) line: 187	
	UIEventHandler.handleEvent(Event) line: 38	
	EventHandlerWrapper.handleEvent(Event, Permission) line: 197	
	EventHandlerTracker.dispatchEvent(EventHandlerWrapper, Permission, int, Event) line: 197	
	EventHandlerTracker.dispatchEvent(Object, Object, int, Object) line: 1	
	EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line: 230	
	ListenerQueue.dispatchEventSynchronous(int, Object) line: 148	
	EventAdminImpl.dispatchEvent(Event, boolean) line: 135	
	EventAdminImpl.sendEvent(Event) line: 78	
	EventComponent.sendEvent(Event) line: 39	
	EventBroker.send(String, Object) line: 81	
	UIEventPublisher.notifyChanged(Notification) line: 58	
	TrimmedWindowImpl(BasicNotifierImpl).eNotify(Notification) line: 374	
	TrimmedWindowImpl(UIElementImpl).setWidget(Object) line: 248	
	WBWRenderer(SWTPartRenderer).unbindWidget(MUIElement) line: 114	
	WBWRenderer(SWTPartRenderer).disposeWidget(MUIElement) line: 135	
	PartRenderingEngine.safeRemoveGui(MUIElement) line: 847	
	PartRenderingEngine.access$3(PartRenderingEngine, MUIElement) line: 775	
	PartRenderingEngine$8.run() line: 770	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.removeGui(MUIElement) line: 755	
	PartRenderingEngine.stop() line: 1081	
	Workbench.busyClose(boolean) line: 1121	
	Workbench.access$16(Workbench, boolean) line: 1001	
	Workbench$17.run() line: 1182	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	Workbench.close(int, boolean) line: 1180	
	Workbench.close() line: 1153	
	WorkbenchWindow.busyClose(boolean) line: 1164	
	WorkbenchWindow.access$14(WorkbenchWindow, boolean) line: 1137	
	WorkbenchWindow$10.run() line: 1193	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	WorkbenchWindow.close(boolean) line: 1191	
	WorkbenchWindow.close() line: 1203	
	WorkbenchWindow$6.close(MWindow) line: 446	
	WBWRenderer$11.shellClosed(ShellEvent) line: 575	
	TypedListener.handleEvent(Event) line: 98	
	EventTable.sendEvent(Event) line: 84	
	Shell(Widget).sendEvent(Event) line: 1053	
	Shell(Widget).sendEvent(int, Event, boolean) line: 1077	
	Shell(Widget).sendEvent(int, Event) line: 1062	
	Shell(Decorations).closeWidget() line: 309	
	Shell(Decorations).WM_CLOSE(int, int) line: 1694	
	Shell(Control).windowProc(int, int, int, int) line: 4530	
	Shell(Canvas).windowProc(int, int, int, int) line: 341	
	Shell(Decorations).windowProc(int, int, int, int) line: 1627	
	Shell.windowProc(int, int, int, int) line: 2069	
	Display.windowProc(int, int, int, int) line: 4976	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2541	
	Shell.callWindowProc(int, int, int, int) line: 498	
	Shell(Control).windowProc(int, int, int, int) line: 4623	
	Shell(Canvas).windowProc(int, int, int, int) line: 341	
	Shell(Decorations).windowProc(int, int, int, int) line: 1627	
	Shell.windowProc(int, int, int, int) line: 2069	
	Display.windowProc(int, int, int, int) line: 4976	
	OS.DefWindowProcW(int, int, int, int) line: not available [native method]	
	OS.DefWindowProc(int, int, int, int) line: 2541	
	Shell.callWindowProc(int, int, int, int) line: 498	
	Shell(Control).windowProc(int, int, int, int) line: 4623	
	Shell(Canvas).windowProc(int, int, int, int) line: 341	
	Shell(Decorations).windowProc(int, int, int, int) line: 1627	
	Shell.windowProc(int, int, int, int) line: 2069	
	Display.windowProc(int, int, int, int) line: 4976	
	OS.DispatchMessageW(MSG) line: not available [native method]	
	OS.DispatchMessage(MSG) line: 2546	
	Display.readAndDispatch() line: 3756	
	PartRenderingEngine$9.run() line: 1029	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 923	
	E4Workbench.createAndRunUI(MApplicationElement) line: 86	
	Workbench$5.run() line: 588	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 543	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	Application.start(IApplicationContext) line: 48	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 353	
	EclipseStarter.run(String[], Runnable) line: 180	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available	
	Method.invoke(Object, Object...) line: not available	
	Main.invokeFramework(String[], URL[]) line: 629	
	Main.basicRun(String[]) line: 584	
	Main.run(String[]) line: 1438	
	Main.main(String[]) line: 1414	


The direct calling code in WorkbenchWindow$1.handleEvent(Event) line: 286 looks like this:
MMenu menu = model.getMainMenu();
if (menu != null) {
	engine.removeGui(menu);
	model.setMainMenu(null);
}


In the debugger, I changed the passed argument (null) to have the value of the existing menu. The result is a workbench.xmi which contains the main menu.

Any further hint how I can make the workbench not to remove the main menu.

Frank
Re: Menu shows only with -clearPersistedState [message #1003970 is a reply to message #1003939] Tue, 22 January 2013 10:41 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for digging into this. It truly looks like an issue with the code as this deliberately removing the menu if it exists doesn't make sense to me. However I'm not familiar with the specific use case so please file a bug at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform&component=UI and reference this bug here also.
Re: Menu shows only with -clearPersistedState [message #1004258 is a reply to message #1003970] Tue, 22 January 2013 21:53 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
The bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398847
Re: Menu shows only with -clearPersistedState [message #1100752 is a reply to message #997140] Tue, 03 September 2013 14:46 Go to previous messageGo to next message
Wernke zur Borg is currently offline Wernke zur BorgFriend
Messages: 42
Registered: December 2011
Member
I am also running into this issue - has there been any development? Comment #10 in the bug report does not really help. The main menu stays invisible, even with a new Application.e4xmi that was started from Legacy.e4xmi.

Thanks for any hints or workarounds!

Wernke
Re: Menu shows only with -clearPersistedState [message #1110364 is a reply to message #1100752] Mon, 16 September 2013 19:46 Go to previous messageGo to next message
Eric Moffatt is currently offline Eric MoffattFriend
Messages: 118
Registered: July 2009
Senior Member

For reference here's the comment that helped with this issue:

"Frank, perhaps it's just a case of starting with a cut-down copy of the LegacyIDE.xmi ? For example the compatibility code has expectations like the main menu having the elementId "org.eclipse.ui.main.menu"...

You might try by creating a new starting model for your app from an initial copy of the LegacyIDE and cutting out some stuff (but leaving the ids in place).."

Basically, we're reliant on the ids of trim bars and such for the compat layer to work.
Re: Menu shows only with -clearPersistedState [message #1413327 is a reply to message #1110364] Thu, 28 August 2014 09:27 Go to previous message
Karl Puperze is currently offline Karl PuperzeFriend
Messages: 36
Registered: August 2011
Member
This is still a bug! The main menu is removed before the application model is persisted to disk. Next time you start without the -clearPersistedState option the main menu is missing. I use the following workaround.

1. Use a model processor to create an empty main menu and set the apply option in the extension point to "always".
public class MainMenuModelProcessor {

  @Inject
  MApplication application;
  
  @Inject
  EModelService modelService;
  
  @Execute
  public void execute() {
    MTrimmedWindow window = (MTrimmedWindow)this.modelService.find("window.main", this.application);
    if (window == null || window.getMainMenu() != null) {
      return;
    }
    
    window.setMainMenu(createEmptyMainMenu());
  }
  
  private MMenu createEmptyMainMenu() {
    final MMenu mainMenu = this.modelService.createModelElement(MMenu.class);
    mainMenu.setElementId("org.eclipse.ui.main.menu");
    return mainMenu;
  }
  
}


2. Add an empty main menu to your base application model with ID=org.eclipse.ui.main.menu (you need this for referencing in model fragments).
3. Create an application model fragment and set the apply option in the extension point to "always".
4. In the fragment create a model fragment for your main menu with feature=children and add all your main menu elements.

This way the main menu will always be added to the application model.
Previous Topic:Nothing to merge for "platform:/plugin/org.eclipse.e4.tools.emf.ui/fragment.e4xmi"???
Next Topic:[SOLVED] RCP: Part stack is removed when last part was closed
Goto Forum:
  


Current Time: Tue Apr 16 08:25:04 GMT 2024

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

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

Back to the top