org.eclipse.xtext.xtext.wizard.LanguageDescriptor Java Examples

The following examples show how to use org.eclipse.xtext.xtext.wizard.LanguageDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CliWizardIntegrationTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private static WizardConfiguration newProjectConfig(Procedure1<? super WizardConfiguration> block) {
	WizardConfiguration result = new WizardConfiguration() {
		@Override
		public String toString() {
			return getPreferredBuildSystem() + "|" + getSourceLayout() + "|" + getProjectLayout() + "|"
					+ getLanguageServer();
		}
	};
	result.setXtextVersion(new XtextVersion("unspecified"));
	result.setEncoding(Charsets.UTF_8);
	result.setLineDelimiter(LineDelimiter.UNIX.getValue());
	result.getLanguage().setName("org.xtext.example.mydsl.MyDsl");
	result.getLanguage().setFileExtensions(LanguageDescriptor.FileExtensions.fromString("mydsl"));
	block.apply(result);
	return result;
}
 
Example #2
Source File: NewXtextProjectWizard.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected IProjectInfo getProjectInfo() {
	XtextProjectInfo projectInfo = createProjectInfo();
	LanguageDescriptor language = projectInfo.getLanguage();
	language.setFileExtensions(FileExtensions.fromString(mainPage.getFileExtensions()));
	language.setName(mainPage.getLanguageName());
	projectInfo.setBaseName(mainPage.getProjectName());
	projectInfo.setWorkingSets(Arrays.asList(mainPage.getSelectedWorkingSets()));
	projectInfo.setRootLocation(mainPage.getLocationPath().toString());
	Charset encoding = null;
	try {
		encoding = Charset.forName(ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset());
	}
	catch (final CoreException e) {
		encoding = Charset.defaultCharset();
	}
	projectInfo.setEncoding(encoding);
	String lineDelimiter = InstanceScope.INSTANCE.getNode("org.eclipse.core.runtime").get("line.separator", Strings.newLine());
	projectInfo.setLineDelimiter(lineDelimiter);
	projectInfo.setWorkbench(getWorkbench());
	JavaVersion selectedBree = mainPage.getJavaVersion();
	// Use old default for wizard as fall back, when something goes wrong
	if (selectedBree != null) {
		projectInfo.setJavaVersion(selectedBree);
	}

	BuildSystem buildSystem = advancedPage.getPreferredBuildSystem();
	projectInfo.setPreferredBuildSystem(buildSystem);
	projectInfo.setSourceLayout(advancedPage.getSourceLayout());
	
	projectInfo.getUiProject().setEnabled(advancedPage.isCreateUiProject());
	if (buildSystem != BuildSystem.NONE) {
		projectInfo.setProjectLayout(ProjectLayout.HIERARCHICAL);
	}
	projectInfo.getIdeProject().setEnabled(advancedPage.isCreateIdeProject());
	projectInfo.getWebProject().setEnabled(advancedPage.isCreateWebProject());
	projectInfo.getSdkProject().setEnabled(advancedPage.isCreateSdkProject());
	projectInfo.getP2Project().setEnabled(advancedPage.isCreateP2Project());
	projectInfo.setLanguageServer(advancedPage.getLanguageServer());
	projectInfo.setJunitVersion(advancedPage.getSelectedJUnitVersion());
	
	if (advancedPage.isCreateTestProject()) {
		for (ProjectDescriptor project : projectInfo.getEnabledProjects()) {
			if (project instanceof TestedProjectDescriptor) {
				((TestedProjectDescriptor) project).getTestProject().setEnabled(true);
			}
		}
	}
	return projectInfo;
}
 
Example #3
Source File: CliProjectsCreatorMain.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
private WizardConfiguration createProjectConfig() {
	WizardConfiguration cfg = new WizardConfiguration();
	cfg.setXtextVersion(new XtextVersion(this.xtextVersion));
	cfg.setRootLocation(this.targetDir.getAbsolutePath());
	cfg.setBaseName(this.baseName);
	cfg.setPreferredBuildSystem(this.buildSystem);
	cfg.setSourceLayout(this.sourceLayout);
	cfg.setProjectLayout(this.projectLayout);
	cfg.setJavaVersion(this.javaVersion);
	cfg.setJunitVersion(this.junitVersion);
	cfg.setEncoding(Charset.forName(this.encoding));
	cfg.setLineDelimiter(this.delimiter.getValue());
	
	LanguageDescriptor langDesc = cfg.getLanguage();
		langDesc.setName(this.languageName);
		langDesc.setFileExtensions(LanguageDescriptor.FileExtensions.fromString(this.fileExtension));

	
	for (ProjectType projectType : enabledProjects) {
		switch (projectType) {
		case RuntimeTest: 
			cfg.getRuntimeProject().getTestProject().setEnabled(true);
			break;
		case UIProject:
			cfg.getUiProject().setEnabled(true);
			break;
		case UITest:
			cfg.getUiProject().getTestProject().setEnabled(true);
			break;
		case GenericIDE:
			cfg.getIdeProject().setEnabled(true);
			break;
		case Web:
			cfg.getWebProject().setEnabled(true);
			break;
		case P2Project:
			cfg.getP2Project().setEnabled(true);
			break;
		}
	}

	return cfg;
}
 
Example #4
Source File: WizardConfiguration.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Pure
public LanguageDescriptor getLanguage() {
  return this.language;
}