Using the model spy in Eclipse. This tutorial gives an description how to use the model spy in Eclipse RCP applications.
The following assume that you installed the e4 spies.
The application model of an Eclipse application is available at runtime. The application can access the model and change it via a defined API.
To analyzing and modify the runtime model, you can use a test tool from the e4 tools project which allows modifying the application model interactively. This tool is called Model Spy (used to be called: Live model editor) and can be integrated into your RCP application. Most changes are directly applied, e.g., if you change the orientation of a part sash container, your user interface is updated automatically.
In the model spy, you can select a part in the application model, right click on it and select Show Control to get the part highlighted.
If installed you can also use the model spy to see the application model of the running Eclipse IDE itself. You can open it via the Alt+Shift+F9 shortcut.
If you modify the Eclipse IDE model, you should be careful as this might put the running Eclipse IDE into a bad state. To fix such issues, start the Eclipse IDE from the command line with the -clearPersistedState parameter.
To test the application model dynamics, integrate the model spy and its dependencies into the run configuration of your application.
The spies are debug tools and not not intended to be used in a productive application. So it might happen that this exercise does not work, or that you see additional exceptions in your log file, caused by the tool.
Ensure you have the e4 spies installed.
If you are using a target platform, add the model spies plug-ins to your target platform. Otherwise the spies cannot be integrated into your RCP application.
The update site for the e4 spies is:
Add a main menu to your window.
This can be done via the
Main Menu property on the window application model.
Ensure the id for this menu menu is set to
Open the run configuration of your product via the
org.eclipse.e4.tools.model.spy plug-in and its dependencies to it.
If you use the filter you have to remove it before the Add Required Plug-ins becomes active again.
Press the Validate button to ensure that all dependencies are included.
After you have added the new plug-ins to your run configuration press the Run button in the run configuration you just added.
Do not start the application now via the product. Starting via the product resets your changes in the runtime configuration.
Use the generated menu entry to display the model spy.
Use the model spy to change the runtime application model. For example, add a part (with a label) or change the size of the window. All changes should become immediately visible (except changes for new menu entries, due to a bug).
After testing with the tool enabled, start your application again from your product configuration file to remove the model spy plug-in from your run configuration.
If you leave the model spy included in your run configuration, it might cause side effects. For example, in the past it created exceptions if key bindings were present in the application.
I hope you enjoyed this tutorial. You find this tutorial and much more information also in the Eclipse 4 RCP book.
|TRAINING||SERVICE & SUPPORT|
The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.
The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.
Copyright © 2012-2017 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.