Adding First Run Actions to a Plug-in
This procedure provides step-by-step instructions for adding first-run actions to a plug-in. It uses classes that are defined for Sabre Red 360.
Before you begin:
-
Add an Activator class to your plug-in. This Activator class controls the life cycle of the plug-in.
-
Add the com.sabre.edge.platform.optional.firstrun dependency to your plug-in.
-
In Package Explorer view, right-click the package name of your plug-in. Choose New > Class from the menu.
On the New Java Class dialog, you will extend com.sabre.edge.platform.optional.firstrun.worker.AbstractFirstRunWorker .
-
If the Package field is not populated, type the package name. In the Name field, type a name for your class.
In the example, the name is ExampleFirstRunWorker.
-
In Superclass, type com.sabre.edge.platform.optional.firstrun.worker.AbstractFirstRunWorker.
-
Select the following check boxes: * Constructors from superclass * Inherited abstract methods Click Finish.
After you click Finish, Eclipse displays the Java class source file.
-
In your Java code, implement the abstract method boolean performActions().
-
If your first run action interacts with the UI, you must implement this method in a UI thread.
-
Add your code for the first run action in this method.
-
The following code sample code shows the ExampleFirstRunWorker.java class and the performActions() method.
package com.sabre.redapp.example.firstrun.internal;
import com.sabre.redapp.example.firstrun.dialog.SampleFirstRunDialog;
import com.sabre.edge.platform.optional.firstrun.worker.AbstractFirstRunWorker;
/**
* Example implementation of worker to be started on first run.
*/
public class ExampleFirstRunWorker extends AbstractFirstRunWorker {
/**
* Implementation of actions to be performed on first run.
*
* @return returns true if OK was clicked on dialog, and false if
* it was Cancel.
*/
@Override
protected boolean performActions() {
SampleFirstRunDialog dialog = new SampleFirstRunDialog(getDisplay()
.getActiveShell());
int result = dialog.open();
return SampleFirstRunDialog.OK == result;
}
}
-
On the Extensions tab, click Add. On the New Extension dialog, add the com.sabre.edge.platform.optional.firstrun extension.
-
On the Extensions tab, right-click com.sabre.edge.platform.optional.firstrun. Choose New > client from the menu.
-
Add the following properties to the client element.
class |
In the class field, click Browse. On the Select Type dialog, select the class that you created in the Name field. |
versionId |
The versionId is an identifier that lets you force the startup of a task that has been started previously. The need to force the startup of a plug-in usually occurs after the plug-in is updated. |
You are done adding first run functionality to a plug-in.