Search in sources :

Example 1 with ChangeStructure

use of org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure in project jbosstools-hibernate by jbosstools.

the class HibernateJPARefactoring method createChange.

@Override
public Change createChange(IProgressMonitor pm) {
    // $NON-NLS-1$
    final CompositeChange cc = new CompositeChange("");
    for (int i = 0; i < changes.size(); i++) {
        ChangeStructure cs = changes.get(i);
        final String change_name = cs.path.toString();
        TextFileChange change = new TextFileChange(change_name, (IFile) cs.icu.getResource());
        change.setSaveMode(TextFileChange.LEAVE_DIRTY);
        change.setEdit(cs.textEdit);
        cs.change = change;
        cc.add(change);
    }
    cc.markAsSynthetic();
    return cc;
}
Also used : CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) ChangeStructure(org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure)

Example 2 with ChangeStructure

use of org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure 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

ChangeStructure (org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure)2 Iterator (java.util.Iterator)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)1 TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)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