Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Multiple windows for Eclipse RCP apps
Multiple windows for Eclipse RCP apps [message #461653] Mon, 15 January 2007 21:46 Go to next message
Eclipse UserFriend
Originally posted by: mgenovese.austin.rr.com

I have searched quite a long time trying to find some tangible answer to
my question: How do I implement multiple windows in an Eclipse RCP app?

I have see a few threads with not much concrete information. It sounds
like this can be done.....but how? I own the Eclipse RCP book (McAffer,
et al.), but also do not see it.

My app currently has one window, and I'd like a few (I'm greedy). In the
Application class extending IPlatformRunnable, run() contains:

display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display, new
ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IPlatformRunnable.EXIT_RESTART;
}
return IPlatformRunnable.EXIT_OK;
} finally {
display.dispose();
}

This is the default code generated for an app. I would think multiple
windows would be managed from this point, or in the
ApplicationWorkbenchAdvisor. However, in the ApplicationWorkbenchAdvisor
extending WorkbenchAdvisor, the default createWorkbenchWindowAdvisor()
just creates a new window advisor:

return new ApplicationWorkbenchWindowAdvisor(configurer);

After that point, it seems like I'm locked into a single-window
application....but it's not clear how to add another window with its own
perspective, and how to select which one opens at app start.

What I'd like for my app is an opening "Welcome" screen to appear that
allows the user to make a selection. Depending on that selection, one or
the other of the windows will appear. Each window has its own set of
menus, toolbars, perspectives, and views. Seems like using multiple
windows makes the most sense to me to address this configuration.

Any and all suggestions will be appreciated.

Thanks,

Matt
--
Re: Multiple windows for Eclipse RCP apps [message #461669 is a reply to message #461653] Tue, 16 January 2007 06:12 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Does IWorkbenchWindow.openPage(null) do what you want?

Alex.
Re: Multiple windows for Eclipse RCP apps [message #461783 is a reply to message #461669] Wed, 17 January 2007 05:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mgenovese.austin.rr.com

Alex,

First off, thanks for the reply - much appreciated.

Second to answer your question, I'm not sure. It looks like it opens a
new page (per the documentation), and we can only have one page per
window, so I suppose it opens a new window. But it's not clear to me if
this is the *intended* approach for handling multi-window applications
for Eclipse RCP projects.

Has anyone developed multi-window apps? I'm looking for the *best* way
to handle this. I realize there may be a bunch of possible ways to do
it, but I'm guessing the Eclipse developers already thought this through
and have a *BEST* answer in mind for multi-window apps.

To summarize, I want an Eclipse RCP app which can open of several
possible windows, each with its own perspective, views, menus, coolbars,
etc. I only need one window open at a time; it's a single threaded app.

If IWorkbenchWindow.openPage(null) is the defacto solution for this
problem, how should it be used programmatically?

Thanks much,

Matt
--


Alex Blewitt wrote:
> Does IWorkbenchWindow.openPage(null) do what you want?
>
> Alex.

Matt Genovese wrote:
> I have searched quite a long time trying to find some tangible answer to my question: How do I implement multiple windows in an Eclipse RCP app?
>
> I have see a few threads with not much concrete information. It sounds like this can be done.....but how? I own the Eclipse RCP book (McAffer, et al.), but also do not see it.
>
> My app currently has one window, and I'd like a few (I'm greedy). In the Application class extending IPlatformRunnable, run() contains:
>
> display = PlatformUI.createDisplay();
> try {
> int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
> if (returnCode == PlatformUI.RETURN_RESTART) {
> return IPlatformRunnable.EXIT_RESTART;
> }
> return IPlatformRunnable.EXIT_OK;
> } finally {
> display.dispose();
> }
>
> This is the default code generated for an app. I would think multiple windows would be managed from this point, or in the ApplicationWorkbenchAdvisor. However, in the ApplicationWorkbenchAdvisor extending WorkbenchAdvisor, the default createWorkbenchWindowAdvisor() just creates a new window advisor:
>
> return new ApplicationWorkbenchWindowAdvisor(configurer);
>
> After that point, it seems like I'm locked into a single-window application....but it's not clear how to add another window with its own perspective, and how to select which one opens at app start.
>
> What I'd like for my app is an opening "Welcome" screen to appear that allows the user to make a selection. Depending on that selection, one or the other of the windows will appear. Each window has its own set of menus, toolbars, perspectives, and views. Seems like using multiple windows makes the most sense to me to address this configuration.
>
> Any and all suggestions will be appreciated.
> Thanks,
>
> Matt
> --
Re: Multiple windows for Eclipse RCP apps [message #461792 is a reply to message #461783] Wed, 17 January 2007 10:37 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
I'm afraid I don't understand your points ... and I can't give you 'best' advice.

What I can observe is that the functionality that you want -- having one window open at a time -- is in direct violation of being able to open more than one window. Each window will be its own separate look into the UI and will be open all the time; so if you want only one window, don't open other windows.

It really sounds like you should be using perspectives, so that each perspective is its own perspective, and that you implement some functionality (perhaps, under a menu entitled 'window' to appease users) of being able to switch the current page's perspective to something else, using the IWorkbenchPage's 'setPerspective' call. That way, you could have a single window, but then change how that window looked based on what the user did.

Anyway, your choices like between one of the following:

1) Having a single window, and then using setPerspective to switch between perspectives (recommended)
2) Having multiple windows, each with their own perspectives (recommended)
3) Open a new window for each perspective switch, and close the old window (not recommended)

Which one you pick will be up to you. If you want people to Alt+Tab between windows, and you want to allow the user to have more than one window open at once, I'd recommend 2. If you only want there to be a single visible window, then I'd recommend 1. I wouldn't recommend 3, because you'll lose things like e.g. window placement/sizing.

As for calling it in code ... just get the workbench page, and call the methods:

view.getViewSite().getPage().openPage(null);
// or
view.getViewSite().getPage().setPerspective(
  view.getWorkbench().getPerspectiveRegistry().
    findPerspectiveWithId("org.example.perspective.id")
)


Alex.
Re: Multiple windows for Eclipse RCP apps [message #461888 is a reply to message #461792] Wed, 17 January 2007 20:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mgenovese.austin.rr.com

Alex,

Thanks again for your reply.

I'll inline my comments below:

Alex Blewitt wrote:
> I'm afraid I don't understand your points ... and I can't give you 'best' advice.
>
> What I can observe is that the functionality that you want -- having one window open at a time -- is in direct violation of being able to open more than one window. Each window will be its own separate look into the UI and will be open all the time; so if you want only one window, don't open other windows.


You're absolutely right. I modified my original wish that I want
multiple windows open. In fact, one window at a time should be
sufficient for my particular application. Initially I was speaking more
generally about multi-window RCP apps.

>
> It really sounds like you should be using perspectives, so that each perspective is its own perspective, and that you implement some functionality (perhaps, under a menu entitled 'window' to appease users) of being able to switch the current page's perspective to something else, using the IWorkbenchPage's 'setPerspective' call. That way, you could have a single window, but then change how that window looked based on what the user did.


Well, I am currently using perspectives for organizing or enabling my
various views. I suppose the issue I have stems from my app's intent.

The application I'm building has various "mini-apps" embedded in the
single app, for lack of a better term. From the invocation of the main
app, the user is presented with a "Welcome" perspective to select what
to do. Based on the user's selection, the right mini-app is
started....which currently involves switching to another perspective in
that same window. The mini-app can be "exited", which just means I
switch back to the Welcome perspective. Easy enough, at least for
perspectives. However, things like toolbars and menus that were created
in the selected mini-app tag along back to the Welcome perspective. I
want each perspective to have its own menus, toolbars, etc. So I
thought the best way to accomplish this was to have dedicated windows
for each mini-app, instead of switching between perspectives in the
single window.

Is there a better way accomplish this without opening new windows?

>
> Anyway, your choices like between one of the following:
>
> 1) Having a single window, and then using setPerspective to switch between perspectives (recommended)
> 2) Having multiple windows, each with their own perspectives (recommended)
> 3) Open a new window for each perspective switch, and close the old window (not recommended)
>
> Which one you pick will be up to you. If you want people to Alt+Tab between windows, and you want to allow the user to have more than one window open at once, I'd recommend 2. If you only want there to be a single visible window, then I'd recommend 1. I wouldn't recommend 3, because you'll lose things like e.g. window placement/sizing.
>
> As for calling it in code ... just get the workbench page, and call the methods:
>
>
> view.getViewSite().getPage().openPage(null);
> // or
> view.getViewSite().getPage().setPerspective(
>   view.getWorkbench().getPerspectiveRegistry().
>     findPerspectiveWithId("org.example.perspective.id")
> )
> 

>

Thanks again very much for the code. Please let me know if there's
another way I should be going about this (using a single window versus
multiple windows) in order maintain menus, toolbars, etc.

> Alex.

Cheers,

Matt
--
Re: Multiple windows for Eclipse RCP apps [message #553197 is a reply to message #461888] Mon, 16 August 2010 16:29 Go to previous messageGo to next message
eshvar60  is currently offline eshvar60 Friend
Messages: 51
Registered: March 2010
Member
Hey Matt,
I am having the exact same issue right now as you. I have mini-apps that should have their own perspectives, views and toolbars. Have you found a good solution to this problem?

Are you currently using perspectives for this? How is that working out? Can you detach each mini-app somehow and run it in its own window(like a view)?

Thanks
Eugene
Re: Multiple windows for Eclipse RCP apps [message #553509 is a reply to message #461792] Tue, 17 August 2010 18:19 Go to previous message
eshvar60  is currently offline eshvar60 Friend
Messages: 51
Registered: March 2010
Member
Hey Alex,

Is it possible to have multiple windows open under one workbench? Right now when I call openWorkbenchWindow a new window with its own menu bar and toolbar is opened. Is it possible to have something similar to Photoshop where each window is separate but inside the main workbench?

So each window would share a common toolbar, and console view but everything else inside that window should stay with it.

Thanks
Eugene
Previous Topic:Export an RCP Product with Features: Validation failes
Next Topic:NullPointerException in ApplicationActionBarAdvisor
Goto Forum:
  


Current Time: Thu Mar 28 21:08:18 GMT 2024

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

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

Back to the top