source: trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDcleanupKeyInteractions.java @ 750

Last change on this file since 750 was 750, checked in by sherbold, 12 years ago
  • added command cleanupKeyInteractions to handle invalid KeyPressed/KeyReleased? pairs
  • fixed minor bug in command condenseMouseClicks
  • fixed minor bug in command correctKeyInteractionTargets
  • fixed minor bug in command detectTextInputEvents
  • fixed minor bug in command sortKeyInteractions
  • beautified showing of sequences in SWT GUI
  • updated ArgoUML GUI Mappings
  • Property svn:mime-type set to text/plain
File size: 2.9 KB
Line 
1
2package de.ugoe.cs.quest.commands.sequences;
3
4import java.security.InvalidParameterException;
5import java.util.Collection;
6import java.util.LinkedList;
7import java.util.List;
8import java.util.logging.Level;
9
10import de.ugoe.cs.quest.CommandHelpers;
11import de.ugoe.cs.quest.SequenceInstanceOf;
12import de.ugoe.cs.quest.eventcore.Event;
13import de.ugoe.cs.quest.eventcore.gui.KeyInteractionCleaner;
14import de.ugoe.cs.quest.eventcore.gui.KeyInteractionCleaner.CleanupMode;
15import de.ugoe.cs.util.console.Command;
16import de.ugoe.cs.util.console.Console;
17import de.ugoe.cs.util.console.GlobalDataContainer;
18
19/**
20 * <p>
21 * TODO comment
22 * </p>
23 *
24 * @version $Revision: $ $Date: Sep 3, 2012$
25 * @author 2012, last modified by $Author: sherbold$
26 */
27public class CMDcleanupKeyInteractions implements Command {
28
29    /*
30     * (non-Javadoc)
31     *
32     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
33     */
34    @SuppressWarnings("unchecked")
35    @Override
36    public void run(List<Object> parameters) {
37        String sequencesName = null;
38        String newSequencesName = null;
39        String modeString = null;
40        if (parameters.size() > 2) {
41            sequencesName = (String) parameters.get(0);
42            newSequencesName = (String) parameters.get(1);
43            modeString = (String) parameters.get(2);
44        }
45        else {
46            throw new InvalidParameterException();
47        }
48
49        Collection<List<Event>> sequences = null;
50        Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
51        if (dataObject == null) {
52            CommandHelpers.objectNotFoundMessage(sequencesName);
53            return;
54        }
55        if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
56            CommandHelpers.objectNotType(sequencesName, "Collection<List<Event>>");
57            return;
58        }
59        sequences = (Collection<List<Event>>) dataObject;
60
61        KeyInteractionCleaner.CleanupMode mode = null;
62        try {
63            mode = CleanupMode.valueOf(modeString);
64        }
65        catch (IllegalArgumentException e) {
66            Console.printerrln("Invalid mode. Only REMOVAL and ADDITION are allowed values!");
67            return;
68        }
69
70        Collection<List<Event>> newSequences = new LinkedList<List<Event>>();
71        KeyInteractionCleaner cleaner = new KeyInteractionCleaner();
72
73        int i=0;
74        for (List<Event> sequence : sequences) {
75            Console.traceln(Level.INFO, "Cleaning up sequence " + i++);
76            newSequences.add(cleaner.cleanupKeyInteractions(sequence, mode));
77        }
78
79        if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) {
80            CommandHelpers.dataOverwritten(newSequencesName);
81        }
82
83    }
84
85    /*
86     * (non-Javadoc)
87     *
88     * @see de.ugoe.cs.util.console.Command#help()
89     */
90    @Override
91    public String help() {
92        return "cleanupKeyInteractions <sequencesName> <newSequencesName> <mode>";
93    }
94
95}
Note: See TracBrowser for help on using the repository browser.