Get Project Name in new Project Wizard for Eclipse [message #1745299] |
Fri, 07 October 2016 11:29  |
Martin Westerkamp Messages: 9 Registered: September 2016 |
Junior Member |
|
|
Hey everyone,
I have a short question concerning the new Project Wizard for eclipse feature which was added I think with version 2.9 of xtext.
While before the Project name was accessible through xpand using projectName of MD2ProjectInfo (as I understand), now I try to use it within MyDslNewProjectWizardInitialContents.
I have tried to inject MyDslProjectInfo, however, the projectName variable is null, when accessed.
Does anyone have an idea how to access the Project Name from MyDslNewProjectWizardInitialContents in order to generate the files from there?
Greets,
Martin
[Updated on: Thu, 08 December 2016 15:02] Report message to a moderator
|
|
|
|
|
|
Re: Get Project Name in new Project Wizard for Eclipse [message #1745317 is a reply to message #1745307] |
Fri, 07 October 2016 12:44   |
Martin Westerkamp Messages: 9 Registered: September 2016 |
Junior Member |
|
|
Actually your hint using MyDslProjectCreator already did the trick.
All that is necessary is injecting MyDslProjectCreator and using its method getProjectInfo which returns MyDslProjectInfo. From there projectName can be accessed.
Thanks Christian for the hint!
/*
* generated by Xtext 2.10.0
*/
package com.mydsl.ui.wizard
import org.eclipse.xtext.generator.IFileSystemAccess2
import com.google.inject.Inject
class MyDslNewProjectWizardInitialContents {
@Inject
MyDslProjectCreator projectCreator
def generateInitialContents(IFileSystemAccess2 fsa) {
val projectName = projectCreator.projectInfo.projectName
fsa.generateFile(
"src/" + projectName + "/model/default.mydsl",
'''
package «projectName».model
/*
* Implement the model here
*/
'''
)
}
}
[Updated on: Fri, 07 October 2016 12:45] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02205 seconds