Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [SOLVED] Dynamically adding/removing actions to/from the ToolbarManager in form's header
icon14.gif  [SOLVED] Dynamically adding/removing actions to/from the ToolbarManager in form's header [message #656967] Tue, 01 March 2011 08:29 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi guys,

I have a SharedHeaderFormEditor with it's shared HeaderForm. I also have two IFormPages added to it. The head of the HeaderForm has set an icon and a text. I would like to add an Action to the shared HeaderForm when the second page is selected and remove this Action when it's unselected.

So I have this code in the second page:
    @Override
    public void setActive(boolean active) {
        super.setActive(active);
        if (active) {
            IManagedForm headerForm = ((SharedHeaderFormEditor) getEditor()).getHeaderForm();
            headerForm.getForm().getToolBarManager().add(getVerticalAction());
            headerForm.getForm().updateToolBar();
        } else {
            headerForm.getForm().getToolBarManager().remove(getVerticalAction().getId());
            headerForm.getForm().updateToolBar();
        }
    }

    private IAction getVerticalAction() {
        if (verticalAction == null) {
            verticalAction = new Action(null, Action.AS_RADIO_BUTTON) {

                @Override
                public void run() {
                    .....
                }
            };
            verticalAction.setId("verticalAction");
            verticalAction.setChecked(true);
            verticalAction.setToolTipText("vertical");
            verticalAction.setImageDescriptor(myImageDescriptor);
        }
        return verticalAction;
    }


This way the action is added/removed properly but the toolbar has gray background until I minimize and maximize or move the entire workbench window. I tried call all of this
                headerForm.reflow(true);
		headerForm.refresh();
		headerForm.getForm().getParent().redraw();
		headerForm.getForm().getParent().update();
		headerForm.getForm().getParent().layout();
		headerForm.getForm().getForm().getHead().redraw();
		headerForm.getForm().getForm().getHead().update();
         	headerForm.getForm().getForm().getHead().layout();
		headerForm.getForm().getForm().redraw();
		headerForm.getForm().getForm().update();
		headerForm.getForm().getForm().layout();


but nothing helps. Am I missing something about toolbars?

[Updated on: Thu, 03 March 2011 22:36]

Report message to a moderator

Re: Dynamically adding/removing actions to/from the ToolbarManager in form's header [message #657527 is a reply to message #656967] Thu, 03 March 2011 07:59 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Well, I found a solution. I don't think it's the best one, but it works.
http:// www.eclipse.org/forums/index.php?t=msg&goto=498927&S Q=58d3a06b66ce085709e4042769ca6b79&S=d5c9154eba75d3f8aa9 ac5bdcb3cbc45&
Previous Topic:Eclipse RCP Toolbar Icons do not update state on Mac OS X
Next Topic:How to customize perspective with editors?
Goto Forum:
  


Current Time: Thu Apr 25 17:01:52 GMT 2024

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

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

Back to the top