Search in sources :

Example 1 with SyncBeanDef

use of org.jboss.errai.ioc.client.container.SyncBeanDef in project kie-wb-common by kiegroup.

the class ClientDefinitionManager method init.

@PostConstruct
@SuppressWarnings("unchecked")
public void init() {
    // DefinitionSet client adapters.
    Collection<SyncBeanDef<DefinitionSetAdapter>> beanDefSetAdapters = beanManager.lookupBeans(DefinitionSetAdapter.class);
    for (SyncBeanDef<DefinitionSetAdapter> defSet : beanDefSetAdapters) {
        DefinitionSetAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // DefinitionSetRule client adapters.
    Collection<SyncBeanDef<DefinitionSetRuleAdapter>> beanDefSetRuleAdapters = beanManager.lookupBeans(DefinitionSetRuleAdapter.class);
    for (SyncBeanDef<DefinitionSetRuleAdapter> defSet : beanDefSetRuleAdapters) {
        DefinitionSetRuleAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // Definition client adapters.
    Collection<SyncBeanDef<DefinitionAdapter>> beanDefAdapters = beanManager.lookupBeans(DefinitionAdapter.class);
    for (SyncBeanDef<DefinitionAdapter> defSet : beanDefAdapters) {
        DefinitionAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // PropertySet client adapters.
    Collection<SyncBeanDef<PropertySetAdapter>> beanPropSetAdapters = beanManager.lookupBeans(PropertySetAdapter.class);
    for (SyncBeanDef<PropertySetAdapter> defSet : beanPropSetAdapters) {
        PropertySetAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // Property client adapters.
    Collection<SyncBeanDef<PropertyAdapter>> beanPropAdapters = beanManager.lookupBeans(PropertyAdapter.class);
    for (SyncBeanDef<PropertyAdapter> defSet : beanPropAdapters) {
        PropertyAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // Morph adapters.
    Collection<SyncBeanDef<MorphAdapter>> beanMorphAdapters = beanManager.lookupBeans(MorphAdapter.class);
    for (SyncBeanDef<MorphAdapter> morphAdapter : beanMorphAdapters) {
        MorphAdapter instance = morphAdapter.getInstance();
        addAdapter(instance);
    }
    // Once adapters present, add the Definition Sets found on current context.
    Collection<SyncBeanDef<DefinitionSetProxy>> beanDefSets = beanManager.lookupBeans(DefinitionSetProxy.class);
    for (SyncBeanDef<DefinitionSetProxy> defSet : beanDefSets) {
        DefinitionSetProxy definitionSetProxy = defSet.getInstance();
        Object definitionSet = definitionSetProxy.getDefinitionSet();
        addDefinitionSet(definitionSet);
    }
}
Also used : DefinitionSetProxy(org.kie.workbench.common.stunner.core.definition.DefinitionSetProxy) PropertySetAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertySetAdapter) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) DefinitionAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter) DefinitionSetAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetAdapter) DefinitionSetRuleAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetRuleAdapter) PropertyAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter) MorphAdapter(org.kie.workbench.common.stunner.core.definition.adapter.MorphAdapter) PostConstruct(javax.annotation.PostConstruct)

Example 2 with SyncBeanDef

use of org.jboss.errai.ioc.client.container.SyncBeanDef in project kie-wb-common by kiegroup.

the class FormGeneratorDriver method lookupComponent.

protected LayoutDragComponent lookupComponent(LayoutComponent layoutComponent) {
    Class<? extends LayoutDragComponent> clazz = componentsCache.get(layoutComponent.getDragTypeName());
    if (clazz == null) {
        SyncBeanDef dragTypeDef = beanManager.lookupBeans(layoutComponent.getDragTypeName()).iterator().next();
        componentsCache.put(layoutComponent.getDragTypeName(), dragTypeDef.getBeanClass());
        clazz = dragTypeDef.getBeanClass();
    }
    LayoutDragComponent dragComponent = instance.select(clazz).get();
    if (dragComponent instanceof FieldLayoutComponent) {
        FieldLayoutComponent fieldComponent = (FieldLayoutComponent) dragComponent;
        FieldDefinition field = renderingContext.getRootForm().getFieldById(layoutComponent.getProperties().get(FieldLayoutComponent.FIELD_ID));
        fieldComponent.init(renderingContext, field);
        layoutComponents.add(fieldComponent);
    }
    return dragComponent;
}
Also used : LayoutDragComponent(org.uberfire.ext.layout.editor.client.api.LayoutDragComponent) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef)

Example 3 with SyncBeanDef

use of org.jboss.errai.ioc.client.container.SyncBeanDef in project kie-wb-common by kiegroup.

the class DefaultWorkbenchFeaturesMenusHelperTest method createSyncBeanDef.

private <T> SyncBeanDef<T> createSyncBeanDef(Class<T> clazz) {
    final SyncBeanDef syncBeanDef = mock(SyncBeanDef.class);
    doReturn(mock(clazz)).when(syncBeanDef).getInstance();
    doReturn(mock(clazz)).when(syncBeanDef).newInstance();
    return syncBeanDef;
}
Also used : SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef)

Example 4 with SyncBeanDef

use of org.jboss.errai.ioc.client.container.SyncBeanDef in project kie-wb-common by kiegroup.

the class WorkbenchConfigurationMenu method setup.

@PostConstruct
public void setup() {
    final Collection<SyncBeanDef<WorkbenchConfigurationHandler>> handlerBeans = iocBeanManager.lookupBeans(WorkbenchConfigurationHandler.class);
    if (handlerBeans.size() > 0) {
        for (SyncBeanDef<WorkbenchConfigurationHandler> handlerBean : handlerBeans) {
            final WorkbenchConfigurationHandler activeHandler = handlerBean.getInstance();
            final String description = activeHandler.getDescription();
            final MenuItem menuItem = MenuFactory.newSimpleItem(description).respondsWith(new Command() {

                @Override
                public void execute() {
                    newResourcePresenter.show(activeHandler);
                }
            }).endMenu().build().getItems().get(0);
            workbenchConfigurationHandler.put(activeHandler, menuItem);
            items.add(menuItem);
        }
    }
    Collections.sort(items, new Comparator<MenuItem>() {

        @Override
        public int compare(final MenuItem o1, final MenuItem o2) {
            return o1.getCaption().compareToIgnoreCase(o2.getCaption());
        }
    });
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) PostConstruct(javax.annotation.PostConstruct)

Example 5 with SyncBeanDef

use of org.jboss.errai.ioc.client.container.SyncBeanDef in project kie-wb-common by kiegroup.

the class Classifier method init.

@PostConstruct
public void init() {
    // @Any doesn't work client side, so lookup instances using Errai's BeanManager
    final Collection<SyncBeanDef<ClientResourceType>> availableResourceTypes = iocManager.lookupBeans(ClientResourceType.class);
    for (final SyncBeanDef<ClientResourceType> resourceTypeBean : availableResourceTypes) {
        final ClientResourceType resourceType = resourceTypeBean.getInstance();
        resourceTypes.add(resourceType);
    }
    // Sort ResourceTypes so those with highest priority match first
    Collections.sort(resourceTypes, new Comparator<ClientResourceType>() {

        @Override
        public int compare(final ClientResourceType o1, final ClientResourceType o2) {
            int priority1 = o1.getPriority();
            int priority2 = o2.getPriority();
            if (priority1 == priority2) {
                return 0;
            }
            if (priority1 < priority2) {
                return 1;
            }
            return -1;
        }
    });
}
Also used : ClientResourceType(org.uberfire.client.workbench.type.ClientResourceType) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) PostConstruct(javax.annotation.PostConstruct)

Aggregations

SyncBeanDef (org.jboss.errai.ioc.client.container.SyncBeanDef)8 PostConstruct (javax.annotation.PostConstruct)6 ClientResourceType (org.uberfire.client.workbench.type.ClientResourceType)2 SyncBeanManager (org.jboss.errai.ioc.client.container.SyncBeanManager)1 FormGenerationResourcesProvider (org.kie.workbench.common.forms.adf.service.building.FormGenerationResourcesProvider)1 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)1 DefinitionSetProxy (org.kie.workbench.common.stunner.core.definition.DefinitionSetProxy)1 DefinitionAdapter (org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter)1 DefinitionSetAdapter (org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetAdapter)1 DefinitionSetRuleAdapter (org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetRuleAdapter)1 MorphAdapter (org.kie.workbench.common.stunner.core.definition.adapter.MorphAdapter)1 PropertyAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter)1 PropertySetAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertySetAdapter)1 MorphDefinitionProvider (org.kie.workbench.common.stunner.core.definition.morph.MorphDefinitionProvider)1 LayoutDragComponent (org.uberfire.ext.layout.editor.client.api.LayoutDragComponent)1 Command (org.uberfire.mvp.Command)1 MenuItem (org.uberfire.workbench.model.menu.MenuItem)1