A simple example of creating JDT code

I am trying to write an Eclipse plugin. It will have RCP dependencies for the base material and JDT for generating Java code. It consists of a Wizard / WizardPage that requests a package and several class names. When the user clicks Finish, I want the wizard to create classes that match the entered values ​​in the current Java project.

I have a main user interface. I cannot figure out how to create the appropriate class code. The Eclipse documentation is a bit complicated. From what I can learn, I first need to get IJavaProject from the workspace, from it IPackageFragment, and from this I can call createCompilationUnit () to create the class.

What I cannot do is find working examples. I suppose that somehow I can go from the root of the workspace to where I need to be and create a block.

Can anyone suggest some pointers to simple working code?

+3
source share
2 answers

You need to extend NewElementWizardPage and provide functionality. See this documentation for more details.

+1
source

I suppose that somehow I can go from the root of the workspace to where I need to be and create a block.

Yes. Take a look at IProject, IFolder, and IFile in the org.eclipse.core.resources package.

Can anyone suggest some pointers to simple working code?

Eclipse Java- , , New Java Class Wizard. , . Eclipse Eclipse. , - org.eclipse.pde.

, org.eclipse.ui.newWizards.

0

All Articles