Index: trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java
===================================================================
--- trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java	(revision 1674)
+++ trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java	(revision 1678)
@@ -24,4 +24,5 @@
 import java.util.Iterator;
 import java.util.List;
+import java.util.UUID;
 import java.util.logging.Level;
 
@@ -30,4 +31,5 @@
 import de.ugoe.cs.util.console.Command;
 import de.ugoe.cs.autoquest.eventcore.Event;
+import de.ugoe.cs.autoquest.eventcore.IEventTarget;
 import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
 import de.ugoe.cs.util.console.Console;
@@ -43,4 +45,6 @@
  */
 public class CMDgenerateJacaretoReplay implements Command {
+
+    private int nextRef;
 
     /*
@@ -108,5 +112,5 @@
         writeLine(writer,
                   "<KeyboardState procTime=\"0\" duration=\"0\" isNumLockOn=\"false\" isScrollLockOn=\"false\" isCapsLockOn=\"false\" applyIsNumLockOn=\"true\" applyIsScrollLockOn=\"true\" applyIsCapsLockOn=\"true\" uuid=\"28146f79-9fc7-49f9-b4a8-5866a7625683\" />");
-        writeLine(writer, "ComponentMode numberPopupMenues=\"true\" />");
+        writeLine(writer, "<ComponentMode numberPopupMenues=\"true\" />");
         writeLine(writer,
                   "<ApplicationStarter procTime=\"5\" duration=\"5\" name=\"HelloWorldSwing\" class=\"HelloWorldSwing\" initclass=\"\" basepath=\"/home/daniel/project/autoquest-jfcmonitor\" classpathext=\"${basepath}/helloswing.jar;${basepath}/.;\" detectDuration=\"false\" captureparams=\"\" replayparams=\"\" uuid=\"a7b7d7b9-caa9-4d6d-b052-cf74d353275e\" />");
@@ -120,8 +124,10 @@
         structure.add("<StructureElement class=\"jacareto.struct.RootElement\">");
         // reference the elements that we included in the header
-        structure.add("<Recordable ref=\"1\" />"); // Calendar
-        structure.add("<Recordable ref=\"2\" />"); // SystemInfo
-        structure.add("<Recordable ref=\"3\" />"); // KeyboardState
+        structure.add("<Recordable ref=\"0\" />"); // Calendar
+        structure.add("<Recordable ref=\"1\" />"); // SystemInfo
+        structure.add("<Recordable ref=\"2\" />"); // KeyboardState
+        structure.add("<Recordable ref=\"3\" />"); // ComponentMode
         structure.add("<Recordable ref=\"4\" />"); // ApplicationStarter
+        nextRef = 5;
 
         for (List<Event> sequence : sequences) {
@@ -131,15 +137,37 @@
                 // TODO: do a mapping file or something to map
                 // from autoquest events to jacareto events
-                if (event.getType().getName().equals("KeyboardFocusChange")) {
-                    /*
-                    writeLine(
-                        "<FocusEvent procTime=\"0\" duration=\"0\" source="JFrame_(1).JRootPane_(1).JLayeredPane_(1).JPanel_(1).JPanel_(1).JCheckBox_(1)" +" +
-                        "       class="javax.swing.JCheckBox" uuid="061bee8f-d8a3-477f-ab8d-bab02f614916" ID="1004" component="null" root="JFrame_(1)" xPos="0" yPos="0" width="0" height="0" isTemporary="false" />");
-                    */
-                    System.out.println(((JFCGUIElement)event.getTarget()).getJacaretoHierarchy());
-                }
-                else {
-                    System.out.println(event.getType());
-                    System.out.println(event.getTarget());
+                if (event.getType().getName().equals("LeftMouseClick")) {
+                    JFCGUIElement target = (JFCGUIElement) event.getTarget();
+
+                    // FIXME: assume that the target is a checkbox for now =)
+                    // this is an item event and an action event in jacareto
+                    //@formatter:off
+                    writeLine(writer,
+                        "<ItemEvent "
+                        + "procTime=\"1\" "
+                        + "duration=\"8\" "
+                        + "source=\"" + target.getJacaretoHierarchy() + "\" "
+                        + "class=\"" + target.getSpecification().getType() + "\" "
+                        + "uuid=\"" + UUID.randomUUID() + "\" "
+                        + "ID=\"701\" "
+                        + "item=\"\" "
+                        + "stateChange=\"1\" />"
+                    );
+                    writeLine(writer,
+                        "<ActionEvent "
+                        + "procTime=\"1\" "
+                        + "duration=\"0\" "
+                        + "source=\"" + target.getJacaretoHierarchy() + "\" "
+                        + "class=\"" + target.getSpecification().getType() + "\" "
+                        + "uuid=\"" + UUID.randomUUID() + "\" "
+                        + "ID=\"1001\" "
+                        + "command=" + target.getName() + " "
+                        + "modifiers=\"16\" />"
+                    );
+                    //@formatter:on
+                    structure.add("<StructureElement class=\"jacareto.struct.ItemStateChange\">");
+                    structure.add("<Recordable ref=\"" + (nextRef++) + "\" />");
+                    structure.add("<Recordable ref=\"" + (nextRef++) + "\" />");
+                    structure.add("</StructureElement>");
                 }
             }
@@ -159,4 +187,6 @@
             writeLine(writer, element);
         }
+        // close root element
+        writeLine(writer, "</StructureElement>");
         writeLine(writer, "</Structure>");
     }
@@ -169,5 +199,5 @@
             ArrayList<String> structure = writeJacaretoEvents(writer, sequences);
             writeJacaretoTail(writer, structure);
-            writeLine(writer, "<JacaretoStructure>");
+            writeLine(writer, "</JacaretoStructure>");
 
             writer.flush();
Index: trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java
===================================================================
--- trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java	(revision 1674)
+++ trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java	(revision 1678)
@@ -87,5 +87,5 @@
      * @return the name
      */
-    String getName() {
+    public String getName() {
         return specification.getName();
     }
@@ -128,6 +128,6 @@
      * 
      * @see
-     * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest.eventcore
-     * .guimodel.IGUIElementSpec)
+     * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest
+     * .eventcore .guimodel.IGUIElementSpec)
      */
     @Override
@@ -152,11 +152,24 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     public String getJacaretoHierarchy() {
-        String str = getElementDescriptor() + "_(" + getIndex() + ")";
+        String str;
+
+        // get the Java classname, ignore the package hierarchy if present
+        String[] parts = getSpecification().getType().split("\\.");
+        String name = parts[parts.length - 1];
+
+        // find the correct Jacareto index
+        // jacareto indices start at 1
+        int jacIndex = getIndex() + 1;
+        // some class specific hacks
+        if (name.equals("JFrame")) {
+            jacIndex++;
+        }
+        else if (name.equals("JLayeredPane")) {
+            jacIndex--;
+        }
+
+        str = parts[parts.length - 1] + "_(" + jacIndex + ")";
+
         if (getParent() != null) {
             return ((JFCGUIElement) getParent()).getJacaretoHierarchy() + "." + str;
@@ -164,5 +177,5 @@
         return str;
     }
-    
+
     /*
      * (non-Javadoc)
@@ -178,5 +191,7 @@
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement)
      */
