class
ProjectLibraryImportNewOperation
Project library operation that imports one or multiple resources from a source resource of some third-party format.
Third-party format must have a importer registered for the extension otherwise the operation will fail. Note the operation cannot overwrite existing files.
The operation works in two ways depending on if the imported resources should synchronized with the source resource or not:
- Not synchronized - Multiple resources may be imported from a single source resource, in which case an individual package will be created for each imported resource and they will be placed in a newly created folder with the same name as the source resource. If a single resource is imported instead, no folder will be created and the resource will have the same name as the source resource.
- Synchronized - All imported resources will be placed in a single package. That package will be read-only and its contents cannot be modified by other project library operations, other than re-importing the package contents from the source resource. Source resource will be copied into the source resources folder so external system can monitor it for changes and trigger reimport operation when it changes.
Public
Constructors
ProjectLibraryImportNewOperation
Constructs the operation.
- context
- Project library context the operation is being executed in.
- sourceResourcePath
- Absolute path to the source resource to import.
- destinationFolderRelativePath
- Path to the folder where the imported resources will be stored. Relative to the project library imported resources folder.
- importOptions
- Options used to control the import. Must match the imported file type. May be null in which case defaults will be used.
- synchronizeWithSourceResource
- If false, imported resources will all be stored as their own individual packages. If true, all resources will be placed in a single read-only package. Such package cannot be modified by the project library, and it may instead just be re-imported from its associated source resource. The source resource at path will be copied into the source resources folder.
Methods
PrepareOnMainThread
Performs the first stage of the operation.
Verifies the input parameters are correct, creates library database entries (if possible) and returns success if operation will proceed to execute. Executed on the main thread.
Returns: Operation result and optional error message if failed.
RunOnWorkerThread
Performs the second stage of the operation.
Performs longer lasting tasks such as saving or loading a package, copying a file or generating preview icons. Executed on a worker thread.
FinalizeOnMainThread
Performs the last stage of the operation.
This will be called after the worker thread completes. Will ensure the entries in the project library database match to packages written by the worker thread.