Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » OleEditor for embedded editors doesn't work in RCP application
OleEditor for embedded editors doesn't work in RCP application [message #332891] Wed, 12 November 2008 22:06 Go to next message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Hi all,

I have a very simple rcp application with the default navigation view visible. It allows
user to open some Word/Excel/Pdf documents (and other ole embedded documents). When I
double click a file, the Ole Editor doesn't open correctly and throws the following exception.

//------------------
Could not open the editor: An unexpected exception was thrown.java.lang.NullPointerException
at
org.eclipse.ui.internal.editorsupport.win32.OleEditor.initia lizeWorkbenchMenus(OleEditor.java:512)
at ... win32.OleEditor.createPartControl(OleEditor.java:227)
at ... EditorReference.createPartHelper(EditorReference.java:661)
at ... EditorReference.createPart(EditorReference.java:428)
at ... WorkbenchPartReference.getPart(WorkbenchPartReference.java:5 94)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 6)
at ... PresentablePart.setVisible(PresentablePart.java:180)
at ... PresentablePartFolder.select(PresentablePartFolder.java:270)
at ... util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at ... bedStackPresentation.selectPart(TabbedStackPresentation.java :473)
at ... refreshPresentationSelection(PartStack.java:1256)
....
//------------------

1- I checked the dependencies and everythins seems to be there especially the
org.eclipse.ui.ide plugin and org.eclipse.swt.win32.win32.x86 fragment.

2- When I run my application outside of the RCP context, with the same plugins but in the
IDE, I don't have problem.


3- I debugged the OleEditor code and I found some problems in the initializeWorkbenchMenus
function (called by createPartControl of the OleEditor).

At the end of this mail I inserted the code of the initializeWorkbenchMenus function. It
throws the Java NullPointerException at line 29 (Id = null). I don't know why the
MenuManager returned by the item have a null ID?

Here is also the value of each variables during execution:

/*----------------
clientFrame = OleFrame instance (line 6)
shell = Shell instance (line 10)
menuBar = Menu instance (line 11)
windowMenu = [ null ] (line 18)
fileMenu = [ null ] (line 19)
containerItems = [] (line 20)
window = WorkbenchWindow instance (line 22)
menuBar.getItemCount() = 6 (line 24)

- For loop iteration 0: (line 24)
item = MenuItem (id=4308) (line 25)
item.getData() = MenuManager (id=4310) (line 27)
id = null (line 28)

----------------*/


1 /**
2 * Initialize the workbench menus for proper merging
3 */
4 protected void initializeWorkbenchMenus() {
5 //If there was an OLE Error or nothing has been created yet
6 if (clientFrame == null || clientFrame.isDisposed())
7 return;
8 // Get the browser menu bar. If one does not exist then
9 // create it.
10 Shell shell = clientFrame.getShell();
11 Menu menuBar = shell.getMenuBar();
12 if (menuBar == null) {
13 menuBar = new Menu(shell, SWT.BAR);
14 shell.setMenuBar(menuBar);
15 }
16
17 // Swap the file and window menus.
18 MenuItem[] windowMenu = new MenuItem[1];
19 MenuItem[] fileMenu = new MenuItem[1];
20 Vector containerItems = new Vector();
21
22 IWorkbenchWindow window = getSite().getWorkbenchWindow();
23
24 for (int i = 0; i < menuBar.getItemCount(); i++) {
25 MenuItem item = menuBar.getItem(i);
26 String id = ""; //$NON-NLS-1$
27 if (item.getData() instanceof IMenuManager)
28 id = ((IMenuManager) item.getData()).getId();
29 if (id.equals(IWorkbenchActionConstants.M_FILE))
30 fileMenu[0] = item;
31 else if (id.equals(IWorkbenchActionConstants.M_WINDOW))
32 windowMenu[0] = item;
33 else {
34 if (window.isApplicationMenu(id)) {
35 containerItems.addElement(item);
36 }
37 }
38 }
39 MenuItem[] containerMenu = new MenuItem[containerItems.size()];
40 containerItems.copyInto(containerMenu);
41 clientFrame.setFileMenus(fileMenu);
42 clientFrame.setContainerMenus(containerMenu);
43 clientFrame.setWindowMenus(windowMenu);
44 }

Any suggestion will be appreciate...

Thanks

Vincent
Re: OleEditor for embedded editors doesn't work in RCP application [message #332942 is a reply to message #332891] Fri, 14 November 2008 21:52 Go to previous message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Hi all,

I found the solution.

In the fillMenuBar function of my ApplicationActionBarAdvisor of my RCP I need to create
the MenuManagers, that will contains the main menus, with the appropriate
IWorkbenchActionConstants as parameter.

For example, instead of

final MenuManager fileMenuManager = new MenuManager("File");

Use:

final MenuManager fileMenuManager = new MenuManager("&File",
IWorkbenchActionConstants.M_FILE);

Vincent
Previous Topic:[Commands Framework] differentiating between view popup and toolbar
Next Topic:batik feature missing?
Goto Forum:
  


Current Time: Fri Apr 26 21:08:13 GMT 2024

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

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

Back to the top