Changes between Version 10 and Version 11 of GROUP_SCRIPTING_R0


Ignore:
Timestamp:
07/11/09 11:05:51 (16 years ago)
Author:
mitex
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TabularUnified GROUP_SCRIPTING_R0

    v10 v11  
    5656   * RwProp<String> scriptText - the javascript source code text 
    5757  * subpackage {{{persistence}}} 
    58    * class {{{ScriptPersister}}} extends {{{Persister<String, Storage>}}} 
     58   * class {{{ScriptResPersister}}} extends {{{Persister<String, Storage>}}} 
    5959    * schema "resource:script|storage|r3" 
    6060    * the storage should have one child for the script text 
    6161    * this persister is needed when the parent book is persisted. 
    62    * class {{{ScriptFilePersister}}} extends {{{Persister<Storage, File>}}} 
    63     * schema "storage|file|js" 
    64     * the script is persisted as a plain text file with ".js" extension 
    65    * register the persisters as extensions 
     62   * register the persister as an extension 
    6663 
    6764 * view: 
     
    7168   * INSERT_SCRIPT_FILE 
    7269   * RUN_SCRIPT 
    73    * EDIT_SCRIPT 
     70   * TEXT_CHANGED 
     71   * OPEN_WINDOW 
    7472  * document window for resource viewing, editing and running: 
    7573   * class {{{ScriptDocumentWindow}}} extends {{{DefaultDocumentWindow}}} implements {{{DocumentView}}} 
    76    * RwProp<ResourceRef> model - the script resource that is displayed 
     74   * In DocumentWindow add Prop<ResourceRef> modelDocument() 
     75   * RwProp<ResourceRef> modelDocument - the script resource that is displayed 
    7776   * resource property {{{swingFrameSync}}} that adds the following components to {{{swingComponent}}}: 
    78     * a text area that fires EDIT_SCRIPT 
    79     * and "Run" {{{LogicR3Button}}} that fires RUN_SCRIPT 
     77    * a text area that fires TEXT_CHANGED 
     78    * "Run" {{{LogicR3Button}}} that fires RUN_SCRIPT 
     79    * a text area for the script result or error messages 
    8080  * class {{{ScriptDocumentWindowProvider}}} implements {{{DocumentWindowProvider}}} (see last section) 
    8181   * getWindow should return a new {{{ScriptDocumentWindow}}} for the given script resource 
     
    8585    * {{{getResourceKind()}}} should return the kind in {{{ScriptResource}}} 
    8686    * {{{filterKind()}}} should return "Script" 
    87     * nested private static class {{{ScriptResourcePreview}}} 
     87    * nested static class {{{ScriptResourcePreview}}} which is a {{{SwingVisualElement}}} 
    8888     * constructor with argument of type {{{ScriptResource}}} 
    89      * in {{{swingComponent}}} create a new JPanel, analogic to the panel in {{{ScriptDocumentWindow}}} 
    90       * components should fire the same events as in {{{ScriptDocumentWindow}}} 
     89     * in {{{swingComponent}}} create a new JPanel with: 
     90      * read-only JTextArea that displays the script content 
     91      * "Open" LogicR3Button that fires OPEN_WINDOW 
    9192    * {{{getVisualElement(Resource element)}}} should return a new instance of {{{ScriptResourcePreview}}} 
     93   * In ResourceDetailsPalette create a property RwProp<SwingVisualElement> previewVisualElement 
     94    * use @Own annotation because the parent is required in the logic of OPEN_WINDOW 
    9295   * register the class as an extension 
    9396 
    9497 * logic: 
    9598  * enum ScriptingLogic that implements OperationDef: 
    96    * all of the following items should listen for an event with the same id 
     99   * all of the following items should listen for an event with the corresponding id 
    97100   * INSERT_SCRIPT 
    98101    * listens for the event in {{{InsertScriptItem}}} 
    99102    * creates a new empty {{{ScriptResource}}} in current book (use {{{CurrentBookUtil.getCurrentBook}}}) 
    100103    * adds it to {{{App.documents}}} (see last section for details) 
     104    * sets it as current 
    101105   * INSERT_SCRIPT_FILE 
    102106    * listens for the event in {{{InsertScriptFileItem}}} 
     
    104108    * using the persisters, creates a new {{{ScriptResource}}} in current book 
    105109    * adds it to {{{App.documents}}} (see last section) 
     110    * sets it as current 
    106111   * RUN_SCRIPT 
    107112    * write the following temporary solution: 
     
    109114     * initialize the standard objects (Object, Function, etc.) using {{{Scriptable scope = cx.initStandardObjects();}}} 
    110115     * evaluate the resource's text: {{{Object result = cx.evaluateString(scope, s, "<cmd>", 1, null);}}} 
    111      * if there's a result, open a message box to display the result by creating a new {{{MessageDialogInput}}} and invoking {{{DialogManager#showDialog}}} 
     116     * display the result in the result text area. 
     117     * if org.mozilla.javascript.EcmaError or org.mozilla.javascript.EvaluatorException is thrown, display the message in the result text area 
    112118     * exit from the context with {{{Context.exit();}}}. Call this from a finally block. 
    113    * EDIT_SCRIPT 
     119   * TEXT_CHANGED 
    114120    * the following solution can be optimized: 
    115      * create a new AutoChange that changes the text in the resource with that from the text area. Register the change to script's book. 
     121     * create a new AutoChange that changes the text in the resource with that from the text area. Register the change to the script resource. 
     122   * OPEN_WINDOW 
     123    * get the source which is of type {{{ScriptResourcePreview}}} 
     124    * add its model to the list {{{App.documents}}}, but only if it is not already added 
     125    * set the document as current 
    116126   * register the enum as an extension 
    117127 
     
    120130  * Create an interface {{{org.sophie2.main.app.commons.windows.DocumentWindowProvider}}} 
    121131   * String getResourceKind() - Gets the resource kind of the resource for which this provider should create appropriate document window. 
    122    * DocumentWindow getWindow(ResourceRef ref) - Creates a new concrete implementation of {{{DocumentWindow}}} for the given resource. 
     132   * DocumentWindowProvider getWindowProvider(ResourceRef ref) - Creates a new concrete implementation of {{{DocumentWindowProvider}}} for the given resource. 
    123133  * Create an extension point in {{{MainAppModule}}} for document window providers 
    124134  * Class {{{org.sophie2.main.app.commons.windows.BookDocumentWindowProvider}}} implements {{{DocumentWindowProvider}}} and creates book document windows 
    125135   * Register it as an extension 
    126136  * Class {{{org.sophie2.main.app.commons.windows.DocumentWindowProviderFactory}}} 
    127    * static DocumentWindow createWindow(ResourceRef ref) 
     137   * static DocumentWindowProvider getWindowProvider(ResourceRef ref) 
    128138    * iterates over all extensions in the extension point 
    129     * if an appropriate provider is found, creates a document window with it 
    130   * Remove the properties {{{currentBook}}} and {{{lastCurrentBook}}} in {{{App}}}. 
    131    * Create analogical property {{{lastCurrentWindow}}} in {{{AppDocumentsDesktop}}}. 
    132    * Refactor the {{{AppDocumentsDesktop.currentWindow}}}. 
    133    * Replace all calls of currentBook with calls of currentWindow. 
    134   * On book closing close all children resources too (currently they can be scripts). 
     139    * if an appropriate provider is found, returns it 
     140  * Refactor {{{AppDocumentsDesktop.windows}}}: 
     141   * create a class DocumentInfo that has two fields - ResourceRef ref and DocumentWindowProvider provider 
     142   * create a hash map with keys of type DocumentInfo and values of type DocumentWindow 
     143    * override equals and hashCode methods 
     144    * create a hashCode in ResourceRef too 
     145   * replace the TrackingProList with ComposingProList 
     146   * iterate over all open documents and use the factory to find the appropriate provider 
     147   * if the cache (the hash map) contains DocumentInfo with these resource reference and provider, return the window 
     148   * if not, create a new window with the factory and store it in the cache 
    135149 
    136150 * Source code: [source:/branches/private/deni/scripting/] 
     151  * Tests: [source:/branches/private/deni/scripting/modules/org.sophie2.extra.func.scripting/src/test/java/org/sophie2/extra/func/scripting] 
    137152 
    138153= Implementation = 
    139 ^(Describe and link the implementation results here (from the wiki or the repository).)^ 
     154 * Source code: [source:/branches/private/deni/scripting/] 
    140155 
    141156= Testing =