Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Project Nature in Xtend(Translate Java code in Xtend code for set project nature in Eclipse)
Project Nature in Xtend [message #1730307] Sun, 24 April 2016 09:14 Go to next message
Yves LEDUC is currently offline Yves LEDUCFriend
Messages: 56
Registered: May 2015
Project Nature in Xtend
In a plugin project I defines the project and file creation.
I want to define the nature of the project created.
I found this Java code to do (it works fine).

public class WizardNewProject extends BasicNewProjectResourceWizard {


public boolean performFinish() {

IProject project = getNewProject();

//Add the Nature
try {
IProjectDescription description = project.getDescription();

String[] natureIds = description.getNatureIds();
String[] newNatureIds = new String[natureIds.length + 1];
System.arraycopy(natureIds, 0, newNatureIds, 0, natureIds.length) ;
newNatureIds[newNatureIds.length - 1] = XtextProjectHelper.NATURE_ID;
project.setDescription(description, new NullProgressMonitor());
} catch (CoreException e1) {

try {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
return true;



I want to write this code in Xtend (for use in Xtext projects)
but the translation I did of Java code Xtend:

override boolean performFinish() {
// Add the Nature
var project = newProject as IProject
var description = project.getDescription() as IProjectDescription
var natureIds = description.getNatureIds() as String[]
project.setDescription(description, new NullProgressMonitor())
return true

does not work (not the top of the Eclipse Java translator Xtend does not work either)!
No way to access the project from the performFinish () function.
In BasicNewProjectResourceWizard newProject is private but getNewProject () function is public but the call does not work either.
Thank you in advance for your help.
Re: Project Nature in Xtend [message #1730309 is a reply to message #1730307] Sun, 24 April 2016 09:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member

your code and the code translated via convert to xtend both compile fine for me.
that is the actual error you get?

maybe it is a buinesslogic problem?

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Re: Project Nature in Xtend [message #1730341 is a reply to message #1730309] Mon, 25 April 2016 08:17 Go to previous message
Yves LEDUC is currently offline Yves LEDUCFriend
Messages: 56
Registered: May 2015
For me also now ??? I don't understand why. Thanks
Previous Topic:Include Xtext document formating as model elements
Next Topic:Syntax Highlighting in Xtext
Goto Forum:

Current Time: Tue Oct 20 23:59:34 GMT 2020

Powered by FUDForum. Page generated in 0.02298 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top