if (!dotproject.exists()){
return Services.getMessage("project.dotproject.missing", folder);
}
// hacky, but I want to re-use the eclipse logic as much as possible.
WizardProjectsImportPage page = new WizardProjectsImportPage();
// construct a ProjectRecord
Constructor<WizardProjectsImportPage.ProjectRecord> construct =
WizardProjectsImportPage.ProjectRecord.class
.getDeclaredConstructor(WizardProjectsImportPage.class, File.class);
construct.setAccessible(true);
WizardProjectsImportPage.ProjectRecord record =
construct.newInstance(page, dotproject);
String projectName = record.getProjectName();
IProject project = ProjectUtils.getProject(projectName);
if(project.exists()){
return Services.getMessage("project.name.exists", projectName, folder);
}
// need to initialize the wizard page's 'createdProjects' list.
Field field = page.getClass().getDeclaredField("createdProjects");
field.setAccessible(true);
field.set(page, new ArrayList<IProject>());
// create the project from the ProjectRecord
Method method = page.getClass().getDeclaredMethod(
"createExistingProject",
WizardProjectsImportPage.ProjectRecord.class,
IProgressMonitor.class);
method.setAccessible(true);
Boolean result = (Boolean)method.invoke(page, record, new NullProgressMonitor());