Bug 187956 - [ActionSets] ActionContributionItem.MODE_FORCE_TEXT should apply to Buttons too
Summary: [ActionSets] ActionContributionItem.MODE_FORCE_TEXT should apply to Buttons too
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-05-19 06:21 EDT by Andras Varga CLA
Modified: 2007-12-11 13:00 EST (History)
3 users (show)

See Also:


Attachments
Patch to implement the requested functionality of displaying text in a Button when MODE_FORCE_TEXT is set. (4.02 KB, patch)
2007-09-20 23:33 EDT, Remy Suen CLA
no flags Details | Diff
Patch for HEAD (3.90 KB, patch)
2007-11-30 11:05 EST, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andras Varga CLA 2007-05-19 06:21:08 EDT
Build ID:  I20070503-1400

ActionContributionItem.MODE_FORCE_TEXT only applies when the widget is a ToolItem, but not for Buttons. Currently, Buttons (created with ActionContributionItem.fill(Composite)) only display the icon -- I would like them to display both icon and text if MODE_FORCE_TEXT is given.

Steps To Reproduce:
ActionContributionItem item = new ActionContributionItem(new MyAction());
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
item.fill(composite);


More information:
Indeed, currently getMode() is only called in the "if (widget instanceof ToolItem)" branch of update(), but not in the "if (widget instanceof Button)" branch.
Comment 1 Andras Varga CLA 2007-05-19 06:55:06 EDT
An ActionContributionItem(IAction action, int mode) constructor would be nice too.
Comment 2 Andras Varga CLA 2007-05-19 07:32:41 EDT
I would like a public getControl() [or getWidget()] method too, otherwise I cannot set layout data on the button. And/or, fill(Composite parent) could return the widget it has created.
Comment 3 Pavel Sklenak CLA 2007-05-25 08:12:54 EDT
(In reply to comment #2)
> I would like a public getControl() [or getWidget()] method too, otherwise I
> cannot set layout data on the button. And/or, fill(Composite parent) could
> return the widget it has created.
> 

exactly, it should be much easier than this:

new ActionContributionItem(action).fill(this);

Control [] children = this.getChildren();
for(int i = 0; i < children.length; i++){
    if(children[i].getData instanceof ActionContributionItem){
        Button button = (Button) children[i];
        button.setLayoutData(...);
    }

}
Comment 4 Remy Suen CLA 2007-09-20 23:33:46 EDT
Created attachment 78914 [details]
Patch to implement the requested functionality of displaying text in a Button when MODE_FORCE_TEXT is set.

(In reply to comment #1)
> An ActionContributionItem(IAction action, int mode) constructor would be nice
> too.

Paul? This doesn't sound that important to me although it would save a call to update().

(In reply to comment #2)
> I would like a public getControl() [or getWidget()] method too, otherwise I
> cannot set layout data on the button. And/or, fill(Composite parent) could
> return the widget it has created.

It'd have to be getWidget() since SWT Items aren't Controls.
Comment 5 Remy Suen CLA 2007-09-21 12:57:51 EDT
The API request in comment 2 and comment 3 seems to go back to bug 36446.
Comment 6 Paul Webster CLA 2007-11-30 11:05:17 EST
Created attachment 84188 [details]
Patch for HEAD

Remy, please have a look.

Thanx,
PW
Comment 7 Paul Webster CLA 2007-11-30 11:53:15 EST
Released in HEAD >20071130
PW
Comment 8 Markus Keller CLA 2007-12-02 19:45:03 EST
The Javadoc for ActionContributionItem.MODE_FORCE_TEXT should be updated as well.
Comment 9 Paul Webster CLA 2007-12-03 09:50:00 EST
Updated the javadoc to mention buttons as well.  Released to HEAD >20071203

PW
Comment 10 Paul Webster CLA 2007-12-11 13:00:45 EST
In I20071211-0010
PW