Chapter 9. UI improvements

This chapter introduces the code needed to deploy a Kermeta code for a end user (eclipse GUI). It will use the interpreter as sample.

9.1. GUI deployment setup

We need to add some GUI elements to interact with the interpreter sample through eclipse GUI. To do so, we are going to set up 2 plugin projects one to handle ui settings and one to handle needed libraries :

  1. Create a new plug-in project and name it : org.kermeta.kmlogo.logoasm.ui. This plugin project contains the eclipse extension and the code that allows to launch a kermeta program from Eclipse GUI. This hides the language in which the transformation is written in to the end user.

    On the creational wizard : Be sure that you set the activator at org.kermeta.kmlogo.logoasm.ui.Activator then hit next.

    Check custom plug-in wizard and hit next, select New File Wizard and Popup Menu then hit next.

  2. In the New Wizard Option :

    • set the Java package name to org.kermeta.kmlogo.logoasm.ui.tools.wizards;

    • set Wizard Category Name to Kermeta samples;

    • set WizardClass Name to KmLogoExampleWizard;

    • set WizardPage Class Name to KmLogoExampleWizardPage

    • set Wizard name to KmLogo samples;

    • file extension to kmt and inital file name to new_file.kmt.

    In the Sample Popup Menu

    • set Submenu name to Logo;

    • set Action Label to Run Logo Simulator;

    • set Java package name to org.kermeta.kmlogo.logoasm.ui.popup.actions;

    • set Action Class to RunLogo and hit finish;

    If you are asked wether to open the plug-in perspective which you are not familiar with, you can choose "No".

  3. Copy (and replace) all the files :

    • CompileNXCLogoK.java, ExecHelper.java, RunLogoK.java, ConvertToLogosmK, ConvertToLogoK, Activator.java from the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiSetting/ui into the package org.kermeta.kmlogo.logoasm.ui;

    • CompileLogoNXC.java, RunLogo.java, ConvertToLogoasm, ConvertToLogo, from the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiSetting/popup into the package org.kermeta.kmlogo.logoasm.ui.popup.actions;

    • KmLogoExampleWizard.java into the package org.kermeta.kmlogo.logoasm.ui.tools.wizard.

    Inside the package org.kermeta.kmlogo.logoasm.ui.tools.wizard, delete the file KmLogoExampleWizardPage.java since we do not use it.

    (Update : Inside the package org.kermeta.kmlogo.logoasm.ui.popup.actions, delete the file NewAction.java if it exists).

    It is normal that you got errors at this time just because there are needed libraries that we should define inside steps ahead.

  4. Copy the file org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiSetting/plugin/plugin.xml and overwrite the one in the created project.

    Open the file and have a look to the popupMenus extension. They declare the actions for the end user.

  5. Copy the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiSetting/icons to the root of the project org.kermeta.kmlogo.logoasm.ui so as to set up the correct icons for the ui.

    Copy (and replace) the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiSetting/editor/icons to the root of the project org.kermeta.kmlogo.logoasm.editor so as to set up the correct icons for the ui.

  6. Copy (and replace) the file META-INF/MANIFEST.MF by the one from org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiSetting/plugin.

    Open the file and have a look at the dependencies and the export package of the project. We've done with the first plugin project, let's now move on to the second one.

    [Caution]Caution

    RunLogo.java is the code to call the Logo interpreter (the operational behavior we've defined for it). Open it and look at how is manipulated the kmt file;

    RunLogoK.java is the code that calls Kermeta interpreter with a given kermeta program and parameters. In addition to initializing the interpreter, this code also sets the correct java classpath. Otherwise, Kermeta interpreter will not correctly find the java code called via the "extern".

    You should now have no errors (if there's one left reffering to an unresolved "LogoResourceFactory" regenerate the code for texteditor (repeat step 4 of 4.3))

  7. Create a new plug-in project and name it : org.kermeta.kmlogo.logoasm.ui.osspecific. This plugin project handles the implementation of specific missing libraries according to each platform.

    On the creational wizard : Be sure that you set the activator at org.kermeta.kmlogo.logoasm.ui.osspecific.Activator then hit next.

    Select custom plug-in wizard and hit next, select Popup Menu then hit next.

  8. In the Sample Popup Menu

    • set Submenu name to Logo;

    • set Action Label to Compile to NXT Binary (*.rxe);

    • set Java package name to org.kermeta.kmlogo.logoasm.ui.popup.actions;

    • set Action Class to NXC2RXE then hit finish;

    If you are asked wether to open the plug-in perspective which you are not familiar with, you can choose "No".

  9. Copy (and replace) all the files from the folder :

    • Activator.java from the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiOsSpecific/ui into the packageorg.kermeta.kmlogo.logoasm.ui.osspecific;

    • UploadRXE.java from the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiOsSpecific/popup into the package org.kermeta.kmlogo.logoasm.ui.osspecific.actions;

    It is normal that you got errors at this time just because there are needed libraries that we should define in next step.

  10. Set up the missing libraries : Copy the folder org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiOsSpecific/lib and paste it into your root project.

    Unfold this folder, add bluecove.jar, icommand.jar, RXTXcomm.jar to the Java build path (right-click) and move to the next step.

  11. Copy the file org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiOsSpecific/plugin/plugin.xml and overwrite the one in the created project.

    Open the file and have a look to the popupMenus extension. They declares the actions for the end user.

    [Note]Note

    You can customize with your own action by opening the Extensions tab of plugin.xml file and choose add button to add your action.

  12. Copy and replace the file META-INF/MANIFEST.MF by the one from org.kermeta.kmlogo.logoasm.tutorial/parts/5.ui/uiOsSpecific/plugin.

    Open the file and have a look at the dependencies and the export package of the project.

To be sure that the editor's configuration has not been overwridden, right-click on org.kermeta.kmlogo.logoasm.emftexteditor/concrete_syntax/ASMLogo.cs and choose to Generate Text Ressource again.

Now that everything is correctly configured, let's jump into the last step of this tutorial which is the deployement the Logo demo.