single click for getting xText editor support - java

In my current work, I want provide xText editor support ( because of its code completion, syntax high-lighting) to the programmers of my domain specific language. I have written grammar in xText.
To provide xText editor support, I am going to provide programmers with full eclipse IDE with xText plugin installed (available on xText website). However, I get xText editor facility at the cost of the the following manual manual steps (as discussed in 5 mins xText tutorial).
The programmers have to go to File -> New -> Project - > xText Project
The programmers have to replace “hello world” example grammars by my language grammar.
They have to go to RunAs -> Generate Xtext Artifacts.
Finally, they have to do : run -> Eclipse Application to take editor support . So, they can write dsl specification.
My question is that is there any way, which can atomize (with minimum effort) these tasks (any scripting or any other thing) in a single click?

OK I'm really not sure I understand your question. So I'll re-state what I think you're asking, and answer that. Apologies if I've misunderstood - please let me know.
So - I think you're saying:
You've developed an xtext grammar for your language
You want your users to be able to use the editor xtext has generated for the language
right now, the only way you know how to do this is to have your users emulate what you did (install xtext, create a new project,
copy in your grammar, run the generator, create a runtime instance &
then finally create files in your DSL)
You want to fix step 3. So your users can just create a new project then create a new file with your DSL extension and start editing.
If that's correct then the easiest approach is:
Select File->Export...->Plug-in Development->Deployable Features & click Next
Select your DSL project in the list of features (<your.dsl>.sdk)
Select a directory for the resulting repository and click Finish
Eclipse will generate an installable feature for you in the target dir. You then need to make the repository dir available to your users by publishing somewhere they can access. This is your Repository URL.
Your users then need to:
Install a standard eclipse distribution (the modeling tools one is suitable)
Select Help->Install New Software
Click Add to add a new repository, and enter your Repository URL
Select your feature in the list & install
From there they can create new projects & files. If they create a file with your DSL extension, your xtext-generated editor will be loaded automatically.
You can make their job even easier by generating an eclipse product. To do that you'll first need to create a product specification then use the File->Export->Plugin Development->Eclipse Product. That will create a standalone eclipse IDE with your plugin pre-installed. So your users can just install and go. There's a good tutorial here for this.
hth.

There are three options that would do such automation for you:
1- Use a general macro recording software such as AutoHotkey or Sikuli Script, so you can record these steps and replay them back. You can find similar software as well in this Wikipedia article
2- Use eclipse macro plug-in such as Practically Macro, which is an open source plugin for eclipse
3- Write your own implementation using Java Robot class which simply can generate events that are needed for automation such as keyPress, mousePress and mouseMove

Related

How to remove Java from RCP application

I am making an Eclipse product which contains the Xtext plugin.I followed this tutorial https://kthoms.wordpress.com/2010/11/12/setting-up-a-rcp-product-for-a-dsl/ and I made a running product.
I created a platform runtime feature with the "needed" plugins. Most plugins are useless and I remove them one by one. But I can't remove Java from the RCP application and some others useless plugins.
When I tried to remove jdt, for example, Xtext doesn't work anymore.
How can I remove Java from the application? Is it implement by a plugin?
Thank you for your help guys :)
If you want to remove something from platform, you can use "activities".
Open your plugin.xml, Extensions tab then add the extension org.eclipse.ui.activities
Create an activitypatternbinding child as the extension, give it an ID of your choice, then fill the pattern attribute with the eclipse id of the element you want to hide. If you want to hide java perspective, this should be something like org.eclipse.jdt.ui.JavaPerspective.
More infos here and here

Is there an equivalent of "vim: set ft=cpp:" or "-*- c++ -*-" for Eclipse?

There are occasions when there is some code in a file that does not have any extension. Such files will have code written in a single language, but each such file may be written using a different language (like C, C++, assembly language, wiki markup, and HTML for example). Similarly, the problem also happens when there is a common extension in the file name, but different files use different programming languages.
The problem I want to solve is to avoid making each individual developer that has checked out a workspace from having to figure out what kind of file a source file is (there is either no extension, or the extension does not imply the source language used). To do so, the author of the file has the responsibility of putting the right magic in the file to let the file be opened properly. Since Eclipse has the ability to disable the formatter based on some embedded text in the file, I thought it should be possible to specify the file type as well. The Open With feature allows an individual developer to change how a file is interpreted, but must be done again each time a new workspace is checked out.
In Emacs or Vim, I can place magic strings at the top of the file to indicate how I want the file to be rendered within the editor. For example:
/* -*- c++ -*- */
/* vim: set ft=cpp: */
Is there some equivalent magic for Eclipse? My attempts at finding a solution constantly pointed out how to disable the formatter. Clearly, my inexperience with Eclipse is capping my Google-Fu.
If there is no file extension, then things are a little harder. Instead of double-clicking to open the file, right-click -> Open with... -> other -> C++ editor. This will remember your choice for that file only.
ref:Quick way to set custom syntax highlighting in Eclipse
Of all the free plugins providing Vim functionality within Eclipse that are available as of 8 November 2013, namely
Vrapper
ViPlugin
Vimplugin
Eclim
...none seem to support modelines. Nevertheless, a Vrapper user asked more than a year ago if such support existed.
Note that Eclim is a special case. It might solve your problem since it allows you to use Vim as an embedded Eclipse editor. However, from within the Vim instance, Eclipse's key bindings will not work. I guess it's a trade-off between access to features and convenience. From Eclim's website:
Please be aware that the embedded vim does not behave like a standard
eclipse editor. It's a separate program (vim) embedded into eclipse,
so eclipse features are provided by eclim's vim plugins and not the
usual eclipse key bindings, context menus, etc. For those that just
want vim like key bindings in their eclipse editors, vrapper is an
excellent alternative which provides exactly that.
There used to be a commercial plugin called Viable but development seems to have stalled since 2011. Also, some users report that it breaks under Juno.
Finally, although your question is about Eclipse, it turns out NetBeans does have a plugin that supports modelines. It's called jVi. Another plugin for Netbeans is VIEX, in case you're interested.
Hope that helps!
Sources:
What vim plugins are available for Eclipse?
What are some good plugins for developing Java in VIM?
I'm not aware of any Eclipse plugin able to deal with vim-style modelines. However, AnyEdit gives you a pretty precise control over tab size and related prefs. And you can always search the marketplace.

Java: Creating a GUI-Builder for Web app with custom tags

In our project we develop a framework that is meant to encapsulate most aspects of Java web development. My clients are other programmers who use this framework.
One of the things we encapsulate are JSP tags. We created custom tags for everything so that the user is not meant to use regular HTML and JavaScript at all.
Now I'm looking at ways to create a GUI-Builder for these custom tags. Meaning some sort of GUI application that allows the user to drag and drop graphic controls onto a canvas, and then based on that the application will generate the JSP code of the page.
Please note that our custom tags are not just for abstraction. Many of them are visible controls that consist of both HTML structures and JavaScript logic to control them. And the properties of the custom tag (that the user defines in the JSP) sometimes affect it's appearance and behavior.
If the tool can be a plugin for Eclipse it would be a huge bonus.
Is there any existing tool that allows to do that?
Is there a design pattern or best-practices tutorial for creating a tool like that?
Thanks!
I had worked on developing a tool similar to what you described. In our case we wanted a drag and drop GUI tool that would create RDBMS (Tables,Columns,RelationShips) like models for our server. We used eclipse GEF plugin for that.
GEF( Graphical Editing Framework) is a very mature framework that allows you to build a drag and drop graphical editor. You can create a Palette, define different shapes,associate different shapes with different internal "models", define different kind of connectors, define what needs to be done when you drag and drop a shape in to editor etc..When I worked on it ,we build our tool as a normal eclipse plugin ( on top of GEF plugin) and deployed it on eclipse. Eclipse RCP framework was just getting started at that time.
http://www.eclipse.org/gef/
My experience is with GEF and I am pretty sure GEF will do your job. Once you download the demos and go through the code you will get an idea of what needs to be done to develop your own graphical editor.
There is another eclipse project called GMF (Graphical Modeling Framework).
GMF is built on top of GEF and EMF and provides higher-level tools to build a graphical editor ,associate it with a source code editor ( you have the "Graphical View" on one tab,you have the "source view" on the other tab) etc. GMF is sort of a "higher-level" framework that manages the GEF plumbing code for you.
http://www.eclipse.org/modeling/gmp/?project=gmf-tooling#gmf-tooling
Beware that both of the frameworks above will require some time and effort to understand. GEF is well documented. If you have had eclipse plugin development experience before thats a plus.
If you're creating an Eclipse plug-in, you're creating a multi-page editor. One (or more) page(s) for the GUI, and one page for the resulting code.
When you first construct an Eclipse plug-in, one of the multi-page editors that you run across is the editor for the MANIFEST.MF file and the plugin.xml file. This is a multi-page editor that produces two code files, rather than one.
The Eclipse for RCP and RAP Developers will help you get an Eclipse plug-in started.
Open Eclipse, and switch to the workspace you want to use to develop the plug-in.
In the Eclipse menu bar, left click on File -> New -> Project...
On the New Project dialog, open up the Plug-in Development folder, and left click on Plug-in Project.
Left click on the Next button.
On the Plug-in project dialog, give the project a name. You can accept the defaults on the rest of the dialog.
Left click on the Next button.
Accept the defaults on the Content dialog, and left click the Next button.
On the Templates dialog, left click on the "Plug-in with a multi-page editor".
Left click on the Finish button.
The Eclipse javadoc is located in the Eclipse Help at Platform Plug-in Developer Guide -> Reference -> API Reference.
To help with understanding the Eclipse javadoc, you'll need a good tutorial. The Vogella tutorial is pretty good.
If you have specific questions about your Eclipse plug-in, you can ask on Stack Overflow.

How to make an eclipse plugin for text comparison of two files

I plan to make a text comparison plugin for eclipse which basically provides a visual aid for changes that are required in the file and allows the user to accept or reject them. It is very much in lines of subclipse for svn or any other code comparison tools. I already found a good source to perform the text comparison but I'm looking for some pointers regarding the implementation of the UI in eclipse.
Eclipse already supports this. Select two files, go to Compare With, choose 'Each other'. Does this work for you?
Buy a copy of "Eclipse Plugins" by Clayberg and Rubel.
For what it is worth ... Eclipse already includes text file comparison tools as standard.

How to generate UML diagrams (especially sequence diagrams) from Java code?

How can I generate UML diagrams (especially sequence diagrams) from existing Java code?
ObjectAid UML Explorer
Is what I used. It is easily installed from the repository:
Name: ObjectAid UML Explorer
Location: http://www.objectaid.com/update/current
And produces quite nice UML diagrams:
Description from the website:
The ObjectAid UML Explorer is different from other UML tools. It uses
the UML notation to show a graphical representation of existing code
that is as accurate and up-to-date as your text editor, while being
very easy to use. Several unique features make this possible:
Your source code and libraries are the model that is displayed, they are not reverse engineered into a different format.
If you update your code in Eclipse, your diagram is updated as well; there is no need to reverse engineer source code.
Refactoring updates your diagram as well as your source code. When you rename a field or move a class, your diagram simply reflects the
changes without going out of sync.
All diagrams in your Eclipse workspace are updated with refactoring changes as appropriate. If necessary, they are checked out of your
version control system.
Diagrams are fully integrated into the Eclipse IDE. You can drag Java classes from any other view onto the diagram, and diagram-related
information is shown in other views wherever applicable.
EDIT:
If you're a designer then Papyrus is your best choice it's very advanced and full of features, but if you just want to sketch out some UML diagrams and easy installation then ObjectAid is pretty cool and it doesn't require any plugins I just installed it over Eclipse-Java EE and works great !.
UPDATE Oct 11th, 2013
My original post was in June 2012 a lot of things have changed many tools has grown and others didn't. Since I'm going back to do some modeling and also getting some replies to the post I decided to install papyrus again and will investigate other possible UML modeling solutions again. UML generation (with synchronization feature) is really important not to software designer but to the average developer.
I wish papyrus had straightforward way to Reverse Engineer classes into UML class diagram and It would be super cool if that reverse engineering had a synchronization feature, but unfortunately papyrus project is full of features and I think developers there have already much at hand since also many actions you do over papyrus might not give you any response and just nothing happens but that's out of this question scope anyway.
The Answer (Oct 11th, 2013)
Tools
Download Papyrus
Go to Help -> Install New Software...
In the Work with: drop-down, select --All Available Sites--
In the filter, type in Papyrus
After installation finishes restart Eclipse
Repeat steps 1-3 and this time, install Modisco
Steps
In your java project (assume it's called MyProject) create a folder e.g UML
Right click over the project name -> Discovery -> Discoverer -> Discover Java and inventory model from java project, a file called MyProject_kdm.xmi will be generated.
Right click project name file --> new --> papyrus model -> and call it MyProject.
Move the three generated files MyProject.di , MyProject.notation, MyProject.uml to the UML folder
Right click on MyProject_kdm.xmi -> Discovery -> Discoverer -> Discover UML model from KDM code again you'll get a property dialog set the serialization prop to TRUE to generate a file named MyProject.uml
Move generated MyProject.uml which was generated at root, to UML folder, Eclipse will ask you If you wanted to replace it click yes. What we did in here was that we replaced an empty model with a generated one.
ALT+W -> show view -> papyrus -> model explorer
In that view, you'll find your classes like in the picture
In the view Right click root model -> New diagram
Then start grabbing classes to the diagram from the view
Some features
To show the class elements (variables, functions etc) Right click on any class -> Filters -> show/hide contents Voila !!
You can have default friendly color settings from Window -> pereferences -> papyrus -> class diagram
one very important setting is Arrange when you drop the classes they get a cramped right click on any empty space at a class diagram and click Arrange All
Arrows in the model explorer view can be grabbed to the diagram to show generalization, realization etc
After all of that your settings will show diagrams like
Synchronization isn't available as far as I know you'll need to manually import any new classes.
That's all, And don't buy commercial products unless you really need it, papyrus is actually great and sophisticated instead donate or something.
Disclaimer: I've no relation to the papyrus people, in fact, I didn't like papyrus at first until I did lots of research and experienced it with some patience. And will get back to this post again when I try other free tools.
What is your codebase? Java or C++?
eUML2 for Java is a powerful UML modeler designed for Java developper
in Eclipse. The free edition can be used for commercial use. It
supports the following features:
CVS and Team Support
Designed for large project with multiple and customizable model views
Helios Compliant
Real-time code/model synchronization
UML2.1 compliant and support of OMG XMI
JDK 1.4 and 1.5 support
The commercial edition provides:
Advanced reversed engineering
Powerful true dependency analyze tools
UML Profile and MDD
Database tools
Customizable template support
I am one of the authors, so the answer can be biased. It is open-source (Apache 2.0), but the plugin is not free. You don't have to pay (obviously) if you clone and build it locally.
On Intellij IDEA, ZenUML can generate sequence diagram from Java code.
Check it out at https://plugins.jetbrains.com/plugin/12437-zenuml-support
Source code: https://github.com/ZenUml/jetbrains-zenuml
How about PlantUML?
It's not for reverse engineering!!! It's for engineering before you code.
I developed a maven plugin that can both, be run from CLI as a plugin goal, or import as dependency and programmatically use the parser, #see Main#main() to get the idea on how.
It renders PlantUML src code of desired packages recursively that you can edit manually if needed (hopefully you won't). Then, by pasting the code in the plantUML page, or by downloading plant's jar you can render the UML diagram as a png image.
Check it out here https://github.com/juanmf/Java2PlantUML
Example output diagram:
Any contribution is more than welcome. It has a set of filters that customize output but I didn't expose these yet in the plugin CLI params.
It's important to note that it's not limited to your *.java files, it can render UML diagrams src from you maven dependencies as well. This is very handy to understand libraries you depend on. It actually inspects compiled classes with reflection so no source needed
Be the 1st to star it at GitHub :P
I would recommend EclipseUML from Omondo for general usage, although I did experience some problems a few months back, with my web projects. They had a free edition at one point in time, but that is supposedly no longer promoted.
If you are really keen on reverse engineering sequence diagrams from source code, I would recommend jTracert.
As far as Eclipse projects themselves are concerned, the Eclipse UML2 Tools project might support reverse engineering, although I've have never seen its use in practice.
The MoDisco (Model Discovery) project Eclipse GMT project seems to be clearer in achieving your objective. The list of technology specific tools would be a good place to start with.
I found Green plugin very simple to use and to generate class diagram from source code.
Give it a try :).
Just copy the plugin to your plugin dir.
Using IntelliJ IDEA. To generate class diagram select package and press Ctrl + Alt + U:
By default, it displays only class names and not all dependencies. To change it: right click -> Show Categories... and Show dependencies:
To genarate dependencies diagram (UML Deployment diagram) and you use maven go View -> Tool Windows -> Maven Projects and press Ctrl + Alt + U:
The result:
Also it is possible to generate more others diagrams. See documentation.
You could also give the netbeans UML modeller a try. I have used it to generate javacode that I used in my eclipse projects. You can even import eclipse projects in netbeans and keep the eclipse settings synced with the netbeans project settings.
I tried several UML modellers for eclipse and wasn't satisfied with them. They were either unstable, complicated or just plain ugly. ;-)
You can use the 30 days evaluation build of EclipseUML for Eclipse 3.5 : http://www.uml2.org/eclipse-java-galileo-SR2-win32_eclipseUML2.2_package_may2010.zip
This is not the latest 3.6 build, but is pretty good and don't require you purchase it for testing and reverse engineering.
Reverse engineering : http://www.forum-omondo.com/documentation_eclipseuml_2008/reverse/reverse/reverse_engineering_example.html
Live flash demo: http://www.ejb3.org/reverse.swf
EclipseUML Omondo is the best tool in the world for Java. Only eUML seems to compete with it on this live java synchronization market, but eUML adds model tags in the code which is really very very bad and a definitive no go for me.
I've noticed SequenceDiagram plugin for Intellij is also a good option.
By far the best tool I have used for reverse engineering, and round tripping java -> UML is Borland's Together. It is based on Eclipse (not just a single plugin) and really works well.
Another modelling tool for Java is (my) website GitUML.
Generate UML diagrams from Java or Python code stored in GitHub repositories.
One key idea with GitUML is to address one of the problems with "documentation": that diagrams are always out of date. With GitUML, diagrams automatically update when you push code using git.
Browse through community UML diagrams, there are some Java design patterns there. Surf through popular GitHub repositories and visualise the architectures and patterns in them.
Create diagrams using point and click. There is no drag drop editor, just click on the classes in the repository tree that you want to visualise:
The underlying technology is PlantUML based, which means you can refine your diagrams with additional PlantUML markup.
There is a Free tool named binarydoc which can generate UML Sequence Diagram, or Control Flow Graph (CFG) from the bytecode (instead of source code) of a Java method.
Here is an sample diagram binarydoc generated for the java method java.net.AbstractPlainSocketImpl.getInputStream:
Control Flow Graph of method java.net.AbstractPlainSocketImpl.getInputStream:
UML Sequence Diagram of method java.net.AbstractPlainSocketImpl.getInputStream:
I suggest PlantUML. this tools is very usefull and easy to use. PlantUML have a plugin for Netbeans that you can create UML diagram from your java code.
you can install PlantUML plugin in the netbeans by this method:
Netbeans Menu -> Tools -> Plugin
Now select Available Plugins and then find PlantUML and install it.
For more information go to website: www.plantuml.com

Categories