如何将raido按钮和实现添加到BasicNewFileResourceWizard

时间:2019-06-26 08:37:29

标签: eclipse plugins eclipse-plugin eclipse-rcp

我有一个文件向导,该向导以编程方式创建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;
  }
}

1 个答案:

答案 0 :(得分:1)

您可以尝试覆盖WizardNewFileCreationPage createAdvancedControls方法:

@Override
protected void createAdvancedControls(Composite parent)
{
  super.createAdvancedControls(parent);

  ... add your controls here
}