如何向基本文件资源向导添加单选按钮和实现
How to add raido button and implementation to BasicNewFileResourceWizard
我有一个文件向导,它以编程方式创建 css 文件。我想在底部添加附加组件,如 raio 按钮或复选框。有没有办法在这里添加它及其基本实现。还是我应该创建自定义向导?
public class MyNewFileWizard extends BasicNewFileResourceWizard
{
WizardNewFileCreationPage mainPage;
public static final String WIZARD_ID = "ui.wizard.MyNewFileWizard";
public MyNewFileWizard()
{
super();
}
@Override
public void addPages()
{
mainPage = new WizardNewFileCreationPage("New File Page", getSelection())
{
@Override
protected InputStream getInitialContents()
{
StringBuilder sb = new StringBuilder();
sb.append("SAMPLE_README_FILE");
return new ByteArrayInputStream(sb.toString().getBytes());
}
};
mainPage.setFileExtension("css");
addPage(mainPage);
}
@Override
public boolean performFinish()
{
IFile file = mainPage.createNewFile();
if (file == null) {
return false;
}
selectAndReveal(file);
// Open editor on new file.
IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
}
}
catch (PartInitException e) {
//openError(dw.getShell(), "Problems opening editor", e.getMessage(), e);
}
return true;
}
}
您可以尝试覆盖 WizardNewFileCreationPage
createAdvancedControls
方法:
@Override
protected void createAdvancedControls(Composite parent)
{
super.createAdvancedControls(parent);
... add your controls here
}
我有一个文件向导,它以编程方式创建 css 文件。我想在底部添加附加组件,如 raio 按钮或复选框。有没有办法在这里添加它及其基本实现。还是我应该创建自定义向导?
public class MyNewFileWizard extends BasicNewFileResourceWizard
{
WizardNewFileCreationPage mainPage;
public static final String WIZARD_ID = "ui.wizard.MyNewFileWizard";
public MyNewFileWizard()
{
super();
}
@Override
public void addPages()
{
mainPage = new WizardNewFileCreationPage("New File Page", getSelection())
{
@Override
protected InputStream getInitialContents()
{
StringBuilder sb = new StringBuilder();
sb.append("SAMPLE_README_FILE");
return new ByteArrayInputStream(sb.toString().getBytes());
}
};
mainPage.setFileExtension("css");
addPage(mainPage);
}
@Override
public boolean performFinish()
{
IFile file = mainPage.createNewFile();
if (file == null) {
return false;
}
selectAndReveal(file);
// Open editor on new file.
IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
}
}
catch (PartInitException e) {
//openError(dw.getShell(), "Problems opening editor", e.getMessage(), e);
}
return true;
}
}
您可以尝试覆盖 WizardNewFileCreationPage
createAdvancedControls
方法:
@Override
protected void createAdvancedControls(Composite parent)
{
super.createAdvancedControls(parent);
... add your controls here
}