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
Member
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 {

...

@Override
public boolean performFinish() {
super.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;
description.setNatureIds(newNatureIds);
project.setDescription(description, new NullProgressMonitor());
} catch (CoreException e1) {
e1.printStackTrace();
}

try {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
e.printStackTrace();
}
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() {
super.performFinish()
// Add the Nature
var project = newProject as IProject
var description = project.getDescription() as IProjectDescription
var natureIds = description.getNatureIds() as String[]
natureIds.add(XtextProjectHelper.NATURE_ID)
description.setNatureIds(natureIds)
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: 13216
Registered: July 2009
Senior Member
Hi,

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: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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
Member
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: Thu Nov 21 11:18:45 GMT 2019

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

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

Back to the top