script generation in GMF - eclipse-plugin

i have created my own graphical editor using GMF.
i want to generate code based on the diagram created by editor? any pointers how to proceed

This might help you:
http://www.vogella.de/articles/EclipseBuilder/article.html
That page doesn't have the actual code example but the points to the necessary concepts: Builders. For example, the java compiler is hooked in through a builder that's registered for the .java type.

Related

Auto Generate code in java based on templates

I have a eclipse plugin and I want to add a capability to generate java code blocks based on simple template or anything simple. Something like generate source for constructors or getters and setters that java editor provides.
I have seen the JET articles : https://eclipse.org/articles/Article-JET2/jet_tutorial2.html but I want something simpler.
Eclipse already some has it built in:
1. Highlight your field
2. Right Click -> Source -> Generate Getters and Setters
Also you can use the wizards to create a basic java class.
1. File -> New -> Class
etc.
You can also look up this related question:
A Java API to generate Java source files

Changing VB.NET code programmatically

I want to open an existing VB class file, add a few properties and close it again.
Simple enough, I thought: Take the CodeDom, a VBCodeProvider, parse the code (using the Parse-method), then identify the location where I want my stuff added (doubtless using some nifty LINQ expressions), add a bit of code and then have it generated and here we go.
Now I see that Microsoft apparently added the Parse method only for the fun of it but never implemented it.
What's the story here? Can I only generate code from scratch? Is it not possible to load existing code?
Does anyone know of any solutions?
You say "class files" and then you say "parse". I think you meant "parse and modify".
Our DMS Software Reengineering Toolkit with its Visual Basic Front End can do what you need on VB.net source code files.
DMS provides general parsing, AST-building, generic analysis and AST transformations, and is able to regenerate source text in compilable form. The Visual Basic Front End enables DMS to process VB.net, VBScript or VB6 and carry out any of these activities.
DMS's Source-to-Source transformations can be used to make changes using "if-you-see-this, replace-it-by-that" patterns.

Mscgen / trace2uml input file generator from source code

is there a way to generate Mscgen / trace2uml compatible input files (description files/text) from source code, to be able to later generate the sequence diagrams? The project homepages mention Message Sequence Chart descriptions that no program seem to generate. I would hate to go over the entire code and create the sequence descriptors myself. Other tools that would let me generate sequence diagrams from source code would help too..
"generating sequence charts from source code" is not possible. Because a state chart is not a statically view to the program, but a view to an example of a program RUN.
But you can "trace" a program, while it is running, and use the trace output for the diagram. Thats the reason, why Trace2UML is called "trace to uml" ;-)
All you need is a trace framework (class) that does the correct trace formate.
A good one is "Trace2UML.cpp" you can find in the Astade distribution.
e.g.: http://daily.astade.de/2011-08-25/astade-1.1.4-dev-2375.tar.gz

Find child plug-ins of features in eclipse workspace

I want to find all the child plug-ins of a feature ? I know the name of the feature, but IWorkspaceRoot.getProject(String) does not really help me. I get an IProject that I don't know how to convert to a feature object (IFeature ?). Maybe I am on the wrong track and there is a better / easier way to do this. Any ideas ?
You could check that a selected IProject is a feature project by checking for the nature called org.eclipse.pde.FeatureNature.
Then you could try to use IProject.getAdapter(IFeature.class) call, the cast the result to IFeature. I did not try this with feature projects, but works well with Java projects.
The correct answer is the use of PDECore static class. This class provides a FeatureModelManager, that would provide the corresponding information:
FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager();
How to obtain this information? I looked with the plug-in spy to find which project defines the 'Deployable Features' export wizard (use Alt+Shift+F3 when the wizard is selected), and then looked at the implementation of the wizard class, where the addPages() method contains the previously described code block.

Integrate JET Templates to an EMF-GMF plugin

I created an plugin that lets me model JSF Applications. I created it using Emfatic, Ecore, EMF, GMF.
So now i have 5 projects in my workspace:
myapp
myapp.diagram
myapp.edit
myapp.editor
myapp.tests
If i run myapp as a Eclipse Application i can draw/design a .myapp_diagram based on the meta-model.
Now I want to know how can i integrate JET Templates with what i have here.
I have the diagram, i know how to build JET Templates, i just want to know how can i feed the diagram as input to the JET temples so that code will be generated.
What i have done until now is convert the "myapp" project to JET Project and wrote the template files. But if i now run "myapp" and draw a diagram, theres nowhere a GENERATE CODE button/option.
Unfortunately none of the Eclipse-based modelling projects provide a "generate code" button. There are a wide range of possible model sources and code generation platforms (JET, OAW, Xpand), so you will have to implement the button and the relevant source code yourself. However, the process is fairly straightforward.
One approach is to implement an org.eclipse.ui.popupMenus extension point, which then calls the Java class necessary to generate the code.
As an example, you can check out the plugin.xml used in the IAML project to generate PHP/Javascript source code, using openArchitectureWare (OAW) templates. The relevant Eclipse Action is GenerateCodeAction - check out the method doExecute(). Hope this helps :)