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

Last change on this file since 820 was 820, checked in by sherbold, 12 years ago
  • modified GUIModel to not automatically merge nodes during the creation of the model, but rather after the creation is completed through a call of condenseModel
  • added command condenseGuiModel
  • Property svn:mime-type set to text/plain
File size: 1.4 KB
Line 
1
2package de.ugoe.cs.quest.commands.sequences;
3
4import java.util.List;
5
6import de.ugoe.cs.quest.CommandHelpers;
7import de.ugoe.cs.quest.eventcore.guimodel.GUIModel;
8import de.ugoe.cs.util.console.Command;
9import de.ugoe.cs.util.console.GlobalDataContainer;
10
11/**
12 * <p>
13 * Command to condense the GUI model of a sequence, i.e., merge duplicate nodes.
14 * </p>
15 *
16 * @version 1.0
17 * @author Steffen Herbold
18 */
19public class CMDcondenseGuiModel implements Command {
20
21    /*
22     * (non-Javadoc)
23     *
24     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
25     */
26    @Override
27    public void run(List<Object> parameters) {
28        String sequencesName = "sequences";
29
30        if (parameters.size() > 0) {
31            sequencesName = (String) parameters.get(0);
32        }
33
34        Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName + "_targets");
35        if (dataObject == null) {
36            CommandHelpers.objectNotFoundMessage(sequencesName + "_targets");
37            return;
38        }
39        if (!(dataObject instanceof GUIModel)) {
40            CommandHelpers.objectNotType(sequencesName, "GUIModel");
41            return;
42        }
43
44        GUIModel model = (GUIModel) dataObject;
45
46        model.condenseModel();
47    }
48
49    /*
50     * (non-Javadoc)
51     *
52     * @see de.ugoe.cs.util.console.Command#help()
53     */
54    @Override
55    public String help() {
56        return "condenseGuiModel {<sequencesName>}";
57    }
58
59}
Note: See TracBrowser for help on using the repository browser.