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.