Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to open views as action thru pull down menu
How to open views as action thru pull down menu [message #463261] Wed, 07 February 2007 14:47 Go to next message
Bill Blalock is currently offline Bill BlalockFriend
Messages: 119
Registered: July 2009
Location: Alabama
Senior Member
Good morning all:

I am probably overlooking the obvious but after a couple hours of search
and trying different things I'll ask for some help.

I am developing an RCP. Right now it has 2 views, call them ClientView
and ServerView.

I want the user to be able to select the view from the RCP pull down menu.
This is not a case of multiple instances of same view.

I can do this indirectly with this code:

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

private IWorkbenchAction exitAction;
private IWorkbenchAction preferenceAction;
private IContributionItem views;

public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}

protected void makeActions(final IWorkbenchWindow window) {
preferenceAction = ActionFactory.PREFERENCES.create(window);
exitAction = ActionFactory.QUIT.create(window);
views = ContributionItemFactory.VIEWS_SHORTLIST.create(window);

register(preferenceAction);
register(exitAction);
}

protected void fillMenuBar(IMenuManager menuBar) {
MenuManager fileMenu = new MenuManager("&File",
IWorkbenchActionConstants.M_FILE);

menuBar.add(fileMenu);

fileMenu.add(views);
fileMenu.add( new Separator() );
fileMenu.add(preferenceAction);
fileMenu.add( new Separator() );
fileMenu.add(exitAction);
}

The file menu has
- Other
- Preferences
- Exit

Other opens a dialog, the dialog shows the Client View and Server view,
and the user selects one of the two views.

I'd like to make the file menu have
- Client View
- Server View
- Preferences
- Exit

I tried to adapt the OpenViewsAction class presented in part 3 of Ed
Burnetts RCP tutorial but haven't be able to make it work.

Can anyone point me in the right direction?

I have "Building Commercial-Quality Plug-ins" by Clayberg & Rubel and
"Rich Client Platform" bye McAffer & Lemieux book. If anyone knows where
I should be looking in these books I'd appreciate it. I am sure the
answers are there ..

Thanks all
Bill
Re: How to open views as action thru pull down menu [message #463269 is a reply to message #463261] Wed, 07 February 2007 16:46 Go to previous message
Snjezana Peco is currently offline Snjezana PecoFriend
Messages: 789
Registered: July 2009
Senior Member
You have to make two actions.
You can open a view using:
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWindow().getActivePage();
page.showView(YOUR_VIEW_ID);

Snjeza

Bill Blalock wrote:
> Good morning all:
>
> I am probably overlooking the obvious but after a couple hours of search
> and trying different things I'll ask for some help.
>
> I am developing an RCP. Right now it has 2 views, call them ClientView
> and ServerView.
>
> I want the user to be able to select the view from the RCP pull down
> menu. This is not a case of multiple instances of same view.
>
> I can do this indirectly with this code:
>
> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>
> private IWorkbenchAction exitAction;
> private IWorkbenchAction preferenceAction;
> private IContributionItem views;
>
> public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
> super(configurer);
> }
>
> protected void makeActions(final IWorkbenchWindow window) {
> preferenceAction = ActionFactory.PREFERENCES.create(window);
> exitAction = ActionFactory.QUIT.create(window);
> views = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
>
> register(preferenceAction);
> register(exitAction);
> }
>
> protected void fillMenuBar(IMenuManager menuBar) {
> MenuManager fileMenu = new MenuManager("&File",
> IWorkbenchActionConstants.M_FILE);
>
> menuBar.add(fileMenu);
>
> fileMenu.add(views);
> fileMenu.add( new Separator() );
> fileMenu.add(preferenceAction);
> fileMenu.add( new Separator() );
> fileMenu.add(exitAction);
> }
>
> The file menu has
> - Other
> - Preferences
> - Exit
>
> Other opens a dialog, the dialog shows the Client View and Server view,
> and the user selects one of the two views.
>
> I'd like to make the file menu have
> - Client View
> - Server View
> - Preferences
> - Exit
>
> I tried to adapt the OpenViewsAction class presented in part 3 of Ed
> Burnetts RCP tutorial but haven't be able to make it work.
>
> Can anyone point me in the right direction?
>
> I have "Building Commercial-Quality Plug-ins" by Clayberg & Rubel and
> "Rich Client Platform" bye McAffer & Lemieux book. If anyone knows
> where I should be looking in these books I'd appreciate it. I am sure
> the answers are there ..
>
> Thanks all
> Bill
>
Previous Topic:ProgressBar in SplashScreen
Next Topic:Questions to MasterDetailsBlock
Goto Forum:
  


Current Time: Mon Oct 07 08:15:02 GMT 2024

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

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

Back to the top