Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Understanding the Eclipse Workbench Lifecycle

Understanding the Eclipse Workbench Lifecycle

Commerce Manager utilizes the Eclipse Workbench to create its UI. The Workbench provides events that Commerce Manager can register code against, and Commerce Manager's com.elasticpath.cmclient.core.CorePlugin class exposes them for other plugins.

CorePlugin primarily uses Workbench pre- and post-startup events.

Pre-Startup Events

Pre-startup events are executed before the first Commerce Manager window is opened. At this point, Commerce Manager loads localized messages and strings.

Post-Startup Events

Post-startup events are executed when the window is opened, but before the application's main event loop starts.

Registering Code for Execution During Pre- and Post-Startup Events

CorePlugin allows you to register code to be executed during pre- and post- startup events.

To register a pre-startup event, call CorePlugin.registerPreStartupCallback().

To register a post-startup event, call CorePlugin.registerPostStartupCallback().

Both methods accept a Runnable. You do not need to provide the UI context when registering a Runnable, as the Runnable is executed within the UI thread.

Example: Hiding Action Sets on the Main Toolbar Post-Startup

@Override
public void start(final BundleContext context) throws Exception {
    super.start(context);
                
    //If change set is disabled or then remove change set toolbar from the CoolBar
    CorePlugin.registerPostStartupCallback(new HideActionSetRunnable(changeSetHideCondition, ACTION_SET_ID));
}

The code above registers a Runnable at bundle startup. When the UI thread executes the Runnable, it removes the change set action set from the main toolbar.