Interface FileBasedActivity

All Superinterfaces:
Activity, Disableable, PropertyBean
All Known Implementing Classes:
AbstractFileBasedActivity

public interface FileBasedActivity extends Activity
A FileBasedActivity is an Activity that involves data that is stored in a file.

There is one activity instance per file. The filename is used as the title of the activity.

The storage location of a file is not restricted to the file system. This is why, the storage location of the file is identified by an URI.

Author:
Werner Randelshofer
  • Property Details

    • modified

      @NonNull javafx.beans.property.ReadOnlyBooleanProperty modifiedProperty
      The modified property indicates that the content has been modified and needs to be saved to the file.

      This property is set to true if a change in the content has been detected.

      The property is only set to false by calling clearModified(). This is typically done by an Action invoked by the user, or by an automatic save function managed by the Application.

      See Also:
    • uri

      @NonNull javafx.beans.property.ObjectProperty<@Nullable URI> uriProperty
      This property is used to identify the file that is used for storing the content.

      This property is managed by the Actions that load and save the content from/to the file.

      See Also:
    • dataFormat

      @NonNull javafx.beans.property.ObjectProperty<@Nullable javafx.scene.input.DataFormat> dataFormatProperty
      This property specifies the format that is used for storing the content in the file.

      This property is managed by Actions. Typically by actions that load or save the content, and actions that manage file properties.

      See Also:
    • title

      @NonNull javafx.beans.property.StringProperty titleProperty
      For file-based activity, the title should be bound to the file name from the uriProperty().

      See Activity.titleProperty() for a general description of this property.

      Specified by:
      titleProperty in interface Activity
      Returns:
      the title of the activity
      See Also:
  • Field Details

  • Method Details

    • modifiedProperty

      @NonNull javafx.beans.property.ReadOnlyBooleanProperty modifiedProperty()
      The modified property indicates that the content has been modified and needs to be saved to the file.

      This property is set to true if a change in the content has been detected.

      The property is only set to false by calling clearModified(). This is typically done by an Action invoked by the user, or by an automatic save function managed by the Application.

      Returns:
      the modified property
      See Also:
    • isModified

      default boolean isModified()
      Gets the value of the modified property.
      Property description:
      The modified property indicates that the content has been modified and needs to be saved to the file.

      This property is set to true if a change in the content has been detected.

      The property is only set to false by calling clearModified(). This is typically done by an Action invoked by the user, or by an automatic save function managed by the Application.

      Returns:
      the value of the modified property
      See Also:
    • clearModified

      void clearModified()
      Clears the modified property.
      See Also:
    • uriProperty

      @NonNull javafx.beans.property.ObjectProperty<@Nullable URI> uriProperty()
      This property is used to identify the file that is used for storing the content.

      This property is managed by the Actions that load and save the content from/to the file.

      Returns:
      the resource
    • getURI

      default @Nullable URI getURI()
    • setURI

      default void setURI(@Nullable URI newValue)
    • dataFormatProperty

      @NonNull javafx.beans.property.ObjectProperty<@Nullable javafx.scene.input.DataFormat> dataFormatProperty()
      This property specifies the format that is used for storing the content in the file.

      This property is managed by Actions. Typically by actions that load or save the content, and actions that manage file properties.

      Returns:
      the data format of the content
      See Also:
    • getDataFormat

      default @Nullable javafx.scene.input.DataFormat getDataFormat()
      Gets the value of the dataFormat property.
      Property description:
      This property specifies the format that is used for storing the content in the file.

      This property is managed by Actions. Typically by actions that load or save the content, and actions that manage file properties.

      Returns:
      the value of the dataFormat property
      See Also:
    • setDataFormat

      default void setDataFormat(@Nullable javafx.scene.input.DataFormat newValue)
      Sets the value of the dataFormat property.
      Property description:
      This property specifies the format that is used for storing the content in the file.

      This property is managed by Actions. Typically by actions that load or save the content, and actions that manage file properties.

      Parameters:
      newValue - the value for the dataFormat property
      See Also:
    • read

      @NonNull CompletionStage<@NonNull javafx.scene.input.DataFormat> read(@NonNull URI uri, @Nullable javafx.scene.input.DataFormat format, @NonNull ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>,Object> options, boolean insert, WorkState<Void> workState)
      Asynchronously reads content data from the specified URI.

      This method must not change the current document if reading fails or is canceled.

      The activity must be disabled with a SimpleWorkState during a read. See Disableable.

      Usage:

      
       WorkState ws = new WorkState("read");
       activity.addDisablers(ws);
       activity.read(uri, format, options, insert, workState).handle((fmt,ex)->{
          ...
          activity.removeDisablers(ws);
       });
       
      Parameters:
      uri - the URI
      format - the desired data format, null means default data format should be used
      options - read options
      insert - whether to insert into the current document or to replace it.
      workState - the work state for monitoring this invocation of the read method. The work state is updated by the read method. The worker can be used to cancel the read.
      Returns:
      Returns a CompletionStage which is completed with the data format that was actually used for reading the file.
    • read

      default @NonNull CompletableWorker<Void> read(@NonNull URI uri, @NonNull ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>,Object> options)
      Sets the content of this activity by asynchronously reading the data from the specified uri.

      The activity must be disabled with the Action that invokes this method.

      
       activity.addDisablers(anAction);
       activity.read(uri, options).handle((data,ex)->{
          ...
          activity.removeDisablers(anAction);
       });
       
      Parameters:
      uri - an uri
      options - reading options
      Returns:
      a completable worker for monitoring the progress of the read operation
    • write

      @NonNull CompletionStage<Void> write(@NonNull URI uri, @Nullable javafx.scene.input.DataFormat format, @NonNull ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>,Object> options, @NonNull WorkState<Void> workState)
      Asynchronously writes document data to the specified URI.

      This method must not change the current document.

      The activity must be disabled with a SimpleWorkState during a read. See usage example in read(java.net.URI, javafx.scene.input.DataFormat, org.jhotdraw8.icollection.immutable.ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>, java.lang.Object>, boolean, org.jhotdraw8.fxbase.concurrent.WorkState<java.lang.Void>).

      Parameters:
      uri - the URI
      format - the desired data format, null means default data format should be used
      options - write options
      workState - the work state for monitoring this invocation of the write method. The work state is updated by the write method. The worker can be used to cancel the write.
      Returns:
      Returns a CompletionStage which is completed when the write operation has finished.
    • write

      default @NonNull CompletableWorker<Void> write(@NonNull URI uri, @NonNull ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>,Object> options, WorkState<Void> state)
      Asynchronously writes the content of this activity into the specified uri.

      The activity must be disabled with the Action that invokes this method.

      
       activity.addDisablers(anAction);
       activity.write(uri, options).handle((data,ex)->{
          ...
          activity.removeDisablers(anAction);
       });
       
      Parameters:
      uri - an uri
      options - writing options
      Returns:
      a completable worker for monitoring the progress of the write operation
    • clear

      Clears the content.
      Returns:
      Returns a CompletionStage which is completed when the clear operation has finished. For example return CompletableFuture.completedFuture(null);
    • print

      @NonNull CompletionStage<Void> print(@NonNull javafx.print.PrinterJob job, @NonNull WorkState<Void> workState)
      Parameters:
      job - the printer job
      workState - the work state for monitoring this invocation of the print method. The work state is updated by the print method. The worker can be used to cancel printing.
      Returns:
      Returns a CompletionStage which is completed when the print operation has finished. For example return CompletableFuture.completedFuture(null);
    • isEmpty

      default boolean isEmpty()
      Returns true if this content is empty and can be replaced by another document without that the user loses data.
      Returns:
      true if empty
    • titleProperty

      @NonNull javafx.beans.property.StringProperty titleProperty()
      For file-based activity, the title should be bound to the file name from the uriProperty().

      See Activity.titleProperty() for a general description of this property.

      Specified by:
      titleProperty in interface Activity
      Returns:
      the title of the activity
      See Also: