Class XsdTreeNodeRoot

java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.editor.XsdTreeNode
org.opentrafficsim.editor.XsdTreeNodeRoot
All Implemented Interfaces:
Serializable, Remote, org.djutils.event.EventProducer

public class XsdTreeNodeRoot extends XsdTreeNode
Extends XsdTreeNode with event producer capabilities. In this way there is a clear central point for subscription to events on node creation and removal. Because this node itself is created, and the tree table model will expand two layers, for none of those nodes creation events can be thrown regularly after listeners have had a change to register with this root node. Therefore, this class overrides addListener(...) to throw a creation event for all existing nodes in the tree.

This class also sets up a listener for all xsd:key, xsd:keyref and xsd:unique from the schema.

Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Wouter Schakel
See Also:
  • Field Details

    • NODE_CREATED

      public static final org.djutils.event.EventType NODE_CREATED
      Event when a node is created. This event is always thrown by the root of the data structure. Listeners should register with the root.
    • NODE_REMOVED

      public static final org.djutils.event.EventType NODE_REMOVED
      Event when a node is removed. Invoked for each individual node, including all child nodes of a node that a user removes. This event is always thrown by the root of the data structure. Listeners should register with the root.
  • Constructor Details

    • XsdTreeNodeRoot

      public XsdTreeNodeRoot(Schema schema) throws RemoteException
      Constructor for root node, based on a schema.
      Parameters:
      schema - XsdSchema; XSD Schema.
      Throws:
      RemoteException - when unable to listen for created nodes.
  • Method Details

    • getDirectory

      public String getDirectory()
      Returns the directory.
      Returns:
      String; directory.
    • setDirectory

      public void setDirectory(String directory)
      Set the directory.
      Parameters:
      directory - String; directory.
    • getRoot

      public XsdTreeNodeRoot getRoot()
      Returns the root node.
      Overrides:
      getRoot in class XsdTreeNode
      Returns:
      XsdTreeNodeRoot; root node.
    • addListener

      public boolean addListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, int position, org.djutils.event.reference.ReferenceType referenceType)
      Overridden to throw events on existing nodes to the listener.
      Specified by:
      addListener in interface org.djutils.event.EventProducer
      Overrides:
      addListener in class org.djutils.event.LocalEventProducer
    • setSchemaLocation

      public void setSchemaLocation(String schemaLocation)
      Sets the scehame location. This can't happen through the editor, but it may be set when loading a file.
      Parameters:
      schemaLocation - String; schema location.
    • getSchemaLocation

      public String getSchemaLocation()
      Returns the schema location. If it is not null it was set during file loading, and will be saved too.
      Returns:
      String; schema location.