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 | |
---|
15 | package de.ugoe.cs.autoquest.commands.sequences; |
---|
16 | |
---|
17 | import java.util.List; |
---|
18 | |
---|
19 | import de.ugoe.cs.autoquest.CommandHelpers; |
---|
20 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel; |
---|
21 | import de.ugoe.cs.util.console.Command; |
---|
22 | import de.ugoe.cs.util.console.GlobalDataContainer; |
---|
23 | |
---|
24 | /** |
---|
25 | * <p> |
---|
26 | * Command to condense the GUI model of a sequence, i.e., merge duplicate nodes. |
---|
27 | * </p> |
---|
28 | * |
---|
29 | * @version 1.0 |
---|
30 | * @author Steffen Herbold |
---|
31 | */ |
---|
32 | public class CMDcondenseGuiModel implements Command { |
---|
33 | |
---|
34 | /* |
---|
35 | * (non-Javadoc) |
---|
36 | * |
---|
37 | * @see de.ugoe.cs.util.console.Command#run(java.util.List) |
---|
38 | */ |
---|
39 | @Override |
---|
40 | public void run(List<Object> parameters) { |
---|
41 | String sequencesName = "sequences"; |
---|
42 | |
---|
43 | if (parameters.size() > 0) { |
---|
44 | sequencesName = (String) parameters.get(0); |
---|
45 | } |
---|
46 | |
---|
47 | Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName + "_targets"); |
---|
48 | if (dataObject == null) { |
---|
49 | CommandHelpers.objectNotFoundMessage(sequencesName + "_targets"); |
---|
50 | return; |
---|
51 | } |
---|
52 | if (!(dataObject instanceof GUIModel)) { |
---|
53 | CommandHelpers.objectNotType(sequencesName, "GUIModel"); |
---|
54 | return; |
---|
55 | } |
---|
56 | |
---|
57 | GUIModel model = (GUIModel) dataObject; |
---|
58 | |
---|
59 | model.condenseModel(); |
---|
60 | } |
---|
61 | |
---|
62 | /* |
---|
63 | * (non-Javadoc) |
---|
64 | * |
---|
65 | * @see de.ugoe.cs.util.console.Command#help() |
---|
66 | */ |
---|
67 | @Override |
---|
68 | public String help() { |
---|
69 | return "condenseGuiModel {<sequencesName>}"; |
---|
70 | } |
---|
71 | |
---|
72 | } |
---|