[JFace] ToolBarManager and items with text [message #257612] |
Thu, 01 July 2004 15:05  |
Eclipse User |
|
|
|
I'm trying to create a toolbar that has a display similar to the perspective
toolbar in 3.0. That is, I would like an image on the left and text on the
right. I was able to accomplish this easliy with a ToolBar by using the
SWT.RIGHT. Now I'm using a ToolBarManager to handle my actions and laying
out my ToolBar and its not working.
I've tried creating the ToolBar (with the SWT.RIGHT style) and then creating
my ToolBarManager with it. I've also tried creating my ToolBarManager with
the SWT.RIGHT style and then letting it create the ToolBar
(createControl()). Either way, the ToolBar only ever has the images and
never the text.
Am I doing something incorrectly. Is this not supported by the
ToolBarManager? I would assume the ToolBarManager should respect whatever
style settings you used to create the Toolbar, so is it a bug?
regards,
-Chris
p.s. 3.0 rocks!
|
|
|
|
Re: [JFace] ToolBarManager and items with text [message #259892 is a reply to message #259874] |
Thu, 08 July 2004 18:05   |
Eclipse User |
|
|
|
Originally posted by: flo.ffxml.net
Hi again,
found a better way:
Instead of adding an action to to toolbarmanager like
toolbarmanager.add(new AddCustomerAction());
use this way:
ActionContributionItem addCustItem
= new ActionContributionItem(new AddCustomerAction());
addCustItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
toolbarmanager.add(addCustItem);
Or even better:
Subclass the toolbarmanager and override the add(IAction) method, to
force showing text for every added action:
public class IconWithTextToolBarManager extends ToolBarManager {
public IconWithTextToolBarManager() {
super();
}
public IconWithTextToolBarManager(int style) {
super(style);
}
public IconWithTextToolBarManager(ToolBar toolbar) {
super(toolbar);
}
public void add(IAction action) {
ActionContributionItem contributionItem
= new ActionContributionItem(action);
contributionItem.setMode(
ActionContributionItem.MODE_FORCE_TEXT);
add(contributionItem);
}
}
Greetings,
Florian
Florian Fankhauser wrote:
> Hi,
>
> I have the same problem. i found that the toolbarmanager does respect
> the toolbar style, but it does not set the toolitems text. When you set
> the text on the created tooitems manualy, it works. But doing this is
> not funny:
>
> toolbarmanager.createControl(shell).getItem(...).setText("... ");
>
> Anyone knows a better way?
>
> Greetings,
> Florian
>
> Chris wrote:
>
>> I'm trying to create a toolbar that has a display similar to the
>> perspective
>> toolbar in 3.0. That is, I would like an image on the left and text
>> on the
>> right. I was able to accomplish this easliy with a ToolBar by using the
>> SWT.RIGHT. Now I'm using a ToolBarManager to handle my actions and
>> laying
>> out my ToolBar and its not working.
>>
>> I've tried creating the ToolBar (with the SWT.RIGHT style) and then
>> creating
>> my ToolBarManager with it. I've also tried creating my ToolBarManager
>> with
>> the SWT.RIGHT style and then letting it create the ToolBar
>> (createControl()). Either way, the ToolBar only ever has the images and
>> never the text.
>>
>> Am I doing something incorrectly. Is this not supported by the
>> ToolBarManager? I would assume the ToolBarManager should respect
>> whatever
>> style settings you used to create the Toolbar, so is it a bug?
>>
>> regards,
>> -Chris
>>
>> p.s. 3.0 rocks!
>>
>>
|
|
|
Re: [JFace] ToolBarManager and items with text [message #260256 is a reply to message #259892] |
Fri, 09 July 2004 15:06  |
Eclipse User |
|
|
|
Wow, great! Thanks alot.
-Chris
"Florian Fankhauser" <flo@ffxml.net> wrote in message
news:cckgdb$bat$1@eclipse.org...
> Hi again,
>
> found a better way:
>
> Instead of adding an action to to toolbarmanager like
>
> toolbarmanager.add(new AddCustomerAction());
>
> use this way:
>
> ActionContributionItem addCustItem
> = new ActionContributionItem(new AddCustomerAction());
> addCustItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
>
> toolbarmanager.add(addCustItem);
>
> Or even better:
> Subclass the toolbarmanager and override the add(IAction) method, to
> force showing text for every added action:
>
> public class IconWithTextToolBarManager extends ToolBarManager {
>
> public IconWithTextToolBarManager() {
> super();
> }
>
> public IconWithTextToolBarManager(int style) {
> super(style);
> }
>
> public IconWithTextToolBarManager(ToolBar toolbar) {
> super(toolbar);
> }
>
> public void add(IAction action) {
> ActionContributionItem contributionItem
> = new ActionContributionItem(action);
> contributionItem.setMode(
> ActionContributionItem.MODE_FORCE_TEXT);
> add(contributionItem);
> }
> }
>
> Greetings,
> Florian
>
> Florian Fankhauser wrote:
>
> > Hi,
> >
> > I have the same problem. i found that the toolbarmanager does respect
> > the toolbar style, but it does not set the toolitems text. When you set
> > the text on the created tooitems manualy, it works. But doing this is
> > not funny:
> >
> > toolbarmanager.createControl(shell).getItem(...).setText("... ");
> >
> > Anyone knows a better way?
> >
> > Greetings,
> > Florian
> >
> > Chris wrote:
> >
> >> I'm trying to create a toolbar that has a display similar to the
> >> perspective
> >> toolbar in 3.0. That is, I would like an image on the left and text
> >> on the
> >> right. I was able to accomplish this easliy with a ToolBar by using
the
> >> SWT.RIGHT. Now I'm using a ToolBarManager to handle my actions and
> >> laying
> >> out my ToolBar and its not working.
> >>
> >> I've tried creating the ToolBar (with the SWT.RIGHT style) and then
> >> creating
> >> my ToolBarManager with it. I've also tried creating my ToolBarManager
> >> with
> >> the SWT.RIGHT style and then letting it create the ToolBar
> >> (createControl()). Either way, the ToolBar only ever has the images
and
> >> never the text.
> >>
> >> Am I doing something incorrectly. Is this not supported by the
> >> ToolBarManager? I would assume the ToolBarManager should respect
> >> whatever
> >> style settings you used to create the Toolbar, so is it a bug?
> >>
> >> regards,
> >> -Chris
> >>
> >> p.s. 3.0 rocks!
> >>
> >>
|
|
|
Powered by
FUDForum. Page generated in 1.06274 seconds