| Summary: | [e4] submit button is not shown in task editor toolbar | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Steffen Pingel <steffen.pingel> | ||||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||||
| Status: | CLOSED WORKSFORME | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | arunkumar.thondapu, bsd, emoffatt, ericwill, gheorghe, mik.kersten, pwebster | ||||||
| Version: | 4.2 | Keywords: | triaged | ||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 321278 | ||||||||
| Attachments: |
|
||||||||
|
Description
Steffen Pingel
Created attachment 215264 [details]
actual
Created attachment 215265 [details]
expeted
Interestingly, the button sometimes shows up correctly but I haven't quite determined the steps. Below is the code that contributes the button in AbstractTaskEditorPage. This is a pretty major regression for Mylyn since this button is important in terms of usability of the task editor.
pre..
public void fillToolBar(IToolBarManager toolBarManager) {
ToolBarButtonContribution submitButtonContribution = new ToolBarButtonContribution(
"org.eclipse.mylyn.tasks.toolbars.submit") { //$NON-NLS-1$
@Override
protected Control createButton(Composite composite) {
submitButton = new Button(composite, SWT.FLAT);
submitButton.setText(Messages.TaskEditorActionPart_Submit + " "); //$NON-NLS-1$
submitButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_SUBMIT));
submitButton.setBackground(null);
submitButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
doSubmit();
}
});
return submitButton;
}
};
submitButtonContribution.marginLeft = 10;
toolBarManager.add(submitButtonContribution);
}
public abstract class ToolBarButtonContribution extends ControlContribution {
public int marginLeft = 0;
public int marginRight = 0;
protected ToolBarButtonContribution(String id) {
super(id);
}
protected abstract Control createButton(Composite parent);
@Override
protected Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setBackground(null);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
if (Platform.WS_CARBON.equals(SWT.getPlatform())) {
layout.marginTop = -3;
}
layout.marginLeft = this.marginLeft;
layout.marginRight = this.marginRight;
composite.setLayout(layout);
Control button = createButton(composite);
int heigtHint = SWT.DEFAULT;
if (Platform.WS_WIN32.equals(SWT.getPlatform())) {
heigtHint = 22;
} else if (Platform.WS_CARBON.equals(SWT.getPlatform())) {
heigtHint = 32;
}
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).hint(SWT.DEFAULT, heigtHint).applyTo(button);
return composite;
}
}
Similar problem on linux to bug 377961 PW I've had a similar sounding problem on Linux —- in this case we had two toolbar contribution controls with <visibleWhen> expressions that show/hide the controls for different editor types. Switching from one particular editor type to another would result in one control being 0-pixels wide. The workaround is to do a pack() in #createControl(). I notice that ToolContributionRenderer#createWidget() does a pack(), but ControlContribution#fill() does not; ControlContribution is used for compatibility WorkbenchWindowControlContributions. (In reply to comment #5) > I notice that ToolContributionRenderer#createWidget() does a pack(), but > ControlContribution#fill() does not; ControlContribution is used for > compatibility WorkbenchWindowControlContributions. ControlContribution#fill(): public final void fill(ToolBar parent, int index) { Control control = createControl(parent); if (control == null) { Policy.logException(new IllegalStateException( "createControl(Composite) of " + getClass() //$NON-NLS-1$ + " returned null, cannot fill toolbar")); //$NON-NLS-1$ } else { ToolItem ti = new ToolItem(parent, SWT.SEPARATOR, index); ti.setControl(control); ti.setWidth(computeWidth(control)); } } ToolContributionRenderer#createWidget(): public Object createWidget(final MUIElement element, Object parent) { ... if (sep != null && newCtrl != null) { sep.setControl(newCtrl); newCtrl.pack(); sep.setWidth(newCtrl.getSize().x); } ... } The pack was introduced in a bug fix from me, apparently :) I'd suggest that, if a pack() fixes the Mylyn button issue, that we add a pack() to ContributionControl#fill(). Bug 293870 looks like a possible dupe. I cannot reproduce this issue on GTK3.22, 4.9M3, and Fedora 28. |