Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Adding a pulldown button to a view
Adding a pulldown button to a view [message #517511] Mon, 01 March 2010 00:04 Go to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Hi!

Last time I wanted to do this, I was told it wasn't possible. But since
then, Galileo has been released, so I'm trying my luck again:

Is there any way to add a pulldown button to a view? I've been adding a
regular push button action to the console view using the viewContribution
extension, but I'd like to add a pulldown button which opens a custom menu
(created at runtime) to the same view, similar to the "Open Console" button
already created by the console view itself.

Cheers,
Marian.
Re: Adding a pulldown button to a view [message #518800 is a reply to message #517511] Fri, 05 March 2010 04:17 Go to previous message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Marian Schedenig wrote:

> Is there any way to add a pulldown button to a view? I've been adding a
> regular push button action to the console view using the viewContribution
> extension, but I'd like to add a pulldown button which opens a custom menu
> (created at runtime) to the same view, similar to the "Open Console"
> button already created by the console view itself.

Well, it seems I'm halfway there (unless I'm about to run into a dead end).

The PluginActionContributionItem created by the viewContribution extension
apparently doesn't support the IMenuCreator interface necessary to make a
pulldown button actually open a menu. But obviously, the console view's
toolbar can deal with menu creators once it gets them.

I was able to programmatically add an action to the console view's toolbar
with the following lines:

IToolBarManager manager =
consoleView.getViewSite().getActionBars().getToolBarManager( );
manager.appendToGroup("additions", new MyAction());
manager.update(true);

If MyAction implements IMenuCreator, this creates exactly the kind of button
I need. Now I can even do this from my plug-in's activator class, by getting
the console view from the workbench like this:

IWorkbenchWindow activeWorkbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
ConsoleView consoleView = (ConsoleView)
activePage.findView(IConsoleConstants.ID_CONSOLE_VIEW);

(plus checks for null pointers)

That works fine, too. The problem that remains is that, of course, my
activator doesn't get called until one of my classes is loaded for the first
time - which at this point isn't until the user clicks the action button
still (for now) included using the viewContribution.

So what's left is finding some way to get my plug-in initialised
automatically once the workbench has been loaded, so that I can add my
button to the console view *before* the user needs it.

Surely there must be some way to accomplish this? Any pointers appreciated.

Thanks,
Marian.
Re: Adding a pulldown button to a view [message #604893 is a reply to message #517511] Fri, 05 March 2010 04:17 Go to previous message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Marian Schedenig wrote:

> Is there any way to add a pulldown button to a view? I've been adding a
> regular push button action to the console view using the viewContribution
> extension, but I'd like to add a pulldown button which opens a custom menu
> (created at runtime) to the same view, similar to the "Open Console"
> button already created by the console view itself.

Well, it seems I'm halfway there (unless I'm about to run into a dead end).

The PluginActionContributionItem created by the viewContribution extension
apparently doesn't support the IMenuCreator interface necessary to make a
pulldown button actually open a menu. But obviously, the console view's
toolbar can deal with menu creators once it gets them.

I was able to programmatically add an action to the console view's toolbar
with the following lines:

IToolBarManager manager =
consoleView.getViewSite().getActionBars().getToolBarManager( );
manager.appendToGroup("additions", new MyAction());
manager.update(true);

If MyAction implements IMenuCreator, this creates exactly the kind of button
I need. Now I can even do this from my plug-in's activator class, by getting
the console view from the workbench like this:

IWorkbenchWindow activeWorkbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
ConsoleView consoleView = (ConsoleView)
activePage.findView(IConsoleConstants.ID_CONSOLE_VIEW);

(plus checks for null pointers)

That works fine, too. The problem that remains is that, of course, my
activator doesn't get called until one of my classes is loaded for the first
time - which at this point isn't until the user clicks the action button
still (for now) included using the viewContribution.

So what's left is finding some way to get my plug-in initialised
automatically once the workbench has been loaded, so that I can add my
button to the console view *before* the user needs it.

Surely there must be some way to accomplish this? Any pointers appreciated.

Thanks,
Marian.
Previous Topic:[Standalone app] Standalone app not displaying widgets
Next Topic:Hooking into the console's Document
Goto Forum:
  


Current Time: Fri Apr 26 21:56:07 GMT 2024

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

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

Back to the top