1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import org.eclipse.swt.SWT;
|
---|
7 | import org.eclipse.swt.widgets.Shell;
|
---|
8 |
|
---|
9 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
10 | import de.ugoe.cs.eventbench.SequenceInstanceOf;
|
---|
11 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
12 | import de.ugoe.cs.eventbench.swt.SequencesDialog;
|
---|
13 | import de.ugoe.cs.util.console.Command;
|
---|
14 | import de.ugoe.cs.util.console.Console;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * <p>
|
---|
18 | * Command to show sequences.
|
---|
19 | * </p>
|
---|
20 | *
|
---|
21 | * @author Jeffrey Hall, Steffen Herbold
|
---|
22 | */
|
---|
23 | public class CMDshowSequences implements Command {
|
---|
24 |
|
---|
25 | /*
|
---|
26 | * (non-Javadoc)
|
---|
27 | *
|
---|
28 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
29 | */
|
---|
30 | @Override
|
---|
31 | public void help() {
|
---|
32 | Console.println("Usage: showSequences <sequencesName>");
|
---|
33 | }
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * (non-Javadoc)
|
---|
37 | *
|
---|
38 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
39 | */
|
---|
40 | @Override
|
---|
41 | public void run(List<Object> parameters) {
|
---|
42 | String sequencesName;
|
---|
43 | try {
|
---|
44 | sequencesName = (String) parameters.get(0);
|
---|
45 | } catch (Exception e) {
|
---|
46 | throw new InvalidParameterException();
|
---|
47 | }
|
---|
48 |
|
---|
49 | Object dataObject = GlobalDataContainer.getInstance().getData(
|
---|
50 | sequencesName);
|
---|
51 | if (dataObject == null) {
|
---|
52 | CommandHelpers.objectNotFoundMessage(sequencesName);
|
---|
53 | return;
|
---|
54 | }
|
---|
55 | if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
|
---|
56 | CommandHelpers.objectNotType(sequencesName,
|
---|
57 | "Collection<List<Event<?>>>");
|
---|
58 | return;
|
---|
59 | }
|
---|
60 |
|
---|
61 | Shell shell = new Shell(SWT.NONE);
|
---|
62 | shell.open();
|
---|
63 | shell.layout();
|
---|
64 | shell.setSize(0, 0);
|
---|
65 | SequencesDialog sequencesDialog = new SequencesDialog(shell, SWT.NONE);
|
---|
66 | sequencesDialog.open(sequencesName);
|
---|
67 | shell.dispose();
|
---|
68 | }
|
---|
69 | }
|
---|