source: trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/commands/CMDshowSequences.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 2.4 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.ui.swt.commands;
16
17import java.util.List;
18
19import org.eclipse.swt.SWT;
20import org.eclipse.swt.widgets.Shell;
21
22import de.ugoe.cs.autoquest.CommandHelpers;
23import de.ugoe.cs.autoquest.SequenceInstanceOf;
24import de.ugoe.cs.autoquest.ui.swt.SequencesDialog;
25import de.ugoe.cs.util.console.Command;
26import de.ugoe.cs.util.console.GlobalDataContainer;
27
28/**
29 * <p>
30 * Command to show sequences.
31 * </p>
32 *
33 * @author Jeffrey Hall, Steffen Herbold
34 */
35public class CMDshowSequences implements Command {
36
37    /*
38     * (non-Javadoc)
39     *
40     * @see de.ugoe.cs.util.console.Command#help()
41     */
42    @Override
43    public String help() {
44        return "showSequences <sequencesName>";
45    }
46
47    /*
48     * (non-Javadoc)
49     *
50     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
51     */
52    @Override
53    public void run(List<Object> parameters) {
54        String sequencesName;
55        try {
56            sequencesName = (String) parameters.get(0);
57        }
58        catch (Exception e) {
59            throw new IllegalArgumentException();
60        }
61
62        Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
63        if (dataObject == null) {
64            CommandHelpers.objectNotFoundMessage(sequencesName);
65            return;
66        }
67        if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
68            CommandHelpers.objectNotType(sequencesName, "Collection<List<Event<?>>>");
69            return;
70        }
71
72        Shell shell = new Shell(SWT.NONE);
73        shell.open();
74        shell.layout();
75        shell.setSize(0, 0);
76        SequencesDialog sequencesDialog = new SequencesDialog(shell, SWT.NONE);
77        sequencesDialog.open(sequencesName);
78        shell.dispose();
79    }
80}
Note: See TracBrowser for help on using the repository browser.