Class ResourceCollectControl

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Component, Control, InputFocusableComponent, Displayable, Enableable, InfoModel, LabelModel, Model, PresentationModel, DepictedObject

public class ResourceCollectControl extends AbstractControl
Control that allows resources to be collected and received at a given path. The destination path should reference a registered ResourceWriteDestination of the application.
Author:
Garret Wilson
  • Field Details

    • RESOURCE_PATHS_PROPERTY

      public static final String RESOURCE_PATHS_PROPERTY
      The bound property of the paths of the collected resources.
    • STATE_PROPERTY

      public static final String STATE_PROPERTY
      The bound property of the state of receiving collected resources.
  • Constructor Details

    • ResourceCollectControl

      public ResourceCollectControl()
      Default constructor with a default models.
    • ResourceCollectControl

      public ResourceCollectControl(InfoModel infoModel, Enableable enableable)
      Info model and enableable object constructor.
      Parameters:
      infoModel - The component info model.
      enableable - The enableable object in which to store enabled status.
      Throws:
      NullPointerException - if the given info model and/or enableable object is null.
  • Method Details

    • getDepictor

      Specified by:
      getDepictor in interface Component
      Specified by:
      getDepictor in interface DepictedObject
      Overrides:
      getDepictor in class AbstractComponent
      Returns:
      The depictor for this component.
    • getState

      public com.globalmentor.model.TaskState getState()
      Returns:
      The state of receiving resources, or null if receiving has not been initiated.
    • setState

      public void setState(com.globalmentor.model.TaskState newSendState)
      Sets the state of receiving resources. This method is called by the associated depictor and should normally not be called directly by applications. This is a bound property.
      Parameters:
      newSendState - The new state of receiving resources, or null if receiving has not been initiated.
      See Also:
    • getResourcePaths

      public List<String> getResourcePaths()
      Returns the paths of the currently collected resources. These paths are for identification only, and are not guaranteed to represent any location accessible from the application.
      Returns:
      The the paths of the currently collected resources.
    • addResourcePath

      public void addResourcePath(String resourcePath)
      Adds a new resource path. This method changes a bound property of type List holding type String. This method is called by the framework and normally this should not be called directly from applications. Manually adding a new resource path, depending on the platform, may not actually result in another resource being collected absent user intervention.
      Parameters:
      resourcePath - The resource path to add.
      Throws:
      NullPointerException - if the given resource path is null.
      See Also:
    • removeResourcePath

      public void removeResourcePath(String resourcePath)
      Removes a resource path. This method changes a bound property of type List holding type String. This method is called by the framework and normally this should not be called directly from applications. //TODO fix to actually tell the browser control that the path has changed Manually adding a new resource path, depending on the platform, may not actually result in another resource being collected absent user intervention.
      Parameters:
      resourcePath - The resource path to remove.
      Throws:
      NullPointerException - if the given resource path is null.
      See Also:
    • clearResourcePaths

      public void clearResourcePaths()
      Clears all resource paths. This method changes a bound property of type List holding type String. This method is called by the framework and normally this should not be called directly from applications. //TODO fix to actually tell the browser control that the path has changed Manually adding a new resource path, depending on the platform, may not actually result in another resource being collected absent user intervention.
      See Also:
    • getDestinationPath

      public String getDestinationPath()
      Indicates the destination path relative to the application context path.
      Returns:
      The path representing the destination of the collected resources, or null if no resources are currently being sent.
    • getDestinationBookmark

      public Bookmark getDestinationBookmark()
      Returns:
      The bookmark being used in receiving the resources at the destination path, or null if there is no bookmark specified and/or no resources are currently being sent.
    • receiveResources

      public void receiveResources(String destinationPath)
      Receives collected resources at the given destination path with no bookmark.
      Parameters:
      destinationPath - The path representing the destination of the collected resources, relative to the application.
      Throws:
      NullPointerException - if the given path is null.
      IllegalArgumentException - if the provided path specifies a URI scheme (i.e. the URI is absolute) and/or authority.
    • receiveResources

      public void receiveResources(String destinationPath, Bookmark destinationBookmark)
      Receives collected resources at the given destination path using the given bookmark. If the resources are currently started to be received or already being received, no action occurs.
      Parameters:
      destinationPath - The path representing the destination of the collected resources, relative to the application.
      destinationBookmark - The bookmark to be used in receiving the resources at the destination path, or null if no bookmark should be used.
      Throws:
      NullPointerException - if the given path is null.
      IllegalArgumentException - if the provided path specifies a URI scheme (i.e. the URI is absolute) and/or authority.
      IllegalArgumentException - if the provided path is absolute.
    • cancelReceive

      public void cancelReceive()
      Cancels any currently occurring resource transfers. If the resources are not currently being transferred, no action occurs.
    • addProgressListener

      public void addProgressListener(ProgressListener<Long> progressListener)
      Adds a progress listener.
      Parameters:
      progressListener - The progress listener to add.
    • removeProgressListener

      public void removeProgressListener(ProgressListener<Long> progressListener)
      Removes an progress listener.
      Parameters:
      progressListener - The progress listener to remove.
    • fireProgressed

      public void fireProgressed(String task, com.globalmentor.model.TaskState taskState, long value, long maximumValue)
      Fires a progress event to all registered progress listeners. This method delegates to fireProgressed(ProgressEvent).
      Parameters:
      task - The task being performed, or null if not indicated.
      taskState - The state of the task.
      value - The current progress, or -1 if not known.
      maximumValue - The goal, or -1 if not known.
      Throws:
      NullPointerException - if the given task state is null.
      See Also:
    • fireProgressed

      protected void fireProgressed(ProgressEvent<Long> progressEvent)
      Fires a given progress event to all registered progress listeners.
      Parameters:
      progressEvent - The progress event to fire.