Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamically resizing action in viewer
Dynamically resizing action in viewer [message #718969] Thu, 25 August 2011 16:51 Go to next message
upal  is currently offline upal
Messages: 6
Registered: July 2011
Junior Member

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?

Re: Dynamically resizing action in viewer [message #719518 is a reply to message #718969] Sat, 27 August 2011 15:30 Go to previous messageGo to next message
John Steele is currently offline John Steele
Messages: 33
Registered: June 2010
Location: Seattle, WA
Are you creating the Action programmatically like so:

Action action = new Action("test") {
 public void run() {
    if (getText().equals("test")) 

Are you then adding it to a ToolBarManager like so:

ICoolBarManager ....

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

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 16:24 Go to previous message
upal  is currently offline upal
Messages: 6
Registered: July 2011
Junior Member
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();

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();

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.
Previous Topic:Open sourceFile In Edior from CommandLineInterface
Next Topic:Target Definition for all platforms with missing dependencies
Goto Forum:

Current Time: Wed Oct 22 06:27:17 GMT 2014

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

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