Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Updating the toolbar with a new action
Updating the toolbar with a new action [message #64698] Thu, 05 June 2003 21:27 Go to next message
Eclipse UserFriend
Originally posted by: jverhaeg.metamatrix.com

I'm trying to add a new action to the toolbar in the setActivePage method of
my own MultiPageEditorActionBarContributer contribution. I need to add the
action in this method vs. the contributeToToolBar method because the action
I'm adding, the GEF zoom-in action, requires a ZoomManager, which is
accessible from my "page" editor, not the parent multi-page editor. Plus, I
want the action to appear only when my GEF page is active, and not when
other pages within the editor are active. I've run into a couple of
problems, the first of which I have an apparent solution for, but I'm not
sure if it's really the correct way to do this.

1) The toolbar manager is actually a CoolItemMultiToolBarManager, and when I
add an action to it, the action doesn't seem to really get added unless I
also call createCoolBarContributionItems(). Is this correct, or is there a
better way to do this?

2) I can't get the toolbar to update immediately to show the action I just
added. If I click on a view, the action suddenly appears within a draggable
toolbar. How do I get the action to show up right away?

Below is a snippet of the code in my setActivePage method:

// Remove old actions

final IToolBarManager toolbarMgr = getActionBars().getToolBarManager();

if (this.actionGrp != null) {

toolbarMgr.remove(this.actionGrp);

}

// Add new actions to toolbar manager

this.actionGrp = new GroupMarker(GROUP);

toolbarMgr.add(this.actionGrp);

final ZoomManager zoomMgr =
(ZoomManager)activeEditorPage.getAdapter(ZoomManager.class);

final ZoomInAction zoomInAction = new ZoomInAction(zoomMgr);

final ActionContributionItem item = new
ActionContributionItem(zoomInAction);

toolbarMgr.appendToGroup(this.actionGrp.getGroupName(), item);

if (toolbarMgr instanceof CoolItemMultiToolBarManager) {


((CoolItemMultiToolBarManager)toolbarMgr).createCoolBarContr ibutionItems();

}
Re: Updating the toolbar with a new action [message #69500 is a reply to message #64698] Tue, 10 June 2003 15:29 Go to previous message
Eclipse UserFriend
Originally posted by: lynne_kues.oti.com

No, you should not be calling createCoolBarContributionItems()!
CoolItemMultiToolBarManager is an internal class. You should only useAPI
that is defined for ToolBarManager and above. You can use the
update(boolean) method defined in ToolBarManager to get your item to show.

"JPAV" <jverhaeg@metamatrix.com> wrote in message
news:bbocj9$qeb$1@rogue.oti.com...
> I'm trying to add a new action to the toolbar in the setActivePage method
of
> my own MultiPageEditorActionBarContributer contribution. I need to add
the
> action in this method vs. the contributeToToolBar method because the
action
> I'm adding, the GEF zoom-in action, requires a ZoomManager, which is
> accessible from my "page" editor, not the parent multi-page editor. Plus,
I
> want the action to appear only when my GEF page is active, and not when
> other pages within the editor are active. I've run into a couple of
> problems, the first of which I have an apparent solution for, but I'm not
> sure if it's really the correct way to do this.
>
> 1) The toolbar manager is actually a CoolItemMultiToolBarManager, and when
I
> add an action to it, the action doesn't seem to really get added unless I
> also call createCoolBarContributionItems(). Is this correct, or is there
a
> better way to do this?

>
> 2) I can't get the toolbar to update immediately to show the action I just
> added. If I click on a view, the action suddenly appears within a
draggable
> toolbar. How do I get the action to show up right away?
>
> Below is a snippet of the code in my setActivePage method:
>
> // Remove old actions
>
> final IToolBarManager toolbarMgr = getActionBars().getToolBarManager();
>
> if (this.actionGrp != null) {
>
> toolbarMgr.remove(this.actionGrp);
>
> }
>
> // Add new actions to toolbar manager
>
> this.actionGrp = new GroupMarker(GROUP);
>
> toolbarMgr.add(this.actionGrp);
>
> final ZoomManager zoomMgr =
> (ZoomManager)activeEditorPage.getAdapter(ZoomManager.class);
>
> final ZoomInAction zoomInAction = new ZoomInAction(zoomMgr);
>
> final ActionContributionItem item = new
> ActionContributionItem(zoomInAction);
>
> toolbarMgr.appendToGroup(this.actionGrp.getGroupName(), item);
>
> if (toolbarMgr instanceof CoolItemMultiToolBarManager) {
>
>
>
((CoolItemMultiToolBarManager)toolbarMgr).createCoolBarContr ibutionItems();
>
> }
>
>
>
Previous Topic:debug variables not showing up
Next Topic:Want to add a new toolbar to...
Goto Forum:
  


Current Time: Fri Jul 19 22:25:41 GMT 2024

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

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

Back to the top