Class TLcdModelChangedEvent

java.lang.Object
java.util.EventObject
com.luciad.model.TLcdModelChangedEvent
All Implemented Interfaces:
Serializable

public class TLcdModelChangedEvent extends EventObject
TLcdModelChangedEvent implements change events that occurred in a model, as received by a model listener.

A TLcdModelChangedEvent has an integer code property specifying the global changes. Its value is a any logical OR operation of OBJECTS_ADDED, OBJECTS_CHANGED, SOME_OBJECTS_REMOVED, ALL_OBJECTS_CHANGED and ALL_OBJECTS_REMOVED.

A TLcdModelChangedEvent also has information specifying the model changes in more detail, i.e. per object in an ILcdModel. The elements() method returns an Enumeration of all the objects that have been added, removed or changed with respect to the ILcdModel. The int value returned by retrieveChange(java.lang.Object) specifies the type of change of any Object in this Enumeration. This value is one of: OBJECT_ADDED, OBJECT_CHANGED, or OBJECT_REMOVED.

Note 1: if ALL_OBJECTS_REMOVED is set in the getCode() method, only the changes after the removal of all objects are detailed. Note 2: if ALL_OBJECTS_CHANGED is set in the getCode() method, all changes before and after are detailed. ALL_OBJECTS_CHANGED will not alter the set of changes retrieved by elements().

Example/template code

Here is example code on how to handle an event:

  public void modelChanged(TLcdModelChangedEvent aEvent) {
    if ((aEvent.getCode() & TLcdModelChangedEvent.ALL_OBJECTS_CHANGED) != 0) {
      // all elements were changed (note: still process individual events after)
    }
    if ((aEvent.getCode() & TLcdModelChangedEvent.ALL_OBJECTS_REMOVED) != 0) {
      // all elements were removed (note: still process individual events after)
    }
    try (TLcdLockUtil.Lock lock = TLcdLockUtil.readLock(aEvent.getModel())) {
      Enumeration elements = aEvent.elements();
      while (elements.hasMoreElements()) {
        Object element = elements.nextElement();
        int change = aEvent.retrieveChange(element);
        if (change == TLcdModelChangedEvent.OBJECT_ADDED) {
          // ...
        } else if (change == TLcdModelChangedEvent.OBJECT_CHANGED) {
          // ...
        } else if (change == TLcdModelChangedEvent.OBJECT_REMOVED) {
          // ...
        }
      }
    }
  }
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Indicates that all objects of the model have been changed.
    static final int
    Indicates that all objects of the model have been removed, i.e., the model is now empty.
    static final int
    Indicates for a given element that it has been added to the model.
    static final int
    Indicates for a given model element that its contents have been changed.
    static final int
    Indicates for a given element that it has been removed from the model.
    static final int
    Indicates that objects have been added to the model.
    static final int
    Indicates that at least some objects in the model have changed.
    static final int
    Indicates that some objects have been removed from the model.

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    TLcdModelChangedEvent(ILcdModel aModel, int aCode, Map aModelChanges)
    Constructs a new TLcdModelChangedEvent with the given parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether aObject is associated to this TLcdModelChangedEvent.
    int
    Returns the number of Objects associated to this TLcdModelChangedEvent.
    Returns an Enumeration of all the objects that have been added, removed or changed with respect to the ILcdModel.
    int
    Returns the global model change of this TLcdModelChangedEvent.
    Returns the ILcdModel that is the source of this TLcdModelChangedEvent.
    int
    Returns the details concerning aObject in this TLcdModelChangedEvent.
    Returns a general description of this event.

    Methods inherited from class java.util.EventObject

    getSource

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • OBJECTS_CHANGED

      public static final int OBJECTS_CHANGED
      Indicates that at least some objects in the model have changed.
      See Also:
    • OBJECTS_ADDED

      public static final int OBJECTS_ADDED
      Indicates that objects have been added to the model.
      See Also:
    • SOME_OBJECTS_REMOVED

      public static final int SOME_OBJECTS_REMOVED
      Indicates that some objects have been removed from the model.
      See Also:
    • ALL_OBJECTS_REMOVED

      public static final int ALL_OBJECTS_REMOVED
      Indicates that all objects of the model have been removed, i.e., the model is now empty.
      See Also:
    • ALL_OBJECTS_CHANGED

      public static final int ALL_OBJECTS_CHANGED
      Indicates that all objects of the model have been changed.
      See Also:
    • OBJECT_CHANGED

      public static final int OBJECT_CHANGED
      Indicates for a given model element that its contents have been changed.
      See Also:
    • OBJECT_ADDED

      public static final int OBJECT_ADDED
      Indicates for a given element that it has been added to the model.
      See Also:
    • OBJECT_REMOVED

      public static final int OBJECT_REMOVED
      Indicates for a given element that it has been removed from the model.
      See Also:
  • Constructor Details

    • TLcdModelChangedEvent

      public TLcdModelChangedEvent(ILcdModel aModel, int aCode, Map aModelChanges)
      Constructs a new TLcdModelChangedEvent with the given parameters.
      Parameters:
      aModel - the model that is firing this event.
      aCode - the code indicating the global model changes.
      aModelChanges - the hash table that details the model changes. The key is the object that has changed. The value is (an Integer wrapper of) the change itself, which can be one of OBJECT_REMOVED, OBJECT_ADDED, OBJECT_CHANGED.
  • Method Details

    • getModel

      public ILcdModel getModel()
      Returns the ILcdModel that is the source of this TLcdModelChangedEvent.
      Returns:
      the ILcdModel that is the source of this TLcdModelChangedEvent.
    • getCode

      public int getCode()
      Returns the global model change of this TLcdModelChangedEvent.
      Returns:
      the global model change of this TLcdModelChangedEvent. This can be OBJECTS_CHANGED, OBJECTS_ADDED, SOME_OBJECTS_REMOVED, ALL_OBJECTS_REMOVED or ALL_OBJECTS_CHANGED or a binary or of these values.

      See template code on how to use this method.

    • elements

      public Enumeration elements()
      Returns an Enumeration of all the objects that have been added, removed or changed with respect to the ILcdModel.

      See template code on how to use this method.

      Returns:
      an Enumeration of all the objects that have been added, removed or changed with respect to the ILcdModel.
      See Also:
    • elementCount

      public int elementCount()
      Returns the number of Objects associated to this TLcdModelChangedEvent.
      Returns:
      the number of Objects associated to this TLcdModelChangedEvent
    • containsElement

      public boolean containsElement(Object aObject)
      Returns whether aObject is associated to this TLcdModelChangedEvent.
      Parameters:
      aObject - the object to check for.
      Returns:
      whether aObject is associated to this TLcdModelChangedEvent
    • retrieveChange

      public int retrieveChange(Object aObject)
      Returns the details concerning aObject in this TLcdModelChangedEvent. One of OBJECT_ADDED, OBJECT_CHANGED, or OBJECT_REMOVED

      See template code on how to use this method.

      Parameters:
      aObject - the object to retrieve the type of change for.
      Returns:
      the details concerning aObject in this TLcdModelChangedEvent. One of OBJECT_ADDED, OBJECT_CHANGED, or OBJECT_REMOVED
    • toString

      public String toString()
      Returns a general description of this event. The exact details of the representation are unspecified and are subject to change.
      Overrides:
      toString in class EventObject
      Returns:
      a general description of this event.