用于导出文件的 Eclipse WizardPage
我想使用 Eclipse 插件的 ExportWizard 扩展点。我在弄清楚简单的文件对话框向导页面应该是什么样子时遇到一些困难。
public class ExportWizardPage extends WizardPage {
private FileDialog fileDialog=null;
protected ExportWizardPage(String pageName) {
super(pageName);
}
@Override
public void createControl(Composite parent) {
fileDialog = new FileDialog(parent.getShell(), SWT.SAVE);
fileDialog.setFilterExtensions(new String[] { "*.bm" });
}
}
我目前正在尝试像上面一样并使用 FileDialog 来选择目标文件。基本上它可以工作,对话框打开,我得到文件的名称,但是一旦对话框关闭,我就会得到一个异常。
org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:178)
我认为我错误地使用了这个 Wizard/WizardPage 机制,但我确实找不到一个简单的示例来向我展示某些东西应该是什么样子。
I want to use the exportWizard extension point for an eclipse plugin. I am having some difficulties figuring out how a simple filedialog wizard page should look like.
public class ExportWizardPage extends WizardPage {
private FileDialog fileDialog=null;
protected ExportWizardPage(String pageName) {
super(pageName);
}
@Override
public void createControl(Composite parent) {
fileDialog = new FileDialog(parent.getShell(), SWT.SAVE);
fileDialog.setFilterExtensions(new String[] { "*.bm" });
}
}
I am trying it currently like above and use a FileDialog for selecting the target file. Basically it works, the dialog is opened and I get the name of the file, but as soon the dialog closes I get an exception.
org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:178)
I think I am using this Wizard/WizardPage mechanism wrongly, but I really could not found a simple example that showed me how something should look like.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的向导页面不包含任何控件。您应该创建一个组合,然后将所有控件添加到其中(而不是直接添加
parent
)。调用setControl(..)
也是绝对必要的。它应该看起来像这样:Your wizard page does not contain any controls. You should create one composite and then add all your controls to it (and NOT
parent
directly). CallingsetControl(..)
is also absolutely required. It should look something like this: