- All Superinterfaces:
Activity,Disableable,PropertyBean
- All Known Implementing Classes:
AbstractFileBasedActivity
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 Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ObjectProperty<@Nullable javafx.scene.input.DataFormat> This property specifies the format that is used for storing the content in the file.javafx.beans.property.ReadOnlyBooleanPropertyThe modified property indicates that the content has been modified and needs to be saved to the file.javafx.beans.property.StringPropertyFor file-based activity, the title should be bound to the file name from theuriProperty().javafx.beans.property.ObjectProperty<@Nullable URI> This property is used to identify the file that is used for storing the content.Properties inherited from interface org.jhotdraw8.application.Activity
actions, application, disambiguationProperties inherited from interface org.jhotdraw8.fxbase.control.Disableable
disabled -
Field Summary
FieldsFields inherited from interface org.jhotdraw8.application.Activity
APPLICATION_PROPERTY, DISAMBIGUATION_PROPERTY, TITLE_PROPERTYFields inherited from interface org.jhotdraw8.fxbase.control.Disableable
DISABLED_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptionclear()Clears the content.voidClears the modified property.javafx.beans.property.ObjectProperty<@Nullable javafx.scene.input.DataFormat> This property specifies the format that is used for storing the content in the file.default @Nullable javafx.scene.input.DataFormatGets the value of thedataFormatproperty.default @Nullable URIgetURI()default booleanisEmpty()Returns true if this content is empty and can be replaced by another document without that the user loses data.default booleanGets the value of themodifiedproperty.javafx.beans.property.ReadOnlyBooleanPropertyThe modified property indicates that the content has been modified and needs to be saved to the file.Prints the current content.CompletionStage<javafx.scene.input.DataFormat> read(URI uri, @Nullable javafx.scene.input.DataFormat format, ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>, Object> options, boolean insert, WorkState<Void> workState) Asynchronously reads content data from the specified URI.default CompletableWorker<Void> read(URI uri, ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>, Object> options) Sets the content of this activity by asynchronously reading the data from the specified uri.default voidsetDataFormat(@Nullable javafx.scene.input.DataFormat newValue) Sets the value of thedataFormatproperty.default voidjavafx.beans.property.StringPropertyFor file-based activity, the title should be bound to the file name from theuriProperty().javafx.beans.property.ObjectProperty<@Nullable URI> This property is used to identify the file that is used for storing the content.write(URI uri, @Nullable javafx.scene.input.DataFormat format, ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>, Object> options, WorkState<Void> workState) Asynchronously writes document data to the specified URI.default CompletableWorker<Void> write(URI uri, ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>, Object> options, WorkState<Void> state) Asynchronously writes the content of this activity into the specified uri.Methods inherited from interface org.jhotdraw8.application.Activity
actionsProperty, applicationProperty, destroy, disambiguationProperty, getActions, getApplication, getDisambiguation, getNode, getTitle, init, setApplication, setDisambiguation, setTitle, start, stopMethods inherited from interface org.jhotdraw8.fxbase.control.Disableable
addDisabler, disabledProperty, disablers, isDisabled, removeDisablerMethods inherited from interface org.jhotdraw8.fxbase.beans.PropertyBean
get, getNonNull, getProperties, getProperty, put, remove, set, setNonNull, valueAt
-
Property Details
-
modified
javafx.beans.property.ReadOnlyBooleanProperty modifiedPropertyThe 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 anActioninvoked by the user, or by an automatic save function managed by theApplication.- See Also:
-
uri
javafx.beans.property.ObjectProperty<@Nullable URI> uriPropertyThis 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
javafx.beans.property.ObjectProperty<@Nullable javafx.scene.input.DataFormat> dataFormatPropertyThis 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
javafx.beans.property.StringProperty titlePropertyFor file-based activity, the title should be bound to the file name from theuriProperty().See
Activity.titleProperty()for a general description of this property.- Specified by:
titlePropertyin interfaceActivity- Returns:
- the title of the activity
- See Also:
-
-
Field Details
-
MODIFIED_PROPERTY
- See Also:
-
URI_PROPERTY
- See Also:
-
DATA_FORMAT_PROPERTY
- See Also:
-
-
Method Details
-
modifiedProperty
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 anActioninvoked by the user, or by an automatic save function managed by theApplication.- Returns:
- the modified property
- See Also:
-
isModified
default boolean isModified()Gets the value of themodifiedproperty.- 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 anActioninvoked by the user, or by an automatic save function managed by theApplication. - Returns:
- the value of the
modifiedproperty - See Also:
-
clearModified
void clearModified()Clears the modified property.- See Also:
-
uriProperty
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
-
setURI
-
dataFormatProperty
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 thedataFormatproperty.- 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
dataFormatproperty - See Also:
-
setDataFormat
default void setDataFormat(@Nullable javafx.scene.input.DataFormat newValue) Sets the value of thedataFormatproperty.- 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 thedataFormatproperty- See Also:
-
read
CompletionStage<javafx.scene.input.DataFormat> read(URI uri, @Nullable javafx.scene.input.DataFormat format, 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
SimpleWorkStateduring a read. SeeDisableable.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 URIformat- the desired data format, null means default data format should be usedoptions- read optionsinsert- 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 CompletableWorker<Void> read(URI uri, 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
Actionthat invokes this method.activity.addDisablers(anAction); activity.read(uri, options).handle((data,ex)->{ ... activity.removeDisablers(anAction); });- Parameters:
uri- an urioptions- reading options- Returns:
- a completable worker for monitoring the progress of the read operation
-
write
CompletionStage<Void> write(URI uri, @Nullable javafx.scene.input.DataFormat format, ImmutableMap<org.jhotdraw8.fxcollection.typesafekey.Key<?>, Object> options, 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
SimpleWorkStateduring a read. See usage example inread(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 URIformat- the desired data format, null means default data format should be usedoptions- write optionsworkState- 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 CompletableWorker<Void> write(URI uri, 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
Actionthat invokes this method.activity.addDisablers(anAction); activity.write(uri, options).handle((data,ex)->{ ... activity.removeDisablers(anAction); });- Parameters:
uri- an urioptions- writing options- Returns:
- a completable worker for monitoring the progress of the write operation
-
clear
CompletionStage<Void> clear()Clears the content.- Returns:
- Returns a CompletionStage which is completed when the clear
operation has finished. For example
return CompletableFuture.completedFuture(null);
-
print
Prints the current content.This method must not change the current document.
The activity must be disabled with a
SimpleWorkStateduring printing. See usage example inread(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:
job- the printer jobworkState- 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
javafx.beans.property.StringProperty titleProperty()For file-based activity, the title should be bound to the file name from theuriProperty().See
Activity.titleProperty()for a general description of this property.- Specified by:
titlePropertyin interfaceActivity- Returns:
- the title of the activity
- See Also:
-