View Javadoc
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 XsdTreeNode; 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 XsdTreeNode; node.
29       * @return boolean; 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 XsdTreeNode; scenario node.
39       */
40      public XsdTreeNode getScenarioNode()
41      {
42          return this.scenarioNode;
43      }
44      
45      /** {@inheritDoc} */
46      @Override
47      public String toString()
48      {
49          if (this.scenarioNode == null)
50          {
51              return "(Default)";
52          }
53          String id = this.scenarioNode.getId();
54          return id == null ? "(no id)" : id;
55      }
56      
57  }