The ELN Editor API
Notebook editors are classes that allow input of new media/data types into the notebook. The purpose of separating the editors from the notebook client is to allow domain experts to be able to build new editors without requiring access to or knowledge of the notebook client or engine. The separation of [gathering/editing] content and [transporting, signing, storing, retrieving] it is accomplished by defining a notebook object (NOb) that can "wrap" any data type. Through the new API you don't have to worry about handling the notebook object, you can leave that up to the editor wrapper and deal with the binary data directly. If you do wish to interact with the notebook objects directly you can reference the Editor API and the latest source code for the client can be found on sourceforge.
Editors are designed for a specific data type(s) and must handle all input and edit operations. They must be able to read data from a byte array or file to allow editing, and must be able to save the data as a byte array or as a reference to file containing the data. The notebook client interacts with the editor in several ways. The client can query the editor about its name/label and it's icon, get its data type, launch it, and send/receive data to/from it.
Generic Editor Wrapper
In order to implement a new, custom editor, you will need to extend the class eln.editors.GenericEditorWrapper, this will be used by the client to interact with your editor. Below are the methods that you need to be familiar with. The wrapper is located the ELNClient.jar included in the client install, this can be used when compiling your editor.
Required methods: /** Launch() - called by the parent wrapper to launch the editor, within this * method you should initialize and display the user interface. */ /** Launch() - called by the parent class to launch the editor, within this * method you should initialize and display the user interface. * @param byte data for editing existing object */ /** Launch() - called by the parent class to launch the editor, within this * method you should initialize and display the user interface. * @param java.lang.String file reference for editing existing object */ Optional methods, if unspecified then generic values will be used: /** getIcon() - get the editor icon * @returns java.awt.Image containing the editor icon */ /** getLabel() - get the editor label * @returns java.lang.String containing the editor label */ Call one of these methods to save data to the client: /** * save() - save to the notebook client, sending data. * @param byte - the data * @param String - mimeType to be associated with the data * @param String - label to be associated with the data */ /** * save() - save to the notebook client, sending reference to data. * @param String - the reference to the data (path to the data) * @param String - mimeType to be associated with the data * @param String - label to be associated with the data */
A Sample Editor
We have included a sample editor that extends the wrapper class and functions as a simple text editor. ExampleELNEditor.java.
After you build your editor you will need to configure it. There are three steps to this:
- Move your compiled editor classes into the ELN Client lib directory. It is reccomended that you add your application as a jar file.
- Update the ELNApp5.x.x.lax file to include your editor classes in the classpath. If you use .class files (not collected in a .jar file) they will need to be located in the same directory as the .lax file, this will be your base ELN Client directory.
- Add a dummy file on the server so that the editor will by loaded by the client. The ELN client will see your editor as long as there is a file with your editor name in the /eln/applets/eln/editors directory of your server. For example, /eln/applets/eln/editors/ExampleELNEditor.class. This file is just a dummy file and can be empty. The next time you open the ELN Client through the SAM server you should see the button for your editor displayed on the editors panel. When your editor saves a notebook object to the ELN client, it will be added to the annotation list. When the ELN client's "Submit" button is clicked, all of the NObs in the annotation list will be sent to the notebook server. If the server understands the data type of your notebook object, it will be displayed to the user using a registered viewer. If not, the user will see a link to your data.