当我将一个新项目添加到一个比当前所选字符串长的字符串的组合中时,文本在Ubuntu中不在组合中,但在Windows中一切正常。
添加新项目后,如何刷新/更新/调整控件/工具栏的大小?
为什么在Ubuntu中组合之外的文本?
我在org.eclipse.ui
中的扩展名:
<menuContribution
allPopups="true"
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=connections">
<toolbar id="ru.mycompany.rg.toolbarPINConnections">
<control
class="ru.mycompany.rg.custom.PINConnectionsControl"
id="PINConnectionsControl">
</control>
</toolbar>
</menuContribution>
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
...
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
coolBar.add(new CoolItemGroupMarker("connections"));
}
我在工具栏上的控件:
public class PINConnectionsControl extends WorkbenchWindowControlContribution implements PropertyChangeListener, PrefConstants {
private ComboViewer combo;
@Override
protected Control createControl(Composite parent) {
IPreferenceNode connectionsPreferenceNode = integrationNode.findSubNode(PINListConnectionsPreferenceNode.ID);
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout(SWT.HORIZONTAL));
combo = new ComboViewer(container, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
combo.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ConItem) {
ConItem current = (ConItem) element;
return current.getLabel();
}
return "";
}
});
combo.setContentProvider(new ObservableListContentProvider());
combo.setInput(PINListConnectionsModel.getInstance().getPINConnections());
for(ConItem item:PINListConnectionsModel.getInstance().getPINConnections()) {
if(sCon.equals(item.getValue())) {
ISelection selection = new StructuredSelection(item);
combo.setSelection(selection);
break;
}
}
((PINListConnectionsPreferenceNode)connectionsPreferenceNode).addConListener(this);
//@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=471313
parent.getParent().setRedraw(true);
return container;
}
@Override
public boolean isDynamic() {
return true;
}
@Override
public void propertyChange(java.beans.PropertyChangeEvent event) {
for(ConItem item:PINListConnectionsModel.getInstance().getPINConnections()) {
if(event.getNewValue().equals(item.getValue())) {
ISelection selection = new StructuredSelection(item);
combo.setSelection(selection);
break;
}
}
}
}