How to make a new Eclipse project template? - eclipse

I am using a kind of framework where every time I make a new Java project. I have to arrange the files in the appropriate packages and reference the appropriate external JAR libraries. How do I make a new project template like in the New Project dialog under a new folder?

I've just done a bit of research on this for our own nefarious purposes, and found the answer.
You need to create an Eclipse plugin that uses the org.eclipse.ui.newWizards package. You can define your own category or use an existing one once you find the category ID. To create a new project wizard rather than a new resource wizard, you need to set the "project=true".
Also, your plugin must contain a class that implement org.eclipse.ui.INewWizard. Clicking on the class link from the plugin.xml editor will do the trick.
That class must do all the work in the performFinish override, and must return true to indicate that it actually did its thing and the wizard can close. This is where you create files, directories, set natures, and so forth.

You need to write an Eclipse plugin for that, and concentrate on New Project Wizard.
Writing Eclipse plugins is covered in Stack Overflow question How to write a plugin for Eclipse?.

Related

Creating library in TwinCAT 3

I have made some "standard" functionblocks that I would like to add to a new library that I can include when making a new project, but for the sake of me I can't figure out how to do it.
On Beckhoffs website it says to create a new library-project from the library template. I don't have that template though, and I just reinstalled TC3 with everything included.
So my question is:
What is the procedure to make a new library in TC3, and how do I add functions to it?
I figured it out.
If you right click on a project under "PLC" in the solution explorer, you get the option to save as a library.
Also, you don't create a library project from a template when you create a new project, as I initially thought. You create an "Empty PLC project" when you add a new item to the PLC folder in an existing project.

eclipse custom project plugin

I have already read many articles but never succeeded to do what I need.
I would like to make a plugin for eclipse.
this plugin should add new wizard category to the 'File->New->Project',
this category should have 3 items under it, lets say 'X', 'Y', 'Z'.
when pressing each of them, no matter which,
a new 'Create a Java Project' window open.
after entering the 'name' for the project,
a new Folder needs to be create at the project manager at the same chosen 'name'.
this folder must have all other items inside, just like creating a new normal java project.
also should be a new package under the 'src' folder, package name is 'X' ('Y', or 'Z')..
and inside the package should be a java file (with my own default template), its name should be 'name'.jave.
is it possible to make such plugin to eclipse?
even not making the plugin with eclipse itself.
will really appreciate your answer,
Thanks!
Yes, it is possible. You will have to learn how to make Eclipse plugins though. Start with some basic tutorial like this or this. Then when you know the basics, you can look into the newWizard extension point that you want to use.
You can do this in any editor, even a text editor if you want. But you will have a huge advantage by doing this in Eclipse since there are editors and tools to help you out.
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_newWizards.html

How to set up customized project type?

I want to ask how to create a customized project type in Eclipse. For example, when I create my project, a project with some built-in read-only folders will appear and in these folders, some files are added. Any help will be appreciated.
Best regards.
You have to create a New project wizard using the extension point org.eclipse.ui.newWizards.
Then in the implementation you could rely on an existing wizard (look the plug-in spy to get the contributor plug-in of the wizard you are using - select the contribution of the first page in the New wizard, and press Alt+Shift+F3), and override the performFinish method to create your own content. However, you could also create your brand new wizard.
For creating the project/contents, you have to use the Eclipse resources API. A quick tutorial is included in the Java AST tutorial of Lars Vogel - it is Java specific, but has some information about creating files/folders.

How to link two or more projects in Eclipse?

I am trying to develop my application in different Eclipse Java projects where each will contain a certain feature. Then I want to combine them in one complete Java project.
However, I have a problem when linking the sources.
The sub-projects can correctly refer to parent-project classes but some of the source files that are accessed by the parent projects cannot be identified in the sub-projects.
I have a workspace/ParentProject/src/main/resources/file, where in the ParentProject I am accessing with "src\main\resources\" from within Java.
However, at runtime the ChildProject throws an exception that they cannot access the file : 'file:/E:/Eclipse%20workspace/ChildProject/src/main/resources/file'
So, when using a method of the ParentProject from the ChildProject, the classpath is somewhat transfered to the ChildProject. My question is how to resolve this.
I hope I made it clear what the problem is and will be really appreciative for any help.
Regards,
Petar
Btw: It is explained there How to link project in eclipse but I still have the error, that the child project cannot access resources accessed by the parent project.
Although I am not entirely sure what you need to do, it sounds to me that you are trying to create circular dependencies, which is an anti-pattern. You want to avoid creating dependencies where project a depends on project b, but project b also depends on project a. If you provide more details on your use case and what you are trying to create I will be happy to provide some guidance as to how you could structure your dependencies.
Hope this helps.
Right click the Parent project and click properties. Then click Java Build Path on the left hand side. Next click the projects tab. Make sure the Child project is selected as a required project, if it is not Add the Child project.
You should also do this for the Parent Project.

Can I add JavaDoc to a package easily with Eclipse?

I use javadoc to document my classes and methods. I would like to add some overview information to my packages, too. I like how Eclipse creates a stub of a matching Doc Comment for each class or method once I type /**<Enter>. Does Eclipse have an easy way to generate a package.html file, too?
Update 4 years later (Oct. 2013)
javabeangrinder's answer (upvoted) mentions the following trick:
To create a package-info.java file in an existing package:
Right click on the package where you want a package-info.java.
Select new->package.
Check the Create package.info.java check box.
Click on Finish
Original answer (May 2009)
There is no template or wizard to easily create a package.html file.
As mmyers said in his comment, since Java1.5, the correct file to create would be package-info.java.
That file can be used not only for javadocs, but also for package-level annotations (as illustrated here).
There is an opened Bug (#86168) for demanding a wizard for the creation of package-info.java (since the class wizard does not allow the package-info name).
The reflections on that topic are on since... 2005! The problem is that any solution should
be implemented in a way that it also helps with 1.4 code.
The current workaround is to create a package-info.java as a text file.
From that point forward, package-info.java behaves as a normal Java class, and Eclipse places a package-info.class file in the output folder.
The Javadocs are correctly built using package-info.java, and not the package.html file.
(source: developpez.com)
Note (in response to Strawberry's comment):
bug 77451 (2004!, for package.html)
bug 163633 and bug 163926 (2006, for package-info.java)
both wish a preview of the package overview in package-info.java in the Javadoc
view.
So far, no patch has been proposed/implemented.
There is simply not enough demands for that feature to be added.
In eclipse
Since package-info.java isn't a valid identifier for a class it cannot be created as a class in Eclipse.
I found that when you create a new package there is a check box to check if you want a package-info.java.
To create a package-info.java file in an existing package:
Right click on the package where you want a package-info.java.
Select new->package.
Check the Create package.info.java check box.
Click on Finish
The JAutodoc plugin does a great job of this, as well as all your other documentation needs. Install and configure the plugin and right click the package and click JAutodoc > Add Package Javadoc
There are configurations and templates available for the .java or .html package documentation.
This plugin also does a great job of standardizing all your Javadoc needs, with a great deal of customization.
http://jautodoc.sourceforge.net/
There's a plugin that seems to create package.html files. I haven't used it but someone landing here might find it useful.
http://sourceforge.net/projects/package-javadoc/