ramblings/oxygen/js-options
Eric van der Vlist 429f44f57b js-options: implementing housekeeping tasks (WIP) 2021-04-30 21:13:26 +02:00
..
css Copying 2021-04-28 15:12:30 +02:00
icons Copying 2021-04-28 15:12:30 +02:00
resources Copying 2021-04-28 15:12:30 +02:00
schema Copying 2021-04-28 15:12:30 +02:00
src-java/simple/documentation/framework Copying 2021-04-28 15:12:30 +02:00
templates Copying 2021-04-28 15:12:30 +02:00
xsl Copying 2021-04-28 15:12:30 +02:00
README.md js-options: doc 2021-04-29 14:06:43 +02:00
catalog.xml Copying 2021-04-28 15:12:30 +02:00
commons.js Copying 2021-04-28 15:12:30 +02:00
debugger.js Copying 2021-04-28 15:12:30 +02:00
hello.js js-options: implementing housekeeping tasks (WIP) 2021-04-30 21:13:26 +02:00
js-options.xpr First draft of js-options 2021-04-28 16:48:01 +02:00
options.js js-options: implementing housekeeping tasks (WIP) 2021-04-30 21:13:26 +02:00
sdf.framework Copying 2021-04-28 15:12:30 +02:00
sdf.jar Copying 2021-04-28 15:12:30 +02:00
sdf_sample.xml Copying 2021-04-28 15:12:30 +02:00
test.js First draft of js-options 2021-04-28 16:48:01 +02:00

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.