Updating the toolbar with a new action [message #64698] |
Thu, 05 June 2003 17:27  |
Eclipse User |
|
|
|
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 11:29  |
Eclipse User |
|
|
|
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();
>
> }
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.05806 seconds