Search in sources :

Example 1 with CompilationUnitCollector

use of org.hibernate.eclipse.jdt.ui.internal.jpa.collect.CompilationUnitCollector in project jbosstools-hibernate by jbosstools.

the class HibernateJPAWizardDataFactory method createHibernateJPAWizardData.

public static IHibernateJPAWizardData createHibernateJPAWizardData(final IStructuredSelection selection2Update, IHibernateJPAWizardParams params, int depth) {
    CompilationUnitCollector compileUnitCollector = new CompilationUnitCollector();
    @SuppressWarnings("rawtypes") Iterator itSelection2Update = selection2Update.iterator();
    while (itSelection2Update.hasNext()) {
        Object obj = itSelection2Update.next();
        compileUnitCollector.processJavaElements(obj, true);
    }
    Iterator<ICompilationUnit> it = compileUnitCollector.setSelectionCUIterator();
    AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
    collector.initCollector();
    while (it.hasNext()) {
        ICompilationUnit cu = it.next();
        collector.collect(cu, depth);
    }
    collector.resolveRelations();
    final Map<String, EntityInfo> entities = collector.getMapCUs_Info();
    params.performDisconnect();
    params.reCollectModification(entities);
    final ArrayList<ChangeStructure> changes = params.getChanges();
    IHibernateJPAWizardData data = new IHibernateJPAWizardData() {

        public Map<String, EntityInfo> getEntities() {
            return entities;
        }

        public ArrayList<ChangeStructure> getChanges() {
            return changes;
        }

        public IStructuredSelection getSelection2Update() {
            return selection2Update;
        }
    };
    return data;
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnitCollector(org.hibernate.eclipse.jdt.ui.internal.jpa.collect.CompilationUnitCollector) ChangeStructure(org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure) AllEntitiesInfoCollector(org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo) Iterator(java.util.Iterator)

Aggregations

Iterator (java.util.Iterator)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 AllEntitiesInfoCollector (org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector)1 CompilationUnitCollector (org.hibernate.eclipse.jdt.ui.internal.jpa.collect.CompilationUnitCollector)1 EntityInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo)1 ChangeStructure (org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure)1