Changes between Version 8 and Version 9 of SCRIPTING_ACTIONS_API_R0


Ignore:
Timestamp:
07/16/09 09:42:52 (16 years ago)
Author:
mitex
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SCRIPTING_ACTIONS_API_R0

    v8 v9  
    5757 
    5858== Implementation idea == 
    59  * Decide whether to expose the model classes (org.sophie2.base.model.book.Book, org.sophie2.base.model.book.Page, org.sophie2.base.model.book.Frame, etc.) or to write facade classes. 
     59 * Decide whether to expose the model classes (org.sophie2.base.model.book.Book, org.sophie2.base.model.book.Page, org.sophie2.base.model.book.Frame, etc.) or to write adapter classes. 
    6060  * The first approach will make scripts very powerful - the user will be able to do with them everything he/she can do with the application. In addition, it won't be necessary to update the facade every time we change something. 
    6161  * The second approach however will be more convenient for the user. It will also solve most of the security issues. 
     
    9696   * The swing component should be a panel with the combo box. 
    9797   * Register it as an extension 
    98   * Enum {{{RunScriptLogic}}} implements {{{OperationDef}}} 
     98  * Enum {{{org.sophie2.extra.func.scripting.logic.RunScriptLogic}}} implements {{{OperationDef}}} 
    9999   * Move RUN_SCRIPT from {{{ScriptLogic}}} 
    100    * ...ACTION_RUN_SCRIPT 
    101     * ... 
     100   * ACTION_RUN_SCRIPT 
     101    * Use this when activating a {{{RunScriptLinkAction}}}. 
    102102 
    103103 * For the API: 
    104104  * Package {{{org.sophie2.extra.func.scripting.facade}}} 
    105105  * Class {{{JSBook}}} extends {{{ScriptableObject}}} 
    106    * Override {{{getClassName}}} to return "Book". That means that Sophie users will see that name instead of "JSBook". 
     106   * Override {{{getClassName}}} to return "Book". That means that script writers will use "Book" instead of "JSBook". 
     107   * Create getters and setters according to the analysis. 
     108    * For example, for the title write {{{String jsGet_title()}}} and {{{void jsSet_title(String title)}}}. This will allow users to benefit from the easy JavaScript syntax: "book.title = 'Design Patterns'". 
    107109  * Class {{{JSPage}}} extends {{{ScriptableObject}}} 
    108110   * {{{getClassName}}} returns "Page". 
    109111  * Class {{{JSFrame}}} extends {{{ScriptableObject}}} 
    110112   * {{{getClassName}}} returns "Frame". 
     113  * Class {{{JSApp}}} extends {{{ScriptableObject}}} 
     114   * {{{getClassName}}} returns "App". 
     115   * Create method {{{JSBook jsFunction_newBook()}}} which  
    111116  * In {{{RunScriptLogic}}}: 
    112    * ... 
     117   * Use {{{ScriptableObject.defineClass(scope, JSBook.class);}}} to expose a given {{{ScriptableObject}}} to JavaScript. 
     118   * When executing a script from a document window, expose all adapter and facade classes. When the script is used as a link action, do not expose {{{JSApp}}}. 
     119   * Use 
     120{{{ 
     121Scriptable scriptableJsBook = context.newObject(scope, "Book"); 
     122ScriptableObject.putProperty(scope, "book", scriptableJsBook);  
     123JSBook jsBook = (JSBook) Context.jsToJava(scriptableJsBook, JSBook.class); 
     124jsBook.setBook(bookRef); 
     125}}} 
     126    to expose a global variable {{{book}}} which represents the book where the script is created. 
     127   * Expose the app too, if running a script from a document window. 
     128   * Limit the scope of visible Java classes to only Rhino classes using {{{context.setClassShutter}}}. 
    113129 
    114130 * Source code: [source:/branches/private/deni/scripting_actions/]