5.2 Eclipse plug-in for MetaEdit+
While the Watch Example Java code generator does not require
any IDE to be present in order to produce fully functional code, quite often
users still want to browse, compile and manage their code base from within an
IDE. In order to make this kind of tighter integration easier, MetaCase provides
a plug-in for the popular Eclipse Java IDE. The integration between MetaEdit+
and Eclipse includes:
| Launching
MetaEdit+ from Eclipse and logging in, opening MetaEdit+ projects and starting
its
API, |
| Showing
the MetaEdit+ model hierarchy in an Eclipse tree
view, |
| Opening
and editing MetaEdit+ models from
Eclipse, |
| Running
generators on MetaEdit+ models, and importing the results as Eclipse
solutions. |
After installing Eclipse, there are three alternative ways
of installing the plug-in:
With Eclipse and plug-in installed,
you can start the plug-in from the Eclipse Workbench by selecting Window |
Show view | Other | MetaEdit+ | Graph Browser. The plug-in tries to connect
to the MetaEdit+ API server at startup. If it doesn't find any available
connection, it will offer to launch MetaEdit+, start the API server, and login
to the repository. This needs some paths and other parameters, which are stored
in a ‘default.mer’ file that is saved in the root of the Eclipse
workspace. When running the plug-in for the first time there is no 'default.mer'
file. In this case the plug-in tries to find and suggest the correct paths
needed for launching MetaEdit+. It shows them to the user who can edit and
accept them by clicking Open MetaEdit+. Accepting them will open
MetaEdit+.
If the plug-in doesn’t show any models after
starting MetaEdit+ and its API, try clicking the Update Graph List icon
on the plug-in’s toolbar. If the problem persists and the plug-in reports
‘No API connection found’, it may be that the requests made to port
6390 in localhost do not get through, most likely because of a proxy or firewall
problem. On Windows, go to the Internet Explorer proxy server advanced settings
and add localhost to the list of addresses for which the proxy server is
bypassed (“Bypass proxy server for local addresses” does not seem to
be enough). If you are using Microsoft Firewall Client for ISA Server, also turn
off its “Enable Web browser automatic configuration”
setting.
When the plug-in establishes a connection to MetaEdit+, it
will populate the Graph Browser pane with a list of graphs available in
MetaEdit+ at the time (as shown in
Figure
5-1).
Figure 5-1. Eclipse plug-in.
The following operations are
available in the Graph Browser pane:
| Run
‘Autobuild’ generator for selected
graph |
| Run
selected generator for selected
graph |
| Open
selected graph in
MetaEdit+ |
| Edit
properties of the selected
graph |
| Create
new
graph |
| Update
graph
list |
| Show/hide
types |
| Setting
launch parameters |
All communication between
the plug-in and MetaEdit+ is carried out via the MetaEdit+ API. Hence, all model
editing and code generation is carried out natively in MetaEdit+ while the
generated code is loaded into, build and executed in Eclipse. To try this out,
select ‘WatchModels’ graph in Graph Browser plug-in and then
Edit
Graph Properties from its popup menu. This will open the usual property
dialog in MetaEdit+. Set ‘Java: Windows’ as the
Generation target
platform, OK the dialog and select
Run Autobuild from
‘WatchModels’ popup menu in the Graph Browser pane to launch the
code generation. After the code is generated and compiled, the test environment
will be launched (as shown in
Figure
5-2).
Figure 5-2. Using the Eclipse plug-in