ShowTable of Contents
The PlatformUI API gives you access to the Eclipse part of the Notes Client user interface: You can find out what the user is currently looking at, open new display areas for content (so called view parts) or bring existing ones to the front.
The API also contains helper classes to display message boxes and file/directory selection dialogs.
To use the PlatformUI API, call the method com.x2e.PlatformUIAPI.getUI(conn)
with a valid XPages2Eclipse connection object.
The resulting object of type IRemotePlatformUI
contains a useful helper method to write text to the Notes Client's status bar:
var conn=X2E.createConnection();
var pUI=com.x2e.PlatformUIAPI.getUI(conn);
pUI.logToStatusBar("Use the method 'logToStatusBar()' to write status and debug information");
var conn=X2E.createConnection();
var pUI=com.x2e.PlatformUIAPI.getUI(conn);
var msgBoxTools=pUI.getMessageBoxTools();
//the first parameter is a bit combination of an ICON_ constant and the button types (e.g. OK, CANCEL)
msgBoxTools.showMessageBox(2 /* ICON_INFORMATION */ | 32 /* OK */,"Title", "Information message");
For a complete reference of available message box icons and buttons, please refer to the
Javadocs for the IRemoteMessageBoxTools class in the API Javadocs.
The sample application for this wiki article demonstrates all valid icon/button combinations:
File and directory dialogs
Standard web technologies only offer simple upload controls to select and upload a single file in the browser.
By using the class IRemoteFileDialogTools
of the PlatformUI API for local XPages applications instead, you get support for multiple file selection, filetype filters and a directory selection dialog.
var conn=X2E.createConnection();
var platformUI=com.x2e.PlatformUIAPI.getUI(conn);
var fdTools=platformUI.getFileDialogTools();
var filterNames=["All images", "All files"];
var filterExt=["*.jpg;*.jpeg;*.png;*.gif", "*.*"];
var filterIndex=0;
var filterPath=null;
var fileName=null;
var overwrite=false;
var dlgText=null;
var selPathArr=fdTools.showFileDialog(4096 /* OPEN */ | 2 /* MULTI */, filterNames, filterExt, filterIndex, filterPath, fileName, overwrite, dlgText);
if (selPathArr && selPathArr.length>0) {
//do something with image paths in the array selPathArr
}
A directory selection dialog can be displayed by calling the method fdTools.showDirectoryDialog()
of the file dialog tools class:
var startPath="c:\\temp";
var selDirectoryPath=fdTools.showDirectoryDialog(String startPath, "Please select a directory to import");
if (selDirectoryPath) {
//do something with selected directory path
}
A directory selection dialog is used in the sample of the wiki article
JavaScript Jobs - Background operations developed in JavaScript: we let the user select one or more directories that will then be scanned recursively in background job developed in JavaScript. The purpose is to calculate MD5 checksums for each contained file in order to find duplicates.