Quickly push-in refactor large number of Spring Roo generated methods in .aj files - eclipse

Is there a faster way to push in multiple methods from Roo-generated aspects to Java classes than doing them one at a time in an IDE that supports the operation?
I want to push in all methods from the aspects generated because of a specific Roo annotation as painlessly as possible.

In STS or Eclipse, you can probably do this with the "Outline" view.
Open up the .aj file that Spring Roo generated.
Find the "Outline" view.
Select all of the methods that you want to push-in.
Right-click them, "Refactor, Push In"
If you're having trouble getting the Roo created .aj files to show up in Package Explorer, look for the little down-arrow, go into "Filters..." and turn off the "Hide generated Spring Roo ITDs" box.

Have you tried removing the AspectJ nature from your project?
Or you can also remove the SpringROO nature directly. That will remove all your .aj files and all the methods will be transfered to the actual class files.
In STS you can choose this option from right click menu of your project.
If your IDE is slow then you can do this from ROO shell from command prompt.
Hope this helps you. Cheers.

Related

Multiple Xtext DSLs in single Eclipse project

I would like to know if there is a way to organize multiple DSLs inside a single Eclipse project. More specifically, I would like to organize all five Xtext projects of a DSL in some top-level "project folder".
The background is that we manage complexity and enable reuse by making smaller reusable DSLs, e.g. one reusable for expressions and other one for more domain-specific or application-specific aspects. However, each Xtext DSL results in 5 projects, causing a lot of clutter in the Package Explorer when multiple DSLs are involved. A strongly related question has been asked before:
Xtext: define 2 DSL's in one project
The answer there is that multiple DSLs are not needed inside the project for that specific use-case. My use-case is different because I want to be able to easily view the different DSLs and potentially co-develop them.
We are using Xtext in an environment managed by Gradle. We are using the Gradle Eclipse plugin, which creates a lot of Eclipse project files everywhere. As a result, when choosing to "Open Project from File System" in Eclipse, I not only get the option to import the five projects related to the DSL, but also the option of opening the parent folder as a project. This means I can have each DSL (all its five projects) organized neatly in a "project folder". This is exactly what I want! ...
BUT ...
it does not actually work. The figure below shows my package explorer with the five projects of my ExperimentDSL included in the bottom. This DSL works. On top, it shows the folder structure I get when including the project file generated by Gradle, resulting in a "project folder" that can potentially contain multiple DSLs.
As you can see, GenerateExperimentDSL is flagged red and refuses to run. It seems Eclipse somehow treats it as a Java project, but I do not know how to change this or and if this would help solve my problem. Secondly, I would not know how to set up such a project by hand, since the project file in this failing case was generated by Gradle.
Long story short, does anyone know how to get this kind of folder structure to work so that I can keep all my DSLs in the workspace without clutter?
What you try to do is currently not possible. Have a look at the concept of WorkingSets in Eclipse that let you achieve something similar

How can I add dependancies to a Spring Tool Suite 4 project?

Using STS 3.7, I created a new "Spring Starter Project" by right clicking in the package explorer and selecting new -> Spring Starter Project and, of course, selecting what I needed.
Now, I would like to add JPA to it. I looked at some sample JPA projects and see there are many dependencies, and I'm thinking they vary based upon what persistence engine I'm going to use.
So, I'm wondering if there is an easy way to edit the project to add what the starter project creation feature would have if I had selected it in the first place.
Failing that, whats the best way to figure out what dependancies are needed for any particular thing and add them? I tried a few different things but the only result was a broken project.
Thanks very much...
If you right-click on the generated pom file, there is an option "Spring -> Edit Starters" where you can add more of the Spring Boot starters. This is what you are looking for, I guess. In addition to that I would like to recommend the guides at http://spring.io/guides, if you are looking for additional advice. There are a bunch of data related guides as well. Hope this helps!

How to create Eclipse RCP application that behaves like a wizard?

I want create a installer by using Eclipse RCP. I need to give the user a wizard-like installer. This means user can do some options then click next. Or they can go back to previous page by click previous. Or they can cancel the installation by clicking cancel.
Here is my problem:
I don't know how to switch between views when clicking "next","previous". I need to create something like WizardPages and i can change between these pages?
I can't use JFace wizard because I'm required not to pop up any dialog.
I'm totally new to Eclipse RCP so please help!
thanks.
Maybe "StackLayout" is what you need.
Consider whether you actually want/need Eclipse RCP in this context. Eclipse RCP shines in complex applications with an extensive business domain and complex user interface.
An installer wizard, however, is very straightforward and static. I cannot imagine you requiring more than two or three user inputs. Your question is a bit like "I want to hear beautiful music. How do I program a robot to play the piano?"
It is much easier to limit yourself to using SWT and JFace. Use the JFace WizardDialog to make a nice installation wizard. You will find you will have never needed the Eclipse RCP framework.
See http://www.vogella.com/tutorials/EclipseWizards/article.html for a nice tutorial.
If you do think you need the features of the Eclipse RCP runtime framework, I suggest you follow the path below instead:
Create an RCP application (e.g. the sample 'Mail' application). A class will be created that is the main entry point in your application. This class will launch the Eclipse Workbench. Delete this code, and instead launch the WizardDialog.
A lot of things will not be available, such as menu's, views with drag-and-drop functionality, keybindings, etc. I cannot imagine you will need those things. However, you will benefit from the following Eclipse RCP features:
Eclipse launch framework. Ability to create a self-contained product including the JRE.
OSGi framework. Ability to easily add new plugins. Ability to use services, blueprint, etc.
JFace framework.
EMF (if you have a very complicated installation wizard)
All other eclipse plugins, although a lot of them may not work outside of the context of the Eclipse Workbench.
If you are convinced you need the full Eclipse Workbench, you can always do the following:
Define a 'base' perspective that is 'locked down'.
Use a Command to move from one perspective to the other. This will allow you to keep the previous wizard views open in other (hidden) perspectives.
Use Eclipse Contexts to hide all the standard Eclipse Workbench functionality, menu's, etc.
Since you are new to Eclipse RCP, I do not recommend learning the framework in the particular usecase of an Installation Wizard. You already need good knowledge of Eclipse RCP to be able to hack it this way, and it will not be a clean or nice implementation :-)

How to generate code in java file rather than in aspectJ file when creating and advanced roo addon?

I am in the process of creating an advanced Roo add-on. Besides the fact that there is almost no existing documentation, and I'm hitting on multiple issues, the one that gives me now headaches is the following:
I need to modify a method from a controller. That method already exists in the respective generated Roo controller .aj file. However, if I create a new method in my .aj file, having the same name, I get an error. On the Roo forums they say that this kind of code should be injected directly in the .java file. Ok, I agree with that, but anybody knows how?
Kind regards,
Radu
Ok, I have found the solution.
One needs to get the path to the java file to write to by using ProjectOperations, then using MutableFile in order to be able to operate the file.

Is it possible to group projects in Eclipse?

Is it possible to group projects in Eclipse? Or maybe have a project with sub-projects?
Eclipse offers working sets. You can reduce the projects shown in the Package Explorer and other places to whichever projects you defined into the working set. You can also show the union of various sets, and similar gymnastics.
You can define/edit/delete working sets from the little triangle dropdown menu on the Package Explorer and similar directory views.
You have two options, as far as I know:
use the already suggested Working Set option: you can create custom groups, use them to focus on a particular area of a project, activate them through Mylin; a really powerful tool indeed
use the basic concept of workspace which allows you to work on many projects and relate them (via the Build path "Projects" tab, and "Java EE Module Dependencies") so that when you need resources from other projects or you need to deploy them along with your main web application Eclipse will do that for you
Using Working Sets, you can add and organize them as shown in the picture :
As you can see my Java projects are in Working sets like Sem1 and TPs.
When you create an all new Project, just add the project to your working set, like this :
What about eclipse working sets? You define a working set and then add some projects to it. Later you could select a working set and only the projects you selected earlier are shown in project explorer.
Simpl grouping to reduce clutter.
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.user/concepts/cworkset.htm
Since Eclipse Mars M5, you can see a hierarchical view of nested projects in the Project Explorer view. In the view menu, click "Projects Layout > Hierarchical". https://www.eclipse.org/mars/noteworthy/#_nested_hierarchical_view_of_projects
Working sets are great, but they don't work if the projects in one working set has the same name as in another, and such occurs in some TI C2000 chip examples that are in different directories.