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);
}
}
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;
}
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;
}
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());
}
});
}
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;
}
});
}
Aggregations