Interface DomainObject

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DO_DOMAIN_FILE_CHANGED
      Event type generated when the domain file associated with the domain object changes.
      static int DO_OBJECT_CLOSED
      Event type generated when this domain object is closed.
      static int DO_OBJECT_ERROR
      Event type generated when a fatal error occurs which renders the domain object invalid.
      static int DO_OBJECT_RENAMED
      Event type generated when the object name changes.
      static int DO_OBJECT_RESTORED
      Event type generated when domain object is restored.
      static int DO_OBJECT_SAVED
      Event type generated when the domain object is saved.
      static int DO_PROPERTY_CHANGED
      Event type generated when a property on this DomainObject is changed.
      static java.lang.Object undoLock
      Object to synchronize on for undo/redo operations.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addCloseListener​(DomainObjectClosedListener listener)
      Adds a listener that will be notified when this DomainObject is closed.
      boolean addConsumer​(java.lang.Object consumer)
      Adds the given object as a consumer.
      void addListener​(DomainObjectListener dol)
      Adds a listener for this object.
      boolean canLock()
      Returns true if a modification lock can be obtained on this domain object.
      boolean canSave()
      Returns true if this object can be saved; a read-only file cannot be saved.
      EventQueueID createPrivateEventQueue​(DomainObjectListener listener, int maxDelay)
      Creates a private event queue that can be flushed independently from the main event queue.
      void flushEvents()
      Makes sure all pending domainEvents have been sent.
      void flushPrivateEventQueue​(EventQueueID id)
      Flush events from the specified event queue.
      void forceLock​(boolean rollback, java.lang.String reason)
      Cancels any previous lock and acquires it.
      java.util.ArrayList<java.lang.Object> getConsumerList()
      Returns the list of consumers on this domainObject
      java.lang.String getDescription()
      Returns a word or short phrase that best describes or categorizes the object in terms that a user will understand.
      DomainFile getDomainFile()
      Get the domain file for this domain object.
      java.util.Map<java.lang.String,​java.lang.String> getMetadata()
      Returns a map containing all the stored metadata associated with this domain object.
      long getModificationNumber()
      Returns a long value that gets incremented every time a change, undo, or redo takes place.
      java.lang.String getName()
      Get the name of this domain object.
      Options getOptions​(java.lang.String propertyListName)
      Get the property list for the given name.
      java.util.List<java.lang.String> getOptionsNames()
      Returns all properties lists contained by this domain object.
      boolean hasExclusiveAccess()
      Returns true if the user has exclusive access to the domain object.
      boolean isChangeable()
      Returns true if changes are permitted.
      boolean isChanged()
      Returns whether the object has changed.
      boolean isClosed()
      Returns true if this domain object has been closed as a result of the last release
      boolean isLocked()
      Returns true if the domain object currently has a modification lock enabled.
      boolean isSendingEvents()
      Returns true if this object is sending out events as it is changed.
      boolean isTemporary()
      Returns true if this object has been marked as Temporary.
      boolean isUsedBy​(java.lang.Object consumer)
      Returns true if the given consumer is using (has open) this domain object.
      boolean lock​(java.lang.String reason)
      Attempt to obtain a modification lock on the domain object.
      void release​(java.lang.Object consumer)
      Notify the domain object that the specified consumer is no longer using it.
      void removeCloseListener​(DomainObjectClosedListener listener)
      Removes the given close listener.
      void removeListener​(DomainObjectListener dol)
      Remove the listener for this object.
      boolean removePrivateEventQueue​(EventQueueID id)
      Removes the specified private event queue
      void save​(java.lang.String comment, TaskMonitor monitor)
      Saves changes to the DomainFile.
      void saveToPackedFile​(java.io.File outputFile, TaskMonitor monitor)
      Saves (i.e., serializes) the current content to a packed file.
      void setEventsEnabled​(boolean enabled)
      If true, domain object change events are sent.
      void setName​(java.lang.String name)
      Set the name for this domain object.
      void setTemporary​(boolean state)
      Set the temporary state of this object.
      void unlock()
      Release a modification lock previously granted with the lock method.
    • Field Detail

      • undoLock

        static final java.lang.Object undoLock
        Object to synchronize on for undo/redo operations.
      • DO_OBJECT_SAVED

        static final int DO_OBJECT_SAVED
        Event type generated when the domain object is saved.
        See Also:
        Constant Field Values
      • DO_DOMAIN_FILE_CHANGED

        static final int DO_DOMAIN_FILE_CHANGED
        Event type generated when the domain file associated with the domain object changes.
        See Also:
        Constant Field Values
      • DO_OBJECT_RENAMED

        static final int DO_OBJECT_RENAMED
        Event type generated when the object name changes.
        See Also:
        Constant Field Values
      • DO_OBJECT_RESTORED

        static final int DO_OBJECT_RESTORED
        Event type generated when domain object is restored.
        See Also:
        Constant Field Values
      • DO_PROPERTY_CHANGED

        static final int DO_PROPERTY_CHANGED
        Event type generated when a property on this DomainObject is changed.
        See Also:
        Constant Field Values
      • DO_OBJECT_CLOSED

        static final int DO_OBJECT_CLOSED
        Event type generated when this domain object is closed.
        See Also:
        Constant Field Values
      • DO_OBJECT_ERROR

        static final int DO_OBJECT_ERROR
        Event type generated when a fatal error occurs which renders the domain object invalid.
        See Also:
        Constant Field Values
    • Method Detail

      • isChanged

        boolean isChanged()
        Returns whether the object has changed.
        Returns:
        whether the object has changed.
      • setTemporary

        void setTemporary​(boolean state)
        Set the temporary state of this object. If this object is temporary, the isChanged() method will always return false. The default temporary state is false.
        Parameters:
        state - if true object is marked as temporary
      • isTemporary

        boolean isTemporary()
        Returns true if this object has been marked as Temporary.
        Returns:
        true if this object has been marked as Temporary.
      • isChangeable

        boolean isChangeable()
        Returns true if changes are permitted.
        Returns:
        true if changes are permitted.
      • canSave

        boolean canSave()
        Returns true if this object can be saved; a read-only file cannot be saved.
        Returns:
        true if this object can be saved
      • save

        void save​(java.lang.String comment,
                  TaskMonitor monitor)
           throws java.io.IOException,
                  CancelledException
        Saves changes to the DomainFile.
        Parameters:
        comment - comment used for new version
        monitor - monitor that shows the progress of the save
        Throws:
        java.io.IOException - thrown if there was an error accessing this domain object
        ReadOnlyException - thrown if this DomainObject is read only and cannot be saved
        CancelledException - thrown if the user canceled the save operation
      • saveToPackedFile

        void saveToPackedFile​(java.io.File outputFile,
                              TaskMonitor monitor)
                       throws java.io.IOException,
                              CancelledException
        Saves (i.e., serializes) the current content to a packed file.
        Parameters:
        outputFile - packed output file
        monitor - progress monitor
        Throws:
        java.io.IOException - if an exception occurs
        CancelledException - if the user cancels
        java.lang.UnsupportedOperationException - if not supported by object implementation
      • release

        void release​(java.lang.Object consumer)
        Notify the domain object that the specified consumer is no longer using it. When the last consumer invokes this method, the domain object will be closed and will become invalid.
        Parameters:
        consumer - the consumer (e.g., tool, plugin, etc) of the domain object previously established with the addConsumer method.
      • addListener

        void addListener​(DomainObjectListener dol)
        Adds a listener for this object.
        Parameters:
        dol - listener notified when any change occurs to this domain object
      • removeListener

        void removeListener​(DomainObjectListener dol)
        Remove the listener for this object.
        Parameters:
        dol - listener
      • addCloseListener

        void addCloseListener​(DomainObjectClosedListener listener)
        Adds a listener that will be notified when this DomainObject is closed. This is meant for clients to have a chance to cleanup, such as reference removal.
        Parameters:
        listener - the reference to add
      • removeCloseListener

        void removeCloseListener​(DomainObjectClosedListener listener)
        Removes the given close listener.
        Parameters:
        listener - the listener to remove.
      • createPrivateEventQueue

        EventQueueID createPrivateEventQueue​(DomainObjectListener listener,
                                             int maxDelay)
        Creates a private event queue that can be flushed independently from the main event queue.
        Parameters:
        listener - the listener to be notified of domain object events.
        maxDelay - the time interval (in milliseconds) used to buffer events.
        Returns:
        a unique identifier for this private queue.
      • removePrivateEventQueue

        boolean removePrivateEventQueue​(EventQueueID id)
        Removes the specified private event queue
        Parameters:
        id - the id of the queue to remove.
        Returns:
        true if the id represents a valid queue that was removed.
      • getDescription

        java.lang.String getDescription()
        Returns a word or short phrase that best describes or categorizes the object in terms that a user will understand.
        Returns:
        the description
      • getName

        java.lang.String getName()
        Get the name of this domain object.
        Returns:
        the name
      • setName

        void setName​(java.lang.String name)
        Set the name for this domain object.
        Parameters:
        name - object name
      • getDomainFile

        DomainFile getDomainFile()
        Get the domain file for this domain object.
        Returns:
        the associated domain file
      • addConsumer

        boolean addConsumer​(java.lang.Object consumer)
        Adds the given object as a consumer. The release method must be invoked with this same consumer instance when this domain object is no longer in-use.
        Parameters:
        consumer - domain object consumer
        Returns:
        false if this domain object has already been closed
      • getConsumerList

        java.util.ArrayList<java.lang.Object> getConsumerList()
        Returns the list of consumers on this domainObject
        Returns:
        the list of consumers.
      • isUsedBy

        boolean isUsedBy​(java.lang.Object consumer)
        Returns true if the given consumer is using (has open) this domain object.
        Parameters:
        consumer - the object to test to see if it is a consumer of this domain object.
        Returns:
        true if the given consumer is using (has open) this domain object;
      • setEventsEnabled

        void setEventsEnabled​(boolean enabled)
        If true, domain object change events are sent. If false, no events are sent.

        NOTE: disabling events could cause plugins to be out of sync!

        NOTE: when re-enabling events, an event will be sent to the system to signal that every listener should update.

        Parameters:
        enabled - true means to enable events
      • isSendingEvents

        boolean isSendingEvents()
        Returns true if this object is sending out events as it is changed. The default is true. You can change this value by calling setEventsEnabled(boolean).
        Returns:
        true if sending events
        See Also:
        setEventsEnabled(boolean)
      • flushEvents

        void flushEvents()
        Makes sure all pending domainEvents have been sent.
      • flushPrivateEventQueue

        void flushPrivateEventQueue​(EventQueueID id)
        Flush events from the specified event queue.
        Parameters:
        id - the id specifying the event queue to be flushed.
      • canLock

        boolean canLock()
        Returns true if a modification lock can be obtained on this domain object. Care should be taken with using this method since this will not prevent another thread from modifying the domain object.
        Returns:
        true if can lock
      • isLocked

        boolean isLocked()
        Returns true if the domain object currently has a modification lock enabled.
        Returns:
        true if locked
      • lock

        boolean lock​(java.lang.String reason)
        Attempt to obtain a modification lock on the domain object. Multiple locks may be granted on this domain object, although all lock owners must release their lock in a timely fashion.
        Parameters:
        reason - very short reason for requesting lock
        Returns:
        true if lock obtained successfully, else false which indicates that a modification is in process.
      • forceLock

        void forceLock​(boolean rollback,
                       java.lang.String reason)
        Cancels any previous lock and acquires it.
        Parameters:
        rollback - if true, any changes in made with the previous lock should be discarded.
        reason - very short reason for requesting lock
      • unlock

        void unlock()
        Release a modification lock previously granted with the lock method.
      • getOptionsNames

        java.util.List<java.lang.String> getOptionsNames()
        Returns all properties lists contained by this domain object.
        Returns:
        all property lists contained by this domain object.
      • getOptions

        Options getOptions​(java.lang.String propertyListName)
        Get the property list for the given name.
        Parameters:
        propertyListName - name of property list
        Returns:
        the options
      • isClosed

        boolean isClosed()
        Returns true if this domain object has been closed as a result of the last release
        Returns:
        true if closed
      • hasExclusiveAccess

        boolean hasExclusiveAccess()
        Returns true if the user has exclusive access to the domain object. Exclusive access means either the object is not shared or the user has an exclusive checkout on the object.
        Returns:
        true if has exclusive access
      • getMetadata

        java.util.Map<java.lang.String,​java.lang.String> getMetadata()
        Returns a map containing all the stored metadata associated with this domain object. The map contains key,value pairs and are ordered by their insertion order.
        Returns:
        a map containing all the stored metadata associated with this domain object.
      • getModificationNumber

        long getModificationNumber()
        Returns a long value that gets incremented every time a change, undo, or redo takes place. Useful for implementing a lazy caching system.
        Returns:
        a long value that is incremented for every change to the program.