Search in sources :

Example 1 with JpaProjectManager

use of org.eclipse.jpt.jpa.core.JpaProjectManager in project jbosstools-hibernate by jbosstools.

the class HibernateJptPlugin method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    KnownConfigurations.getInstance().addConsoleConfigurationListener(new KnownConfigurationsAdapter() {

        private void revalidateProjects(ConsoleConfiguration ccfg) {
            // INFO: should revalidate project to calculate correct naming strategy's values
            JpaProjectManager manager = (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class);
            Iterator<JpaProject> jpaProjects = manager.getJpaProjects().iterator();
            while (jpaProjects.hasNext()) {
                JpaProject jpaProject = jpaProjects.next();
                if (jpaProject instanceof HibernateJpaProject) {
                    String ccName = ((HibernateJpaProject) jpaProject).getDefaultConsoleConfigurationName();
                    if (ccfg.getName().equals(ccName)) {
                        rebuildJpaProject(jpaProject.getJavaProject().getProject());
                    // jpaProject.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
                    }
                }
            }
        }

        @Override
        public void configurationBuilt(ConsoleConfiguration ccfg) {
            if (ccfg.getConfiguration() == null) {
                return;
            }
            revalidateProjects(ccfg);
        }

        @Override
        public void configurationRemoved(ConsoleConfiguration root, boolean forUpdate) {
            if (forUpdate) {
                return;
            }
            revalidateProjects(root);
        }
    });
}
Also used : KnownConfigurationsAdapter(org.hibernate.console.KnownConfigurationsAdapter) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) JpaProjectManager(org.eclipse.jpt.jpa.core.JpaProjectManager) Iterator(java.util.Iterator) JpaProject(org.eclipse.jpt.jpa.core.JpaProject)

Aggregations

Iterator (java.util.Iterator)1 JpaProject (org.eclipse.jpt.jpa.core.JpaProject)1 JpaProjectManager (org.eclipse.jpt.jpa.core.JpaProjectManager)1 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)1 KnownConfigurationsAdapter (org.hibernate.console.KnownConfigurationsAdapter)1