Index: /trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/KeyInteractionCleaner.java
===================================================================
--- /trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/KeyInteractionCleaner.java	(revision 750)
+++ /trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/KeyInteractionCleaner.java	(revision 750)
@@ -0,0 +1,88 @@
+
+package de.ugoe.cs.quest.eventcore.gui;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+
+import de.ugoe.cs.quest.eventcore.Event;
+import de.ugoe.cs.tasktree.keyboardmaps.VirtualKey;
+import de.ugoe.cs.util.console.Console;
+
+/**
+ * <p>
+ * Because often not all events are recorded properly, it is possible that there is not always a
+ * KEYDOWN interaction each KEYUP interaction. This class provides the functionality to correct
+ * these mismatches with one of the following two strategies:
+ * <ul>
+ * <li>Removal: each interaction that does not form a proper KEYDOWN/KEYUP pair is removed.</li>
+ * <li>Addition: for each interaction that does not form a proper KEYDOWN/KEYUP pair, the missing
+ * message is added to the sequence directly before/after the existing message.</li>
+ * </ul>
+ * </p>
+ * 
+ * @version $Revision: $ $Date: Sep 3, 2012$
+ * @author 2012, last modified by $Author: sherbold$
+ */
+public class KeyInteractionCleaner {
+
+    /**
+     * <p>
+     * Describes the clean-up mode.
+     * </p>
+     * 
+     * @version $Revision: $ $Date: Sep 3, 2012$
+     * @author 2012, last modified by $Author: sherbold$
+     */
+    public enum CleanupMode {
+        REMOVAL, ADDITION
+    };
+
+    /**
+     * <p>
+     * Creates a copy of the passed sequence and performs the clean-up (see class description) on
+     * the copy.
+     * </p>
+     * 
+     * @param sequence
+     *            sequence on which the clean-up is performed
+     * @param mode
+     *            defines whether removal or addition mode is used
+     * @return copy of sequence with cleaned up key interactions
+     */
+    public List<Event> cleanupKeyInteractions(List<Event> sequence, CleanupMode mode) {
+        List<Event> sequenceCopy = new LinkedList<Event>(sequence);
+        List<VirtualKey> pressedKeys = new LinkedList<VirtualKey>();
+        
+        for( int i=0 ; i<sequenceCopy.size() ; i++ ) {
+            Event event = sequenceCopy.get(i);
+            if( event.getType() instanceof KeyPressed ) {
+                pressedKeys.add(((KeyPressed) event.getType()).getKey());
+            }
+            if( event.getType() instanceof KeyReleased ) {
+                VirtualKey key = ((KeyReleased) event.getType()).getKey();
+                if( pressedKeys.contains(key)) {
+                    pressedKeys.remove(key);
+                }
+                else {
+                    Console.traceln(Level.INFO, "KeyReleased without KeyDown for key " + key + " found at index " + i);
+                    switch(mode) {
+                        case REMOVAL:
+                            sequenceCopy.remove(i);
+                            i--;
+                            break;
+                        case ADDITION:
+                            KeyPressed pressed = new KeyPressed(key);
+                            Event keyPressedEvent = new Event(pressed, event.getTarget());
+                            sequenceCopy.add(i, keyPressedEvent);
+                            i++;
+                            break;
+                        default:
+                            throw new AssertionError("reached source code that should be unreachable");
+                    }
+                }
+            }
+        }
+        return sequenceCopy;
+    }
+}
Index: /trunk/quest-plugin-jfc/data/guimappings/guimapping-argouml.txt
===================================================================
--- /trunk/quest-plugin-jfc/data/guimappings/guimapping-argouml.txt	(revision 749)
+++ /trunk/quest-plugin-jfc/data/guimappings/guimapping-argouml.txt	(revision 750)
@@ -41,2 +41,3 @@
 org.tigris.toolbar.toolbutton.ModalButton = de.ugoe.cs.quest.plugin.jfc.guimodel.JFCButton
 org.tigris.toolbar.toolbutton.PopupToolBoxButton = de.ugoe.cs.quest.plugin.jfc.guimodel.JFCMenuButton
+org.argouml.core.propertypanels.ui.UMLExpressionLanguageField = de.ugoe.cs.quest.plugin.jfc.guimodel.JFCGUIElement
Index: /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcleanupKeyInteractions.java
===================================================================
--- /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcleanupKeyInteractions.java	(revision 750)
+++ /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcleanupKeyInteractions.java	(revision 750)
@@ -0,0 +1,95 @@
+
+package de.ugoe.cs.quest.commands.sequences;
+
+import java.security.InvalidParameterException;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+
+import de.ugoe.cs.quest.CommandHelpers;
+import de.ugoe.cs.quest.SequenceInstanceOf;
+import de.ugoe.cs.quest.eventcore.Event;
+import de.ugoe.cs.quest.eventcore.gui.KeyInteractionCleaner;
+import de.ugoe.cs.quest.eventcore.gui.KeyInteractionCleaner.CleanupMode;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+import de.ugoe.cs.util.console.GlobalDataContainer;
+
+/**
+ * <p>
+ * TODO comment
+ * </p>
+ * 
+ * @version $Revision: $ $Date: Sep 3, 2012$
+ * @author 2012, last modified by $Author: sherbold$
+ */
+public class CMDcleanupKeyInteractions implements Command {
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public void run(List<Object> parameters) {
+        String sequencesName = null;
+        String newSequencesName = null;
+        String modeString = null;
+        if (parameters.size() > 2) {
+            sequencesName = (String) parameters.get(0);
+            newSequencesName = (String) parameters.get(1);
+            modeString = (String) parameters.get(2);
+        }
+        else {
+            throw new InvalidParameterException();
+        }
+
+        Collection<List<Event>> sequences = null;
+        Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
+        if (dataObject == null) {
+            CommandHelpers.objectNotFoundMessage(sequencesName);
+            return;
+        }
+        if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
+            CommandHelpers.objectNotType(sequencesName, "Collection<List<Event>>");
+            return;
+        }
+        sequences = (Collection<List<Event>>) dataObject;
+
+        KeyInteractionCleaner.CleanupMode mode = null;
+        try {
+            mode = CleanupMode.valueOf(modeString);
+        }
+        catch (IllegalArgumentException e) {
+            Console.printerrln("Invalid mode. Only REMOVAL and ADDITION are allowed values!");
+            return;
+        }
+
+        Collection<List<Event>> newSequences = new LinkedList<List<Event>>();
+        KeyInteractionCleaner cleaner = new KeyInteractionCleaner();
+
+        int i=0;
+        for (List<Event> sequence : sequences) {
+            Console.traceln(Level.INFO, "Cleaning up sequence " + i++);
+            newSequences.add(cleaner.cleanupKeyInteractions(sequence, mode));
+        }
+
+        if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
+            CommandHelpers.dataOverwritten(newSequencesName);
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see de.ugoe.cs.util.console.Command#help()
+     */
+    @Override
+    public String help() {
+        return "cleanupKeyInteractions <sequencesName> <newSequencesName> <mode>";
+    }
+
+}
Index: /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcondenseMouseClicks.java
===================================================================
--- /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcondenseMouseClicks.java	(revision 749)
+++ /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcondenseMouseClicks.java	(revision 750)
@@ -80,5 +80,5 @@
 
         if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
-            CommandHelpers.dataOverwritten(sequencesName);
+            CommandHelpers.dataOverwritten(newSequencesName);
         }
         
Index: /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcorrectKeyInteractionTargets.java
===================================================================
--- /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcorrectKeyInteractionTargets.java	(revision 749)
+++ /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcorrectKeyInteractionTargets.java	(revision 750)
@@ -81,5 +81,5 @@
 
         if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
-            CommandHelpers.dataOverwritten(sequencesName);
+            CommandHelpers.dataOverwritten(newSequencesName);
         }
         
Index: /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDdetectTextInputEvents.java
===================================================================
--- /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDdetectTextInputEvents.java	(revision 749)
+++ /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDdetectTextInputEvents.java	(revision 750)
@@ -77,5 +77,5 @@
 
         if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
-            CommandHelpers.dataOverwritten(sequencesName);
+            CommandHelpers.dataOverwritten(newSequencesName);
         }
         
Index: /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java
===================================================================
--- /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java	(revision 749)
+++ /trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java	(revision 750)
@@ -104,5 +104,5 @@
 
         if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
-            CommandHelpers.dataOverwritten(sequencesName);
+            CommandHelpers.dataOverwritten(newSequencesName);
         }
         
Index: /trunk/quest-ui-core/src/main/resources/manuals/cleanupKeyInteractions
===================================================================
--- /trunk/quest-ui-core/src/main/resources/manuals/cleanupKeyInteractions	(revision 750)
+++ /trunk/quest-ui-core/src/main/resources/manuals/cleanupKeyInteractions	(revision 750)
@@ -0,0 +1,10 @@
+Deletes an object, e.g., a selection of sequences, from the global data storage.
+
+$USAGE$
+<sequencesName> name of the sequences to be cleaned-up
+<neqSequencesName> name of the cleaned-up sequences
+<mode> defines whether KeyReleased events without a matching KeyPressed are removed (mode: REMOVAL) or if a matching KeyPressed event is added directly in front of the KeyReleased event (mode: ADDITION)
+
+Example(s):
+cleanupKeyInteractions sequences cleanedSequences REMOVAL
+cleanupKeyInteractions sequences cleanedSequences ADDITION
Index: /trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/EditSequenceDialog.java
===================================================================
--- /trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/EditSequenceDialog.java	(revision 749)
+++ /trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/EditSequenceDialog.java	(revision 750)
@@ -24,4 +24,5 @@
     protected Shell shell;
     private Table table;
+    private TableColumn tblclmnEventIndex;
     private TableColumn tblclmnEventType;
     private TableColumn tblclmnEventTarget;
@@ -71,4 +72,8 @@
         table.setHeaderVisible(true);
         table.setLinesVisible(true);
+        
+        tblclmnEventIndex = new TableColumn(table, SWT.NONE);
+        tblclmnEventIndex.setAlignment(20);
+        
 
         tblclmnEventType = new TableColumn(table, SWT.NONE);
@@ -166,4 +171,5 @@
     private void updateTableContents() {
         table.removeAll();
+        int index = 1;
         for (Event event : sequence) {
             TableItem tableItem = new TableItem(table, SWT.NONE);
@@ -178,5 +184,5 @@
             }
             tableItem.setText(new String[]
-                { event.getType().toString(), target });
+                { ""+(index++), event.getType().toString(), target });
         }
         for (int i = 0; i < table.getColumnCount(); i++) {
@@ -186,9 +192,16 @@
 
     private void openInsertDialog(int position) {
-        InsertAssertionDialog insertDialog = new InsertAssertionDialog(shell, SWT.NONE, guiModel);
-        Event event = insertDialog.open();
-        if (event != null) {
-            sequence.add(position, event);
-            updateTableContents();
+        if (guiModel == null) {
+            MessageBox messageBox = new MessageBox(shell, SWT.ERROR);
+            messageBox.setMessage("Operation not supported!\nOnly works for GUI sequences.");
+            messageBox.setText("Error");
+            messageBox.open();
+        } else {
+            InsertAssertionDialog insertDialog = new InsertAssertionDialog(shell, SWT.NONE, guiModel);
+            Event event = insertDialog.open();
+            if (event != null) {
+                sequence.add(position, event);
+                updateTableContents();
+            }
         }
     }
Index: /trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SequencesDialog.java
===================================================================
--- /trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SequencesDialog.java	(revision 749)
+++ /trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SequencesDialog.java	(revision 750)
@@ -133,10 +133,4 @@
                 guiModel = (GUIModel) targetObject;
             }
-            if (guiModel == null) {
-                MessageBox messageBox = new MessageBox(shell, SWT.ERROR);
-                messageBox.setMessage("Operation not supported!\nOnly works for GUI sequences.");
-                messageBox.setText("Error");
-                messageBox.open();
-            }
         }
         else {
