use of org.eclipse.titan.designer.wizards.GUIProjectImporter.IncludedProject in project titan.EclipsePlug-ins by eclipse.
the class TITANProjectImportWizard method performFinish.
@Override
public boolean performFinish() {
URI targetLocation = null;
if (!newProjectPage.useDefaults()) {
targetLocation = newProjectPage.getLocationURI();
}
final IProject newProject = GUIProjectImporter.createNewProject(newProjectPage.getProjectHandle(), mainPage.getInformation(), targetLocation);
if (newProject == null) {
final IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
if (description.isAutoBuilding() != wasAutoBuilding) {
description.setAutoBuilding(wasAutoBuilding);
try {
ResourcesPlugin.getWorkspace().setDescription(description);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Activator.getDefault().resumeHandlingResourceChanges();
return true;
}
try {
TITANNature.addTITANBuilderToProject(newProject);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
ProjectFileHandler pfHandler;
pfHandler = new ProjectFileHandler(newProject);
pfHandler.saveProjectSettings();
try {
newProject.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
BasicNewProjectResourceWizard.updatePerspective(config);
selectAndReveal(newProject);
final ProjectInformation information = mainPage.getInformation();
List<IncludedProject> includedProjects = information.getIncludedProjects();
if (!includedProjects.isEmpty() && (recursivelyPage == null || recursivelyPage.getRecursiveImport())) {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final List<String> processedProjectFiles = new ArrayList<String>();
processedProjectFiles.add(information.getSourceFile());
final List<IPath> projectFilesToBeProcessed = new ArrayList<IPath>();
for (IncludedProject includedProject : includedProjects) {
final IPath temp = includedProject.getAbsolutePath();
if (temp != null) {
projectFilesToBeProcessed.add(temp);
}
}
while (!projectFilesToBeProcessed.isEmpty()) {
IPath tempPath = projectFilesToBeProcessed.remove(projectFilesToBeProcessed.size() - 1);
if (processedProjectFiles.contains(tempPath.toOSString())) {
continue;
}
final GUIProjectImporter importer = new GUIProjectImporter();
final ProjectInformation tempProjectInformation = importer.loadProjectFile(tempPath.toOSString(), null, // false: not headless
false);
final IPath tempPath2 = tempPath.removeFileExtension();
final String includedProjectName = tempPath2.lastSegment();
IProject tempProject = workspace.getRoot().getProject(includedProjectName);
if (tempProject.exists()) {
continue;
}
tempProject = GUIProjectImporter.createNewProject(tempProject, tempProjectInformation, targetLocation);
if (tempProject == null) {
continue;
}
try {
TITANNature.addTITANBuilderToProject(tempProject);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
pfHandler = new ProjectFileHandler(tempProject);
pfHandler.saveProjectSettings();
try {
tempProject.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
includedProjects = tempProjectInformation.getIncludedProjects();
for (IncludedProject includedProject : includedProjects) {
final IPath temp = includedProject.getAbsolutePath();
if (temp != null) {
projectFilesToBeProcessed.add(temp);
}
}
}
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
final PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(null, newProject, GeneralConstants.PROJECT_PROPERTY_PAGE, null, null);
if (dialog != null) {
dialog.open();
}
final IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
if (description.isAutoBuilding() != wasAutoBuilding) {
description.setAutoBuilding(wasAutoBuilding);
try {
ResourcesPlugin.getWorkspace().setDescription(description);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Activator.getDefault().resumeHandlingResourceChanges();
}
});
return true;
}
Aggregations