Eclipse plugin - nodes and connection + code generation - java

I'd like to create an Eclipse extension modelling a decision tree/diagram. The actual modelling would be done using a graphical interface (nodes, connections etc). I'd like this plugin to generate code based on nodes and their interconnections. I have basic model classes ready; however, my diagrams are very large and it's difficult to manage all the connections only through code. I imagine I would build the whole diagram using GUI. When I double-click on a connection, I'd like to be able to override some of its methods, thus creating an anonymous subclass.
I found GEF used in similar plugins. Is my goal plugin "doable" in GEF? Do you have any advice?

Yes. GEF is the foundation for building any graphical editor in Eclipse. It has basic support for moving nodes, placing connection, palette, etc. Other frameworks sit on top of GEF to make the task of creating a graphical editor even easier if your requirements fit with their supported scenarios. Take a look at Eclipse Graphiti project.

I would say that GMF is something that would help your life. GMF generates quite big parts for free, and also includes EMF.
Also GMF is highly extendeable, so if you don't like something it has generated, you can just override those parts.
There are good GMF tutorial here: http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial

Related

Is there any alternative to build a Java editor without Eclipse?

Some context here first. We currently have a tool that is written in Eclipse, a RCP app, that is basically a Java Editor simplified that also does some other basic stuff (not relevant at the moment)
The problem we're having is that is just too big, whenever we use it we face a lot problems because its a memory hog, and it feels slow. So I'm considering alternatives to using Eclipse. I know I can probably do all the front-end stuff easily with Swing, SwingX or JavaFX (just to name a few) but I'm more worried about the built-in capabilities that Eclipse provides to create a code editor (intellisense-code syntax highlight and checker, etc)...will this be possible to replace out of Eclipse? Are there any projects out there that could be used for that?
Thanks!

How to implement a Modeling Application with GUI

I'm trying to implement a application with GUI in Java that can let users build a model using certain predefined modeling language.
Is there any approach that I could easily build a GUI where user can do "drag a circle into canvas", "connect this circle with that rectangle", etc?
Or I should just use Swing.(maybe Swing Builder for simplicity). listen to the action of mouse and draw something accordingly?
Also I found Graphic Modeling Frame work in Eclipse very interesting, but I'm not sure if I could integrate it into my App easily.
Personally, I would give the Eclipse Modeling Framework a try before starting to write something in Swing (or SwingBuilder - you mean the Swing framework for Groovy?), unless you need something very simple and you are quite sure the required functionality will remain small.
According to the FAQ on the Eclipse wiki, it is possible to use EMF standalone in your application:
"I want to use EMF, SDO, or XSD in my standalone project, or include only a working subset of the code. What libraries (jar files) do I need in my CLASSPATH?
Eclipse Modeling Framework (EMF) provides the infrastructure to run the generated models and dynamic model based on existing ecore files. It also provides XMI/XML serialization and deserialization.
The following jars can be used in standalone mode. [Lists of jars are provided for several scenarios.]"
This EMF tutorial by Lars Vogel could also be useful.

Generating Class Diagram

HI All I am at the end of the release of my project.So in order to keep working our manager asked us to generate Class Diagrams for the code we had written.Its medium project with 3500 java files .So I think we need to generate class diagrams.First I need to know how reverse engineering works here. Also I looked for some tools in Google(Green, Violet) but not sure
whether they are of any help.Please suggest me how to proceed.Also a good beginning tutorial is appreciated.
I strongly recommend BOUML. Its Java reverse support is absolutely ROCK SOLID.
BOUML has many other advanteges:
it is extremely fast (fastest UML tool ever created, check out benchmarks),
has rock solid C++, Java, PHP and others import support,
it is multiplatform (Linux, Windows, other OSes),
has a great SVG export support, which is important, because viewing large graphs in vector format, which scales fast in e.g. Firefox, is very convenient (you can quickly switch between "birds eye" view and class detail view),
it is full featured, impressively intensively developed (look at development history, it's hard to believe that such fast progress is possible).
supports plugins, has modular architecture (this allows user contributions, looks like BOUML community is forming up)
The tool you want to use is Doxygen. It's similar to Javadoc, but works across multiple languages. If figures out the dependencies, and can call graphviz to render the class diagrams. Here's an example of a few Java classes run through Doxygen.
This is more a toolchain than a tool and I haven't tried it out myself. But it maybe a starting point. Using UMLGraph, ant and GraphViz. Explained step by step: in this article.
I ve used Visual Paradigm for UML for what you want to do and it was quite good.
See here for details.
Just go Tools -> Instant reverse and select your packages.
You may be able to reverse engineer class diagrams with the open source modelleing tool ArgoUML http://argouml.tigris.org/
ObjectAid is pretty nice. You can drag classes into a diagram and arrange them the way you want.
Visual Paradigm for UML Standard Edition (or Better) will reverse engineer Java files in to Class Diagrams.
I guess if your boss just wants to keep you busy until the next project starts then there's no harm in it, but you will find pretty quickly that creating a class diagram with 3500 classes will tell you exactly NOTHING about your system. In fact, you don't really want a diagram with more than about 10 classes on it. So once you have reversed all the code into your modelling tool, you will want to start organizing and arranging to find the meaning. Create a new diagram, drop a single important class onto it and bring in all the classes that are directly related to that class. Repeat for maybe the 300 most significant classes. Don't worry, it isn't as horrible as it sounds, maybe a week's work.
For the record, my modelling tool of choice is Enterprise Architect by Sparx Systems. It will reverse java sources or .jar files. There is a free 30 day trial edition.
There are some tools available that will help you generate these diagrams. These cost money.
Otherwise you could to try to parse your Java files. This could be as simple to create a simple parser that reads the Java files and writes the name of the class and all the import statements to a file and generates a class diagram from there, graphviz can help you there.
I've been using Enterprise Architect for a number of years. A JBoss developer suggested it to me. It works very well for all types of UML modeling including the reverse engineering of class models (Java, C# and others). The basic version is currently $120 per seat, but it has most of the capabilities of much more expensive tools and it is much easier to learn. I particularly like its ability to generate HTML and RTF documentation.
It is very easy to synchronize code between the tool and your source code. Even bi-directional if you want.
Your PM may also like the activity and sequence diagrams that it can create. I also frequently use the deployment diagrams. It's very helpful to have all of this in one tool.

Does anyone have any experiences with Eclipse GMF?

I've just started to play around with Eclipse GMF.
Has anyone used the framework?
Any good or bad experiences you had using it?
Any alternatives for graphical modeling you could suggest?
EDIT: What good examples are available?
Has anyone used the framework? Yes, I am using it right now. It works, but it is typically quite a bit of coding for the graphical figures. I currently am struggling to leverage the IBM RSA/RSM UML editparts/figures/nodes etc built on top of GMF.
Any good or bad experiences you made using it? Looking back on my initial dives into GMF/EMF/GEF etc I can say for certain, study the examples. There are important patterns that you have to pick-up on from the examples and not the documentation. I would also suggest a new book (Eclipse Modeling Project: A Domain-Specific Language (DSL)) specific for GMF Modeling in Eclipse. I paged through it and it seemed to be the missing manual to some of the more basic concepts. Why the book is good is that is focuses on the key to making UML/Models useful through constraining it to a specific domain and providing a tool that only allows for valid models to be created. There is not a lot of documentation online and the API only tells you so much. WATCH OUT for repaint/paint loops caused by calling setBounds() or other set methods on children, it crashes the eclipse instance, not fun. Oh yes and the APIs are split between eclipse help documentation versions or not included at all.
Any alternatives for graphical modeling you could suggest?
Consider UML profiles with custom images and icons rather than full shape generation. It takes about 2 hours to put together a pretty good Image/Icon editor building on top of UML graphical objects and UML profiles. The IBM RSM tool UML Profile tooling project does this quickly. There is a lot you can do with constrained UML profiles (via Eclipse plug-ins or OCL). Entering GMF land is more than a order of magnitude effort increase, from 1 to 10 hours no problem.
Consider pure DSL (Domain specific language) tools out there. Google will provide a good list. From what I have seen the main reason to use GMF is eclipse integration and leveraging existing ecore/UML models, this is why I use GMF.
Ask yourself do I need model which is easy, or do I need a tool for creating instances of this model. If there are only 1-5 expert users there may not be a need for a sleek tool.
The TOPCASED project makes use of GMF. It provides various graphical editors for UML and other diagrams.
With GMF, most of the editor code is generated for you, but the main complexity arises from having to modify it.
As most recent alternatives, you might try Graphiti and Spray. Here is a comparison and another between GMF and Graphiti.

What does either Java GUI editor offer for rapid development and maintainability (i.e., Eclipse/SWT and Netbeans/Matisse)?

Between Eclipse/SWT or Netbeans/Matisse, what does either Java GUI editor give you in terms of rapid development and maintainability?
You are really asking two different questions: SWT vs Swing, and Eclipse GUI Editor vs Netbeans GUI Editor (Matisse).
First, the difference between SWT and Swing is that they are two fundamentally different GUI libraries. This akin to asking the difference between Tk and Win32, or Java Swing vs .NET Forms (not to say that SWT is .NET). There are a lot of discussions out there discussing SWT vs Swing--I don't know enough about SWT to summarize the differences.
First, let me say my bias is in favor of Netbeans and I have spent 10 years learning the IDE from its days as Forte.
As far as the GUI editor, Eclipse and Netbeans have functionally similar products, but implement the code in very different ways.
My observation is that Matisse behaves, functions, and produces code that's reminiscent of Visual Studio .NET code. There are clear initialziation sections and custom behaviors for certain objects (such as the JTable). You can "Customize" an object and add your own arbitrary code via the GUI editor very easily for everything from initialization to setting individual properties. For event handling, it defaults to replicating "delegates" in .NET by using anonymous inner classes and invoking a stand-alone method. The GUI editor itself provides detailed access to the form object model and has a rich set of customizations. You also have the freedom to drop non-GUI beans into the form for use by GUI components, such as models (tablemodel, listmodel, etc), JPA-related objects, Workers, etc. What used to take a week to produce with hand-coded SWING takes a day with Matisse (though you have to really learn Matisse to do this). If you've been hand-coding swing for many years, then relearning to use a GUI editor effectively is going to be a long, hard lession.
The code is highly maintainable from within Matisse; it is NOT intended to be edited outside of Matisse, but the code is suitable for editing if you needed to (many folks I know use Netbeans GUI and then copy the source into Eclipse).
The Eclipse GUI editor is a very different creature. The GUI editor(s) are roughly the same in terms of overall capability, but I have found them to be less polished. The layout capabilities are about equal, though errors are a bit less forgiving at times. Some customizations required me to go to the source file and edit the file directly, rather than getting access to code customizations through the GUI. The code produced is very different than Matisse. GUI Components are added and initialized through "getters" and is scattered throughout the file; this good because each component is isolated/grouped into a single function, but troublesome when you need to diagnose bad interactions between component initialization. The same goes with the event handlers--very different than matisse.
Eclipse also did not provide any protections from me editing/breaking/tampering with the produced GUI file where as Netbeans was almost obnoxious with its protections. As far as maintainability, the Eclipse code is probably a little closer to the way a human would produce Java code... personally, I find the code it produces harder to maintain, but I've been looking at Matisse generated code since the first beta so my opinion is hardly objective on this issue.
Netbeans also has the capability of using the same editor for building Swing framework applications, Netbeans RCP, etc... I am unsure if Eclipse does the same.
This is definitely subjective -- we use both, Eclipse and Netbeans. I think it comes down to a matter of preference.
No one can tell you which is better. This is completely subject to change per developer. Here's a google search for "Eclipse vs Netbeans" and you can look at some pros and cons which others have poured their thoughts into already. Eclipse vs. NetBeans
I think you should put more research into whether you want the resulting application to be SWT or Swing-based. Which IDE to use should be the least important factor.
I'm personally an Eclipse user, but I heard very good things about Matisse, so I would probably consider it if I had to build a Swing UI. BTW, if you buy MyEclipse, it integrates Matisse.
Some may contend that the end product you want to use actually depends on how easy it is to use - which is hinted at in the question.
This article suggests that the Netbeans/Matisse editor is easier to use - and so you should use it on your projects.
http://cld.blog-city.com/netbeans_matisse_versus_eclipses_visual_editor__no_contest.htm

Categories

Resources