Bug 516021 - WorkbenchWindowControlContribution isn't fully shown in Eclipse Neon
Summary: WorkbenchWindowControlContribution isn't fully shown in Eclipse Neon
Status: CLOSED DUPLICATE of bug 471313
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-02 02:15 EDT by Denis Aristov CLA
Modified: 2017-05-16 07:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Aristov CLA 2017-05-02 02:15:06 EDT
After switching to Eclipe Neon I noticed that WorkbenchWindowControlContribution's aren't fully shown. There weren't any problems with them in Eclipse Mars.

A simple control consisting of a Label and a Text looks so in Neon:

https://i.stack.imgur.com/BDm1M.png


The code of the control is below:

package experiments;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;

public class ControlContributionItem extends WorkbenchWindowControlContribution {
    public static final String ID = "MyControlContributionItem"; //$NON-NLS-1$

    @Override
    protected Control createControl(Composite parent) {
        Composite rootComp = new Composite(parent, SWT.NONE);

        GridLayout gridLayout = new GridLayout(2, false);
        gridLayout.marginHeight = 0;
        gridLayout.verticalSpacing = 0;
        rootComp.setLayout(gridLayout);

        Label label = new Label(rootComp, SWT.NONE);
        label.setText("Label"); //$NON-NLS-1$

        Text text = new Text(rootComp, SWT.BORDER | SWT.READ_ONLY);
        text.setText("Text");
        GridData data = new GridData(SWT.FILL, SWT.CENTER, false, true);
        FontData fontData = text.getFont().getFontData()[0];
        Font boldFont = new Font(parent.getDisplay(), fontData.getName(), fontData.getHeight(), fontData.getStyle() | SWT.BOLD);
        text.setFont(boldFont);
        data.widthHint = 120;
        text.setLayoutData(data);

        rootComp.pack();

        return rootComp;
    }

}



The related part in plugin.xml

   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
         <toolbar
               id="MyControlContributionItem">
            <control
                  class="experiments.ControlContributionItem"
                  id="MyControlContributionItem">
            </control>
         </toolbar>
        </menuContribution>
    </extension>


Please, suggest a workaround ASAP. We have a lot of WorkbenchWindowControlContribution's which are cut off and we have a release this month.
Comment 1 Andrey Loskutov CLA 2017-05-02 03:11:18 EDT
(In reply to Denis Aristov from comment #0)
> After switching to Eclipe Neon I noticed that
> WorkbenchWindowControlContribution's aren't fully shown. There weren't any
> problems with them in Eclipse Mars.
> 
> A simple control consisting of a Label and a Text looks so in Neon:
> 
> https://i.stack.imgur.com/BDm1M.png
> 
> 
> The code of the control is below:

It would be great if you could create a simple plugin containing your snippet, so that it could be used for debugging the problem and verifying the fix. If you do, please attach to the bug 471313.

> Please, suggest a workaround ASAP. We have a lot of
> WorkbenchWindowControlContribution's which are cut off 

You can check bug 471313 comment 12, if this helps you in your environment.

> and we have a release this month.

Switching the platform *a month* before release? Good luck then :-)

*** This bug has been marked as a duplicate of bug 471313 ***
Comment 2 Denis Aristov CLA 2017-05-16 07:26:02 EDT
Thank you. The workaround works!


(In reply to Andrey Loskutov from comment #1)
> (In reply to Denis Aristov from comment #0)
> > After switching to Eclipe Neon I noticed that
> > WorkbenchWindowControlContribution's aren't fully shown. There weren't any
> > problems with them in Eclipse Mars.
> > 
> > A simple control consisting of a Label and a Text looks so in Neon:
> > 
> > https://i.stack.imgur.com/BDm1M.png
> > 
> > 
> > The code of the control is below:
> 
> It would be great if you could create a simple plugin containing your
> snippet, so that it could be used for debugging the problem and verifying
> the fix. If you do, please attach to the bug 471313.
> 
> > Please, suggest a workaround ASAP. We have a lot of
> > WorkbenchWindowControlContribution's which are cut off 
> 
> You can check bug 471313 comment 12, if this helps you in your environment.
> 
> > and we have a release this month.
> 
> Switching the platform *a month* before release? Good luck then :-)
> 
> *** This bug has been marked as a duplicate of bug 471313 ***