【发布时间】:2015-07-22 13:44:51
【问题描述】:
我正在编写一个 Eclipse 插件,它必须创建一个新项目。到目前为止这有效,但我需要将外部文件复制到项目文件夹中。我打算在我的一个 WizardPages 上有一个“浏览”按钮,它会打开一个文件对话框,用户可以在其中浏览文件,关闭对话框后,我可以使用该文件的路径进行各种操作。我的问题是对话窗口永远不会打开。现在我正在尝试这种方式(来自我的向导页面的 sn-p):
public void createControl(Composite composite) {
this.container = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
this.container.setLayout(layout);
layout.numColumns = 2;
Button browseButton = new Button(this.container, SWT.PUSH);
browseButton.setText("Browse");
browseButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
FileDialog fileDialog = new FileDialog(DataPage.this.container.getShell(), SWT.OPEN);
fileDialog.setText("JZOS created File");
String path = fileDialog.open();
DataPage.this.setJzosCreatedName(path);
}
});
我尝试了几种实现,我在示例和教程中看到过,但没有任何效果。我假设我给文件对话框的 Shell 有问题。我试图在widgetDefaultSelected 函数中打开一个新的Shell,但它也不起作用。有什么建议吗?
【问题讨论】:
标签: eclipse wizard filedialog