Eric van der Vlist 429f44f57b | ||
---|---|---|
.. | ||
css | ||
icons | ||
resources | ||
schema | ||
src-java/simple/documentation/framework | ||
templates | ||
xsl | ||
README.md | ||
catalog.xml | ||
commons.js | ||
debugger.js | ||
hello.js | ||
js-options.xpr | ||
options.js | ||
sdf.framework | ||
sdf.jar | ||
sdf_sample.xml | ||
test.js |
README.md
Options (Work in Progress)
This rambling shows how to add functionalities to the OptionStorage mechanism.
Principle
The idea is to add metadata to be able to do some kind of introspection and cleanup the options store when/if needed.
Usage hello.js
Instanciation (with a namespace set to 'hello':
var options = new Options(authorAccess, 'hello');
Setting options:
var options = new Options(authorAccess, 'hello');
These values can then be retrieved using options.getOption(key, defaultValue) but also as an object:
// Retrieve and display these options
var myOptions = options.getOptions();
for (var key in myOptions) {
var value = myOptions[key];
Packages.java.lang.System.out.println(key + ' ' + value);
}
Options can also be "per file" using methods containing the "SystemId" keyword in their names:
// Do the same with file specific options
options.setSystemIdOption('Hello', 'aligator');
options.setSystemIdOption('See you later', 'World');
var myOptions = options.getSystemIdOptions();
for (var key in myOptions) {
var value = myOptions[key];
Packages.java.lang.System.out.println(key + ' ' + value);
}
By default, the systemId is the current file system Id but it could be set up to any other file using the setSystemId() method.
Internally, "per file" properties are stored in a namespace which is the concatenation of the options namespace and the SHA1 of the systemId (such as "hello.1D4E43D67658FA9C7F17B230DB629D9DE3FA8001").
Installation
See also
More details on these hacks:
Framework
This directory includes the Oxygen sample framework on which ou can test these techniques but they should work on any framework.