Craig
Craig

Reputation: 863

How do I open a new workbench window (with its own WorkbenchWindowAdvisor) from an existing workbench window?

I have a RCP applicaton from which I need to show a GEF Editor in a modal "dialog". But since the editor framework seems to be tightly coupled to the use of a workbench window etc I need to find a why to open a new workbench window (with its own WorkbenchWindowAdvisor etc) so that I can open my GEF editor within this workbench window. Once I get this workbenchWindow opened I will set the style of the WorkbenchWindow's shell to be application modal.

Upvotes: 1

Views: 1944

Answers (2)

Tonny Madsen
Tonny Madsen

Reputation: 12718

I have done this in a customer project using the following components:

  • A static class with a method openNewWindow(String type, ...). This is the method you call to open a new window. The type argument specifies the wanted type of window.
  • The class looks up the specified type via a new extension point to get an ILocalWorkbenchWindowAdvisor and the initial perspective ID.
  • It then saves the information in global variables and calls IWorkbench.openWorkbenchWindow(perspectiveID, ...)
  • In ApplicationWorkbenchAdvisor.createWorkbenchWindowAdvisor(...) a new advisor is create based on the saved ILocalWorkbenchWindowAdvisor - the returned advisor basically delegates all the postWindowCreate(...), etc to the same methods in ILocalWorkbenchWindowAdvisor...
  • If no ILocalWorkbenchWindowAdvisor is saved - which is the case for the very first window to be opened - the type "mainWindow" is looked up and used...

It works pretty well and let all parts of the project add new windows as needed.

Upvotes: 2

Prakash G. R.
Prakash G. R.

Reputation: 4892

Use the command "org.eclipse.ui.window.newWindow" to open a new window. In your WorkbenchWindowAdvisor.preWindowOpen(), set the shell style on the IWorkbenchWindowConfigurer to be application modal. You can also hide the coolbar, menu and status bars, so it looks more like a dialog than a window.

Upvotes: 0

Related Questions