Index: trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateAltIndex.java
===================================================================
--- trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDparseJFCDirwithJacaretoIndices.java	(revision 1946)
+++ trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateAltIndex.java	(revision 1956)
@@ -15,5 +15,4 @@
 package de.ugoe.cs.autoquest.plugin.jfc.commands;
 
-import java.io.File;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
@@ -21,12 +20,12 @@
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
-import java.util.logging.Level;
 
 import de.ugoe.cs.autoquest.CommandHelpers;
+import de.ugoe.cs.autoquest.SequenceInstanceOf;
 import de.ugoe.cs.autoquest.eventcore.Event;
 import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
-import de.ugoe.cs.autoquest.plugin.jfc.JFCSimplifiedLogParser;
 import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement;
 import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElementSpec;
@@ -34,5 +33,4 @@
 import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCMenuButton;
 import de.ugoe.cs.util.console.Command;
-import de.ugoe.cs.util.console.Console;
 import de.ugoe.cs.util.console.GlobalDataContainer;
 
@@ -42,7 +40,7 @@
  * </p>
  * 
- * @author Steffen Herbold
+ * @author Daniel May
  */
-public class CMDparseJFCDirwithJacaretoIndices implements Command {
+public class CMDgenerateAltIndex implements Command {
 
     private List<String> menuList;
@@ -53,20 +51,16 @@
      * @see de.ugoe.cs.util.console.Command#run(java.util.List)
      */
+    @SuppressWarnings("unchecked")
     @Override
     public void run(List<Object> parameters) {
-        String path;
         String sequencesName = "sequences";
 
         try {
-            path = (String) parameters.get(0);
+            sequencesName = (String) parameters.get(0);
             if (parameters.size() >= 2) {
-                sequencesName = (String) parameters.get(1);
-            }
-            if (parameters.size() >= 3) {
                 menuList =
-                    Files.readAllLines(Paths.get((String) parameters.get(2)),
+                    Files.readAllLines(Paths.get((String) parameters.get(1)),
                                        Charset.defaultCharset());
             }
-
         }
         catch (Exception e) {
@@ -74,45 +68,54 @@
         }
 
-        File folder = new File(path);
-        if (!folder.isDirectory()) {
-            Console.printerrln(path + " is not a directory");
+        Collection<List<Event>> sequences = null;
+        Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
+        if (dataObject == null) {
+            CommandHelpers.objectNotFoundMessage(sequencesName);
             return;
         }
-
-        JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser();
-
-        String absolutPath = folder.getAbsolutePath();
-        for (String filename : folder.list()) {
-            String source = absolutPath + File.separator + filename;
-            Console.traceln(Level.INFO, "Processing file: " + source);
-
-            try {
-                parser.parseFile(source);
-            }
-            catch (Exception e) {
-                Console.printerrln("Could not parse " + source + ": " + e.getMessage());
-            }
-        }
-
-        Collection<List<Event>> sequences = parser.getSequences();
-
-        GUIModel targets = parser.getGuiModel();
-        targets.condenseModel();
-
-        // TODO: throw our stuff before this
-        
-        generateJacaretoIndices(targets.getRootElements(), targets);
-        
-        // TODO: iterate over all sequences
-        // TODO: iterate over all events in the sequences
-        // TODO: for each event: find representing node in GUI element
-        // TODO: then update altIndex
-
-        if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
-            CommandHelpers.dataOverwritten(sequencesName);
-        }
-
-        if (GlobalDataContainer.getInstance().addData(sequencesName + "_targets", targets)) {
-            CommandHelpers.dataOverwritten(sequencesName + "_targets");
+        if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
+            CommandHelpers.objectNotType(sequencesName, "Collection<List<Event<?>>>");
+            return;
+        }
+        sequences = (Collection<List<Event>>) dataObject;
+        GUIModel model = null;
+
+        for (List<Event> sequence : sequences) {
+            if (model == null) {
+                // generate jacareto indices for the GUI model of this sequence
+                JFCGUIElement element = (JFCGUIElement) sequence.get(0).getTarget();
+                model = element.getGUIModel();
+                generateJacaretoIndices(model.getRootElements(), model);
+            }
+            else {
+                for (Iterator<Event> eventIter = sequence.iterator(); eventIter.hasNext();) {
+                    // find and set the alt index for every target
+                    IGUIElement target = (IGUIElement) eventIter.next().getTarget();
+                    findAltIndex(target, model.getRootElements(), model);
+                }
+            }
+        }
+    }
+
+    private void findAltIndex(IGUIElement target, List<IGUIElement> elements, GUIModel model) {
+        int altIndex = ((JFCGUIElementSpec) target.getSpecification()).getAltIndex();
+
+        if (altIndex < 0) {
+            for (IGUIElement child : elements) {
+                if (target.equals(child)) {
+                    int childAltIndex =
+                        ((JFCGUIElementSpec) child.getSpecification()).getAltIndex();
+
+                    if (childAltIndex > -1) {
+                        ((JFCGUIElementSpec) target.getSpecification()).setAltIndex(childAltIndex);
+                    }
+                    else {
+                        findAltIndex(target, model.getChildren(child), model);
+                    }
+                }
+                else {
+                    findAltIndex(target, model.getChildren(child), model);
+                }
+            }
         }
     }
