i2b2 Web Client
Space shortcuts
Space Tools

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Starting from our Hello World plug-in it is easy to build a second plug-in that uses standard tabs display and can accept SDX drop messages. Begin building this plug-in by copying the previous plug-in example into the directory /js-i2b2/cells/plugins/ExampTabs and change the filenames to reflect the naming convention of the new plug-in, resulting in the filenames:

  1. ExampTabs.js
  2. ExampTabs.css.css 


The new filenames should be reflected in the cell configuration file found at:

     /js-i2b2/cells/plugins/ExampTabs/cell_config_data.js

To register the new plug-in in the module loader configuration file add the following lines: 

// THESE ARE ALL THE CELLS THAT ARE INSTALLED ONTO THE SERVER
i2b2.hive.tempCellsList = [
    { code: "PM",
    forceLoading: true // <------- this must be set to true for the PM cell!
    },
    { code: "ONT" } ,
    { code: "CRC" } ,
    { code: "PLUGINMGR" ,
    forceLoading: true,
    forceConfigMsg: {
params          params

Wiki Markup
:  \[\]

    }
   },
    {code: "ExampHello" ,
    forceLoading: true, // <------- this must be set to true for all plugins
    forceDir: "cells/plugins/examples"
params          params
Wiki Markup
:  \[\]

    },
    {code: "ExampTabs" ,
    forceLoading: true,
    forceDir: "cells/plugins/examples"
    forceConfigMsg: {
DefaultTab          DefaultTab: 3 // <------- define variable for later use
    }
   }
];

Info
title

In this "Tabs Example" we will have the plug-in read a configuration variable called DefaultTab and use its value to display a specific tab when the plug-in is loaded. This is to present an example of how to use a single variable but the same principle applies if several values are needed. You will see how this value is used later in the section called Setup Standard Display Tabs.



Setup Standard Display Tabs

...

Once a handler function is created we can register it to accept the drop events by having the SDX system call the example's local drop event handler instead of using the default handler for that SDX Data Message data type.
To do this properly, we are going to use a simple demultiplexer function that simply calls our real drop handler in the plug-in's root namespace. There are two reasons we do this instead of registering the real drop handler directly:

  1. To remap the scope of JavaScript's this identifier so that it refers to the plug-in's base namespace
  2. To save memory


When the SDX system is told to use an alternative drop event handler function, it saves an isolated clone of that function. If the same function is going to be registered to process 10 different types of SDX data then that function would be in memory 11 times (10 in the SDX system + the original copy of the function). This does not have a big impact if the cloned function is a small router function but can have a much larger impact if the drop handler is very large.
The code to map the drop event handler for this example is shown below:

...