【发布时间】:2016-06-28 15:24:35
【问题描述】:
我正在向 Eclipse 添加一些功能,就像在 Eclipse 插件中一样
我有一个项目是复选框选择(见图)
final ListSelectionDialog dialog = new ListSelectionDialog(window.getShell(), list,
ArrayContentProvider.getInstance(), new LabelProvider(), "");
dialog.setTitle("Create Events");
dialog.setHelpAvailable(false);
dialog.setMessage("Potential events in code:");
dialog.create();
dialog.getOkButton().setText("Create");
dialog.open();
还有一个包含单选按钮的项目(我找不到像 ListSelectionDialog 这样的单选按钮
public void display(List<String> list){
Display.getDefault().asyncExec(new Runnable(){
public void run() {
Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
shell.setText("Create Object");
Label label = new Label(shell, SWT.NULL);
label.setText("Entry point: ");
for (String item: list){
Button btn = new Button(shell, SWT.RADIO);
btn.setText(item);
}
Composite composite = new Composite(shell, SWT.NULL);
composite.setLayout(new RowLayout());
Button createButton = new Button(composite, SWT.PUSH);
createButton.setText("Create");
Button cancelButton = new Button(composite, SWT.PUSH);
cancelButton.setText("Cancel");
shell.setSize(400, 200);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
shell.dispose ();
}
});
}
正如您所见,基于 SWT 的项目看起来格格不入,并且与 Eclipse 的 UI 不一致。 有没有可能让它看起来像另一个?
【问题讨论】:
-
所有 Eclipse 对话框都使用 SWT,通常也使用 JFace
Dialog,它提供了更高级别的接口,但基本上仍然是 SWT。我不清楚你关心对话的哪些部分。 -
第一,左上角图标不同第二,窗口的大小(我强制它为400,200)但并不理想(就像另一个窗口的自动检测大小一样)三、创建和取消按钮看起来不一样 另外,我假设我需要添加自己的监听器?到选定的收音机和取消/创建 btns?
-
使用JFace
Dialog,你可以使用同样的getOKButton()调用来改变OK按钮文本。
标签: java eclipse eclipse-plugin swt