Home » Eclipse Projects » Eclipse 4 » Menu shows only with -clearPersistedState
Menu shows only with -clearPersistedState [message #997140] |
Thu, 03 January 2013 17:37  |
Eclipse User |
|
|
|
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 #1003939 is a reply to message #1003179] |
Tue, 22 January 2013 04:32   |
Eclipse User |
|
|
|
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 #1413327 is a reply to message #1110364] |
Thu, 28 August 2014 05:27  |
Eclipse User |
|
|
|
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.
|
|
|
Goto Forum:
Current Time: Tue Jul 22 18:36:44 EDT 2025
Powered by FUDForum. Page generated in 0.06038 seconds
|