Skip Navigation

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.

  1. 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 .

  1. 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.

  1. In Superclass, type com.sabre.edge.platform.optional.firstrun.worker.AbstractFirstRunWorker.

  1. Select the following check boxes: * Constructors from superclass * Inherited abstract methods Click Finish.

        After you click Finish, Eclipse displays the Java class source file.

  1. 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;
    }

}
  1. On the Extensions tab, click Add. On the New Extension dialog, add the com.sabre.edge.platform.optional.firstrun extension.

image091
  1. On the Extensions tab, right-click com.sabre.edge.platform.optional.firstrun. Choose New > client from the menu.

  1. 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.
In the example, the class name ExampleFirstRunWorker.

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 can increment this integer whenever you need to force a first-time launch of your plug-in. Type an integer in the field.

You are done adding first run functionality to a plug-in.