Last published: April 18, 2007 by 'tgriggs'
Defines 2 Classes
Extends 5 Classes
This package is meant to be used by a developer to build up and maintain an Assets subclass. It is separated in a separate package so that the external file importing/syncing behavior is not something a normal application needs to prerequisite.
It is worthwhile to explain at this point, the way the asset methods work. Consider again the example from the Asset clas comment:
^["...some code which instantiates an opaque image..."] once
The Import Specifier:
The first tag (i.e. icon:) is used to link the method with an external resource. The external resource is specified by the argument which is path to a file. The specific tag (e.g. icon: vs image: vs something else) determines what method is to be used to build a smalltalk object from the external file. At time of writing, the only two import types are image: and icon:.
The Remembered Hash:
The second tag (i.e. md5sum:) shows up after we have "integrated" the external file with the method. It is a snapshot of the md5sum of the external file at the time of integration. It can then be used to determine at future points which assets need to be reintegrated because the hash of their external files has changed.
Added Menu Items:
Two menu items show up in the class menu when an Assets class is selected:
1) Sync Assets - syncs all asset methods in the class.
2) Add Assets - with submenus for different types. Brings up a multi file selection dialog. Creates a method for each file by smalltalk-izing the file name, and then sync'ing them.
Adding a New Type of Import:
To add a new type of supported import, one must do two things. Let's say for example, you wanted to support external resources of type xml, where the resources were integrated as pre parsed structured objects representing XML trees. Two things would need to be done:
1) add a method to Assets (or just to your own Assets subclass) of ilk:
2) add a method to Assets (or to your own Assets subclass) named: '_import_xml: aLogicalFilename'. Your method should take aLogicalFilename, it can be assured it exists, and create the objects from that file and return a source code string which can recreate that object in the future (often using storeString for example).