下面列出了org.eclipse.ui.actions.ReadOnlyStateChecker#org.eclipse.core.resources.IWorkspaceRunnable 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected IProject createDummyAbapProject(String projectName) throws CoreException{
String destinationId = projectName;
IDestinationDataWritable data = AdtDestinationDataFactory.newDestinationData(destinationId);
data.setUser("TEST_DUMMY_USER");
data.setClient("777");
data.setLanguage("DE");
data.setPassword("TEST_DUMMY_PW");
String projectDestinationId = AdtProjectServiceFactory.createProjectService().createDestinationId(projectName);
final IDestinationData destinationData = data.getReadOnlyClone(projectDestinationId);
final IAbapProjectService abapProjectService = AdtProjectServiceFactory.createProjectService();
//IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final AbapProject[] projects = new AbapProject[1];
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
projects[0] = (AbapProject) abapProjectService.createAbapProject(projectName, destinationData, monitor);
}
}, new NullProgressMonitor());
return projects[0].getProject();
}
protected IProject createDummyAbapProject() throws CoreException{
String projectName = "ABAPGIT_TEST_PROJECT";
String destinationId = "ABAPGIT_TEST_PROJECT";
IDestinationDataWritable data = AdtDestinationDataFactory.newDestinationData(destinationId);
data.setUser("TEST_DUMMY_USER");
data.setClient("777");
data.setLanguage("DE");
data.setPassword("TEST_DUMMY_PW");
String projectDestinationId = AdtProjectServiceFactory.createProjectService().createDestinationId(projectName);
final IDestinationData destinationData = data.getReadOnlyClone(projectDestinationId);
final IAbapProjectService abapProjectService = AdtProjectServiceFactory.createProjectService();
//IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final AbapProject[] projects = new AbapProject[1];
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
projects[0] = (AbapProject) abapProjectService.createAbapProject(projectName, destinationData, monitor);
}
}, new NullProgressMonitor());
return projects[0].getProject();
}
public void saveEditors(final IRenameElementContext context) {
new DisplayRunnable() {
@Override
protected void run() throws Exception {
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IWorkbenchPage workbenchPage = getWorkbenchPage(context);
if (prefs.isSaveAllBeforeRefactoring())
workbenchPage.saveAllEditors(false);
else
saveDeclaringEditor(context, workbenchPage);
}
}, new NullProgressMonitor());
}
}.syncExec();
syncUtil.waitForBuild(null);
}
private void doInitializeCache() throws CoreException {
if(!isInitialized) {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
if(!isInitialized) {
for(IProject project: workspace.getRoot().getProjects()) {
if(project.isAccessible() && JavaProject.hasJavaNature(project)) {
IJavaProject javaProject = JavaCore.create(project);
updateCache(javaProject);
}
}
isInitialized = true;
}
}
};
// while the tree is locked, workspace.run may not be used but we are sure that we do already
// hold the workspace lock - save to just run the action code
if (workspace.isTreeLocked()) {
runnable.run(null);
} else {
workspace.run(runnable, null, IWorkspace.AVOID_UPDATE, null);
}
}
}
private static void refreshDiagnostics(final ICompilationUnit target) {
final JavaClientConnection connection = JavaLanguageServerPlugin.getInstance().getClientConnection();
if (connection == null) {
JavaLanguageServerPlugin.logError("The client connection doesn't exist.");
return;
}
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
List<ICompilationUnit> units = getNonProjectCompilationUnits(target, monitor);
for (ICompilationUnit unit : units) {
publishDiagnostics(connection, unit, monitor);
}
}
}, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Refresh Diagnostics for non-project Java files", e);
}
}
protected List<IProject> importProjects(Collection<String> paths, boolean deleteExistingFiles) throws Exception {
final List<IPath> roots = new ArrayList<>();
for (String path : paths) {
File file = copyFiles(path, deleteExistingFiles);
roots.add(Path.fromOSString(file.getAbsolutePath()));
}
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
projectsManager.initializeProjects(roots, monitor);
}
};
JavaCore.run(runnable, null, monitor);
JobHelpers.waitForWorkspaceJobsToComplete(monitor);
return Arrays.asList(ProjectUtils.getAllProjects());
}
protected IProject importRootFolder(IPath rootPath, String triggerFile) throws Exception {
if (StringUtils.isNotBlank(triggerFile)) {
IPath triggerFilePath = rootPath.append(triggerFile);
Preferences preferences = preferenceManager.getPreferences();
preferences.setTriggerFiles(Arrays.asList(triggerFilePath));
}
final List<IPath> roots = Arrays.asList(rootPath);
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
projectsManager.initializeProjects(roots, monitor);
}
};
JavaCore.run(runnable, null, monitor);
waitForBackgroundJobs();
String invisibleProjectName = ProjectUtils.getWorkspaceInvisibleProjectName(rootPath);
return ResourcesPlugin.getWorkspace().getRoot().getProject(invisibleProjectName);
}
protected List<IProject> importProjects(Collection<String> paths, boolean deleteExistingFiles) throws Exception {
final List<IPath> roots = new ArrayList<>();
for (String path : paths) {
File file = copyFiles(path, deleteExistingFiles);
roots.add(Path.fromOSString(file.getAbsolutePath()));
}
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
projectsManager.initializeProjects(roots, monitor);
}
};
JavaCore.run(runnable, null, monitor);
waitForBackgroundJobs();
return WorkspaceHelper.getAllProjects();
}
private IWorkspaceRunnable updateGraphRunnable(final File f) {
if (!listenToDotContent
&& !hasDotFileExtension(f.getAbsolutePath().toString())) {
return null;
}
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor)
throws CoreException {
if (updateGraph(f)) {
currentFile = f;
}
}
};
return workspaceRunnable;
}
/**
* Removes all files in the project and sets the given classpath
*
* @param jproject
* The project to clear
* @param entries
* The default class path to set
* @throws CoreException
* Clearing the project failed
*/
public static void clear(final IJavaProject jproject, final IClasspathEntry[] entries) throws CoreException {
performDummySearch();
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
jproject.setRawClasspath(entries, null);
IResource[] resources = jproject.getProject().members();
for (int i = 0; i < resources.length; i++) {
if (!resources[i].getName().startsWith(".")) {
resources[i].delete(true, null);
}
}
}
};
ResourcesPlugin.getWorkspace().run(runnable, null);
}
public synchronized void appendText(final String text)
{
try
{
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException
{
// System.out.print(Thread.currentThread().getId() + " : " + message);
outFile.appendContents(new ByteArrayInputStream(text.getBytes()), IResource.FORCE, monitor);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
// if the console output is active, print to it
} catch (CoreException e)
{
TLCActivator.logError("Error writing the TLC process output file for " + model.getName(), e);
}
}
/**
* Set the selection and focus to the list of elements
* @param elements the object to be selected and displayed
*/
public void setSelection(final List<?> elements) {
if (elements == null || elements.size() == 0)
return;
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
fPackageViewer.refresh();
IStructuredSelection selection= new StructuredSelection(elements);
fPackageViewer.setSelection(selection, true);
fPackageViewer.getTree().setFocus();
if (elements.size() == 1 && elements.get(0) instanceof IJavaProject)
fPackageViewer.expandToLevel(elements.get(0), 1);
}
}, ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
@Test
public void testRemoveEngineUsingName() throws CoreException {
final HybridMobileEngine[] engines = new HybridMobileEngine[2];
engines[0] = new HybridMobileEngine("android", "6.0.0", null);
engines[1] = new HybridMobileEngine("ios", "4.4.0", null);
manager.updateEngines(engines);
JobUtils.waitForIdle();
// Run on a IWorkspaceRunnable because it needs to sync with the udpateEngines
// call.
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
manager.removeEngine(engines[0].getName(), monitor, true);
Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead();
assertEquals(1, w.getEngines().size());
assertEquals(1, manager.getEngines().length);
checkEnginesPersistedCorrectly(new HybridMobileEngine[] { engines[1] });
}
};
IWorkspace ws = ResourcesPlugin.getWorkspace();
ISchedulingRule rule = ws.getRuleFactory().modifyRule(testproject.getProject());
ws.run(runnable, rule, 0, new NullProgressMonitor());
}
@Test
public void testRemoveEngine() throws CoreException {
final HybridMobileEngine[] engines = new HybridMobileEngine[2];
engines[0] = new HybridMobileEngine("android", "6.0.0", null);
engines[1] = new HybridMobileEngine("ios", "4.4.0", null);
manager.updateEngines(engines);
JobUtils.waitForIdle();
// Run on a IWorkspaceRunnable because it needs to sync with the udpateEngines
// call.
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
manager.removeEngine(engines[0], monitor, true);
Widget w = WidgetModel.getModel(testproject.hybridProject()).getWidgetForRead();
assertEquals(1, w.getEngines().size());
checkEnginesPersistedCorrectly(new HybridMobileEngine[] { engines[1] });
}
};
IWorkspace ws = ResourcesPlugin.getWorkspace();
ISchedulingRule rule = ws.getRuleFactory().modifyRule(testproject.getProject());
ws.run(runnable, rule, 0, new NullProgressMonitor());
}
/**
* Store the breakpoint properties.
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
@Override
public boolean performOk() {
IWorkspaceRunnable wr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
PyBreakpoint breakpoint = getBreakpoint();
boolean delOnCancel = breakpoint.getMarker().getAttribute(ATTR_DELETE_ON_CANCEL) != null;
if (delOnCancel) {
// if this breakpoint is being created, remove the "delete on cancel" attribute
// and register with the breakpoint manager
breakpoint.getMarker().setAttribute(ATTR_DELETE_ON_CANCEL, (String) null);
breakpoint.setRegistered(true);
}
doStore();
}
};
try {
ResourcesPlugin.getWorkspace().run(wr, null, 0, null);
} catch (CoreException e) {
PydevDebugPlugin.errorDialog("An exception occurred while saving breakpoint properties.", e); //$NON-NLS-1$
PydevDebugPlugin.log(IStatus.ERROR, e.getLocalizedMessage(), e);
}
return super.performOk();
}
@After
public void tearDown() throws Exception {
// Should undo all wizard actions
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IProject project = EclipseUtils.getWorkspaceRoot().getProject(NEWPROJNAME);
if(project.exists()) {
project.delete(true, monitor);
}
}
}, null);
if(wizDialog != null) {
wizDialog.close();
}
}
public void doAddErrorMarkers(Iterable<ToolSourceMessage> buildErrors, Location rootPath, IProgressMonitor pm)
throws CoreException {
documents.clear();
ResourceUtils.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
for(ToolSourceMessage buildError : buildErrors) {
if(pm.isCanceled()) {
return;
}
addErrorMarkers(buildError, rootPath);
}
}
}, ResourceUtils.getWorkspaceRoot(), IWorkspace.AVOID_UPDATE, pm);
}
protected void updateProblemMarkers() throws CoreException {
// Review if this can run outside lock
IFile[] files = ResourceUtils.getWorkspaceRoot().findFilesForLocationURI(location.toUri());
if(files.length == 0) {
return;
}
final IFile file = files[0];
ResourceUtils.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
doCreateProblemMarkers(file);
} catch(OperationCancellation e) {
return;
}
}
}, file, IWorkspace.AVOID_UPDATE, null);
}
public static void connectResourceListener(IResourceChangeListener listener,
RunnableX<CoreException> initialUpdate, ISchedulingRule opRule, IOwner owner) {
try {
getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
initialUpdate.run();
}
}, opRule, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException ce) {
EclipseCore.logStatus(ce);
// This really should not happen, but still try to recover by registering the listener.
getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
}
owner.bind(() -> ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener));
}
protected IWorkspaceRunnable handlePoolRemoved(final ProcessConfigurationRepositoryStore processConfStore,
final DiagramRepositoryStore diagramStore) {
return new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor arg0) throws CoreException {
final Set<String> poolIds = diagramStore.getAllProcessIds();
for (final IRepositoryFileStore file : processConfStore.getChildren()) {
String id = file.getName();
id = id.substring(0, id.lastIndexOf("."));
if (!poolIds.contains(id)) {
file.delete();
}
}
}
};
}
public void load() {
if (!isLoaded) {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
if (!isLoaded) {
resourceDescriptionData = new ResourceDescriptionsData(persister.load());
if(storage2UriMapper instanceof IStorage2UriMapperExtension)
((IStorage2UriMapperExtension) storage2UriMapper).initializeCache();
isLoaded = true;
}
}
};
try {
switch(workspaceLockAccess.isWorkspaceLockedByCurrentThread(workspace)) {
case YES: {
runnable.run(null);
break;
}
case NO: {
workspace.run(runnable, null, IWorkspace.AVOID_UPDATE, null);
break;
}
case SHUTDOWN: {
// do not initialize anything if we are about to shutdown.
return;
}
}
} catch(CoreException e) {
log.error(e.getMessage(), e);
}
}
}
/**
* Gets the classpaths and modulepaths.
*
* @param uri
* Uri of the source/class file that needs to be queried.
* @param options
* Query options.
* @return <code>ClasspathResult</code> containing both classpaths and
* modulepaths.
* @throws CoreException
* @throws URISyntaxException
*/
public static ClasspathResult getClasspaths(String uri, ClasspathOptions options) throws CoreException, URISyntaxException {
IJavaProject javaProject = getJavaProjectFromUri(uri);
Optional<IBuildSupport> bs = JavaLanguageServerPlugin.getProjectsManager().getBuildSupport(javaProject.getProject());
if (!bs.isPresent()) {
throw new CoreException(new Status(IStatus.ERROR, IConstants.PLUGIN_ID, "No BuildSupport for the project: " + javaProject.getElementName()));
}
ILaunchConfiguration launchConfig = bs.get().getLaunchConfiguration(javaProject, options.scope);
JavaLaunchDelegate delegate = new JavaLaunchDelegate();
ClasspathResult[] result = new ClasspathResult[1];
IWorkspace workspace = ResourcesPlugin.getWorkspace();
ISchedulingRule currentRule = Job.getJobManager().currentRule();
ISchedulingRule schedulingRule;
if (currentRule != null && currentRule.contains(javaProject.getSchedulingRule())) {
schedulingRule = null;
} else {
schedulingRule = javaProject.getSchedulingRule();
}
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
String[][] paths = delegate.getClasspathAndModulepath(launchConfig);
result[0] = new ClasspathResult(javaProject.getProject().getLocationURI(), paths[0], paths[1]);
}
}, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
if (result[0] != null) {
return result[0];
}
throw new CoreException(new Status(IStatus.ERROR, IConstants.PLUGIN_ID, "Failed to get the classpaths."));
}
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
final Change[] result = new Change[1];
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
result[0] = DynamicValidationStateChange.super.perform(monitor);
}
};
JavaCore.run(runnable, fSchedulingRule, pm);
return result[0];
}
public void didChangeWatchedFiles(DidChangeWatchedFilesParams param) {
List<FileEvent> changes = param.getChanges().stream().distinct().collect(Collectors.toList());
for (FileEvent fileEvent : changes) {
CHANGE_TYPE changeType = toChangeType(fileEvent.getType());
if (changeType == CHANGE_TYPE.DELETED) {
cleanUpDiagnostics(fileEvent.getUri());
handler.didClose(new DidCloseTextDocumentParams(new TextDocumentIdentifier(fileEvent.getUri())));
discardWorkingCopies(fileEvent.getUri());
}
ICompilationUnit unit = JDTUtils.resolveCompilationUnit(fileEvent.getUri());
if (unit != null && changeType == CHANGE_TYPE.CREATED && !unit.exists()) {
final ICompilationUnit[] units = new ICompilationUnit[1];
units[0] = unit;
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
units[0] = createCompilationUnit(units[0]);
}
}, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
unit = units[0];
}
if (unit != null) {
if (unit.isWorkingCopy()) {
continue;
}
if (changeType == CHANGE_TYPE.DELETED || changeType == CHANGE_TYPE.CHANGED) {
if (unit.equals(CoreASTProvider.getInstance().getActiveJavaElement())) {
CoreASTProvider.getInstance().disposeAST();
}
}
}
pm.fileChanged(fileEvent.getUri(), changeType);
}
}
public void didClose(DidCloseTextDocumentParams params) {
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleClosed(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document close ", e);
}
}
public void didOpen(DidOpenTextDocumentParams params) {
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleOpen(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document open ", e);
}
}
public void didChange(DidChangeTextDocumentParams params) {
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleChanged(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document change ", e);
}
}
public void didSave(DidSaveTextDocumentParams params) {
ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
try {
JobHelpers.waitForJobs(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, new NullProgressMonitor());
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
handleSaved(params);
}
}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Handle document save ", e);
}
}
public IProject createFromScratch(NewProjectSettings settings, Bundle resourceBundle, IUserInteraction userInteraction) {
FromScratchMaker fsm = new FromScratchMaker(settings, resourceBundle, userInteraction);
String err = fsm.createProjectFiles();
if (err != null) {
if (!err.isEmpty()) {
userInteraction.showOkNotification(Messages.NewProjectCreator_CreatePrjFromScratch, err);
}
return null;
}
final IProject project = createProject(settings.getProjectName(), settings.getProjectRoot());
openProject(project);
ExternalResourceManager.recreateExternalsFolder(project, new NullProgressMonitor());
final XdsProjectSettings xdsProjectSettings = XdsProjectSettingsManager.getXdsProjectSettings(project);
if (XdsProjectType.PROJECT_FILE.equals(fsm.projectType)) {
xdsProjectSettings.setXdsProjectFile(ResourceUtils.getRelativePath(project, fsm.prjFile));
xdsProjectSettings.setProjectType(XdsProjectType.PROJECT_FILE);
} else {
xdsProjectSettings.setMainModule(ResourceUtils.getRelativePath(project, fsm.mainModule));
xdsProjectSettings.setProjectType(XdsProjectType.MAIN_MODULE);
}
mainModule = fsm.mainModule;
xdsProjectSettings.setProjectSdk(settings.getProjectSdk());
NatureUtils.addNature(project, NatureIdRegistry.MODULA2_SOURCE_PROJECT_NATURE_ID);
ResourceUtils.scheduleWorkspaceRunnable(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
xdsProjectSettings.flush();
}
}, project, Messages.NewProjectCreator_BuildingProject, false);
return project;
}
public static IProject createFromSources (NewProjectSettings settings) {
final IProject project = createProject(settings.getProjectName(), settings.getProjectRoot());
openProject(project);
ExternalResourceManager.recreateExternalsFolder(project, new NullProgressMonitor());
final XdsProjectSettings xdsProjectSettings = XdsProjectSettingsManager.getXdsProjectSettings(project);
if (settings.getXdsProjectFile() != null) {
xdsProjectSettings.setProjectType(XdsProjectType.PROJECT_FILE);
xdsProjectSettings.setXdsProjectFile(ResourceUtils.getRelativePath(project, settings.getXdsProjectFile()));
} else {
xdsProjectSettings.setProjectType(XdsProjectType.MAIN_MODULE);
xdsProjectSettings.setMainModule(ResourceUtils.getRelativePath(project, settings.getMainModule()));
}
xdsProjectSettings.setProjectSdk(settings.getProjectSdk());
NatureUtils.addNature(project, NatureIdRegistry.MODULA2_SOURCE_PROJECT_NATURE_ID);
ResourceUtils.scheduleWorkspaceRunnable(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
xdsProjectSettings.flush();
}
}, project, Messages.NewProjectCreator_BuildingProject, false);
return project;
}