Mindoo Blog - Cutting edge technologies - About Java, Lotus Notes and iPhone

  • Lotusphere announcement: LS2Eclipse - Leverage Eclipse/Expeditor features in your Lotusscript code!

    Karsten Lehmann  11 January 2010 13:53:17
    If one of the following questions sound familiar, this blog article may be interesting for you:
    • You have Notes applications and want to bring them to the 21st century without rewriting everything in Java/JavaScript?
    • Your users often sit at their desk waiting for your Notes application because of a long running Lotusscript operation?
    • Composite Application technology looks interesting, but the Lotusscript APIs are not dynamic / powerful enough?
    • As a Lotusscript developer, you always hated it to hear those Java guys saying "That's easy. All you have to do is call this Eclipse API..." :-)
    During our own Notes/Domino development in the past years, we often needed Eclipse API functionality in places where it was not available, like a classic view action, a form or an agent.
    New features always got added to the "outside world", the Eclipse/Expeditor framework, but the classic Notes client and the Lotusscript language nearly stayed the same over the years.
    While Java development for Eclipse/Expeditor has many advantages compared to classic form/view development of Lotus Notes, it surely makes development more complex and you loose the rapid application development approach that Lotus Notes made so successful.
    In addition, long-time Notes users have an existing code base of thousands of lines of code, that they cannot simply rewrite in Java/JavaScript to create a new Java UI or XPages based application.

    We think that there is a missing piece between classic Notes and the Expeditor framework of Lotus Notes R8.x. This is our main use case for Mindoo LS2Eclipse.

    Mindoo LS2Eclipse is a bridging technology that makes Eclipse APIs accessible from Lotusscript code.

    The following image is a rough overview of the LS2Eclipse architecture:

    Image:Lotusphere announcement: LS2Eclipse - Leverage Eclipse/Expeditor features in your Lotusscript code!

    The installation kit contains an Eclipse plugin (packaged as a widget for easy deployment) and a set of Lotusscript libraries.
    Those libraries with a rich set of about 50 object-oriented Lotusscript classes give you access to many powerful Eclipse features, divided into the following 7 areas:

    The JobTools area is a key feature of the LS2Eclipse API. It is the key to running your application code in multiple threads, thus making it possible to keep the user interface responsive even if a long-running operation (e.g. storing an email in a CRM system on a Domino server) is active.
    Your Lotusscript code runs as a so called Eclipse Job, a background process that can optionally display a progress dialog with status/progress information.

    Feature overview:
    • Bridge between the Eclipse job framework and Notes agents
    • schedule the execution of an agent as an Eclipse background job
    • pass parameters to the job
    • jobs can report progress and can be cancelled on user request
    • Notes UI is responsive when job is running, job may change the UI during execution (e.g. to present the result)
    The PlatformUI area let's you read and interact with the Eclipse workbench, which is the graphical framework that is displaying the Lotus Notes client.

    Feature overview:
    • Read the structure of open windows, tabs and their contents (Eclipse views)
    • focus tabs, show/hide/minimize/maximize views
    • Access the side shelf, show/hide shelf views and toggle the shelf between collapsed, thin and expanded
    • show text in the status bar of the Notes client and show message boxes (e.g. to display information from a background agent job)
    The ComponentTools contain a set of tool classes to make Composite Applications more dynamic.

    Feature overview:
    • call Composite Application actions of components manually without a CA wire
    • dynamically create and show content like Notes data or a web browser view
    • modify the properties of components
    • read and modify the structure of a Composite Application (component/page preferences)
    • toggle between CA pages in your code (e.g. to create a custom navigator)
    • locate open views in the workbench based on their internal ids
    This area contains features of the new Java UI API in Lotus Notes 8.5.1. With it you can interact with the Notes client user interface, even if your code is running in a background job, where the standard NotesUIWorkspace is not available. In addition, you are no longer restricted to the active area of the screen to read/write data from/to a view or a document.

    Feature overview:
    • gives you access to the Notes UI even when your code is running in a background job
    • get a NotesUIDocument/NotesUIView handle for any area (IWorkbenchPart) of the screen, not just the active one
    • modify the NotesUIDocument's content, read the current selection from a NotesUIView
    • activate a view/document in the current page
    In the Notes client, an Eclipse perspective is the content of a main tab. The perspective tools give you access to all registered tabs in the system and they even allow for the creation of completely new tab layouts.

    Feature overview
    • get list of registered Eclipse perspectives (IPerspectiveRegistry)
    • clone existing perspectives
    • create and display your own Eclipse tab layouts (IPerspectiveFactory/IPageLayout etc.) on the fly
    The program tools contain platform independent APIs to registered file extensions in the OS.

    Feature overview
    • find associated programs by file extension
    • get list of registered file extensions in the system
    • launch files and urls
    Experts can use the ExtensionRegistryTools to add new Eclipse extensions to the IExtensionRegistry of the Eclipse framework.

    How does the code look like?

    We tried to name the Lotusscript objects similar to their corresponding Eclipse API objects. That way, you already know most of the important Eclipse APIs if you start coding in Java later on and searching for code snippets on the internet is made easier.
    To get a feeling for the API, here is a small code snippet:

    To create a new API connection, you use this syntax:

    Dim connection As EclipseConnection
    Set connection=EclipseConnectionManager.createConnection()

    To access the PlatformUI, type in this:

    Dim platfUI As PlatformUI
    Set platfUI=PlatformUIFactory.getInstance(connection)

    The IPartService is a class to get the currently active area (IWorkbenchPart) of the screen:

    Dim partService As IPartService
    Dim part As IWorkbenchPart
    Dim vpart as IViewPart
    Dim classes as EclipseAPIClasses
    Dim partTitle as String
    Dim partId as String
    Dim partSecondaryId as String

    Set classes=connection.EclipseAPIClasses 'helper to cast an object to another API object
    Set partService=platfUI.getWorkbench().getActiveWorkbenchWindow().getPartService()
    Set part=partService.getActivePart()
    If classes.IViewPart.isInstance(part) then
            'part is a IViewPart; this gives us additional properties
            Set vpart=classes.IViewPart.cast(part)
    End If

    Where to get the API

    The API is feature complete, but we still have some documentation to write. For example, I'm currently working on a database with test cases that may be handy to learn about the new features.
    It currently contains the following 12 cases:
    • Case 1 - Workbench information
    • Case 2 - PartService, get information about the active viewpart
    • Case 3 - Viewparts in the current page
    • Case 4 - Schedule background agent jobs
    • Case 5 - Change the UIDocument in another viewpart
    • Case 6 - Get the selection from a Notes view in another viewpart
    • Case 7 - Create new NSF viewparts in the current page
    • Case 8 - Create new NSF viewparts in a different tab
    • Case 9 - Manually call actions of CA components (change content of a document container)
    • Case 10 - Create a new Eclipse perspective layout with placeholders for new views
    • Case 11 - Compare selected documents in a new Eclipse perspective
    • Case 12 - Toggle the sidebar mode between collapsed/expanded/thin
    If you are interested and will be attending Lotusphere next week, come to our session about the new Java APIs of Lotus Notes 8.5.1 (BP203) on Wednesday from 3:00 until 4:00 pm or wake up early on Thursday to join us in our birds-of-a-feature session about "Application Architecture based on Composite Application technology" (BOF206) from 7:00 until 8:00 am.

    I will post an info in this blog, when a trial version of LS2Eclipse is available.