Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » New Project Wizard without use XtextNewProjectWizard ?
New Project Wizard without use XtextNewProjectWizard ? [message #903014] Tue, 21 August 2012 16:07 Go to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi,

I could note that Xtext has a fragment that creates the new project wizard for your DSL and it uses a XtextNewProjectWizard class.

My problems:
1) I have more than one DSL that could be created inside the project that will be created by the wizard. so I must create the wizard in a common UI project.

2) XtextNewProjectWizard uses guice injection that I don't have in the common UI project.

I think I have two alternatives:
1) include guice support in common UI project and use XtextNewProjectWizard;
2) create a newProjectWizard using JDT's JavaProjectWizard.

I'm inclined to use option 2. So my question is: what must be set in a java project to it be xtext compatible for all my dsls? it needs only xtext nature and builder ?

thanks for any hint.

Cristiano
Re: New Project Wizard without use XtextNewProjectWizard ? [message #903042 is a reply to message #903014] Tue, 21 August 2012 17:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

what about (3)
create an acticator in the commmon project that provides an injector (similar to the stuff that is done in the ui project)
that offers the required bindings through a module.

then create an executableextensionfactory that uses this injects and use it in the plugin.xml

for (2) Xtext Nature + Builder should be fine.

~Christian
Re: New Project Wizard without use XtextNewProjectWizard ? [message #903056 is a reply to message #903042] Tue, 21 August 2012 18:38 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi Christian,

Quote:
what about (3)
create an acticator in the commmon project that provides an injector (similar to the stuff that is done in the ui project)
that offers the required bindings through a module.


well, that was what I mean about add support to guice Wink

but even with providing my own injector for the common UI, I think I can't use the XtextNewProjectWizard, right ? At least I noted that it creates an instance file of current DSL and open it in the editor. Or its something that I can remove from it ?

btw, do you think it is necessary to have dependencies from Common Ui project to other DSL projects ? or should I change the DSLs UI project to create it injectors as child injector from the Common UI?

regards,

Cristiano

[Updated on: Tue, 21 August 2012 18:42]

Report message to a moderator

Re: New Project Wizard without use XtextNewProjectWizard ? [message #903065 is a reply to message #903056] Tue, 21 August 2012 19:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

this can not be customized?????? i am sure it can (have a look at the project creator

~Christian
Re: New Project Wizard without use XtextNewProjectWizard ? [message #903072 is a reply to message #903065] Tue, 21 August 2012 19:59 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Ok, I will look into deeper that.

but there are a bug in my head. I couldn't understand how to deal with common injector, yet.

Each DSL has its own, right?

It is necessary anyhow to relate the DLS's injectors with the Common UI one that I will create?
Re: New Project Wizard without use XtextNewProjectWizard ? [message #903073 is a reply to message #903072] Tue, 21 August 2012 20:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

no i dont think so.

~Christian
Re: New Project Wizard without use XtextNewProjectWizard ? [message #903425 is a reply to message #903014] Thu, 23 August 2012 15:03 Go to previous messageGo to next message
Chad Lafferty is currently offline Chad Lafferty
Messages: 3
Registered: August 2012
Junior Member
I used a variant of 2) on my project.

- You need a plugin project, not a java project (I couldn't get xtext to work happily in a standard java project)

- You do need to add the xtext nature of course (org.eclipse.xtext.ui.shared.xtextNature)

- I used the IBundleProjectService to do a lot of the work behind the scenes (it creates plugin projects). Even with this you still need to add the java and plugin natures as well (IBundleProjectDescription.PLUGIN_NATURE & JavaCore.NATURE_ID)

- If you make use of xbase you need to add a plugin dependency for plugin org.eclipse.xtext.xbase.lib

- For the wizard, I simply extend Wizard and implement INewWizard. Page one derives from WizardNewProjectCreationPage. (this does not give you places to specify src/bin directories or other particulars but I am simply setting up reasonable defaults as part of my creation process - may update the UI for this later if users care to customize)
Re: New Project Wizard without use XtextNewProjectWizard ? [message #903689 is a reply to message #903073] Fri, 24 August 2012 22:05 Go to previous message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Well, after have lost many many hours with some annoying ArrayStoreException I could make it work.

The errors gone after I have removed all import packages for Guice and Xtext stuffs and added Required Bundle instead... Sad

That are the classes that I needed to create:

UiCommonModule:
public class UiCommonModule extends AbstractGenericModule {

	private final AbstractUIPlugin plugin;

	public UiCommonModule(AbstractUIPlugin plugin) {
		this.plugin = plugin;
	}

	@Override
	public void configure(Binder binder) {
		super.configure(binder);
		binder.bind(AbstractUIPlugin.class).toInstance(plugin);
		binder.bind(IDialogSettings.class).toInstance(plugin.getDialogSettings());
	}
	
	public Class<? extends IProjectCreator> bindIProjectCreator() {
		return CommonProjectCreator.class;
	}

	public java.lang.ClassLoader bindClassLoaderToInstance() {
		return getClass().getClassLoader();
	}


	public Class<? extends IImageHelper> bindIImageHelper() {
		return PluginImageHelper.class;
	}
	
	public void configureFileExtensions(Binder binder) {
		
		binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("any");
	}
}


an ProjectWizard based on XtextNewProjectWizard:
public class NewProjectWizard extends XtextNewProjectWizard implements
		INewWizard {

	private WizardNewProjectCreationPage mainPage;

	@Inject
	public NewProjectWizard(IProjectCreator projectCreator) {
		super(projectCreator);
		setWindowTitle("New Project");
	}

	public void addPages() {
		mainPage = new WizardNewProjectCreationPage("basicNewProjectPage");
		mainPage.setTitle("My Project");
		addPage(mainPage);
	}

	@Override
	protected IProjectInfo getProjectInfo() {
		MainProjectInfo projectInfo = new MainProjectInfo();
		projectInfo.setProjectName(mainPage.getProjectName());
		return projectInfo;
	}
}


a ProjectInfo:

public class MainProjectInfo extends DefaultProjectInfo {

	public MainProjectInfo() {

	}
}


I need to create a custom CommonProjectCreator extending AbstractPluginProjectCreator and a custom ProjectFactory provider, that way the project created is a plugin one and with my own files.

now is everything ok...

cheers,

Cristiano
Previous Topic:why a parser exception inside a converter is ignored by my test ?
Next Topic:How to generate a field with a generic type
Goto Forum:
  


Current Time: Thu Oct 23 14:00:49 GMT 2014

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

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