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.

Using the Condition Builder UI widget

Using the Condition Builder UI widget

The Condition Builder UI widget provides Commerce Manager client users with an easy way to build conditional expressions to evaluate tags.


You can also create conditional expressions programmatically using the ConditionBuilder service.

The "widget" is an RCP Composite that is created using the com.elasticpath.cmclient.conditionbuilder.impl.tag.ConditionBuilderFactoryImpl class. The following code sample shows how it works.

private Composite displayConditionBuilder(final Composite parentComposite) {

     Application application = Application.getInstance();

     // get the tag operator service
     TagOperatorService tagOpService = (TagOperatorService)

     // get tag definitions from the custom dictionary
     TagDictionaryService dictionaryService = (TagDictionaryService)
     TagDictionary tagDictionary = dictionaryService.findByGuid(CUSTOM_DICTIONARY);
     Set<TagDefinition> tagDefinitions = tagDictionary.getTagDefinitions();

     ConditionBuilderFactoryImpl factory = new ConditionBuilderFactoryImpl();
     factory.setConditionBuilderTitle(""); //$NON-NLS-1$

               new ResourceAdapter<LogicalOperatorType>() {
                    public String getLocalizedResource(final LogicalOperatorType object) {
                         return AdminGCMessages.getMessage(object.getMessageKey());
                    } });

               new ResourceAdapter<String>() {
                    public String getLocalizedResource(final String object) {
                         return AdminGCMessages.getMessage(object);
                    } });

               new ActionEventListener<Object>() {
                    public void onEvent(final Object object) {
                    } });

     final Composite composite = factory.createFullUiFromModel(parentComposite, SWT.FLAT, this.logicalOperator);
     return composite;

Making the Condition Builder State Policy Aware

The plugin's State Policy is not automatically applied to the constituent controls of the Condition Builder composite. You must add a StateChangeTarget to the state policy container and override StateChangeTarget's setState to call EpControlFactory.changeEpStateForComposite. The first parameter to the changeEpStateForComposite is the Condition Builder composite. The second parameter is the new state.

The following example shows how to apply the state policy to those controls.

// apply the state policy to the condition builder widget
policyContainer.addTarget(new StateChangeTarget() {
    public void setState(final EpState state) {
        EpControlFactory.changeEpStateForComposite(composite, state);