Interface ILockState


  • public interface ILockState
    Interface used to handle locking and unlocking of the application session, with potential message and progress indicator.

    In case this instance's method release() is not called, the lock state will not be released until this instance is garbage collected.

    This lock can be obtained from the IAppSessionGyro as well as the IClientSessionGyro. If obtained from a client session, a dispose listener is used to unlock the application session in case the client session is disposed of and the lock never released.

    This class implementor of this interface is written in such a way that the lock state will be released upon garbage collection if you have forgotten to release it.

    Author:
    Christopher Mindus
    • Method Detail

      • createNewLock

        ILockState createNewLock()
        Creates a new lock state instance from this one, incrementing the lock, i.e. the caller must issue release() on the new instance also in order to release the lock.
        Returns:
        The new lock state, null if this lock state is already released, or the app or client session is disposed of.
      • getAppSessionGyro

        IAppSessionGyro getAppSessionGyro()
        Gets the application session gyro.
        Returns:
        The gyro instance.
      • getClientSessionGyro

        IClientSessionGyro getClientSessionGyro()
        Gets the client session gyro.
        Returns:
        The client gyro instance, or null if not retrieved from a client session but from an application session gyro.
      • setMessage

        boolean setMessage​(KString msg)
        Sets the message to display for the lock state, above the indicator.
        Parameters:
        msg - The message to display, or null to remove it.
        Returns:
        true for changed, or false if busy state is not present or no change of message.
      • setMessage

        boolean setMessage​(KString msg,
                           int progress)
        Sets the message to display for the lock state, above the indicator, along with a progress value.
        Parameters:
        msg - The message to display, or null to remove it.
        progress - The progress value between 0 and 100, or -1 to remove it.
        Returns:
        true for changed, or false if busy state is not present or no change of values.
        Throws:
        java.lang.IllegalArgumentException - If the progress value is not -1 or 0 to 100.
      • setMessage

        boolean setMessage​(KString msg,
                           int delay,
                           int progress)
        Sets the message to display for the lock state, above the indicator, along with a progress value.
        Parameters:
        msg - The message to display, or null to remove it.
        delay - Delay of lock spinner: -2 for default (1.5 second), -1 disabled, 0=no delay, >0 wait time in milliseconds (1-20000, i.e. 20 seconds).
        progress - The progress value between 0 and 100, or -1 to remove it.
        Returns:
        true for changed, or false if busy state is not present or no change of values.
        Throws:
        java.lang.IllegalArgumentException - If progress value is not -1 or 0 to 100, or delay is smaller than -2 or larger than 20000.
      • setProgress

        boolean setProgress​(int progress)
        Sets the current progress bar value.
        Parameters:
        progress - The progress value between 0 and 100, or -1 to remove it.
        Returns:
        true for changes, false for no change or no lock state.
        Throws:
        java.lang.IllegalArgumentException - If the progress value is not -1 or 0 to 100.
      • isReleased

        boolean isReleased()
        Checks if this lock state is released or not.
      • release

        boolean release()
        Releases the lock state.
        Returns:
        true for success, false if already released.