1 package org.opentrafficsim.editor;
2
3 /**
4 * Wraps a scenario node as an item in the dropdown menu.
5 * <p>
6 * Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
7 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
8 * </p>
9 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
10 */
11 public class ScenarioWrapper
12 {
13
14 /** Scenario node. */
15 private final XsdTreeNode scenarioNode;
16
17 /**
18 * Constructor.
19 * @param scenarioNode node of the scenario.
20 */
21 public ScenarioWrapper(final XsdTreeNode scenarioNode)
22 {
23 this.scenarioNode = scenarioNode;
24 }
25
26 /**
27 * Returns whether this wraps the given node.
28 * @param node node.
29 * @return whether this wraps the given node.
30 */
31 public boolean isScenario(final XsdTreeNode node)
32 {
33 return node.equals(this.scenarioNode);
34 }
35
36 /**
37 * Returns the scenario node.
38 * @return scenario node.
39 */
40 public XsdTreeNode getScenarioNode()
41 {
42 return this.scenarioNode;
43 }
44
45 @Override
46 public String toString()
47 {
48 if (this.scenarioNode == null)
49 {
50 return "(Default)";
51 }
52 String id = this.scenarioNode.getId();
53 return id == null ? "(no id)" : id;
54 }
55
56 }