ShowTable of Contents
The Symphony Add-on API of XPages2Eclipse builds a bridge between XPages applications and the embedded Symphony application of the Lotus Notes Client.
The API contains almost the whole set of classes and methods from the
Symphony SDK
that is available for Symphony version 3.
In short, it covers reading and writing data from/to Symphony Documents, Spreadsheets and Presentations. The full Javadoc for the supported classes is available
here in this product wiki.
Please note that for Lotus Notes 8.5.2, the embedded Symphony has to be updated to version 3 first (using the add-on installer available from IBM) to be able to use the XPages2Eclipse Symphony Add-on API.
However, this is not required for Lotus Notes 8.5.3, which will already contain the newest Symphony release.You get access to the embedded Symphony application instance by calling the method com.x2e.SymphonyAPI.getApplication(conn)
with a valid XPages2Eclipse connection object.
Afterwards you can use the available methods to work with the currently open content:
var conn=X2E.createConnection();
var app=com.x2e.SymphonyAPI.getApplication(conn);
//get a handle on the active Document, Spreadsheet or Presentation:
var activeDoc=app.getActiveDocument();
var activeSpreadsheet=app.getActiveSpreadsheet();
var activePresentation=app.getActivePresentation();
//access collections of all open Documents, Spreadsheets and Presentations
var documents=app.getDocuments();
var spreadsheets=app.getSpreadsheets();
var presentations=app.getPresentations();
Using the collection objects, you can create a new element:
var template=""; //String - Specifies the name of the template to be used, use "" for no template;
var asTemplate=false; //boolean - When a template is used, this parameter specifies true to creates a new
//untitled element based on the template, and it specifies false to load the template for editing. If no template is used, both true and false create a new untitled element.
var visible=true; //boolean - specifies true to open the new element in a visible window or tab, or false to open the new element in invisible mode
var newDoc=documents.addDocument(template, asTemplate, visible);
var newSpreadsheet=spreadsheets.addSpreadsheet(template, asTemplate, visible);
var newPresentation=spreadsheets.addPresentation(template, asTemplate, visible);
Our sample application is a sidebar add-on that reads the selected entries from an open Notes view and exports the view data to a new Symphony spreadsheet.
The sidebar add-on displays a small XPage in the sidebar of the Lotus Notes Client. The sidebar component is visible while the sample database is open, even when another database is focused. This is implemented by using a Composite Application that consists of two components: the main display area of the sample database and the always visible sidebar component.
The sidebar component consists of a single button. In the onClick event, we open a connection to XPages2Eclipse and use a useful method of the PartService in the PlatformUI API to get information about the active viewpart.
Afterwards, we try to convert this workbench part into a NotesUIView by leveraging the NotesUI API. If the user is actually looking at a Notes view, we start the export process. The export progress is visualized by a Monitoring Job of the Job API, so that the user can see the current export progress and is able to cancel the export operation.
var conn=X2E.createConnection();
var pUI=com.x2e.PlatformUIAPI.getUI(conn);
var wb=pUI.getWorkbench();
var activeWindow=wb.getActiveWorkbenchWindow();
var partService=activeWindow.getPartService();
//get a handle on the workbench part that was active right before
//the user clicked into this sidebar panel
var activeParts=partService.getLastActiveParts();
//element 0 of the list contains the sidebar panel's part
var partRef=activeParts.get(1);
var part=partRef.getPart(false);
if (!part)
return;
//use NotesUIWorkspace of UI API to convert the part into a NotesUIView
var notesUITools=com.x2e.NotesUIAPI.getTools(conn);
var ws=notesUITools.getNotesUIWorkspace();
var uiview=ws.getUIView(part);
if (!uiview) {
//no ui view found
var mbTools=pUI.getMessageBoxTools();
mbTools.showMessageBox(1+32 /* ERROR+OK */, "No Notes view", "Unable to locate the Notes view to export the data!");
return;
}
//prepare the execution of the export code:
//progress will be visualized by using a Monitoring Job
//(code is running in XPages context, the Job is only used
//for progress visualization)
var exportCallback=function(progMon) {
exportToSymphony(progMon, uiview);
}
Jobs.syncExec("Exporting view data", exportCallback);