|
Re: Adding a pulldown button to a view [message #518800 is a reply to message #517511] |
Fri, 05 March 2010 04:17 |
Marian Schedenig 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 |
Marian Schedenig 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.
|
|
|
Powered by
FUDForum. Page generated in 0.02933 seconds