Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Ordinary Button using ActionContributionItem
Ordinary Button using ActionContributionItem [message #465330] Wed, 28 March 2007 16:25 Go to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello List,

I'm trying to create a simple ordinary good old Button using a
ActionContributionItem and a Composite. When saying 'simple ordinary good
old Button' I mean not a Button inside a Coolbar or somewhere else where
it could hang out beeing somehow fancy.
I mean a gray button on a gray background somewhere on a View.

The Code:
buttonF1Action = new
ActionContributionItem(actionProvider.getFunction_F1()); buttonF1Action.setMode(ActionContributionItem.MODE_FORCE_TEX T);
buttonF1Action.fill(buttonF1);

Where buttonF1Action is a ActionContributionItem,
buttonfF1 is a Compoiste that is created juts like this:

buttonF1 = toolkit.createComposite(functionButtonComposite, SWT.NONE);
buttonF1.setLayout(new FillLayout());
buttonF1.setBackground(Display.getCurrent().getSystemColor(S WT.COLOR_WIDGET_BACKGROUND));
final GridData gd_buttonF1 = new GridData(SWT.FILL, SWT.FILL, true, false);
gd_buttonF1.heightHint = 35;
buttonF1.setLayoutData(gd_buttonF1);

So what ist the problem?
My problem is that the Button widget never displays both, the text AND the
image of the underlying action. I've searched a while and found some old
posts from 2003 handling the problem. I'm using Eclipse Version: 3.2.2
Build id: M20070212-1330 on Windows XP. Is it possible that this issue is
still not solved?

Or are I'm doing something fundamentally wrong? The only thing I want is a
Actions Image and Text side by side (image left, text right) on a 'simple
ordinary good old Button' :(

thanks & with best regards,
Jan
Re: Ordinary Button using ActionContributionItem [message #465337 is a reply to message #465330] Wed, 28 March 2007 17:38 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

it might be that fill(Composite) doesn't honour the MODE_FORCE_TEXT option.

Does the code for fill(Composite) have the same hooks as fill(ToolBar, int)?

PW


Re: Ordinary Button using ActionContributionItem [message #465420 is a reply to message #465337] Thu, 29 March 2007 07:48 Go to previous message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
No it does not the same :(
boolean showText = text != null && ((getMode() & MODE_FORCE_TEXT) != 0 ||
!hasImages(action));

is only called when widget is a ToolItem.

The only solution that came to my minde was to copy
ActionContributionItem. Sublassing was not possible because important
properties are private (like action - why not making the whole class final
than???).

In my copied call I changed inside update(String) the part: if
(textChanged) {}
In the original Class textChanged is always false when showing the widget
the forst time. The second time showing it also makes the text visible.

Could that be a Bug???

So I did nothing else than to delete the textChanged check and always set
the the button text.
// Change to original Class ActionContributionItem. Text is beeing always
set!
//if (textChanged) {
String text = action.getText();
if (text == null) {
text = ""; //$NON-NLS-1$
} else {
text = Action.removeAcceleratorText(text);
}
button.setText(text);
//}

As conclusion I must say that it would be usefull if someone coded the
MODE_FORCE_TEXT Flag also into the Button section of the class.
Previous Topic:problems with context sensitive help
Next Topic:Perspective
Goto Forum:
  


Current Time: Fri Apr 26 19:39:02 GMT 2024

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

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

Back to the top