Package org.drools.workbench.screens.workitems.client.widget

Source Code of org.drools.workbench.screens.workitems.client.widget.WorkItemMetaDataLoader

package org.drools.workbench.screens.workitems.client.widget;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import org.drools.workbench.screens.workitems.model.WorkItemDefinitionElements;
import org.drools.workbench.screens.workitems.service.WorkItemsEditorService;
import org.jboss.errai.common.client.api.Caller;
import org.jboss.errai.common.client.api.RemoteCallback;
import org.kie.uberfire.client.callbacks.DefaultErrorCallback;

/**
* Loader for Work Items Editors meta-data.
*/
@ApplicationScoped
public class WorkItemMetaDataLoader {

    @Inject
    private Caller<WorkItemsEditorService> workItemsService;

    private WorkItemDefinitionElements metaContent = null;

    public void loadMetaContent( final HasWorkItemDefinitionElements handler ) {
        if ( metaContent == null ) {
            workItemsService.call( getMetaContentSuccessCallback( handler ),
                                   new DefaultErrorCallback() ).loadDefinitionElements();
        } else {
            handler.setDefinitionElements( metaContent );
        }
    }

    private RemoteCallback<WorkItemDefinitionElements> getMetaContentSuccessCallback( final HasWorkItemDefinitionElements handler ) {
        return new RemoteCallback<WorkItemDefinitionElements>() {

            @Override
            public void callback( final WorkItemDefinitionElements content ) {
                metaContent = content;
                handler.setDefinitionElements( content );
            }
        };
    }

}
TOP

Related Classes of org.drools.workbench.screens.workitems.client.widget.WorkItemMetaDataLoader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.