使用noDefaultAndApplyButton()
删除了应用和恢复默认按钮,但我只需要删除恢复默认按钮。知道怎么做吗?
答案 0 :(得分:5)
调用noDefaultAndApplyButton()
取消默认按钮并覆盖contributeButtons
方法以添加您自己的“应用”按钮 - 您必须自己处理此按钮。
类似的东西:
@Override
protected void contributeButtons(final Composite parent)
{
final Button applyButton = new Button(parent, SWT.PUSH);
applyButton.setText("Apply");
final int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
final GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
final Point minButtonSize = applyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minButtonSize.x);
applyButton.setLayoutData(data);
applyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
performApply();
}
});
final GridLayout layout = (GridLayout)parent.getLayout();
layout.numColumns++;
}
更新: JFace的3.11版本在Eclipse 4.5(Mars)中添加了noDefaultButton()
方法,该方法仅关闭“恢复默认值”按钮。