Example usage for org.springframework.ide.eclipse.beans.core BeansCorePlugin getModel

List of usage examples for org.springframework.ide.eclipse.beans.core BeansCorePlugin getModel

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.beans.core BeansCorePlugin getModel.

Prototype

public static IBeansModel getModel() 

Source Link

Document

Returns the singleton IBeansModel .

Usage

From source file:org.synyx.hades.eclipse.HadesUtils.java

/**
 * Returns all DAO beans for the given {@link IProject project}.
 * //from   w  w w .j av  a2s  .  c o  m
 * @param project
 * @return
 */
public static Set<IBean> getDaoBeansFor(IProject project) {

    IBeansProject beansProject = BeansCorePlugin.getModel().getProject(project);
    return beansProject == null ? new HashSet<IBean>() : beansProject.getBeans(getFactoryName());
}

From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java

public static IBean getDozerBeanForMappingFile(IFile mappingIFile) {
    Set<IBean> beans = new HashSet<IBean>();
    IBean returnBean = null;/*from  w  w  w  .j  av a 2 s . c o m*/

    //The mapping file that we are in
    File mappingFile = new File(mappingIFile.getName());
    String mappingFileName = mappingFile.getName();

    //First get direct references
    IBeansProject beansProject = BeansCorePlugin.getModel().getProject(mappingIFile.getProject());

    if (beansProject == null)
        return null;

    Set<IBeansConfig> tempConfigs = beansProject.getConfigs();

    if (tempConfigs == null)
        return null;

    //We need some File to later get allBeans from ConfigSets
    IFile someBeansModelFile = null;

    //check local beans
    for (IBeansConfig config : tempConfigs) {
        if (someBeansModelFile == null)
            someBeansModelFile = (IFile) config.getElementResource();

        beans.addAll(config.getBeans());
    }
    returnBean = getDozerBeanFromBeans(beans, mappingFileName);

    //no local bean for mappingfile found
    if (returnBean == null && someBeansModelFile != null) {
        //check configsets
        Set<IBean> allBeans = BeansEditorUtils.getBeansFromConfigSets(someBeansModelFile);
        returnBean = getDozerBeanFromBeans(allBeans, mappingFileName);
    }

    return returnBean;
}

From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java

public static String getClassNameForCCI(IFile mappingIFile, String customConverterId) {
    IBean bean = getDozerBeanForMappingFile(mappingIFile);

    if (bean == null)
        return null;

    BeansMapEntry beansMapEntry = getCCIModelElementForMappingFile(bean, customConverterId);

    if (beansMapEntry != null) {
        if (beansMapEntry.getValue() instanceof Bean) {
            Bean cciBean = (Bean) beansMapEntry.getValue();
            return cciBean.getBeanDefinition().getBeanClassName();
        } else if (beansMapEntry.getValue() instanceof BeanReference) {
            BeanReference beanRef = (BeanReference) beansMapEntry.getValue();
            String beanName = beanRef.getBeanName();

            Set<IBeansProject> projects = BeansCorePlugin.getModel().getProjects();
            for (IBeansProject beansProject : projects) {
                Set<IBeansConfig> tempConfigs = beansProject.getConfigs();
                for (IBeansConfig config : tempConfigs) {
                    IBean foundBean = config.getBean(beanName);
                    if (foundBean != null) {
                        return foundBean.getClassName();
                    }/*from  ww w . j av  a  2s.c o m*/
                }
            }
        }
    }

    return null;
}