1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import de.ugoe.cs.eventbench.swing.DlgSequences;
|
---|
8 | import de.ugoe.cs.util.console.Command;
|
---|
9 | import de.ugoe.cs.util.console.Console;
|
---|
10 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
11 | import de.ugoe.cs.eventbench.data.Event;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * <p>
|
---|
15 | * Command to show sequences.
|
---|
16 | * </p>
|
---|
17 | *
|
---|
18 | * @author Jeffrey Hall, Steffen Herbold
|
---|
19 | */
|
---|
20 | public class CMDshowSequences implements Command {
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * (non-Javadoc)
|
---|
24 | *
|
---|
25 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
26 | */
|
---|
27 | @Override
|
---|
28 | public void help() {
|
---|
29 | Console.println("Usage: showSequences");
|
---|
30 | }
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * (non-Javadoc)
|
---|
34 | *
|
---|
35 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
36 | */
|
---|
37 | @SuppressWarnings("unchecked")
|
---|
38 | @Override
|
---|
39 | public void run(List<Object> parameters) {
|
---|
40 |
|
---|
41 | if (parameters.size() > 0)
|
---|
42 | throw new InvalidParameterException();
|
---|
43 |
|
---|
44 | Collection<List<Event<?>>> containedSequences = null;
|
---|
45 |
|
---|
46 | try {
|
---|
47 | containedSequences = (Collection<List<Event<?>>>) GlobalDataContainer
|
---|
48 | .getInstance().getData("sequences");
|
---|
49 | } catch (ClassCastException e) {
|
---|
50 | Console.println("Unable to cast Data in GlobalDataContainer to List of Sequences");
|
---|
51 | }
|
---|
52 |
|
---|
53 | if (containedSequences == null) {
|
---|
54 | Console.printerrln("No sequences found.");
|
---|
55 | } else {
|
---|
56 |
|
---|
57 | // TODO use SWT-GUI instead
|
---|
58 | DlgSequences.showDialog();
|
---|
59 |
|
---|
60 | synchronized (Console.getInstance()) {
|
---|
61 | try {
|
---|
62 | Console.getInstance().wait();
|
---|
63 | } catch (InterruptedException e) {
|
---|
64 | e.printStackTrace();
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|