切换到Eclipse Neon后,我注意到WorkbenchWindowControlContribution
没有完全显示。 Eclipse Mars 中没有任何问题。
由Label
和Text
组成的简单项目在霓虹灯中看起来如此:
该项目的代码如下:
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;
}
}
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>
这可能是霓虹灯的错误吗?
答案 0 :(得分:3)
是的,这是一个错误,在此报道:
Bug 471313 - toolbar:org.eclipse.ui.trim.status is not displayed correctly in Eclipse Mars
另外看一下这个,因为它关于工具栏,它更适合你的描述:
Bug 471326 - main toolbar control contributions is cut off
这是一种解决方法:
该课程应扩展<div v-for="item in (menu ? menu.items : [])">{{ item.text }}</div>
而不是ControlContribution
。
在WorkbenchWindowControlContribution
(替换YourApplicationName)中添加:YourApplicationNameActionBarAdvisor.fillCoolBar()