Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 378847

Summary: [e4] submit button is not shown in task editor toolbar
Product: [Eclipse Project] Platform Reporter: Steffen Pingel <steffen.pingel>
Component: SWTAssignee: 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.2Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 321278    
Attachments:
Description Flags
actual
none
expeted none

Description Steffen Pingel CLA 2012-05-08 10:42:07 EDT
After updating to I20120503-1800 I noticed that the submit button does not always show as expected in the task editor tool bar. It seems that the width of the control is reduced to two pixels. If I click those two pixels the submit is executed so the control seems to be there.
Comment 1 Steffen Pingel CLA 2012-05-08 10:42:36 EDT
Created attachment 215264 [details]
actual
Comment 2 Steffen Pingel CLA 2012-05-08 10:42:57 EDT
Created attachment 215265 [details]
expeted
Comment 3 Steffen Pingel CLA 2012-05-08 10:47:24 EDT
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;
	}

}
Comment 4 Paul Webster CLA 2012-05-08 12:23:25 EDT
Similar problem on linux to bug 377961

PW
Comment 5 Brian de Alwis CLA 2012-09-10 19:13:34 EDT
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.
Comment 6 Brian de Alwis CLA 2012-09-11 11:26:33 EDT
(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().
Comment 7 Brian de Alwis CLA 2012-09-11 11:30:13 EDT
Bug 293870 looks like a possible dupe.
Comment 8 Eric Williams CLA 2018-08-30 15:01:51 EDT
I cannot reproduce this issue on GTK3.22, 4.9M3, and Fedora 28.