Writing your first application
As of Moomba 0.9 (yet to be deployed) the Workbench requires an application to be declared via the org.karora.moomba.ui.applications extension point.
| Mutiple Applications The workbench only supports one application at a time. If there is more than one application in the runtime, then a dialog is displayed listing all the available applications. You can specify which application to run as the default application, via the moomba.application system property, by using the application id. If there is only one application available, then the workbench uses this application by default. |
The IApplication interface
The IApplication interface is part of the org.eclipse.equinox.app package). The interface consists of the following methods:
public interface IApplication { public Object start(IApplicationContext context) throws Exception; public void stop(); }
start - Starts the application with the given context and returns a result.
stop - Forces the running application to exit.
Writing a default application
For most applications, the following implementations of start and stop will be sufficient.
public Object start(IApplicationContext context) { Map arguments = context.getArguments(); final Display display = (Display)arguments.get(PlatformUI.DISPLAY);//PlatformUI.createDisplay(); try { int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) { return IApplication.EXIT_RESTART; } return IApplication.EXIT_OK; } finally { display.dispose(); } } public void stop() { final IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return; workbench.close(); }
Alternatively, a problem we had on a separate project was how to create a Login screen for the workbench - a very common use case. Under the RCP, you would implement the IApplication interface to call a login screen, and if authentication is successful, delegate to the workbench. This does essentially the same thing:
public class Application implements IApplication { LoginDialog loginDialog; public Object start(IApplicationContext context) throws Exception { int returnCode = IApplication.EXIT_OK; loginDialog = new LoginDialog(display); loginDialog.open(new IWindowCallback() { public void windowClosed(int returnCode) { if (returnCode == LoginDialog.DISPLAY_WORKBENCH) { Display display = PlatformUI.createDisplay(); try { returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); } finally { display.dispose(); } } } }); if (returnCode == PlatformUI.RETURN_RESTART) { return IApplication.EXIT_RESTART; return IApplication.EXIT_OK; } private PlatformUI getPlatform(Display display) { PlatformUI p = new PlatformUI(bundleContext); p.init(display); return p; } public void stop() { final IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return; workbench.close(); } }
Spring/OSGi configuration files
As of Moomba-0.9 there is no longer any support for defining applications as either OSGI services or Spring beans.
Plugin.XML definition
In the root directory of your project, you will need a file called "plugin.xml". If you're using Eclipse as your development environment, this file will most likely be created for you via the Plugin development environment. In this file, you will need something along the lines of the following:
<extension
id="application"
point="org.karora.moomba.ui.applications">
<application>
<run
class="org.karora.wiki.demo.Application">
</run>
</application>
</extension>
You can find out more about the org.karora.moomba.ui.applications extension point here: Applications - org.karora.moomba.ui.applications
MANIFEST.MF
If you haven't done so already, you should have an import package statement for "org.karora.moomba.ui". You should also have an export package statement for the package containing your application.
How Moomba Applications have evolved since 0.8
Prior to Moomba 0.9, the workbench recognised applications by them being exported as OSGI services (under the interface org.karora.moomba.platform.app.IApplication). If you were not running in an OSGI environment, they were detected by being registered as Spring beans. However Karora has since decided to focus even further on adherence to the Eclipse way of doing things which means using the Eclipse Extension Registry for detecting new extensions. This means Applications registered as Spring beans or OSGI services will no longer be recognised by the Moomba Workbench and will consequently not appear.

Add Comment