Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamically resizing action in viewer
Dynamically resizing action in viewer [message #718969] Thu, 25 August 2011 12:51 Go to next message
Eclipse UserFriend
Hello,

I have a toolbar with an action in it. The text on the action changes when the user clicks on it. So what happens is that initially the text is only 8 characters, but when the user clicks on it, the length of the text increases to 15 characters. If the user clicks on it again, the text will return back to 8 characters. The action is right justified on the toolbar.

Normally I'd expect the button to resize to the left so the entire text can display, but it hasn't been doing so. Instead the button just disappears.

I tried doing a refresh on the viewer itself, but that doesn't cause the button to reappear.

Does anyone have any suggestions for how I can resolve this issue?

Thanks!
-upal
Re: Dynamically resizing action in viewer [message #719518 is a reply to message #718969] Sat, 27 August 2011 11:30 Go to previous messageGo to next message
Eclipse UserFriend
Are you creating the Action programmatically like so:

Action action = new Action("test") {
 @Override
 public void run() {
    if (getText().equals("test")) 
       setText("testing");
    else
       setText("test");
    }
};



Are you then adding it to a ToolBarManager like so:

ICoolBarManager ....

IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
coolBar.add(toolbar);
	
toolbar.add(action);


I'm confused how you embedded a toolbar within a viewer. How did you manage to do that? A JFace viewer displays lists, trees, and tables. They do not display a toolbar as well, so refreshing your viewer will not refresh a button that you have within the coolbar.

Hope this helps!



Re: Dynamically resizing action in viewer [message #719996 is a reply to message #719518] Mon, 29 August 2011 12:24 Go to previous message
Eclipse UserFriend
Hi Gator,

Thanks so much for your response. I think I might have just figured the issue out.

Here's what I did to get the actions into the toolbar:

IActionBars bars = getViewSite().getActionBars();
bars.getToolBarManager().add(myAction);


myAction was implemented the same way that you had listed and yes I was changing the text of myAction inside the run().

What I had to do to get the action to resize dynamically was the following:

IActionBars bars = getViewSite().getActionBars();
bars.getToolBarManager().update(true);


In hindsight, this seems like the obvious thing to do, but I guess at the time I hadn't thought to look at the other methods for the tool bar manager.

Hope this helps someone out.
-upal
Previous Topic:Open sourceFile In Edior from CommandLineInterface
Next Topic:Target Definition for all platforms with missing dependencies
Goto Forum:
  


Current Time: Thu Jul 10 05:32:25 EDT 2025

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

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

Back to the top