Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Execute main class in a package from a button - Eclipse RCP
Execute main class in a package from a button - Eclipse RCP [message #1698562] Tue, 16 June 2015 08:27 Go to next message
Eclipse UserFriend
Hello All,

I posted this question on the XText forum, but was redirected here, as the experts thought this is the best place for my query.

I am trying to develop an XText DSL editor for our end-users. I have packaged this DSL editor into an Eclipse RCP project. When I launch the Eclipse product and save the DSL script, XTend automatically generates code in the class in the folder src-gen, for the corresponding dsl file. So finally, the structure of the project looks like the following.

Project A
------Package org.tlf
-----------src
--------------Main.dsl
-----------src-gen
--------------Main.java

What I am trying without success, is when I click the 'save' button on the "Main.dsl" active page, the Main.java class needs to run. For this to work, first the src-gen folder needs to be programmatically added to the class path and the Main.java needs to be run, upon click on "Save".

To get the name of the dsl file (that corresponds to the Java class), the following works:
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
name[0] = activePage.getActiveEditor().getEditorInput().getName();
System.out.println(name[0]);

Is there a way to get the active project name and then the path to the Main.java class, so I could run it when I click on 'Save'.?

Many thanks for your time,



Re: Execute main class in a package from a button - Eclipse RCP [message #1699040 is a reply to message #1698562] Fri, 19 June 2015 13:40 Go to previous messageGo to next message
Eclipse UserFriend
When you call activePage.getActiveEditor().getEditorInput(), isn't the result actually an IFileEditorInput?
Its getFile().getFullPath() should answer your needs.

As for programmatically adding src-gen to the class path: I'm not sure I fully understand your approach. If you want the .java file to be compiled, why not add src-gen to the build path permanently? Otherwise you'd have to manually trigger compilation before you can run it, right?

[Updated on: Sun, 21 June 2015 06:07] by Moderator

Re: Execute main class in a package from a button - Eclipse RCP [message #1701212 is a reply to message #1699040] Thu, 09 July 2015 17:24 Go to previous message
Eclipse UserFriend
Hi Stephan ,

Thanks much for your time and reply.

With the getFullPath() I am able to add the src-gen folder programmatically to the build path.

When I save the xtext dsl, the src-gen with the generated java code files, is newly created; then I add the newly generated src-gen to the build path.

Many thanks again!



Previous Topic:Bug 470977: Formatter Removes Space between Assert and Unary
Next Topic:Eclipse Market Place Freezing (Kepler)
Goto Forum:
  


Current Time: Thu Apr 24 23:29:19 EDT 2025

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

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

Back to the top