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

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.

Related

Spring Cloud Contract: Prefered way to import repeating parts in Contract DSL

When writing a contract for an API i found myself repeating the same things over and over. For example regex validations for complex json object need to be copy pasted.
Thats tedious and not very DRY.
I'm using Kotlin DSL and Maven
I tried to extract the common parts in another file to reuse it. (Kotlin extension functions ftw.)
After trying multiple things to reuse that file I gave up.
The common parts should be as close to the actual contracts as possible. I don't want to export them in another project, and build them seperat, as they are an vital part of the contracts.
I tried it the following ways:
just put the file in the same directory and importing the functions, hoping it would be resolved as it would in java - did not work at all (my expectations were low, was worth a shot)
putting it in another maven module, and add that as dependency to the spring-cloud-contract-maven-plugin. that worked, as long as the dependant module was built and installed in the local maven repo. if no built version was available maven could not resolve it.
experimenting with kotlin script #file:Import() and #file:DependOn to tackle my issue, no luck.
Is there another way, that I missed? Is there a prefered way doing this?
This must be a common issue, right?

automatic code generation for IDL (ITTVIS/exelis) in eclipse IDE?

I was hoping to find a way to automatically generate some code based on existing code.
The actual functionality would be very similar to javadoc or in this case IDLdoc or to automatic get/set functions.
I want to create some generic code based on some already listed parameters.
How do I accomplish this within eclipse?
I think an example would be best, so here is what I would like to accomplish:
keyword1: stuffIdontCareAbout, $;comments
keyword2: otherStuffIdontCareAbout, $;more comments
keyword3: lastStuffIdontCareAbout $
What do I need to do in eclipse so that I can have eclipse quickly parse the above block and output the following for another part of the code?
KEYWORD1=inp_keyword1, KEYWORD2=inp_keyword2, KEYWORD3=inp_keyword3
Thanks
My usual knee-jerk response is to suggest that you use JET as that what it's designed for.
For this specific case, however, you might be better off just writing a simple popup action (use the new plugin project with the popup action template) that parses the properties file (looks simple enough to do in Java) and writes out the target code to another file, the console or, if you're clever, back into an existing file in the right place.
Once you have the plugin generated for you with the template, the rest should be simple Java.

Extend or configure Eclipse compare files functionality

Eclipse has built in functionality for comparing files, but how can I configure that functionality? Say I create a new file type and want an external program do perform the diff. How do I set that up?
Can I create an Eclipse plugin to add my own plugin for handling file comparisons? Or perhaps that is the answer to the first question...
You may want to look at the EMF Compare Project which helps build compare editors for EMF models. If you don't have an EMF model for your file type, you can either create one or look through the source code of EMF Compare to see how it works.
The developer guide explains how to use the code to write your custom viewers.
There is a plugin integrating Beyond Compare into Eclipse. As it is open source, you might get a clue by looking at its sources.

How to update zfproject.xml file after deleting some controllers, dbtables, etc. in Zend Framework?

I am using Netbeans IDE to work with Zend Framework. When I create a new controller, action, etc.. using Netbeans Zend Command Window, zfproject.xml file is updated automatically. However, when I delete some of them, the file is not updated and still keeps the names that I deleted.
Is there a way (apart from manual way) to update this file?
Is it needed to update zfproject.xml to run the project properly or is it just an organized schema of the project?
Thanks a lot
This is very good question. zfproject.xml often gets out of sync when you use both Zend Tool and manual creating of the files.
Is there a way (apart from manual way) to update this file?
I don't know a good answer for this part. You may try to iterate the application directory structure.
Is it needed to update zfproject.xml to run the project properly or is it just an organized schema of the project?
This is just a schema which is not parsed during the normal application life. Used only by the tools.

How to programmatically get information in Eclipse

I'm developing an Eclipse Plug-in.
I need to programmatically get both filepath and filename of the selected/active file in the eclipse editor.
Also need to programmatically add an existing file (located outside the project) to the project and then open it on the editor.
I'm a totally beginner with Eclipse, so complete solution would be appreciated.
You question is quite general, but this should clear things up a bit:
Eclipse Plugin Development Tutorial
About adding a file to the project, you have to read the documentation and find where eclipse handles projects. I think that if you have a reference to the project it should be easy.
Hope it helps =)
Your editor is most likely inheriting from IEditorPart, so you should be able to call getEditorInput(), which then may or may not turn out to be a FileEditorInput, for example. From there, you can get at the underlying details of the file.
For your second problem, you can use IProject.create() and then e.g. do an IFile.createLink() and use a local filesystem path, or copy the file using IFile.appendContents().
Have you tried the solution proposed in http://www.eclipse.org/forums/index.php/mv/msg/97927/300308/#msg_300308?