@Override
 public void addPage(IWizardPage page) {
   super.addPage(page);
   IWizardPage mainPage = getPage("basicNewProjectPage");
   if (mainPage instanceof WizardNewProjectCreationPage) {
     ((WizardNewProjectCreationPage) mainPage)
         .setInitialProjectName(getInitalProjectName().replace(" ", "_"));
   }
 }
  @Override
  public void addPages() {
    super.addPages();

    mainPage =
        new WizardNewProjectCreationPage("basicNewProjectPage") // $NON-NLS-1$
        {

          @Override
          public void createControl(Composite parent) {
            super.createControl(parent);
            validatePage();
          }

          @Override
          protected boolean validatePage() {
            boolean valid = super.validatePage();
            if (!valid) {
              return false;
            }

            // Check if there's already a directory/files at the destination
            IPath location = getLocationPath();
            if (useDefaults()) {
              // needs to append the project name since getLocationPath() returns the workspace path
              // in this case
              location = location.append(getProjectName());
            }

            File file = location.toFile();
            if (file.exists()) {
              setMessage(Messages.NewSampleProjectWizard_LocationExistsMessage, WARNING);
              return true;
            }

            setErrorMessage(null);
            setMessage(null);
            return true;
          }
        };
    mainPage.setTitle(Messages.NewSampleProjectWizard_ProjectPage_Title);
    mainPage.setDescription(Messages.NewSampleProjectWizard_ProjectPage_Description);
    addPage(mainPage);

    String name = sample.getName();
    if (name != null) {
      mainPage.setInitialProjectName(name);
    }
  }
Ejemplo n.º 3
0
  /**
   * Creates the sole wizard page contributed by this base implementation; the standard Eclipse
   * WizardNewProjectCreationPage.
   *
   * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String)
   */
  public void init(IWorkbench workbench, IStructuredSelection selection) {
    // Set default image for all wizard pages
    IPath path =
        new Path(
            org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIResourceBundle
                .NEW_PROJECT_WIZARD_PAGE_ICON);
    Bundle bundle =
        org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIPlugin.getDefault().getBundle();
    URL url = FileLocator.find(bundle, path, null);
    ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
    setDefaultPageImageDescriptor(descriptor);

    wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName);
    wizardNewProjectCreationPage.setTitle(pageTitle);
    wizardNewProjectCreationPage.setDescription(pageDescription);
    wizardNewProjectCreationPage.setInitialProjectName(pageProjectName);

    this.addPage(wizardNewProjectCreationPage);
    setWindowTitle(
        org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIResourceBundle
            .NEW_PROJECT_WIZARD_WINDOW_TITLE);
  }